11 #include <linux/module.h>
12 #include <linux/slab.h>
13 #include <linux/device.h>
27 #define AC97_CONFIG 0x00
28 #define AC97_STATUS 0x04
29 #define AC97_DATA 0x08
30 #define AC97_CMDRESP 0x0c
31 #define AC97_ENABLE 0x10
33 #define CFG_RC(x) (((x) & 0x3ff) << 13)
34 #define CFG_XS(x) (((x) & 0x3ff) << 3)
35 #define CFG_SG (1 << 2)
36 #define CFG_SN (1 << 1)
37 #define CFG_RS (1 << 0)
38 #define STAT_XU (1 << 11)
39 #define STAT_XO (1 << 10)
40 #define STAT_RU (1 << 9)
41 #define STAT_RO (1 << 8)
42 #define STAT_RD (1 << 7)
43 #define STAT_CP (1 << 6)
44 #define STAT_TE (1 << 4)
45 #define STAT_TF (1 << 3)
46 #define STAT_RE (1 << 1)
47 #define STAT_RF (1 << 0)
48 #define CMD_SET_DATA(x) (((x) & 0xffff) << 16)
49 #define CMD_GET_DATA(x) ((x) & 0xffff)
50 #define CMD_READ (1 << 7)
51 #define CMD_WRITE (0 << 7)
52 #define CMD_IDX(x) ((x) & 0x7f)
54 #define EN_CE (1 << 0)
57 #define AC97_RW_RETRIES 5
60 SNDRV_PCM_RATE_CONTINUOUS
63 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE)
69 #define ac97_to_ctx(x) ac97c_workdata
82 static unsigned short au1xac97c_ac97_read(
struct snd_ac97 *ac97,
86 unsigned int tmo,
retry;
109 asm volatile (
"nop");
117 }
while (--retry && !tmo);
119 pr_debug(
"AC97RD %04x %04lx %d\n", r, data, retry);
121 return retry ? data & 0xffff : 0xffff;
124 static void au1xac97c_ac97_write(
struct snd_ac97 *ac97,
unsigned short r,
128 unsigned int tmo,
retry;
149 }
while (--retry && !tmo);
151 pr_debug(
"AC97WR %04x %04x %d\n", r, v, retry);
154 static void au1xac97c_ac97_warm_reset(
struct snd_ac97 *ac97)
164 static void au1xac97c_ac97_cold_reset(
struct snd_ac97 *ac97)
183 .read = au1xac97c_ac97_read,
184 .write = au1xac97c_ac97_write,
185 .reset = au1xac97c_ac97_cold_reset,
186 .warm_reset = au1xac97c_ac97_warm_reset,
194 snd_soc_dai_set_dma_data(dai, substream, &ctx->
dmaids[0]);
199 .startup = alchemy_ac97c_startup,
204 return ac97c_workdata ? 0 : -
ENODEV;
208 .name =
"alchemy-ac97c",
210 .probe = au1xac97c_dai_probe,
223 .ops = &alchemy_ac97c_ops,
243 resource_size(iores),
248 resource_size(iores));
269 platform_set_drvdata(pdev, ctx);
275 ac97c_workdata =
ctx;
287 ac97c_workdata =
NULL;
293 static int au1xac97c_drvsuspend(
struct device *
dev)
302 static int au1xac97c_drvresume(
struct device *
dev)
313 static const struct dev_pm_ops au1xpscac97_pmops = {
314 .
suspend = au1xac97c_drvsuspend,
315 .resume = au1xac97c_drvresume,
318 #define AU1XPSCAC97_PMOPS (&au1xpscac97_pmops)
322 #define AU1XPSCAC97_PMOPS NULL
328 .name =
"alchemy-ac97c",
332 .probe = au1xac97c_drvprobe,
336 static int __init au1xac97c_load(
void)
338 ac97c_workdata =
NULL;
342 static void __exit au1xac97c_unload(
void)