diff options
Diffstat (limited to 'sound/soc/txx9/txx9aclc-ac97.c')
-rw-r--r-- | sound/soc/txx9/txx9aclc-ac97.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/sound/soc/txx9/txx9aclc-ac97.c b/sound/soc/txx9/txx9aclc-ac97.c index 0ec20b68e8cb..743d07b82c06 100644 --- a/sound/soc/txx9/txx9aclc-ac97.c +++ b/sound/soc/txx9/txx9aclc-ac97.c | |||
@@ -36,13 +36,11 @@ | |||
36 | 36 | ||
37 | static DECLARE_WAIT_QUEUE_HEAD(ac97_waitq); | 37 | static DECLARE_WAIT_QUEUE_HEAD(ac97_waitq); |
38 | 38 | ||
39 | /* REVISIT: How to find txx9aclc_soc_device from snd_ac97? */ | 39 | /* REVISIT: How to find txx9aclc_drvdata from snd_ac97? */ |
40 | static struct txx9aclc_soc_device *txx9aclc_soc_dev; | 40 | static struct txx9aclc_plat_drvdata *txx9aclc_drvdata; |
41 | 41 | ||
42 | static int txx9aclc_regready(struct txx9aclc_soc_device *dev) | 42 | static int txx9aclc_regready(struct txx9aclc_plat_drvdata *drvdata) |
43 | { | 43 | { |
44 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
45 | |||
46 | return __raw_readl(drvdata->base + ACINTSTS) & ACINT_REGACCRDY; | 44 | return __raw_readl(drvdata->base + ACINTSTS) & ACINT_REGACCRDY; |
47 | } | 45 | } |
48 | 46 | ||
@@ -50,8 +48,7 @@ static int txx9aclc_regready(struct txx9aclc_soc_device *dev) | |||
50 | static unsigned short txx9aclc_ac97_read(struct snd_ac97 *ac97, | 48 | static unsigned short txx9aclc_ac97_read(struct snd_ac97 *ac97, |
51 | unsigned short reg) | 49 | unsigned short reg) |
52 | { | 50 | { |
53 | struct txx9aclc_soc_device *dev = txx9aclc_soc_dev; | 51 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; |
54 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
55 | void __iomem *base = drvdata->base; | 52 | void __iomem *base = drvdata->base; |
56 | u32 dat; | 53 | u32 dat; |
57 | 54 | ||
@@ -61,15 +58,15 @@ static unsigned short txx9aclc_ac97_read(struct snd_ac97 *ac97, | |||
61 | dat = (reg << ACREGACC_REG_SHIFT) | ACREGACC_READ; | 58 | dat = (reg << ACREGACC_REG_SHIFT) | ACREGACC_READ; |
62 | __raw_writel(dat, base + ACREGACC); | 59 | __raw_writel(dat, base + ACREGACC); |
63 | __raw_writel(ACINT_REGACCRDY, base + ACINTEN); | 60 | __raw_writel(ACINT_REGACCRDY, base + ACINTEN); |
64 | if (!wait_event_timeout(ac97_waitq, txx9aclc_regready(dev), HZ)) { | 61 | if (!wait_event_timeout(ac97_waitq, txx9aclc_regready(txx9aclc_drvdata), HZ)) { |
65 | __raw_writel(ACINT_REGACCRDY, base + ACINTDIS); | 62 | __raw_writel(ACINT_REGACCRDY, base + ACINTDIS); |
66 | dev_err(dev->soc_dev.dev, "ac97 read timeout (reg %#x)\n", reg); | 63 | printk(KERN_ERR "ac97 read timeout (reg %#x)\n", reg); |
67 | dat = 0xffff; | 64 | dat = 0xffff; |
68 | goto done; | 65 | goto done; |
69 | } | 66 | } |
70 | dat = __raw_readl(base + ACREGACC); | 67 | dat = __raw_readl(base + ACREGACC); |
71 | if (((dat >> ACREGACC_REG_SHIFT) & 0xff) != reg) { | 68 | if (((dat >> ACREGACC_REG_SHIFT) & 0xff) != reg) { |
72 | dev_err(dev->soc_dev.dev, "reg mismatch %x with %x\n", | 69 | printk(KERN_ERR "reg mismatch %x with %x\n", |
73 | dat, reg); | 70 | dat, reg); |
74 | dat = 0xffff; | 71 | dat = 0xffff; |
75 | goto done; | 72 | goto done; |
@@ -84,16 +81,15 @@ done: | |||
84 | static void txx9aclc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | 81 | static void txx9aclc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, |
85 | unsigned short val) | 82 | unsigned short val) |
86 | { | 83 | { |
87 | struct txx9aclc_soc_device *dev = txx9aclc_soc_dev; | 84 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; |
88 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
89 | void __iomem *base = drvdata->base; | 85 | void __iomem *base = drvdata->base; |
90 | 86 | ||
91 | __raw_writel(((reg | (ac97->num << 7)) << ACREGACC_REG_SHIFT) | | 87 | __raw_writel(((reg | (ac97->num << 7)) << ACREGACC_REG_SHIFT) | |
92 | (val << ACREGACC_DAT_SHIFT), | 88 | (val << ACREGACC_DAT_SHIFT), |
93 | base + ACREGACC); | 89 | base + ACREGACC); |
94 | __raw_writel(ACINT_REGACCRDY, base + ACINTEN); | 90 | __raw_writel(ACINT_REGACCRDY, base + ACINTEN); |
95 | if (!wait_event_timeout(ac97_waitq, txx9aclc_regready(dev), HZ)) { | 91 | if (!wait_event_timeout(ac97_waitq, txx9aclc_regready(txx9aclc_drvdata), HZ)) { |
96 | dev_err(dev->soc_dev.dev, | 92 | printk(KERN_ERR |
97 | "ac97 write timeout (reg %#x)\n", reg); | 93 | "ac97 write timeout (reg %#x)\n", reg); |
98 | } | 94 | } |
99 | __raw_writel(ACINT_REGACCRDY, base + ACINTDIS); | 95 | __raw_writel(ACINT_REGACCRDY, base + ACINTDIS); |
@@ -101,8 +97,7 @@ static void txx9aclc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | |||
101 | 97 | ||
102 | static void txx9aclc_ac97_cold_reset(struct snd_ac97 *ac97) | 98 | static void txx9aclc_ac97_cold_reset(struct snd_ac97 *ac97) |
103 | { | 99 | { |
104 | struct txx9aclc_soc_device *dev = txx9aclc_soc_dev; | 100 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; |
105 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
106 | void __iomem *base = drvdata->base; | 101 | void __iomem *base = drvdata->base; |
107 | u32 ready = ACINT_CODECRDY(ac97->num) | ACINT_REGACCRDY; | 102 | u32 ready = ACINT_CODECRDY(ac97->num) | ACINT_REGACCRDY; |
108 | 103 | ||
@@ -141,31 +136,23 @@ static irqreturn_t txx9aclc_ac97_irq(int irq, void *dev_id) | |||
141 | return IRQ_HANDLED; | 136 | return IRQ_HANDLED; |
142 | } | 137 | } |
143 | 138 | ||
144 | static int txx9aclc_ac97_probe(struct platform_device *pdev, | 139 | static int txx9aclc_ac97_probe(struct snd_soc_dai *dai) |
145 | struct snd_soc_dai *dai) | ||
146 | { | 140 | { |
147 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 141 | txx9aclc_drvdata = snd_soc_dai_get_drvdata(dai); |
148 | struct txx9aclc_soc_device *dev = | ||
149 | container_of(socdev, struct txx9aclc_soc_device, soc_dev); | ||
150 | |||
151 | dev->aclc_pdev = to_platform_device(dai->dev); | ||
152 | txx9aclc_soc_dev = dev; | ||
153 | return 0; | 142 | return 0; |
154 | } | 143 | } |
155 | 144 | ||
156 | static void txx9aclc_ac97_remove(struct platform_device *pdev, | 145 | static int txx9aclc_ac97_remove(struct snd_soc_dai *dai) |
157 | struct snd_soc_dai *dai) | ||
158 | { | 146 | { |
159 | struct platform_device *aclc_pdev = to_platform_device(dai->dev); | 147 | struct txx9aclc_plat_drvdata *drvdata = snd_soc_dai_get_drvdata(dai); |
160 | struct txx9aclc_plat_drvdata *drvdata = platform_get_drvdata(aclc_pdev); | ||
161 | 148 | ||
162 | /* disable AC-link */ | 149 | /* disable AC-link */ |
163 | __raw_writel(ACCTL_ENLINK, drvdata->base + ACCTLDIS); | 150 | __raw_writel(ACCTL_ENLINK, drvdata->base + ACCTLDIS); |
164 | txx9aclc_soc_dev = NULL; | 151 | txx9aclc_drvdata = NULL; |
152 | return 0; | ||
165 | } | 153 | } |
166 | 154 | ||
167 | struct snd_soc_dai txx9aclc_ac97_dai = { | 155 | static struct snd_soc_dai_driver txx9aclc_ac97_dai = { |
168 | .name = "txx9aclc_ac97", | ||
169 | .ac97_control = 1, | 156 | .ac97_control = 1, |
170 | .probe = txx9aclc_ac97_probe, | 157 | .probe = txx9aclc_ac97_probe, |
171 | .remove = txx9aclc_ac97_remove, | 158 | .remove = txx9aclc_ac97_remove, |
@@ -182,7 +169,6 @@ struct snd_soc_dai txx9aclc_ac97_dai = { | |||
182 | .channels_max = 2, | 169 | .channels_max = 2, |
183 | }, | 170 | }, |
184 | }; | 171 | }; |
185 | EXPORT_SYMBOL_GPL(txx9aclc_ac97_dai); | ||
186 | 172 | ||
187 | static int __devinit txx9aclc_ac97_dev_probe(struct platform_device *pdev) | 173 | static int __devinit txx9aclc_ac97_dev_probe(struct platform_device *pdev) |
188 | { | 174 | { |
@@ -219,13 +205,12 @@ static int __devinit txx9aclc_ac97_dev_probe(struct platform_device *pdev) | |||
219 | if (err < 0) | 205 | if (err < 0) |
220 | return err; | 206 | return err; |
221 | 207 | ||
222 | txx9aclc_ac97_dai.dev = &pdev->dev; | 208 | return snd_soc_register_dai(&pdev->dev, &txx9aclc_ac97_dai); |
223 | return snd_soc_register_dai(&txx9aclc_ac97_dai); | ||
224 | } | 209 | } |
225 | 210 | ||
226 | static int __devexit txx9aclc_ac97_dev_remove(struct platform_device *pdev) | 211 | static int __devexit txx9aclc_ac97_dev_remove(struct platform_device *pdev) |
227 | { | 212 | { |
228 | snd_soc_unregister_dai(&txx9aclc_ac97_dai); | 213 | snd_soc_unregister_dai(&pdev->dev); |
229 | return 0; | 214 | return 0; |
230 | } | 215 | } |
231 | 216 | ||