aaci.c (ed03f430cdc8c802652467e9097606fedc2c7abc) aaci.c (a62c80e559809e6c7851ec04d30575e85ad6f6ed)
1/*
2 * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver
3 *
4 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Documentation: ARM DDI 0173B
11 */
12#include <linux/module.h>
13#include <linux/delay.h>
14#include <linux/init.h>
15#include <linux/ioport.h>
16#include <linux/device.h>
17#include <linux/spinlock.h>
18#include <linux/interrupt.h>
19#include <linux/err.h>
1/*
2 * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver
3 *
4 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Documentation: ARM DDI 0173B
11 */
12#include <linux/module.h>
13#include <linux/delay.h>
14#include <linux/init.h>
15#include <linux/ioport.h>
16#include <linux/device.h>
17#include <linux/spinlock.h>
18#include <linux/interrupt.h>
19#include <linux/err.h>
20#include <linux/amba/bus.h>
20
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/sizes.h>
21
22#include <asm/io.h>
23#include <asm/irq.h>
24#include <asm/sizes.h>
24#include <asm/hardware/amba.h>
25
26#include <sound/driver.h>
27#include <sound/core.h>
28#include <sound/initval.h>
29#include <sound/ac97_codec.h>
30#include <sound/pcm.h>
31#include <sound/pcm_params.h>
32
33#include "aaci.h"
34#include "devdma.h"
35
36#define DRIVER_NAME "aaci-pl041"
37
38/*
39 * PM support is not complete. Turn it off.
40 */
41#undef CONFIG_PM
42
25
26#include <sound/driver.h>
27#include <sound/core.h>
28#include <sound/initval.h>
29#include <sound/ac97_codec.h>
30#include <sound/pcm.h>
31#include <sound/pcm_params.h>
32
33#include "aaci.h"
34#include "devdma.h"
35
36#define DRIVER_NAME "aaci-pl041"
37
38/*
39 * PM support is not complete. Turn it off.
40 */
41#undef CONFIG_PM
42
43static void aaci_ac97_select_codec(struct aaci *aaci, struct snd_ac97 *ac97)
43static void aaci_ac97_select_codec(struct aaci *aaci, ac97_t *ac97)
44{
45 u32 v, maincr = aaci->maincr | MAINCR_SCRA(ac97->num);
46
47 /*
48 * Ensure that the slot 1/2 RX registers are empty.
49 */
50 v = readl(aaci->base + AACI_SLFR);
51 if (v & SLFR_2RXV)

--- 8 unchanged lines hidden (view full) ---

60 * P29:
61 * The recommended use of programming the external codec through slot 1
62 * and slot 2 data is to use the channels during setup routines and the
63 * slot register at any other time. The data written into slot 1, slot 2
64 * and slot 12 registers is transmitted only when their corresponding
65 * SI1TxEn, SI2TxEn and SI12TxEn bits are set in the AACI_MAINCR
66 * register.
67 */
44{
45 u32 v, maincr = aaci->maincr | MAINCR_SCRA(ac97->num);
46
47 /*
48 * Ensure that the slot 1/2 RX registers are empty.
49 */
50 v = readl(aaci->base + AACI_SLFR);
51 if (v & SLFR_2RXV)

--- 8 unchanged lines hidden (view full) ---

60 * P29:
61 * The recommended use of programming the external codec through slot 1
62 * and slot 2 data is to use the channels during setup routines and the
63 * slot register at any other time. The data written into slot 1, slot 2
64 * and slot 12 registers is transmitted only when their corresponding
65 * SI1TxEn, SI2TxEn and SI12TxEn bits are set in the AACI_MAINCR
66 * register.
67 */
68static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val)
68static void aaci_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
69{
70 struct aaci *aaci = ac97->private_data;
71 u32 v;
72
73 if (ac97->num >= 4)
74 return;
75
76 down(&aaci->ac97_sem);

--- 15 unchanged lines hidden (view full) ---

92 } while (v & (SLFR_1TXB|SLFR_2TXB));
93
94 up(&aaci->ac97_sem);
95}
96
97/*
98 * Read an AC'97 register.
99 */
69{
70 struct aaci *aaci = ac97->private_data;
71 u32 v;
72
73 if (ac97->num >= 4)
74 return;
75
76 down(&aaci->ac97_sem);

--- 15 unchanged lines hidden (view full) ---

92 } while (v & (SLFR_1TXB|SLFR_2TXB));
93
94 up(&aaci->ac97_sem);
95}
96
97/*
98 * Read an AC'97 register.
99 */
100static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
100static unsigned short aaci_ac97_read(ac97_t *ac97, unsigned short reg)
101{
102 struct aaci *aaci = ac97->private_data;
103 u32 v;
104
105 if (ac97->num >= 4)
106 return ~0;
107
108 down(&aaci->ac97_sem);

--- 170 unchanged lines hidden (view full) ---

279 48000, 64000, 88200, 96000, 176400, 192000
280};
281
282/*
283 * Double-rate rule: we can support double rate iff channels == 2
284 * (unimplemented)
285 */
286static int
101{
102 struct aaci *aaci = ac97->private_data;
103 u32 v;
104
105 if (ac97->num >= 4)
106 return ~0;
107
108 down(&aaci->ac97_sem);

--- 170 unchanged lines hidden (view full) ---

279 48000, 64000, 88200, 96000, 176400, 192000
280};
281
282/*
283 * Double-rate rule: we can support double rate iff channels == 2
284 * (unimplemented)
285 */
286static int
287aaci_rule_rate_by_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule)
287aaci_rule_rate_by_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule)
288{
289 struct aaci *aaci = rule->private;
290 unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512;
288{
289 struct aaci *aaci = rule->private;
290 unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512;
291 struct snd_interval *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS);
291 snd_interval_t *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS);
292
293 switch (c->max) {
294 case 6:
295 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_LFE);
296 case 4:
297 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_SURROUND);
298 case 2:
299 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_FRONT);
300 }
301
302 return snd_interval_list(hw_param_interval(p, rule->var),
303 ARRAY_SIZE(rate_list), rate_list,
304 rate_mask);
305}
306
292
293 switch (c->max) {
294 case 6:
295 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_LFE);
296 case 4:
297 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_SURROUND);
298 case 2:
299 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_FRONT);
300 }
301
302 return snd_interval_list(hw_param_interval(p, rule->var),
303 ARRAY_SIZE(rate_list), rate_list,
304 rate_mask);
305}
306
307static struct snd_pcm_hardware aaci_hw_info = {
307static snd_pcm_hardware_t aaci_hw_info = {
308 .info = SNDRV_PCM_INFO_MMAP |
309 SNDRV_PCM_INFO_MMAP_VALID |
310 SNDRV_PCM_INFO_INTERLEAVED |
311 SNDRV_PCM_INFO_BLOCK_TRANSFER |
312 SNDRV_PCM_INFO_RESUME,
313
314 /*
315 * ALSA doesn't support 18-bit or 20-bit packed into 32-bit

--- 9 unchanged lines hidden (view full) ---

325 .channels_max = 6,
326 .buffer_bytes_max = 64 * 1024,
327 .period_bytes_min = 256,
328 .period_bytes_max = PAGE_SIZE,
329 .periods_min = 4,
330 .periods_max = PAGE_SIZE / 16,
331};
332
308 .info = SNDRV_PCM_INFO_MMAP |
309 SNDRV_PCM_INFO_MMAP_VALID |
310 SNDRV_PCM_INFO_INTERLEAVED |
311 SNDRV_PCM_INFO_BLOCK_TRANSFER |
312 SNDRV_PCM_INFO_RESUME,
313
314 /*
315 * ALSA doesn't support 18-bit or 20-bit packed into 32-bit

--- 9 unchanged lines hidden (view full) ---

325 .channels_max = 6,
326 .buffer_bytes_max = 64 * 1024,
327 .period_bytes_min = 256,
328 .period_bytes_max = PAGE_SIZE,
329 .periods_min = 4,
330 .periods_max = PAGE_SIZE / 16,
331};
332
333static int aaci_pcm_open(struct aaci *aaci, struct snd_pcm_substream *substream,
333static int aaci_pcm_open(struct aaci *aaci, snd_pcm_substream_t *substream,
334 struct aaci_runtime *aacirun)
335{
334 struct aaci_runtime *aacirun)
335{
336 struct snd_pcm_runtime *runtime = substream->runtime;
336 snd_pcm_runtime_t *runtime = substream->runtime;
337 int ret;
338
339 aacirun->substream = substream;
340 runtime->private_data = aacirun;
341 runtime->hw = aaci_hw_info;
342
343 /*
344 * FIXME: ALSA specifies fifo_size in bytes. If we're in normal

--- 25 unchanged lines hidden (view full) ---

370 out:
371 return ret;
372}
373
374
375/*
376 * Common ALSA stuff
377 */
337 int ret;
338
339 aacirun->substream = substream;
340 runtime->private_data = aacirun;
341 runtime->hw = aaci_hw_info;
342
343 /*
344 * FIXME: ALSA specifies fifo_size in bytes. If we're in normal

--- 25 unchanged lines hidden (view full) ---

370 out:
371 return ret;
372}
373
374
375/*
376 * Common ALSA stuff
377 */
378static int aaci_pcm_close(struct snd_pcm_substream *substream)
378static int aaci_pcm_close(snd_pcm_substream_t *substream)
379{
380 struct aaci *aaci = substream->private_data;
381 struct aaci_runtime *aacirun = substream->runtime->private_data;
382
383 WARN_ON(aacirun->cr & TXCR_TXEN);
384
385 aacirun->substream = NULL;
386 free_irq(aaci->dev->irq[0], aaci);
387
388 return 0;
389}
390
379{
380 struct aaci *aaci = substream->private_data;
381 struct aaci_runtime *aacirun = substream->runtime->private_data;
382
383 WARN_ON(aacirun->cr & TXCR_TXEN);
384
385 aacirun->substream = NULL;
386 free_irq(aaci->dev->irq[0], aaci);
387
388 return 0;
389}
390
391static int aaci_pcm_hw_free(struct snd_pcm_substream *substream)
391static int aaci_pcm_hw_free(snd_pcm_substream_t *substream)
392{
393 struct aaci_runtime *aacirun = substream->runtime->private_data;
394
395 /*
396 * This must not be called with the device enabled.
397 */
398 WARN_ON(aacirun->cr & TXCR_TXEN);
399

--- 4 unchanged lines hidden (view full) ---

404 /*
405 * Clear out the DMA and any allocated buffers.
406 */
407 devdma_hw_free(NULL, substream);
408
409 return 0;
410}
411
392{
393 struct aaci_runtime *aacirun = substream->runtime->private_data;
394
395 /*
396 * This must not be called with the device enabled.
397 */
398 WARN_ON(aacirun->cr & TXCR_TXEN);
399

--- 4 unchanged lines hidden (view full) ---

404 /*
405 * Clear out the DMA and any allocated buffers.
406 */
407 devdma_hw_free(NULL, substream);
408
409 return 0;
410}
411
412static int aaci_pcm_hw_params(struct snd_pcm_substream *substream,
412static int aaci_pcm_hw_params(snd_pcm_substream_t *substream,
413 struct aaci_runtime *aacirun,
413 struct aaci_runtime *aacirun,
414 struct snd_pcm_hw_params *params)
414 snd_pcm_hw_params_t *params)
415{
416 int err;
417
418 aaci_pcm_hw_free(substream);
419
420 err = devdma_hw_alloc(NULL, substream,
421 params_buffer_bytes(params));
422 if (err < 0)

--- 6 unchanged lines hidden (view full) ---

429 goto out;
430
431 aacirun->pcm_open = 1;
432
433 out:
434 return err;
435}
436
415{
416 int err;
417
418 aaci_pcm_hw_free(substream);
419
420 err = devdma_hw_alloc(NULL, substream,
421 params_buffer_bytes(params));
422 if (err < 0)

--- 6 unchanged lines hidden (view full) ---

429 goto out;
430
431 aacirun->pcm_open = 1;
432
433 out:
434 return err;
435}
436
437static int aaci_pcm_prepare(struct snd_pcm_substream *substream)
437static int aaci_pcm_prepare(snd_pcm_substream_t *substream)
438{
438{
439 struct snd_pcm_runtime *runtime = substream->runtime;
439 snd_pcm_runtime_t *runtime = substream->runtime;
440 struct aaci_runtime *aacirun = runtime->private_data;
441
442 aacirun->start = (void *)runtime->dma_area;
443 aacirun->end = aacirun->start + runtime->dma_bytes;
444 aacirun->ptr = aacirun->start;
445 aacirun->period =
446 aacirun->bytes = frames_to_bytes(runtime, runtime->period_size);
447
448 return 0;
449}
450
440 struct aaci_runtime *aacirun = runtime->private_data;
441
442 aacirun->start = (void *)runtime->dma_area;
443 aacirun->end = aacirun->start + runtime->dma_bytes;
444 aacirun->ptr = aacirun->start;
445 aacirun->period =
446 aacirun->bytes = frames_to_bytes(runtime, runtime->period_size);
447
448 return 0;
449}
450
451static snd_pcm_uframes_t aaci_pcm_pointer(struct snd_pcm_substream *substream)
451static snd_pcm_uframes_t aaci_pcm_pointer(snd_pcm_substream_t *substream)
452{
452{
453 struct snd_pcm_runtime *runtime = substream->runtime;
453 snd_pcm_runtime_t *runtime = substream->runtime;
454 struct aaci_runtime *aacirun = runtime->private_data;
455 ssize_t bytes = aacirun->ptr - aacirun->start;
456
457 return bytes_to_frames(runtime, bytes);
458}
459
454 struct aaci_runtime *aacirun = runtime->private_data;
455 ssize_t bytes = aacirun->ptr - aacirun->start;
456
457 return bytes_to_frames(runtime, bytes);
458}
459
460static int aaci_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma)
460static int aaci_pcm_mmap(snd_pcm_substream_t *substream, struct vm_area_struct *vma)
461{
462 return devdma_mmap(NULL, substream, vma);
463}
464
465
466/*
467 * Playback specific ALSA stuff
468 */

--- 10 unchanged lines hidden (view full) ---

479 * 4 -> FL(3), FR(4), SL(7), SR(8)
480 * 6 -> FL(3), FR(4), SL(7), SR(8), C(6), LFE(9) (required)
481 * FL(3), FR(4), C(6), SL(7), SR(8), LFE(9) (actual)
482 * This requires an ALSA configuration file to correct.
483 */
484static unsigned int channel_list[] = { 2, 4, 6 };
485
486static int
461{
462 return devdma_mmap(NULL, substream, vma);
463}
464
465
466/*
467 * Playback specific ALSA stuff
468 */

--- 10 unchanged lines hidden (view full) ---

479 * 4 -> FL(3), FR(4), SL(7), SR(8)
480 * 6 -> FL(3), FR(4), SL(7), SR(8), C(6), LFE(9) (required)
481 * FL(3), FR(4), C(6), SL(7), SR(8), LFE(9) (actual)
482 * This requires an ALSA configuration file to correct.
483 */
484static unsigned int channel_list[] = { 2, 4, 6 };
485
486static int
487aaci_rule_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule)
487aaci_rule_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule)
488{
489 struct aaci *aaci = rule->private;
490 unsigned int chan_mask = 1 << 0, slots;
491
492 /*
493 * pcms[0] is the our 5.1 PCM instance.
494 */
495 slots = aaci->ac97_bus->pcms[0].r[0].slots;
496 if (slots & (1 << AC97_SLOT_PCM_SLEFT)) {
497 chan_mask |= 1 << 1;
498 if (slots & (1 << AC97_SLOT_LFE))
499 chan_mask |= 1 << 2;
500 }
501
502 return snd_interval_list(hw_param_interval(p, rule->var),
503 ARRAY_SIZE(channel_list), channel_list,
504 chan_mask);
505}
506
488{
489 struct aaci *aaci = rule->private;
490 unsigned int chan_mask = 1 << 0, slots;
491
492 /*
493 * pcms[0] is the our 5.1 PCM instance.
494 */
495 slots = aaci->ac97_bus->pcms[0].r[0].slots;
496 if (slots & (1 << AC97_SLOT_PCM_SLEFT)) {
497 chan_mask |= 1 << 1;
498 if (slots & (1 << AC97_SLOT_LFE))
499 chan_mask |= 1 << 2;
500 }
501
502 return snd_interval_list(hw_param_interval(p, rule->var),
503 ARRAY_SIZE(channel_list), channel_list,
504 chan_mask);
505}
506
507static int aaci_pcm_playback_open(struct snd_pcm_substream *substream)
507static int aaci_pcm_playback_open(snd_pcm_substream_t *substream)
508{
509 struct aaci *aaci = substream->private_data;
510 int ret;
511
512 /*
513 * Add rule describing channel dependency.
514 */
515 ret = snd_pcm_hw_rule_add(substream->runtime, 0,
516 SNDRV_PCM_HW_PARAM_CHANNELS,
517 aaci_rule_channels, aaci,
518 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
519 if (ret)
520 return ret;
521
522 return aaci_pcm_open(aaci, substream, &aaci->playback);
523}
524
508{
509 struct aaci *aaci = substream->private_data;
510 int ret;
511
512 /*
513 * Add rule describing channel dependency.
514 */
515 ret = snd_pcm_hw_rule_add(substream->runtime, 0,
516 SNDRV_PCM_HW_PARAM_CHANNELS,
517 aaci_rule_channels, aaci,
518 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
519 if (ret)
520 return ret;
521
522 return aaci_pcm_open(aaci, substream, &aaci->playback);
523}
524
525static int aaci_pcm_playback_hw_params(struct snd_pcm_substream *substream,
526 struct snd_pcm_hw_params *params)
525static int aaci_pcm_playback_hw_params(snd_pcm_substream_t *substream,
526 snd_pcm_hw_params_t *params)
527{
528 struct aaci *aaci = substream->private_data;
529 struct aaci_runtime *aacirun = substream->runtime->private_data;
530 unsigned int channels = params_channels(params);
531 int ret;
532
533 WARN_ON(channels >= ARRAY_SIZE(channels_to_txmask) ||
534 !channels_to_txmask[channels]);

--- 35 unchanged lines hidden (view full) ---

570 aacirun->cr |= TXCR_TXEN;
571
572 ie = readl(aacirun->base + AACI_IE);
573 ie |= IE_URIE | IE_TXIE;
574 writel(ie, aacirun->base + AACI_IE);
575 writel(aacirun->cr, aacirun->base + AACI_TXCR);
576}
577
527{
528 struct aaci *aaci = substream->private_data;
529 struct aaci_runtime *aacirun = substream->runtime->private_data;
530 unsigned int channels = params_channels(params);
531 int ret;
532
533 WARN_ON(channels >= ARRAY_SIZE(channels_to_txmask) ||
534 !channels_to_txmask[channels]);

--- 35 unchanged lines hidden (view full) ---

570 aacirun->cr |= TXCR_TXEN;
571
572 ie = readl(aacirun->base + AACI_IE);
573 ie |= IE_URIE | IE_TXIE;
574 writel(ie, aacirun->base + AACI_IE);
575 writel(aacirun->cr, aacirun->base + AACI_TXCR);
576}
577
578static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd)
578static int aaci_pcm_playback_trigger(snd_pcm_substream_t *substream, int cmd)
579{
580 struct aaci *aaci = substream->private_data;
581 struct aaci_runtime *aacirun = substream->runtime->private_data;
582 unsigned long flags;
583 int ret = 0;
584
585 spin_lock_irqsave(&aaci->lock, flags);
586 switch (cmd) {

--- 22 unchanged lines hidden (view full) ---

609 default:
610 ret = -EINVAL;
611 }
612 spin_unlock_irqrestore(&aaci->lock, flags);
613
614 return ret;
615}
616
579{
580 struct aaci *aaci = substream->private_data;
581 struct aaci_runtime *aacirun = substream->runtime->private_data;
582 unsigned long flags;
583 int ret = 0;
584
585 spin_lock_irqsave(&aaci->lock, flags);
586 switch (cmd) {

--- 22 unchanged lines hidden (view full) ---

609 default:
610 ret = -EINVAL;
611 }
612 spin_unlock_irqrestore(&aaci->lock, flags);
613
614 return ret;
615}
616
617static struct snd_pcm_ops aaci_playback_ops = {
617static snd_pcm_ops_t aaci_playback_ops = {
618 .open = aaci_pcm_playback_open,
619 .close = aaci_pcm_close,
620 .ioctl = snd_pcm_lib_ioctl,
621 .hw_params = aaci_pcm_playback_hw_params,
622 .hw_free = aaci_pcm_hw_free,
623 .prepare = aaci_pcm_prepare,
624 .trigger = aaci_pcm_playback_trigger,
625 .pointer = aaci_pcm_pointer,
626 .mmap = aaci_pcm_mmap,
627};
628
629
630
631/*
632 * Power Management.
633 */
634#ifdef CONFIG_PM
618 .open = aaci_pcm_playback_open,
619 .close = aaci_pcm_close,
620 .ioctl = snd_pcm_lib_ioctl,
621 .hw_params = aaci_pcm_playback_hw_params,
622 .hw_free = aaci_pcm_hw_free,
623 .prepare = aaci_pcm_prepare,
624 .trigger = aaci_pcm_playback_trigger,
625 .pointer = aaci_pcm_pointer,
626 .mmap = aaci_pcm_mmap,
627};
628
629
630
631/*
632 * Power Management.
633 */
634#ifdef CONFIG_PM
635static int aaci_do_suspend(struct snd_card *card, unsigned int state)
635static int aaci_do_suspend(snd_card_t *card, unsigned int state)
636{
637 struct aaci *aaci = card->private_data;
636{
637 struct aaci *aaci = card->private_data;
638 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold);
639 snd_pcm_suspend_all(aaci->pcm);
638 if (aaci->card->power_state != SNDRV_CTL_POWER_D3cold) {
639 snd_pcm_suspend_all(aaci->pcm);
640 snd_power_change_state(aaci->card, SNDRV_CTL_POWER_D3cold);
641 }
640 return 0;
641}
642
642 return 0;
643}
644
643static int aaci_do_resume(struct snd_card *card, unsigned int state)
645static int aaci_do_resume(snd_card_t *card, unsigned int state)
644{
646{
645 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
647 struct aaci *aaci = card->private_data;
648 if (aaci->card->power_state != SNDRV_CTL_POWER_D0) {
649 snd_power_change_state(aaci->card, SNDRV_CTL_POWER_D0);
650 }
646 return 0;
647}
648
649static int aaci_suspend(struct amba_device *dev, pm_message_t state)
650{
651 return 0;
652}
653
654static int aaci_suspend(struct amba_device *dev, pm_message_t state)
655{
651 struct snd_card *card = amba_get_drvdata(dev);
656 snd_card_t *card = amba_get_drvdata(dev);
652 return card ? aaci_do_suspend(card) : 0;
653}
654
655static int aaci_resume(struct amba_device *dev)
656{
657 return card ? aaci_do_suspend(card) : 0;
658}
659
660static int aaci_resume(struct amba_device *dev)
661{
657 struct snd_card *card = amba_get_drvdata(dev);
662 snd_card_t *card = amba_get_drvdata(dev);
658 return card ? aaci_do_resume(card) : 0;
659}
660#else
661#define aaci_do_suspend NULL
662#define aaci_do_resume NULL
663#define aaci_suspend NULL
664#define aaci_resume NULL
665#endif

--- 29 unchanged lines hidden (view full) ---

695 .r = {
696 [0] = {
697 .slots = (1 << AC97_SLOT_MIC),
698 },
699 },
700 }
701};
702
663 return card ? aaci_do_resume(card) : 0;
664}
665#else
666#define aaci_do_suspend NULL
667#define aaci_do_resume NULL
668#define aaci_suspend NULL
669#define aaci_resume NULL
670#endif

