aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJassi Brar <jassi.brar@samsung.com>2010-04-27 02:57:11 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-05-07 11:45:41 -0400
commitaf56b1c27b909e06318d26416d7b21fe6483224a (patch)
treee290e1e1206e98223bd7f06fd18c37e3f6784249 /sound
parentbd843edf81dc1200f71b61d4804af0e2918e8ae3 (diff)
ASoC: S3C64XX: IISv4: Add CPU driver
Add the CPU driver for the IISv4 block found on S3C6410. For now, the driver is almost a copy of s3c64xx-i2s.c but it should diverge as more IISv4 specific stuff is added. Signed-off-by: Jassi Brar <jassi.brar@samsung.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/s3c24xx/Kconfig5
-rw-r--r--sound/soc/s3c24xx/Makefile2
-rw-r--r--sound/soc/s3c24xx/s3c64xx-i2s-v4.c209
-rw-r--r--sound/soc/s3c24xx/s3c64xx-i2s.h1
4 files changed, 217 insertions, 0 deletions
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
index 15fe57e5a232..c0c7edf792fd 100644
--- a/sound/soc/s3c24xx/Kconfig
+++ b/sound/soc/s3c24xx/Kconfig
@@ -24,6 +24,11 @@ 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
27config SND_S3C64XX_SOC_I2S_V4
28 tristate
29 select SND_S3C_I2SV2_SOC
30 select S3C64XX_DMA
31
27config SND_S3C_SOC_PCM 32config SND_S3C_SOC_PCM
28 tristate 33 tristate
29 34
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
index df071a376fa2..81d8dc503f87 100644
--- a/sound/soc/s3c24xx/Makefile
+++ b/sound/soc/s3c24xx/Makefile
@@ -4,6 +4,7 @@ snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o
4snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o 4snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o
5snd-soc-s3c64xx-i2s-objs := s3c64xx-i2s.o 5snd-soc-s3c64xx-i2s-objs := s3c64xx-i2s.o
6snd-soc-s3c-ac97-objs := s3c-ac97.o 6snd-soc-s3c-ac97-objs := s3c-ac97.o
7snd-soc-s3c64xx-i2s-v4-objs := s3c64xx-i2s-v4.o
7snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o 8snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o
8snd-soc-s3c-pcm-objs := s3c-pcm.o 9snd-soc-s3c-pcm-objs := s3c-pcm.o
9 10
@@ -12,6 +13,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o
12obj-$(CONFIG_SND_S3C_SOC_AC97) += snd-soc-s3c-ac97.o 13obj-$(CONFIG_SND_S3C_SOC_AC97) += snd-soc-s3c-ac97.o
13obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o 14obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o
14obj-$(CONFIG_SND_S3C64XX_SOC_I2S) += snd-soc-s3c64xx-i2s.o 15obj-$(CONFIG_SND_S3C64XX_SOC_I2S) += snd-soc-s3c64xx-i2s.o
16obj-$(CONFIG_SND_S3C64XX_SOC_I2S_V4) += snd-soc-s3c64xx-i2s-v4.o
15obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o 17obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o
16obj-$(CONFIG_SND_S3C_SOC_PCM) += snd-soc-s3c-pcm.o 18obj-$(CONFIG_SND_S3C_SOC_PCM) += snd-soc-s3c-pcm.o
17 19
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s-v4.c b/sound/soc/s3c24xx/s3c64xx-i2s-v4.c
new file mode 100644
index 000000000000..06db130030a1
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c64xx-i2s-v4.c
@@ -0,0 +1,209 @@
1/* sound/soc/s3c24xx/s3c64xx-i2s-v4.c
2 *
3 * ALSA SoC Audio Layer - S3C64XX I2Sv4 driver
4 * Copyright (c) 2010 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
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/clk.h>
13#include <linux/gpio.h>
14#include <linux/io.h>
15
16#include <sound/soc.h>
17#include <sound/pcm_params.h>
18
19#include <mach/gpio-bank-c.h>
20#include <mach/gpio-bank-h.h>
21#include <plat/gpio-cfg.h>
22
23#include <mach/map.h>
24#include <mach/dma.h>
25
26#include "s3c-dma.h"
27#include "regs-i2s-v2.h"
28#include "s3c64xx-i2s.h"
29
30static struct s3c2410_dma_client s3c64xx_dma_client_out = {
31 .name = "I2Sv4 PCM Stereo out"
32};
33
34static struct s3c2410_dma_client s3c64xx_dma_client_in = {
35 .name = "I2Sv4 PCM Stereo in"
36};
37
38static struct s3c_dma_params s3c64xx_i2sv4_pcm_stereo_out;
39static struct s3c_dma_params s3c64xx_i2sv4_pcm_stereo_in;
40static struct s3c_i2sv2_info s3c64xx_i2sv4;
41
42struct snd_soc_dai s3c64xx_i2s_v4_dai;
43EXPORT_SYMBOL_GPL(s3c64xx_i2s_v4_dai);
44
45static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai)
46{
47 return cpu_dai->private_data;
48}
49
50static int s3c64xx_i2sv4_probe(struct platform_device *pdev,
51 struct snd_soc_dai *dai)
52{
53 /* configure GPIO for i2s port */
54 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C64XX_GPC4_I2S_V40_DO0);
55 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C64XX_GPC5_I2S_V40_DO1);
56 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C64XX_GPC7_I2S_V40_DO2);
57 s3c_gpio_cfgpin(S3C64XX_GPH(6), S3C64XX_GPH6_I2S_V40_BCLK);
58 s3c_gpio_cfgpin(S3C64XX_GPH(7), S3C64XX_GPH7_I2S_V40_CDCLK);
59 s3c_gpio_cfgpin(S3C64XX_GPH(8), S3C64XX_GPH8_I2S_V40_LRCLK);
60 s3c_gpio_cfgpin(S3C64XX_GPH(9), S3C64XX_GPH9_I2S_V40_DI);
61
62 return 0;
63}
64
65static int s3c_i2sv4_hw_params(struct snd_pcm_substream *substream,
66 struct snd_pcm_hw_params *params,
67 struct snd_soc_dai *cpu_dai)
68{
69 struct s3c_i2sv2_info *i2s = to_info(cpu_dai);
70 struct s3c_dma_params *dma_data;
71 u32 iismod;
72
73 dev_dbg(cpu_dai->dev, "Entered %s\n", __func__);
74
75 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
76 dma_data = i2s->dma_playback;
77 else
78 dma_data = i2s->dma_capture;
79
80 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
81
82 iismod = readl(i2s->regs + S3C2412_IISMOD);
83 dev_dbg(cpu_dai->dev, "%s: r: IISMOD: %x\n", __func__, iismod);
84
85 iismod &= ~S3C64XX_IISMOD_BLC_MASK;
86 switch (params_format(params)) {
87 case SNDRV_PCM_FORMAT_S8:
88 iismod |= S3C64XX_IISMOD_BLC_8BIT;
89 break;
90 case SNDRV_PCM_FORMAT_S16_LE:
91 break;
92 case SNDRV_PCM_FORMAT_S24_LE:
93 iismod |= S3C64XX_IISMOD_BLC_24BIT;
94 break;
95 }
96
97 writel(iismod, i2s->regs + S3C2412_IISMOD);
98 dev_dbg(cpu_dai->dev, "%s: w: IISMOD: %x\n", __func__, iismod);
99
100 return 0;
101}
102
103static struct snd_soc_dai_ops s3c64xx_i2sv4_dai_ops = {
104 .hw_params = s3c_i2sv4_hw_params,
105};
106
107static __devinit int s3c64xx_i2sv4_dev_probe(struct platform_device *pdev)
108{
109 struct s3c_i2sv2_info *i2s;
110 struct snd_soc_dai *dai;
111 int ret;
112
113 i2s = &s3c64xx_i2sv4;
114 dai = &s3c64xx_i2s_v4_dai;
115
116 if (dai->dev) {
117 dev_dbg(dai->dev, "%s: \
118 I2Sv4 instance already registered!\n", __func__);
119 return -EBUSY;
120 }
121
122 dai->dev = &pdev->dev;
123 dai->name = "s3c64xx-i2s-v4";
124 dai->id = 0;
125 dai->symmetric_rates = 1;
126 dai->playback.channels_min = 2;
127 dai->playback.channels_max = 2;
128 dai->playback.rates = S3C64XX_I2S_RATES;
129 dai->playback.formats = S3C64XX_I2S_FMTS;
130 dai->capture.channels_min = 2;
131 dai->capture.channels_max = 2;
132 dai->capture.rates = S3C64XX_I2S_RATES;
133 dai->capture.formats = S3C64XX_I2S_FMTS;
134 dai->probe = s3c64xx_i2sv4_probe;
135 dai->ops = &s3c64xx_i2sv4_dai_ops;
136
137 i2s->feature |= S3C_FEATURE_CDCLKCON;
138
139 i2s->dma_capture = &s3c64xx_i2sv4_pcm_stereo_in;
140 i2s->dma_playback = &s3c64xx_i2sv4_pcm_stereo_out;
141
142 i2s->dma_capture->channel = DMACH_HSI_I2SV40_RX;
143 i2s->dma_capture->dma_addr = S3C64XX_PA_IISV4 + S3C2412_IISRXD;
144 i2s->dma_playback->channel = DMACH_HSI_I2SV40_TX;
145 i2s->dma_playback->dma_addr = S3C64XX_PA_IISV4 + S3C2412_IISTXD;
146
147 i2s->dma_capture->client = &s3c64xx_dma_client_in;
148 i2s->dma_capture->dma_size = 4;
149 i2s->dma_playback->client = &s3c64xx_dma_client_out;
150 i2s->dma_playback->dma_size = 4;
151
152 i2s->iis_cclk = clk_get(&pdev->dev, "audio-bus");
153 if (IS_ERR(i2s->iis_cclk)) {
154 dev_err(&pdev->dev, "failed to get audio-bus\n");
155 ret = PTR_ERR(i2s->iis_cclk);
156 goto err;
157 }
158
159 clk_enable(i2s->iis_cclk);
160
161 ret = s3c_i2sv2_probe(pdev, dai, i2s, 0);
162 if (ret)
163 goto err_clk;
164
165 ret = s3c_i2sv2_register_dai(dai);
166 if (ret != 0)
167 goto err_i2sv2;
168
169 return 0;
170
171err_i2sv2:
172 /* Not implemented for I2Sv2 core yet */
173err_clk:
174 clk_put(i2s->iis_cclk);
175err:
176 return ret;
177}
178
179static __devexit int s3c64xx_i2sv4_dev_remove(struct platform_device *pdev)
180{
181 dev_err(&pdev->dev, "Device removal not yet supported\n");
182 return 0;
183}
184
185static struct platform_driver s3c64xx_i2sv4_driver = {
186 .probe = s3c64xx_i2sv4_dev_probe,
187 .remove = s3c64xx_i2sv4_dev_remove,
188 .driver = {
189 .name = "s3c64xx-iis-v4",
190 .owner = THIS_MODULE,
191 },
192};
193
194static int __init s3c64xx_i2sv4_init(void)
195{
196 return platform_driver_register(&s3c64xx_i2sv4_driver);
197}
198module_init(s3c64xx_i2sv4_init);
199
200static void __exit s3c64xx_i2sv4_exit(void)
201{
202 platform_driver_unregister(&s3c64xx_i2sv4_driver);
203}
204module_exit(s3c64xx_i2sv4_exit);
205
206/* Module information */
207MODULE_AUTHOR("Jaswinder Singh, <jassi.brar@samsung.com>");
208MODULE_DESCRIPTION("S3C64XX I2Sv4 SoC Interface");
209MODULE_LICENSE("GPL");
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.h b/sound/soc/s3c24xx/s3c64xx-i2s.h
index f27ed50e4d82..7a40f43d1d51 100644
--- a/sound/soc/s3c24xx/s3c64xx-i2s.h
+++ b/sound/soc/s3c24xx/s3c64xx-i2s.h
@@ -37,5 +37,6 @@ struct clk;
37 SNDRV_PCM_FMTBIT_S24_LE) 37 SNDRV_PCM_FMTBIT_S24_LE)
38 38
39extern struct snd_soc_dai s3c64xx_i2s_dai[]; 39extern struct snd_soc_dai s3c64xx_i2s_dai[];
40extern struct snd_soc_dai s3c64xx_i2s_v4_dai;
40 41
41#endif /* __SND_SOC_S3C24XX_S3C64XX_I2S_H */ 42#endif /* __SND_SOC_S3C24XX_S3C64XX_I2S_H */