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