1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-12 00:44:03 +02:00

[xburst] ASoC: Fix and cleaup dma config

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21618 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
lars 2010-05-29 00:09:51 +00:00
parent 884d14dfb6
commit b28851ab49

View File

@ -1,6 +1,6 @@
From 6548719b6a1ce4e202d58625fbfb94e6c894ced9 Mon Sep 17 00:00:00 2001
From d12d1c5f8615192b545faa69a553f64d4d9cc9ab Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen <lars@metafoo.de>
Date: Sat, 24 Apr 2010 12:35:07 +0200
Date: Fri, 28 May 2010 19:54:02 +0200
Subject: [PATCH] Add jz4740 SoC sound drivers
---
@ -8,11 +8,11 @@ Subject: [PATCH] Add jz4740 SoC sound drivers
sound/soc/Makefile | 1 +
sound/soc/jz4740/Kconfig | 13 +
sound/soc/jz4740/Makefile | 9 +
sound/soc/jz4740/jz4740-i2s.c | 572 +++++++++++++++++++++++++++++++++++++++++
sound/soc/jz4740/jz4740-i2s.c | 568 +++++++++++++++++++++++++++++++++++++++++
sound/soc/jz4740/jz4740-i2s.h | 18 ++
sound/soc/jz4740/jz4740-pcm.c | 350 +++++++++++++++++++++++++
sound/soc/jz4740/jz4740-pcm.h | 22 ++
8 files changed, 986 insertions(+), 0 deletions(-)
8 files changed, 982 insertions(+), 0 deletions(-)
create mode 100644 sound/soc/jz4740/Kconfig
create mode 100644 sound/soc/jz4740/Makefile
create mode 100644 sound/soc/jz4740/jz4740-i2s.c
@ -77,10 +77,10 @@ index 0000000..1be8d19
+
diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c
new file mode 100644
index 0000000..d3daa27
index 0000000..2b139fd
--- /dev/null
+++ b/sound/soc/jz4740/jz4740-i2s.c
@@ -0,0 +1,572 @@
@@ -0,0 +1,568 @@
+/*
+ * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
+ *
@ -173,29 +173,10 @@ index 0000000..d3daa27
+ struct clk *clk_aic;
+ struct clk *clk_i2s;
+
+ struct jz4740_pcm_config capture_pcm_config;
+ struct jz4740_pcm_config playback_pcm_config;
+ struct jz4740_pcm_config pcm_config_playback;
+ struct jz4740_pcm_config pcm_config_capture;
+};
+
+static struct jz4740_dma_config jz4740_i2s_dma_playback_config = {
+ .src_width = JZ4740_DMA_WIDTH_16BIT,
+ .dst_width = JZ4740_DMA_WIDTH_32BIT,
+ .transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE,
+ .request_type = JZ4740_DMA_TYPE_AIC_TRANSMIT,
+ .flags = JZ4740_DMA_SRC_AUTOINC,
+ .mode = JZ4740_DMA_MODE_SINGLE,
+};
+
+static struct jz4740_dma_config jz4740_i2s_dma_capture_config = {
+ .src_width = JZ4740_DMA_WIDTH_32BIT,
+ .dst_width = JZ4740_DMA_WIDTH_16BIT,
+ .transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE,
+ .request_type = JZ4740_DMA_TYPE_AIC_RECEIVE,
+ .flags = JZ4740_DMA_DST_AUTOINC,
+ .mode = JZ4740_DMA_MODE_SINGLE,
+};
+
+
+static inline uint32_t jz4740_i2s_read(const struct jz4740_i2s *i2s,
+ unsigned int reg)
+{
@ -222,22 +203,22 @@ index 0000000..d3daa27
+ if (dai->active)
+ return 0;
+
+ conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
+
+ ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL);
+
+ conf |= JZ_AIC_CONF_ENABLE;
+ ctrl |= JZ_AIC_CTRL_FLUSH;
+
+
+ jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl);
+
+ clk_enable(i2s->clk_i2s);
+
+ conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
+ conf |= JZ_AIC_CONF_ENABLE;
+ jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf);
+
+ return 0;
+}
+
+static void jz4740_i2s_shutdown(struct snd_pcm_substream *substream, struct
+ snd_soc_dai *dai)
+static void jz4740_i2s_shutdown(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct jz4740_i2s *i2s = jz4740_dai_to_i2s(dai);
+ uint32_t conf;
@ -262,11 +243,10 @@ index 0000000..d3daa27
+ uint32_t ctrl;
+ uint32_t mask;
+
+ if (playback) {
+ if (playback)
+ mask = JZ_AIC_CTRL_ENABLE_PLAYBACK | JZ_AIC_CTRL_ENABLE_TX_DMA;
+ } else {
+ else
+ mask = JZ_AIC_CTRL_ENABLE_CAPTURE | JZ_AIC_CTRL_ENABLE_RX_DMA;
+ }
+
+ ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL);
+
@ -291,8 +271,7 @@ index 0000000..d3daa27
+}
+
+
+static int jz4740_i2s_set_fmt(struct snd_soc_dai *dai,
+ unsigned int fmt)
+static int jz4740_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+{
+ struct jz4740_i2s *i2s = jz4740_dai_to_i2s(dai);
+
@ -344,8 +323,7 @@ index 0000000..d3daa27
+}
+
+static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
+ struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
+{
+ struct jz4740_i2s *i2s = jz4740_dai_to_i2s(dai);
+ bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
@ -392,23 +370,20 @@ index 0000000..d3daa27
+ jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl);
+
+ if (playback) {
+ jz4740_i2s_dma_playback_config.src_width = dma_width;
+ pcm_config = &i2s->playback_pcm_config;
+ pcm_config->dma_config = &jz4740_i2s_dma_playback_config;
+ pcm_config = &i2s->pcm_config_playback;
+ pcm_config->dma_config.dst_width = dma_width;
+ } else {
+ jz4740_i2s_dma_capture_config.dst_width = dma_width;
+ pcm_config = &i2s->capture_pcm_config;
+ pcm_config->dma_config = &jz4740_i2s_dma_capture_config;
+ pcm_config = &i2s->pcm_config_capture;
+ pcm_config->dma_config.src_width = dma_width;
+ }
+ pcm_config->fifo_addr = i2s->phys_base + JZ_REG_AIC_FIFO;
+
+
+ snd_soc_dai_set_dma_data(dai, substream, pcm_config);
+
+ return 0;
+}
+
+static int jz4740_i2s_set_clkdiv(struct snd_soc_dai *dai,
+ int div_id, int div)
+static int jz4740_i2s_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
+{
+ struct jz4740_i2s *i2s = jz4740_dai_to_i2s(dai);
+
@ -524,13 +499,13 @@ index 0000000..d3daa27
+ .playback = {
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = SNDRV_PCM_RATE_8000_44100,
+ .rates = SNDRV_PCM_RATE_8000_48000,
+ .formats = JZ4740_I2S_FMTS,
+ },
+ .capture = {
+ .channels_min = 2,
+ .channels_max = 2,
+ .rates = SNDRV_PCM_RATE_8000_44100,
+ .rates = SNDRV_PCM_RATE_8000_48000,
+ .formats = JZ4740_I2S_FMTS,
+ },
+ .symmetric_rates = 1,
@ -540,6 +515,29 @@ index 0000000..d3daa27
+};
+EXPORT_SYMBOL_GPL(jz4740_i2s_dai);
+
+static void __devinit jz4740_i2c_init_pcm_config(struct jz4740_i2s *i2s)
+{
+ struct jz4740_dma_config *dma_config;
+
+ /* Playback */
+ dma_config = &i2s->pcm_config_playback.dma_config;
+ dma_config->src_width = JZ4740_DMA_WIDTH_32BIT,
+ dma_config->transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE;
+ dma_config->request_type = JZ4740_DMA_TYPE_AIC_TRANSMIT;
+ dma_config->flags = JZ4740_DMA_SRC_AUTOINC;
+ dma_config->mode = JZ4740_DMA_MODE_SINGLE;
+ i2s->pcm_config_playback.fifo_addr = i2s->phys_base + JZ_REG_AIC_FIFO;
+
+ /* Capture */
+ dma_config = &i2s->pcm_config_capture.dma_config;
+ dma_config->dst_width = JZ4740_DMA_WIDTH_32BIT,
+ dma_config->transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE;
+ dma_config->request_type = JZ4740_DMA_TYPE_AIC_RECEIVE;
+ dma_config->flags = JZ4740_DMA_DST_AUTOINC;
+ dma_config->mode = JZ4740_DMA_MODE_SINGLE;
+ i2s->pcm_config_capture.fifo_addr = i2s->phys_base + JZ_REG_AIC_FIFO;
+}
+
+static int __devinit jz4740_i2s_dev_probe(struct platform_device *pdev)
+{
+ struct jz4740_i2s *i2s;
@ -574,20 +572,13 @@ index 0000000..d3daa27
+
+ i2s->phys_base = i2s->mem->start;
+
+ jz4740_i2s_dai.private_data = i2s;
+
+ ret = snd_soc_register_dai(&jz4740_i2s_dai);
+
+ i2s->clk_aic = clk_get(&pdev->dev, "aic");
+
+ if (IS_ERR(i2s->clk_aic)) {
+ ret = PTR_ERR(i2s->clk_aic);
+ goto err_iounmap;
+ }
+
+
+ i2s->clk_i2s = clk_get(&pdev->dev, "i2s");
+
+ if (IS_ERR(i2s->clk_i2s)) {
+ ret = PTR_ERR(i2s->clk_i2s);
+ goto err_iounmap;
@ -595,6 +586,11 @@ index 0000000..d3daa27
+
+ clk_enable(i2s->clk_aic);
+
+ jz4740_i2c_init_pcm_config(i2s);
+
+ jz4740_i2s_dai.private_data = i2s;
+ ret = snd_soc_register_dai(&jz4740_i2s_dai);
+
+ platform_set_drvdata(pdev, i2s);
+
+ return 0;
@ -679,7 +675,7 @@ index 0000000..da22ed8
+#endif
diff --git a/sound/soc/jz4740/jz4740-pcm.c b/sound/soc/jz4740/jz4740-pcm.c
new file mode 100644
index 0000000..e55ffbf
index 0000000..fd1c203
--- /dev/null
+++ b/sound/soc/jz4740/jz4740-pcm.c
@@ -0,0 +1,350 @@
@ -735,7 +731,7 @@ index 0000000..e55ffbf
+ .rates = SNDRV_PCM_RATE_8000_48000,
+ .channels_min = 1,
+ .channels_max = 2,
+ .period_bytes_min = 32,
+ .period_bytes_min = 16,
+ .period_bytes_max = 2 * PAGE_SIZE,
+ .periods_min = 2,
+ .periods_max = 128,
@ -805,7 +801,7 @@ index 0000000..e55ffbf
+ if (!prtd->dma)
+ return -EBUSY;
+
+ jz4740_dma_configure(prtd->dma, config->dma_config);
+ jz4740_dma_configure(prtd->dma, &config->dma_config);
+ prtd->fifo_addr = config->fifo_addr;
+
+ jz4740_dma_set_complete_cb(prtd->dma, jz4740_pcm_dma_transfer_done);
@ -1035,7 +1031,7 @@ index 0000000..e55ffbf
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/jz4740/jz4740-pcm.h b/sound/soc/jz4740/jz4740-pcm.h
new file mode 100644
index 0000000..2a11800
index 0000000..e3f221e
--- /dev/null
+++ b/sound/soc/jz4740/jz4740-pcm.h
@@ -0,0 +1,22 @@
@ -1056,7 +1052,7 @@ index 0000000..2a11800
+extern struct snd_soc_platform jz4740_soc_platform;
+
+struct jz4740_pcm_config {
+ struct jz4740_dma_config *dma_config;
+ struct jz4740_dma_config dma_config;
+ phys_addr_t fifo_addr;
+};
+