Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s5pv210/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 | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 14 | |
| 15 | #include <plat/gpio-cfg.h> |
| 16 | #include <plat/audio.h> |
| 17 | |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 18 | #include <mach/map.h> |
| 19 | #include <mach/dma.h> |
| 20 | #include <mach/irqs.h> |
Sangbeom Kim | 2d21237 | 2011-07-21 14:15:11 +0900 | [diff] [blame] | 21 | #include <mach/regs-audss.h> |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 22 | |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 23 | static const char *rclksrc[] = { |
| 24 | [0] = "busclk", |
| 25 | [1] = "i2sclk", |
| 26 | }; |
| 27 | |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 28 | static int s5pv210_cfg_i2s(struct platform_device *pdev) |
| 29 | { |
| 30 | /* configure GPIO for i2s port */ |
| 31 | switch (pdev->id) { |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 32 | case 0: |
| 33 | s3c_gpio_cfgpin_range(S5PV210_GPI(0), 7, S3C_GPIO_SFN(2)); |
| 34 | break; |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 35 | case 1: |
Ben Dooks | 64c5bd8 | 2010-10-01 14:27:31 +0900 | [diff] [blame] | 36 | s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(2)); |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 37 | break; |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 38 | case 2: |
Ben Dooks | 64c5bd8 | 2010-10-01 14:27:31 +0900 | [diff] [blame] | 39 | s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 40 | break; |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 41 | default: |
| 42 | printk(KERN_ERR "Invalid Device %d\n", pdev->id); |
| 43 | return -EINVAL; |
| 44 | } |
| 45 | |
| 46 | return 0; |
| 47 | } |
| 48 | |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 49 | static struct s3c_audio_pdata i2sv5_pdata = { |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 50 | .cfg_gpio = s5pv210_cfg_i2s, |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 51 | .type = { |
| 52 | .i2s = { |
| 53 | .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI |
| 54 | | QUIRK_NEED_RSTCLR, |
| 55 | .src_clk = rclksrc, |
Sangbeom Kim | 2839cc1 | 2011-07-21 14:12:19 +0900 | [diff] [blame] | 56 | .idma_addr = S5PV210_AUDSS_INT_MEM, |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 57 | }, |
| 58 | }, |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static struct resource s5pv210_iis0_resource[] = { |
Tushar Behera | 58ff20a | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 62 | [0] = DEFINE_RES_MEM(S5PV210_PA_IIS0, SZ_256), |
| 63 | [1] = DEFINE_RES_DMA(DMACH_I2S0_TX), |
| 64 | [2] = DEFINE_RES_DMA(DMACH_I2S0_RX), |
| 65 | [3] = DEFINE_RES_DMA(DMACH_I2S0S_TX), |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | struct platform_device s5pv210_device_iis0 = { |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 69 | .name = "samsung-i2s", |
| 70 | .id = 0, |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 71 | .num_resources = ARRAY_SIZE(s5pv210_iis0_resource), |
| 72 | .resource = s5pv210_iis0_resource, |
| 73 | .dev = { |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 74 | .platform_data = &i2sv5_pdata, |
| 75 | }, |
| 76 | }; |
| 77 | |
| 78 | static const char *rclksrc_v3[] = { |
| 79 | [0] = "iis", |
| 80 | [1] = "audio-bus", |
| 81 | }; |
| 82 | |
| 83 | static struct s3c_audio_pdata i2sv3_pdata = { |
| 84 | .cfg_gpio = s5pv210_cfg_i2s, |
| 85 | .type = { |
| 86 | .i2s = { |
| 87 | .src_clk = rclksrc_v3, |
| 88 | }, |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 89 | }, |
| 90 | }; |
| 91 | |
| 92 | static struct resource s5pv210_iis1_resource[] = { |
Tushar Behera | 58ff20a | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 93 | [0] = DEFINE_RES_MEM(S5PV210_PA_IIS1, SZ_256), |
| 94 | [1] = DEFINE_RES_DMA(DMACH_I2S1_TX), |
| 95 | [2] = DEFINE_RES_DMA(DMACH_I2S1_RX), |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | struct platform_device s5pv210_device_iis1 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame] | 99 | .name = "samsung-i2s", |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 100 | .id = 1, |
| 101 | .num_resources = ARRAY_SIZE(s5pv210_iis1_resource), |
| 102 | .resource = s5pv210_iis1_resource, |
| 103 | .dev = { |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 104 | .platform_data = &i2sv3_pdata, |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 105 | }, |
| 106 | }; |
| 107 | |
| 108 | static struct resource s5pv210_iis2_resource[] = { |
Tushar Behera | 58ff20a | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 109 | [0] = DEFINE_RES_MEM(S5PV210_PA_IIS2, SZ_256), |
| 110 | [1] = DEFINE_RES_DMA(DMACH_I2S2_TX), |
| 111 | [2] = DEFINE_RES_DMA(DMACH_I2S2_RX), |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | struct platform_device s5pv210_device_iis2 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame] | 115 | .name = "samsung-i2s", |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 116 | .id = 2, |
| 117 | .num_resources = ARRAY_SIZE(s5pv210_iis2_resource), |
| 118 | .resource = s5pv210_iis2_resource, |
| 119 | .dev = { |
Jassi Brar | 9aa2570 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 120 | .platform_data = &i2sv3_pdata, |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 121 | }, |
| 122 | }; |
| 123 | |
| 124 | /* PCM Controller platform_devices */ |
| 125 | |
| 126 | static int s5pv210_pcm_cfg_gpio(struct platform_device *pdev) |
| 127 | { |
| 128 | switch (pdev->id) { |
| 129 | case 0: |
Ben Dooks | 64c5bd8 | 2010-10-01 14:27:31 +0900 | [diff] [blame] | 130 | s3c_gpio_cfgpin_range(S5PV210_GPI(0), 5, S3C_GPIO_SFN(3)); |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 131 | break; |
| 132 | case 1: |
Ben Dooks | 64c5bd8 | 2010-10-01 14:27:31 +0900 | [diff] [blame] | 133 | s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(3)); |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 134 | break; |
| 135 | case 2: |
Ben Dooks | 64c5bd8 | 2010-10-01 14:27:31 +0900 | [diff] [blame] | 136 | s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(2)); |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 137 | break; |
| 138 | default: |
| 139 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 140 | return -EINVAL; |
| 141 | } |
| 142 | |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | static struct s3c_audio_pdata s3c_pcm_pdata = { |
| 147 | .cfg_gpio = s5pv210_pcm_cfg_gpio, |
| 148 | }; |
| 149 | |
| 150 | static struct resource s5pv210_pcm0_resource[] = { |
Tushar Behera | 58ff20a | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 151 | [0] = DEFINE_RES_MEM(S5PV210_PA_PCM0, SZ_256), |
| 152 | [1] = DEFINE_RES_DMA(DMACH_PCM0_TX), |
| 153 | [2] = DEFINE_RES_DMA(DMACH_PCM0_RX), |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | struct platform_device s5pv210_device_pcm0 = { |
| 157 | .name = "samsung-pcm", |
| 158 | .id = 0, |
| 159 | .num_resources = ARRAY_SIZE(s5pv210_pcm0_resource), |
| 160 | .resource = s5pv210_pcm0_resource, |
| 161 | .dev = { |
| 162 | .platform_data = &s3c_pcm_pdata, |
| 163 | }, |
| 164 | }; |
| 165 | |
| 166 | static struct resource s5pv210_pcm1_resource[] = { |
Tushar Behera | 58ff20a | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 167 | [0] = DEFINE_RES_MEM(S5PV210_PA_PCM1, SZ_256), |
| 168 | [1] = DEFINE_RES_DMA(DMACH_PCM1_TX), |
| 169 | [2] = DEFINE_RES_DMA(DMACH_PCM1_RX), |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | struct platform_device s5pv210_device_pcm1 = { |
| 173 | .name = "samsung-pcm", |
| 174 | .id = 1, |
| 175 | .num_resources = ARRAY_SIZE(s5pv210_pcm1_resource), |
| 176 | .resource = s5pv210_pcm1_resource, |
| 177 | .dev = { |
| 178 | .platform_data = &s3c_pcm_pdata, |
| 179 | }, |
| 180 | }; |
| 181 | |
| 182 | static struct resource s5pv210_pcm2_resource[] = { |
Tushar Behera | 58ff20a | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 183 | [0] = DEFINE_RES_MEM(S5PV210_PA_PCM2, SZ_256), |
| 184 | [1] = DEFINE_RES_DMA(DMACH_PCM2_TX), |
| 185 | [2] = DEFINE_RES_DMA(DMACH_PCM2_RX), |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | struct platform_device s5pv210_device_pcm2 = { |
| 189 | .name = "samsung-pcm", |
| 190 | .id = 2, |
| 191 | .num_resources = ARRAY_SIZE(s5pv210_pcm2_resource), |
| 192 | .resource = s5pv210_pcm2_resource, |
| 193 | .dev = { |
| 194 | .platform_data = &s3c_pcm_pdata, |
| 195 | }, |
| 196 | }; |
| 197 | |
| 198 | /* AC97 Controller platform devices */ |
| 199 | |
| 200 | static int s5pv210_ac97_cfg_gpio(struct platform_device *pdev) |
| 201 | { |
Ben Dooks | 64c5bd8 | 2010-10-01 14:27:31 +0900 | [diff] [blame] | 202 | return s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | static struct resource s5pv210_ac97_resource[] = { |
Tushar Behera | 58ff20a | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 206 | [0] = DEFINE_RES_MEM(S5PV210_PA_AC97, SZ_256), |
| 207 | [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT), |
| 208 | [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN), |
| 209 | [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN), |
| 210 | [4] = DEFINE_RES_IRQ(IRQ_AC97), |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 211 | }; |
| 212 | |
| 213 | static struct s3c_audio_pdata s3c_ac97_pdata = { |
| 214 | .cfg_gpio = s5pv210_ac97_cfg_gpio, |
| 215 | }; |
| 216 | |
| 217 | static u64 s5pv210_ac97_dmamask = DMA_BIT_MASK(32); |
| 218 | |
| 219 | struct platform_device s5pv210_device_ac97 = { |
Jassi Brar | e610467 | 2010-11-22 15:36:00 +0900 | [diff] [blame] | 220 | .name = "samsung-ac97", |
Jassi Brar | 602bf0c | 2010-05-18 16:02:26 +0900 | [diff] [blame] | 221 | .id = -1, |
| 222 | .num_resources = ARRAY_SIZE(s5pv210_ac97_resource), |
| 223 | .resource = s5pv210_ac97_resource, |
| 224 | .dev = { |
| 225 | .platform_data = &s3c_ac97_pdata, |
| 226 | .dma_mask = &s5pv210_ac97_dmamask, |
| 227 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 228 | }, |
| 229 | }; |
Seungwhan Youn | 494edad | 2010-10-14 10:35:24 +0900 | [diff] [blame] | 230 | |
| 231 | /* S/PDIF Controller platform_device */ |
| 232 | |
| 233 | static int s5pv210_spdif_cfg_gpio(struct platform_device *pdev) |
| 234 | { |
| 235 | s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 2, S3C_GPIO_SFN(3)); |
| 236 | |
| 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | static struct resource s5pv210_spdif_resource[] = { |
Tushar Behera | 58ff20a | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 241 | [0] = DEFINE_RES_MEM(S5PV210_PA_SPDIF, SZ_256), |
| 242 | [1] = DEFINE_RES_DMA(DMACH_SPDIF), |
Seungwhan Youn | 494edad | 2010-10-14 10:35:24 +0900 | [diff] [blame] | 243 | }; |
| 244 | |
| 245 | static struct s3c_audio_pdata samsung_spdif_pdata = { |
| 246 | .cfg_gpio = s5pv210_spdif_cfg_gpio, |
| 247 | }; |
| 248 | |
| 249 | static u64 s5pv210_spdif_dmamask = DMA_BIT_MASK(32); |
| 250 | |
| 251 | struct platform_device s5pv210_device_spdif = { |
| 252 | .name = "samsung-spdif", |
| 253 | .id = -1, |
| 254 | .num_resources = ARRAY_SIZE(s5pv210_spdif_resource), |
| 255 | .resource = s5pv210_spdif_resource, |
| 256 | .dev = { |
| 257 | .platform_data = &samsung_spdif_pdata, |
| 258 | .dma_mask = &s5pv210_spdif_dmamask, |
| 259 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 260 | }, |
| 261 | }; |