Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/mach-exynos4/dev-audio.c |
| 2 | * |
| 3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com |
| 5 | * |
| 6 | * Copyright (c) 2010 Samsung Electronics Co. Ltd |
| 7 | * Jaswinder Singh <jassi.brar@samsung.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/dma-mapping.h> |
| 16 | #include <linux/gpio.h> |
Jingoo Han | f034d85 | 2012-11-07 08:11:30 +0900 | [diff] [blame] | 17 | #include <linux/platform_data/asoc-s3c.h> |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 18 | |
| 19 | #include <plat/gpio-cfg.h> |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 20 | |
| 21 | #include <mach/map.h> |
| 22 | #include <mach/dma.h> |
| 23 | #include <mach/irqs.h> |
Kukjin Kim | 6ccb2ae | 2013-01-01 16:23:07 -0800 | [diff] [blame] | 24 | |
| 25 | #define EXYNOS4_AUDSS_INT_MEM (0x03000000) |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 26 | |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 27 | static int exynos4_cfg_i2s(struct platform_device *pdev) |
| 28 | { |
| 29 | /* configure GPIO for i2s port */ |
| 30 | switch (pdev->id) { |
| 31 | case 0: |
| 32 | s3c_gpio_cfgpin_range(EXYNOS4_GPZ(0), 7, S3C_GPIO_SFN(2)); |
| 33 | break; |
| 34 | case 1: |
| 35 | s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(2)); |
| 36 | break; |
| 37 | case 2: |
| 38 | s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 5, S3C_GPIO_SFN(4)); |
| 39 | break; |
| 40 | default: |
| 41 | printk(KERN_ERR "Invalid Device %d\n", pdev->id); |
| 42 | return -EINVAL; |
| 43 | } |
| 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | static struct s3c_audio_pdata i2sv5_pdata = { |
| 49 | .cfg_gpio = exynos4_cfg_i2s, |
| 50 | .type = { |
| 51 | .i2s = { |
| 52 | .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI |
| 53 | | QUIRK_NEED_RSTCLR, |
Sangbeom Kim | 2839cc1 | 2011-07-21 14:12:19 +0900 | [diff] [blame] | 54 | .idma_addr = EXYNOS4_AUDSS_INT_MEM, |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 55 | }, |
| 56 | }, |
| 57 | }; |
| 58 | |
| 59 | static struct resource exynos4_i2s0_resource[] = { |
Tushar Behera | d1e819e | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 60 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S0, SZ_256), |
| 61 | [1] = DEFINE_RES_DMA(DMACH_I2S0_TX), |
| 62 | [2] = DEFINE_RES_DMA(DMACH_I2S0_RX), |
| 63 | [3] = DEFINE_RES_DMA(DMACH_I2S0S_TX), |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | struct platform_device exynos4_device_i2s0 = { |
| 67 | .name = "samsung-i2s", |
| 68 | .id = 0, |
| 69 | .num_resources = ARRAY_SIZE(exynos4_i2s0_resource), |
| 70 | .resource = exynos4_i2s0_resource, |
| 71 | .dev = { |
| 72 | .platform_data = &i2sv5_pdata, |
| 73 | }, |
| 74 | }; |
| 75 | |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 76 | static struct s3c_audio_pdata i2sv3_pdata = { |
| 77 | .cfg_gpio = exynos4_cfg_i2s, |
| 78 | .type = { |
| 79 | .i2s = { |
| 80 | .quirks = QUIRK_NO_MUXPSR, |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 81 | }, |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | static struct resource exynos4_i2s1_resource[] = { |
Tushar Behera | d1e819e | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 86 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S1, SZ_256), |
| 87 | [1] = DEFINE_RES_DMA(DMACH_I2S1_TX), |
| 88 | [2] = DEFINE_RES_DMA(DMACH_I2S1_RX), |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | struct platform_device exynos4_device_i2s1 = { |
| 92 | .name = "samsung-i2s", |
| 93 | .id = 1, |
| 94 | .num_resources = ARRAY_SIZE(exynos4_i2s1_resource), |
| 95 | .resource = exynos4_i2s1_resource, |
| 96 | .dev = { |
| 97 | .platform_data = &i2sv3_pdata, |
| 98 | }, |
| 99 | }; |
| 100 | |
| 101 | static struct resource exynos4_i2s2_resource[] = { |
Tushar Behera | d1e819e | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 102 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S2, SZ_256), |
| 103 | [1] = DEFINE_RES_DMA(DMACH_I2S2_TX), |
| 104 | [2] = DEFINE_RES_DMA(DMACH_I2S2_RX), |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | struct platform_device exynos4_device_i2s2 = { |
| 108 | .name = "samsung-i2s", |
| 109 | .id = 2, |
| 110 | .num_resources = ARRAY_SIZE(exynos4_i2s2_resource), |
| 111 | .resource = exynos4_i2s2_resource, |
| 112 | .dev = { |
| 113 | .platform_data = &i2sv3_pdata, |
| 114 | }, |
| 115 | }; |
| 116 | |
| 117 | /* PCM Controller platform_devices */ |
| 118 | |
| 119 | static int exynos4_pcm_cfg_gpio(struct platform_device *pdev) |
| 120 | { |
| 121 | switch (pdev->id) { |
| 122 | case 0: |
| 123 | s3c_gpio_cfgpin_range(EXYNOS4_GPZ(0), 5, S3C_GPIO_SFN(3)); |
| 124 | break; |
| 125 | case 1: |
| 126 | s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(3)); |
| 127 | break; |
| 128 | case 2: |
| 129 | s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 5, S3C_GPIO_SFN(3)); |
| 130 | break; |
| 131 | default: |
| 132 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 133 | return -EINVAL; |
| 134 | } |
| 135 | |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | static struct s3c_audio_pdata s3c_pcm_pdata = { |
| 140 | .cfg_gpio = exynos4_pcm_cfg_gpio, |
| 141 | }; |
| 142 | |
| 143 | static struct resource exynos4_pcm0_resource[] = { |
Tushar Behera | d1e819e | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 144 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM0, SZ_256), |
| 145 | [1] = DEFINE_RES_DMA(DMACH_PCM0_TX), |
| 146 | [2] = DEFINE_RES_DMA(DMACH_PCM0_RX), |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | struct platform_device exynos4_device_pcm0 = { |
| 150 | .name = "samsung-pcm", |
| 151 | .id = 0, |
| 152 | .num_resources = ARRAY_SIZE(exynos4_pcm0_resource), |
| 153 | .resource = exynos4_pcm0_resource, |
| 154 | .dev = { |
| 155 | .platform_data = &s3c_pcm_pdata, |
| 156 | }, |
| 157 | }; |
| 158 | |
| 159 | static struct resource exynos4_pcm1_resource[] = { |
Tushar Behera | d1e819e | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 160 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM1, SZ_256), |
| 161 | [1] = DEFINE_RES_DMA(DMACH_PCM1_TX), |
| 162 | [2] = DEFINE_RES_DMA(DMACH_PCM1_RX), |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | struct platform_device exynos4_device_pcm1 = { |
| 166 | .name = "samsung-pcm", |
| 167 | .id = 1, |
| 168 | .num_resources = ARRAY_SIZE(exynos4_pcm1_resource), |
| 169 | .resource = exynos4_pcm1_resource, |
| 170 | .dev = { |
| 171 | .platform_data = &s3c_pcm_pdata, |
| 172 | }, |
| 173 | }; |
| 174 | |
| 175 | static struct resource exynos4_pcm2_resource[] = { |
Tushar Behera | d1e819e | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 176 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM2, SZ_256), |
| 177 | [1] = DEFINE_RES_DMA(DMACH_PCM2_TX), |
| 178 | [2] = DEFINE_RES_DMA(DMACH_PCM2_RX), |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | struct platform_device exynos4_device_pcm2 = { |
| 182 | .name = "samsung-pcm", |
| 183 | .id = 2, |
| 184 | .num_resources = ARRAY_SIZE(exynos4_pcm2_resource), |
| 185 | .resource = exynos4_pcm2_resource, |
| 186 | .dev = { |
| 187 | .platform_data = &s3c_pcm_pdata, |
| 188 | }, |
| 189 | }; |
| 190 | |
| 191 | /* AC97 Controller platform devices */ |
| 192 | |
| 193 | static int exynos4_ac97_cfg_gpio(struct platform_device *pdev) |
| 194 | { |
| 195 | return s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(4)); |
| 196 | } |
| 197 | |
| 198 | static struct resource exynos4_ac97_resource[] = { |
Tushar Behera | d1e819e | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 199 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_AC97, SZ_256), |
| 200 | [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT), |
| 201 | [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN), |
| 202 | [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN), |
| 203 | [4] = DEFINE_RES_IRQ(EXYNOS4_IRQ_AC97), |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | static struct s3c_audio_pdata s3c_ac97_pdata = { |
| 207 | .cfg_gpio = exynos4_ac97_cfg_gpio, |
| 208 | }; |
| 209 | |
| 210 | static u64 exynos4_ac97_dmamask = DMA_BIT_MASK(32); |
| 211 | |
| 212 | struct platform_device exynos4_device_ac97 = { |
| 213 | .name = "samsung-ac97", |
| 214 | .id = -1, |
| 215 | .num_resources = ARRAY_SIZE(exynos4_ac97_resource), |
| 216 | .resource = exynos4_ac97_resource, |
| 217 | .dev = { |
| 218 | .platform_data = &s3c_ac97_pdata, |
| 219 | .dma_mask = &exynos4_ac97_dmamask, |
| 220 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 221 | }, |
| 222 | }; |
| 223 | |
| 224 | /* S/PDIF Controller platform_device */ |
| 225 | |
| 226 | static int exynos4_spdif_cfg_gpio(struct platform_device *pdev) |
| 227 | { |
Naveen Krishna Chatradhi | a3df1d4 | 2011-06-16 19:33:29 +0900 | [diff] [blame] | 228 | s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 2, S3C_GPIO_SFN(4)); |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 229 | |
| 230 | return 0; |
| 231 | } |
| 232 | |
| 233 | static struct resource exynos4_spdif_resource[] = { |
Tushar Behera | d1e819e | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 234 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_SPDIF, SZ_256), |
| 235 | [1] = DEFINE_RES_DMA(DMACH_SPDIF), |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | static struct s3c_audio_pdata samsung_spdif_pdata = { |
| 239 | .cfg_gpio = exynos4_spdif_cfg_gpio, |
| 240 | }; |
| 241 | |
| 242 | static u64 exynos4_spdif_dmamask = DMA_BIT_MASK(32); |
| 243 | |
| 244 | struct platform_device exynos4_device_spdif = { |
| 245 | .name = "samsung-spdif", |
| 246 | .id = -1, |
| 247 | .num_resources = ARRAY_SIZE(exynos4_spdif_resource), |
| 248 | .resource = exynos4_spdif_resource, |
| 249 | .dev = { |
| 250 | .platform_data = &samsung_spdif_pdata, |
| 251 | .dma_mask = &exynos4_spdif_dmamask, |
| 252 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 253 | }, |
| 254 | }; |