blob: 71fbf8d7ee820a8c6d6c3820a89eeed4b6741f25 [file] [log] [blame]
Takashi Iwai2c484df2005-06-30 18:54:04 +02001/*
2 * linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip.
3 *
4 * Author: Nicolas Pitre
5 * Created: Dec 02, 2004
6 * Copyright: MontaVista Software Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/kernel.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010016#include <linux/platform_device.h>
Takashi Iwai2c484df2005-06-30 18:54:04 +020017#include <linux/interrupt.h>
18#include <linux/wait.h>
Mark Brown93873fb2008-03-04 11:14:25 +010019#include <linux/clk.h>
Takashi Iwai2c484df2005-06-30 18:54:04 +020020#include <linux/delay.h>
21
Takashi Iwai2c484df2005-06-30 18:54:04 +020022#include <sound/core.h>
23#include <sound/pcm.h>
24#include <sound/ac97_codec.h>
25#include <sound/initval.h>
26
27#include <asm/irq.h>
Ingo Molnar12aa7572006-01-16 16:36:05 +010028#include <linux/mutex.h>
Takashi Iwai2c484df2005-06-30 18:54:04 +020029#include <asm/hardware.h>
30#include <asm/arch/pxa-regs.h>
eric miaoa683b142008-03-03 09:44:25 +080031#include <asm/arch/pxa2xx-gpio.h>
Takashi Iwai2c484df2005-06-30 18:54:04 +020032#include <asm/arch/audio.h>
33
34#include "pxa2xx-pcm.h"
35
36
Ingo Molnar12aa7572006-01-16 16:36:05 +010037static DEFINE_MUTEX(car_mutex);
Takashi Iwai2c484df2005-06-30 18:54:04 +020038static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
39static volatile long gsr_bits;
Mark Brown93873fb2008-03-04 11:14:25 +010040static struct clk *ac97_clk;
41#ifdef CONFIG_PXA27x
42static struct clk *ac97conf_clk;
43#endif
Takashi Iwai2c484df2005-06-30 18:54:04 +020044
Nicolas Pitreea265c02005-12-12 15:41:47 +010045/*
46 * Beware PXA27x bugs:
47 *
48 * o Slot 12 read from modem space will hang controller.
49 * o CDONE, SDONE interrupt fails after any slot 12 IO.
50 *
51 * We therefore have an hybrid approach for waiting on SDONE (interrupt or
52 * 1 jiffy timeout if interrupt never comes).
53 */
54
Takashi Iwaid18f8372005-11-17 15:10:38 +010055static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
Takashi Iwai2c484df2005-06-30 18:54:04 +020056{
57 unsigned short val = -1;
58 volatile u32 *reg_addr;
59
Ingo Molnar12aa7572006-01-16 16:36:05 +010060 mutex_lock(&car_mutex);
Takashi Iwai2c484df2005-06-30 18:54:04 +020061
62 /* set up primary or secondary codec space */
63 reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE;
64 reg_addr += (reg >> 1);
65
66 /* start read access across the ac97 link */
Nicolas Pitreea265c02005-12-12 15:41:47 +010067 GSR = GSR_CDONE | GSR_SDONE;
Takashi Iwai2c484df2005-06-30 18:54:04 +020068 gsr_bits = 0;
69 val = *reg_addr;
70 if (reg == AC97_GPIO_STATUS)
71 goto out;
Nicolas Pitreea265c02005-12-12 15:41:47 +010072 if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 &&
73 !((GSR | gsr_bits) & GSR_SDONE)) {
Takashi Iwai2c484df2005-06-30 18:54:04 +020074 printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",
Harvey Harrison9bf8e7d2008-03-03 15:32:18 -080075 __func__, reg, GSR | gsr_bits);
Takashi Iwai2c484df2005-06-30 18:54:04 +020076 val = -1;
77 goto out;
78 }
79
80 /* valid data now */
Nicolas Pitreea265c02005-12-12 15:41:47 +010081 GSR = GSR_CDONE | GSR_SDONE;
Takashi Iwai2c484df2005-06-30 18:54:04 +020082 gsr_bits = 0;
83 val = *reg_addr;
84 /* but we've just started another cycle... */
Nicolas Pitreea265c02005-12-12 15:41:47 +010085 wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
Takashi Iwai2c484df2005-06-30 18:54:04 +020086
Ingo Molnar12aa7572006-01-16 16:36:05 +010087out: mutex_unlock(&car_mutex);
Takashi Iwai2c484df2005-06-30 18:54:04 +020088 return val;
89}
90
Takashi Iwaid18f8372005-11-17 15:10:38 +010091static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val)
Takashi Iwai2c484df2005-06-30 18:54:04 +020092{
93 volatile u32 *reg_addr;
94
Ingo Molnar12aa7572006-01-16 16:36:05 +010095 mutex_lock(&car_mutex);
Takashi Iwai2c484df2005-06-30 18:54:04 +020096
Takashi Iwai2c484df2005-06-30 18:54:04 +020097 /* set up primary or secondary codec space */
98 reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE;
99 reg_addr += (reg >> 1);
Nicolas Pitreea265c02005-12-12 15:41:47 +0100100
101 GSR = GSR_CDONE | GSR_SDONE;
Takashi Iwai2c484df2005-06-30 18:54:04 +0200102 gsr_bits = 0;
103 *reg_addr = val;
Nicolas Pitreea265c02005-12-12 15:41:47 +0100104 if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1) <= 0 &&
105 !((GSR | gsr_bits) & GSR_CDONE))
Takashi Iwai2c484df2005-06-30 18:54:04 +0200106 printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n",
Harvey Harrison9bf8e7d2008-03-03 15:32:18 -0800107 __func__, reg, GSR | gsr_bits);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200108
Ingo Molnar12aa7572006-01-16 16:36:05 +0100109 mutex_unlock(&car_mutex);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200110}
111
Takashi Iwaid18f8372005-11-17 15:10:38 +0100112static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200113{
114 /* First, try cold reset */
115 GCR &= GCR_COLD_RST; /* clear everything but nCRST */
116 GCR &= ~GCR_COLD_RST; /* then assert nCRST */
117
118 gsr_bits = 0;
119#ifdef CONFIG_PXA27x
120 /* PXA27x Developers Manual section 13.5.2.2.1 */
Mark Brown93873fb2008-03-04 11:14:25 +0100121 clk_enable(ac97conf_clk);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200122 udelay(5);
Mark Brown93873fb2008-03-04 11:14:25 +0100123 clk_disable(ac97conf_clk);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200124 GCR = GCR_COLD_RST;
125 udelay(50);
126#else
127 GCR = GCR_COLD_RST;
128 GCR |= GCR_CDONE_IE|GCR_SDONE_IE;
129 wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
130#endif
131
132 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) {
133 printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
Harvey Harrison9bf8e7d2008-03-03 15:32:18 -0800134 __func__, gsr_bits);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200135
136 /* let's try warm reset */
137 gsr_bits = 0;
138#ifdef CONFIG_PXA27x
139 /* warm reset broken on Bulverde,
140 so manually keep AC97 reset high */
141 pxa_gpio_mode(113 | GPIO_OUT | GPIO_DFLT_HIGH);
142 udelay(10);
143 GCR |= GCR_WARM_RST;
144 pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
Liam Girdwood4a677ac52005-08-05 10:24:36 +0200145 udelay(500);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200146#else
Liam Girdwood4a677ac52005-08-05 10:24:36 +0200147 GCR |= GCR_WARM_RST|GCR_PRIRDY_IEN|GCR_SECRDY_IEN;
Takashi Iwai2c484df2005-06-30 18:54:04 +0200148 wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
149#endif
150
151 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
152 printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
Harvey Harrison9bf8e7d2008-03-03 15:32:18 -0800153 __func__, gsr_bits);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200154 }
155
156 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
157 GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
158}
159
David Howells7d12e782006-10-05 14:55:46 +0100160static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200161{
162 long status;
163
164 status = GSR;
165 if (status) {
166 GSR = status;
167 gsr_bits |= status;
168 wake_up(&gsr_wq);
169
170#ifdef CONFIG_PXA27x
171 /* Although we don't use those we still need to clear them
172 since they tend to spuriously trigger when MMC is used
173 (hardware bug? go figure)... */
174 MISR = MISR_EOC;
175 PISR = PISR_EOC;
176 MCSR = MCSR_EOC;
177#endif
178
179 return IRQ_HANDLED;
180 }
181
182 return IRQ_NONE;
183}
184
Takashi Iwaid18f8372005-11-17 15:10:38 +0100185static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
Takashi Iwai2c484df2005-06-30 18:54:04 +0200186 .read = pxa2xx_ac97_read,
187 .write = pxa2xx_ac97_write,
188 .reset = pxa2xx_ac97_reset,
189};
190
Takashi Iwaid18f8372005-11-17 15:10:38 +0100191static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_out = {
Takashi Iwai2c484df2005-06-30 18:54:04 +0200192 .name = "AC97 PCM out",
193 .dev_addr = __PREG(PCDR),
194 .drcmr = &DRCMRTXPCDR,
195 .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG |
196 DCMD_BURST32 | DCMD_WIDTH4,
197};
198
Takashi Iwaid18f8372005-11-17 15:10:38 +0100199static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_in = {
Takashi Iwai2c484df2005-06-30 18:54:04 +0200200 .name = "AC97 PCM in",
201 .dev_addr = __PREG(PCDR),
202 .drcmr = &DRCMRRXPCDR,
203 .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC |
204 DCMD_BURST32 | DCMD_WIDTH4,
205};
206
Takashi Iwaid18f8372005-11-17 15:10:38 +0100207static struct snd_pcm *pxa2xx_ac97_pcm;
208static struct snd_ac97 *pxa2xx_ac97_ac97;
Takashi Iwai2c484df2005-06-30 18:54:04 +0200209
Takashi Iwaid18f8372005-11-17 15:10:38 +0100210static int pxa2xx_ac97_pcm_startup(struct snd_pcm_substream *substream)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200211{
Takashi Iwaid18f8372005-11-17 15:10:38 +0100212 struct snd_pcm_runtime *runtime = substream->runtime;
Takashi Iwai2c484df2005-06-30 18:54:04 +0200213 pxa2xx_audio_ops_t *platform_ops;
214 int r;
215
216 runtime->hw.channels_min = 2;
217 runtime->hw.channels_max = 2;
218
219 r = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
220 AC97_RATES_FRONT_DAC : AC97_RATES_ADC;
221 runtime->hw.rates = pxa2xx_ac97_ac97->rates[r];
222 snd_pcm_limit_hw_rates(runtime);
223
224 platform_ops = substream->pcm->card->dev->platform_data;
225 if (platform_ops && platform_ops->startup)
226 return platform_ops->startup(substream, platform_ops->priv);
227 else
228 return 0;
229}
230
Takashi Iwaid18f8372005-11-17 15:10:38 +0100231static void pxa2xx_ac97_pcm_shutdown(struct snd_pcm_substream *substream)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200232{
233 pxa2xx_audio_ops_t *platform_ops;
234
235 platform_ops = substream->pcm->card->dev->platform_data;
236 if (platform_ops && platform_ops->shutdown)
237 platform_ops->shutdown(substream, platform_ops->priv);
238}
239
Takashi Iwaid18f8372005-11-17 15:10:38 +0100240static int pxa2xx_ac97_pcm_prepare(struct snd_pcm_substream *substream)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200241{
Takashi Iwaid18f8372005-11-17 15:10:38 +0100242 struct snd_pcm_runtime *runtime = substream->runtime;
Takashi Iwai2c484df2005-06-30 18:54:04 +0200243 int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
244 AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
245 return snd_ac97_set_rate(pxa2xx_ac97_ac97, reg, runtime->rate);
246}
247
Takashi Iwaid18f8372005-11-17 15:10:38 +0100248static struct pxa2xx_pcm_client pxa2xx_ac97_pcm_client = {
Takashi Iwai2c484df2005-06-30 18:54:04 +0200249 .playback_params = &pxa2xx_ac97_pcm_out,
250 .capture_params = &pxa2xx_ac97_pcm_in,
251 .startup = pxa2xx_ac97_pcm_startup,
252 .shutdown = pxa2xx_ac97_pcm_shutdown,
253 .prepare = pxa2xx_ac97_pcm_prepare,
254};
255
256#ifdef CONFIG_PM
257
Takashi Iwaid18f8372005-11-17 15:10:38 +0100258static int pxa2xx_ac97_do_suspend(struct snd_card *card, pm_message_t state)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200259{
Takashi Iwai792a6c52005-11-17 17:19:25 +0100260 pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data;
261
262 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold);
263 snd_pcm_suspend_all(pxa2xx_ac97_pcm);
264 snd_ac97_suspend(pxa2xx_ac97_ac97);
265 if (platform_ops && platform_ops->suspend)
266 platform_ops->suspend(platform_ops->priv);
267 GCR |= GCR_ACLINK_OFF;
Mark Brown93873fb2008-03-04 11:14:25 +0100268 clk_disable(ac97_clk);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200269
270 return 0;
271}
272
Takashi Iwaid18f8372005-11-17 15:10:38 +0100273static int pxa2xx_ac97_do_resume(struct snd_card *card)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200274{
Takashi Iwai792a6c52005-11-17 17:19:25 +0100275 pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data;
276
Mark Brown93873fb2008-03-04 11:14:25 +0100277 clk_enable(ac97_clk);
Takashi Iwai792a6c52005-11-17 17:19:25 +0100278 if (platform_ops && platform_ops->resume)
279 platform_ops->resume(platform_ops->priv);
280 snd_ac97_resume(pxa2xx_ac97_ac97);
281 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200282
283 return 0;
284}
285
Russell King3ae5eae2005-11-09 22:32:44 +0000286static int pxa2xx_ac97_suspend(struct platform_device *dev, pm_message_t state)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200287{
Takashi Iwaid18f8372005-11-17 15:10:38 +0100288 struct snd_card *card = platform_get_drvdata(dev);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200289 int ret = 0;
290
Russell King9480e302005-10-28 09:52:56 -0700291 if (card)
Dirk Opfera55bfdc2005-08-08 16:29:43 +0200292 ret = pxa2xx_ac97_do_suspend(card, PMSG_SUSPEND);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200293
294 return ret;
295}
296
Russell King3ae5eae2005-11-09 22:32:44 +0000297static int pxa2xx_ac97_resume(struct platform_device *dev)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200298{
Takashi Iwaid18f8372005-11-17 15:10:38 +0100299 struct snd_card *card = platform_get_drvdata(dev);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200300 int ret = 0;
301
Russell King9480e302005-10-28 09:52:56 -0700302 if (card)
Dirk Opfera55bfdc2005-08-08 16:29:43 +0200303 ret = pxa2xx_ac97_do_resume(card);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200304
305 return ret;
306}
307
308#else
309#define pxa2xx_ac97_suspend NULL
310#define pxa2xx_ac97_resume NULL
311#endif
312
Prarit Bhargava788c6042007-02-13 13:11:11 +0100313static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200314{
Takashi Iwaid18f8372005-11-17 15:10:38 +0100315 struct snd_card *card;
316 struct snd_ac97_bus *ac97_bus;
317 struct snd_ac97_template ac97_template;
Takashi Iwai2c484df2005-06-30 18:54:04 +0200318 int ret;
319
320 ret = -ENOMEM;
321 card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
322 THIS_MODULE, 0);
323 if (!card)
324 goto err;
325
Russell King3ae5eae2005-11-09 22:32:44 +0000326 card->dev = &dev->dev;
327 strncpy(card->driver, dev->dev.driver->name, sizeof(card->driver));
Takashi Iwai2c484df2005-06-30 18:54:04 +0200328
329 ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm);
330 if (ret)
331 goto err;
332
333 ret = request_irq(IRQ_AC97, pxa2xx_ac97_irq, 0, "AC97", NULL);
334 if (ret < 0)
335 goto err;
336
337 pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
338 pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
339 pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);
340 pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD);
341#ifdef CONFIG_PXA27x
342 /* Use GPIO 113 as AC97 Reset on Bulverde */
343 pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
Mark Brown93873fb2008-03-04 11:14:25 +0100344 ac97conf_clk = clk_get(&dev->dev, "AC97CONFCLK");
345 if (IS_ERR(ac97conf_clk)) {
346 ret = PTR_ERR(ac97conf_clk);
347 ac97conf_clk = NULL;
348 goto err;
349 }
Takashi Iwai2c484df2005-06-30 18:54:04 +0200350#endif
Mark Brown93873fb2008-03-04 11:14:25 +0100351
352 ac97_clk = clk_get(&dev->dev, "AC97CLK");
353 if (IS_ERR(ac97_clk)) {
354 ret = PTR_ERR(ac97_clk);
355 ac97_clk = NULL;
356 goto err;
357 }
358 clk_enable(ac97_clk);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200359
360 ret = snd_ac97_bus(card, 0, &pxa2xx_ac97_ops, NULL, &ac97_bus);
361 if (ret)
362 goto err;
363 memset(&ac97_template, 0, sizeof(ac97_template));
364 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &pxa2xx_ac97_ac97);
365 if (ret)
366 goto err;
367
368 snprintf(card->shortname, sizeof(card->shortname),
369 "%s", snd_ac97_get_short_name(pxa2xx_ac97_ac97));
370 snprintf(card->longname, sizeof(card->longname),
Russell King3ae5eae2005-11-09 22:32:44 +0000371 "%s (%s)", dev->dev.driver->name, card->mixername);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200372
Takashi Iwaif78dfac2007-12-17 16:24:04 +0100373 snd_card_set_dev(card, &dev->dev);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200374 ret = snd_card_register(card);
375 if (ret == 0) {
Russell King3ae5eae2005-11-09 22:32:44 +0000376 platform_set_drvdata(dev, card);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200377 return 0;
378 }
379
380 err:
381 if (card)
382 snd_card_free(card);
Mark Brown93873fb2008-03-04 11:14:25 +0100383 if (ac97_clk) {
Takashi Iwai2c484df2005-06-30 18:54:04 +0200384 GCR |= GCR_ACLINK_OFF;
385 free_irq(IRQ_AC97, NULL);
Mark Brown93873fb2008-03-04 11:14:25 +0100386 clk_disable(ac97_clk);
387 clk_put(ac97_clk);
388 ac97_clk = NULL;
Takashi Iwai2c484df2005-06-30 18:54:04 +0200389 }
Mark Brown93873fb2008-03-04 11:14:25 +0100390#ifdef CONFIG_PXA27x
391 if (ac97conf_clk) {
392 clk_put(ac97conf_clk);
393 ac97conf_clk = NULL;
394 }
395#endif
Takashi Iwai2c484df2005-06-30 18:54:04 +0200396 return ret;
397}
398
Prarit Bhargava788c6042007-02-13 13:11:11 +0100399static int __devexit pxa2xx_ac97_remove(struct platform_device *dev)
Takashi Iwai2c484df2005-06-30 18:54:04 +0200400{
Takashi Iwaid18f8372005-11-17 15:10:38 +0100401 struct snd_card *card = platform_get_drvdata(dev);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200402
403 if (card) {
404 snd_card_free(card);
Russell King3ae5eae2005-11-09 22:32:44 +0000405 platform_set_drvdata(dev, NULL);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200406 GCR |= GCR_ACLINK_OFF;
407 free_irq(IRQ_AC97, NULL);
Mark Brown93873fb2008-03-04 11:14:25 +0100408 clk_disable(ac97_clk);
409 clk_put(ac97_clk);
410 ac97_clk = NULL;
411#ifdef CONFIG_PXA27x
412 clk_put(ac97conf_clk);
413 ac97conf_clk = NULL;
414#endif
Takashi Iwai2c484df2005-06-30 18:54:04 +0200415 }
416
417 return 0;
418}
419
Russell King3ae5eae2005-11-09 22:32:44 +0000420static struct platform_driver pxa2xx_ac97_driver = {
Takashi Iwai2c484df2005-06-30 18:54:04 +0200421 .probe = pxa2xx_ac97_probe,
Prarit Bhargava788c6042007-02-13 13:11:11 +0100422 .remove = __devexit_p(pxa2xx_ac97_remove),
Takashi Iwai2c484df2005-06-30 18:54:04 +0200423 .suspend = pxa2xx_ac97_suspend,
424 .resume = pxa2xx_ac97_resume,
Russell King3ae5eae2005-11-09 22:32:44 +0000425 .driver = {
426 .name = "pxa2xx-ac97",
Kay Sievers8b45a202008-04-14 13:33:36 +0200427 .owner = THIS_MODULE,
Russell King3ae5eae2005-11-09 22:32:44 +0000428 },
Takashi Iwai2c484df2005-06-30 18:54:04 +0200429};
430
431static int __init pxa2xx_ac97_init(void)
432{
Russell King3ae5eae2005-11-09 22:32:44 +0000433 return platform_driver_register(&pxa2xx_ac97_driver);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200434}
435
436static void __exit pxa2xx_ac97_exit(void)
437{
Russell King3ae5eae2005-11-09 22:32:44 +0000438 platform_driver_unregister(&pxa2xx_ac97_driver);
Takashi Iwai2c484df2005-06-30 18:54:04 +0200439}
440
441module_init(pxa2xx_ac97_init);
442module_exit(pxa2xx_ac97_exit);
443
444MODULE_AUTHOR("Nicolas Pitre");
445MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip");
446MODULE_LICENSE("GPL");
Kay Sievers8b45a202008-04-14 13:33:36 +0200447MODULE_ALIAS("platform:pxa2xx-ac97");