--- 29 unchanged lines hidden (view full) ---

700 .r = {
701 [0] = {
702 .slots = (1 << AC97_SLOT_MIC),
703 },
704 },
705 }
706};
707
703static struct snd_ac97_bus_ops aaci_bus_ops = {
708static ac97_bus_ops_t aaci_bus_ops = {
704 .write = aaci_ac97_write,
705 .read = aaci_ac97_read,
706};
707
708static int __devinit aaci_probe_ac97(struct aaci *aaci)
709{
709 .write = aaci_ac97_write,
710 .read = aaci_ac97_read,
711};
712
713static int __devinit aaci_probe_ac97(struct aaci *aaci)
714{
710 struct snd_ac97_template ac97_template;
711 struct snd_ac97_bus *ac97_bus;
712 struct snd_ac97 *ac97;
715 ac97_template_t ac97_template;
716 ac97_bus_t *ac97_bus;
717 ac97_t *ac97;
713 int ret;
714
715 /*
716 * Assert AACIRESET for 2us
717 */
718 writel(0, aaci->base + AACI_RESET);
719 udelay(2);
720 writel(RESET_NRST, aaci->base + AACI_RESET);

--- 6 unchanged lines hidden (view full) ---

727
728 ret = snd_ac97_bus(aaci->card, 0, &aaci_bus_ops, aaci, &ac97_bus);
729 if (ret)
730 goto out;
731
732 ac97_bus->clock = 48000;
733 aaci->ac97_bus = ac97_bus;
734
718 int ret;
719
720 /*
721 * Assert AACIRESET for 2us
722 */
723 writel(0, aaci->base + AACI_RESET);
724 udelay(2);
725 writel(RESET_NRST, aaci->base + AACI_RESET);

--- 6 unchanged lines hidden (view full) ---

732
733 ret = snd_ac97_bus(aaci->card, 0, &aaci_bus_ops, aaci, &ac97_bus);
734 if (ret)
735 goto out;
736
737 ac97_bus->clock = 48000;
738 aaci->ac97_bus = ac97_bus;
739
735 memset(&ac97_template, 0, sizeof(struct snd_ac97_template));
740 memset(&ac97_template, 0, sizeof(ac97_template_t));
736 ac97_template.private_data = aaci;
737 ac97_template.num = 0;
738 ac97_template.scaps = AC97_SCAP_SKIP_MODEM;
739
740 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &ac97);
741 if (ret)
742 goto out;
743

--- 8 unchanged lines hidden (view full) ---

752 goto out;
753
754 aaci->playback.pcm = &ac97_bus->pcms[0];
755
756 out:
757 return ret;
758}
759
741 ac97_template.private_data = aaci;
742 ac97_template.num = 0;
743 ac97_template.scaps = AC97_SCAP_SKIP_MODEM;
744
745 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &ac97);
746 if (ret)
747 goto out;
748

