Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 1 | /* |
| 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 King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 16 | #include <linux/platform_device.h> |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/wait.h> |
| 19 | #include <linux/delay.h> |
| 20 | |
| 21 | #include <sound/driver.h> |
| 22 | #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> |
| 28 | #include <asm/semaphore.h> |
| 29 | #include <asm/hardware.h> |
| 30 | #include <asm/arch/pxa-regs.h> |
| 31 | #include <asm/arch/audio.h> |
| 32 | |
| 33 | #include "pxa2xx-pcm.h" |
| 34 | |
| 35 | |
| 36 | static DECLARE_MUTEX(car_mutex); |
| 37 | static DECLARE_WAIT_QUEUE_HEAD(gsr_wq); |
| 38 | static volatile long gsr_bits; |
| 39 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 40 | static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 41 | { |
| 42 | unsigned short val = -1; |
| 43 | volatile u32 *reg_addr; |
| 44 | |
| 45 | down(&car_mutex); |
| 46 | if (CAR & CAR_CAIP) { |
| 47 | printk(KERN_CRIT"%s: CAR_CAIP already set\n", __FUNCTION__); |
| 48 | goto out; |
| 49 | } |
| 50 | |
| 51 | /* set up primary or secondary codec space */ |
| 52 | reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE; |
| 53 | reg_addr += (reg >> 1); |
| 54 | |
| 55 | /* start read access across the ac97 link */ |
| 56 | gsr_bits = 0; |
| 57 | val = *reg_addr; |
| 58 | if (reg == AC97_GPIO_STATUS) |
| 59 | goto out; |
| 60 | wait_event_timeout(gsr_wq, gsr_bits & GSR_SDONE, 1); |
| 61 | if (!gsr_bits & GSR_SDONE) { |
| 62 | printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n", |
| 63 | __FUNCTION__, reg, gsr_bits); |
| 64 | val = -1; |
| 65 | goto out; |
| 66 | } |
| 67 | |
| 68 | /* valid data now */ |
| 69 | gsr_bits = 0; |
| 70 | val = *reg_addr; |
| 71 | /* but we've just started another cycle... */ |
| 72 | wait_event_timeout(gsr_wq, gsr_bits & GSR_SDONE, 1); |
| 73 | |
| 74 | out: up(&car_mutex); |
| 75 | return val; |
| 76 | } |
| 77 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 78 | static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 79 | { |
| 80 | volatile u32 *reg_addr; |
| 81 | |
| 82 | down(&car_mutex); |
| 83 | |
| 84 | if (CAR & CAR_CAIP) { |
| 85 | printk(KERN_CRIT "%s: CAR_CAIP already set\n", __FUNCTION__); |
| 86 | goto out; |
| 87 | } |
| 88 | |
| 89 | /* set up primary or secondary codec space */ |
| 90 | reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE; |
| 91 | reg_addr += (reg >> 1); |
| 92 | gsr_bits = 0; |
| 93 | *reg_addr = val; |
| 94 | wait_event_timeout(gsr_wq, gsr_bits & GSR_CDONE, 1); |
| 95 | if (!gsr_bits & GSR_SDONE) |
| 96 | printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n", |
| 97 | __FUNCTION__, reg, gsr_bits); |
| 98 | |
| 99 | out: up(&car_mutex); |
| 100 | } |
| 101 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 102 | static void pxa2xx_ac97_reset(struct snd_ac97 *ac97) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 103 | { |
| 104 | /* First, try cold reset */ |
| 105 | GCR &= GCR_COLD_RST; /* clear everything but nCRST */ |
| 106 | GCR &= ~GCR_COLD_RST; /* then assert nCRST */ |
| 107 | |
| 108 | gsr_bits = 0; |
| 109 | #ifdef CONFIG_PXA27x |
| 110 | /* PXA27x Developers Manual section 13.5.2.2.1 */ |
| 111 | pxa_set_cken(1 << 31, 1); |
| 112 | udelay(5); |
| 113 | pxa_set_cken(1 << 31, 0); |
| 114 | GCR = GCR_COLD_RST; |
| 115 | udelay(50); |
| 116 | #else |
| 117 | GCR = GCR_COLD_RST; |
| 118 | GCR |= GCR_CDONE_IE|GCR_SDONE_IE; |
| 119 | wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); |
| 120 | #endif |
| 121 | |
| 122 | if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) { |
| 123 | printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n", |
| 124 | __FUNCTION__, gsr_bits); |
| 125 | |
| 126 | /* let's try warm reset */ |
| 127 | gsr_bits = 0; |
| 128 | #ifdef CONFIG_PXA27x |
| 129 | /* warm reset broken on Bulverde, |
| 130 | so manually keep AC97 reset high */ |
| 131 | pxa_gpio_mode(113 | GPIO_OUT | GPIO_DFLT_HIGH); |
| 132 | udelay(10); |
| 133 | GCR |= GCR_WARM_RST; |
| 134 | pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT); |
Liam Girdwood | 4a677ac5 | 2005-08-05 10:24:36 +0200 | [diff] [blame] | 135 | udelay(500); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 136 | #else |
Liam Girdwood | 4a677ac5 | 2005-08-05 10:24:36 +0200 | [diff] [blame] | 137 | GCR |= GCR_WARM_RST|GCR_PRIRDY_IEN|GCR_SECRDY_IEN; |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 138 | wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); |
| 139 | #endif |
| 140 | |
| 141 | if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) |
| 142 | printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", |
| 143 | __FUNCTION__, gsr_bits); |
| 144 | } |
| 145 | |
| 146 | GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); |
| 147 | GCR |= GCR_SDONE_IE|GCR_CDONE_IE; |
| 148 | } |
| 149 | |
| 150 | static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id, struct pt_regs *regs) |
| 151 | { |
| 152 | long status; |
| 153 | |
| 154 | status = GSR; |
| 155 | if (status) { |
| 156 | GSR = status; |
| 157 | gsr_bits |= status; |
| 158 | wake_up(&gsr_wq); |
| 159 | |
| 160 | #ifdef CONFIG_PXA27x |
| 161 | /* Although we don't use those we still need to clear them |
| 162 | since they tend to spuriously trigger when MMC is used |
| 163 | (hardware bug? go figure)... */ |
| 164 | MISR = MISR_EOC; |
| 165 | PISR = PISR_EOC; |
| 166 | MCSR = MCSR_EOC; |
| 167 | #endif |
| 168 | |
| 169 | return IRQ_HANDLED; |
| 170 | } |
| 171 | |
| 172 | return IRQ_NONE; |
| 173 | } |
| 174 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 175 | static struct snd_ac97_bus_ops pxa2xx_ac97_ops = { |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 176 | .read = pxa2xx_ac97_read, |
| 177 | .write = pxa2xx_ac97_write, |
| 178 | .reset = pxa2xx_ac97_reset, |
| 179 | }; |
| 180 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 181 | static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_out = { |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 182 | .name = "AC97 PCM out", |
| 183 | .dev_addr = __PREG(PCDR), |
| 184 | .drcmr = &DRCMRTXPCDR, |
| 185 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | |
| 186 | DCMD_BURST32 | DCMD_WIDTH4, |
| 187 | }; |
| 188 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 189 | static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_in = { |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 190 | .name = "AC97 PCM in", |
| 191 | .dev_addr = __PREG(PCDR), |
| 192 | .drcmr = &DRCMRRXPCDR, |
| 193 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | |
| 194 | DCMD_BURST32 | DCMD_WIDTH4, |
| 195 | }; |
| 196 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 197 | static struct snd_pcm *pxa2xx_ac97_pcm; |
| 198 | static struct snd_ac97 *pxa2xx_ac97_ac97; |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 199 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 200 | static int pxa2xx_ac97_pcm_startup(struct snd_pcm_substream *substream) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 201 | { |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 202 | struct snd_pcm_runtime *runtime = substream->runtime; |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 203 | pxa2xx_audio_ops_t *platform_ops; |
| 204 | int r; |
| 205 | |
| 206 | runtime->hw.channels_min = 2; |
| 207 | runtime->hw.channels_max = 2; |
| 208 | |
| 209 | r = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? |
| 210 | AC97_RATES_FRONT_DAC : AC97_RATES_ADC; |
| 211 | runtime->hw.rates = pxa2xx_ac97_ac97->rates[r]; |
| 212 | snd_pcm_limit_hw_rates(runtime); |
| 213 | |
| 214 | platform_ops = substream->pcm->card->dev->platform_data; |
| 215 | if (platform_ops && platform_ops->startup) |
| 216 | return platform_ops->startup(substream, platform_ops->priv); |
| 217 | else |
| 218 | return 0; |
| 219 | } |
| 220 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 221 | static void pxa2xx_ac97_pcm_shutdown(struct snd_pcm_substream *substream) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 222 | { |
| 223 | pxa2xx_audio_ops_t *platform_ops; |
| 224 | |
| 225 | platform_ops = substream->pcm->card->dev->platform_data; |
| 226 | if (platform_ops && platform_ops->shutdown) |
| 227 | platform_ops->shutdown(substream, platform_ops->priv); |
| 228 | } |
| 229 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 230 | static int pxa2xx_ac97_pcm_prepare(struct snd_pcm_substream *substream) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 231 | { |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 232 | struct snd_pcm_runtime *runtime = substream->runtime; |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 233 | int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? |
| 234 | AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; |
| 235 | return snd_ac97_set_rate(pxa2xx_ac97_ac97, reg, runtime->rate); |
| 236 | } |
| 237 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 238 | static struct pxa2xx_pcm_client pxa2xx_ac97_pcm_client = { |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 239 | .playback_params = &pxa2xx_ac97_pcm_out, |
| 240 | .capture_params = &pxa2xx_ac97_pcm_in, |
| 241 | .startup = pxa2xx_ac97_pcm_startup, |
| 242 | .shutdown = pxa2xx_ac97_pcm_shutdown, |
| 243 | .prepare = pxa2xx_ac97_pcm_prepare, |
| 244 | }; |
| 245 | |
| 246 | #ifdef CONFIG_PM |
| 247 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 248 | static int pxa2xx_ac97_do_suspend(struct snd_card *card, pm_message_t state) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 249 | { |
Takashi Iwai | 792a6c5 | 2005-11-17 17:19:25 +0100 | [diff] [blame^] | 250 | pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; |
| 251 | |
| 252 | snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); |
| 253 | snd_pcm_suspend_all(pxa2xx_ac97_pcm); |
| 254 | snd_ac97_suspend(pxa2xx_ac97_ac97); |
| 255 | if (platform_ops && platform_ops->suspend) |
| 256 | platform_ops->suspend(platform_ops->priv); |
| 257 | GCR |= GCR_ACLINK_OFF; |
| 258 | pxa_set_cken(CKEN2_AC97, 0); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 259 | |
| 260 | return 0; |
| 261 | } |
| 262 | |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 263 | static int pxa2xx_ac97_do_resume(struct snd_card *card) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 264 | { |
Takashi Iwai | 792a6c5 | 2005-11-17 17:19:25 +0100 | [diff] [blame^] | 265 | pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; |
| 266 | |
| 267 | pxa_set_cken(CKEN2_AC97, 1); |
| 268 | if (platform_ops && platform_ops->resume) |
| 269 | platform_ops->resume(platform_ops->priv); |
| 270 | snd_ac97_resume(pxa2xx_ac97_ac97); |
| 271 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 272 | |
| 273 | return 0; |
| 274 | } |
| 275 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 276 | static int pxa2xx_ac97_suspend(struct platform_device *dev, pm_message_t state) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 277 | { |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 278 | struct snd_card *card = platform_get_drvdata(dev); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 279 | int ret = 0; |
| 280 | |
Russell King | 9480e30 | 2005-10-28 09:52:56 -0700 | [diff] [blame] | 281 | if (card) |
Dirk Opfer | a55bfdc | 2005-08-08 16:29:43 +0200 | [diff] [blame] | 282 | ret = pxa2xx_ac97_do_suspend(card, PMSG_SUSPEND); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 283 | |
| 284 | return ret; |
| 285 | } |
| 286 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 287 | static int pxa2xx_ac97_resume(struct platform_device *dev) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 288 | { |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 289 | struct snd_card *card = platform_get_drvdata(dev); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 290 | int ret = 0; |
| 291 | |
Russell King | 9480e30 | 2005-10-28 09:52:56 -0700 | [diff] [blame] | 292 | if (card) |
Dirk Opfer | a55bfdc | 2005-08-08 16:29:43 +0200 | [diff] [blame] | 293 | ret = pxa2xx_ac97_do_resume(card); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 294 | |
| 295 | return ret; |
| 296 | } |
| 297 | |
| 298 | #else |
| 299 | #define pxa2xx_ac97_suspend NULL |
| 300 | #define pxa2xx_ac97_resume NULL |
| 301 | #endif |
| 302 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 303 | static int pxa2xx_ac97_probe(struct platform_device *dev) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 304 | { |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 305 | struct snd_card *card; |
| 306 | struct snd_ac97_bus *ac97_bus; |
| 307 | struct snd_ac97_template ac97_template; |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 308 | int ret; |
| 309 | |
| 310 | ret = -ENOMEM; |
| 311 | card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, |
| 312 | THIS_MODULE, 0); |
| 313 | if (!card) |
| 314 | goto err; |
| 315 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 316 | card->dev = &dev->dev; |
| 317 | strncpy(card->driver, dev->dev.driver->name, sizeof(card->driver)); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 318 | |
| 319 | ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm); |
| 320 | if (ret) |
| 321 | goto err; |
| 322 | |
| 323 | ret = request_irq(IRQ_AC97, pxa2xx_ac97_irq, 0, "AC97", NULL); |
| 324 | if (ret < 0) |
| 325 | goto err; |
| 326 | |
| 327 | pxa_gpio_mode(GPIO31_SYNC_AC97_MD); |
| 328 | pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD); |
| 329 | pxa_gpio_mode(GPIO28_BITCLK_AC97_MD); |
| 330 | pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD); |
| 331 | #ifdef CONFIG_PXA27x |
| 332 | /* Use GPIO 113 as AC97 Reset on Bulverde */ |
| 333 | pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT); |
| 334 | #endif |
| 335 | pxa_set_cken(CKEN2_AC97, 1); |
| 336 | |
| 337 | ret = snd_ac97_bus(card, 0, &pxa2xx_ac97_ops, NULL, &ac97_bus); |
| 338 | if (ret) |
| 339 | goto err; |
| 340 | memset(&ac97_template, 0, sizeof(ac97_template)); |
| 341 | ret = snd_ac97_mixer(ac97_bus, &ac97_template, &pxa2xx_ac97_ac97); |
| 342 | if (ret) |
| 343 | goto err; |
| 344 | |
| 345 | snprintf(card->shortname, sizeof(card->shortname), |
| 346 | "%s", snd_ac97_get_short_name(pxa2xx_ac97_ac97)); |
| 347 | snprintf(card->longname, sizeof(card->longname), |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 348 | "%s (%s)", dev->dev.driver->name, card->mixername); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 349 | |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 350 | ret = snd_card_register(card); |
| 351 | if (ret == 0) { |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 352 | platform_set_drvdata(dev, card); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 353 | return 0; |
| 354 | } |
| 355 | |
| 356 | err: |
| 357 | if (card) |
| 358 | snd_card_free(card); |
| 359 | if (CKEN & CKEN2_AC97) { |
| 360 | GCR |= GCR_ACLINK_OFF; |
| 361 | free_irq(IRQ_AC97, NULL); |
| 362 | pxa_set_cken(CKEN2_AC97, 0); |
| 363 | } |
| 364 | return ret; |
| 365 | } |
| 366 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 367 | static int pxa2xx_ac97_remove(struct platform_device *dev) |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 368 | { |
Takashi Iwai | d18f837 | 2005-11-17 15:10:38 +0100 | [diff] [blame] | 369 | struct snd_card *card = platform_get_drvdata(dev); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 370 | |
| 371 | if (card) { |
| 372 | snd_card_free(card); |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 373 | platform_set_drvdata(dev, NULL); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 374 | GCR |= GCR_ACLINK_OFF; |
| 375 | free_irq(IRQ_AC97, NULL); |
| 376 | pxa_set_cken(CKEN2_AC97, 0); |
| 377 | } |
| 378 | |
| 379 | return 0; |
| 380 | } |
| 381 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 382 | static struct platform_driver pxa2xx_ac97_driver = { |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 383 | .probe = pxa2xx_ac97_probe, |
| 384 | .remove = pxa2xx_ac97_remove, |
| 385 | .suspend = pxa2xx_ac97_suspend, |
| 386 | .resume = pxa2xx_ac97_resume, |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 387 | .driver = { |
| 388 | .name = "pxa2xx-ac97", |
| 389 | }, |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 390 | }; |
| 391 | |
| 392 | static int __init pxa2xx_ac97_init(void) |
| 393 | { |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 394 | return platform_driver_register(&pxa2xx_ac97_driver); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | static void __exit pxa2xx_ac97_exit(void) |
| 398 | { |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 399 | platform_driver_unregister(&pxa2xx_ac97_driver); |
Takashi Iwai | 2c484df | 2005-06-30 18:54:04 +0200 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | module_init(pxa2xx_ac97_init); |
| 403 | module_exit(pxa2xx_ac97_exit); |
| 404 | |
| 405 | MODULE_AUTHOR("Nicolas Pitre"); |
| 406 | MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip"); |
| 407 | MODULE_LICENSE("GPL"); |