Commit 9f0ac6e1 authored by Frank Mandarino's avatar Frank Mandarino Committed by 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: default avatarFrank Mandarino <fmandarino@endrelia.com>
Signed-off-by: default avatarLiam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent a9e99660
# AT91 Platform Support # AT91 Platform Support
snd-soc-at91-objs := at91rm9200-pcm.o snd-soc-at91-objs := at91-pcm.o
snd-soc-at91-i2s-objs := at91rm9200-i2s.o snd-soc-at91-i2s-objs := at91-i2s.o
obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o
obj-$(CONFIG_SND_AT91_SOC_I2S) += snd-soc-at91-i2s.o obj-$(CONFIG_SND_AT91_SOC_I2S) += snd-soc-at91-i2s.o
......
/* /*
* 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> * Author: Frank Mandarino <fmandarino@endrelia.com>
* Endrelia Technologies Inc. * Endrelia Technologies Inc.
...@@ -16,24 +16,26 @@ ...@@ -16,24 +16,26 @@
* published by the Free Software Foundation. * 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. * Registers and status bits that are required by the PCM driver.
*/ */
struct at91rm9200_ssc_regs { struct at91_pdc_regs {
void __iomem *cr; /* SSC control */ unsigned int xpr; /* PDC recv/trans pointer */
void __iomem *ier; /* SSC interrupt enable */ unsigned int xcr; /* PDC recv/trans counter */
void __iomem *idr; /* SSC interrupt disable */ 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 { struct at91_ssc_mask {
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 {
u32 ssc_enable; /* SSC recv/trans enable */ u32 ssc_enable; /* SSC recv/trans enable */
u32 ssc_disable; /* SSC recv/trans disable */ u32 ssc_disable; /* SSC recv/trans disable */
u32 ssc_endx; /* SSC ENDTX or ENDRX */ u32 ssc_endx; /* SSC ENDTX or ENDRX */
...@@ -51,25 +53,19 @@ struct at91rm9200_ssc_mask { ...@@ -51,25 +53,19 @@ struct at91rm9200_ssc_mask {
* driver and called by the interface SSC interrupt handler if it is * driver and called by the interface SSC interrupt handler if it is
* non-NULL. * non-NULL.
*/ */
typedef struct { struct at91_pcm_dma_params {
char *name; /* stream identifier */ char *name; /* stream identifier */
int pdc_xfer_size; /* PDC counter increment in bytes */ int pdc_xfer_size; /* PDC counter increment in bytes */
struct at91rm9200_ssc_regs *ssc; /* SSC register addresses */ void __iomem *ssc_base; /* SSC base address */
struct at91rm9200_pdc_regs *pdc; /* PDC receive/transmit registers */ struct at91_pdc_regs *pdc; /* PDC receive or transmit registers */
struct at91rm9200_ssc_mask *mask;/* SSC & PDC status bits */ struct at91_ssc_mask *mask;/* SSC & PDC status bits */
snd_pcm_substream_t *substream; struct snd_pcm_substream *substream;
void (*dma_intr_handler)(u32, snd_pcm_substream_t *); void (*dma_intr_handler)(u32, struct snd_pcm_substream *);
} at91rm9200_pcm_dma_params_t; };
extern struct snd_soc_cpu_dai at91rm9200_i2s_dai[3]; extern struct snd_soc_cpu_dai at91_i2s_dai[3];
extern struct snd_soc_platform at91rm9200_soc_platform; 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_read(a) ((unsigned long) __raw_readl(a))
#define at91_ssc_write(a,v) __raw_writel((v),(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> * Author: Frank Mandarino <fmandarino@endrelia.com>
* Endrelia Technologies Inc. * Endrelia Technologies Inc.
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include <asm/arch/at91rm9200.h>
#include <asm/arch/gpio.h>
#include <asm/arch/hardware.h> #include <asm/arch/hardware.h>
#include <asm/arch/at91_pio.h>
#include <asm/arch/gpio.h>
#include "../codecs/wm8731.h" #include "../codecs/wm8731.h"
#include "at91rm9200-pcm.h" #include "at91-pcm.h"
#if 0 #if 0
#define DBG(x...) printk(KERN_INFO "eti_b1_wm8731:" x) #define DBG(x...) printk(KERN_INFO "eti_b1_wm8731:" x)
...@@ -50,10 +50,18 @@ ...@@ -50,10 +50,18 @@
#define DBG(x...) #define DBG(x...)
#endif #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 *pck1_clk;
static struct clk *pllb_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. */ /* Start PCK1 clock. */
clk_enable(pck1_clk); clk_enable(pck1_clk);
...@@ -62,7 +70,7 @@ static int eti_b1_startup(snd_pcm_substream_t *substream) ...@@ -62,7 +70,7 @@ static int eti_b1_startup(snd_pcm_substream_t *substream)
return 0; 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. */ /* Stop PCK1 clock. */
clk_disable(pck1_clk); clk_disable(pck1_clk);
...@@ -138,7 +146,7 @@ unsigned int eti_b1_config_sysclk(struct snd_soc_pcm_runtime *rtd, ...@@ -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 = { static struct snd_soc_dai_link eti_b1_dai = {
.name = "WM8731", .name = "WM8731",
.stream_name = "WM8731", .stream_name = "WM8731",
.cpu_dai = &at91rm9200_i2s_dai[1], .cpu_dai = &at91_i2s_dai[1],
.codec_dai = &wm8731_dai, .codec_dai = &wm8731_dai,
.init = eti_b1_wm8731_init, .init = eti_b1_wm8731_init,
.config_sysclk = eti_b1_config_sysclk, .config_sysclk = eti_b1_config_sysclk,
...@@ -157,7 +165,7 @@ static struct wm8731_setup_data eti_b1_wm8731_setup = { ...@@ -157,7 +165,7 @@ static struct wm8731_setup_data eti_b1_wm8731_setup = {
static struct snd_soc_device eti_b1_snd_devdata = { static struct snd_soc_device eti_b1_snd_devdata = {
.machine = &snd_soc_machine_eti_b1, .machine = &snd_soc_machine_eti_b1,
.platform = &at91rm9200_soc_platform, .platform = &at91_soc_platform,
.codec_dev = &soc_codec_dev_wm8731, .codec_dev = &soc_codec_dev_wm8731,
.codec_data = &eti_b1_wm8731_setup, .codec_data = &eti_b1_wm8731_setup,
}; };
...@@ -168,22 +176,41 @@ static int __init eti_b1_init(void) ...@@ -168,22 +176,41 @@ static int __init eti_b1_init(void)
{ {
int ret; int ret;
u32 ssc_pio_lines; 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); eti_b1_snd_device = platform_device_alloc("soc-audio", -1);
if (!eti_b1_snd_device) if (!eti_b1_snd_device) {
return -ENOMEM; DBG("platform device allocation failed\n");
ret = -ENOMEM;
goto fail_io_unmap;
}
platform_set_drvdata(eti_b1_snd_device, &eti_b1_snd_devdata); platform_set_drvdata(eti_b1_snd_device, &eti_b1_snd_devdata);
eti_b1_snd_devdata.dev = &eti_b1_snd_device->dev; eti_b1_snd_devdata.dev = &eti_b1_snd_device->dev;
ret = platform_device_add(eti_b1_snd_device); ret = platform_device_add(eti_b1_snd_device);
if (ret) { if (ret) {
DBG("platform device add failed\n");
platform_device_put(eti_b1_snd_device); 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 ssc_pio_lines = AT91_PIO_TF1 | AT91_PIO_TK1 | AT91_PIO_TD1
| AT91_PB9_RD1 /* | AT91_PB10_RK1 | AT91_PB11_RF1 */; | AT91_PIO_RD1 /* | AT91_PIO_RK1 | AT91_PIO_RF1 */;
/* Reset all PIO registers and assign lines to peripheral A */ /* Reset all PIO registers and assign lines to peripheral A */
at91_sys_write(AT91_PIOB + PIO_PDR, ssc_pio_lines); at91_sys_write(AT91_PIOB + PIO_PDR, ssc_pio_lines);
...@@ -211,14 +238,25 @@ static int __init eti_b1_init(void) ...@@ -211,14 +238,25 @@ static int __init eti_b1_init(void)
at91_set_B_periph(AT91_PIN_PA24, 0); at91_set_B_periph(AT91_PIN_PA24, 0);
return ret; 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) 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(pck1_clk);
clk_put(pllb_clk); clk_put(pllb_clk);
platform_device_unregister(eti_b1_snd_device); platform_device_unregister(eti_b1_snd_device);
iounmap(ssc->base);
release_mem_region(AT91RM9200_BASE_SSC1, SZ_16K);
} }
module_init(eti_b1_init); module_init(eti_b1_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment