Krzysztof Kozlowski | 28a196f | 2017-12-25 20:54:33 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // |
| 3 | // Copyright 2009 Wolfson Microelectronics |
| 4 | // Mark Brown <broonie@opensource.wolfsonmicro.com> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 5 | |
| 6 | #include <linux/kernel.h> |
| 7 | #include <linux/string.h> |
| 8 | #include <linux/platform_device.h> |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 9 | #include <linux/dma-mapping.h> |
Kukjin Kim | 1c739c7 | 2010-08-05 07:54:49 +0900 | [diff] [blame] | 10 | #include <linux/gpio.h> |
Paul Gortmaker | dc28094 | 2011-07-31 16:17:29 -0400 | [diff] [blame] | 11 | #include <linux/export.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 12 | |
| 13 | #include <mach/irqs.h> |
| 14 | #include <mach/map.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 15 | #include <mach/dma.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 16 | |
| 17 | #include <plat/devs.h> |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 18 | #include <linux/platform_data/asoc-s3c.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 19 | #include <plat/gpio-cfg.h> |
Linus Walleij | b0161ca | 2014-01-14 14:24:24 +0100 | [diff] [blame] | 20 | #include <mach/gpio-samsung.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 21 | |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 22 | static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev) |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 23 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 24 | unsigned int base; |
| 25 | |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 26 | switch (pdev->id) { |
| 27 | case 0: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 28 | base = S3C64XX_GPD(0); |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 29 | break; |
| 30 | case 1: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 31 | base = S3C64XX_GPE(0); |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 32 | break; |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 33 | case 2: |
| 34 | s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5)); |
| 35 | s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5)); |
| 36 | s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5)); |
| 37 | s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5)); |
| 38 | return 0; |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 39 | default: |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 40 | printk(KERN_DEBUG "Invalid I2S Controller number: %d\n", |
| 41 | pdev->id); |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 42 | return -EINVAL; |
| 43 | } |
| 44 | |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 45 | s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3)); |
| 46 | |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 47 | return 0; |
| 48 | } |
| 49 | |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 50 | static struct resource s3c64xx_iis0_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 51 | [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256), |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 52 | }; |
| 53 | |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 54 | static struct s3c_audio_pdata i2s0_pdata = { |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 55 | .cfg_gpio = s3c64xx_i2s_cfg_gpio, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | struct platform_device s3c64xx_device_iis0 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame] | 59 | .name = "samsung-i2s", |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 60 | .id = 0, |
| 61 | .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource), |
| 62 | .resource = s3c64xx_iis0_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 63 | .dev = { |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 64 | .platform_data = &i2s0_pdata, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 65 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 66 | }; |
| 67 | EXPORT_SYMBOL(s3c64xx_device_iis0); |
| 68 | |
| 69 | static struct resource s3c64xx_iis1_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 70 | [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256), |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | static struct s3c_audio_pdata i2s1_pdata = { |
| 74 | .cfg_gpio = s3c64xx_i2s_cfg_gpio, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 75 | }; |
| 76 | |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 77 | struct platform_device s3c64xx_device_iis1 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame] | 78 | .name = "samsung-i2s", |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 79 | .id = 1, |
| 80 | .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource), |
| 81 | .resource = s3c64xx_iis1_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 82 | .dev = { |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 83 | .platform_data = &i2s1_pdata, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 84 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 85 | }; |
| 86 | EXPORT_SYMBOL(s3c64xx_device_iis1); |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 87 | |
| 88 | static struct resource s3c64xx_iisv4_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 89 | [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256), |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 90 | }; |
| 91 | |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 92 | static struct s3c_audio_pdata i2sv4_pdata = { |
| 93 | .cfg_gpio = s3c64xx_i2s_cfg_gpio, |
| 94 | .type = { |
Krzysztof Kozlowski | 409c69b | 2016-12-10 11:51:11 +0200 | [diff] [blame] | 95 | .quirks = QUIRK_PRI_6CHAN, |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 96 | }, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | struct platform_device s3c64xx_device_iisv4 = { |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 100 | .name = "samsung-i2s", |
| 101 | .id = 2, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 102 | .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource), |
| 103 | .resource = s3c64xx_iisv4_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 104 | .dev = { |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 105 | .platform_data = &i2sv4_pdata, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 106 | }, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 107 | }; |
| 108 | EXPORT_SYMBOL(s3c64xx_device_iisv4); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 109 | |
| 110 | |
| 111 | /* PCM Controller platform_devices */ |
| 112 | |
| 113 | static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev) |
| 114 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 115 | unsigned int base; |
| 116 | |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 117 | switch (pdev->id) { |
| 118 | case 0: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 119 | base = S3C64XX_GPD(0); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 120 | break; |
| 121 | case 1: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 122 | base = S3C64XX_GPE(0); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 123 | break; |
| 124 | default: |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 125 | printk(KERN_DEBUG "Invalid PCM Controller number: %d\n", |
| 126 | pdev->id); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 127 | return -EINVAL; |
| 128 | } |
| 129 | |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 130 | s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2)); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | static struct resource s3c64xx_pcm0_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 135 | [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256), |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 136 | }; |
| 137 | |
Mark Brown | 43f0de8 | 2009-11-27 16:43:53 +0000 | [diff] [blame] | 138 | static struct s3c_audio_pdata s3c_pcm0_pdata = { |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 139 | .cfg_gpio = s3c64xx_pcm_cfg_gpio, |
| 140 | }; |
| 141 | |
| 142 | struct platform_device s3c64xx_device_pcm0 = { |
| 143 | .name = "samsung-pcm", |
| 144 | .id = 0, |
| 145 | .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource), |
| 146 | .resource = s3c64xx_pcm0_resource, |
| 147 | .dev = { |
| 148 | .platform_data = &s3c_pcm0_pdata, |
| 149 | }, |
| 150 | }; |
| 151 | EXPORT_SYMBOL(s3c64xx_device_pcm0); |
| 152 | |
| 153 | static struct resource s3c64xx_pcm1_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 154 | [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256), |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 155 | }; |
| 156 | |
Mark Brown | 43f0de8 | 2009-11-27 16:43:53 +0000 | [diff] [blame] | 157 | static struct s3c_audio_pdata s3c_pcm1_pdata = { |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 158 | .cfg_gpio = s3c64xx_pcm_cfg_gpio, |
| 159 | }; |
| 160 | |
| 161 | struct platform_device s3c64xx_device_pcm1 = { |
| 162 | .name = "samsung-pcm", |
| 163 | .id = 1, |
| 164 | .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource), |
| 165 | .resource = s3c64xx_pcm1_resource, |
| 166 | .dev = { |
| 167 | .platform_data = &s3c_pcm1_pdata, |
| 168 | }, |
| 169 | }; |
| 170 | EXPORT_SYMBOL(s3c64xx_device_pcm1); |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 171 | |
| 172 | /* AC97 Controller platform devices */ |
| 173 | |
| 174 | static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev) |
| 175 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 176 | return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev) |
| 180 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 181 | return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | static struct resource s3c64xx_ac97_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 185 | [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256), |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 186 | [1] = DEFINE_RES_IRQ(IRQ_AC97), |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 187 | }; |
| 188 | |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 189 | static struct s3c_audio_pdata s3c_ac97_pdata = { |
Arnd Bergmann | b9a1a74 | 2015-11-18 15:25:23 +0100 | [diff] [blame] | 190 | }; |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 191 | |
| 192 | static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32); |
| 193 | |
| 194 | struct platform_device s3c64xx_device_ac97 = { |
Jassi Brar | e610467 | 2010-11-22 15:36:00 +0900 | [diff] [blame] | 195 | .name = "samsung-ac97", |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 196 | .id = -1, |
| 197 | .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource), |
| 198 | .resource = s3c64xx_ac97_resource, |
| 199 | .dev = { |
| 200 | .platform_data = &s3c_ac97_pdata, |
| 201 | .dma_mask = &s3c64xx_ac97_dmamask, |
| 202 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 203 | }, |
| 204 | }; |
| 205 | EXPORT_SYMBOL(s3c64xx_device_ac97); |
| 206 | |
| 207 | void __init s3c64xx_ac97_setup_gpio(int num) |
| 208 | { |
| 209 | if (num == S3C64XX_AC97_GPD) |
| 210 | s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd; |
| 211 | else |
| 212 | s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe; |
| 213 | } |