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> |
| 14 | |
| 15 | #include <mach/irqs.h> |
| 16 | #include <mach/map.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 17 | #include <mach/dma.h> |
| 18 | #include <mach/gpio.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 19 | |
| 20 | #include <plat/devs.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 21 | #include <plat/audio.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 22 | #include <plat/gpio-cfg.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 23 | |
Ben Dooks | 3501c9a | 2010-01-26 10:45:40 +0900 | [diff] [blame^] | 24 | #include <mach/gpio-bank-c.h> |
| 25 | #include <mach/gpio-bank-d.h> |
| 26 | #include <mach/gpio-bank-e.h> |
| 27 | #include <mach/gpio-bank-h.h> |
| 28 | |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 29 | static int s3c64xx_i2sv3_cfg_gpio(struct platform_device *pdev) |
| 30 | { |
| 31 | switch (pdev->id) { |
| 32 | case 0: |
| 33 | s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK); |
| 34 | s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK); |
| 35 | s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_I2S0_LRCLK); |
| 36 | s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_I2S0_DI); |
| 37 | s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_I2S0_D0); |
| 38 | break; |
| 39 | case 1: |
| 40 | s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_I2S1_CLK); |
| 41 | s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_I2S1_CDCLK); |
| 42 | s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_I2S1_LRCLK); |
| 43 | s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_I2S1_DI); |
| 44 | s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_I2S1_D0); |
| 45 | default: |
| 46 | printk(KERN_DEBUG "Invalid I2S Controller number!"); |
| 47 | return -EINVAL; |
| 48 | } |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | static int s3c64xx_i2sv4_cfg_gpio(struct platform_device *pdev) |
| 54 | { |
Mark Brown | 1c24522 | 2010-01-20 12:05:55 +0000 | [diff] [blame] | 55 | s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C64XX_GPC4_I2S_V40_DO0); |
| 56 | s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C64XX_GPC5_I2S_V40_DO1); |
| 57 | s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C64XX_GPC7_I2S_V40_DO2); |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 58 | s3c_gpio_cfgpin(S3C64XX_GPH(6), S3C64XX_GPH6_I2S_V40_BCLK); |
| 59 | s3c_gpio_cfgpin(S3C64XX_GPH(7), S3C64XX_GPH7_I2S_V40_CDCLK); |
| 60 | s3c_gpio_cfgpin(S3C64XX_GPH(8), S3C64XX_GPH8_I2S_V40_LRCLK); |
| 61 | s3c_gpio_cfgpin(S3C64XX_GPH(9), S3C64XX_GPH9_I2S_V40_DI); |
| 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 66 | static struct resource s3c64xx_iis0_resource[] = { |
| 67 | [0] = { |
| 68 | .start = S3C64XX_PA_IIS0, |
| 69 | .end = S3C64XX_PA_IIS0 + 0x100 - 1, |
| 70 | .flags = IORESOURCE_MEM, |
| 71 | }, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 72 | [1] = { |
| 73 | .start = DMACH_I2S0_OUT, |
| 74 | .end = DMACH_I2S0_OUT, |
| 75 | .flags = IORESOURCE_DMA, |
| 76 | }, |
| 77 | [2] = { |
| 78 | .start = DMACH_I2S0_IN, |
| 79 | .end = DMACH_I2S0_IN, |
| 80 | .flags = IORESOURCE_DMA, |
| 81 | }, |
| 82 | }; |
| 83 | |
Mark Brown | 8dcdd6e | 2010-01-20 13:06:04 +0000 | [diff] [blame] | 84 | static struct s3c_audio_pdata s3c_i2s0_pdata = { |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 85 | .cfg_gpio = s3c64xx_i2sv3_cfg_gpio, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | struct platform_device s3c64xx_device_iis0 = { |
| 89 | .name = "s3c64xx-iis", |
| 90 | .id = 0, |
| 91 | .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource), |
| 92 | .resource = s3c64xx_iis0_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 93 | .dev = { |
| 94 | .platform_data = &s3c_i2s0_pdata, |
| 95 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 96 | }; |
| 97 | EXPORT_SYMBOL(s3c64xx_device_iis0); |
| 98 | |
| 99 | static struct resource s3c64xx_iis1_resource[] = { |
| 100 | [0] = { |
| 101 | .start = S3C64XX_PA_IIS1, |
| 102 | .end = S3C64XX_PA_IIS1 + 0x100 - 1, |
| 103 | .flags = IORESOURCE_MEM, |
| 104 | }, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 105 | [1] = { |
| 106 | .start = DMACH_I2S1_OUT, |
| 107 | .end = DMACH_I2S1_OUT, |
| 108 | .flags = IORESOURCE_DMA, |
| 109 | }, |
| 110 | [2] = { |
| 111 | .start = DMACH_I2S1_IN, |
| 112 | .end = DMACH_I2S1_IN, |
| 113 | .flags = IORESOURCE_DMA, |
| 114 | }, |
| 115 | }; |
| 116 | |
Mark Brown | 8dcdd6e | 2010-01-20 13:06:04 +0000 | [diff] [blame] | 117 | static struct s3c_audio_pdata s3c_i2s1_pdata = { |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 118 | .cfg_gpio = s3c64xx_i2sv3_cfg_gpio, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | struct platform_device s3c64xx_device_iis1 = { |
| 122 | .name = "s3c64xx-iis", |
| 123 | .id = 1, |
| 124 | .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource), |
| 125 | .resource = s3c64xx_iis1_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 126 | .dev = { |
| 127 | .platform_data = &s3c_i2s1_pdata, |
| 128 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 129 | }; |
| 130 | EXPORT_SYMBOL(s3c64xx_device_iis1); |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 131 | |
| 132 | static struct resource s3c64xx_iisv4_resource[] = { |
| 133 | [0] = { |
| 134 | .start = S3C64XX_PA_IISV4, |
| 135 | .end = S3C64XX_PA_IISV4 + 0x100 - 1, |
| 136 | .flags = IORESOURCE_MEM, |
| 137 | }, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 138 | [1] = { |
| 139 | .start = DMACH_HSI_I2SV40_TX, |
| 140 | .end = DMACH_HSI_I2SV40_TX, |
| 141 | .flags = IORESOURCE_DMA, |
| 142 | }, |
| 143 | [2] = { |
| 144 | .start = DMACH_HSI_I2SV40_RX, |
| 145 | .end = DMACH_HSI_I2SV40_RX, |
| 146 | .flags = IORESOURCE_DMA, |
| 147 | }, |
| 148 | }; |
| 149 | |
Mark Brown | 8dcdd6e | 2010-01-20 13:06:04 +0000 | [diff] [blame] | 150 | static struct s3c_audio_pdata s3c_i2sv4_pdata = { |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 151 | .cfg_gpio = s3c64xx_i2sv4_cfg_gpio, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | struct platform_device s3c64xx_device_iisv4 = { |
| 155 | .name = "s3c64xx-iis-v4", |
| 156 | .id = -1, |
| 157 | .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource), |
| 158 | .resource = s3c64xx_iisv4_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 159 | .dev = { |
| 160 | .platform_data = &s3c_i2sv4_pdata, |
| 161 | }, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 162 | }; |
| 163 | EXPORT_SYMBOL(s3c64xx_device_iisv4); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 164 | |
| 165 | |
| 166 | /* PCM Controller platform_devices */ |
| 167 | |
| 168 | static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev) |
| 169 | { |
| 170 | switch (pdev->id) { |
| 171 | case 0: |
| 172 | s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_PCM0_SCLK); |
| 173 | s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_PCM0_EXTCLK); |
| 174 | s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_PCM0_FSYNC); |
| 175 | s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_PCM0_SIN); |
| 176 | s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_PCM0_SOUT); |
| 177 | break; |
| 178 | case 1: |
| 179 | s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_PCM1_SCLK); |
| 180 | s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_PCM1_EXTCLK); |
| 181 | s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_PCM1_FSYNC); |
| 182 | s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_PCM1_SIN); |
| 183 | s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_PCM1_SOUT); |
| 184 | break; |
| 185 | default: |
| 186 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 187 | return -EINVAL; |
| 188 | } |
| 189 | |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | static struct resource s3c64xx_pcm0_resource[] = { |
| 194 | [0] = { |
| 195 | .start = S3C64XX_PA_PCM0, |
| 196 | .end = S3C64XX_PA_PCM0 + 0x100 - 1, |
| 197 | .flags = IORESOURCE_MEM, |
| 198 | }, |
| 199 | [1] = { |
| 200 | .start = DMACH_PCM0_TX, |
| 201 | .end = DMACH_PCM0_TX, |
| 202 | .flags = IORESOURCE_DMA, |
| 203 | }, |
| 204 | [2] = { |
| 205 | .start = DMACH_PCM0_RX, |
| 206 | .end = DMACH_PCM0_RX, |
| 207 | .flags = IORESOURCE_DMA, |
| 208 | }, |
| 209 | }; |
| 210 | |
Mark Brown | 43f0de8 | 2009-11-27 16:43:53 +0000 | [diff] [blame] | 211 | static struct s3c_audio_pdata s3c_pcm0_pdata = { |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 212 | .cfg_gpio = s3c64xx_pcm_cfg_gpio, |
| 213 | }; |
| 214 | |
| 215 | struct platform_device s3c64xx_device_pcm0 = { |
| 216 | .name = "samsung-pcm", |
| 217 | .id = 0, |
| 218 | .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource), |
| 219 | .resource = s3c64xx_pcm0_resource, |
| 220 | .dev = { |
| 221 | .platform_data = &s3c_pcm0_pdata, |
| 222 | }, |
| 223 | }; |
| 224 | EXPORT_SYMBOL(s3c64xx_device_pcm0); |
| 225 | |
| 226 | static struct resource s3c64xx_pcm1_resource[] = { |
| 227 | [0] = { |
| 228 | .start = S3C64XX_PA_PCM1, |
| 229 | .end = S3C64XX_PA_PCM1 + 0x100 - 1, |
| 230 | .flags = IORESOURCE_MEM, |
| 231 | }, |
| 232 | [1] = { |
| 233 | .start = DMACH_PCM1_TX, |
| 234 | .end = DMACH_PCM1_TX, |
| 235 | .flags = IORESOURCE_DMA, |
| 236 | }, |
| 237 | [2] = { |
| 238 | .start = DMACH_PCM1_RX, |
| 239 | .end = DMACH_PCM1_RX, |
| 240 | .flags = IORESOURCE_DMA, |
| 241 | }, |
| 242 | }; |
| 243 | |
Mark Brown | 43f0de8 | 2009-11-27 16:43:53 +0000 | [diff] [blame] | 244 | static struct s3c_audio_pdata s3c_pcm1_pdata = { |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 245 | .cfg_gpio = s3c64xx_pcm_cfg_gpio, |
| 246 | }; |
| 247 | |
| 248 | struct platform_device s3c64xx_device_pcm1 = { |
| 249 | .name = "samsung-pcm", |
| 250 | .id = 1, |
| 251 | .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource), |
| 252 | .resource = s3c64xx_pcm1_resource, |
| 253 | .dev = { |
| 254 | .platform_data = &s3c_pcm1_pdata, |
| 255 | }, |
| 256 | }; |
| 257 | EXPORT_SYMBOL(s3c64xx_device_pcm1); |