--- 8 unchanged lines hidden (view full) ---

757 goto out;
758
759 aaci->playback.pcm = &ac97_bus->pcms[0];
760
761 out:
762 return ret;
763}
764
760static void aaci_free_card(struct snd_card *card)
765static void aaci_free_card(snd_card_t *card)
761{
762 struct aaci *aaci = card->private_data;
763 if (aaci->base)
764 iounmap(aaci->base);
765}
766
767static struct aaci * __devinit aaci_init_card(struct amba_device *dev)
768{
769 struct aaci *aaci;
766{
767 struct aaci *aaci = card->private_data;
768 if (aaci->base)
769 iounmap(aaci->base);
770}
771
772static struct aaci * __devinit aaci_init_card(struct amba_device *dev)
773{
774 struct aaci *aaci;
770 struct snd_card *card;
775 snd_card_t *card;
771
772 card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
773 THIS_MODULE, sizeof(struct aaci));
774 if (card == NULL)
775 return ERR_PTR(-ENOMEM);
776
777 card->private_free = aaci_free_card;
776
777 card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
778 THIS_MODULE, sizeof(struct aaci));
779 if (card == NULL)
780 return ERR_PTR(-ENOMEM);
781
782 card->private_free = aaci_free_card;
783 snd_card_set_pm_callback(card, aaci_do_suspend, aaci_do_resume, NULL);
778
779 strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver));
780 strlcpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname));
781 snprintf(card->longname, sizeof(card->longname),
782 "%s at 0x%08lx, irq %d",
783 card->shortname, dev->res.start, dev->irq[0]);
784
785 aaci = card->private_data;

