15 #include <linux/module.h>
16 #include <linux/device.h>
27 #include <mach/hardware.h>
36 #define SACR0 __REG(0x40400000)
37 #define SACR1 __REG(0x40400004)
38 #define SASR0 __REG(0x4040000C)
39 #define SAIMR __REG(0x40400014)
40 #define SAICR __REG(0x40400018)
41 #define SADIV __REG(0x40400060)
42 #define SADR __REG(0x40400080)
44 #define SACR0_RFTH(x) ((x) << 12)
45 #define SACR0_TFTH(x) ((x) << 8)
46 #define SACR0_STRF (1 << 5)
47 #define SACR0_EFWR (1 << 4)
48 #define SACR0_RST (1 << 3)
49 #define SACR0_BCKD (1 << 2)
50 #define SACR0_ENB (1 << 0)
51 #define SACR1_ENLBF (1 << 5)
52 #define SACR1_DRPL (1 << 4)
53 #define SACR1_DREC (1 << 3)
54 #define SACR1_AMSL (1 << 0)
56 #define SASR0_I2SOFF (1 << 7)
57 #define SASR0_ROR (1 << 6)
58 #define SASR0_TUR (1 << 5)
59 #define SASR0_RFS (1 << 4)
60 #define SASR0_TFS (1 << 3)
61 #define SASR0_BSY (1 << 2)
62 #define SASR0_RNE (1 << 1)
63 #define SASR0_TNF (1 << 0)
65 #define SAICR_ROR (1 << 6)
66 #define SAICR_TUR (1 << 5)
68 #define SAIMR_ROR (1 << 6)
69 #define SAIMR_TUR (1 << 5)
70 #define SAIMR_RFS (1 << 4)
71 #define SAIMR_TFS (1 << 3)
82 static struct clk *clk_i2s;
83 static int clk_ena = 0;
86 .name =
"I2S PCM Stereo out",
94 .name =
"I2S PCM Stereo in",
108 return PTR_ERR(clk_i2s);
117 static int pxa_i2s_wait(
void)
122 for(i = 0; i < 16; i++)
127 static int pxa2xx_i2s_set_dai_fmt(
struct snd_soc_dai *cpu_dai,
153 static int pxa2xx_i2s_set_dai_sysclk(
struct snd_soc_dai *cpu_dai,
154 int clk_id,
unsigned int freq,
int dir)
169 clk_prepare_enable(clk_i2s);
174 dma_data = &pxa2xx_i2s_pcm_stereo_out;
176 dma_data = &pxa2xx_i2s_pcm_stereo_in;
178 snd_soc_dai_set_dma_data(dai, substream, dma_data);
187 SACR1 |= pxa_i2s.fmt;
262 clk_disable_unprepare(clk_i2s);
272 pxa_i2s.sacr0 =
SACR0;
273 pxa_i2s.sacr1 =
SACR1;
274 pxa_i2s.saimr =
SAIMR;
275 pxa_i2s.sadiv =
SADIV;
287 SACR0 = pxa_i2s.sacr0 & ~SACR0_ENB;
288 SACR1 = pxa_i2s.sacr1;
289 SAIMR = pxa_i2s.saimr;
290 SADIV = pxa_i2s.sadiv;
292 SACR0 = pxa_i2s.sacr0;
298 #define pxa2xx_i2s_suspend NULL
299 #define pxa2xx_i2s_resume NULL
302 static int pxa2xx_i2s_probe(
struct snd_soc_dai *dai)
306 return PTR_ERR(clk_i2s);
324 static int pxa2xx_i2s_remove(
struct snd_soc_dai *dai)
327 clk_i2s = ERR_PTR(-
ENOENT);
331 #define PXA2XX_I2S_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
332 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
333 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000)
336 .startup = pxa2xx_i2s_startup,
337 .shutdown = pxa2xx_i2s_shutdown,
338 .trigger = pxa2xx_i2s_trigger,
339 .hw_params = pxa2xx_i2s_hw_params,
340 .set_fmt = pxa2xx_i2s_set_dai_fmt,
341 .set_sysclk = pxa2xx_i2s_set_dai_sysclk,
345 .probe = pxa2xx_i2s_probe,
346 .remove = pxa2xx_i2s_remove,
359 .ops = &pxa_i2s_dai_ops,
360 .symmetric_rates = 1,
375 .probe = pxa2xx_i2s_drv_probe,
379 .name =
"pxa2xx-i2s",
384 static int __init pxa2xx_i2s_init(
void)
386 clk_i2s = ERR_PTR(-
ENOENT);
390 static void __exit pxa2xx_i2s_exit(
void)