2005-06-30 16:54:04 +00:00
|
|
|
/*
|
|
|
|
* linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip.
|
|
|
|
*
|
|
|
|
* Author: Nicolas Pitre
|
|
|
|
* Created: Dec 02, 2004
|
|
|
|
* Copyright: MontaVista Software Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
2005-10-29 18:07:23 +00:00
|
|
|
#include <linux/platform_device.h>
|
2005-06-30 16:54:04 +00:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
|
|
|
#include <sound/driver.h>
|
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/ac97_codec.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
|
|
|
|
#include <asm/irq.h>
|
2006-01-16 15:36:05 +00:00
|
|
|
#include <linux/mutex.h>
|
2005-06-30 16:54:04 +00:00
|
|
|
#include <asm/hardware.h>
|
|
|
|
#include <asm/arch/pxa-regs.h>
|
|
|
|
#include <asm/arch/audio.h>
|
|
|
|
|
|
|
|
#include "pxa2xx-pcm.h"
|
|
|
|
|
|
|
|
|
2006-01-16 15:36:05 +00:00
|
|
|
static DEFINE_MUTEX(car_mutex);
|
2005-06-30 16:54:04 +00:00
|
|
|
static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
|
|
|
|
static volatile long gsr_bits;
|
|
|
|
|
2005-12-12 14:41:47 +00:00
|
|
|
/*
|
|
|
|
* Beware PXA27x bugs:
|
|
|
|
*
|
|
|
|
* o Slot 12 read from modem space will hang controller.
|
|
|
|
* o CDONE, SDONE interrupt fails after any slot 12 IO.
|
|
|
|
*
|
|
|
|
* We therefore have an hybrid approach for waiting on SDONE (interrupt or
|
|
|
|
* 1 jiffy timeout if interrupt never comes).
|
|
|
|
*/
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
|
|
|
unsigned short val = -1;
|
|
|
|
volatile u32 *reg_addr;
|
|
|
|
|
2006-01-16 15:36:05 +00:00
|
|
|
mutex_lock(&car_mutex);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
/* set up primary or secondary codec space */
|
|
|
|
reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE;
|
|
|
|
reg_addr += (reg >> 1);
|
|
|
|
|
|
|
|
/* start read access across the ac97 link */
|
2005-12-12 14:41:47 +00:00
|
|
|
GSR = GSR_CDONE | GSR_SDONE;
|
2005-06-30 16:54:04 +00:00
|
|
|
gsr_bits = 0;
|
|
|
|
val = *reg_addr;
|
|
|
|
if (reg == AC97_GPIO_STATUS)
|
|
|
|
goto out;
|
2005-12-12 14:41:47 +00:00
|
|
|
if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 &&
|
|
|
|
!((GSR | gsr_bits) & GSR_SDONE)) {
|
2005-06-30 16:54:04 +00:00
|
|
|
printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",
|
2005-12-12 14:41:47 +00:00
|
|
|
__FUNCTION__, reg, GSR | gsr_bits);
|
2005-06-30 16:54:04 +00:00
|
|
|
val = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* valid data now */
|
2005-12-12 14:41:47 +00:00
|
|
|
GSR = GSR_CDONE | GSR_SDONE;
|
2005-06-30 16:54:04 +00:00
|
|
|
gsr_bits = 0;
|
|
|
|
val = *reg_addr;
|
|
|
|
/* but we've just started another cycle... */
|
2005-12-12 14:41:47 +00:00
|
|
|
wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
2006-01-16 15:36:05 +00:00
|
|
|
out: mutex_unlock(&car_mutex);
|
2005-06-30 16:54:04 +00:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
|
|
|
volatile u32 *reg_addr;
|
|
|
|
|
2006-01-16 15:36:05 +00:00
|
|
|
mutex_lock(&car_mutex);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
/* set up primary or secondary codec space */
|
|
|
|
reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE;
|
|
|
|
reg_addr += (reg >> 1);
|
2005-12-12 14:41:47 +00:00
|
|
|
|
|
|
|
GSR = GSR_CDONE | GSR_SDONE;
|
2005-06-30 16:54:04 +00:00
|
|
|
gsr_bits = 0;
|
|
|
|
*reg_addr = val;
|
2005-12-12 14:41:47 +00:00
|
|
|
if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1) <= 0 &&
|
|
|
|
!((GSR | gsr_bits) & GSR_CDONE))
|
2005-06-30 16:54:04 +00:00
|
|
|
printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n",
|
2005-12-12 14:41:47 +00:00
|
|
|
__FUNCTION__, reg, GSR | gsr_bits);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
2006-01-16 15:36:05 +00:00
|
|
|
mutex_unlock(&car_mutex);
|
2005-06-30 16:54:04 +00:00
|
|
|
}
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
|
|
|
/* First, try cold reset */
|
|
|
|
GCR &= GCR_COLD_RST; /* clear everything but nCRST */
|
|
|
|
GCR &= ~GCR_COLD_RST; /* then assert nCRST */
|
|
|
|
|
|
|
|
gsr_bits = 0;
|
|
|
|
#ifdef CONFIG_PXA27x
|
|
|
|
/* PXA27x Developers Manual section 13.5.2.2.1 */
|
|
|
|
pxa_set_cken(1 << 31, 1);
|
|
|
|
udelay(5);
|
|
|
|
pxa_set_cken(1 << 31, 0);
|
|
|
|
GCR = GCR_COLD_RST;
|
|
|
|
udelay(50);
|
|
|
|
#else
|
|
|
|
GCR = GCR_COLD_RST;
|
|
|
|
GCR |= GCR_CDONE_IE|GCR_SDONE_IE;
|
|
|
|
wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) {
|
|
|
|
printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
|
|
|
|
__FUNCTION__, gsr_bits);
|
|
|
|
|
|
|
|
/* let's try warm reset */
|
|
|
|
gsr_bits = 0;
|
|
|
|
#ifdef CONFIG_PXA27x
|
|
|
|
/* warm reset broken on Bulverde,
|
|
|
|
so manually keep AC97 reset high */
|
|
|
|
pxa_gpio_mode(113 | GPIO_OUT | GPIO_DFLT_HIGH);
|
|
|
|
udelay(10);
|
|
|
|
GCR |= GCR_WARM_RST;
|
|
|
|
pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
|
2005-08-05 08:24:36 +00:00
|
|
|
udelay(500);
|
2005-06-30 16:54:04 +00:00
|
|
|
#else
|
2005-08-05 08:24:36 +00:00
|
|
|
GCR |= GCR_WARM_RST|GCR_PRIRDY_IEN|GCR_SECRDY_IEN;
|
2005-06-30 16:54:04 +00:00
|
|
|
wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
|
|
|
|
printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
|
|
|
|
__FUNCTION__, gsr_bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
|
|
|
|
GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
|
|
|
long status;
|
|
|
|
|
|
|
|
status = GSR;
|
|
|
|
if (status) {
|
|
|
|
GSR = status;
|
|
|
|
gsr_bits |= status;
|
|
|
|
wake_up(&gsr_wq);
|
|
|
|
|
|
|
|
#ifdef CONFIG_PXA27x
|
|
|
|
/* Although we don't use those we still need to clear them
|
|
|
|
since they tend to spuriously trigger when MMC is used
|
|
|
|
(hardware bug? go figure)... */
|
|
|
|
MISR = MISR_EOC;
|
|
|
|
PISR = PISR_EOC;
|
|
|
|
MCSR = MCSR_EOC;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
|
2005-06-30 16:54:04 +00:00
|
|
|
.read = pxa2xx_ac97_read,
|
|
|
|
.write = pxa2xx_ac97_write,
|
|
|
|
.reset = pxa2xx_ac97_reset,
|
|
|
|
};
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_out = {
|
2005-06-30 16:54:04 +00:00
|
|
|
.name = "AC97 PCM out",
|
|
|
|
.dev_addr = __PREG(PCDR),
|
|
|
|
.drcmr = &DRCMRTXPCDR,
|
|
|
|
.dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG |
|
|
|
|
DCMD_BURST32 | DCMD_WIDTH4,
|
|
|
|
};
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_in = {
|
2005-06-30 16:54:04 +00:00
|
|
|
.name = "AC97 PCM in",
|
|
|
|
.dev_addr = __PREG(PCDR),
|
|
|
|
.drcmr = &DRCMRRXPCDR,
|
|
|
|
.dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC |
|
|
|
|
DCMD_BURST32 | DCMD_WIDTH4,
|
|
|
|
};
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static struct snd_pcm *pxa2xx_ac97_pcm;
|
|
|
|
static struct snd_ac97 *pxa2xx_ac97_ac97;
|
2005-06-30 16:54:04 +00:00
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static int pxa2xx_ac97_pcm_startup(struct snd_pcm_substream *substream)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
2005-11-17 14:10:38 +00:00
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2005-06-30 16:54:04 +00:00
|
|
|
pxa2xx_audio_ops_t *platform_ops;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
runtime->hw.channels_min = 2;
|
|
|
|
runtime->hw.channels_max = 2;
|
|
|
|
|
|
|
|
r = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
|
|
|
|
AC97_RATES_FRONT_DAC : AC97_RATES_ADC;
|
|
|
|
runtime->hw.rates = pxa2xx_ac97_ac97->rates[r];
|
|
|
|
snd_pcm_limit_hw_rates(runtime);
|
|
|
|
|
|
|
|
platform_ops = substream->pcm->card->dev->platform_data;
|
|
|
|
if (platform_ops && platform_ops->startup)
|
|
|
|
return platform_ops->startup(substream, platform_ops->priv);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static void pxa2xx_ac97_pcm_shutdown(struct snd_pcm_substream *substream)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
|
|
|
pxa2xx_audio_ops_t *platform_ops;
|
|
|
|
|
|
|
|
platform_ops = substream->pcm->card->dev->platform_data;
|
|
|
|
if (platform_ops && platform_ops->shutdown)
|
|
|
|
platform_ops->shutdown(substream, platform_ops->priv);
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static int pxa2xx_ac97_pcm_prepare(struct snd_pcm_substream *substream)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
2005-11-17 14:10:38 +00:00
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2005-06-30 16:54:04 +00:00
|
|
|
int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
|
|
|
|
AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
|
|
|
|
return snd_ac97_set_rate(pxa2xx_ac97_ac97, reg, runtime->rate);
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static struct pxa2xx_pcm_client pxa2xx_ac97_pcm_client = {
|
2005-06-30 16:54:04 +00:00
|
|
|
.playback_params = &pxa2xx_ac97_pcm_out,
|
|
|
|
.capture_params = &pxa2xx_ac97_pcm_in,
|
|
|
|
.startup = pxa2xx_ac97_pcm_startup,
|
|
|
|
.shutdown = pxa2xx_ac97_pcm_shutdown,
|
|
|
|
.prepare = pxa2xx_ac97_pcm_prepare,
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static int pxa2xx_ac97_do_suspend(struct snd_card *card, pm_message_t state)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
2005-11-17 16:19:25 +00:00
|
|
|
pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data;
|
|
|
|
|
|
|
|
snd_power_change_state(card, SNDRV_CTL_POWER_D3cold);
|
|
|
|
snd_pcm_suspend_all(pxa2xx_ac97_pcm);
|
|
|
|
snd_ac97_suspend(pxa2xx_ac97_ac97);
|
|
|
|
if (platform_ops && platform_ops->suspend)
|
|
|
|
platform_ops->suspend(platform_ops->priv);
|
|
|
|
GCR |= GCR_ACLINK_OFF;
|
[ARM] 4304/1: removes the unnecessary bit number from CKENnn_XXXX
This patch removes the unnecessary bit number from CKENnn_XXXX
definitions for PXA, so that
CKEN0_PWM0 --> CKEN_PWM0
CKEN1_PWM1 --> CKEN_PWM1
...
CKEN24_CAMERA --> CKEN_CAMERA
The reasons for the change of these defitions are:
1. they do not scale - they are currently valid for pxa2xx, but
definitely not valid for pxa3xx, e.g., pxa3xx has bit 3 for camera
instead of bit 24
2. they are unnecessary - the peripheral name within the definition
has already announced its usage, we don't need those bit numbers
to know which peripheral we are going to enable/disable clock for
3. they are inconvenient - think about this: a driver programmer
for pxa has to remember which bit in the CKEN register to turn
on/off
Another change in the patch is to make the definitions equal to its
clock bit index, so that
#define CKEN_CAMERA (24)
instead of
#define CKEN_CAMERA (1 << 24)
this change, however, will add a run-time bit shift operation in
pxa_set_cken(), but the benefit of this change is that it scales
when bit index exceeds 32, e.g., pxa3xx has two registers CKENA
and CKENB, totally 64 bit for this, suppose CAMERA clock enabling
bit is CKENB:10, one can simply define CKEN_CAMERA to be (32 + 10)
and so that pxa_set_cken() need minimum change to adapt to that.
Signed-off-by: eric miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2007-04-05 03:07:20 +00:00
|
|
|
pxa_set_cken(CKEN_AC97, 0);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:10:38 +00:00
|
|
|
static int pxa2xx_ac97_do_resume(struct snd_card *card)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
2005-11-17 16:19:25 +00:00
|
|
|
pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data;
|
|
|
|
|
[ARM] 4304/1: removes the unnecessary bit number from CKENnn_XXXX
This patch removes the unnecessary bit number from CKENnn_XXXX
definitions for PXA, so that
CKEN0_PWM0 --> CKEN_PWM0
CKEN1_PWM1 --> CKEN_PWM1
...
CKEN24_CAMERA --> CKEN_CAMERA
The reasons for the change of these defitions are:
1. they do not scale - they are currently valid for pxa2xx, but
definitely not valid for pxa3xx, e.g., pxa3xx has bit 3 for camera
instead of bit 24
2. they are unnecessary - the peripheral name within the definition
has already announced its usage, we don't need those bit numbers
to know which peripheral we are going to enable/disable clock for
3. they are inconvenient - think about this: a driver programmer
for pxa has to remember which bit in the CKEN register to turn
on/off
Another change in the patch is to make the definitions equal to its
clock bit index, so that
#define CKEN_CAMERA (24)
instead of
#define CKEN_CAMERA (1 << 24)
this change, however, will add a run-time bit shift operation in
pxa_set_cken(), but the benefit of this change is that it scales
when bit index exceeds 32, e.g., pxa3xx has two registers CKENA
and CKENB, totally 64 bit for this, suppose CAMERA clock enabling
bit is CKENB:10, one can simply define CKEN_CAMERA to be (32 + 10)
and so that pxa_set_cken() need minimum change to adapt to that.
Signed-off-by: eric miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2007-04-05 03:07:20 +00:00
|
|
|
pxa_set_cken(CKEN_AC97, 1);
|
2005-11-17 16:19:25 +00:00
|
|
|
if (platform_ops && platform_ops->resume)
|
|
|
|
platform_ops->resume(platform_ops->priv);
|
|
|
|
snd_ac97_resume(pxa2xx_ac97_ac97);
|
|
|
|
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-09 22:32:44 +00:00
|
|
|
static int pxa2xx_ac97_suspend(struct platform_device *dev, pm_message_t state)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
2005-11-17 14:10:38 +00:00
|
|
|
struct snd_card *card = platform_get_drvdata(dev);
|
2005-06-30 16:54:04 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2005-10-28 16:52:56 +00:00
|
|
|
if (card)
|
2005-08-08 14:29:43 +00:00
|
|
|
ret = pxa2xx_ac97_do_suspend(card, PMSG_SUSPEND);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-09 22:32:44 +00:00
|
|
|
static int pxa2xx_ac97_resume(struct platform_device *dev)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
2005-11-17 14:10:38 +00:00
|
|
|
struct snd_card *card = platform_get_drvdata(dev);
|
2005-06-30 16:54:04 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2005-10-28 16:52:56 +00:00
|
|
|
if (card)
|
2005-08-08 14:29:43 +00:00
|
|
|
ret = pxa2xx_ac97_do_resume(card);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define pxa2xx_ac97_suspend NULL
|
|
|
|
#define pxa2xx_ac97_resume NULL
|
|
|
|
#endif
|
|
|
|
|
2007-02-13 12:11:11 +00:00
|
|
|
static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
2005-11-17 14:10:38 +00:00
|
|
|
struct snd_card *card;
|
|
|
|
struct snd_ac97_bus *ac97_bus;
|
|
|
|
struct snd_ac97_template ac97_template;
|
2005-06-30 16:54:04 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = -ENOMEM;
|
|
|
|
card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
|
|
|
|
THIS_MODULE, 0);
|
|
|
|
if (!card)
|
|
|
|
goto err;
|
|
|
|
|
2005-11-09 22:32:44 +00:00
|
|
|
card->dev = &dev->dev;
|
|
|
|
strncpy(card->driver, dev->dev.driver->name, sizeof(card->driver));
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
ret = request_irq(IRQ_AC97, pxa2xx_ac97_irq, 0, "AC97", NULL);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
|
|
|
|
pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
|
|
|
|
pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);
|
|
|
|
pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD);
|
|
|
|
#ifdef CONFIG_PXA27x
|
|
|
|
/* Use GPIO 113 as AC97 Reset on Bulverde */
|
|
|
|
pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
|
|
|
|
#endif
|
[ARM] 4304/1: removes the unnecessary bit number from CKENnn_XXXX
This patch removes the unnecessary bit number from CKENnn_XXXX
definitions for PXA, so that
CKEN0_PWM0 --> CKEN_PWM0
CKEN1_PWM1 --> CKEN_PWM1
...
CKEN24_CAMERA --> CKEN_CAMERA
The reasons for the change of these defitions are:
1. they do not scale - they are currently valid for pxa2xx, but
definitely not valid for pxa3xx, e.g., pxa3xx has bit 3 for camera
instead of bit 24
2. they are unnecessary - the peripheral name within the definition
has already announced its usage, we don't need those bit numbers
to know which peripheral we are going to enable/disable clock for
3. they are inconvenient - think about this: a driver programmer
for pxa has to remember which bit in the CKEN register to turn
on/off
Another change in the patch is to make the definitions equal to its
clock bit index, so that
#define CKEN_CAMERA (24)
instead of
#define CKEN_CAMERA (1 << 24)
this change, however, will add a run-time bit shift operation in
pxa_set_cken(), but the benefit of this change is that it scales
when bit index exceeds 32, e.g., pxa3xx has two registers CKENA
and CKENB, totally 64 bit for this, suppose CAMERA clock enabling
bit is CKENB:10, one can simply define CKEN_CAMERA to be (32 + 10)
and so that pxa_set_cken() need minimum change to adapt to that.
Signed-off-by: eric miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2007-04-05 03:07:20 +00:00
|
|
|
pxa_set_cken(CKEN_AC97, 1);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
ret = snd_ac97_bus(card, 0, &pxa2xx_ac97_ops, NULL, &ac97_bus);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
memset(&ac97_template, 0, sizeof(ac97_template));
|
|
|
|
ret = snd_ac97_mixer(ac97_bus, &ac97_template, &pxa2xx_ac97_ac97);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
snprintf(card->shortname, sizeof(card->shortname),
|
|
|
|
"%s", snd_ac97_get_short_name(pxa2xx_ac97_ac97));
|
|
|
|
snprintf(card->longname, sizeof(card->longname),
|
2005-11-09 22:32:44 +00:00
|
|
|
"%s (%s)", dev->dev.driver->name, card->mixername);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
ret = snd_card_register(card);
|
|
|
|
if (ret == 0) {
|
2005-11-09 22:32:44 +00:00
|
|
|
platform_set_drvdata(dev, card);
|
2005-06-30 16:54:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
err:
|
|
|
|
if (card)
|
|
|
|
snd_card_free(card);
|
2007-07-02 09:19:07 +00:00
|
|
|
if (CKEN & (1 << CKEN_AC97)) {
|
2005-06-30 16:54:04 +00:00
|
|
|
GCR |= GCR_ACLINK_OFF;
|
|
|
|
free_irq(IRQ_AC97, NULL);
|
[ARM] 4304/1: removes the unnecessary bit number from CKENnn_XXXX
This patch removes the unnecessary bit number from CKENnn_XXXX
definitions for PXA, so that
CKEN0_PWM0 --> CKEN_PWM0
CKEN1_PWM1 --> CKEN_PWM1
...
CKEN24_CAMERA --> CKEN_CAMERA
The reasons for the change of these defitions are:
1. they do not scale - they are currently valid for pxa2xx, but
definitely not valid for pxa3xx, e.g., pxa3xx has bit 3 for camera
instead of bit 24
2. they are unnecessary - the peripheral name within the definition
has already announced its usage, we don't need those bit numbers
to know which peripheral we are going to enable/disable clock for
3. they are inconvenient - think about this: a driver programmer
for pxa has to remember which bit in the CKEN register to turn
on/off
Another change in the patch is to make the definitions equal to its
clock bit index, so that
#define CKEN_CAMERA (24)
instead of
#define CKEN_CAMERA (1 << 24)
this change, however, will add a run-time bit shift operation in
pxa_set_cken(), but the benefit of this change is that it scales
when bit index exceeds 32, e.g., pxa3xx has two registers CKENA
and CKENB, totally 64 bit for this, suppose CAMERA clock enabling
bit is CKENB:10, one can simply define CKEN_CAMERA to be (32 + 10)
and so that pxa_set_cken() need minimum change to adapt to that.
Signed-off-by: eric miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2007-04-05 03:07:20 +00:00
|
|
|
pxa_set_cken(CKEN_AC97, 0);
|
2005-06-30 16:54:04 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-02-13 12:11:11 +00:00
|
|
|
static int __devexit pxa2xx_ac97_remove(struct platform_device *dev)
|
2005-06-30 16:54:04 +00:00
|
|
|
{
|
2005-11-17 14:10:38 +00:00
|
|
|
struct snd_card *card = platform_get_drvdata(dev);
|
2005-06-30 16:54:04 +00:00
|
|
|
|
|
|
|
if (card) {
|
|
|
|
snd_card_free(card);
|
2005-11-09 22:32:44 +00:00
|
|
|
platform_set_drvdata(dev, NULL);
|
2005-06-30 16:54:04 +00:00
|
|
|
GCR |= GCR_ACLINK_OFF;
|
|
|
|
free_irq(IRQ_AC97, NULL);
|
[ARM] 4304/1: removes the unnecessary bit number from CKENnn_XXXX
This patch removes the unnecessary bit number from CKENnn_XXXX
definitions for PXA, so that
CKEN0_PWM0 --> CKEN_PWM0
CKEN1_PWM1 --> CKEN_PWM1
...
CKEN24_CAMERA --> CKEN_CAMERA
The reasons for the change of these defitions are:
1. they do not scale - they are currently valid for pxa2xx, but
definitely not valid for pxa3xx, e.g., pxa3xx has bit 3 for camera
instead of bit 24
2. they are unnecessary - the peripheral name within the definition
has already announced its usage, we don't need those bit numbers
to know which peripheral we are going to enable/disable clock for
3. they are inconvenient - think about this: a driver programmer
for pxa has to remember which bit in the CKEN register to turn
on/off
Another change in the patch is to make the definitions equal to its
clock bit index, so that
#define CKEN_CAMERA (24)
instead of
#define CKEN_CAMERA (1 << 24)
this change, however, will add a run-time bit shift operation in
pxa_set_cken(), but the benefit of this change is that it scales
when bit index exceeds 32, e.g., pxa3xx has two registers CKENA
and CKENB, totally 64 bit for this, suppose CAMERA clock enabling
bit is CKENB:10, one can simply define CKEN_CAMERA to be (32 + 10)
and so that pxa_set_cken() need minimum change to adapt to that.
Signed-off-by: eric miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2007-04-05 03:07:20 +00:00
|
|
|
pxa_set_cken(CKEN_AC97, 0);
|
2005-06-30 16:54:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-09 22:32:44 +00:00
|
|
|
static struct platform_driver pxa2xx_ac97_driver = {
|
2005-06-30 16:54:04 +00:00
|
|
|
.probe = pxa2xx_ac97_probe,
|
2007-02-13 12:11:11 +00:00
|
|
|
.remove = __devexit_p(pxa2xx_ac97_remove),
|
2005-06-30 16:54:04 +00:00
|
|
|
.suspend = pxa2xx_ac97_suspend,
|
|
|
|
.resume = pxa2xx_ac97_resume,
|
2005-11-09 22:32:44 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "pxa2xx-ac97",
|
|
|
|
},
|
2005-06-30 16:54:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init pxa2xx_ac97_init(void)
|
|
|
|
{
|
2005-11-09 22:32:44 +00:00
|
|
|
return platform_driver_register(&pxa2xx_ac97_driver);
|
2005-06-30 16:54:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit pxa2xx_ac97_exit(void)
|
|
|
|
{
|
2005-11-09 22:32:44 +00:00
|
|
|
platform_driver_unregister(&pxa2xx_ac97_driver);
|
2005-06-30 16:54:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(pxa2xx_ac97_init);
|
|
|
|
module_exit(pxa2xx_ac97_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Nicolas Pitre");
|
|
|
|
MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip");
|
|
|
|
MODULE_LICENSE("GPL");
|