Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/plat-s3c/dev-audio.c |
| 2 | * |
| 3 | * Copyright 2009 Wolfson Microelectronics |
| 4 | * Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 5 | * |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/string.h> |
| 13 | #include <linux/platform_device.h> |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 14 | #include <linux/dma-mapping.h> |
Kukjin Kim | 1c739c7 | 2010-08-05 07:54:49 +0900 | [diff] [blame] | 15 | #include <linux/gpio.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 16 | |
| 17 | #include <mach/irqs.h> |
| 18 | #include <mach/map.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 19 | #include <mach/dma.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 20 | |
| 21 | #include <plat/devs.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 22 | #include <plat/audio.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 23 | #include <plat/gpio-cfg.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 24 | |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 25 | static int s3c64xx_i2sv3_cfg_gpio(struct platform_device *pdev) |
| 26 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 27 | unsigned int base; |
| 28 | |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 29 | switch (pdev->id) { |
| 30 | case 0: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 31 | base = S3C64XX_GPD(0); |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 32 | break; |
| 33 | case 1: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 34 | base = S3C64XX_GPE(0); |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 35 | break; |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 36 | default: |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 37 | printk(KERN_DEBUG "Invalid I2S Controller number: %d\n", |
| 38 | pdev->id); |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 39 | return -EINVAL; |
| 40 | } |
| 41 | |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 42 | s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3)); |
| 43 | |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | static int s3c64xx_i2sv4_cfg_gpio(struct platform_device *pdev) |
| 48 | { |
Ben Dooks | f532176 | 2010-05-27 14:57:27 +0900 | [diff] [blame] | 49 | s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5)); |
| 50 | s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5)); |
| 51 | s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5)); |
Mark Brown | dff2126 | 2010-10-14 07:53:12 +0900 | [diff] [blame] | 52 | s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5)); |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 57 | static struct resource s3c64xx_iis0_resource[] = { |
| 58 | [0] = { |
| 59 | .start = S3C64XX_PA_IIS0, |
| 60 | .end = S3C64XX_PA_IIS0 + 0x100 - 1, |
| 61 | .flags = IORESOURCE_MEM, |
| 62 | }, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 63 | [1] = { |
| 64 | .start = DMACH_I2S0_OUT, |
| 65 | .end = DMACH_I2S0_OUT, |
| 66 | .flags = IORESOURCE_DMA, |
| 67 | }, |
| 68 | [2] = { |
| 69 | .start = DMACH_I2S0_IN, |
| 70 | .end = DMACH_I2S0_IN, |
| 71 | .flags = IORESOURCE_DMA, |
| 72 | }, |
| 73 | }; |
| 74 | |
Mark Brown | 8dcdd6e | 2010-01-20 13:06:04 +0000 | [diff] [blame] | 75 | static struct s3c_audio_pdata s3c_i2s0_pdata = { |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 76 | .cfg_gpio = s3c64xx_i2sv3_cfg_gpio, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | struct platform_device s3c64xx_device_iis0 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame^] | 80 | .name = "samsung-i2s", |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 81 | .id = 0, |
| 82 | .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource), |
| 83 | .resource = s3c64xx_iis0_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 84 | .dev = { |
| 85 | .platform_data = &s3c_i2s0_pdata, |
| 86 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 87 | }; |
| 88 | EXPORT_SYMBOL(s3c64xx_device_iis0); |
| 89 | |
| 90 | static struct resource s3c64xx_iis1_resource[] = { |
| 91 | [0] = { |
| 92 | .start = S3C64XX_PA_IIS1, |
| 93 | .end = S3C64XX_PA_IIS1 + 0x100 - 1, |
| 94 | .flags = IORESOURCE_MEM, |
| 95 | }, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 96 | [1] = { |
| 97 | .start = DMACH_I2S1_OUT, |
| 98 | .end = DMACH_I2S1_OUT, |
| 99 | .flags = IORESOURCE_DMA, |
| 100 | }, |
| 101 | [2] = { |
| 102 | .start = DMACH_I2S1_IN, |
| 103 | .end = DMACH_I2S1_IN, |
| 104 | .flags = IORESOURCE_DMA, |
| 105 | }, |
| 106 | }; |
| 107 | |
Mark Brown | 8dcdd6e | 2010-01-20 13:06:04 +0000 | [diff] [blame] | 108 | static struct s3c_audio_pdata s3c_i2s1_pdata = { |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 109 | .cfg_gpio = s3c64xx_i2sv3_cfg_gpio, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | struct platform_device s3c64xx_device_iis1 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame^] | 113 | .name = "samsung-i2s", |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 114 | .id = 1, |
| 115 | .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource), |
| 116 | .resource = s3c64xx_iis1_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 117 | .dev = { |
| 118 | .platform_data = &s3c_i2s1_pdata, |
| 119 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 120 | }; |
| 121 | EXPORT_SYMBOL(s3c64xx_device_iis1); |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 122 | |
| 123 | static struct resource s3c64xx_iisv4_resource[] = { |
| 124 | [0] = { |
| 125 | .start = S3C64XX_PA_IISV4, |
| 126 | .end = S3C64XX_PA_IISV4 + 0x100 - 1, |
| 127 | .flags = IORESOURCE_MEM, |
| 128 | }, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 129 | [1] = { |
| 130 | .start = DMACH_HSI_I2SV40_TX, |
| 131 | .end = DMACH_HSI_I2SV40_TX, |
| 132 | .flags = IORESOURCE_DMA, |
| 133 | }, |
| 134 | [2] = { |
| 135 | .start = DMACH_HSI_I2SV40_RX, |
| 136 | .end = DMACH_HSI_I2SV40_RX, |
| 137 | .flags = IORESOURCE_DMA, |
| 138 | }, |
| 139 | }; |
| 140 | |
Mark Brown | 8dcdd6e | 2010-01-20 13:06:04 +0000 | [diff] [blame] | 141 | static struct s3c_audio_pdata s3c_i2sv4_pdata = { |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 142 | .cfg_gpio = s3c64xx_i2sv4_cfg_gpio, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | struct platform_device s3c64xx_device_iisv4 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame^] | 146 | .name = "samsung-i2s-v4", |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 147 | .id = -1, |
| 148 | .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource), |
| 149 | .resource = s3c64xx_iisv4_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 150 | .dev = { |
| 151 | .platform_data = &s3c_i2sv4_pdata, |
| 152 | }, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 153 | }; |
| 154 | EXPORT_SYMBOL(s3c64xx_device_iisv4); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 155 | |
| 156 | |
| 157 | /* PCM Controller platform_devices */ |
| 158 | |
| 159 | static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev) |
| 160 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 161 | unsigned int base; |
| 162 | |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 163 | switch (pdev->id) { |
| 164 | case 0: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 165 | base = S3C64XX_GPD(0); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 166 | break; |
| 167 | case 1: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 168 | base = S3C64XX_GPE(0); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 169 | break; |
| 170 | default: |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 171 | printk(KERN_DEBUG "Invalid PCM Controller number: %d\n", |
| 172 | pdev->id); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 173 | return -EINVAL; |
| 174 | } |
| 175 | |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 176 | s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2)); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 177 | return 0; |
| 178 | } |
| 179 | |
| 180 | static struct resource s3c64xx_pcm0_resource[] = { |
| 181 | [0] = { |
| 182 | .start = S3C64XX_PA_PCM0, |
| 183 | .end = S3C64XX_PA_PCM0 + 0x100 - 1, |
| 184 | .flags = IORESOURCE_MEM, |
| 185 | }, |
| 186 | [1] = { |
| 187 | .start = DMACH_PCM0_TX, |
| 188 | .end = DMACH_PCM0_TX, |
| 189 | .flags = IORESOURCE_DMA, |
| 190 | }, |
| 191 | [2] = { |
| 192 | .start = DMACH_PCM0_RX, |
| 193 | .end = DMACH_PCM0_RX, |
| 194 | .flags = IORESOURCE_DMA, |
| 195 | }, |
| 196 | }; |
| 197 | |
Mark Brown | 43f0de8 | 2009-11-27 16:43:53 +0000 | [diff] [blame] | 198 | static struct s3c_audio_pdata s3c_pcm0_pdata = { |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 199 | .cfg_gpio = s3c64xx_pcm_cfg_gpio, |
| 200 | }; |
| 201 | |
| 202 | struct platform_device s3c64xx_device_pcm0 = { |
| 203 | .name = "samsung-pcm", |
| 204 | .id = 0, |
| 205 | .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource), |
| 206 | .resource = s3c64xx_pcm0_resource, |
| 207 | .dev = { |
| 208 | .platform_data = &s3c_pcm0_pdata, |
| 209 | }, |
| 210 | }; |
| 211 | EXPORT_SYMBOL(s3c64xx_device_pcm0); |
| 212 | |
| 213 | static struct resource s3c64xx_pcm1_resource[] = { |
| 214 | [0] = { |
| 215 | .start = S3C64XX_PA_PCM1, |
| 216 | .end = S3C64XX_PA_PCM1 + 0x100 - 1, |
| 217 | .flags = IORESOURCE_MEM, |
| 218 | }, |
| 219 | [1] = { |
| 220 | .start = DMACH_PCM1_TX, |
| 221 | .end = DMACH_PCM1_TX, |
| 222 | .flags = IORESOURCE_DMA, |
| 223 | }, |
| 224 | [2] = { |
| 225 | .start = DMACH_PCM1_RX, |
| 226 | .end = DMACH_PCM1_RX, |
| 227 | .flags = IORESOURCE_DMA, |
| 228 | }, |
| 229 | }; |
| 230 | |
Mark Brown | 43f0de8 | 2009-11-27 16:43:53 +0000 | [diff] [blame] | 231 | static struct s3c_audio_pdata s3c_pcm1_pdata = { |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 232 | .cfg_gpio = s3c64xx_pcm_cfg_gpio, |
| 233 | }; |
| 234 | |
| 235 | struct platform_device s3c64xx_device_pcm1 = { |
| 236 | .name = "samsung-pcm", |
| 237 | .id = 1, |
| 238 | .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource), |
| 239 | .resource = s3c64xx_pcm1_resource, |
| 240 | .dev = { |
| 241 | .platform_data = &s3c_pcm1_pdata, |
| 242 | }, |
| 243 | }; |
| 244 | EXPORT_SYMBOL(s3c64xx_device_pcm1); |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 245 | |
| 246 | /* AC97 Controller platform devices */ |
| 247 | |
| 248 | static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev) |
| 249 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 250 | 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] | 251 | } |
| 252 | |
| 253 | static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev) |
| 254 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 255 | 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] | 256 | } |
| 257 | |
| 258 | static struct resource s3c64xx_ac97_resource[] = { |
| 259 | [0] = { |
| 260 | .start = S3C64XX_PA_AC97, |
| 261 | .end = S3C64XX_PA_AC97 + 0x100 - 1, |
| 262 | .flags = IORESOURCE_MEM, |
| 263 | }, |
| 264 | [1] = { |
| 265 | .start = DMACH_AC97_PCMOUT, |
| 266 | .end = DMACH_AC97_PCMOUT, |
| 267 | .flags = IORESOURCE_DMA, |
| 268 | }, |
| 269 | [2] = { |
| 270 | .start = DMACH_AC97_PCMIN, |
| 271 | .end = DMACH_AC97_PCMIN, |
| 272 | .flags = IORESOURCE_DMA, |
| 273 | }, |
| 274 | [3] = { |
| 275 | .start = DMACH_AC97_MICIN, |
| 276 | .end = DMACH_AC97_MICIN, |
| 277 | .flags = IORESOURCE_DMA, |
| 278 | }, |
| 279 | [4] = { |
| 280 | .start = IRQ_AC97, |
| 281 | .end = IRQ_AC97, |
| 282 | .flags = IORESOURCE_IRQ, |
| 283 | }, |
| 284 | }; |
| 285 | |
| 286 | static struct s3c_audio_pdata s3c_ac97_pdata; |
| 287 | |
| 288 | static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32); |
| 289 | |
| 290 | struct platform_device s3c64xx_device_ac97 = { |
| 291 | .name = "s3c-ac97", |
| 292 | .id = -1, |
| 293 | .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource), |
| 294 | .resource = s3c64xx_ac97_resource, |
| 295 | .dev = { |
| 296 | .platform_data = &s3c_ac97_pdata, |
| 297 | .dma_mask = &s3c64xx_ac97_dmamask, |
| 298 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 299 | }, |
| 300 | }; |
| 301 | EXPORT_SYMBOL(s3c64xx_device_ac97); |
| 302 | |
| 303 | void __init s3c64xx_ac97_setup_gpio(int num) |
| 304 | { |
| 305 | if (num == S3C64XX_AC97_GPD) |
| 306 | s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd; |
| 307 | else |
| 308 | s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe; |
| 309 | } |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 310 | |
| 311 | static u64 s3c_device_audio_dmamask = 0xffffffffUL; |
| 312 | |
| 313 | struct platform_device s3c_device_pcm = { |
| 314 | .name = "s3c24xx-pcm-audio", |
| 315 | .id = -1, |
| 316 | .dev = { |
| 317 | .dma_mask = &s3c_device_audio_dmamask, |
| 318 | .coherent_dma_mask = 0xffffffffUL |
| 319 | } |
| 320 | }; |
| 321 | EXPORT_SYMBOL(s3c_device_pcm); |
| 322 | |