提交 9f0ac6e1 编写于 作者: F Frank Mandarino 提交者: Jaroslav Kysela

[ALSA] Update AT91 ASoC driver for 2.6.19 kernel.

Changes were required to support latest AT91 header files.
Also updated to remove AT91RM9200-specific code in the ASoC
platform drivers to support the AT91SAM9260 and AT91SAM9261
chips, but no testing was performed on these chips.
Signed-off-by: NFrank Mandarino <fmandarino@endrelia.com>
Signed-off-by: NLiam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
Signed-off-by: NJaroslav Kysela <perex@suse.cz>
上级 a9e99660
# AT91 Platform Support
snd-soc-at91-objs := at91rm9200-pcm.o
snd-soc-at91-i2s-objs := at91rm9200-i2s.o
snd-soc-at91-objs := at91-pcm.o
snd-soc-at91-i2s-objs := at91-i2s.o
obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o
obj-$(CONFIG_SND_AT91_SOC_I2S) += snd-soc-at91-i2s.o
......
/*
* at91rm9200-pcm.c -- ALSA PCM interface for the Atmel AT91RM9200 chip.
* at91-pcm.c -- ALSA PCM interface for the Atmel AT91 SoC
*
* Author: Frank Mandarino <fmandarino@endrelia.com>
* Endrelia Technologies Inc.
......@@ -28,20 +28,19 @@
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <asm/arch/at91rm9200.h>
#include <asm/arch/at91rm9200_ssc.h>
#include <asm/arch/at91rm9200_pdc.h>
#include <asm/arch/hardware.h>
#include <asm/arch/at91_ssc.h>
#include <asm/arch/at91_pdc.h>
#include "at91rm9200-pcm.h"
#include "at91-pcm.h"
#if 0
#define DBG(x...) printk(KERN_INFO "at91rm9200-pcm: " x)
#define DBG(x...) printk(KERN_INFO "at91-pcm: " x)
#else
#define DBG(x...)
#endif
static const snd_pcm_hardware_t at91rm9200_pcm_hardware = {
static const struct snd_pcm_hardware at91_pcm_hardware = {
.info = SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_INTERLEAVED |
......@@ -54,8 +53,8 @@ static const snd_pcm_hardware_t at91rm9200_pcm_hardware = {
.buffer_bytes_max = 32 * 1024,
};
struct at91rm9200_runtime_data {
at91rm9200_pcm_dma_params_t *params;
struct at91_runtime_data {
struct at91_pcm_dma_params *params;
dma_addr_t dma_buffer; /* physical address of dma buffer */
dma_addr_t dma_buffer_end; /* first address beyond DMA buffer */
size_t period_size;
......@@ -66,11 +65,11 @@ struct at91rm9200_runtime_data {
u32 pdc_xncr_save;
};
static void at91rm9200_pcm_dma_irq(u32 ssc_sr,
static void at91_pcm_dma_irq(u32 ssc_sr,
struct snd_pcm_substream *substream)
{
struct at91rm9200_runtime_data *prtd = substream->runtime->private_data;
at91rm9200_pcm_dma_params_t *params = prtd->params;
struct at91_runtime_data *prtd = substream->runtime->private_data;
struct at91_pcm_dma_params *params = prtd->params;
static int count = 0;
count++;
......@@ -78,24 +77,24 @@ static void at91rm9200_pcm_dma_irq(u32 ssc_sr,
if (ssc_sr & params->mask->ssc_endbuf) {
printk(KERN_WARNING
"at91rm9200-pcm: buffer %s on %s (SSC_SR=%#x, count=%d)\n",
"at91-pcm: buffer %s on %s (SSC_SR=%#x, count=%d)\n",
substream->stream == SNDRV_PCM_STREAM_PLAYBACK
? "underrun" : "overrun",
params->name, ssc_sr, count);
/* re-start the PDC */
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_disable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
prtd->period_ptr += prtd->period_size;
if (prtd->period_ptr >= prtd->dma_buffer_end) {
prtd->period_ptr = prtd->dma_buffer;
}
at91_ssc_write(params->pdc->xpr, prtd->period_ptr);
at91_ssc_write(params->pdc->xcr,
at91_ssc_write(params->ssc_base + params->pdc->xpr, prtd->period_ptr);
at91_ssc_write(params->ssc_base + params->pdc->xcr,
prtd->period_size / params->pdc_xfer_size);
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_enable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable);
}
if (ssc_sr & params->mask->ssc_endx) {
......@@ -105,19 +104,19 @@ static void at91rm9200_pcm_dma_irq(u32 ssc_sr,
if (prtd->period_ptr >= prtd->dma_buffer_end) {
prtd->period_ptr = prtd->dma_buffer;
}
at91_ssc_write(params->pdc->xnpr, prtd->period_ptr);
at91_ssc_write(params->pdc->xncr,
at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->period_ptr);
at91_ssc_write(params->ssc_base + params->pdc->xncr,
prtd->period_size / params->pdc_xfer_size);
}
snd_pcm_period_elapsed(substream);
}
static int at91rm9200_pcm_hw_params(struct snd_pcm_substream *substream,
static int at91_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
snd_pcm_runtime_t *runtime = substream->runtime;
struct at91rm9200_runtime_data *prtd = runtime->private_data;
struct snd_pcm_runtime *runtime = substream->runtime;
struct at91_runtime_data *prtd = runtime->private_data;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
/* this may get called several times by oss emulation
......@@ -127,7 +126,7 @@ static int at91rm9200_pcm_hw_params(struct snd_pcm_substream *substream,
runtime->dma_bytes = params_buffer_bytes(params);
prtd->params = rtd->cpu_dai->dma_data;
prtd->params->dma_intr_handler = at91rm9200_pcm_dma_irq;
prtd->params->dma_intr_handler = at91_pcm_dma_irq;
prtd->dma_buffer = runtime->dma_addr;
prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes;
......@@ -138,76 +137,76 @@ static int at91rm9200_pcm_hw_params(struct snd_pcm_substream *substream,
return 0;
}
static int at91rm9200_pcm_hw_free(struct snd_pcm_substream *substream)
static int at91_pcm_hw_free(struct snd_pcm_substream *substream)
{
struct at91rm9200_runtime_data *prtd = substream->runtime->private_data;
at91rm9200_pcm_dma_params_t *params = prtd->params;
struct at91_runtime_data *prtd = substream->runtime->private_data;
struct at91_pcm_dma_params *params = prtd->params;
if (params != NULL) {
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_disable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
prtd->params->dma_intr_handler = NULL;
}
return 0;
}
static int at91rm9200_pcm_prepare(struct snd_pcm_substream *substream)
static int at91_pcm_prepare(struct snd_pcm_substream *substream)
{
struct at91rm9200_runtime_data *prtd = substream->runtime->private_data;
at91rm9200_pcm_dma_params_t *params = prtd->params;
struct at91_runtime_data *prtd = substream->runtime->private_data;
struct at91_pcm_dma_params *params = prtd->params;
at91_ssc_write(params->ssc->idr,
at91_ssc_write(params->ssc_base + AT91_SSC_IDR,
params->mask->ssc_endx | params->mask->ssc_endbuf);
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_disable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
return 0;
}
static int at91rm9200_pcm_trigger(struct snd_pcm_substream *substream,
static int at91_pcm_trigger(struct snd_pcm_substream *substream,
int cmd)
{
struct at91rm9200_runtime_data *prtd = substream->runtime->private_data;
at91rm9200_pcm_dma_params_t *params = prtd->params;
struct at91_runtime_data *prtd = substream->runtime->private_data;
struct at91_pcm_dma_params *params = prtd->params;
int ret = 0;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
prtd->period_ptr = prtd->dma_buffer;
at91_ssc_write(params->pdc->xpr, prtd->period_ptr);
at91_ssc_write(params->pdc->xcr,
at91_ssc_write(params->ssc_base + params->pdc->xpr, prtd->period_ptr);
at91_ssc_write(params->ssc_base + params->pdc->xcr,
prtd->period_size / params->pdc_xfer_size);
prtd->period_ptr += prtd->period_size;
at91_ssc_write(params->pdc->xnpr, prtd->period_ptr);
at91_ssc_write(params->pdc->xncr,
at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->period_ptr);
at91_ssc_write(params->ssc_base + params->pdc->xncr,
prtd->period_size / params->pdc_xfer_size);
DBG("trigger: period_ptr=%lx, xpr=%lx, xcr=%ld, xnpr=%lx, xncr=%ld\n",
(unsigned long) prtd->period_ptr,
at91_ssc_read(params->pdc->xpr),
at91_ssc_read(params->pdc->xcr),
at91_ssc_read(params->pdc->xnpr),
at91_ssc_read(params->pdc->xncr));
at91_ssc_read(params->ssc_base + params->pdc->xpr),
at91_ssc_read(params->ssc_base + params->pdc->xcr),
at91_ssc_read(params->ssc_base + params->pdc->xnpr),
at91_ssc_read(params->ssc_base + params->pdc->xncr));
at91_ssc_write(params->ssc->ier,
at91_ssc_write(params->ssc_base + AT91_SSC_IER,
params->mask->ssc_endx | params->mask->ssc_endbuf);
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_enable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable);
DBG("sr=%lx imr=%lx\n", at91_ssc_read(params->ssc->ier - 4),
at91_ssc_read(params->ssc->ier + 8));
DBG("sr=%lx imr=%lx\n", at91_ssc_read(params->ssc_base + AT91_SSC_SR),
at91_ssc_read(params->ssc_base + AT91_SSC_IER));
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_disable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
break;
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_enable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable);
break;
default:
......@@ -217,16 +216,16 @@ static int at91rm9200_pcm_trigger(struct snd_pcm_substream *substream,
return ret;
}
static snd_pcm_uframes_t at91rm9200_pcm_pointer(
static snd_pcm_uframes_t at91_pcm_pointer(
struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct at91rm9200_runtime_data *prtd = runtime->private_data;
at91rm9200_pcm_dma_params_t *params = prtd->params;
struct at91_runtime_data *prtd = runtime->private_data;
struct at91_pcm_dma_params *params = prtd->params;
dma_addr_t ptr;
snd_pcm_uframes_t x;
ptr = (dma_addr_t) at91_ssc_read(params->pdc->xpr);
ptr = (dma_addr_t) at91_ssc_read(params->ssc_base + params->pdc->xpr);
x = bytes_to_frames(runtime, ptr - prtd->dma_buffer);
if (x == runtime->buffer_size)
......@@ -234,20 +233,20 @@ static snd_pcm_uframes_t at91rm9200_pcm_pointer(
return x;
}
static int at91rm9200_pcm_open(struct snd_pcm_substream *substream)
static int at91_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct at91rm9200_runtime_data *prtd;
struct at91_runtime_data *prtd;
int ret = 0;
snd_soc_set_runtime_hwparams(substream, &at91rm9200_pcm_hardware);
snd_soc_set_runtime_hwparams(substream, &at91_pcm_hardware);
/* ensure that buffer size is a multiple of period size */
ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
goto out;
prtd = kzalloc(sizeof(struct at91rm9200_runtime_data), GFP_KERNEL);
prtd = kzalloc(sizeof(struct at91_runtime_data), GFP_KERNEL);
if (prtd == NULL) {
ret = -ENOMEM;
goto out;
......@@ -258,15 +257,15 @@ static int at91rm9200_pcm_open(struct snd_pcm_substream *substream)
return ret;
}
static int at91rm9200_pcm_close(struct snd_pcm_substream *substream)
static int at91_pcm_close(struct snd_pcm_substream *substream)
{
struct at91rm9200_runtime_data *prtd = substream->runtime->private_data;
struct at91_runtime_data *prtd = substream->runtime->private_data;
kfree(prtd);
return 0;
}
static int at91rm9200_pcm_mmap(struct snd_pcm_substream *substream,
static int at91_pcm_mmap(struct snd_pcm_substream *substream,
struct vm_area_struct *vma)
{
struct snd_pcm_runtime *runtime = substream->runtime;
......@@ -277,24 +276,24 @@ static int at91rm9200_pcm_mmap(struct snd_pcm_substream *substream,
runtime->dma_bytes);
}
struct snd_pcm_ops at91rm9200_pcm_ops = {
.open = at91rm9200_pcm_open,
.close = at91rm9200_pcm_close,
struct snd_pcm_ops at91_pcm_ops = {
.open = at91_pcm_open,
.close = at91_pcm_close,
.ioctl = snd_pcm_lib_ioctl,
.hw_params = at91rm9200_pcm_hw_params,
.hw_free = at91rm9200_pcm_hw_free,
.prepare = at91rm9200_pcm_prepare,
.trigger = at91rm9200_pcm_trigger,
.pointer = at91rm9200_pcm_pointer,
.mmap = at91rm9200_pcm_mmap,
.hw_params = at91_pcm_hw_params,
.hw_free = at91_pcm_hw_free,
.prepare = at91_pcm_prepare,
.trigger = at91_pcm_trigger,
.pointer = at91_pcm_pointer,
.mmap = at91_pcm_mmap,
};
static int at91rm9200_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
static int at91_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
int stream)
{
struct snd_pcm_substream *substream = pcm->streams[stream].substream;
struct snd_dma_buffer *buf = &substream->dma_buffer;
size_t size = at91rm9200_pcm_hardware.buffer_bytes_max;
size_t size = at91_pcm_hardware.buffer_bytes_max;
buf->dev.type = SNDRV_DMA_TYPE_DEV;
buf->dev.dev = pcm->card->dev;
......@@ -314,27 +313,27 @@ static int at91rm9200_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
return 0;
}
static u64 at91rm9200_pcm_dmamask = 0xffffffff;
static u64 at91_pcm_dmamask = 0xffffffff;
static int at91rm9200_pcm_new(struct snd_card *card,
static int at91_pcm_new(struct snd_card *card,
struct snd_soc_codec_dai *dai, struct snd_pcm *pcm)
{
int ret = 0;
if (!card->dev->dma_mask)
card->dev->dma_mask = &at91rm9200_pcm_dmamask;
card->dev->dma_mask = &at91_pcm_dmamask;
if (!card->dev->coherent_dma_mask)
card->dev->coherent_dma_mask = 0xffffffff;
if (dai->playback.channels_min) {
ret = at91rm9200_pcm_preallocate_dma_buffer(pcm,
ret = at91_pcm_preallocate_dma_buffer(pcm,
SNDRV_PCM_STREAM_PLAYBACK);
if (ret)
goto out;
}
if (dai->capture.channels_min) {
ret = at91rm9200_pcm_preallocate_dma_buffer(pcm,
ret = at91_pcm_preallocate_dma_buffer(pcm,
SNDRV_PCM_STREAM_CAPTURE);
if (ret)
goto out;
......@@ -343,7 +342,7 @@ static int at91rm9200_pcm_new(struct snd_card *card,
return ret;
}
static void at91rm9200_pcm_free_dma_buffers(struct snd_pcm *pcm)
static void at91_pcm_free_dma_buffers(struct snd_pcm *pcm)
{
struct snd_pcm_substream *substream;
struct snd_dma_buffer *buf;
......@@ -364,12 +363,12 @@ static void at91rm9200_pcm_free_dma_buffers(struct snd_pcm *pcm)
}
}
static int at91rm9200_pcm_suspend(struct platform_device *pdev,
static int at91_pcm_suspend(struct platform_device *pdev,
struct snd_soc_cpu_dai *dai)
{
struct snd_pcm_runtime *runtime = dai->runtime;
struct at91rm9200_runtime_data *prtd;
at91rm9200_pcm_dma_params_t *params;
struct at91_runtime_data *prtd;
struct at91_pcm_dma_params *params;
if (!runtime)
return 0;
......@@ -379,22 +378,22 @@ static int at91rm9200_pcm_suspend(struct platform_device *pdev,
/* disable the PDC and save the PDC registers */
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_disable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
prtd->pdc_xpr_save = at91_ssc_read(params->pdc->xpr);
prtd->pdc_xcr_save = at91_ssc_read(params->pdc->xcr);
prtd->pdc_xnpr_save = at91_ssc_read(params->pdc->xnpr);
prtd->pdc_xncr_save = at91_ssc_read(params->pdc->xncr);
prtd->pdc_xpr_save = at91_ssc_read(params->ssc_base + params->pdc->xpr);
prtd->pdc_xcr_save = at91_ssc_read(params->ssc_base + params->pdc->xcr);
prtd->pdc_xnpr_save = at91_ssc_read(params->ssc_base + params->pdc->xnpr);
prtd->pdc_xncr_save = at91_ssc_read(params->ssc_base + params->pdc->xncr);
return 0;
}
static int at91rm9200_pcm_resume(struct platform_device *pdev,
static int at91_pcm_resume(struct platform_device *pdev,
struct snd_soc_cpu_dai *dai)
{
struct snd_pcm_runtime *runtime = dai->runtime;
struct at91rm9200_runtime_data *prtd;
at91rm9200_pcm_dma_params_t *params;
struct at91_runtime_data *prtd;
struct at91_pcm_dma_params *params;
if (!runtime)
return 0;
......@@ -403,26 +402,26 @@ static int at91rm9200_pcm_resume(struct platform_device *pdev,
params = prtd->params;
/* restore the PDC registers and enable the PDC */
at91_ssc_write(params->pdc->xpr, prtd->pdc_xpr_save);
at91_ssc_write(params->pdc->xcr, prtd->pdc_xcr_save);
at91_ssc_write(params->pdc->xnpr, prtd->pdc_xnpr_save);
at91_ssc_write(params->pdc->xncr, prtd->pdc_xncr_save);
at91_ssc_write(params->ssc_base + params->pdc->xpr, prtd->pdc_xpr_save);
at91_ssc_write(params->ssc_base + params->pdc->xcr, prtd->pdc_xcr_save);
at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->pdc_xnpr_save);
at91_ssc_write(params->ssc_base + params->pdc->xncr, prtd->pdc_xncr_save);
at91_ssc_write(params->pdc->ptcr, params->mask->pdc_enable);
at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable);
return 0;
}
struct snd_soc_platform at91rm9200_soc_platform = {
.name = "at91rm9200-audio",
.pcm_ops = &at91rm9200_pcm_ops,
.pcm_new = at91rm9200_pcm_new,
.pcm_free = at91rm9200_pcm_free_dma_buffers,
.suspend = at91rm9200_pcm_suspend,
.resume = at91rm9200_pcm_resume,
struct snd_soc_platform at91_soc_platform = {
.name = "at91-audio",
.pcm_ops = &at91_pcm_ops,
.pcm_new = at91_pcm_new,
.pcm_free = at91_pcm_free_dma_buffers,
.suspend = at91_pcm_suspend,
.resume = at91_pcm_resume,
};
EXPORT_SYMBOL_GPL(at91rm9200_soc_platform);
EXPORT_SYMBOL_GPL(at91_soc_platform);
MODULE_AUTHOR("Frank Mandarino <fmandarino@endrelia.com>");
MODULE_DESCRIPTION("Atmel AT91RM9200 PCM module");
MODULE_DESCRIPTION("Atmel AT91 PCM module");
MODULE_LICENSE("GPL");
/*
* at91rm9200-pcm.h - ALSA PCM interface for the Atmel AT91RM9200 chip
* at91-pcm.h - ALSA PCM interface for the Atmel AT91 SoC
*
* Author: Frank Mandarino <fmandarino@endrelia.com>
* Endrelia Technologies Inc.
......@@ -16,24 +16,26 @@
* published by the Free Software Foundation.
*/
#include <asm/arch/hardware.h>
struct at91_ssc_periph {
void __iomem *base;
u32 pid;
};
/*
* Registers and status bits that are required by the PCM driver.
*/
struct at91rm9200_ssc_regs {
void __iomem *cr; /* SSC control */
void __iomem *ier; /* SSC interrupt enable */
void __iomem *idr; /* SSC interrupt disable */
struct at91_pdc_regs {
unsigned int xpr; /* PDC recv/trans pointer */
unsigned int xcr; /* PDC recv/trans counter */
unsigned int xnpr; /* PDC next recv/trans pointer */
unsigned int xncr; /* PDC next recv/trans counter */
unsigned int ptcr; /* PDC transfer control */
};
struct at91rm9200_pdc_regs {
void __iomem *xpr; /* PDC recv/trans pointer */
void __iomem *xcr; /* PDC recv/trans counter */
void __iomem *xnpr; /* PDC next recv/trans pointer */
void __iomem *xncr; /* PDC next recv/trans counter */
void __iomem *ptcr; /* PDC transfer control */
};
struct at91rm9200_ssc_mask {
struct at91_ssc_mask {
u32 ssc_enable; /* SSC recv/trans enable */
u32 ssc_disable; /* SSC recv/trans disable */
u32 ssc_endx; /* SSC ENDTX or ENDRX */
......@@ -51,25 +53,19 @@ struct at91rm9200_ssc_mask {
* driver and called by the interface SSC interrupt handler if it is
* non-NULL.
*/
typedef struct {
struct at91_pcm_dma_params {
char *name; /* stream identifier */
int pdc_xfer_size; /* PDC counter increment in bytes */
struct at91rm9200_ssc_regs *ssc; /* SSC register addresses */
struct at91rm9200_pdc_regs *pdc; /* PDC receive/transmit registers */
struct at91rm9200_ssc_mask *mask;/* SSC & PDC status bits */
snd_pcm_substream_t *substream;
void (*dma_intr_handler)(u32, snd_pcm_substream_t *);
} at91rm9200_pcm_dma_params_t;
void __iomem *ssc_base; /* SSC base address */
struct at91_pdc_regs *pdc; /* PDC receive or transmit registers */
struct at91_ssc_mask *mask;/* SSC & PDC status bits */
struct snd_pcm_substream *substream;
void (*dma_intr_handler)(u32, struct snd_pcm_substream *);
};
extern struct snd_soc_cpu_dai at91rm9200_i2s_dai[3];
extern struct snd_soc_platform at91rm9200_soc_platform;
extern struct snd_soc_cpu_dai at91_i2s_dai[3];
extern struct snd_soc_platform at91_soc_platform;
/*
* SSC I/O helpers.
* E.g., at91_ssc_write(AT91_SSC(1) + AT91_SSC_CR, AT91_SSC_RXEN);
*/
#define AT91_SSC(x) (((x)==0) ? AT91_VA_BASE_SSC0 :\
((x)==1) ? AT91_VA_BASE_SSC1 : ((x)==2) ? AT91_VA_BASE_SSC2 : NULL)
#define at91_ssc_read(a) ((unsigned long) __raw_readl(a))
#define at91_ssc_write(a,v) __raw_writel((v),(a))
/*
* eti_b1_wm8731 -- SoC audio for Endrelia ETI_B1.
* eti_b1_wm8731 -- SoC audio for AT91RM9200-based Endrelia ETI_B1 board.
*
* Author: Frank Mandarino <fmandarino@endrelia.com>
* Endrelia Technologies Inc.
......@@ -37,12 +37,12 @@
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <asm/arch/at91rm9200.h>
#include <asm/arch/gpio.h>
#include <asm/arch/hardware.h>
#include <asm/arch/at91_pio.h>
#include <asm/arch/gpio.h>
#include "../codecs/wm8731.h"
#include "at91rm9200-pcm.h"
#include "at91-pcm.h"
#if 0
#define DBG(x...) printk(KERN_INFO "eti_b1_wm8731:" x)
......@@ -50,10 +50,18 @@
#define DBG(x...)
#endif
#define AT91_PIO_TF1 (1 << (AT91_PIN_PB6 - PIN_BASE) % 32)
#define AT91_PIO_TK1 (1 << (AT91_PIN_PB7 - PIN_BASE) % 32)
#define AT91_PIO_TD1 (1 << (AT91_PIN_PB8 - PIN_BASE) % 32)
#define AT91_PIO_RD1 (1 << (AT91_PIN_PB9 - PIN_BASE) % 32)
#define AT91_PIO_RK1 (1 << (AT91_PIN_PB10 - PIN_BASE) % 32)
#define AT91_PIO_RF1 (1 << (AT91_PIN_PB11 - PIN_BASE) % 32)
static struct clk *pck1_clk;
static struct clk *pllb_clk;
static int eti_b1_startup(snd_pcm_substream_t *substream)
static int eti_b1_startup(struct snd_pcm_substream *substream)
{
/* Start PCK1 clock. */
clk_enable(pck1_clk);
......@@ -62,7 +70,7 @@ static int eti_b1_startup(snd_pcm_substream_t *substream)
return 0;
}
static void eti_b1_shutdown(snd_pcm_substream_t *substream)
static void eti_b1_shutdown(struct snd_pcm_substream *substream)
{
/* Stop PCK1 clock. */
clk_disable(pck1_clk);
......@@ -138,7 +146,7 @@ unsigned int eti_b1_config_sysclk(struct snd_soc_pcm_runtime *rtd,
static struct snd_soc_dai_link eti_b1_dai = {
.name = "WM8731",
.stream_name = "WM8731",
.cpu_dai = &at91rm9200_i2s_dai[1],
.cpu_dai = &at91_i2s_dai[1],
.codec_dai = &wm8731_dai,
.init = eti_b1_wm8731_init,
.config_sysclk = eti_b1_config_sysclk,
......@@ -157,7 +165,7 @@ static struct wm8731_setup_data eti_b1_wm8731_setup = {
static struct snd_soc_device eti_b1_snd_devdata = {
.machine = &snd_soc_machine_eti_b1,
.platform = &at91rm9200_soc_platform,
.platform = &at91_soc_platform,
.codec_dev = &soc_codec_dev_wm8731,
.codec_data = &eti_b1_wm8731_setup,
};
......@@ -168,22 +176,41 @@ static int __init eti_b1_init(void)
{
int ret;
u32 ssc_pio_lines;
struct at91_ssc_periph *ssc = eti_b1_dai.cpu_dai->private_data;
if (!request_mem_region(AT91RM9200_BASE_SSC1, SZ_16K, "soc-audio")) {
DBG("SSC1 memory region is busy\n");
return -EBUSY;
}
ssc->base = ioremap(AT91RM9200_BASE_SSC1, SZ_16K);
if (!ssc->base) {
DBG("SSC1 memory ioremap failed\n");
ret = -ENOMEM;
goto fail_release_mem;
}
ssc->pid = AT91RM9200_ID_SSC1;
eti_b1_snd_device = platform_device_alloc("soc-audio", -1);
if (!eti_b1_snd_device)
return -ENOMEM;
if (!eti_b1_snd_device) {
DBG("platform device allocation failed\n");
ret = -ENOMEM;
goto fail_io_unmap;
}
platform_set_drvdata(eti_b1_snd_device, &eti_b1_snd_devdata);
eti_b1_snd_devdata.dev = &eti_b1_snd_device->dev;
ret = platform_device_add(eti_b1_snd_device);
if (ret) {
DBG("platform device add failed\n");
platform_device_put(eti_b1_snd_device);
return ret;
goto fail_io_unmap;
}
ssc_pio_lines = AT91_PB6_TF1 | AT91_PB7_TK1 | AT91_PB8_TD1
| AT91_PB9_RD1 /* | AT91_PB10_RK1 | AT91_PB11_RF1 */;
ssc_pio_lines = AT91_PIO_TF1 | AT91_PIO_TK1 | AT91_PIO_TD1
| AT91_PIO_RD1 /* | AT91_PIO_RK1 | AT91_PIO_RF1 */;
/* Reset all PIO registers and assign lines to peripheral A */
at91_sys_write(AT91_PIOB + PIO_PDR, ssc_pio_lines);
......@@ -211,14 +238,25 @@ static int __init eti_b1_init(void)
at91_set_B_periph(AT91_PIN_PA24, 0);
return ret;
fail_io_unmap:
iounmap(ssc->base);
fail_release_mem:
release_mem_region(AT91RM9200_BASE_SSC1, SZ_16K);
return ret;
}
static void __exit eti_b1_exit(void)
{
struct at91_ssc_periph *ssc = eti_b1_dai.cpu_dai->private_data;
clk_put(pck1_clk);
clk_put(pllb_clk);
platform_device_unregister(eti_b1_snd_device);
iounmap(ssc->base);
release_mem_region(AT91RM9200_BASE_SSC1, SZ_16K);
}
module_init(eti_b1_init);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册