Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s5pc100/dev-audio.c |
| 2 | * |
| 3 | * Copyright (c) 2010 Samsung Electronics Co. Ltd |
| 4 | * Jaswinder Singh <jassi.brar@samsung.com> |
| 5 | * |
| 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/platform_device.h> |
| 12 | #include <linux/dma-mapping.h> |
Kukjin Kim | 1c739c7 | 2010-08-05 07:54:49 +0900 | [diff] [blame] | 13 | #include <linux/gpio.h> |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 14 | |
| 15 | #include <plat/gpio-cfg.h> |
| 16 | #include <plat/audio.h> |
| 17 | |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 18 | #include <mach/map.h> |
| 19 | #include <mach/dma.h> |
| 20 | #include <mach/irqs.h> |
| 21 | |
| 22 | static int s5pc100_cfg_i2s(struct platform_device *pdev) |
| 23 | { |
| 24 | /* configure GPIO for i2s port */ |
| 25 | switch (pdev->id) { |
| 26 | case 1: |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame^] | 27 | s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(2)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 28 | break; |
| 29 | |
| 30 | case 2: |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame^] | 31 | s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 32 | break; |
| 33 | |
| 34 | case -1: /* Dedicated pins */ |
| 35 | break; |
| 36 | |
| 37 | default: |
| 38 | printk(KERN_ERR "Invalid Device %d\n", pdev->id); |
| 39 | return -EINVAL; |
| 40 | } |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | static struct s3c_audio_pdata s3c_i2s_pdata = { |
| 46 | .cfg_gpio = s5pc100_cfg_i2s, |
| 47 | }; |
| 48 | |
| 49 | static struct resource s5pc100_iis0_resource[] = { |
| 50 | [0] = { |
| 51 | .start = S5PC100_PA_I2S0, |
| 52 | .end = S5PC100_PA_I2S0 + 0x100 - 1, |
| 53 | .flags = IORESOURCE_MEM, |
| 54 | }, |
| 55 | [1] = { |
| 56 | .start = DMACH_I2S0_TX, |
| 57 | .end = DMACH_I2S0_TX, |
| 58 | .flags = IORESOURCE_DMA, |
| 59 | }, |
| 60 | [2] = { |
| 61 | .start = DMACH_I2S0_RX, |
| 62 | .end = DMACH_I2S0_RX, |
| 63 | .flags = IORESOURCE_DMA, |
| 64 | }, |
| 65 | }; |
| 66 | |
| 67 | struct platform_device s5pc100_device_iis0 = { |
| 68 | .name = "s3c64xx-iis-v4", |
| 69 | .id = -1, |
| 70 | .num_resources = ARRAY_SIZE(s5pc100_iis0_resource), |
| 71 | .resource = s5pc100_iis0_resource, |
| 72 | .dev = { |
| 73 | .platform_data = &s3c_i2s_pdata, |
| 74 | }, |
| 75 | }; |
| 76 | |
| 77 | static struct resource s5pc100_iis1_resource[] = { |
| 78 | [0] = { |
| 79 | .start = S5PC100_PA_I2S1, |
| 80 | .end = S5PC100_PA_I2S1 + 0x100 - 1, |
| 81 | .flags = IORESOURCE_MEM, |
| 82 | }, |
| 83 | [1] = { |
| 84 | .start = DMACH_I2S1_TX, |
| 85 | .end = DMACH_I2S1_TX, |
| 86 | .flags = IORESOURCE_DMA, |
| 87 | }, |
| 88 | [2] = { |
| 89 | .start = DMACH_I2S1_RX, |
| 90 | .end = DMACH_I2S1_RX, |
| 91 | .flags = IORESOURCE_DMA, |
| 92 | }, |
| 93 | }; |
| 94 | |
| 95 | struct platform_device s5pc100_device_iis1 = { |
| 96 | .name = "s3c64xx-iis", |
| 97 | .id = 1, |
| 98 | .num_resources = ARRAY_SIZE(s5pc100_iis1_resource), |
| 99 | .resource = s5pc100_iis1_resource, |
| 100 | .dev = { |
| 101 | .platform_data = &s3c_i2s_pdata, |
| 102 | }, |
| 103 | }; |
| 104 | |
| 105 | static struct resource s5pc100_iis2_resource[] = { |
| 106 | [0] = { |
| 107 | .start = S5PC100_PA_I2S2, |
| 108 | .end = S5PC100_PA_I2S2 + 0x100 - 1, |
| 109 | .flags = IORESOURCE_MEM, |
| 110 | }, |
| 111 | [1] = { |
| 112 | .start = DMACH_I2S2_TX, |
| 113 | .end = DMACH_I2S2_TX, |
| 114 | .flags = IORESOURCE_DMA, |
| 115 | }, |
| 116 | [2] = { |
| 117 | .start = DMACH_I2S2_RX, |
| 118 | .end = DMACH_I2S2_RX, |
| 119 | .flags = IORESOURCE_DMA, |
| 120 | }, |
| 121 | }; |
| 122 | |
| 123 | struct platform_device s5pc100_device_iis2 = { |
| 124 | .name = "s3c64xx-iis", |
| 125 | .id = 2, |
| 126 | .num_resources = ARRAY_SIZE(s5pc100_iis2_resource), |
| 127 | .resource = s5pc100_iis2_resource, |
| 128 | .dev = { |
| 129 | .platform_data = &s3c_i2s_pdata, |
| 130 | }, |
| 131 | }; |
| 132 | |
| 133 | /* PCM Controller platform_devices */ |
| 134 | |
| 135 | static int s5pc100_pcm_cfg_gpio(struct platform_device *pdev) |
| 136 | { |
| 137 | switch (pdev->id) { |
| 138 | case 0: |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame^] | 139 | s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(5)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 140 | break; |
| 141 | |
| 142 | case 1: |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame^] | 143 | s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(3)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 144 | break; |
| 145 | |
| 146 | default: |
| 147 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 148 | return -EINVAL; |
| 149 | } |
| 150 | |
| 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | static struct s3c_audio_pdata s3c_pcm_pdata = { |
| 155 | .cfg_gpio = s5pc100_pcm_cfg_gpio, |
| 156 | }; |
| 157 | |
| 158 | static struct resource s5pc100_pcm0_resource[] = { |
| 159 | [0] = { |
| 160 | .start = S5PC100_PA_PCM0, |
| 161 | .end = S5PC100_PA_PCM0 + 0x100 - 1, |
| 162 | .flags = IORESOURCE_MEM, |
| 163 | }, |
| 164 | [1] = { |
| 165 | .start = DMACH_PCM0_TX, |
| 166 | .end = DMACH_PCM0_TX, |
| 167 | .flags = IORESOURCE_DMA, |
| 168 | }, |
| 169 | [2] = { |
| 170 | .start = DMACH_PCM0_RX, |
| 171 | .end = DMACH_PCM0_RX, |
| 172 | .flags = IORESOURCE_DMA, |
| 173 | }, |
| 174 | }; |
| 175 | |
| 176 | struct platform_device s5pc100_device_pcm0 = { |
| 177 | .name = "samsung-pcm", |
| 178 | .id = 0, |
| 179 | .num_resources = ARRAY_SIZE(s5pc100_pcm0_resource), |
| 180 | .resource = s5pc100_pcm0_resource, |
| 181 | .dev = { |
| 182 | .platform_data = &s3c_pcm_pdata, |
| 183 | }, |
| 184 | }; |
| 185 | |
| 186 | static struct resource s5pc100_pcm1_resource[] = { |
| 187 | [0] = { |
| 188 | .start = S5PC100_PA_PCM1, |
| 189 | .end = S5PC100_PA_PCM1 + 0x100 - 1, |
| 190 | .flags = IORESOURCE_MEM, |
| 191 | }, |
| 192 | [1] = { |
| 193 | .start = DMACH_PCM1_TX, |
| 194 | .end = DMACH_PCM1_TX, |
| 195 | .flags = IORESOURCE_DMA, |
| 196 | }, |
| 197 | [2] = { |
| 198 | .start = DMACH_PCM1_RX, |
| 199 | .end = DMACH_PCM1_RX, |
| 200 | .flags = IORESOURCE_DMA, |
| 201 | }, |
| 202 | }; |
| 203 | |
| 204 | struct platform_device s5pc100_device_pcm1 = { |
| 205 | .name = "samsung-pcm", |
| 206 | .id = 1, |
| 207 | .num_resources = ARRAY_SIZE(s5pc100_pcm1_resource), |
| 208 | .resource = s5pc100_pcm1_resource, |
| 209 | .dev = { |
| 210 | .platform_data = &s3c_pcm_pdata, |
| 211 | }, |
| 212 | }; |
| 213 | |
| 214 | /* AC97 Controller platform devices */ |
| 215 | |
| 216 | static int s5pc100_ac97_cfg_gpio(struct platform_device *pdev) |
| 217 | { |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame^] | 218 | return s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | static struct resource s5pc100_ac97_resource[] = { |
| 222 | [0] = { |
| 223 | .start = S5PC100_PA_AC97, |
| 224 | .end = S5PC100_PA_AC97 + 0x100 - 1, |
| 225 | .flags = IORESOURCE_MEM, |
| 226 | }, |
| 227 | [1] = { |
| 228 | .start = DMACH_AC97_PCMOUT, |
| 229 | .end = DMACH_AC97_PCMOUT, |
| 230 | .flags = IORESOURCE_DMA, |
| 231 | }, |
| 232 | [2] = { |
| 233 | .start = DMACH_AC97_PCMIN, |
| 234 | .end = DMACH_AC97_PCMIN, |
| 235 | .flags = IORESOURCE_DMA, |
| 236 | }, |
| 237 | [3] = { |
| 238 | .start = DMACH_AC97_MICIN, |
| 239 | .end = DMACH_AC97_MICIN, |
| 240 | .flags = IORESOURCE_DMA, |
| 241 | }, |
| 242 | [4] = { |
| 243 | .start = IRQ_AC97, |
| 244 | .end = IRQ_AC97, |
| 245 | .flags = IORESOURCE_IRQ, |
| 246 | }, |
| 247 | }; |
| 248 | |
| 249 | static struct s3c_audio_pdata s3c_ac97_pdata = { |
| 250 | .cfg_gpio = s5pc100_ac97_cfg_gpio, |
| 251 | }; |
| 252 | |
| 253 | static u64 s5pc100_ac97_dmamask = DMA_BIT_MASK(32); |
| 254 | |
| 255 | struct platform_device s5pc100_device_ac97 = { |
| 256 | .name = "s3c-ac97", |
| 257 | .id = -1, |
| 258 | .num_resources = ARRAY_SIZE(s5pc100_ac97_resource), |
| 259 | .resource = s5pc100_ac97_resource, |
| 260 | .dev = { |
| 261 | .platform_data = &s3c_ac97_pdata, |
| 262 | .dma_mask = &s5pc100_ac97_dmamask, |
| 263 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 264 | }, |
| 265 | }; |