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> |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 14 | #include <linux/dma-mapping.h> |
Kukjin Kim | 1c739c7 | 2010-08-05 07:54:49 +0900 | [diff] [blame] | 15 | #include <linux/gpio.h> |
Paul Gortmaker | dc28094 | 2011-07-31 16:17:29 -0400 | [diff] [blame] | 16 | #include <linux/export.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 17 | |
| 18 | #include <mach/irqs.h> |
| 19 | #include <mach/map.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 20 | #include <mach/dma.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 21 | |
| 22 | #include <plat/devs.h> |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 23 | #include <linux/platform_data/asoc-s3c.h> |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 24 | #include <plat/gpio-cfg.h> |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 25 | |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 26 | static const char *rclksrc[] = { |
| 27 | [0] = "iis", |
| 28 | [1] = "audio-bus", |
| 29 | }; |
| 30 | |
| 31 | static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev) |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 32 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 33 | unsigned int base; |
| 34 | |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 35 | switch (pdev->id) { |
| 36 | case 0: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 37 | base = S3C64XX_GPD(0); |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 38 | break; |
| 39 | case 1: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 40 | base = S3C64XX_GPE(0); |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 41 | break; |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 42 | case 2: |
| 43 | s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5)); |
| 44 | s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5)); |
| 45 | s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5)); |
| 46 | s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5)); |
| 47 | return 0; |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 48 | default: |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 49 | printk(KERN_DEBUG "Invalid I2S Controller number: %d\n", |
| 50 | pdev->id); |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 51 | return -EINVAL; |
| 52 | } |
| 53 | |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 54 | s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3)); |
| 55 | |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 56 | return 0; |
| 57 | } |
| 58 | |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 59 | static struct resource s3c64xx_iis0_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 60 | [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256), |
| 61 | [1] = DEFINE_RES_DMA(DMACH_I2S0_OUT), |
| 62 | [2] = DEFINE_RES_DMA(DMACH_I2S0_IN), |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 63 | }; |
| 64 | |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 65 | static struct s3c_audio_pdata i2sv3_pdata = { |
| 66 | .cfg_gpio = s3c64xx_i2s_cfg_gpio, |
| 67 | .type = { |
| 68 | .i2s = { |
| 69 | .src_clk = rclksrc, |
| 70 | }, |
| 71 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | struct platform_device s3c64xx_device_iis0 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame] | 75 | .name = "samsung-i2s", |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 76 | .id = 0, |
| 77 | .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource), |
| 78 | .resource = s3c64xx_iis0_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 79 | .dev = { |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 80 | .platform_data = &i2sv3_pdata, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 81 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 82 | }; |
| 83 | EXPORT_SYMBOL(s3c64xx_device_iis0); |
| 84 | |
| 85 | static struct resource s3c64xx_iis1_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 86 | [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256), |
| 87 | [1] = DEFINE_RES_DMA(DMACH_I2S1_OUT), |
| 88 | [2] = DEFINE_RES_DMA(DMACH_I2S1_IN), |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 89 | }; |
| 90 | |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 91 | struct platform_device s3c64xx_device_iis1 = { |
Jassi Brar | daea9b4 | 2010-11-19 08:49:43 +0900 | [diff] [blame] | 92 | .name = "samsung-i2s", |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 93 | .id = 1, |
| 94 | .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource), |
| 95 | .resource = s3c64xx_iis1_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 96 | .dev = { |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 97 | .platform_data = &i2sv3_pdata, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 98 | }, |
Mark Brown | 52da219 | 2009-06-03 20:08:38 +0100 | [diff] [blame] | 99 | }; |
| 100 | EXPORT_SYMBOL(s3c64xx_device_iis1); |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 101 | |
| 102 | static struct resource s3c64xx_iisv4_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 103 | [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256), |
| 104 | [1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX), |
| 105 | [2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX), |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 106 | }; |
| 107 | |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 108 | static struct s3c_audio_pdata i2sv4_pdata = { |
| 109 | .cfg_gpio = s3c64xx_i2s_cfg_gpio, |
| 110 | .type = { |
| 111 | .i2s = { |
| 112 | .quirks = QUIRK_PRI_6CHAN, |
| 113 | .src_clk = rclksrc, |
| 114 | }, |
| 115 | }, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | struct platform_device s3c64xx_device_iisv4 = { |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 119 | .name = "samsung-i2s", |
| 120 | .id = 2, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 121 | .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource), |
| 122 | .resource = s3c64xx_iisv4_resource, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 123 | .dev = { |
Jassi Brar | 6a62bee | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 124 | .platform_data = &i2sv4_pdata, |
Jassi Brar | 7126936 | 2010-01-06 15:33:44 +0900 | [diff] [blame] | 125 | }, |
Mark Brown | d06a49e | 2009-06-03 20:08:39 +0100 | [diff] [blame] | 126 | }; |
| 127 | EXPORT_SYMBOL(s3c64xx_device_iisv4); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 128 | |
| 129 | |
| 130 | /* PCM Controller platform_devices */ |
| 131 | |
| 132 | static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev) |
| 133 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 134 | unsigned int base; |
| 135 | |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 136 | switch (pdev->id) { |
| 137 | case 0: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 138 | base = S3C64XX_GPD(0); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 139 | break; |
| 140 | case 1: |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 141 | base = S3C64XX_GPE(0); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 142 | break; |
| 143 | default: |
Dimitris Papastamos | e4b6b74 | 2010-08-26 16:07:23 +0100 | [diff] [blame] | 144 | printk(KERN_DEBUG "Invalid PCM Controller number: %d\n", |
| 145 | pdev->id); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 146 | return -EINVAL; |
| 147 | } |
| 148 | |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 149 | s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2)); |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | static struct resource s3c64xx_pcm0_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 154 | [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256), |
| 155 | [1] = DEFINE_RES_DMA(DMACH_PCM0_TX), |
| 156 | [2] = DEFINE_RES_DMA(DMACH_PCM0_RX), |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 157 | }; |
| 158 | |
Mark Brown | 43f0de8 | 2009-11-27 16:43:53 +0000 | [diff] [blame] | 159 | static struct s3c_audio_pdata s3c_pcm0_pdata = { |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 160 | .cfg_gpio = s3c64xx_pcm_cfg_gpio, |
| 161 | }; |
| 162 | |
| 163 | struct platform_device s3c64xx_device_pcm0 = { |
| 164 | .name = "samsung-pcm", |
| 165 | .id = 0, |
| 166 | .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource), |
| 167 | .resource = s3c64xx_pcm0_resource, |
| 168 | .dev = { |
| 169 | .platform_data = &s3c_pcm0_pdata, |
| 170 | }, |
| 171 | }; |
| 172 | EXPORT_SYMBOL(s3c64xx_device_pcm0); |
| 173 | |
| 174 | static struct resource s3c64xx_pcm1_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 175 | [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256), |
| 176 | [1] = DEFINE_RES_DMA(DMACH_PCM1_TX), |
| 177 | [2] = DEFINE_RES_DMA(DMACH_PCM1_RX), |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 178 | }; |
| 179 | |
Mark Brown | 43f0de8 | 2009-11-27 16:43:53 +0000 | [diff] [blame] | 180 | static struct s3c_audio_pdata s3c_pcm1_pdata = { |
Jassi Brar | acf1aef | 2009-11-17 16:53:56 +0900 | [diff] [blame] | 181 | .cfg_gpio = s3c64xx_pcm_cfg_gpio, |
| 182 | }; |
| 183 | |
| 184 | struct platform_device s3c64xx_device_pcm1 = { |
| 185 | .name = "samsung-pcm", |
| 186 | .id = 1, |
| 187 | .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource), |
| 188 | .resource = s3c64xx_pcm1_resource, |
| 189 | .dev = { |
| 190 | .platform_data = &s3c_pcm1_pdata, |
| 191 | }, |
| 192 | }; |
| 193 | EXPORT_SYMBOL(s3c64xx_device_pcm1); |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 194 | |
| 195 | /* AC97 Controller platform devices */ |
| 196 | |
| 197 | static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev) |
| 198 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 199 | return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev) |
| 203 | { |
Ben Dooks | 2618b55 | 2010-05-27 15:54:06 +0900 | [diff] [blame] | 204 | return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4)); |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | static struct resource s3c64xx_ac97_resource[] = { |
Tushar Behera | c6d884c | 2012-05-12 16:12:25 +0900 | [diff] [blame] | 208 | [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256), |
| 209 | [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT), |
| 210 | [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN), |
| 211 | [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN), |
| 212 | [4] = DEFINE_RES_IRQ(IRQ_AC97), |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 213 | }; |
| 214 | |
| 215 | static struct s3c_audio_pdata s3c_ac97_pdata; |
| 216 | |
| 217 | static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32); |
| 218 | |
| 219 | struct platform_device s3c64xx_device_ac97 = { |
Jassi Brar | e610467 | 2010-11-22 15:36:00 +0900 | [diff] [blame] | 220 | .name = "samsung-ac97", |
Jassi Brar | de6985b | 2010-02-12 10:38:51 +0000 | [diff] [blame] | 221 | .id = -1, |
| 222 | .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource), |
| 223 | .resource = s3c64xx_ac97_resource, |
| 224 | .dev = { |
| 225 | .platform_data = &s3c_ac97_pdata, |
| 226 | .dma_mask = &s3c64xx_ac97_dmamask, |
| 227 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 228 | }, |
| 229 | }; |
| 230 | EXPORT_SYMBOL(s3c64xx_device_ac97); |
| 231 | |
| 232 | void __init s3c64xx_ac97_setup_gpio(int num) |
| 233 | { |
| 234 | if (num == S3C64XX_AC97_GPD) |
| 235 | s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd; |
| 236 | else |
| 237 | s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe; |
| 238 | } |