aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/s3c24xx/s3c64xx-i2s.c
diff options
context:
space:
mode:
authorJassi Brar <jassi.brar@samsung.com>2009-12-08 23:29:25 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-12-16 12:31:03 -0500
commit0fe692292a26f57b6522fe859cc8b2549ec0cd97 (patch)
tree035b655bf064a0f8183c88a79fee126a0ee40663 /sound/soc/s3c24xx/s3c64xx-i2s.c
parent168db50d967e09133feda8247d4dcb3c73437766 (diff)
ASoC: S3C64XX: Compress and generalize the CPU driver
The driver can be 'generalized' a bit by not hardcoding '2'(the number of I2Sv3 controllers that the driver can handle) at many places, instead we define a macro for it. That makes it easier to increase number of controllers by changing the parameter at just one place, this will be useful when there is support for newer SoCs, which have the same controller, only more in number. 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/soc/s3c24xx/s3c64xx-i2s.c')
-rw-r--r--sound/soc/s3c24xx/s3c64xx-i2s.c114
1 files changed, 41 insertions, 73 deletions
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c
index 8feb029b99fe..93ed3aad1631 100644
--- a/sound/soc/s3c24xx/s3c64xx-i2s.c
+++ b/sound/soc/s3c24xx/s3c64xx-i2s.c
@@ -32,6 +32,11 @@
32#include "s3c-dma.h" 32#include "s3c-dma.h"
33#include "s3c64xx-i2s.h" 33#include "s3c64xx-i2s.h"
34 34
35/* The value should be set to maximum of the total number
36 * of I2Sv3 controllers that any supported SoC has.
37 */
38#define MAX_I2SV3 2
39
35static struct s3c2410_dma_client s3c64xx_dma_client_out = { 40static struct s3c2410_dma_client s3c64xx_dma_client_out = {
36 .name = "I2S PCM Stereo out" 41 .name = "I2S PCM Stereo out"
37}; 42};
@@ -40,37 +45,12 @@ static struct s3c2410_dma_client s3c64xx_dma_client_in = {
40 .name = "I2S PCM Stereo in" 45 .name = "I2S PCM Stereo in"
41}; 46};
42 47
43static struct s3c_dma_params s3c64xx_i2s_pcm_stereo_out[2] = { 48static struct s3c_dma_params s3c64xx_i2s_pcm_stereo_out[MAX_I2SV3];
44 [0] = { 49static struct s3c_dma_params s3c64xx_i2s_pcm_stereo_in[MAX_I2SV3];
45 .channel = DMACH_I2S0_OUT, 50static struct s3c_i2sv2_info s3c64xx_i2s[MAX_I2SV3];
46 .client = &s3c64xx_dma_client_out,
47 .dma_addr = S3C64XX_PA_IIS0 + S3C2412_IISTXD,
48 .dma_size = 4,
49 },
50 [1] = {
51 .channel = DMACH_I2S1_OUT,
52 .client = &s3c64xx_dma_client_out,
53 .dma_addr = S3C64XX_PA_IIS1 + S3C2412_IISTXD,
54 .dma_size = 4,
55 },
56};
57
58static struct s3c_dma_params s3c64xx_i2s_pcm_stereo_in[2] = {
59 [0] = {
60 .channel = DMACH_I2S0_IN,
61 .client = &s3c64xx_dma_client_in,
62 .dma_addr = S3C64XX_PA_IIS0 + S3C2412_IISRXD,
63 .dma_size = 4,
64 },
65 [1] = {
66 .channel = DMACH_I2S1_IN,
67 .client = &s3c64xx_dma_client_in,
68 .dma_addr = S3C64XX_PA_IIS1 + S3C2412_IISRXD,
69 .dma_size = 4,
70 },
71};
72 51
73static struct s3c_i2sv2_info s3c64xx_i2s[2]; 52struct snd_soc_dai s3c64xx_i2s_dai[MAX_I2SV3];
53EXPORT_SYMBOL_GPL(s3c64xx_i2s_dai);
74 54
75static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) 55static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai)
76{ 56{
@@ -163,55 +143,13 @@ static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops = {
163 .set_sysclk = s3c64xx_i2s_set_sysclk, 143 .set_sysclk = s3c64xx_i2s_set_sysclk,
164}; 144};
165 145
166struct snd_soc_dai s3c64xx_i2s_dai[] = {
167 {
168 .name = "s3c64xx-i2s",
169 .id = 0,
170 .probe = s3c64xx_i2s_probe,
171 .playback = {
172 .channels_min = 2,
173 .channels_max = 2,
174 .rates = S3C64XX_I2S_RATES,
175 .formats = S3C64XX_I2S_FMTS,
176 },
177 .capture = {
178 .channels_min = 2,
179 .channels_max = 2,
180 .rates = S3C64XX_I2S_RATES,
181 .formats = S3C64XX_I2S_FMTS,
182 },
183 .ops = &s3c64xx_i2s_dai_ops,
184 .symmetric_rates = 1,
185 },
186 {
187 .name = "s3c64xx-i2s",
188 .id = 1,
189 .probe = s3c64xx_i2s_probe,
190 .playback = {
191 .channels_min = 2,
192 .channels_max = 2,
193 .rates = S3C64XX_I2S_RATES,
194 .formats = S3C64XX_I2S_FMTS,
195 },
196 .capture = {
197 .channels_min = 2,
198 .channels_max = 2,
199 .rates = S3C64XX_I2S_RATES,
200 .formats = S3C64XX_I2S_FMTS,
201 },
202 .ops = &s3c64xx_i2s_dai_ops,
203 .symmetric_rates = 1,
204 },
205};
206EXPORT_SYMBOL_GPL(s3c64xx_i2s_dai);
207
208static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev) 146static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev)
209{ 147{
210 struct s3c_i2sv2_info *i2s; 148 struct s3c_i2sv2_info *i2s;
211 struct snd_soc_dai *dai; 149 struct snd_soc_dai *dai;
212 int ret; 150 int ret;
213 151
214 if (pdev->id >= ARRAY_SIZE(s3c64xx_i2s)) { 152 if (pdev->id >= MAX_I2SV3) {
215 dev_err(&pdev->dev, "id %d out of range\n", pdev->id); 153 dev_err(&pdev->dev, "id %d out of range\n", pdev->id);
216 return -EINVAL; 154 return -EINVAL;
217 } 155 }
@@ -219,10 +157,40 @@ static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev)
219 i2s = &s3c64xx_i2s[pdev->id]; 157 i2s = &s3c64xx_i2s[pdev->id];
220 dai = &s3c64xx_i2s_dai[pdev->id]; 158 dai = &s3c64xx_i2s_dai[pdev->id];
221 dai->dev = &pdev->dev; 159 dai->dev = &pdev->dev;
160 dai->name = "s3c64xx-i2s";
161 dai->id = pdev->id;
162 dai->symmetric_rates = 1;
163 dai->playback.channels_min = 2;
164 dai->playback.channels_max = 2;
165 dai->playback.rates = S3C64XX_I2S_RATES;
166 dai->playback.formats = S3C64XX_I2S_FMTS;
167 dai->capture.channels_min = 2;
168 dai->capture.channels_max = 2;
169 dai->capture.rates = S3C64XX_I2S_RATES;
170 dai->capture.formats = S3C64XX_I2S_FMTS;
171 dai->probe = s3c64xx_i2s_probe;
172 dai->ops = &s3c64xx_i2s_dai_ops;
222 173
223 i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id]; 174 i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id];
224 i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id]; 175 i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id];
225 176
177 if (pdev->id == 0) {
178 i2s->dma_capture->channel = DMACH_I2S0_IN;
179 i2s->dma_capture->dma_addr = S3C64XX_PA_IIS0 + S3C2412_IISRXD;
180 i2s->dma_playback->channel = DMACH_I2S0_OUT;
181 i2s->dma_playback->dma_addr = S3C64XX_PA_IIS0 + S3C2412_IISTXD;
182 } else {
183 i2s->dma_capture->channel = DMACH_I2S1_IN;
184 i2s->dma_capture->dma_addr = S3C64XX_PA_IIS1 + S3C2412_IISRXD;
185 i2s->dma_playback->channel = DMACH_I2S1_OUT;
186 i2s->dma_playback->dma_addr = S3C64XX_PA_IIS1 + S3C2412_IISTXD;
187 }
188
189 i2s->dma_capture->client = &s3c64xx_dma_client_in;
190 i2s->dma_capture->dma_size = 4;
191 i2s->dma_playback->client = &s3c64xx_dma_client_out;
192 i2s->dma_playback->dma_size = 4;
193
226 i2s->iis_cclk = clk_get(&pdev->dev, "audio-bus"); 194 i2s->iis_cclk = clk_get(&pdev->dev, "audio-bus");
227 if (IS_ERR(i2s->iis_cclk)) { 195 if (IS_ERR(i2s->iis_cclk)) {
228 dev_err(&pdev->dev, "failed to get audio-bus\n"); 196 dev_err(&pdev->dev, "failed to get audio-bus\n");