1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Copyright 2009 Wolfson Microelectronics
4 // Mark Brown <broonie@opensource.wolfsonmicro.com>
5
6 #include <linux/kernel.h>
7 #include <linux/string.h>
8 #include <linux/platform_device.h>
9 #include <linux/dma-mapping.h>
10 #include <linux/gpio.h>
11 #include <linux/export.h>
12
13 #include "irqs.h"
14 #include "map.h"
15
16 #include "devs.h"
17 #include <linux/platform_data/asoc-s3c.h>
18 #include "gpio-cfg.h"
19 #include "gpio-samsung.h"
20
s3c64xx_i2s_cfg_gpio(struct platform_device * pdev)21 static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
22 {
23 unsigned int base;
24
25 switch (pdev->id) {
26 case 0:
27 base = S3C64XX_GPD(0);
28 break;
29 case 1:
30 base = S3C64XX_GPE(0);
31 break;
32 case 2:
33 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
34 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
35 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
36 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
37 return 0;
38 default:
39 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
40 pdev->id);
41 return -EINVAL;
42 }
43
44 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
45
46 return 0;
47 }
48
49 static struct resource s3c64xx_iis0_resource[] = {
50 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
51 };
52
53 static struct s3c_audio_pdata i2s0_pdata = {
54 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
55 };
56
57 struct platform_device s3c64xx_device_iis0 = {
58 .name = "samsung-i2s",
59 .id = 0,
60 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
61 .resource = s3c64xx_iis0_resource,
62 .dev = {
63 .platform_data = &i2s0_pdata,
64 },
65 };
66 EXPORT_SYMBOL(s3c64xx_device_iis0);
67
68 static struct resource s3c64xx_iis1_resource[] = {
69 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
70 };
71
72 static struct s3c_audio_pdata i2s1_pdata = {
73 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
74 };
75
76 struct platform_device s3c64xx_device_iis1 = {
77 .name = "samsung-i2s",
78 .id = 1,
79 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
80 .resource = s3c64xx_iis1_resource,
81 .dev = {
82 .platform_data = &i2s1_pdata,
83 },
84 };
85 EXPORT_SYMBOL(s3c64xx_device_iis1);
86