diff options
author | Ben Dooks <ben@simtec.co.uk> | 2009-03-03 19:49:31 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-03-06 08:37:08 -0500 |
commit | f8cf8176c7fc2c790e900595755b93e30633754d (patch) | |
tree | ae20b9200fae1b94b5945b4a25fbc7b028f7acc6 /sound | |
parent | dc85447b196a683784eb85654c436fd58c3e2ed1 (diff) |
ASoC: Add s3c64xx-i2s support
Add the initial code to support the S3C64XX I2S hardware using the
s3c-i2s-v2 core code.
Signed-off-by: Ben Dooks <ben@simtec.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/s3c24xx/Kconfig | 6 | ||||
-rw-r--r-- | sound/soc/s3c24xx/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/s3c24xx/s3c64xx-i2s.c | 220 | ||||
-rw-r--r-- | sound/soc/s3c24xx/s3c64xx-i2s.h | 31 |
4 files changed, 258 insertions, 1 deletions
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index bd98adaa5b0b..036a4965c950 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config SND_S3C24XX_SOC | 1 | config SND_S3C24XX_SOC |
2 | tristate "SoC Audio for the Samsung S3C24XX chips" | 2 | tristate "SoC Audio for the Samsung S3C24XX chips" |
3 | depends on ARCH_S3C2410 | 3 | depends on ARCH_S3C2410 || ARCH_S3C64XX |
4 | help | 4 | help |
5 | Say Y or M if you want to add support for codecs attached to | 5 | Say Y or M if you want to add support for codecs attached to |
6 | the S3C24XX AC97, I2S or SSP interface. You will also need | 6 | the S3C24XX AC97, I2S or SSP interface. You will also need |
@@ -16,6 +16,10 @@ config SND_S3C2412_SOC_I2S | |||
16 | tristate | 16 | tristate |
17 | select SND_S3C_I2SV2_SOC | 17 | select SND_S3C_I2SV2_SOC |
18 | 18 | ||
19 | config SND_S3C64XX_SOC_I2S | ||
20 | tristate | ||
21 | select SND_S3C_I2SV2_SOC | ||
22 | |||
19 | config SND_S3C2443_SOC_AC97 | 23 | config SND_S3C2443_SOC_AC97 |
20 | tristate | 24 | tristate |
21 | select AC97_BUS | 25 | select AC97_BUS |
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile index 848981e18ac3..07a93a2ebe5f 100644 --- a/sound/soc/s3c24xx/Makefile +++ b/sound/soc/s3c24xx/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | snd-soc-s3c24xx-objs := s3c24xx-pcm.o | 2 | snd-soc-s3c24xx-objs := s3c24xx-pcm.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-s3c2443-ac97-objs := s3c2443-ac97.o | 6 | snd-soc-s3c2443-ac97-objs := s3c2443-ac97.o |
6 | snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o | 7 | snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o |
7 | 8 | ||
@@ -9,6 +10,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC) += snd-soc-s3c24xx.o | |||
9 | obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o | 10 | obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o |
10 | obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o | 11 | obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o |
11 | obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o | 12 | obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o |
13 | obj-$(CONFIG_SND_S3C64XX_SOC_I2S) += snd-soc-s3c64xx-i2s.o | ||
12 | obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o | 14 | obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o |
13 | 15 | ||
14 | # S3C24XX Machine Support | 16 | # S3C24XX Machine Support |
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c new file mode 100644 index 000000000000..6e1e85dc1ff2 --- /dev/null +++ b/sound/soc/s3c24xx/s3c64xx-i2s.c | |||
@@ -0,0 +1,220 @@ | |||
1 | /* sound/soc/s3c24xx/s3c64xx-i2s.c | ||
2 | * | ||
3 | * ALSA SoC Audio Layer - S3C64XX I2S driver | ||
4 | * | ||
5 | * Copyright 2008 Openmoko, Inc. | ||
6 | * Copyright 2008 Simtec Electronics | ||
7 | * Ben Dooks <ben@simtec.co.uk> | ||
8 | * http://armlinux.simtec.co.uk/ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/init.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/clk.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/gpio.h> | ||
22 | #include <linux/io.h> | ||
23 | |||
24 | #include <sound/core.h> | ||
25 | #include <sound/pcm.h> | ||
26 | #include <sound/pcm_params.h> | ||
27 | #include <sound/initval.h> | ||
28 | #include <sound/soc.h> | ||
29 | |||
30 | #include <plat/regs-s3c2412-iis.h> | ||
31 | #include <plat/gpio-bank-d.h> | ||
32 | #include <plat/gpio-bank-e.h> | ||
33 | #include <plat/gpio-cfg.h> | ||
34 | #include <plat/audio.h> | ||
35 | |||
36 | #include <mach/map.h> | ||
37 | #include <mach/dma.h> | ||
38 | |||
39 | #include "s3c24xx-pcm.h" | ||
40 | #include "s3c64xx-i2s.h" | ||
41 | |||
42 | static struct s3c2410_dma_client s3c64xx_dma_client_out = { | ||
43 | .name = "I2S PCM Stereo out" | ||
44 | }; | ||
45 | |||
46 | static struct s3c2410_dma_client s3c64xx_dma_client_in = { | ||
47 | .name = "I2S PCM Stereo in" | ||
48 | }; | ||
49 | |||
50 | static struct s3c24xx_pcm_dma_params s3c64xx_i2s_pcm_stereo_out[2] = { | ||
51 | [0] = { | ||
52 | .channel = DMACH_I2S0_OUT, | ||
53 | .client = &s3c64xx_dma_client_out, | ||
54 | .dma_addr = S3C64XX_PA_IIS0 + S3C2412_IISTXD, | ||
55 | .dma_size = 4, | ||
56 | }, | ||
57 | [1] = { | ||
58 | .channel = DMACH_I2S1_OUT, | ||
59 | .client = &s3c64xx_dma_client_out, | ||
60 | .dma_addr = S3C64XX_PA_IIS1 + S3C2412_IISTXD, | ||
61 | .dma_size = 4, | ||
62 | }, | ||
63 | }; | ||
64 | |||
65 | static struct s3c24xx_pcm_dma_params s3c64xx_i2s_pcm_stereo_in[2] = { | ||
66 | [0] = { | ||
67 | .channel = DMACH_I2S0_IN, | ||
68 | .client = &s3c64xx_dma_client_in, | ||
69 | .dma_addr = S3C64XX_PA_IIS0 + S3C2412_IISRXD, | ||
70 | .dma_size = 4, | ||
71 | }, | ||
72 | [1] = { | ||
73 | .channel = DMACH_I2S1_IN, | ||
74 | .client = &s3c64xx_dma_client_in, | ||
75 | .dma_addr = S3C64XX_PA_IIS1 + S3C2412_IISRXD, | ||
76 | .dma_size = 4, | ||
77 | }, | ||
78 | }; | ||
79 | |||
80 | static struct s3c_i2sv2_info s3c64xx_i2s[2]; | ||
81 | |||
82 | static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) | ||
83 | { | ||
84 | return cpu_dai->private_data; | ||
85 | } | ||
86 | |||
87 | static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, | ||
88 | int clk_id, unsigned int freq, int dir) | ||
89 | { | ||
90 | struct s3c_i2sv2_info *i2s = to_info(cpu_dai); | ||
91 | u32 iismod = readl(i2s->regs + S3C2412_IISMOD); | ||
92 | |||
93 | switch (clk_id) { | ||
94 | case S3C64XX_CLKSRC_PCLK: | ||
95 | iismod &= ~S3C64XX_IISMOD_IMS_SYSMUX; | ||
96 | break; | ||
97 | |||
98 | case S3C64XX_CLKSRC_MUX: | ||
99 | iismod |= S3C64XX_IISMOD_IMS_SYSMUX; | ||
100 | break; | ||
101 | |||
102 | default: | ||
103 | return -EINVAL; | ||
104 | } | ||
105 | |||
106 | writel(iismod, i2s->regs + S3C2412_IISMOD); | ||
107 | |||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | |||
112 | unsigned long s3c64xx_i2s_get_clockrate(struct snd_soc_dai *dai) | ||
113 | { | ||
114 | struct s3c_i2sv2_info *i2s = to_info(dai); | ||
115 | |||
116 | return clk_get_rate(i2s->iis_cclk); | ||
117 | } | ||
118 | EXPORT_SYMBOL_GPL(s3c64xx_i2s_get_clockrate); | ||
119 | |||
120 | static int s3c64xx_i2s_probe(struct platform_device *pdev, | ||
121 | struct snd_soc_dai *dai) | ||
122 | { | ||
123 | struct device *dev = &pdev->dev; | ||
124 | struct s3c_i2sv2_info *i2s; | ||
125 | int ret; | ||
126 | |||
127 | dev_dbg(dev, "%s: probing dai %d\n", __func__, pdev->id); | ||
128 | |||
129 | if (pdev->id < 0 || pdev->id > ARRAY_SIZE(s3c64xx_i2s)) { | ||
130 | dev_err(dev, "id %d out of range\n", pdev->id); | ||
131 | return -EINVAL; | ||
132 | } | ||
133 | |||
134 | i2s = &s3c64xx_i2s[pdev->id]; | ||
135 | |||
136 | ret = s3c_i2sv2_probe(pdev, dai, i2s, | ||
137 | pdev->id ? S3C64XX_PA_IIS1 : S3C64XX_PA_IIS0); | ||
138 | if (ret) | ||
139 | return ret; | ||
140 | |||
141 | i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id]; | ||
142 | i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id]; | ||
143 | |||
144 | i2s->iis_cclk = clk_get(dev, "audio-bus"); | ||
145 | if (IS_ERR(i2s->iis_cclk)) { | ||
146 | dev_err(dev, "failed to get audio-bus"); | ||
147 | iounmap(i2s->regs); | ||
148 | return -ENODEV; | ||
149 | } | ||
150 | |||
151 | /* configure GPIO for i2s port */ | ||
152 | switch (pdev->id) { | ||
153 | case 0: | ||
154 | s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK); | ||
155 | s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK); | ||
156 | s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_I2S0_LRCLK); | ||
157 | s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_I2S0_DI); | ||
158 | s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_I2S0_D0); | ||
159 | break; | ||
160 | case 1: | ||
161 | s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_I2S1_CLK); | ||
162 | s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_I2S1_CDCLK); | ||
163 | s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_I2S1_LRCLK); | ||
164 | s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_I2S1_DI); | ||
165 | s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_I2S1_D0); | ||
166 | } | ||
167 | |||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | |||
172 | #define S3C64XX_I2S_RATES \ | ||
173 | (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ | ||
174 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ | ||
175 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) | ||
176 | |||
177 | #define S3C64XX_I2S_FMTS \ | ||
178 | (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE) | ||
179 | |||
180 | struct snd_soc_dai s3c64xx_i2s_dai = { | ||
181 | .name = "s3c64xx-i2s", | ||
182 | .id = 0, | ||
183 | .probe = s3c64xx_i2s_probe, | ||
184 | .playback = { | ||
185 | .channels_min = 2, | ||
186 | .channels_max = 2, | ||
187 | .rates = S3C64XX_I2S_RATES, | ||
188 | .formats = S3C64XX_I2S_FMTS, | ||
189 | }, | ||
190 | .capture = { | ||
191 | .channels_min = 2, | ||
192 | .channels_max = 2, | ||
193 | .rates = S3C64XX_I2S_RATES, | ||
194 | .formats = S3C64XX_I2S_FMTS, | ||
195 | }, | ||
196 | .ops = { | ||
197 | .set_sysclk = s3c64xx_i2s_set_sysclk, | ||
198 | }, | ||
199 | }; | ||
200 | EXPORT_SYMBOL_GPL(s3c64xx_i2s_dai); | ||
201 | |||
202 | static int __init s3c64xx_i2s_init(void) | ||
203 | { | ||
204 | return s3c_i2sv2_register_dai(&s3c64xx_i2s_dai); | ||
205 | } | ||
206 | module_init(s3c64xx_i2s_init); | ||
207 | |||
208 | static void __exit s3c64xx_i2s_exit(void) | ||
209 | { | ||
210 | snd_soc_unregister_dai(&s3c64xx_i2s_dai); | ||
211 | } | ||
212 | module_exit(s3c64xx_i2s_exit); | ||
213 | |||
214 | /* Module information */ | ||
215 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); | ||
216 | MODULE_DESCRIPTION("S3C64XX I2S SoC Interface"); | ||
217 | MODULE_LICENSE("GPL"); | ||
218 | |||
219 | |||
220 | |||
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.h b/sound/soc/s3c24xx/s3c64xx-i2s.h new file mode 100644 index 000000000000..b7ffe3c38b66 --- /dev/null +++ b/sound/soc/s3c24xx/s3c64xx-i2s.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* sound/soc/s3c24xx/s3c64xx-i2s.h | ||
2 | * | ||
3 | * ALSA SoC Audio Layer - S3C64XX I2S driver | ||
4 | * | ||
5 | * Copyright 2008 Openmoko, Inc. | ||
6 | * Copyright 2008 Simtec Electronics | ||
7 | * Ben Dooks <ben@simtec.co.uk> | ||
8 | * http://armlinux.simtec.co.uk/ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #ifndef __SND_SOC_S3C24XX_S3C64XX_I2S_H | ||
16 | #define __SND_SOC_S3C24XX_S3C64XX_I2S_H __FILE__ | ||
17 | |||
18 | #include "s3c-i2s-v2.h" | ||
19 | |||
20 | #define S3C64XX_DIV_BCLK S3C_I2SV2_DIV_BCLK | ||
21 | #define S3C64XX_DIV_RCLK S3C_I2SV2_DIV_RCLK | ||
22 | #define S3C64XX_DIV_PRESCALER S3C_I2SV2_DIV_PRESCALER | ||
23 | |||
24 | #define S3C64XX_CLKSRC_PCLK (0) | ||
25 | #define S3C64XX_CLKSRC_MUX (1) | ||
26 | |||
27 | extern struct snd_soc_dai s3c64xx_i2s_dai; | ||
28 | |||
29 | extern unsigned long s3c64xx_i2s_get_clockrate(struct snd_soc_dai *cpu_dai); | ||
30 | |||
31 | #endif /* __SND_SOC_S3C24XX_S3C64XX_I2S_H */ | ||