1 /* sound/soc/s3c24xx/s3c64xx-i2s.c
3 * ALSA SoC Audio Layer - S3C64XX I2S driver
5 * Copyright 2008 Openmoko, Inc.
6 * Copyright 2008 Simtec Electronics
7 * Ben Dooks <ben@simtec.co.uk>
8 * http://armlinux.simtec.co.uk/
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.
15 #include <linux/clk.h>
16 #include <linux/gpio.h>
19 #include <sound/soc.h>
21 #include <mach/gpio-bank-d.h>
22 #include <mach/gpio-bank-e.h>
23 #include <plat/gpio-cfg.h>
29 #include "regs-i2s-v2.h"
30 #include "s3c64xx-i2s.h"
32 /* The value should be set to maximum of the total number
33 * of I2Sv3 controllers that any supported SoC has.
37 static struct s3c2410_dma_client s3c64xx_dma_client_out
= {
38 .name
= "I2S PCM Stereo out"
41 static struct s3c2410_dma_client s3c64xx_dma_client_in
= {
42 .name
= "I2S PCM Stereo in"
45 static struct s3c_dma_params s3c64xx_i2s_pcm_stereo_out
[MAX_I2SV3
];
46 static struct s3c_dma_params s3c64xx_i2s_pcm_stereo_in
[MAX_I2SV3
];
47 static struct s3c_i2sv2_info s3c64xx_i2s
[MAX_I2SV3
];
49 struct snd_soc_dai s3c64xx_i2s_dai
[MAX_I2SV3
];
50 EXPORT_SYMBOL_GPL(s3c64xx_i2s_dai
);
52 static inline struct s3c_i2sv2_info
*to_info(struct snd_soc_dai
*cpu_dai
)
54 return cpu_dai
->private_data
;
57 static int s3c64xx_i2s_probe(struct platform_device
*pdev
,
58 struct snd_soc_dai
*dai
)
60 /* configure GPIO for i2s port */
63 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK
);
64 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK
);
65 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_I2S0_LRCLK
);
66 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_I2S0_DI
);
67 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_I2S0_D0
);
70 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_I2S1_CLK
);
71 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_I2S1_CDCLK
);
72 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_I2S1_LRCLK
);
73 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_I2S1_DI
);
74 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_I2S1_D0
);
81 static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops
;
83 static __devinit
int s3c64xx_iis_dev_probe(struct platform_device
*pdev
)
85 struct s3c_i2sv2_info
*i2s
;
86 struct snd_soc_dai
*dai
;
89 if (pdev
->id
>= MAX_I2SV3
) {
90 dev_err(&pdev
->dev
, "id %d out of range\n", pdev
->id
);
94 i2s
= &s3c64xx_i2s
[pdev
->id
];
95 dai
= &s3c64xx_i2s_dai
[pdev
->id
];
96 dai
->dev
= &pdev
->dev
;
97 dai
->name
= "s3c64xx-i2s";
99 dai
->symmetric_rates
= 1;
100 dai
->playback
.channels_min
= 2;
101 dai
->playback
.channels_max
= 2;
102 dai
->playback
.rates
= S3C64XX_I2S_RATES
;
103 dai
->playback
.formats
= S3C64XX_I2S_FMTS
;
104 dai
->capture
.channels_min
= 2;
105 dai
->capture
.channels_max
= 2;
106 dai
->capture
.rates
= S3C64XX_I2S_RATES
;
107 dai
->capture
.formats
= S3C64XX_I2S_FMTS
;
108 dai
->probe
= s3c64xx_i2s_probe
;
109 dai
->ops
= &s3c64xx_i2s_dai_ops
;
111 i2s
->feature
|= S3C_FEATURE_CDCLKCON
;
113 i2s
->dma_capture
= &s3c64xx_i2s_pcm_stereo_in
[pdev
->id
];
114 i2s
->dma_playback
= &s3c64xx_i2s_pcm_stereo_out
[pdev
->id
];
117 i2s
->dma_capture
->channel
= DMACH_I2S0_IN
;
118 i2s
->dma_capture
->dma_addr
= S3C64XX_PA_IIS0
+ S3C2412_IISRXD
;
119 i2s
->dma_playback
->channel
= DMACH_I2S0_OUT
;
120 i2s
->dma_playback
->dma_addr
= S3C64XX_PA_IIS0
+ S3C2412_IISTXD
;
122 i2s
->dma_capture
->channel
= DMACH_I2S1_IN
;
123 i2s
->dma_capture
->dma_addr
= S3C64XX_PA_IIS1
+ S3C2412_IISRXD
;
124 i2s
->dma_playback
->channel
= DMACH_I2S1_OUT
;
125 i2s
->dma_playback
->dma_addr
= S3C64XX_PA_IIS1
+ S3C2412_IISTXD
;
128 i2s
->dma_capture
->client
= &s3c64xx_dma_client_in
;
129 i2s
->dma_capture
->dma_size
= 4;
130 i2s
->dma_playback
->client
= &s3c64xx_dma_client_out
;
131 i2s
->dma_playback
->dma_size
= 4;
133 i2s
->iis_cclk
= clk_get(&pdev
->dev
, "audio-bus");
134 if (IS_ERR(i2s
->iis_cclk
)) {
135 dev_err(&pdev
->dev
, "failed to get audio-bus\n");
136 ret
= PTR_ERR(i2s
->iis_cclk
);
140 clk_enable(i2s
->iis_cclk
);
142 ret
= s3c_i2sv2_probe(pdev
, dai
, i2s
, 0);
146 ret
= s3c_i2sv2_register_dai(dai
);
153 /* Not implemented for I2Sv2 core yet */
155 clk_put(i2s
->iis_cclk
);
160 static __devexit
int s3c64xx_iis_dev_remove(struct platform_device
*pdev
)
162 dev_err(&pdev
->dev
, "Device removal not yet supported\n");
166 static struct platform_driver s3c64xx_iis_driver
= {
167 .probe
= s3c64xx_iis_dev_probe
,
168 .remove
= s3c64xx_iis_dev_remove
,
170 .name
= "s3c64xx-iis",
171 .owner
= THIS_MODULE
,
175 static int __init
s3c64xx_i2s_init(void)
177 return platform_driver_register(&s3c64xx_iis_driver
);
179 module_init(s3c64xx_i2s_init
);
181 static void __exit
s3c64xx_i2s_exit(void)
183 platform_driver_unregister(&s3c64xx_iis_driver
);
185 module_exit(s3c64xx_i2s_exit
);
187 /* Module information */
188 MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
189 MODULE_DESCRIPTION("S3C64XX I2S SoC Interface");
190 MODULE_LICENSE("GPL");