--- 6 unchanged lines hidden (view full) ---

792 aaci->maincr = MAINCR_IE | MAINCR_SL1RXEN | MAINCR_SL1TXEN |
793 MAINCR_SL2RXEN | MAINCR_SL2TXEN;
794
795 return aaci;
796}
797
798static int __devinit aaci_init_pcm(struct aaci *aaci)
799{
784
785 strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver));
786 strlcpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname));
787 snprintf(card->longname, sizeof(card->longname),
788 "%s at 0x%08lx, irq %d",
789 card->shortname, dev->res.start, dev->irq[0]);
790
791 aaci = card->private_data;

--- 6 unchanged lines hidden (view full) ---

798 aaci->maincr = MAINCR_IE | MAINCR_SL1RXEN | MAINCR_SL1TXEN |
799 MAINCR_SL2RXEN | MAINCR_SL2TXEN;
800
801 return aaci;
802}
803
804static int __devinit aaci_init_pcm(struct aaci *aaci)
805{
800 struct snd_pcm *pcm;
806 snd_pcm_t *pcm;
801 int ret;
802
803 ret = snd_pcm_new(aaci->card, "AACI AC'97", 0, 1, 0, &pcm);
804 if (ret == 0) {
805 aaci->pcm = pcm;
806 pcm->private_data = aaci;
807 pcm->info_flags = 0;
808

--- 100 unchanged lines hidden (view full) ---

909 if (aaci)
910 snd_card_free(aaci->card);
911 amba_release_regions(dev);
912 return ret;
913}
914
915static int __devexit aaci_remove(struct amba_device *dev)
916{
807 int ret;
808
809 ret = snd_pcm_new(aaci->card, "AACI AC'97", 0, 1, 0, &pcm);
810 if (ret == 0) {
811 aaci->pcm = pcm;
812 pcm->private_data = aaci;
813 pcm->info_flags = 0;
814

--- 100 unchanged lines hidden (view full) ---

915 if (aaci)
916 snd_card_free(aaci->card);
917 amba_release_regions(dev);
918 return ret;
919}
920
921static int __devexit aaci_remove(struct amba_device *dev)
922{
917 struct snd_card *card = amba_get_drvdata(dev);
923 snd_card_t *card = amba_get_drvdata(dev);
918
919 amba_set_drvdata(dev, NULL);
920
921 if (card) {
922 struct aaci *aaci = card->private_data;
923 writel(0, aaci->base + AACI_MAINCR);
924
925 snd_card_free(card);

--- 40 unchanged lines hidden ---
924
925 amba_set_drvdata(dev, NULL);
926
927 if (card) {
928 struct aaci *aaci = card->private_data;
929 writel(0, aaci->base + AACI_MAINCR);
930
931 snd_card_free(card);

--- 40 unchanged lines hidden ---