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) { |
Jassi Brar | 651cba5 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 26 | case 0: /* Dedicated pins */ |
| 27 | break; |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 28 | case 1: |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame] | 29 | s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(2)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 30 | break; |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 31 | case 2: |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame] | 32 | s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 33 | break; |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 34 | default: |
| 35 | printk(KERN_ERR "Invalid Device %d\n", pdev->id); |
| 36 | return -EINVAL; |
| 37 | } |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
Jassi Brar | 651cba5 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 42 | static const char *rclksrc_v5[] = { |
| 43 | [0] = "iis", |
| 44 | [1] = "i2sclkd2", |
| 45 | }; |
| 46 | |
| 47 | static struct s3c_audio_pdata i2sv5_pdata = { |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 48 | .cfg_gpio = s5pc100_cfg_i2s, |
Jassi Brar | 651cba5 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 49 | .type = { |
| 50 | .i2s = { |
| 51 | .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI |
| 52 | | QUIRK_NEED_RSTCLR, |
| 53 | .src_clk = rclksrc_v5, |
| 54 | }, |
| 55 | }, |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | static struct resource s5pc100_iis0_resource[] = { |
Tushar Behera | 9823000 | 2012-05-12 16:12:30 +0900 | [diff] [blame^] | 59 | [0] = DEFINE_RES_MEM(S5PC100_PA_I2S0, SZ_256), |
| 60 | [1] = DEFINE_RES_DMA(DMACH_I2S0_TX), |
| 61 | [2] = DEFINE_RES_DMA(DMACH_I2S0_RX), |
| 62 | [3] = DEFINE_RES_DMA(DMACH_I2S0S_TX), |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | struct platform_device s5pc100_device_iis0 = { |
Jassi Brar | 651cba5 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 66 | .name = "samsung-i2s", |
| 67 | .id = 0, |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 68 | .num_resources = ARRAY_SIZE(s5pc100_iis0_resource), |
| 69 | .resource = s5pc100_iis0_resource, |
| 70 | .dev = { |
Jassi Brar | 651cba5 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 71 | .platform_data = &i2sv5_pdata, |
| 72 | }, |
| 73 | }; |
| 74 | |
| 75 | static const char *rclksrc_v3[] = { |
| 76 | [0] = "iis", |
| 77 | [1] = "sclk_audio", |
| 78 | }; |
| 79 | |
| 80 | static struct s3c_audio_pdata i2sv3_pdata = { |
| 81 | .cfg_gpio = s5pc100_cfg_i2s, |
| 82 | .type = { |
| 83 | .i2s = { |
| 84 | .src_clk = rclksrc_v3, |
| 85 | }, |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 86 | }, |
| 87 | }; |
| 88 | |
| 89 | static struct resource s5pc100_iis1_resource[] = { |
Tushar Behera | 9823000 | 2012-05-12 16:12:30 +0900 | [diff] [blame^] | 90 | [0] = DEFINE_RES_MEM(S5PC100_PA_I2S1, SZ_256), |
| 91 | [1] = DEFINE_RES_DMA(DMACH_I2S1_TX), |
| 92 | [2] = DEFINE_RES_DMA(DMACH_I2S1_RX), |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | struct platform_device s5pc100_device_iis1 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame] | 96 | .name = "samsung-i2s", |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 97 | .id = 1, |
| 98 | .num_resources = ARRAY_SIZE(s5pc100_iis1_resource), |
| 99 | .resource = s5pc100_iis1_resource, |
| 100 | .dev = { |
Jassi Brar | 651cba5 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 101 | .platform_data = &i2sv3_pdata, |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 102 | }, |
| 103 | }; |
| 104 | |
| 105 | static struct resource s5pc100_iis2_resource[] = { |
Tushar Behera | 9823000 | 2012-05-12 16:12:30 +0900 | [diff] [blame^] | 106 | [0] = DEFINE_RES_MEM(S5PC100_PA_I2S2, SZ_256), |
| 107 | [1] = DEFINE_RES_DMA(DMACH_I2S2_TX), |
| 108 | [2] = DEFINE_RES_DMA(DMACH_I2S2_RX), |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | struct platform_device s5pc100_device_iis2 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame] | 112 | .name = "samsung-i2s", |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 113 | .id = 2, |
| 114 | .num_resources = ARRAY_SIZE(s5pc100_iis2_resource), |
| 115 | .resource = s5pc100_iis2_resource, |
| 116 | .dev = { |
Jassi Brar | 651cba5 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 117 | .platform_data = &i2sv3_pdata, |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 118 | }, |
| 119 | }; |
| 120 | |
| 121 | /* PCM Controller platform_devices */ |
| 122 | |
| 123 | static int s5pc100_pcm_cfg_gpio(struct platform_device *pdev) |
| 124 | { |
| 125 | switch (pdev->id) { |
| 126 | case 0: |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame] | 127 | s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(5)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 128 | break; |
| 129 | |
| 130 | case 1: |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame] | 131 | s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(3)); |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 132 | break; |
| 133 | |
| 134 | default: |
| 135 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 136 | return -EINVAL; |
| 137 | } |
| 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | static struct s3c_audio_pdata s3c_pcm_pdata = { |
| 143 | .cfg_gpio = s5pc100_pcm_cfg_gpio, |
| 144 | }; |
| 145 | |
| 146 | static struct resource s5pc100_pcm0_resource[] = { |
Tushar Behera | 9823000 | 2012-05-12 16:12:30 +0900 | [diff] [blame^] | 147 | [0] = DEFINE_RES_MEM(S5PC100_PA_PCM0, SZ_256), |
| 148 | [1] = DEFINE_RES_DMA(DMACH_PCM0_TX), |
| 149 | [2] = DEFINE_RES_DMA(DMACH_PCM0_RX), |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 150 | }; |
| 151 | |
| 152 | struct platform_device s5pc100_device_pcm0 = { |
| 153 | .name = "samsung-pcm", |
| 154 | .id = 0, |
| 155 | .num_resources = ARRAY_SIZE(s5pc100_pcm0_resource), |
| 156 | .resource = s5pc100_pcm0_resource, |
| 157 | .dev = { |
| 158 | .platform_data = &s3c_pcm_pdata, |
| 159 | }, |
| 160 | }; |
| 161 | |
| 162 | static struct resource s5pc100_pcm1_resource[] = { |
Tushar Behera | 9823000 | 2012-05-12 16:12:30 +0900 | [diff] [blame^] | 163 | [0] = DEFINE_RES_MEM(S5PC100_PA_PCM1, SZ_256), |
| 164 | [1] = DEFINE_RES_DMA(DMACH_PCM1_TX), |
| 165 | [2] = DEFINE_RES_DMA(DMACH_PCM1_RX), |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | struct platform_device s5pc100_device_pcm1 = { |
| 169 | .name = "samsung-pcm", |
| 170 | .id = 1, |
| 171 | .num_resources = ARRAY_SIZE(s5pc100_pcm1_resource), |
| 172 | .resource = s5pc100_pcm1_resource, |
| 173 | .dev = { |
| 174 | .platform_data = &s3c_pcm_pdata, |
| 175 | }, |
| 176 | }; |
| 177 | |
| 178 | /* AC97 Controller platform devices */ |
| 179 | |
| 180 | static int s5pc100_ac97_cfg_gpio(struct platform_device *pdev) |
| 181 | { |
Ben Dooks | ce8f9ab | 2010-10-01 14:20:55 +0900 | [diff] [blame] | 182 | 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] | 183 | } |
| 184 | |
| 185 | static struct resource s5pc100_ac97_resource[] = { |
Tushar Behera | 9823000 | 2012-05-12 16:12:30 +0900 | [diff] [blame^] | 186 | [0] = DEFINE_RES_MEM(S5PC100_PA_AC97, SZ_256), |
| 187 | [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT), |
| 188 | [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN), |
| 189 | [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN), |
| 190 | [4] = DEFINE_RES_IRQ(IRQ_AC97), |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | static struct s3c_audio_pdata s3c_ac97_pdata = { |
| 194 | .cfg_gpio = s5pc100_ac97_cfg_gpio, |
| 195 | }; |
| 196 | |
| 197 | static u64 s5pc100_ac97_dmamask = DMA_BIT_MASK(32); |
| 198 | |
| 199 | struct platform_device s5pc100_device_ac97 = { |
Jassi Brar | e610467 | 2010-11-22 15:36:00 +0900 | [diff] [blame] | 200 | .name = "samsung-ac97", |
Jassi Brar | 9e4ed5c3 | 2010-05-18 16:02:39 +0900 | [diff] [blame] | 201 | .id = -1, |
| 202 | .num_resources = ARRAY_SIZE(s5pc100_ac97_resource), |
| 203 | .resource = s5pc100_ac97_resource, |
| 204 | .dev = { |
| 205 | .platform_data = &s3c_ac97_pdata, |
| 206 | .dma_mask = &s5pc100_ac97_dmamask, |
| 207 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 208 | }, |
| 209 | }; |
Seungwhan Youn | 068b432 | 2010-10-14 10:35:23 +0900 | [diff] [blame] | 210 | |
| 211 | /* S/PDIF Controller platform_device */ |
| 212 | static int s5pc100_spdif_cfg_gpd(struct platform_device *pdev) |
| 213 | { |
| 214 | s3c_gpio_cfgpin_range(S5PC100_GPD(5), 2, S3C_GPIO_SFN(3)); |
| 215 | |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | static int s5pc100_spdif_cfg_gpg3(struct platform_device *pdev) |
| 220 | { |
| 221 | s3c_gpio_cfgpin_range(S5PC100_GPG3(5), 2, S3C_GPIO_SFN(3)); |
| 222 | |
| 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | static struct resource s5pc100_spdif_resource[] = { |
Tushar Behera | 9823000 | 2012-05-12 16:12:30 +0900 | [diff] [blame^] | 227 | [0] = DEFINE_RES_MEM(S5PC100_PA_SPDIF, SZ_256), |
| 228 | [1] = DEFINE_RES_DMA(DMACH_SPDIF), |
Seungwhan Youn | 068b432 | 2010-10-14 10:35:23 +0900 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | static struct s3c_audio_pdata s5p_spdif_pdata = { |
| 232 | .cfg_gpio = s5pc100_spdif_cfg_gpd, |
| 233 | }; |
| 234 | |
| 235 | static u64 s5pc100_spdif_dmamask = DMA_BIT_MASK(32); |
| 236 | |
| 237 | struct platform_device s5pc100_device_spdif = { |
| 238 | .name = "samsung-spdif", |
| 239 | .id = -1, |
| 240 | .num_resources = ARRAY_SIZE(s5pc100_spdif_resource), |
| 241 | .resource = s5pc100_spdif_resource, |
| 242 | .dev = { |
| 243 | .platform_data = &s5p_spdif_pdata, |
| 244 | .dma_mask = &s5pc100_spdif_dmamask, |
| 245 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 246 | }, |
| 247 | }; |
| 248 | |
| 249 | void __init s5pc100_spdif_setup_gpio(int gpio) |
| 250 | { |
| 251 | if (gpio == S5PC100_SPDIF_GPD) |
| 252 | s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpd; |
| 253 | else |
| 254 | s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpg3; |
| 255 | } |