16 #include <linux/module.h>
17 #include <linux/slab.h>
18 #include <linux/device.h>
32 #define AC97_RW_RETRIES 5
35 (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE)
38 SNDRV_PCM_RATE_8000_48000
41 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3BE)
43 #define AC97PCR_START(stype) \
44 ((stype) == SNDRV_PCM_STREAM_PLAYBACK ? PSC_AC97PCR_TS : PSC_AC97PCR_RS)
45 #define AC97PCR_STOP(stype) \
46 ((stype) == SNDRV_PCM_STREAM_PLAYBACK ? PSC_AC97PCR_TP : PSC_AC97PCR_RP)
47 #define AC97PCR_CLRFIFO(stype) \
48 ((stype) == SNDRV_PCM_STREAM_PLAYBACK ? PSC_AC97PCR_TC : PSC_AC97PCR_RC)
50 #define AC97STAT_BUSY(stype) \
51 ((stype) == SNDRV_PCM_STREAM_PLAYBACK ? PSC_AC97STAT_TB : PSC_AC97STAT_RB)
65 return snd_soc_dai_get_drvdata(c->
rtd->cpu_dai);
70 #define ac97_to_pscdata(x) au1xpsc_ac97_workdata
75 static unsigned short au1xpsc_ac97_read(
struct snd_ac97 *ac97,
79 unsigned short retry, tmo;
107 if (reg != ((data >> 16) & 0x7f))
110 }
while (--retry && !tmo);
112 return retry ? data & 0xffff : 0xffff;
116 static void au1xpsc_ac97_write(
struct snd_ac97 *ac97,
unsigned short reg,
120 unsigned int tmo,
retry;
144 }
while (--retry && !tmo);
148 static void au1xpsc_ac97_warm_reset(
struct snd_ac97 *ac97)
159 static void au1xpsc_ac97_cold_reset(
struct snd_ac97 *ac97)
165 au_writel(0,
AC97_CFG(au1xpsc_ac97_workdata));
205 .read = au1xpsc_ac97_read,
206 .write = au1xpsc_ac97_write,
207 .reset = au1xpsc_ac97_cold_reset,
208 .warm_reset = au1xpsc_ac97_warm_reset,
218 int chans,
t, stype = substream->
stream;
222 r = ro = au_readl(
AC97_CFG(pscdata));
261 while ((au_readl(
AC97_STAT(pscdata)) & PSC_AC97STAT_DR) && --t)
277 while ((!(au_readl(
AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && --t)
315 asm volatile (
"nop");
331 snd_soc_dai_set_dma_data(dai, substream, &pscdata->
dmaids[0]);
335 static int au1xpsc_ac97_probe(
struct snd_soc_dai *dai)
337 return au1xpsc_ac97_workdata ? 0 : -
ENODEV;
341 .startup = au1xpsc_ac97_startup,
342 .trigger = au1xpsc_ac97_trigger,
343 .hw_params = au1xpsc_ac97_hw_params,
348 .probe = au1xpsc_ac97_probe,
361 .ops = &au1xpsc_ac97_dai_ops,
383 resource_size(iores),
388 resource_size(iores));
420 platform_set_drvdata(pdev, wd);
426 au1xpsc_ac97_workdata = wd;
442 au1xpsc_ac97_workdata =
NULL;
448 static int au1xpsc_ac97_drvsuspend(
struct device *
dev)
463 static int au1xpsc_ac97_drvresume(
struct device *dev)
478 static struct dev_pm_ops au1xpscac97_pmops = {
479 .
suspend = au1xpsc_ac97_drvsuspend,
480 .resume = au1xpsc_ac97_drvresume,
483 #define AU1XPSCAC97_PMOPS &au1xpscac97_pmops
487 #define AU1XPSCAC97_PMOPS NULL
493 .name =
"au1xpsc_ac97",
497 .probe = au1xpsc_ac97_drvprobe,
501 static int __init au1xpsc_ac97_load(
void)
503 au1xpsc_ac97_workdata =
NULL;
507 static void __exit au1xpsc_ac97_unload(
void)