16 #include <linux/module.h>
18 #include <linux/slab.h>
30 #define AC97CH(n) (((n) - 1) * 0x20)
32 #define AC97DR(n) (AC97CH(n) + 0x0000)
34 #define AC97RXCR(n) (AC97CH(n) + 0x0004)
35 #define AC97RXCR_REN BIT(0)
36 #define AC97RXCR_RX3 BIT(3)
37 #define AC97RXCR_RX4 BIT(4)
38 #define AC97RXCR_CM BIT(15)
40 #define AC97TXCR(n) (AC97CH(n) + 0x0008)
41 #define AC97TXCR_TEN BIT(0)
42 #define AC97TXCR_TX3 BIT(3)
43 #define AC97TXCR_TX4 BIT(4)
44 #define AC97TXCR_CM BIT(15)
46 #define AC97SR(n) (AC97CH(n) + 0x000c)
47 #define AC97SR_TXFE BIT(1)
48 #define AC97SR_TXUE BIT(6)
50 #define AC97RISR(n) (AC97CH(n) + 0x0010)
51 #define AC97ISR(n) (AC97CH(n) + 0x0014)
52 #define AC97IE(n) (AC97CH(n) + 0x0018)
57 #define AC97S1DATA 0x0080
58 #define AC97S2DATA 0x0084
59 #define AC97S12DATA 0x0088
61 #define AC97RGIS 0x008c
62 #define AC97GIS 0x0090
67 #define AC97_SLOT2RXVALID BIT(1)
68 #define AC97_CODECREADY BIT(5)
69 #define AC97_SLOT2TXCOMPLETE BIT(6)
71 #define AC97EOI 0x0098
72 #define AC97EOI_WINT BIT(0)
73 #define AC97EOI_CODECREADY BIT(1)
75 #define AC97GCR 0x009c
76 #define AC97GCR_AC97IFE BIT(0)
78 #define AC97RESET 0x00a0
79 #define AC97RESET_TIMEDRESET BIT(0)
81 #define AC97SYNC 0x00a4
82 #define AC97SYNC_TIMEDSYNC BIT(0)
84 #define AC97_TIMEOUT msecs_to_jiffies(5)
104 .name =
"ac97-pcm-out",
109 .name =
"ac97-pcm-in",
113 static inline unsigned ep93xx_ac97_read_reg(
struct ep93xx_ac97_info *
info,
119 static inline void ep93xx_ac97_write_reg(
struct ep93xx_ac97_info *
info,
120 unsigned reg,
unsigned val)
125 static unsigned short ep93xx_ac97_read(
struct snd_ac97 *ac97,
128 struct ep93xx_ac97_info *
info = ep93xx_ac97_info;
136 dev_warn(info->
dev,
"timeout reading register %x\n", reg);
146 static void ep93xx_ac97_write(
struct snd_ac97 *ac97,
150 struct ep93xx_ac97_info *info = ep93xx_ac97_info;
163 dev_warn(info->
dev,
"timeout writing register %x\n", reg);
168 static void ep93xx_ac97_warm_reset(
struct snd_ac97 *ac97)
170 struct ep93xx_ac97_info *info = ep93xx_ac97_info;
188 static void ep93xx_ac97_cold_reset(
struct snd_ac97 *ac97)
190 struct ep93xx_ac97_info *info = ep93xx_ac97_info;
198 ep93xx_ac97_write_reg(info,
AC97GCR, 0);
221 struct ep93xx_ac97_info *info =
dev_id;
229 status = ep93xx_ac97_read_reg(info,
AC97GIS);
230 mask = ep93xx_ac97_read_reg(info,
AC97IM);
232 ep93xx_ac97_write_reg(info,
AC97IM, mask);
239 .read = ep93xx_ac97_read,
240 .write = ep93xx_ac97_write,
241 .reset = ep93xx_ac97_cold_reset,
242 .warm_reset = ep93xx_ac97_warm_reset,
249 struct ep93xx_ac97_info *info = snd_soc_dai_get_drvdata(dai);
264 ep93xx_ac97_write_reg(info,
AC97TXCR(1), v);
273 ep93xx_ac97_write_reg(info,
AC97RXCR(1), v);
292 v = ep93xx_ac97_read_reg(info,
AC97SR(1));
300 ep93xx_ac97_write_reg(info,
AC97TXCR(1), 0);
303 ep93xx_ac97_write_reg(info,
AC97RXCR(1), 0);
321 dma_data = &ep93xx_ac97_pcm_out;
323 dma_data = &ep93xx_ac97_pcm_in;
325 snd_soc_dai_set_dma_data(dai, substream, dma_data);
330 .startup = ep93xx_ac97_startup,
331 .trigger = ep93xx_ac97_trigger,
335 .name =
"ep93xx-ac97",
339 .stream_name =
"AC97 Playback",
346 .stream_name =
"AC97 Capture",
352 .ops = &ep93xx_ac97_dai_ops,
357 struct ep93xx_ac97_info *
info;
378 ret = devm_request_irq(&pdev->
dev, irq, ep93xx_ac97_interrupt,
386 init_completion(&info->
done);
389 ep93xx_ac97_info =
info;
390 platform_set_drvdata(pdev, info);
399 platform_set_drvdata(pdev,
NULL);
400 ep93xx_ac97_info =
NULL;
407 struct ep93xx_ac97_info *info = platform_get_drvdata(pdev);
412 ep93xx_ac97_write_reg(info,
AC97GCR, 0);
414 platform_set_drvdata(pdev,
NULL);
415 ep93xx_ac97_info =
NULL;
422 .probe = ep93xx_ac97_probe,
425 .name =
"ep93xx-ac97",