diff options
Diffstat (limited to 'sound/soc/s3c24xx')
23 files changed, 1111 insertions, 96 deletions
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index 923428fc1adb..b489f1ae103d 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig | |||
@@ -24,6 +24,9 @@ config SND_S3C64XX_SOC_I2S | |||
24 | select SND_S3C_I2SV2_SOC | 24 | select SND_S3C_I2SV2_SOC |
25 | select S3C64XX_DMA | 25 | select S3C64XX_DMA |
26 | 26 | ||
27 | config SND_S3C_SOC_PCM | ||
28 | tristate | ||
29 | |||
27 | config SND_S3C2443_SOC_AC97 | 30 | config SND_S3C2443_SOC_AC97 |
28 | tristate | 31 | tristate |
29 | select S3C2410_DMA | 32 | select S3C2410_DMA |
@@ -56,6 +59,15 @@ config SND_S3C24XX_SOC_JIVE_WM8750 | |||
56 | help | 59 | help |
57 | Sat Y if you want to add support for SoC audio on the Jive. | 60 | Sat Y if you want to add support for SoC audio on the Jive. |
58 | 61 | ||
62 | config SND_S3C64XX_SOC_WM8580 | ||
63 | tristate "SoC I2S Audio support for WM8580 on SMDK64XX" | ||
64 | depends on SND_S3C24XX_SOC && (MACH_SMDK6400 || MACH_SMDK6410) | ||
65 | depends on BROKEN | ||
66 | select SND_SOC_WM8580 | ||
67 | select SND_S3C64XX_SOC_I2S | ||
68 | help | ||
69 | Sat Y if you want to add support for SoC audio on the SMDK64XX. | ||
70 | |||
59 | config SND_S3C24XX_SOC_SMDK2443_WM9710 | 71 | config SND_S3C24XX_SOC_SMDK2443_WM9710 |
60 | tristate "SoC AC97 Audio support for SMDK2443 - WM9710" | 72 | tristate "SoC AC97 Audio support for SMDK2443 - WM9710" |
61 | depends on SND_S3C24XX_SOC && MACH_SMDK2443 | 73 | depends on SND_S3C24XX_SOC && MACH_SMDK2443 |
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile index 99f5a7dd3fc6..b744657733d7 100644 --- a/sound/soc/s3c24xx/Makefile +++ b/sound/soc/s3c24xx/Makefile | |||
@@ -1,10 +1,11 @@ | |||
1 | # S3c24XX Platform Support | 1 | # S3c24XX Platform Support |
2 | snd-soc-s3c24xx-objs := s3c24xx-pcm.o | 2 | snd-soc-s3c24xx-objs := s3c-dma.o |
3 | snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o | 3 | snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o |
4 | snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o | 4 | snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o |
5 | snd-soc-s3c64xx-i2s-objs := s3c64xx-i2s.o | 5 | snd-soc-s3c64xx-i2s-objs := s3c64xx-i2s.o |
6 | snd-soc-s3c2443-ac97-objs := s3c2443-ac97.o | 6 | snd-soc-s3c2443-ac97-objs := s3c2443-ac97.o |
7 | snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o | 7 | snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o |
8 | snd-soc-s3c-pcm-objs := s3c-pcm.o | ||
8 | 9 | ||
9 | obj-$(CONFIG_SND_S3C24XX_SOC) += snd-soc-s3c24xx.o | 10 | obj-$(CONFIG_SND_S3C24XX_SOC) += snd-soc-s3c24xx.o |
10 | obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o | 11 | obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o |
@@ -12,6 +13,7 @@ obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o | |||
12 | obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o | 13 | obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o |
13 | obj-$(CONFIG_SND_S3C64XX_SOC_I2S) += snd-soc-s3c64xx-i2s.o | 14 | obj-$(CONFIG_SND_S3C64XX_SOC_I2S) += snd-soc-s3c64xx-i2s.o |
14 | obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o | 15 | obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o |
16 | obj-$(CONFIG_SND_S3C_SOC_PCM) += snd-soc-s3c-pcm.o | ||
15 | 17 | ||
16 | # S3C24XX Machine Support | 18 | # S3C24XX Machine Support |
17 | snd-soc-jive-wm8750-objs := jive_wm8750.o | 19 | snd-soc-jive-wm8750-objs := jive_wm8750.o |
@@ -23,6 +25,7 @@ snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o | |||
23 | snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o | 25 | snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o |
24 | snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o | 26 | snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o |
25 | snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o | 27 | snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o |
28 | snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o | ||
26 | 29 | ||
27 | obj-$(CONFIG_SND_S3C24XX_SOC_JIVE_WM8750) += snd-soc-jive-wm8750.o | 30 | obj-$(CONFIG_SND_S3C24XX_SOC_JIVE_WM8750) += snd-soc-jive-wm8750.o |
28 | obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o | 31 | obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o |
@@ -33,4 +36,5 @@ obj-$(CONFIG_SND_S3C24XX_SOC_S3C24XX_UDA134X) += snd-soc-s3c24xx-uda134x.o | |||
33 | obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o | 36 | obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o |
34 | obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o | 37 | obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o |
35 | obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o | 38 | obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o |
39 | obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o | ||
36 | 40 | ||
diff --git a/sound/soc/s3c24xx/jive_wm8750.c b/sound/soc/s3c24xx/jive_wm8750.c index 93e6c87b7399..59dc2c6b56d9 100644 --- a/sound/soc/s3c24xx/jive_wm8750.c +++ b/sound/soc/s3c24xx/jive_wm8750.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | #include <asm/mach-types.h> | 26 | #include <asm/mach-types.h> |
27 | 27 | ||
28 | #include "s3c24xx-pcm.h" | 28 | #include "s3c-dma.h" |
29 | #include "s3c2412-i2s.h" | 29 | #include "s3c2412-i2s.h" |
30 | 30 | ||
31 | #include "../codecs/wm8750.h" | 31 | #include "../codecs/wm8750.h" |
diff --git a/sound/soc/s3c24xx/ln2440sbc_alc650.c b/sound/soc/s3c24xx/ln2440sbc_alc650.c index 12c71482d258..d00d359a03e6 100644 --- a/sound/soc/s3c24xx/ln2440sbc_alc650.c +++ b/sound/soc/s3c24xx/ln2440sbc_alc650.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <sound/soc-dapm.h> | 24 | #include <sound/soc-dapm.h> |
25 | 25 | ||
26 | #include "../codecs/ac97.h" | 26 | #include "../codecs/ac97.h" |
27 | #include "s3c24xx-pcm.h" | 27 | #include "s3c-dma.h" |
28 | #include "s3c24xx-ac97.h" | 28 | #include "s3c24xx-ac97.h" |
29 | 29 | ||
30 | static struct snd_soc_card ln2440sbc; | 30 | static struct snd_soc_card ln2440sbc; |
diff --git a/sound/soc/s3c24xx/neo1973_gta02_wm8753.c b/sound/soc/s3c24xx/neo1973_gta02_wm8753.c index 0c52e36ddd87..dea83d30a5c9 100644 --- a/sound/soc/s3c24xx/neo1973_gta02_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_gta02_wm8753.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <asm/io.h> | 32 | #include <asm/io.h> |
33 | #include <mach/gta02.h> | 33 | #include <mach/gta02.h> |
34 | #include "../codecs/wm8753.h" | 34 | #include "../codecs/wm8753.h" |
35 | #include "s3c24xx-pcm.h" | 35 | #include "s3c-dma.h" |
36 | #include "s3c24xx-i2s.h" | 36 | #include "s3c24xx-i2s.h" |
37 | 37 | ||
38 | static struct snd_soc_card neo1973_gta02; | 38 | static struct snd_soc_card neo1973_gta02; |
@@ -119,7 +119,7 @@ static int neo1973_gta02_hifi_hw_params(struct snd_pcm_substream *substream, | |||
119 | return ret; | 119 | return ret; |
120 | 120 | ||
121 | /* codec PLL input is PCLK/4 */ | 121 | /* codec PLL input is PCLK/4 */ |
122 | ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, | 122 | ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, |
123 | iis_clkrate / 4, pll_out); | 123 | iis_clkrate / 4, pll_out); |
124 | if (ret < 0) | 124 | if (ret < 0) |
125 | return ret; | 125 | return ret; |
@@ -133,7 +133,7 @@ static int neo1973_gta02_hifi_hw_free(struct snd_pcm_substream *substream) | |||
133 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | 133 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; |
134 | 134 | ||
135 | /* disable the PLL */ | 135 | /* disable the PLL */ |
136 | return snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, 0); | 136 | return snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, 0, 0); |
137 | } | 137 | } |
138 | 138 | ||
139 | /* | 139 | /* |
@@ -183,7 +183,7 @@ static int neo1973_gta02_voice_hw_params( | |||
183 | return ret; | 183 | return ret; |
184 | 184 | ||
185 | /* configue and enable PLL for 12.288MHz output */ | 185 | /* configue and enable PLL for 12.288MHz output */ |
186 | ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, | 186 | ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, |
187 | iis_clkrate / 4, 12288000); | 187 | iis_clkrate / 4, 12288000); |
188 | if (ret < 0) | 188 | if (ret < 0) |
189 | return ret; | 189 | return ret; |
@@ -197,7 +197,7 @@ static int neo1973_gta02_voice_hw_free(struct snd_pcm_substream *substream) | |||
197 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | 197 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; |
198 | 198 | ||
199 | /* disable the PLL */ | 199 | /* disable the PLL */ |
200 | return snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, 0); | 200 | return snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, 0, 0); |
201 | } | 201 | } |
202 | 202 | ||
203 | static struct snd_soc_ops neo1973_gta02_voice_ops = { | 203 | static struct snd_soc_ops neo1973_gta02_voice_ops = { |
diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 906709e6dd5f..0cb4f86f6d1e 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <mach/regs-clock.h> | 29 | #include <mach/regs-clock.h> |
30 | #include <mach/regs-gpio.h> | 30 | #include <mach/regs-gpio.h> |
31 | #include <mach/hardware.h> | 31 | #include <mach/hardware.h> |
32 | #include <plat/audio.h> | ||
33 | #include <linux/io.h> | 32 | #include <linux/io.h> |
34 | #include <mach/spi-gpio.h> | 33 | #include <mach/spi-gpio.h> |
35 | 34 | ||
@@ -37,7 +36,7 @@ | |||
37 | 36 | ||
38 | #include "../codecs/wm8753.h" | 37 | #include "../codecs/wm8753.h" |
39 | #include "lm4857.h" | 38 | #include "lm4857.h" |
40 | #include "s3c24xx-pcm.h" | 39 | #include "s3c-dma.h" |
41 | #include "s3c24xx-i2s.h" | 40 | #include "s3c24xx-i2s.h" |
42 | 41 | ||
43 | /* define the scenarios */ | 42 | /* define the scenarios */ |
@@ -137,7 +136,7 @@ static int neo1973_hifi_hw_params(struct snd_pcm_substream *substream, | |||
137 | return ret; | 136 | return ret; |
138 | 137 | ||
139 | /* codec PLL input is PCLK/4 */ | 138 | /* codec PLL input is PCLK/4 */ |
140 | ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, | 139 | ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, |
141 | iis_clkrate / 4, pll_out); | 140 | iis_clkrate / 4, pll_out); |
142 | if (ret < 0) | 141 | if (ret < 0) |
143 | return ret; | 142 | return ret; |
@@ -153,7 +152,7 @@ static int neo1973_hifi_hw_free(struct snd_pcm_substream *substream) | |||
153 | pr_debug("Entered %s\n", __func__); | 152 | pr_debug("Entered %s\n", __func__); |
154 | 153 | ||
155 | /* disable the PLL */ | 154 | /* disable the PLL */ |
156 | return snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, 0); | 155 | return snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, 0, 0); |
157 | } | 156 | } |
158 | 157 | ||
159 | /* | 158 | /* |
@@ -203,7 +202,7 @@ static int neo1973_voice_hw_params(struct snd_pcm_substream *substream, | |||
203 | return ret; | 202 | return ret; |
204 | 203 | ||
205 | /* configue and enable PLL for 12.288MHz output */ | 204 | /* configue and enable PLL for 12.288MHz output */ |
206 | ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, | 205 | ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, |
207 | iis_clkrate / 4, 12288000); | 206 | iis_clkrate / 4, 12288000); |
208 | if (ret < 0) | 207 | if (ret < 0) |
209 | return ret; | 208 | return ret; |
@@ -219,7 +218,7 @@ static int neo1973_voice_hw_free(struct snd_pcm_substream *substream) | |||
219 | pr_debug("Entered %s\n", __func__); | 218 | pr_debug("Entered %s\n", __func__); |
220 | 219 | ||
221 | /* disable the PLL */ | 220 | /* disable the PLL */ |
222 | return snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, 0); | 221 | return snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, 0, 0); |
223 | } | 222 | } |
224 | 223 | ||
225 | static struct snd_soc_ops neo1973_voice_ops = { | 224 | static struct snd_soc_ops neo1973_voice_ops = { |
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c-dma.c index 5cbbdc80fde3..7725e26d6c91 100644 --- a/sound/soc/s3c24xx/s3c24xx-pcm.c +++ b/sound/soc/s3c24xx/s3c-dma.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * s3c24xx-pcm.c -- ALSA Soc Audio Layer | 2 | * s3c-dma.c -- ALSA Soc Audio Layer |
3 | * | 3 | * |
4 | * (c) 2006 Wolfson Microelectronics PLC. | 4 | * (c) 2006 Wolfson Microelectronics PLC. |
5 | * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com | 5 | * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com |
@@ -29,11 +29,10 @@ | |||
29 | #include <asm/dma.h> | 29 | #include <asm/dma.h> |
30 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
31 | #include <mach/dma.h> | 31 | #include <mach/dma.h> |
32 | #include <plat/audio.h> | ||
33 | 32 | ||
34 | #include "s3c24xx-pcm.h" | 33 | #include "s3c-dma.h" |
35 | 34 | ||
36 | static const struct snd_pcm_hardware s3c24xx_pcm_hardware = { | 35 | static const struct snd_pcm_hardware s3c_dma_hardware = { |
37 | .info = SNDRV_PCM_INFO_INTERLEAVED | | 36 | .info = SNDRV_PCM_INFO_INTERLEAVED | |
38 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 37 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
39 | SNDRV_PCM_INFO_MMAP | | 38 | SNDRV_PCM_INFO_MMAP | |
@@ -63,23 +62,32 @@ struct s3c24xx_runtime_data { | |||
63 | dma_addr_t dma_start; | 62 | dma_addr_t dma_start; |
64 | dma_addr_t dma_pos; | 63 | dma_addr_t dma_pos; |
65 | dma_addr_t dma_end; | 64 | dma_addr_t dma_end; |
66 | struct s3c24xx_pcm_dma_params *params; | 65 | struct s3c_dma_params *params; |
67 | }; | 66 | }; |
68 | 67 | ||
69 | /* s3c24xx_pcm_enqueue | 68 | /* s3c_dma_enqueue |
70 | * | 69 | * |
71 | * place a dma buffer onto the queue for the dma system | 70 | * place a dma buffer onto the queue for the dma system |
72 | * to handle. | 71 | * to handle. |
73 | */ | 72 | */ |
74 | static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream) | 73 | static void s3c_dma_enqueue(struct snd_pcm_substream *substream) |
75 | { | 74 | { |
76 | struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; | 75 | struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; |
77 | dma_addr_t pos = prtd->dma_pos; | 76 | dma_addr_t pos = prtd->dma_pos; |
77 | unsigned int limit; | ||
78 | int ret; | 78 | int ret; |
79 | 79 | ||
80 | pr_debug("Entered %s\n", __func__); | 80 | pr_debug("Entered %s\n", __func__); |
81 | 81 | ||
82 | while (prtd->dma_loaded < prtd->dma_limit) { | 82 | if (s3c_dma_has_circular()) |
83 | limit = (prtd->dma_end - prtd->dma_start) / prtd->dma_period; | ||
84 | else | ||
85 | limit = prtd->dma_limit; | ||
86 | |||
87 | pr_debug("%s: loaded %d, limit %d\n", | ||
88 | __func__, prtd->dma_loaded, limit); | ||
89 | |||
90 | while (prtd->dma_loaded < limit) { | ||
83 | unsigned long len = prtd->dma_period; | 91 | unsigned long len = prtd->dma_period; |
84 | 92 | ||
85 | pr_debug("dma_loaded: %d\n", prtd->dma_loaded); | 93 | pr_debug("dma_loaded: %d\n", prtd->dma_loaded); |
@@ -123,21 +131,21 @@ static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel, | |||
123 | snd_pcm_period_elapsed(substream); | 131 | snd_pcm_period_elapsed(substream); |
124 | 132 | ||
125 | spin_lock(&prtd->lock); | 133 | spin_lock(&prtd->lock); |
126 | if (prtd->state & ST_RUNNING) { | 134 | if (prtd->state & ST_RUNNING && !s3c_dma_has_circular()) { |
127 | prtd->dma_loaded--; | 135 | prtd->dma_loaded--; |
128 | s3c24xx_pcm_enqueue(substream); | 136 | s3c_dma_enqueue(substream); |
129 | } | 137 | } |
130 | 138 | ||
131 | spin_unlock(&prtd->lock); | 139 | spin_unlock(&prtd->lock); |
132 | } | 140 | } |
133 | 141 | ||
134 | static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream, | 142 | static int s3c_dma_hw_params(struct snd_pcm_substream *substream, |
135 | struct snd_pcm_hw_params *params) | 143 | struct snd_pcm_hw_params *params) |
136 | { | 144 | { |
137 | struct snd_pcm_runtime *runtime = substream->runtime; | 145 | struct snd_pcm_runtime *runtime = substream->runtime; |
138 | struct s3c24xx_runtime_data *prtd = runtime->private_data; | 146 | struct s3c24xx_runtime_data *prtd = runtime->private_data; |
139 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 147 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
140 | struct s3c24xx_pcm_dma_params *dma = rtd->dai->cpu_dai->dma_data; | 148 | struct s3c_dma_params *dma = rtd->dai->cpu_dai->dma_data; |
141 | unsigned long totbytes = params_buffer_bytes(params); | 149 | unsigned long totbytes = params_buffer_bytes(params); |
142 | int ret = 0; | 150 | int ret = 0; |
143 | 151 | ||
@@ -164,6 +172,11 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream, | |||
164 | printk(KERN_ERR "failed to get dma channel\n"); | 172 | printk(KERN_ERR "failed to get dma channel\n"); |
165 | return ret; | 173 | return ret; |
166 | } | 174 | } |
175 | |||
176 | /* use the circular buffering if we have it available. */ | ||
177 | if (s3c_dma_has_circular()) | ||
178 | s3c2410_dma_setflags(prtd->params->channel, | ||
179 | S3C2410_DMAF_CIRCULAR); | ||
167 | } | 180 | } |
168 | 181 | ||
169 | s3c2410_dma_set_buffdone_fn(prtd->params->channel, | 182 | s3c2410_dma_set_buffdone_fn(prtd->params->channel, |
@@ -185,7 +198,7 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream, | |||
185 | return 0; | 198 | return 0; |
186 | } | 199 | } |
187 | 200 | ||
188 | static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream) | 201 | static int s3c_dma_hw_free(struct snd_pcm_substream *substream) |
189 | { | 202 | { |
190 | struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; | 203 | struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; |
191 | 204 | ||
@@ -202,7 +215,7 @@ static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream) | |||
202 | return 0; | 215 | return 0; |
203 | } | 216 | } |
204 | 217 | ||
205 | static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream) | 218 | static int s3c_dma_prepare(struct snd_pcm_substream *substream) |
206 | { | 219 | { |
207 | struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; | 220 | struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; |
208 | int ret = 0; | 221 | int ret = 0; |
@@ -235,12 +248,12 @@ static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream) | |||
235 | prtd->dma_pos = prtd->dma_start; | 248 | prtd->dma_pos = prtd->dma_start; |
236 | 249 | ||
237 | /* enqueue dma buffers */ | 250 | /* enqueue dma buffers */ |
238 | s3c24xx_pcm_enqueue(substream); | 251 | s3c_dma_enqueue(substream); |
239 | 252 | ||
240 | return ret; | 253 | return ret; |
241 | } | 254 | } |
242 | 255 | ||
243 | static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | 256 | static int s3c_dma_trigger(struct snd_pcm_substream *substream, int cmd) |
244 | { | 257 | { |
245 | struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; | 258 | struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; |
246 | int ret = 0; | 259 | int ret = 0; |
@@ -275,7 +288,7 @@ static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
275 | } | 288 | } |
276 | 289 | ||
277 | static snd_pcm_uframes_t | 290 | static snd_pcm_uframes_t |
278 | s3c24xx_pcm_pointer(struct snd_pcm_substream *substream) | 291 | s3c_dma_pointer(struct snd_pcm_substream *substream) |
279 | { | 292 | { |
280 | struct snd_pcm_runtime *runtime = substream->runtime; | 293 | struct snd_pcm_runtime *runtime = substream->runtime; |
281 | struct s3c24xx_runtime_data *prtd = runtime->private_data; | 294 | struct s3c24xx_runtime_data *prtd = runtime->private_data; |
@@ -310,7 +323,7 @@ s3c24xx_pcm_pointer(struct snd_pcm_substream *substream) | |||
310 | return bytes_to_frames(substream->runtime, res); | 323 | return bytes_to_frames(substream->runtime, res); |
311 | } | 324 | } |
312 | 325 | ||
313 | static int s3c24xx_pcm_open(struct snd_pcm_substream *substream) | 326 | static int s3c_dma_open(struct snd_pcm_substream *substream) |
314 | { | 327 | { |
315 | struct snd_pcm_runtime *runtime = substream->runtime; | 328 | struct snd_pcm_runtime *runtime = substream->runtime; |
316 | struct s3c24xx_runtime_data *prtd; | 329 | struct s3c24xx_runtime_data *prtd; |
@@ -318,7 +331,7 @@ static int s3c24xx_pcm_open(struct snd_pcm_substream *substream) | |||
318 | pr_debug("Entered %s\n", __func__); | 331 | pr_debug("Entered %s\n", __func__); |
319 | 332 | ||
320 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | 333 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); |
321 | snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware); | 334 | snd_soc_set_runtime_hwparams(substream, &s3c_dma_hardware); |
322 | 335 | ||
323 | prtd = kzalloc(sizeof(struct s3c24xx_runtime_data), GFP_KERNEL); | 336 | prtd = kzalloc(sizeof(struct s3c24xx_runtime_data), GFP_KERNEL); |
324 | if (prtd == NULL) | 337 | if (prtd == NULL) |
@@ -330,7 +343,7 @@ static int s3c24xx_pcm_open(struct snd_pcm_substream *substream) | |||
330 | return 0; | 343 | return 0; |
331 | } | 344 | } |
332 | 345 | ||
333 | static int s3c24xx_pcm_close(struct snd_pcm_substream *substream) | 346 | static int s3c_dma_close(struct snd_pcm_substream *substream) |
334 | { | 347 | { |
335 | struct snd_pcm_runtime *runtime = substream->runtime; | 348 | struct snd_pcm_runtime *runtime = substream->runtime; |
336 | struct s3c24xx_runtime_data *prtd = runtime->private_data; | 349 | struct s3c24xx_runtime_data *prtd = runtime->private_data; |
@@ -338,14 +351,14 @@ static int s3c24xx_pcm_close(struct snd_pcm_substream *substream) | |||
338 | pr_debug("Entered %s\n", __func__); | 351 | pr_debug("Entered %s\n", __func__); |
339 | 352 | ||
340 | if (!prtd) | 353 | if (!prtd) |
341 | pr_debug("s3c24xx_pcm_close called with prtd == NULL\n"); | 354 | pr_debug("s3c_dma_close called with prtd == NULL\n"); |
342 | 355 | ||
343 | kfree(prtd); | 356 | kfree(prtd); |
344 | 357 | ||
345 | return 0; | 358 | return 0; |
346 | } | 359 | } |
347 | 360 | ||
348 | static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream, | 361 | static int s3c_dma_mmap(struct snd_pcm_substream *substream, |
349 | struct vm_area_struct *vma) | 362 | struct vm_area_struct *vma) |
350 | { | 363 | { |
351 | struct snd_pcm_runtime *runtime = substream->runtime; | 364 | struct snd_pcm_runtime *runtime = substream->runtime; |
@@ -358,23 +371,23 @@ static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream, | |||
358 | runtime->dma_bytes); | 371 | runtime->dma_bytes); |
359 | } | 372 | } |
360 | 373 | ||
361 | static struct snd_pcm_ops s3c24xx_pcm_ops = { | 374 | static struct snd_pcm_ops s3c_dma_ops = { |
362 | .open = s3c24xx_pcm_open, | 375 | .open = s3c_dma_open, |
363 | .close = s3c24xx_pcm_close, | 376 | .close = s3c_dma_close, |
364 | .ioctl = snd_pcm_lib_ioctl, | 377 | .ioctl = snd_pcm_lib_ioctl, |
365 | .hw_params = s3c24xx_pcm_hw_params, | 378 | .hw_params = s3c_dma_hw_params, |
366 | .hw_free = s3c24xx_pcm_hw_free, | 379 | .hw_free = s3c_dma_hw_free, |
367 | .prepare = s3c24xx_pcm_prepare, | 380 | .prepare = s3c_dma_prepare, |
368 | .trigger = s3c24xx_pcm_trigger, | 381 | .trigger = s3c_dma_trigger, |
369 | .pointer = s3c24xx_pcm_pointer, | 382 | .pointer = s3c_dma_pointer, |
370 | .mmap = s3c24xx_pcm_mmap, | 383 | .mmap = s3c_dma_mmap, |
371 | }; | 384 | }; |
372 | 385 | ||
373 | static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | 386 | static int s3c_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) |
374 | { | 387 | { |
375 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | 388 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; |
376 | struct snd_dma_buffer *buf = &substream->dma_buffer; | 389 | struct snd_dma_buffer *buf = &substream->dma_buffer; |
377 | size_t size = s3c24xx_pcm_hardware.buffer_bytes_max; | 390 | size_t size = s3c_dma_hardware.buffer_bytes_max; |
378 | 391 | ||
379 | pr_debug("Entered %s\n", __func__); | 392 | pr_debug("Entered %s\n", __func__); |
380 | 393 | ||
@@ -389,7 +402,7 @@ static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | |||
389 | return 0; | 402 | return 0; |
390 | } | 403 | } |
391 | 404 | ||
392 | static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm) | 405 | static void s3c_dma_free_dma_buffers(struct snd_pcm *pcm) |
393 | { | 406 | { |
394 | struct snd_pcm_substream *substream; | 407 | struct snd_pcm_substream *substream; |
395 | struct snd_dma_buffer *buf; | 408 | struct snd_dma_buffer *buf; |
@@ -412,9 +425,9 @@ static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm) | |||
412 | } | 425 | } |
413 | } | 426 | } |
414 | 427 | ||
415 | static u64 s3c24xx_pcm_dmamask = DMA_BIT_MASK(32); | 428 | static u64 s3c_dma_mask = DMA_BIT_MASK(32); |
416 | 429 | ||
417 | static int s3c24xx_pcm_new(struct snd_card *card, | 430 | static int s3c_dma_new(struct snd_card *card, |
418 | struct snd_soc_dai *dai, struct snd_pcm *pcm) | 431 | struct snd_soc_dai *dai, struct snd_pcm *pcm) |
419 | { | 432 | { |
420 | int ret = 0; | 433 | int ret = 0; |
@@ -422,19 +435,19 @@ static int s3c24xx_pcm_new(struct snd_card *card, | |||
422 | pr_debug("Entered %s\n", __func__); | 435 | pr_debug("Entered %s\n", __func__); |
423 | 436 | ||
424 | if (!card->dev->dma_mask) | 437 | if (!card->dev->dma_mask) |
425 | card->dev->dma_mask = &s3c24xx_pcm_dmamask; | 438 | card->dev->dma_mask = &s3c_dma_mask; |
426 | if (!card->dev->coherent_dma_mask) | 439 | if (!card->dev->coherent_dma_mask) |
427 | card->dev->coherent_dma_mask = 0xffffffff; | 440 | card->dev->coherent_dma_mask = 0xffffffff; |
428 | 441 | ||
429 | if (dai->playback.channels_min) { | 442 | if (dai->playback.channels_min) { |
430 | ret = s3c24xx_pcm_preallocate_dma_buffer(pcm, | 443 | ret = s3c_preallocate_dma_buffer(pcm, |
431 | SNDRV_PCM_STREAM_PLAYBACK); | 444 | SNDRV_PCM_STREAM_PLAYBACK); |
432 | if (ret) | 445 | if (ret) |
433 | goto out; | 446 | goto out; |
434 | } | 447 | } |
435 | 448 | ||
436 | if (dai->capture.channels_min) { | 449 | if (dai->capture.channels_min) { |
437 | ret = s3c24xx_pcm_preallocate_dma_buffer(pcm, | 450 | ret = s3c_preallocate_dma_buffer(pcm, |
438 | SNDRV_PCM_STREAM_CAPTURE); | 451 | SNDRV_PCM_STREAM_CAPTURE); |
439 | if (ret) | 452 | if (ret) |
440 | goto out; | 453 | goto out; |
@@ -445,9 +458,9 @@ static int s3c24xx_pcm_new(struct snd_card *card, | |||
445 | 458 | ||
446 | struct snd_soc_platform s3c24xx_soc_platform = { | 459 | struct snd_soc_platform s3c24xx_soc_platform = { |
447 | .name = "s3c24xx-audio", | 460 | .name = "s3c24xx-audio", |
448 | .pcm_ops = &s3c24xx_pcm_ops, | 461 | .pcm_ops = &s3c_dma_ops, |
449 | .pcm_new = s3c24xx_pcm_new, | 462 | .pcm_new = s3c_dma_new, |
450 | .pcm_free = s3c24xx_pcm_free_dma_buffers, | 463 | .pcm_free = s3c_dma_free_dma_buffers, |
451 | }; | 464 | }; |
452 | EXPORT_SYMBOL_GPL(s3c24xx_soc_platform); | 465 | EXPORT_SYMBOL_GPL(s3c24xx_soc_platform); |
453 | 466 | ||
@@ -464,5 +477,5 @@ static void __exit s3c24xx_soc_platform_exit(void) | |||
464 | module_exit(s3c24xx_soc_platform_exit); | 477 | module_exit(s3c24xx_soc_platform_exit); |
465 | 478 | ||
466 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); | 479 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); |
467 | MODULE_DESCRIPTION("Samsung S3C24XX PCM DMA module"); | 480 | MODULE_DESCRIPTION("Samsung S3C Audio DMA module"); |
468 | MODULE_LICENSE("GPL"); | 481 | MODULE_LICENSE("GPL"); |
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.h b/sound/soc/s3c24xx/s3c-dma.h index 0088c79822ea..69bb6bf6fc1c 100644 --- a/sound/soc/s3c24xx/s3c24xx-pcm.h +++ b/sound/soc/s3c24xx/s3c-dma.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * s3c24xx-pcm.h -- | 2 | * s3c-dma.h -- |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
@@ -9,13 +9,13 @@ | |||
9 | * ALSA PCM interface for the Samsung S3C24xx CPU | 9 | * ALSA PCM interface for the Samsung S3C24xx CPU |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #ifndef _S3C24XX_PCM_H | 12 | #ifndef _S3C_AUDIO_H |
13 | #define _S3C24XX_PCM_H | 13 | #define _S3C_AUDIO_H |
14 | 14 | ||
15 | #define ST_RUNNING (1<<0) | 15 | #define ST_RUNNING (1<<0) |
16 | #define ST_OPENED (1<<1) | 16 | #define ST_OPENED (1<<1) |
17 | 17 | ||
18 | struct s3c24xx_pcm_dma_params { | 18 | struct s3c_dma_params { |
19 | struct s3c2410_dma_client *client; /* stream identifier */ | 19 | struct s3c2410_dma_client *client; /* stream identifier */ |
20 | int channel; /* Channel ID */ | 20 | int channel; /* Channel ID */ |
21 | dma_addr_t dma_addr; | 21 | dma_addr_t dma_addr; |
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c index 9bc4aa35caab..e994d8374fe6 100644 --- a/sound/soc/s3c24xx/s3c-i2s-v2.c +++ b/sound/soc/s3c24xx/s3c-i2s-v2.c | |||
@@ -32,11 +32,10 @@ | |||
32 | 32 | ||
33 | #include <plat/regs-s3c2412-iis.h> | 33 | #include <plat/regs-s3c2412-iis.h> |
34 | 34 | ||
35 | #include <plat/audio.h> | ||
36 | #include <mach/dma.h> | 35 | #include <mach/dma.h> |
37 | 36 | ||
38 | #include "s3c-i2s-v2.h" | 37 | #include "s3c-i2s-v2.h" |
39 | #include "s3c24xx-pcm.h" | 38 | #include "s3c-dma.h" |
40 | 39 | ||
41 | #undef S3C_IIS_V2_SUPPORTED | 40 | #undef S3C_IIS_V2_SUPPORTED |
42 | 41 | ||
@@ -312,12 +311,15 @@ static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, | |||
312 | 311 | ||
313 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | 312 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
314 | case SND_SOC_DAIFMT_RIGHT_J: | 313 | case SND_SOC_DAIFMT_RIGHT_J: |
314 | iismod |= S3C2412_IISMOD_LR_RLOW; | ||
315 | iismod |= S3C2412_IISMOD_SDF_MSB; | 315 | iismod |= S3C2412_IISMOD_SDF_MSB; |
316 | break; | 316 | break; |
317 | case SND_SOC_DAIFMT_LEFT_J: | 317 | case SND_SOC_DAIFMT_LEFT_J: |
318 | iismod |= S3C2412_IISMOD_LR_RLOW; | ||
318 | iismod |= S3C2412_IISMOD_SDF_LSB; | 319 | iismod |= S3C2412_IISMOD_SDF_LSB; |
319 | break; | 320 | break; |
320 | case SND_SOC_DAIFMT_I2S: | 321 | case SND_SOC_DAIFMT_I2S: |
322 | iismod &= ~S3C2412_IISMOD_LR_RLOW; | ||
321 | iismod |= S3C2412_IISMOD_SDF_IIS; | 323 | iismod |= S3C2412_IISMOD_SDF_IIS; |
322 | break; | 324 | break; |
323 | default: | 325 | default: |
@@ -392,7 +394,7 @@ static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
392 | int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | 394 | int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); |
393 | unsigned long irqs; | 395 | unsigned long irqs; |
394 | int ret = 0; | 396 | int ret = 0; |
395 | int channel = ((struct s3c24xx_pcm_dma_params *) | 397 | int channel = ((struct s3c_dma_params *) |
396 | rtd->dai->cpu_dai->dma_data)->channel; | 398 | rtd->dai->cpu_dai->dma_data)->channel; |
397 | 399 | ||
398 | pr_debug("Entered %s\n", __func__); | 400 | pr_debug("Entered %s\n", __func__); |
@@ -467,6 +469,31 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, | |||
467 | 469 | ||
468 | switch (div_id) { | 470 | switch (div_id) { |
469 | case S3C_I2SV2_DIV_BCLK: | 471 | case S3C_I2SV2_DIV_BCLK: |
472 | if (div > 3) { | ||
473 | /* convert value to bit field */ | ||
474 | |||
475 | switch (div) { | ||
476 | case 16: | ||
477 | div = S3C2412_IISMOD_BCLK_16FS; | ||
478 | break; | ||
479 | |||
480 | case 32: | ||
481 | div = S3C2412_IISMOD_BCLK_32FS; | ||
482 | break; | ||
483 | |||
484 | case 24: | ||
485 | div = S3C2412_IISMOD_BCLK_24FS; | ||
486 | break; | ||
487 | |||
488 | case 48: | ||
489 | div = S3C2412_IISMOD_BCLK_48FS; | ||
490 | break; | ||
491 | |||
492 | default: | ||
493 | return -EINVAL; | ||
494 | } | ||
495 | } | ||
496 | |||
470 | reg = readl(i2s->regs + S3C2412_IISMOD); | 497 | reg = readl(i2s->regs + S3C2412_IISMOD); |
471 | reg &= ~S3C2412_IISMOD_BCLK_MASK; | 498 | reg &= ~S3C2412_IISMOD_BCLK_MASK; |
472 | writel(reg | div, i2s->regs + S3C2412_IISMOD); | 499 | writel(reg | div, i2s->regs + S3C2412_IISMOD); |
@@ -626,7 +653,7 @@ int s3c_i2sv2_probe(struct platform_device *pdev, | |||
626 | } | 653 | } |
627 | 654 | ||
628 | i2s->iis_pclk = clk_get(dev, "iis"); | 655 | i2s->iis_pclk = clk_get(dev, "iis"); |
629 | if (i2s->iis_pclk == NULL) { | 656 | if (IS_ERR(i2s->iis_pclk)) { |
630 | dev_err(dev, "failed to get iis_clock\n"); | 657 | dev_err(dev, "failed to get iis_clock\n"); |
631 | iounmap(i2s->regs); | 658 | iounmap(i2s->regs); |
632 | return -ENOENT; | 659 | return -ENOENT; |
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.h b/sound/soc/s3c24xx/s3c-i2s-v2.h index f66854a77fb2..ecf8eaaed1db 100644 --- a/sound/soc/s3c24xx/s3c-i2s-v2.h +++ b/sound/soc/s3c24xx/s3c-i2s-v2.h | |||
@@ -49,8 +49,8 @@ struct s3c_i2sv2_info { | |||
49 | 49 | ||
50 | unsigned char master; | 50 | unsigned char master; |
51 | 51 | ||
52 | struct s3c24xx_pcm_dma_params *dma_playback; | 52 | struct s3c_dma_params *dma_playback; |
53 | struct s3c24xx_pcm_dma_params *dma_capture; | 53 | struct s3c_dma_params *dma_capture; |
54 | 54 | ||
55 | u32 suspend_iismod; | 55 | u32 suspend_iismod; |
56 | u32 suspend_iiscon; | 56 | u32 suspend_iiscon; |
diff --git a/sound/soc/s3c24xx/s3c-pcm.c b/sound/soc/s3c24xx/s3c-pcm.c new file mode 100644 index 000000000000..9e61a7c2d9ac --- /dev/null +++ b/sound/soc/s3c24xx/s3c-pcm.c | |||
@@ -0,0 +1,552 @@ | |||
1 | /* sound/soc/s3c24xx/s3c-pcm.c | ||
2 | * | ||
3 | * ALSA SoC Audio Layer - S3C PCM-Controller driver | ||
4 | * | ||
5 | * Copyright (c) 2009 Samsung Electronics Co. Ltd | ||
6 | * Author: Jaswinder Singh <jassi.brar@samsung.com> | ||
7 | * based upon I2S drivers by Ben Dooks. | ||
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/init.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/clk.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/gpio.h> | ||
21 | #include <linux/io.h> | ||
22 | |||
23 | #include <sound/core.h> | ||
24 | #include <sound/pcm.h> | ||
25 | #include <sound/pcm_params.h> | ||
26 | #include <sound/initval.h> | ||
27 | #include <sound/soc.h> | ||
28 | |||
29 | #include <plat/audio.h> | ||
30 | #include <plat/dma.h> | ||
31 | |||
32 | #include "s3c-dma.h" | ||
33 | #include "s3c-pcm.h" | ||
34 | |||
35 | static struct s3c2410_dma_client s3c_pcm_dma_client_out = { | ||
36 | .name = "PCM Stereo out" | ||
37 | }; | ||
38 | |||
39 | static struct s3c2410_dma_client s3c_pcm_dma_client_in = { | ||
40 | .name = "PCM Stereo in" | ||
41 | }; | ||
42 | |||
43 | static struct s3c_dma_params s3c_pcm_stereo_out[] = { | ||
44 | [0] = { | ||
45 | .client = &s3c_pcm_dma_client_out, | ||
46 | .dma_size = 4, | ||
47 | }, | ||
48 | [1] = { | ||
49 | .client = &s3c_pcm_dma_client_out, | ||
50 | .dma_size = 4, | ||
51 | }, | ||
52 | }; | ||
53 | |||
54 | static struct s3c_dma_params s3c_pcm_stereo_in[] = { | ||
55 | [0] = { | ||
56 | .client = &s3c_pcm_dma_client_in, | ||
57 | .dma_size = 4, | ||
58 | }, | ||
59 | [1] = { | ||
60 | .client = &s3c_pcm_dma_client_in, | ||
61 | .dma_size = 4, | ||
62 | }, | ||
63 | }; | ||
64 | |||
65 | static struct s3c_pcm_info s3c_pcm[2]; | ||
66 | |||
67 | static inline struct s3c_pcm_info *to_info(struct snd_soc_dai *cpu_dai) | ||
68 | { | ||
69 | return cpu_dai->private_data; | ||
70 | } | ||
71 | |||
72 | static void s3c_pcm_snd_txctrl(struct s3c_pcm_info *pcm, int on) | ||
73 | { | ||
74 | void __iomem *regs = pcm->regs; | ||
75 | u32 ctl, clkctl; | ||
76 | |||
77 | clkctl = readl(regs + S3C_PCM_CLKCTL); | ||
78 | ctl = readl(regs + S3C_PCM_CTL); | ||
79 | ctl &= ~(S3C_PCM_CTL_TXDIPSTICK_MASK | ||
80 | << S3C_PCM_CTL_TXDIPSTICK_SHIFT); | ||
81 | |||
82 | if (on) { | ||
83 | ctl |= S3C_PCM_CTL_TXDMA_EN; | ||
84 | ctl |= S3C_PCM_CTL_TXFIFO_EN; | ||
85 | ctl |= S3C_PCM_CTL_ENABLE; | ||
86 | ctl |= (0x20<<S3C_PCM_CTL_TXDIPSTICK_SHIFT); | ||
87 | clkctl |= S3C_PCM_CLKCTL_SERCLK_EN; | ||
88 | } else { | ||
89 | ctl &= ~S3C_PCM_CTL_TXDMA_EN; | ||
90 | ctl &= ~S3C_PCM_CTL_TXFIFO_EN; | ||
91 | |||
92 | if (!(ctl & S3C_PCM_CTL_RXFIFO_EN)) { | ||
93 | ctl &= ~S3C_PCM_CTL_ENABLE; | ||
94 | if (!pcm->idleclk) | ||
95 | clkctl |= S3C_PCM_CLKCTL_SERCLK_EN; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | writel(clkctl, regs + S3C_PCM_CLKCTL); | ||
100 | writel(ctl, regs + S3C_PCM_CTL); | ||
101 | } | ||
102 | |||
103 | static void s3c_pcm_snd_rxctrl(struct s3c_pcm_info *pcm, int on) | ||
104 | { | ||
105 | void __iomem *regs = pcm->regs; | ||
106 | u32 ctl, clkctl; | ||
107 | |||
108 | ctl = readl(regs + S3C_PCM_CTL); | ||
109 | clkctl = readl(regs + S3C_PCM_CLKCTL); | ||
110 | |||
111 | if (on) { | ||
112 | ctl |= S3C_PCM_CTL_RXDMA_EN; | ||
113 | ctl |= S3C_PCM_CTL_RXFIFO_EN; | ||
114 | ctl |= S3C_PCM_CTL_ENABLE; | ||
115 | clkctl |= S3C_PCM_CLKCTL_SERCLK_EN; | ||
116 | } else { | ||
117 | ctl &= ~S3C_PCM_CTL_RXDMA_EN; | ||
118 | ctl &= ~S3C_PCM_CTL_RXFIFO_EN; | ||
119 | |||
120 | if (!(ctl & S3C_PCM_CTL_TXFIFO_EN)) { | ||
121 | ctl &= ~S3C_PCM_CTL_ENABLE; | ||
122 | if (!pcm->idleclk) | ||
123 | clkctl |= S3C_PCM_CLKCTL_SERCLK_EN; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | writel(clkctl, regs + S3C_PCM_CLKCTL); | ||
128 | writel(ctl, regs + S3C_PCM_CTL); | ||
129 | } | ||
130 | |||
131 | static int s3c_pcm_trigger(struct snd_pcm_substream *substream, int cmd, | ||
132 | struct snd_soc_dai *dai) | ||
133 | { | ||
134 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
135 | struct s3c_pcm_info *pcm = to_info(rtd->dai->cpu_dai); | ||
136 | unsigned long flags; | ||
137 | |||
138 | dev_dbg(pcm->dev, "Entered %s\n", __func__); | ||
139 | |||
140 | switch (cmd) { | ||
141 | case SNDRV_PCM_TRIGGER_START: | ||
142 | case SNDRV_PCM_TRIGGER_RESUME: | ||
143 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
144 | spin_lock_irqsave(&pcm->lock, flags); | ||
145 | |||
146 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
147 | s3c_pcm_snd_rxctrl(pcm, 1); | ||
148 | else | ||
149 | s3c_pcm_snd_txctrl(pcm, 1); | ||
150 | |||
151 | spin_unlock_irqrestore(&pcm->lock, flags); | ||
152 | break; | ||
153 | |||
154 | case SNDRV_PCM_TRIGGER_STOP: | ||
155 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
156 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
157 | spin_lock_irqsave(&pcm->lock, flags); | ||
158 | |||
159 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
160 | s3c_pcm_snd_rxctrl(pcm, 0); | ||
161 | else | ||
162 | s3c_pcm_snd_txctrl(pcm, 0); | ||
163 | |||
164 | spin_unlock_irqrestore(&pcm->lock, flags); | ||
165 | break; | ||
166 | |||
167 | default: | ||
168 | return -EINVAL; | ||
169 | } | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static int s3c_pcm_hw_params(struct snd_pcm_substream *substream, | ||
175 | struct snd_pcm_hw_params *params, | ||
176 | struct snd_soc_dai *socdai) | ||
177 | { | ||
178 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
179 | struct snd_soc_dai_link *dai = rtd->dai; | ||
180 | struct s3c_pcm_info *pcm = to_info(dai->cpu_dai); | ||
181 | void __iomem *regs = pcm->regs; | ||
182 | struct clk *clk; | ||
183 | int sclk_div, sync_div; | ||
184 | unsigned long flags; | ||
185 | u32 clkctl; | ||
186 | |||
187 | dev_dbg(pcm->dev, "Entered %s\n", __func__); | ||
188 | |||
189 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
190 | dai->cpu_dai->dma_data = pcm->dma_playback; | ||
191 | else | ||
192 | dai->cpu_dai->dma_data = pcm->dma_capture; | ||
193 | |||
194 | /* Strictly check for sample size */ | ||
195 | switch (params_format(params)) { | ||
196 | case SNDRV_PCM_FORMAT_S16_LE: | ||
197 | break; | ||
198 | default: | ||
199 | return -EINVAL; | ||
200 | } | ||
201 | |||
202 | spin_lock_irqsave(&pcm->lock, flags); | ||
203 | |||
204 | /* Get hold of the PCMSOURCE_CLK */ | ||
205 | clkctl = readl(regs + S3C_PCM_CLKCTL); | ||
206 | if (clkctl & S3C_PCM_CLKCTL_SERCLKSEL_PCLK) | ||
207 | clk = pcm->pclk; | ||
208 | else | ||
209 | clk = pcm->cclk; | ||
210 | |||
211 | /* Set the SCLK divider */ | ||
212 | sclk_div = clk_get_rate(clk) / pcm->sclk_per_fs / | ||
213 | params_rate(params) / 2 - 1; | ||
214 | |||
215 | clkctl &= ~(S3C_PCM_CLKCTL_SCLKDIV_MASK | ||
216 | << S3C_PCM_CLKCTL_SCLKDIV_SHIFT); | ||
217 | clkctl |= ((sclk_div & S3C_PCM_CLKCTL_SCLKDIV_MASK) | ||
218 | << S3C_PCM_CLKCTL_SCLKDIV_SHIFT); | ||
219 | |||
220 | /* Set the SYNC divider */ | ||
221 | sync_div = pcm->sclk_per_fs - 1; | ||
222 | |||
223 | clkctl &= ~(S3C_PCM_CLKCTL_SYNCDIV_MASK | ||
224 | << S3C_PCM_CLKCTL_SYNCDIV_SHIFT); | ||
225 | clkctl |= ((sync_div & S3C_PCM_CLKCTL_SYNCDIV_MASK) | ||
226 | << S3C_PCM_CLKCTL_SYNCDIV_SHIFT); | ||
227 | |||
228 | writel(clkctl, regs + S3C_PCM_CLKCTL); | ||
229 | |||
230 | spin_unlock_irqrestore(&pcm->lock, flags); | ||
231 | |||
232 | dev_dbg(pcm->dev, "PCMSOURCE_CLK-%lu SCLK=%ufs \ | ||
233 | SCLK_DIV=%d SYNC_DIV=%d\n", | ||
234 | clk_get_rate(clk), pcm->sclk_per_fs, | ||
235 | sclk_div, sync_div); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int s3c_pcm_set_fmt(struct snd_soc_dai *cpu_dai, | ||
241 | unsigned int fmt) | ||
242 | { | ||
243 | struct s3c_pcm_info *pcm = to_info(cpu_dai); | ||
244 | void __iomem *regs = pcm->regs; | ||
245 | unsigned long flags; | ||
246 | int ret = 0; | ||
247 | u32 ctl; | ||
248 | |||
249 | dev_dbg(pcm->dev, "Entered %s\n", __func__); | ||
250 | |||
251 | spin_lock_irqsave(&pcm->lock, flags); | ||
252 | |||
253 | ctl = readl(regs + S3C_PCM_CTL); | ||
254 | |||
255 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
256 | case SND_SOC_DAIFMT_NB_NF: | ||
257 | /* Nothing to do, NB_NF by default */ | ||
258 | break; | ||
259 | default: | ||
260 | dev_err(pcm->dev, "Unsupported clock inversion!\n"); | ||
261 | ret = -EINVAL; | ||
262 | goto exit; | ||
263 | } | ||
264 | |||
265 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
266 | case SND_SOC_DAIFMT_CBS_CFS: | ||
267 | /* Nothing to do, Master by default */ | ||
268 | break; | ||
269 | default: | ||
270 | dev_err(pcm->dev, "Unsupported master/slave format!\n"); | ||
271 | ret = -EINVAL; | ||
272 | goto exit; | ||
273 | } | ||
274 | |||
275 | switch (fmt & SND_SOC_DAIFMT_CLOCK_MASK) { | ||
276 | case SND_SOC_DAIFMT_CONT: | ||
277 | pcm->idleclk = 1; | ||
278 | break; | ||
279 | case SND_SOC_DAIFMT_GATED: | ||
280 | pcm->idleclk = 0; | ||
281 | break; | ||
282 | default: | ||
283 | dev_err(pcm->dev, "Invalid Clock gating request!\n"); | ||
284 | ret = -EINVAL; | ||
285 | goto exit; | ||
286 | } | ||
287 | |||
288 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
289 | case SND_SOC_DAIFMT_DSP_A: | ||
290 | ctl |= S3C_PCM_CTL_TXMSB_AFTER_FSYNC; | ||
291 | ctl |= S3C_PCM_CTL_RXMSB_AFTER_FSYNC; | ||
292 | break; | ||
293 | case SND_SOC_DAIFMT_DSP_B: | ||
294 | ctl &= ~S3C_PCM_CTL_TXMSB_AFTER_FSYNC; | ||
295 | ctl &= ~S3C_PCM_CTL_RXMSB_AFTER_FSYNC; | ||
296 | break; | ||
297 | default: | ||
298 | dev_err(pcm->dev, "Unsupported data format!\n"); | ||
299 | ret = -EINVAL; | ||
300 | goto exit; | ||
301 | } | ||
302 | |||
303 | writel(ctl, regs + S3C_PCM_CTL); | ||
304 | |||
305 | exit: | ||
306 | spin_unlock_irqrestore(&pcm->lock, flags); | ||
307 | |||
308 | return ret; | ||
309 | } | ||
310 | |||
311 | static int s3c_pcm_set_clkdiv(struct snd_soc_dai *cpu_dai, | ||
312 | int div_id, int div) | ||
313 | { | ||
314 | struct s3c_pcm_info *pcm = to_info(cpu_dai); | ||
315 | |||
316 | switch (div_id) { | ||
317 | case S3C_PCM_SCLK_PER_FS: | ||
318 | pcm->sclk_per_fs = div; | ||
319 | break; | ||
320 | |||
321 | default: | ||
322 | return -EINVAL; | ||
323 | } | ||
324 | |||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | static int s3c_pcm_set_sysclk(struct snd_soc_dai *cpu_dai, | ||
329 | int clk_id, unsigned int freq, int dir) | ||
330 | { | ||
331 | struct s3c_pcm_info *pcm = to_info(cpu_dai); | ||
332 | void __iomem *regs = pcm->regs; | ||
333 | u32 clkctl = readl(regs + S3C_PCM_CLKCTL); | ||
334 | |||
335 | switch (clk_id) { | ||
336 | case S3C_PCM_CLKSRC_PCLK: | ||
337 | clkctl |= S3C_PCM_CLKCTL_SERCLKSEL_PCLK; | ||
338 | break; | ||
339 | |||
340 | case S3C_PCM_CLKSRC_MUX: | ||
341 | clkctl &= ~S3C_PCM_CLKCTL_SERCLKSEL_PCLK; | ||
342 | |||
343 | if (clk_get_rate(pcm->cclk) != freq) | ||
344 | clk_set_rate(pcm->cclk, freq); | ||
345 | |||
346 | break; | ||
347 | |||
348 | default: | ||
349 | return -EINVAL; | ||
350 | } | ||
351 | |||
352 | writel(clkctl, regs + S3C_PCM_CLKCTL); | ||
353 | |||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | static struct snd_soc_dai_ops s3c_pcm_dai_ops = { | ||
358 | .set_sysclk = s3c_pcm_set_sysclk, | ||
359 | .set_clkdiv = s3c_pcm_set_clkdiv, | ||
360 | .trigger = s3c_pcm_trigger, | ||
361 | .hw_params = s3c_pcm_hw_params, | ||
362 | .set_fmt = s3c_pcm_set_fmt, | ||
363 | }; | ||
364 | |||
365 | #define S3C_PCM_RATES SNDRV_PCM_RATE_8000_96000 | ||
366 | |||
367 | #define S3C_PCM_DECLARE(n) \ | ||
368 | { \ | ||
369 | .name = "samsung-pcm", \ | ||
370 | .id = (n), \ | ||
371 | .symmetric_rates = 1, \ | ||
372 | .ops = &s3c_pcm_dai_ops, \ | ||
373 | .playback = { \ | ||
374 | .channels_min = 2, \ | ||
375 | .channels_max = 2, \ | ||
376 | .rates = S3C_PCM_RATES, \ | ||
377 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | ||
378 | }, \ | ||
379 | .capture = { \ | ||
380 | .channels_min = 2, \ | ||
381 | .channels_max = 2, \ | ||
382 | .rates = S3C_PCM_RATES, \ | ||
383 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | ||
384 | }, \ | ||
385 | } | ||
386 | |||
387 | struct snd_soc_dai s3c_pcm_dai[] = { | ||
388 | S3C_PCM_DECLARE(0), | ||
389 | S3C_PCM_DECLARE(1), | ||
390 | }; | ||
391 | EXPORT_SYMBOL_GPL(s3c_pcm_dai); | ||
392 | |||
393 | static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev) | ||
394 | { | ||
395 | struct s3c_pcm_info *pcm; | ||
396 | struct snd_soc_dai *dai; | ||
397 | struct resource *mem_res, *dmatx_res, *dmarx_res; | ||
398 | struct s3c_audio_pdata *pcm_pdata; | ||
399 | int ret; | ||
400 | |||
401 | /* Check for valid device index */ | ||
402 | if ((pdev->id < 0) || pdev->id >= ARRAY_SIZE(s3c_pcm)) { | ||
403 | dev_err(&pdev->dev, "id %d out of range\n", pdev->id); | ||
404 | return -EINVAL; | ||
405 | } | ||
406 | |||
407 | pcm_pdata = pdev->dev.platform_data; | ||
408 | |||
409 | /* Check for availability of necessary resource */ | ||
410 | dmatx_res = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
411 | if (!dmatx_res) { | ||
412 | dev_err(&pdev->dev, "Unable to get PCM-TX dma resource\n"); | ||
413 | return -ENXIO; | ||
414 | } | ||
415 | |||
416 | dmarx_res = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
417 | if (!dmarx_res) { | ||
418 | dev_err(&pdev->dev, "Unable to get PCM-RX dma resource\n"); | ||
419 | return -ENXIO; | ||
420 | } | ||
421 | |||
422 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
423 | if (!mem_res) { | ||
424 | dev_err(&pdev->dev, "Unable to get register resource\n"); | ||
425 | return -ENXIO; | ||
426 | } | ||
427 | |||
428 | if (pcm_pdata && pcm_pdata->cfg_gpio && pcm_pdata->cfg_gpio(pdev)) { | ||
429 | dev_err(&pdev->dev, "Unable to configure gpio\n"); | ||
430 | return -EINVAL; | ||
431 | } | ||
432 | |||
433 | pcm = &s3c_pcm[pdev->id]; | ||
434 | pcm->dev = &pdev->dev; | ||
435 | |||
436 | spin_lock_init(&pcm->lock); | ||
437 | |||
438 | dai = &s3c_pcm_dai[pdev->id]; | ||
439 | dai->dev = &pdev->dev; | ||
440 | |||
441 | /* Default is 128fs */ | ||
442 | pcm->sclk_per_fs = 128; | ||
443 | |||
444 | pcm->cclk = clk_get(&pdev->dev, "audio-bus"); | ||
445 | if (IS_ERR(pcm->cclk)) { | ||
446 | dev_err(&pdev->dev, "failed to get audio-bus\n"); | ||
447 | ret = PTR_ERR(pcm->cclk); | ||
448 | goto err1; | ||
449 | } | ||
450 | clk_enable(pcm->cclk); | ||
451 | |||
452 | /* record our pcm structure for later use in the callbacks */ | ||
453 | dai->private_data = pcm; | ||
454 | |||
455 | if (!request_mem_region(mem_res->start, | ||
456 | resource_size(mem_res), "samsung-pcm")) { | ||
457 | dev_err(&pdev->dev, "Unable to request register region\n"); | ||
458 | ret = -EBUSY; | ||
459 | goto err2; | ||
460 | } | ||
461 | |||
462 | pcm->regs = ioremap(mem_res->start, 0x100); | ||
463 | if (pcm->regs == NULL) { | ||
464 | dev_err(&pdev->dev, "cannot ioremap registers\n"); | ||
465 | ret = -ENXIO; | ||
466 | goto err3; | ||
467 | } | ||
468 | |||
469 | pcm->pclk = clk_get(&pdev->dev, "pcm"); | ||
470 | if (IS_ERR(pcm->pclk)) { | ||
471 | dev_err(&pdev->dev, "failed to get pcm_clock\n"); | ||
472 | ret = -ENOENT; | ||
473 | goto err4; | ||
474 | } | ||
475 | clk_enable(pcm->pclk); | ||
476 | |||
477 | ret = snd_soc_register_dai(dai); | ||
478 | if (ret != 0) { | ||
479 | dev_err(&pdev->dev, "failed to get pcm_clock\n"); | ||
480 | goto err5; | ||
481 | } | ||
482 | |||
483 | s3c_pcm_stereo_in[pdev->id].dma_addr = mem_res->start | ||
484 | + S3C_PCM_RXFIFO; | ||
485 | s3c_pcm_stereo_out[pdev->id].dma_addr = mem_res->start | ||
486 | + S3C_PCM_TXFIFO; | ||
487 | |||
488 | s3c_pcm_stereo_in[pdev->id].channel = dmarx_res->start; | ||
489 | s3c_pcm_stereo_out[pdev->id].channel = dmatx_res->start; | ||
490 | |||
491 | pcm->dma_capture = &s3c_pcm_stereo_in[pdev->id]; | ||
492 | pcm->dma_playback = &s3c_pcm_stereo_out[pdev->id]; | ||
493 | |||
494 | return 0; | ||
495 | |||
496 | err5: | ||
497 | clk_disable(pcm->pclk); | ||
498 | clk_put(pcm->pclk); | ||
499 | err4: | ||
500 | iounmap(pcm->regs); | ||
501 | err3: | ||
502 | release_mem_region(mem_res->start, resource_size(mem_res)); | ||
503 | err2: | ||
504 | clk_disable(pcm->cclk); | ||
505 | clk_put(pcm->cclk); | ||
506 | err1: | ||
507 | return ret; | ||
508 | } | ||
509 | |||
510 | static __devexit int s3c_pcm_dev_remove(struct platform_device *pdev) | ||
511 | { | ||
512 | struct s3c_pcm_info *pcm = &s3c_pcm[pdev->id]; | ||
513 | struct resource *mem_res; | ||
514 | |||
515 | iounmap(pcm->regs); | ||
516 | |||
517 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
518 | release_mem_region(mem_res->start, resource_size(mem_res)); | ||
519 | |||
520 | clk_disable(pcm->cclk); | ||
521 | clk_disable(pcm->pclk); | ||
522 | clk_put(pcm->pclk); | ||
523 | clk_put(pcm->cclk); | ||
524 | |||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | static struct platform_driver s3c_pcm_driver = { | ||
529 | .probe = s3c_pcm_dev_probe, | ||
530 | .remove = s3c_pcm_dev_remove, | ||
531 | .driver = { | ||
532 | .name = "samsung-pcm", | ||
533 | .owner = THIS_MODULE, | ||
534 | }, | ||
535 | }; | ||
536 | |||
537 | static int __init s3c_pcm_init(void) | ||
538 | { | ||
539 | return platform_driver_register(&s3c_pcm_driver); | ||
540 | } | ||
541 | module_init(s3c_pcm_init); | ||
542 | |||
543 | static void __exit s3c_pcm_exit(void) | ||
544 | { | ||
545 | platform_driver_unregister(&s3c_pcm_driver); | ||
546 | } | ||
547 | module_exit(s3c_pcm_exit); | ||
548 | |||
549 | /* Module information */ | ||
550 | MODULE_AUTHOR("Jaswinder Singh, <jassi.brar@samsung.com>"); | ||
551 | MODULE_DESCRIPTION("S3C PCM Controller Driver"); | ||
552 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/s3c24xx/s3c-pcm.h b/sound/soc/s3c24xx/s3c-pcm.h new file mode 100644 index 000000000000..69ff9971692f --- /dev/null +++ b/sound/soc/s3c24xx/s3c-pcm.h | |||
@@ -0,0 +1,123 @@ | |||
1 | /* sound/soc/s3c24xx/s3c-pcm.h | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 as | ||
5 | * published by the Free Software Foundation. | ||
6 | * | ||
7 | */ | ||
8 | |||
9 | #ifndef __S3C_PCM_H | ||
10 | #define __S3C_PCM_H __FILE__ | ||
11 | |||
12 | /*Register Offsets */ | ||
13 | #define S3C_PCM_CTL (0x00) | ||
14 | #define S3C_PCM_CLKCTL (0x04) | ||
15 | #define S3C_PCM_TXFIFO (0x08) | ||
16 | #define S3C_PCM_RXFIFO (0x0C) | ||
17 | #define S3C_PCM_IRQCTL (0x10) | ||
18 | #define S3C_PCM_IRQSTAT (0x14) | ||
19 | #define S3C_PCM_FIFOSTAT (0x18) | ||
20 | #define S3C_PCM_CLRINT (0x20) | ||
21 | |||
22 | /* PCM_CTL Bit-Fields */ | ||
23 | #define S3C_PCM_CTL_TXDIPSTICK_MASK (0x3f) | ||
24 | #define S3C_PCM_CTL_TXDIPSTICK_SHIFT (13) | ||
25 | #define S3C_PCM_CTL_RXDIPSTICK_MSK (0x3f<<7) | ||
26 | #define S3C_PCM_CTL_TXDMA_EN (0x1<<6) | ||
27 | #define S3C_PCM_CTL_RXDMA_EN (0x1<<5) | ||
28 | #define S3C_PCM_CTL_TXMSB_AFTER_FSYNC (0x1<<4) | ||
29 | #define S3C_PCM_CTL_RXMSB_AFTER_FSYNC (0x1<<3) | ||
30 | #define S3C_PCM_CTL_TXFIFO_EN (0x1<<2) | ||
31 | #define S3C_PCM_CTL_RXFIFO_EN (0x1<<1) | ||
32 | #define S3C_PCM_CTL_ENABLE (0x1<<0) | ||
33 | |||
34 | /* PCM_CLKCTL Bit-Fields */ | ||
35 | #define S3C_PCM_CLKCTL_SERCLK_EN (0x1<<19) | ||
36 | #define S3C_PCM_CLKCTL_SERCLKSEL_PCLK (0x1<<18) | ||
37 | #define S3C_PCM_CLKCTL_SCLKDIV_MASK (0x1ff) | ||
38 | #define S3C_PCM_CLKCTL_SYNCDIV_MASK (0x1ff) | ||
39 | #define S3C_PCM_CLKCTL_SCLKDIV_SHIFT (9) | ||
40 | #define S3C_PCM_CLKCTL_SYNCDIV_SHIFT (0) | ||
41 | |||
42 | /* PCM_TXFIFO Bit-Fields */ | ||
43 | #define S3C_PCM_TXFIFO_DVALID (0x1<<16) | ||
44 | #define S3C_PCM_TXFIFO_DATA_MSK (0xffff<<0) | ||
45 | |||
46 | /* PCM_RXFIFO Bit-Fields */ | ||
47 | #define S3C_PCM_RXFIFO_DVALID (0x1<<16) | ||
48 | #define S3C_PCM_RXFIFO_DATA_MSK (0xffff<<0) | ||
49 | |||
50 | /* PCM_IRQCTL Bit-Fields */ | ||
51 | #define S3C_PCM_IRQCTL_IRQEN (0x1<<14) | ||
52 | #define S3C_PCM_IRQCTL_WRDEN (0x1<<12) | ||
53 | #define S3C_PCM_IRQCTL_TXEMPTYEN (0x1<<11) | ||
54 | #define S3C_PCM_IRQCTL_TXALMSTEMPTYEN (0x1<<10) | ||
55 | #define S3C_PCM_IRQCTL_TXFULLEN (0x1<<9) | ||
56 | #define S3C_PCM_IRQCTL_TXALMSTFULLEN (0x1<<8) | ||
57 | #define S3C_PCM_IRQCTL_TXSTARVEN (0x1<<7) | ||
58 | #define S3C_PCM_IRQCTL_TXERROVRFLEN (0x1<<6) | ||
59 | #define S3C_PCM_IRQCTL_RXEMPTEN (0x1<<5) | ||
60 | #define S3C_PCM_IRQCTL_RXALMSTEMPTEN (0x1<<4) | ||
61 | #define S3C_PCM_IRQCTL_RXFULLEN (0x1<<3) | ||
62 | #define S3C_PCM_IRQCTL_RXALMSTFULLEN (0x1<<2) | ||
63 | #define S3C_PCM_IRQCTL_RXSTARVEN (0x1<<1) | ||
64 | #define S3C_PCM_IRQCTL_RXERROVRFLEN (0x1<<0) | ||
65 | |||
66 | /* PCM_IRQSTAT Bit-Fields */ | ||
67 | #define S3C_PCM_IRQSTAT_IRQPND (0x1<<13) | ||
68 | #define S3C_PCM_IRQSTAT_WRD_XFER (0x1<<12) | ||
69 | #define S3C_PCM_IRQSTAT_TXEMPTY (0x1<<11) | ||
70 | #define S3C_PCM_IRQSTAT_TXALMSTEMPTY (0x1<<10) | ||
71 | #define S3C_PCM_IRQSTAT_TXFULL (0x1<<9) | ||
72 | #define S3C_PCM_IRQSTAT_TXALMSTFULL (0x1<<8) | ||
73 | #define S3C_PCM_IRQSTAT_TXSTARV (0x1<<7) | ||
74 | #define S3C_PCM_IRQSTAT_TXERROVRFL (0x1<<6) | ||
75 | #define S3C_PCM_IRQSTAT_RXEMPT (0x1<<5) | ||
76 | #define S3C_PCM_IRQSTAT_RXALMSTEMPT (0x1<<4) | ||
77 | #define S3C_PCM_IRQSTAT_RXFULL (0x1<<3) | ||
78 | #define S3C_PCM_IRQSTAT_RXALMSTFULL (0x1<<2) | ||
79 | #define S3C_PCM_IRQSTAT_RXSTARV (0x1<<1) | ||
80 | #define S3C_PCM_IRQSTAT_RXERROVRFL (0x1<<0) | ||
81 | |||
82 | /* PCM_FIFOSTAT Bit-Fields */ | ||
83 | #define S3C_PCM_FIFOSTAT_TXCNT_MSK (0x3f<<14) | ||
84 | #define S3C_PCM_FIFOSTAT_TXFIFOEMPTY (0x1<<13) | ||
85 | #define S3C_PCM_FIFOSTAT_TXFIFOALMSTEMPTY (0x1<<12) | ||
86 | #define S3C_PCM_FIFOSTAT_TXFIFOFULL (0x1<<11) | ||
87 | #define S3C_PCM_FIFOSTAT_TXFIFOALMSTFULL (0x1<<10) | ||
88 | #define S3C_PCM_FIFOSTAT_RXCNT_MSK (0x3f<<4) | ||
89 | #define S3C_PCM_FIFOSTAT_RXFIFOEMPTY (0x1<<3) | ||
90 | #define S3C_PCM_FIFOSTAT_RXFIFOALMSTEMPTY (0x1<<2) | ||
91 | #define S3C_PCM_FIFOSTAT_RXFIFOFULL (0x1<<1) | ||
92 | #define S3C_PCM_FIFOSTAT_RXFIFOALMSTFULL (0x1<<0) | ||
93 | |||
94 | #define S3C_PCM_CLKSRC_PCLK 0 | ||
95 | #define S3C_PCM_CLKSRC_MUX 1 | ||
96 | |||
97 | #define S3C_PCM_SCLK_PER_FS 0 | ||
98 | |||
99 | /** | ||
100 | * struct s3c_pcm_info - S3C PCM Controller information | ||
101 | * @dev: The parent device passed to use from the probe. | ||
102 | * @regs: The pointer to the device register block. | ||
103 | * @dma_playback: DMA information for playback channel. | ||
104 | * @dma_capture: DMA information for capture channel. | ||
105 | */ | ||
106 | struct s3c_pcm_info { | ||
107 | spinlock_t lock; | ||
108 | struct device *dev; | ||
109 | void __iomem *regs; | ||
110 | |||
111 | unsigned int sclk_per_fs; | ||
112 | |||
113 | /* Whether to keep PCMSCLK enabled even when idle(no active xfer) */ | ||
114 | unsigned int idleclk; | ||
115 | |||
116 | struct clk *pclk; | ||
117 | struct clk *cclk; | ||
118 | |||
119 | struct s3c_dma_params *dma_playback; | ||
120 | struct s3c_dma_params *dma_capture; | ||
121 | }; | ||
122 | |||
123 | #endif /* __S3C_PCM_H */ | ||
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index a587ec40b449..359e59346ba2 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c | |||
@@ -34,11 +34,10 @@ | |||
34 | 34 | ||
35 | #include <plat/regs-s3c2412-iis.h> | 35 | #include <plat/regs-s3c2412-iis.h> |
36 | 36 | ||
37 | #include <plat/audio.h> | ||
38 | #include <mach/regs-gpio.h> | 37 | #include <mach/regs-gpio.h> |
39 | #include <mach/dma.h> | 38 | #include <mach/dma.h> |
40 | 39 | ||
41 | #include "s3c24xx-pcm.h" | 40 | #include "s3c-dma.h" |
42 | #include "s3c2412-i2s.h" | 41 | #include "s3c2412-i2s.h" |
43 | 42 | ||
44 | #define S3C2412_I2S_DEBUG 0 | 43 | #define S3C2412_I2S_DEBUG 0 |
@@ -51,14 +50,14 @@ static struct s3c2410_dma_client s3c2412_dma_client_in = { | |||
51 | .name = "I2S PCM Stereo in" | 50 | .name = "I2S PCM Stereo in" |
52 | }; | 51 | }; |
53 | 52 | ||
54 | static struct s3c24xx_pcm_dma_params s3c2412_i2s_pcm_stereo_out = { | 53 | static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { |
55 | .client = &s3c2412_dma_client_out, | 54 | .client = &s3c2412_dma_client_out, |
56 | .channel = DMACH_I2S_OUT, | 55 | .channel = DMACH_I2S_OUT, |
57 | .dma_addr = S3C2410_PA_IIS + S3C2412_IISTXD, | 56 | .dma_addr = S3C2410_PA_IIS + S3C2412_IISTXD, |
58 | .dma_size = 4, | 57 | .dma_size = 4, |
59 | }; | 58 | }; |
60 | 59 | ||
61 | static struct s3c24xx_pcm_dma_params s3c2412_i2s_pcm_stereo_in = { | 60 | static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { |
62 | .client = &s3c2412_dma_client_in, | 61 | .client = &s3c2412_dma_client_in, |
63 | .channel = DMACH_I2S_IN, | 62 | .channel = DMACH_I2S_IN, |
64 | .dma_addr = S3C2410_PA_IIS + S3C2412_IISRXD, | 63 | .dma_addr = S3C2410_PA_IIS + S3C2412_IISRXD, |
diff --git a/sound/soc/s3c24xx/s3c2443-ac97.c b/sound/soc/s3c24xx/s3c2443-ac97.c index fc1beb0930b9..0191e3acb0b4 100644 --- a/sound/soc/s3c24xx/s3c2443-ac97.c +++ b/sound/soc/s3c24xx/s3c2443-ac97.c | |||
@@ -32,11 +32,10 @@ | |||
32 | #include <plat/regs-ac97.h> | 32 | #include <plat/regs-ac97.h> |
33 | #include <mach/regs-gpio.h> | 33 | #include <mach/regs-gpio.h> |
34 | #include <mach/regs-clock.h> | 34 | #include <mach/regs-clock.h> |
35 | #include <plat/audio.h> | ||
36 | #include <asm/dma.h> | 35 | #include <asm/dma.h> |
37 | #include <mach/dma.h> | 36 | #include <mach/dma.h> |
38 | 37 | ||
39 | #include "s3c24xx-pcm.h" | 38 | #include "s3c-dma.h" |
40 | #include "s3c24xx-ac97.h" | 39 | #include "s3c24xx-ac97.h" |
41 | 40 | ||
42 | struct s3c24xx_ac97_info { | 41 | struct s3c24xx_ac97_info { |
@@ -189,21 +188,21 @@ static struct s3c2410_dma_client s3c2443_dma_client_micin = { | |||
189 | .name = "AC97 Mic Mono in" | 188 | .name = "AC97 Mic Mono in" |
190 | }; | 189 | }; |
191 | 190 | ||
192 | static struct s3c24xx_pcm_dma_params s3c2443_ac97_pcm_stereo_out = { | 191 | static struct s3c_dma_params s3c2443_ac97_pcm_stereo_out = { |
193 | .client = &s3c2443_dma_client_out, | 192 | .client = &s3c2443_dma_client_out, |
194 | .channel = DMACH_PCM_OUT, | 193 | .channel = DMACH_PCM_OUT, |
195 | .dma_addr = S3C2440_PA_AC97 + S3C_AC97_PCM_DATA, | 194 | .dma_addr = S3C2440_PA_AC97 + S3C_AC97_PCM_DATA, |
196 | .dma_size = 4, | 195 | .dma_size = 4, |
197 | }; | 196 | }; |
198 | 197 | ||
199 | static struct s3c24xx_pcm_dma_params s3c2443_ac97_pcm_stereo_in = { | 198 | static struct s3c_dma_params s3c2443_ac97_pcm_stereo_in = { |
200 | .client = &s3c2443_dma_client_in, | 199 | .client = &s3c2443_dma_client_in, |
201 | .channel = DMACH_PCM_IN, | 200 | .channel = DMACH_PCM_IN, |
202 | .dma_addr = S3C2440_PA_AC97 + S3C_AC97_PCM_DATA, | 201 | .dma_addr = S3C2440_PA_AC97 + S3C_AC97_PCM_DATA, |
203 | .dma_size = 4, | 202 | .dma_size = 4, |
204 | }; | 203 | }; |
205 | 204 | ||
206 | static struct s3c24xx_pcm_dma_params s3c2443_ac97_mic_mono_in = { | 205 | static struct s3c_dma_params s3c2443_ac97_mic_mono_in = { |
207 | .client = &s3c2443_dma_client_micin, | 206 | .client = &s3c2443_dma_client_micin, |
208 | .channel = DMACH_MIC_IN, | 207 | .channel = DMACH_MIC_IN, |
209 | .dma_addr = S3C2440_PA_AC97 + S3C_AC97_MIC_DATA, | 208 | .dma_addr = S3C2440_PA_AC97 + S3C_AC97_MIC_DATA, |
@@ -291,7 +290,7 @@ static int s3c2443_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | |||
291 | { | 290 | { |
292 | u32 ac_glbctrl; | 291 | u32 ac_glbctrl; |
293 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 292 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
294 | int channel = ((struct s3c24xx_pcm_dma_params *) | 293 | int channel = ((struct s3c_dma_params *) |
295 | rtd->dai->cpu_dai->dma_data)->channel; | 294 | rtd->dai->cpu_dai->dma_data)->channel; |
296 | 295 | ||
297 | ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL); | 296 | ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL); |
@@ -340,7 +339,7 @@ static int s3c2443_ac97_mic_trigger(struct snd_pcm_substream *substream, | |||
340 | { | 339 | { |
341 | u32 ac_glbctrl; | 340 | u32 ac_glbctrl; |
342 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 341 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
343 | int channel = ((struct s3c24xx_pcm_dma_params *) | 342 | int channel = ((struct s3c_dma_params *) |
344 | rtd->dai->cpu_dai->dma_data)->channel; | 343 | rtd->dai->cpu_dai->dma_data)->channel; |
345 | 344 | ||
346 | ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL); | 345 | ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL); |
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 40e2c4790f0d..0bc5950b9f02 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c | |||
@@ -32,13 +32,13 @@ | |||
32 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
33 | #include <mach/regs-gpio.h> | 33 | #include <mach/regs-gpio.h> |
34 | #include <mach/regs-clock.h> | 34 | #include <mach/regs-clock.h> |
35 | #include <plat/audio.h> | 35 | |
36 | #include <asm/dma.h> | 36 | #include <asm/dma.h> |
37 | #include <mach/dma.h> | 37 | #include <mach/dma.h> |
38 | 38 | ||
39 | #include <plat/regs-iis.h> | 39 | #include <plat/regs-iis.h> |
40 | 40 | ||
41 | #include "s3c24xx-pcm.h" | 41 | #include "s3c-dma.h" |
42 | #include "s3c24xx-i2s.h" | 42 | #include "s3c24xx-i2s.h" |
43 | 43 | ||
44 | static struct s3c2410_dma_client s3c24xx_dma_client_out = { | 44 | static struct s3c2410_dma_client s3c24xx_dma_client_out = { |
@@ -49,14 +49,14 @@ static struct s3c2410_dma_client s3c24xx_dma_client_in = { | |||
49 | .name = "I2S PCM Stereo in" | 49 | .name = "I2S PCM Stereo in" |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static struct s3c24xx_pcm_dma_params s3c24xx_i2s_pcm_stereo_out = { | 52 | static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { |
53 | .client = &s3c24xx_dma_client_out, | 53 | .client = &s3c24xx_dma_client_out, |
54 | .channel = DMACH_I2S_OUT, | 54 | .channel = DMACH_I2S_OUT, |
55 | .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, | 55 | .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, |
56 | .dma_size = 2, | 56 | .dma_size = 2, |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static struct s3c24xx_pcm_dma_params s3c24xx_i2s_pcm_stereo_in = { | 59 | static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { |
60 | .client = &s3c24xx_dma_client_in, | 60 | .client = &s3c24xx_dma_client_in, |
61 | .channel = DMACH_I2S_IN, | 61 | .channel = DMACH_I2S_IN, |
62 | .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, | 62 | .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, |
@@ -258,12 +258,12 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
258 | switch (params_format(params)) { | 258 | switch (params_format(params)) { |
259 | case SNDRV_PCM_FORMAT_S8: | 259 | case SNDRV_PCM_FORMAT_S8: |
260 | iismod &= ~S3C2410_IISMOD_16BIT; | 260 | iismod &= ~S3C2410_IISMOD_16BIT; |
261 | ((struct s3c24xx_pcm_dma_params *) | 261 | ((struct s3c_dma_params *) |
262 | rtd->dai->cpu_dai->dma_data)->dma_size = 1; | 262 | rtd->dai->cpu_dai->dma_data)->dma_size = 1; |
263 | break; | 263 | break; |
264 | case SNDRV_PCM_FORMAT_S16_LE: | 264 | case SNDRV_PCM_FORMAT_S16_LE: |
265 | iismod |= S3C2410_IISMOD_16BIT; | 265 | iismod |= S3C2410_IISMOD_16BIT; |
266 | ((struct s3c24xx_pcm_dma_params *) | 266 | ((struct s3c_dma_params *) |
267 | rtd->dai->cpu_dai->dma_data)->dma_size = 2; | 267 | rtd->dai->cpu_dai->dma_data)->dma_size = 2; |
268 | break; | 268 | break; |
269 | default: | 269 | default: |
@@ -280,7 +280,7 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
280 | { | 280 | { |
281 | int ret = 0; | 281 | int ret = 0; |
282 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 282 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
283 | int channel = ((struct s3c24xx_pcm_dma_params *) | 283 | int channel = ((struct s3c_dma_params *) |
284 | rtd->dai->cpu_dai->dma_data)->channel; | 284 | rtd->dai->cpu_dai->dma_data)->channel; |
285 | 285 | ||
286 | pr_debug("Entered %s\n", __func__); | 286 | pr_debug("Entered %s\n", __func__); |
diff --git a/sound/soc/s3c24xx/s3c24xx_simtec.c b/sound/soc/s3c24xx/s3c24xx_simtec.c index 1966e0d5652d..d441c3b64631 100644 --- a/sound/soc/s3c24xx/s3c24xx_simtec.c +++ b/sound/soc/s3c24xx/s3c24xx_simtec.c | |||
@@ -21,7 +21,7 @@ | |||
21 | 21 | ||
22 | #include <plat/audio-simtec.h> | 22 | #include <plat/audio-simtec.h> |
23 | 23 | ||
24 | #include "s3c24xx-pcm.h" | 24 | #include "s3c-dma.h" |
25 | #include "s3c24xx-i2s.h" | 25 | #include "s3c24xx-i2s.h" |
26 | #include "s3c24xx_simtec.h" | 26 | #include "s3c24xx_simtec.h" |
27 | 27 | ||
@@ -270,7 +270,7 @@ static int attach_gpio_amp(struct device *dev, | |||
270 | gpio_direction_output(pd->amp_gain[1], 0); | 270 | gpio_direction_output(pd->amp_gain[1], 0); |
271 | } | 271 | } |
272 | 272 | ||
273 | /* note, curently we assume GPA0 isn't valid amp */ | 273 | /* note, currently we assume GPA0 isn't valid amp */ |
274 | if (pdata->amp_gpio > 0) { | 274 | if (pdata->amp_gpio > 0) { |
275 | ret = gpio_request(pd->amp_gpio, "gpio-amp"); | 275 | ret = gpio_request(pd->amp_gpio, "gpio-amp"); |
276 | if (ret) { | 276 | if (ret) { |
diff --git a/sound/soc/s3c24xx/s3c24xx_simtec_hermes.c b/sound/soc/s3c24xx/s3c24xx_simtec_hermes.c index 8346bd96eaf5..bdf8951af8e3 100644 --- a/sound/soc/s3c24xx/s3c24xx_simtec_hermes.c +++ b/sound/soc/s3c24xx/s3c24xx_simtec_hermes.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include <plat/audio-simtec.h> | 19 | #include <plat/audio-simtec.h> |
20 | 20 | ||
21 | #include "s3c24xx-pcm.h" | 21 | #include "s3c-dma.h" |
22 | #include "s3c24xx-i2s.h" | 22 | #include "s3c24xx-i2s.h" |
23 | #include "s3c24xx_simtec.h" | 23 | #include "s3c24xx_simtec.h" |
24 | 24 | ||
diff --git a/sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c b/sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c index 25797e096175..185c0acb5ce6 100644 --- a/sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c +++ b/sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include <plat/audio-simtec.h> | 19 | #include <plat/audio-simtec.h> |
20 | 20 | ||
21 | #include "s3c24xx-pcm.h" | 21 | #include "s3c-dma.h" |
22 | #include "s3c24xx-i2s.h" | 22 | #include "s3c24xx-i2s.h" |
23 | #include "s3c24xx_simtec.h" | 23 | #include "s3c24xx_simtec.h" |
24 | 24 | ||
diff --git a/sound/soc/s3c24xx/s3c24xx_uda134x.c b/sound/soc/s3c24xx/s3c24xx_uda134x.c index c215d32d6322..052d59659c29 100644 --- a/sound/soc/s3c24xx/s3c24xx_uda134x.c +++ b/sound/soc/s3c24xx/s3c24xx_uda134x.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include <plat/regs-iis.h> | 25 | #include <plat/regs-iis.h> |
26 | 26 | ||
27 | #include "s3c24xx-pcm.h" | 27 | #include "s3c-dma.h" |
28 | #include "s3c24xx-i2s.h" | 28 | #include "s3c24xx-i2s.h" |
29 | #include "../codecs/uda134x.h" | 29 | #include "../codecs/uda134x.h" |
30 | 30 | ||
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c index 3c06c401d0fb..cc7edb5f792d 100644 --- a/sound/soc/s3c24xx/s3c64xx-i2s.c +++ b/sound/soc/s3c24xx/s3c64xx-i2s.c | |||
@@ -31,12 +31,11 @@ | |||
31 | #include <plat/gpio-bank-d.h> | 31 | #include <plat/gpio-bank-d.h> |
32 | #include <plat/gpio-bank-e.h> | 32 | #include <plat/gpio-bank-e.h> |
33 | #include <plat/gpio-cfg.h> | 33 | #include <plat/gpio-cfg.h> |
34 | #include <plat/audio.h> | ||
35 | 34 | ||
36 | #include <mach/map.h> | 35 | #include <mach/map.h> |
37 | #include <mach/dma.h> | 36 | #include <mach/dma.h> |
38 | 37 | ||
39 | #include "s3c24xx-pcm.h" | 38 | #include "s3c-dma.h" |
40 | #include "s3c64xx-i2s.h" | 39 | #include "s3c64xx-i2s.h" |
41 | 40 | ||
42 | static struct s3c2410_dma_client s3c64xx_dma_client_out = { | 41 | static struct s3c2410_dma_client s3c64xx_dma_client_out = { |
@@ -47,7 +46,7 @@ static struct s3c2410_dma_client s3c64xx_dma_client_in = { | |||
47 | .name = "I2S PCM Stereo in" | 46 | .name = "I2S PCM Stereo in" |
48 | }; | 47 | }; |
49 | 48 | ||
50 | static struct s3c24xx_pcm_dma_params s3c64xx_i2s_pcm_stereo_out[2] = { | 49 | static struct s3c_dma_params s3c64xx_i2s_pcm_stereo_out[2] = { |
51 | [0] = { | 50 | [0] = { |
52 | .channel = DMACH_I2S0_OUT, | 51 | .channel = DMACH_I2S0_OUT, |
53 | .client = &s3c64xx_dma_client_out, | 52 | .client = &s3c64xx_dma_client_out, |
@@ -62,7 +61,7 @@ static struct s3c24xx_pcm_dma_params s3c64xx_i2s_pcm_stereo_out[2] = { | |||
62 | }, | 61 | }, |
63 | }; | 62 | }; |
64 | 63 | ||
65 | static struct s3c24xx_pcm_dma_params s3c64xx_i2s_pcm_stereo_in[2] = { | 64 | static struct s3c_dma_params s3c64xx_i2s_pcm_stereo_in[2] = { |
66 | [0] = { | 65 | [0] = { |
67 | .channel = DMACH_I2S0_IN, | 66 | .channel = DMACH_I2S0_IN, |
68 | .client = &s3c64xx_dma_client_in, | 67 | .client = &s3c64xx_dma_client_in, |
@@ -99,6 +98,19 @@ static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, | |||
99 | iismod |= S3C64XX_IISMOD_IMS_SYSMUX; | 98 | iismod |= S3C64XX_IISMOD_IMS_SYSMUX; |
100 | break; | 99 | break; |
101 | 100 | ||
101 | case S3C64XX_CLKSRC_CDCLK: | ||
102 | switch (dir) { | ||
103 | case SND_SOC_CLOCK_IN: | ||
104 | iismod |= S3C64XX_IISMOD_CDCLKCON; | ||
105 | break; | ||
106 | case SND_SOC_CLOCK_OUT: | ||
107 | iismod &= ~S3C64XX_IISMOD_CDCLKCON; | ||
108 | break; | ||
109 | default: | ||
110 | return -EINVAL; | ||
111 | } | ||
112 | break; | ||
113 | |||
102 | default: | 114 | default: |
103 | return -EINVAL; | 115 | return -EINVAL; |
104 | } | 116 | } |
@@ -111,8 +123,12 @@ static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, | |||
111 | struct clk *s3c64xx_i2s_get_clock(struct snd_soc_dai *dai) | 123 | struct clk *s3c64xx_i2s_get_clock(struct snd_soc_dai *dai) |
112 | { | 124 | { |
113 | struct s3c_i2sv2_info *i2s = to_info(dai); | 125 | struct s3c_i2sv2_info *i2s = to_info(dai); |
126 | u32 iismod = readl(i2s->regs + S3C2412_IISMOD); | ||
114 | 127 | ||
115 | return i2s->iis_cclk; | 128 | if (iismod & S3C64XX_IISMOD_IMS_SYSMUX) |
129 | return i2s->iis_cclk; | ||
130 | else | ||
131 | return i2s->iis_pclk; | ||
116 | } | 132 | } |
117 | EXPORT_SYMBOL_GPL(s3c64xx_i2s_get_clock); | 133 | EXPORT_SYMBOL_GPL(s3c64xx_i2s_get_clock); |
118 | 134 | ||
@@ -220,6 +236,8 @@ static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev) | |||
220 | goto err; | 236 | goto err; |
221 | } | 237 | } |
222 | 238 | ||
239 | clk_enable(i2s->iis_cclk); | ||
240 | |||
223 | ret = s3c_i2sv2_probe(pdev, dai, i2s, 0); | 241 | ret = s3c_i2sv2_probe(pdev, dai, i2s, 0); |
224 | if (ret) | 242 | if (ret) |
225 | goto err_clk; | 243 | goto err_clk; |
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.h b/sound/soc/s3c24xx/s3c64xx-i2s.h index 02148cee2613..abe7253b55fc 100644 --- a/sound/soc/s3c24xx/s3c64xx-i2s.h +++ b/sound/soc/s3c24xx/s3c64xx-i2s.h | |||
@@ -25,6 +25,7 @@ struct clk; | |||
25 | 25 | ||
26 | #define S3C64XX_CLKSRC_PCLK (0) | 26 | #define S3C64XX_CLKSRC_PCLK (0) |
27 | #define S3C64XX_CLKSRC_MUX (1) | 27 | #define S3C64XX_CLKSRC_MUX (1) |
28 | #define S3C64XX_CLKSRC_CDCLK (2) | ||
28 | 29 | ||
29 | extern struct snd_soc_dai s3c64xx_i2s_dai[]; | 30 | extern struct snd_soc_dai s3c64xx_i2s_dai[]; |
30 | 31 | ||
diff --git a/sound/soc/s3c24xx/smdk2443_wm9710.c b/sound/soc/s3c24xx/smdk2443_wm9710.c index a2a4f5323c17..12b783b12fcb 100644 --- a/sound/soc/s3c24xx/smdk2443_wm9710.c +++ b/sound/soc/s3c24xx/smdk2443_wm9710.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <sound/soc-dapm.h> | 20 | #include <sound/soc-dapm.h> |
21 | 21 | ||
22 | #include "../codecs/ac97.h" | 22 | #include "../codecs/ac97.h" |
23 | #include "s3c24xx-pcm.h" | 23 | #include "s3c-dma.h" |
24 | #include "s3c24xx-ac97.h" | 24 | #include "s3c24xx-ac97.h" |
25 | 25 | ||
26 | static struct snd_soc_card smdk2443; | 26 | static struct snd_soc_card smdk2443; |
diff --git a/sound/soc/s3c24xx/smdk64xx_wm8580.c b/sound/soc/s3c24xx/smdk64xx_wm8580.c new file mode 100644 index 000000000000..efe4901213a3 --- /dev/null +++ b/sound/soc/s3c24xx/smdk64xx_wm8580.c | |||
@@ -0,0 +1,268 @@ | |||
1 | /* | ||
2 | * smdk64xx_wm8580.c | ||
3 | * | ||
4 | * Copyright (c) 2009 Samsung Electronics Co. Ltd | ||
5 | * Author: Jaswinder Singh <jassi.brar@samsung.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/clk.h> | ||
15 | #include <sound/core.h> | ||
16 | #include <sound/pcm.h> | ||
17 | #include <sound/pcm_params.h> | ||
18 | #include <sound/soc.h> | ||
19 | #include <sound/soc-dapm.h> | ||
20 | |||
21 | #include "../codecs/wm8580.h" | ||
22 | #include "s3c-dma.h" | ||
23 | #include "s3c64xx-i2s.h" | ||
24 | |||
25 | #define S3C64XX_I2S_V4 2 | ||
26 | |||
27 | /* SMDK64XX has a 12MHZ crystal attached to WM8580 */ | ||
28 | #define SMDK64XX_WM8580_FREQ 12000000 | ||
29 | |||
30 | static int smdk64xx_hw_params(struct snd_pcm_substream *substream, | ||
31 | struct snd_pcm_hw_params *params) | ||
32 | { | ||
33 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
34 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
35 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
36 | unsigned int pll_out; | ||
37 | int bfs, rfs, ret; | ||
38 | |||
39 | switch (params_format(params)) { | ||
40 | case SNDRV_PCM_FORMAT_U8: | ||
41 | case SNDRV_PCM_FORMAT_S8: | ||
42 | bfs = 16; | ||
43 | break; | ||
44 | case SNDRV_PCM_FORMAT_U16_LE: | ||
45 | case SNDRV_PCM_FORMAT_S16_LE: | ||
46 | bfs = 32; | ||
47 | break; | ||
48 | default: | ||
49 | return -EINVAL; | ||
50 | } | ||
51 | |||
52 | /* The Fvco for WM8580 PLLs must fall within [90,100]MHz. | ||
53 | * This criterion can't be met if we request PLL output | ||
54 | * as {8000x256, 64000x256, 11025x256}Hz. | ||
55 | * As a wayout, we rather change rfs to a minimum value that | ||
56 | * results in (params_rate(params) * rfs), and itself, acceptable | ||
57 | * to both - the CODEC and the CPU. | ||
58 | */ | ||
59 | switch (params_rate(params)) { | ||
60 | case 16000: | ||
61 | case 22050: | ||
62 | case 32000: | ||
63 | case 44100: | ||
64 | case 48000: | ||
65 | case 88200: | ||
66 | case 96000: | ||
67 | rfs = 256; | ||
68 | break; | ||
69 | case 64000: | ||
70 | rfs = 384; | ||
71 | break; | ||
72 | case 8000: | ||
73 | case 11025: | ||
74 | rfs = 512; | ||
75 | break; | ||
76 | default: | ||
77 | return -EINVAL; | ||
78 | } | ||
79 | pll_out = params_rate(params) * rfs; | ||
80 | |||
81 | /* Set the Codec DAI configuration */ | ||
82 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | ||
83 | | SND_SOC_DAIFMT_NB_NF | ||
84 | | SND_SOC_DAIFMT_CBM_CFM); | ||
85 | if (ret < 0) | ||
86 | return ret; | ||
87 | |||
88 | /* Set the AP DAI configuration */ | ||
89 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | ||
90 | | SND_SOC_DAIFMT_NB_NF | ||
91 | | SND_SOC_DAIFMT_CBM_CFM); | ||
92 | if (ret < 0) | ||
93 | return ret; | ||
94 | |||
95 | ret = snd_soc_dai_set_sysclk(cpu_dai, S3C64XX_CLKSRC_CDCLK, | ||
96 | 0, SND_SOC_CLOCK_IN); | ||
97 | if (ret < 0) | ||
98 | return ret; | ||
99 | |||
100 | /* We use PCLK for basic ops in SoC-Slave mode */ | ||
101 | ret = snd_soc_dai_set_sysclk(cpu_dai, S3C64XX_CLKSRC_PCLK, | ||
102 | 0, SND_SOC_CLOCK_IN); | ||
103 | if (ret < 0) | ||
104 | return ret; | ||
105 | |||
106 | /* Set WM8580 to drive MCLK from its PLLA */ | ||
107 | ret = snd_soc_dai_set_clkdiv(codec_dai, WM8580_MCLK, | ||
108 | WM8580_CLKSRC_PLLA); | ||
109 | if (ret < 0) | ||
110 | return ret; | ||
111 | |||
112 | /* Explicitly set WM8580-DAC to source from MCLK */ | ||
113 | ret = snd_soc_dai_set_clkdiv(codec_dai, WM8580_DAC_CLKSEL, | ||
114 | WM8580_CLKSRC_MCLK); | ||
115 | if (ret < 0) | ||
116 | return ret; | ||
117 | |||
118 | ret = snd_soc_dai_set_pll(codec_dai, WM8580_PLLA, 0, | ||
119 | SMDK64XX_WM8580_FREQ, pll_out); | ||
120 | if (ret < 0) | ||
121 | return ret; | ||
122 | |||
123 | ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C_I2SV2_DIV_BCLK, bfs); | ||
124 | if (ret < 0) | ||
125 | return ret; | ||
126 | |||
127 | ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C_I2SV2_DIV_RCLK, rfs); | ||
128 | if (ret < 0) | ||
129 | return ret; | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * SMDK64XX WM8580 DAI operations. | ||
136 | */ | ||
137 | static struct snd_soc_ops smdk64xx_ops = { | ||
138 | .hw_params = smdk64xx_hw_params, | ||
139 | }; | ||
140 | |||
141 | /* SMDK64xx Playback widgets */ | ||
142 | static const struct snd_soc_dapm_widget wm8580_dapm_widgets_pbk[] = { | ||
143 | SND_SOC_DAPM_HP("Front-L/R", NULL), | ||
144 | SND_SOC_DAPM_HP("Center/Sub", NULL), | ||
145 | SND_SOC_DAPM_HP("Rear-L/R", NULL), | ||
146 | }; | ||
147 | |||
148 | /* SMDK64xx Capture widgets */ | ||
149 | static const struct snd_soc_dapm_widget wm8580_dapm_widgets_cpt[] = { | ||
150 | SND_SOC_DAPM_MIC("MicIn", NULL), | ||
151 | SND_SOC_DAPM_LINE("LineIn", NULL), | ||
152 | }; | ||
153 | |||
154 | /* SMDK-PAIFTX connections */ | ||
155 | static const struct snd_soc_dapm_route audio_map_tx[] = { | ||
156 | /* MicIn feeds AINL */ | ||
157 | {"AINL", NULL, "MicIn"}, | ||
158 | |||
159 | /* LineIn feeds AINL/R */ | ||
160 | {"AINL", NULL, "LineIn"}, | ||
161 | {"AINR", NULL, "LineIn"}, | ||
162 | }; | ||
163 | |||
164 | /* SMDK-PAIFRX connections */ | ||
165 | static const struct snd_soc_dapm_route audio_map_rx[] = { | ||
166 | /* Front Left/Right are fed VOUT1L/R */ | ||
167 | {"Front-L/R", NULL, "VOUT1L"}, | ||
168 | {"Front-L/R", NULL, "VOUT1R"}, | ||
169 | |||
170 | /* Center/Sub are fed VOUT2L/R */ | ||
171 | {"Center/Sub", NULL, "VOUT2L"}, | ||
172 | {"Center/Sub", NULL, "VOUT2R"}, | ||
173 | |||
174 | /* Rear Left/Right are fed VOUT3L/R */ | ||
175 | {"Rear-L/R", NULL, "VOUT3L"}, | ||
176 | {"Rear-L/R", NULL, "VOUT3R"}, | ||
177 | }; | ||
178 | |||
179 | static int smdk64xx_wm8580_init_paiftx(struct snd_soc_codec *codec) | ||
180 | { | ||
181 | /* Add smdk64xx specific Capture widgets */ | ||
182 | snd_soc_dapm_new_controls(codec, wm8580_dapm_widgets_cpt, | ||
183 | ARRAY_SIZE(wm8580_dapm_widgets_cpt)); | ||
184 | |||
185 | /* Set up PAIFTX audio path */ | ||
186 | snd_soc_dapm_add_routes(codec, audio_map_tx, ARRAY_SIZE(audio_map_tx)); | ||
187 | |||
188 | /* Enabling the microphone requires the fitting of a 0R | ||
189 | * resistor to connect the line from the microphone jack. | ||
190 | */ | ||
191 | snd_soc_dapm_disable_pin(codec, "MicIn"); | ||
192 | |||
193 | /* signal a DAPM event */ | ||
194 | snd_soc_dapm_sync(codec); | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static int smdk64xx_wm8580_init_paifrx(struct snd_soc_codec *codec) | ||
200 | { | ||
201 | /* Add smdk64xx specific Playback widgets */ | ||
202 | snd_soc_dapm_new_controls(codec, wm8580_dapm_widgets_pbk, | ||
203 | ARRAY_SIZE(wm8580_dapm_widgets_pbk)); | ||
204 | |||
205 | /* Set up PAIFRX audio path */ | ||
206 | snd_soc_dapm_add_routes(codec, audio_map_rx, ARRAY_SIZE(audio_map_rx)); | ||
207 | |||
208 | /* signal a DAPM event */ | ||
209 | snd_soc_dapm_sync(codec); | ||
210 | |||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | static struct snd_soc_dai_link smdk64xx_dai[] = { | ||
215 | { /* Primary Playback i/f */ | ||
216 | .name = "WM8580 PAIF RX", | ||
217 | .stream_name = "Playback", | ||
218 | .cpu_dai = &s3c64xx_i2s_dai[S3C64XX_I2S_V4], | ||
219 | .codec_dai = &wm8580_dai[WM8580_DAI_PAIFRX], | ||
220 | .init = smdk64xx_wm8580_init_paifrx, | ||
221 | .ops = &smdk64xx_ops, | ||
222 | }, | ||
223 | { /* Primary Capture i/f */ | ||
224 | .name = "WM8580 PAIF TX", | ||
225 | .stream_name = "Capture", | ||
226 | .cpu_dai = &s3c64xx_i2s_dai[S3C64XX_I2S_V4], | ||
227 | .codec_dai = &wm8580_dai[WM8580_DAI_PAIFTX], | ||
228 | .init = smdk64xx_wm8580_init_paiftx, | ||
229 | .ops = &smdk64xx_ops, | ||
230 | }, | ||
231 | }; | ||
232 | |||
233 | static struct snd_soc_card smdk64xx = { | ||
234 | .name = "smdk64xx", | ||
235 | .platform = &s3c24xx_soc_platform, | ||
236 | .dai_link = smdk64xx_dai, | ||
237 | .num_links = ARRAY_SIZE(smdk64xx_dai), | ||
238 | }; | ||
239 | |||
240 | static struct snd_soc_device smdk64xx_snd_devdata = { | ||
241 | .card = &smdk64xx, | ||
242 | .codec_dev = &soc_codec_dev_wm8580, | ||
243 | }; | ||
244 | |||
245 | static struct platform_device *smdk64xx_snd_device; | ||
246 | |||
247 | static int __init smdk64xx_audio_init(void) | ||
248 | { | ||
249 | int ret; | ||
250 | |||
251 | smdk64xx_snd_device = platform_device_alloc("soc-audio", -1); | ||
252 | if (!smdk64xx_snd_device) | ||
253 | return -ENOMEM; | ||
254 | |||
255 | platform_set_drvdata(smdk64xx_snd_device, &smdk64xx_snd_devdata); | ||
256 | smdk64xx_snd_devdata.dev = &smdk64xx_snd_device->dev; | ||
257 | ret = platform_device_add(smdk64xx_snd_device); | ||
258 | |||
259 | if (ret) | ||
260 | platform_device_put(smdk64xx_snd_device); | ||
261 | |||
262 | return ret; | ||
263 | } | ||
264 | module_init(smdk64xx_audio_init); | ||
265 | |||
266 | MODULE_AUTHOR("Jaswinder Singh, jassi.brar@samsung.com"); | ||
267 | MODULE_DESCRIPTION("ALSA SoC SMDK64XX WM8580"); | ||
268 | MODULE_LICENSE("GPL"); | ||