12 #include <linux/module.h>
22 #include <asm/delay.h>
29 #define DRV_NAME "mpc5200-psc-ac97"
34 static unsigned short psc_ac97_read(
struct snd_ac97 *ac97,
unsigned short reg)
42 status = spin_event_timeout(!(
in_be16(&psc_dma->
psc_regs->sr_csr.status) &
45 pr_err(
"timeout on ac97 bus (rdy)\n");
57 status = spin_event_timeout((
in_be16(&psc_dma->
psc_regs->sr_csr.status) &
60 pr_err(
"timeout on ac97 read (val) %x\n",
67 if (((val >> 24) & 0x7f) != reg) {
68 pr_err(
"reg echo error on ac97 read\n");
72 val = (val >> 8) & 0xffff;
75 return (
unsigned short)
val;
78 static void psc_ac97_write(
struct snd_ac97 *ac97,
79 unsigned short reg,
unsigned short val)
86 status = spin_event_timeout(!(
in_be16(&psc_dma->
psc_regs->sr_csr.status) &
89 pr_err(
"timeout on ac97 bus (write)\n");
94 ((reg & 0x7f) << 24) | (val << 8));
100 static void psc_ac97_warm_reset(
struct snd_ac97 *ac97)
113 static void psc_ac97_cold_reset(
struct snd_ac97 *ac97)
131 psc_ac97_warm_reset(ac97);
135 .read = psc_ac97_read,
136 .write = psc_ac97_write,
137 .reset = psc_ac97_cold_reset,
138 .warm_reset = psc_ac97_warm_reset,
146 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(cpu_dai);
149 dev_dbg(psc_dma->
dev,
"%s(substream=%p) p_size=%i p_bytes=%i"
150 " periods=%i buffer_size=%i buffer_bytes=%i channels=%i"
151 " rate=%i format=%i\n",
169 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(cpu_dai);
171 dev_dbg(psc_dma->
dev,
"%s(substream=%p)\n", __func__, substream);
184 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(dai);
189 dev_dbg(psc_dma->
dev,
"AC97 START: stream=%i\n",
190 substream->
pstr->stream);
198 dev_dbg(psc_dma->
dev,
"AC97 STOP: stream=%i\n",
199 substream->
pstr->stream);
209 static int psc_ac97_probe(
struct snd_soc_dai *cpu_dai)
211 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(cpu_dai);
230 .hw_params = psc_ac97_hw_analog_params,
231 .trigger = psc_ac97_trigger,
235 .hw_params = psc_ac97_hw_digital_params,
240 .name =
"mpc5200-psc-ac97.0",
242 .probe = psc_ac97_probe,
244 .stream_name =
"AC97 Playback",
251 .stream_name =
"AC97 Capture",
257 .ops = &psc_ac97_analog_ops,
260 .name =
"mpc5200-psc-ac97.1",
263 .stream_name =
"AC97 SPDIF",
270 .ops = &psc_ac97_digital_ops,
292 dev_err(&op->
dev,
"Failed to register DAI\n");
322 { .compatible =
"fsl,mpc5200-psc-ac97", },
323 { .compatible =
"fsl,mpc5200b-psc-ac97", },
329 .probe = psc_ac97_of_probe,
332 .name =
"mpc5200-psc-ac97",
334 .of_match_table = psc_ac97_match,