Skip to contentSkip to conversation

mpc5200 audio rework for AC97

PATCH Applied Jon Smirl 3 participants 31 messages May 14, 2009

Subsystems (7)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Jon Smirl

author
#0 lore raw

cover mpc5200 audio rework for AC97

The following series implements audio support for the mpc5200. It adds an AC97 driver and STAC9766 codec driver. Board support for the Efika and Phytec pcm030 are also included. I'm sure everyone will have some edits on this first version.

---

Jon Smirl (13):
Support for AC97 on Phytec pmc030 base board. Fabric bindings for STAC9766 on the Efika
AC97 driver for mpc5200
Codec for STAC9766 used on the Efika
Main rewite of the mpc5200 audio DMA code
Have the WM9712 driver self register itself
Add SNDRV_PCM_FMTBIT_S32_BE as a valid AC97 format Allow a custom ASOC fabric driver with soc-of-simple Add a few more mpc5200 PSC defines
redo 2008f137e92220b98120c4803499cdddb2b0fb06 Rename the PSC functions to DMA
Basic split of mpc5200 DMA code out from mpc5200_psc_i2s Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06

 arch/powerpc/boot/dts/pcm030.dts       |    8 
 arch/powerpc/include/asm/mpc52xx_psc.h |   10 
 arch/powerpc/platforms/52xx/efika.c    |    8 
 include/sound/soc-dai.h                |    3 
 include/sound/soc-of-simple.h          |   16 +
 sound/last.c                           |    6 
 sound/soc/codecs/Kconfig               |    4 
 sound/soc/codecs/Makefile              |    2 
 sound/soc/codecs/stac9766.c            |  491 ++++++++++++++++++++++
 sound/soc/codecs/stac9766.h            |   21 +
 sound/soc/codecs/tlv320aic26.c         |    2 
 sound/soc/codecs/wm9712.c              |   34 ++
 sound/soc/fsl/Kconfig                  |   30 +
 sound/soc/fsl/Makefile                 |    6 
 sound/soc/fsl/efika-audio-fabric.c     |   95 ++++
 sound/soc/fsl/mpc5200_dma.c            |  693 +++++++++++++++++++++++++++++++
 sound/soc/fsl/mpc5200_dma.h            |   83 ++++
 sound/soc/fsl/mpc5200_psc_ac97.c       |  379 +++++++++++++++++
 sound/soc/fsl/mpc5200_psc_ac97.h       |   13 +
 sound/soc/fsl/mpc5200_psc_i2s.c        |  707 +-------------------------------
 sound/soc/fsl/soc-of-simple.c          |  160 ++++++-
 21 files changed, 2053 insertions(+), 718 deletions(-)
 create mode 100644 sound/soc/codecs/stac9766.c
 create mode 100644 sound/soc/codecs/stac9766.h
 create mode 100644 sound/soc/fsl/efika-audio-fabric.c
 create mode 100644 sound/soc/fsl/mpc5200_dma.c
 create mode 100644 sound/soc/fsl/mpc5200_dma.h
 create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c
 create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h
Signature · 2 lines
Jon Smirl
[email protected]
author
#1 lore raw

PATCH 1/13 Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06

Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06 in sound/soc/fsl/mpc5200_psc_i2s.c so that it won't interfere with following patches that split mpc5200_psc_i2s.c.

---
 sound/soc/fsl/mpc5200_psc_i2s.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
sound/soc/fsl/mpc5200_psc_i2s.c +1 -2
index 1111c71..3aa729d 100644
@@ -504,8 +504,7 @@ static struct snd_soc_dai psc_i2s_dai_template = {
 
 static const struct snd_pcm_hardware psc_i2s_pcm_hardware = {
 	.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-		SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
-		SNDRV_PCM_INFO_BATCH,
+		SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER,
 	.formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |
 		   SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE,
 	.rate_min = 8000,
#2 lore raw

Re: [PATCH V1 01/13] Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06

Quoted 1 line · Jon Smirl

Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06 in sound/soc/fsl/mpc5200_psc_i2s.c so that it won't interfere with following patches that split mpc5200_psc_i2s.c.

I'm fairly sure it's possible to squash these in with the other two patches but I guess it's not the end of the world :(

author
#3 lore raw

Re: [PATCH V1 01/13] Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06

Quoted 7 lines · Mark Brown
Quoted 1 line · Jon Smirl

Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06 in sound/soc/fsl/mpc5200_psc_i2s.c so that it won't interfere with following patches that split mpc5200_psc_i2s.c.

I'm fairly sure it's possible to squash these in with the other two patches but I guess it's not the end of the world :(

You and I can easily see how this patch can be folded into the next one. Git is broken in this situation. I've reported the issue to the git people and they acknowledge it, but no one has fixed it. Git's merge strategy does not handle the case of a file splitting. When git tries to merge this one-liner into the next patch that splits the files, it does the merge wrong which then messes up the entire patch stack.

Signature · 2 lines
Jon Smirl
[email protected]
#4 lore raw

Re: [PATCH V1 01/13] Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06

Quoted 7 lines · Jon Smirl

You and I can easily see how this patch can be folded into the next one. Git is broken in this situation. I've reported the issue to the git people and they acknowledge it, but no one has fixed it. Git's merge strategy does not handle the case of a file splitting. When git tries to merge this one-liner into the next patch that splits the files, it does the merge wrong which then messes up the entire patch stack.

It should be possible to do the relevant thing by hand - it's only a one line change you're staging out. Like I say, not the end of the world anyway.

author
#5 lore raw

Re: [PATCH V1 01/13] Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06

Quoted 10 lines · Mark Brown
Quoted 7 lines · Jon Smirl

You and I can easily see how this patch can be folded into the next one. Git is broken in this situation. I've reported the issue to the git people and they acknowledge it, but no one has fixed it. Git's merge strategy does not handle the case of a file splitting. When git tries to merge this one-liner into the next patch that splits the files, it does the merge wrong which then messes up the entire patch stack.

Quoted 3 lines

It should be possible to do the relevant thing by hand - it's only a one line change you're staging out. Like I say, not the end of the world anyway.

I manually edited the diff files to fix this. That not something I like to do because it is too easy to make mistakes. Once they were edited I could feed them back into git. This is the second time I've hit this problem in git.

Signature · 2 lines
Jon Smirl
[email protected]
author
#6 lore raw

PATCH 2/13 Basic split of mpc5200 DMA code out from mpc5200_psc_i2s

In reply to Jon Smirl

Basic split of mpc5200 DMA code out from i2s into a standalone file.

---
 sound/soc/fsl/Kconfig           |    4 
 sound/soc/fsl/Makefile          |    2 
 sound/soc/fsl/mpc5200_dma.c     |  457 +++++++++++++++++++++++++++++++++++++
 sound/soc/fsl/mpc5200_dma.h     |   81 +++++++
 sound/soc/fsl/mpc5200_psc_i2s.c |  484 ---------------------------------------
 5 files changed, 546 insertions(+), 482 deletions(-)
 create mode 100644 sound/soc/fsl/mpc5200_dma.c
 create mode 100644 sound/soc/fsl/mpc5200_dma.h
sound/soc/fsl/Kconfig +4 -0
index 9fc9082..dc79bdf 100644
@@ -1,5 +1,8 @@
 config SND_SOC_OF_SIMPLE
 	tristate
+	
+config SND_MPC52xx_DMA
+	tristate
 
 # ASoC platform support for the Freescale MPC8610 SOC.  This compiles drivers
 # for the SSI and the Elo DMA controller.  You will still need to select
@@ -23,6 +26,7 @@ config SND_SOC_MPC5200_I2S
 	tristate "Freescale MPC5200 PSC in I2S mode driver"
 	depends on PPC_MPC52xx && PPC_BESTCOMM
 	select SND_SOC_OF_SIMPLE
+	select SND_MPC52xx_DMA
 	select PPC_BESTCOMM_GEN_BD
 	help
 	  Say Y here to support the MPC5200 PSCs in I2S mode.
sound/soc/fsl/Makefile +2 -0
index f85134c..7731ef2 100644
@@ -10,5 +10,7 @@ snd-soc-fsl-ssi-objs := fsl_ssi.o
 snd-soc-fsl-dma-objs := fsl_dma.o
 obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o
 
+# MPC5200 Platform Support
+obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o
 obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o
 
sound/soc/fsl/mpc5200_dma.c new file +457 -0

457 lines not on this page · raw message

sound/soc/fsl/mpc5200_dma.h new file +81 -0

81 lines not on this page · raw message

sound/soc/fsl/mpc5200_psc_i2s.c +2 -482

507 lines not on this page · raw message

author
#7 lore raw

PATCH 3/13 Rename the PSC functions to DMA

In reply to Jon Smirl

Rename the functions in the mpc5200 DMA file from i2s based names to dma ones to reflect the file they are in.

---
 sound/soc/fsl/mpc5200_dma.c     |  194 ++++++++++++++++++++-------------------
 sound/soc/fsl/mpc5200_dma.h     |   26 +++--
 sound/soc/fsl/mpc5200_psc_i2s.c |  160 ++++++++++++++++----------------
 3 files changed, 190 insertions(+), 190 deletions(-)
sound/soc/fsl/mpc5200_dma.c +97 -97
index cccaff4..c82ef75 100644
@@ -34,21 +34,21 @@ MODULE_LICENSE("GPL");
 /*
  * Interrupt handlers
  */
-static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s)
+static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma)
 {
-	struct psc_i2s *psc_i2s = _psc_i2s;
-	struct mpc52xx_psc __iomem *regs = psc_i2s->psc_regs;
+	struct psc_dma *psc_dma = _psc_dma;
+	struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs;
 	u16 isr;
 
 	isr = in_be16(&regs->mpc52xx_psc_isr);
 
 	/* Playback underrun error */
-	if (psc_i2s->playback.active && (isr & MPC52xx_PSC_IMR_TXEMP))
-		psc_i2s->stats.underrun_count++;
+	if (psc_dma->playback.active && (isr & MPC52xx_PSC_IMR_TXEMP))
+		psc_dma->stats.underrun_count++;
 
 	/* Capture overrun error */
-	if (psc_i2s->capture.active && (isr & MPC52xx_PSC_IMR_ORERR))
-		psc_i2s->stats.overrun_count++;
+	if (psc_dma->capture.active && (isr & MPC52xx_PSC_IMR_ORERR))
+		psc_dma->stats.overrun_count++;
 
 	out_8(&regs->command, 4 << 4);	/* reset the error status */
 
@@ -56,7 +56,7 @@ static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s)
 }
 
 /**
- * psc_i2s_bcom_enqueue_next_buffer - Enqueue another audio buffer
+ * psc_dma_bcom_enqueue_next_buffer - Enqueue another audio buffer
  * @s: pointer to stream private data structure
  *
  * Enqueues another audio period buffer into the bestcomm queue.
@@ -65,7 +65,7 @@ static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s)
  * the queue.  Otherwise the enqueue will fail and the audio ring buffer
  * will get out of sync
  */
-static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s)
+static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s)
 {
 	struct bcom_bd *bd;
 
@@ -82,9 +82,9 @@ static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s)
 }
 
 /* Bestcomm DMA irq handler */
-static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream)
+static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream)
 {
-	struct psc_i2s_stream *s = _psc_i2s_stream;
+	struct psc_dma_stream *s = _psc_dma_stream;
 
 	/* For each finished period, dequeue the completed period buffer
 	 * and enqueue a new one in it's place. */
@@ -93,7 +93,7 @@ static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream)
 		s->period_current_pt += s->period_bytes;
 		if (s->period_current_pt >= s->period_end)
 			s->period_current_pt = s->period_start;
-		psc_i2s_bcom_enqueue_next_buffer(s);
+		psc_dma_bcom_enqueue_next_buffer(s);
 		bcom_enable(s->bcom_task);
 	}
 
@@ -106,39 +106,39 @@ static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream)
 }
 
 /**
- * psc_i2s_startup: create a new substream
+ * psc_dma_startup: create a new substream
  *
  * This is the first function called when a stream is opened.
  *
  * If this is the first stream open, then grab the IRQ and program most of
  * the PSC registers.
  */
-int psc_i2s_startup(struct snd_pcm_substream *substream,
+int psc_dma_startup(struct snd_pcm_substream *substream,
 			   struct snd_soc_dai *dai)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data;
+	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
 	int rc;
 
-	dev_dbg(psc_i2s->dev, "psc_i2s_startup(substream=%p)\n", substream);
+	dev_dbg(psc_dma->dev, "psc_dma_startup(substream=%p)\n", substream);
 
-	if (!psc_i2s->playback.active &&
-	    !psc_i2s->capture.active) {
+	if (!psc_dma->playback.active &&
+	    !psc_dma->capture.active) {
 		/* Setup the IRQs */
-		rc = request_irq(psc_i2s->irq, &psc_i2s_status_irq, IRQF_SHARED,
-				 "psc-i2s-status", psc_i2s);
-		rc |= request_irq(psc_i2s->capture.irq,
-				  &psc_i2s_bcom_irq, IRQF_SHARED,
-				  "psc-i2s-capture", &psc_i2s->capture);
-		rc |= request_irq(psc_i2s->playback.irq,
-				  &psc_i2s_bcom_irq, IRQF_SHARED,
-				  "psc-i2s-playback", &psc_i2s->playback);
+		rc = request_irq(psc_dma->irq, &psc_dma_status_irq, IRQF_SHARED,
+				 "psc-dma-status", psc_dma);
+		rc |= request_irq(psc_dma->capture.irq,
+				  &psc_dma_bcom_irq, IRQF_SHARED,
+				  "psc-dma-capture", &psc_dma->capture);
+		rc |= request_irq(psc_dma->playback.irq,
+				  &psc_dma_bcom_irq, IRQF_SHARED,
+				  "psc-dma-playback", &psc_dma->playback);
 		if (rc) {
-			free_irq(psc_i2s->irq, psc_i2s);
-			free_irq(psc_i2s->capture.irq,
-				 &psc_i2s->capture);
-			free_irq(psc_i2s->playback.irq,
-				 &psc_i2s->playback);
+			free_irq(psc_dma->irq, psc_dma);
+			free_irq(psc_dma->capture.irq,
+				 &psc_dma->capture);
+			free_irq(psc_dma->playback.irq,
+				 &psc_dma->playback);
 			return -ENODEV;
 		}
 	}
@@ -146,7 +146,7 @@ int psc_i2s_startup(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-int psc_i2s_hw_free(struct snd_pcm_substream *substream,
+int psc_dma_hw_free(struct snd_pcm_substream *substream,
 			   struct snd_soc_dai *dai)
 {
 	snd_pcm_set_runtime_buffer(substream, NULL);
@@ -154,29 +154,29 @@ int psc_i2s_hw_free(struct snd_pcm_substream *substream,
 }
 
 /**
- * psc_i2s_trigger: start and stop the DMA transfer.
+ * psc_dma_trigger: start and stop the DMA transfer.
  *
  * This function is called by ALSA to start, stop, pause, and resume the DMA
  * transfer of data.
  */
-int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
+int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
 			   struct snd_soc_dai *dai)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data;
+	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
 	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct psc_i2s_stream *s;
-	struct mpc52xx_psc __iomem *regs = psc_i2s->psc_regs;
+	struct psc_dma_stream *s;
+	struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs;
 	u16 imr;
 	u8 psc_cmd;
 	unsigned long flags;
 
 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
-		s = &psc_i2s->capture;
+		s = &psc_dma->capture;
 	else
-		s = &psc_i2s->playback;
+		s = &psc_dma->playback;
 
-	dev_dbg(psc_i2s->dev, "psc_i2s_trigger(substream=%p, cmd=%i)"
+	dev_dbg(psc_dma->dev, "psc_dma_trigger(substream=%p, cmd=%i)"
 		" stream_id=%i\n",
 		substream, cmd, substream->pstr->stream);
 
@@ -207,14 +207,14 @@ int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 		else
 			bcom_gen_bd_tx_reset(s->bcom_task);
 		while (!bcom_queue_full(s->bcom_task))
-			psc_i2s_bcom_enqueue_next_buffer(s);
+			psc_dma_bcom_enqueue_next_buffer(s);
 		bcom_enable(s->bcom_task);
 
-		/* Due to errata in the i2s mode; need to line up enabling
+		/* Due to errata in the dma mode; need to line up enabling
 		 * the transmitter with a transition on the frame sync
 		 * line */
 
-		spin_lock_irqsave(&psc_i2s->lock, flags);
+		spin_lock_irqsave(&psc_dma->lock, flags);
 		/* first make sure it is low */
 		while ((in_8(&regs->ipcr_acr.ipcr) & 0x80) != 0)
 			;
@@ -228,7 +228,7 @@ int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 		if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK)
 			psc_cmd |= MPC52xx_PSC_TX_ENABLE;
 		out_8(&regs->command, psc_cmd);
-		spin_unlock_irqrestore(&psc_i2s->lock, flags);
+		spin_unlock_irqrestore(&psc_dma->lock, flags);
 
 		break;
 
@@ -236,7 +236,7 @@ int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 		/* Turn off the PSC */
 		s->active = 0;
 		if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) {
-			if (!psc_i2s->playback.active) {
+			if (!psc_dma->playback.active) {
 				out_8(&regs->command, 2 << 4);	/* reset rx */
 				out_8(&regs->command, 3 << 4);	/* reset tx */
 				out_8(&regs->command, 4 << 4);	/* reset err */
@@ -244,7 +244,7 @@ int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 		} else {
 			out_8(&regs->command, 3 << 4);	/* reset tx */
 			out_8(&regs->command, 4 << 4);	/* reset err */
-			if (!psc_i2s->capture.active)
+			if (!psc_dma->capture.active)
 				out_8(&regs->command, 2 << 4);	/* reset rx */
 		}
 
@@ -255,15 +255,15 @@ int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 		break;
 
 	default:
-		dev_dbg(psc_i2s->dev, "invalid command\n");
+		dev_dbg(psc_dma->dev, "invalid command\n");
 		return -EINVAL;
 	}
 
 	/* Update interrupt enable settings */
 	imr = 0;
-	if (psc_i2s->playback.active)
+	if (psc_dma->playback.active)
 		imr |= MPC52xx_PSC_IMR_TXEMP;
-	if (psc_i2s->capture.active)
+	if (psc_dma->capture.active)
 		imr |= MPC52xx_PSC_IMR_ORERR;
 	out_be16(&regs->isr_imr.imr, imr);
 
@@ -271,36 +271,36 @@ int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 }
 
 /**
- * psc_i2s_shutdown: shutdown the data transfer on a stream
+ * psc_dma_shutdown: shutdown the data transfer on a stream
  *
  * Shutdown the PSC if there are no other substreams open.
  */
-void psc_i2s_shutdown(struct snd_pcm_substream *substream,
+void psc_dma_shutdown(struct snd_pcm_substream *substream,
 			     struct snd_soc_dai *dai)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data;
+	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
 
-	dev_dbg(psc_i2s->dev, "psc_i2s_shutdown(substream=%p)\n", substream);
+	dev_dbg(psc_dma->dev, "psc_dma_shutdown(substream=%p)\n", substream);
 
 	/*
 	 * If this is the last active substream, disable the PSC and release
 	 * the IRQ.
 	 */
-	if (!psc_i2s->playback.active &&
-	    !psc_i2s->capture.active) {
+	if (!psc_dma->playback.active &&
+	    !psc_dma->capture.active) {
 
 		/* Disable all interrupts and reset the PSC */
-		out_be16(&psc_i2s->psc_regs->isr_imr.imr, 0);
-		out_8(&psc_i2s->psc_regs->command, 3 << 4); /* reset tx */
-		out_8(&psc_i2s->psc_regs->command, 2 << 4); /* reset rx */
-		out_8(&psc_i2s->psc_regs->command, 1 << 4); /* reset mode */
-		out_8(&psc_i2s->psc_regs->command, 4 << 4); /* reset error */
+		out_be16(&psc_dma->psc_regs->isr_imr.imr, 0);
+		out_8(&psc_dma->psc_regs->command, 3 << 4); /* reset tx */
+		out_8(&psc_dma->psc_regs->command, 2 << 4); /* reset rx */
+		out_8(&psc_dma->psc_regs->command, 1 << 4); /* reset mode */
+		out_8(&psc_dma->psc_regs->command, 4 << 4); /* reset error */
 
 		/* Release irqs */
-		free_irq(psc_i2s->irq, psc_i2s);
-		free_irq(psc_i2s->capture.irq, &psc_i2s->capture);
-		free_irq(psc_i2s->playback.irq, &psc_i2s->playback);
+		free_irq(psc_dma->irq, psc_dma);
+		free_irq(psc_dma->capture.irq, &psc_dma->capture);
+		free_irq(psc_dma->playback.irq, &psc_dma->playback);
 	}
 }
 
@@ -312,7 +312,7 @@ void psc_i2s_shutdown(struct snd_pcm_substream *substream,
  * interaction with the attached codec
  */
 
-static const struct snd_pcm_hardware psc_i2s_pcm_hardware = {
+static const struct snd_pcm_hardware psc_dma_pcm_hardware = {
 	.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
 		SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER,
 	.formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |
@@ -329,80 +329,80 @@ static const struct snd_pcm_hardware psc_i2s_pcm_hardware = {
 	.fifo_size		= 0,
 };
 
-static int psc_i2s_pcm_open(struct snd_pcm_substream *substream)
+static int psc_dma_pcm_open(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data;
-	struct psc_i2s_stream *s;
+	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
+	struct psc_dma_stream *s;
 
-	dev_dbg(psc_i2s->dev, "psc_i2s_pcm_open(substream=%p)\n", substream);
+	dev_dbg(psc_dma->dev, "psc_dma_pcm_open(substream=%p)\n", substream);
 
 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
-		s = &psc_i2s->capture;
+		s = &psc_dma->capture;
 	else
-		s = &psc_i2s->playback;
+		s = &psc_dma->playback;
 
-	snd_soc_set_runtime_hwparams(substream, &psc_i2s_pcm_hardware);
+	snd_soc_set_runtime_hwparams(substream, &psc_dma_pcm_hardware);
 
 	s->stream = substream;
 	return 0;
 }
 
-static int psc_i2s_pcm_close(struct snd_pcm_substream *substream)
+static int psc_dma_pcm_close(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data;
-	struct psc_i2s_stream *s;
+	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
+	struct psc_dma_stream *s;
 
-	dev_dbg(psc_i2s->dev, "psc_i2s_pcm_close(substream=%p)\n", substream);
+	dev_dbg(psc_dma->dev, "psc_dma_pcm_close(substream=%p)\n", substream);
 
 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
-		s = &psc_i2s->capture;
+		s = &psc_dma->capture;
 	else
-		s = &psc_i2s->playback;
+		s = &psc_dma->playback;
 
 	s->stream = NULL;
 	return 0;
 }
 
 static snd_pcm_uframes_t
-psc_i2s_pcm_pointer(struct snd_pcm_substream *substream)
+psc_dma_pcm_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data;
-	struct psc_i2s_stream *s;
+	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
+	struct psc_dma_stream *s;
 	dma_addr_t count;
 
 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
-		s = &psc_i2s->capture;
+		s = &psc_dma->capture;
 	else
-		s = &psc_i2s->playback;
+		s = &psc_dma->playback;
 
 	count = s->period_current_pt - s->period_start;
 
 	return bytes_to_frames(substream->runtime, count);
 }
 
-static struct snd_pcm_ops psc_i2s_pcm_ops = {
-	.open		= psc_i2s_pcm_open,
-	.close		= psc_i2s_pcm_close,
+static struct snd_pcm_ops psc_dma_pcm_ops = {
+	.open		= psc_dma_pcm_open,
+	.close		= psc_dma_pcm_close,
 	.ioctl		= snd_pcm_lib_ioctl,
-	.pointer	= psc_i2s_pcm_pointer,
+	.pointer	= psc_dma_pcm_pointer,
 };
 
-static u64 psc_i2s_pcm_dmamask = 0xffffffff;
-static int psc_i2s_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
+static u64 psc_dma_pcm_dmamask = 0xffffffff;
+static int psc_dma_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
 			   struct snd_pcm *pcm)
 {
 	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
-	size_t size = psc_i2s_pcm_hardware.buffer_bytes_max;
+	size_t size = psc_dma_pcm_hardware.buffer_bytes_max;
 	int rc = 0;
 
-	dev_dbg(rtd->socdev->dev, "psc_i2s_pcm_new(card=%p, dai=%p, pcm=%p)\n",
+	dev_dbg(rtd->socdev->dev, "psc_dma_pcm_new(card=%p, dai=%p, pcm=%p)\n",
 		card, dai, pcm);
 
 	if (!card->dev->dma_mask)
-		card->dev->dma_mask = &psc_i2s_pcm_dmamask;
+		card->dev->dma_mask = &psc_dma_pcm_dmamask;
 	if (!card->dev->coherent_dma_mask)
 		card->dev->coherent_dma_mask = 0xffffffff;
 
@@ -430,13 +430,13 @@ static int psc_i2s_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
 	return -ENOMEM;
 }
 
-static void psc_i2s_pcm_free(struct snd_pcm *pcm)
+static void psc_dma_pcm_free(struct snd_pcm *pcm)
 {
 	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
 	struct snd_pcm_substream *substream;
 	int stream;
 
-	dev_dbg(rtd->socdev->dev, "psc_i2s_pcm_free(pcm=%p)\n", pcm);
+	dev_dbg(rtd->socdev->dev, "psc_dma_pcm_free(pcm=%p)\n", pcm);
 
 	for (stream = 0; stream < 2; stream++) {
 		substream = pcm->streams[stream].substream;
@@ -448,10 +448,10 @@ static void psc_i2s_pcm_free(struct snd_pcm *pcm)
 	}
 }
 
-struct snd_soc_platform psc_i2s_pcm_soc_platform = {
+struct snd_soc_platform psc_dma_pcm_soc_platform = {
 	.name		= "mpc5200-psc-audio",
-	.pcm_ops	= &psc_i2s_pcm_ops,
-	.pcm_new	= &psc_i2s_pcm_new,
-	.pcm_free	= &psc_i2s_pcm_free,
+	.pcm_ops	= &psc_dma_pcm_ops,
+	.pcm_new	= &psc_dma_pcm_new,
+	.pcm_free	= &psc_dma_pcm_free,
 };
 
sound/soc/fsl/mpc5200_dma.h +13 -13
index 9a19e8a..a33232c 100644
@@ -6,9 +6,9 @@
 #define __SOUND_SOC_FSL_MPC5200_DMA_H__
 
 /**
- * psc_i2s_stream - Data specific to a single stream (playback or capture)
+ * psc_dma_stream - Data specific to a single stream (playback or capture)
  * @active:		flag indicating if the stream is active
- * @psc_i2s:		pointer back to parent psc_i2s data structure
+ * @psc_dma:		pointer back to parent psc_dma data structure
  * @bcom_task:		bestcomm task structure
  * @irq:		irq number for bestcomm task
  * @period_start:	physical address of start of DMA region
@@ -16,9 +16,9 @@
  * @period_next_pt:	physical address of next DMA buffer to enqueue
  * @period_bytes:	size of DMA period in bytes
  */
-struct psc_i2s_stream {
+struct psc_dma_stream {
 	int active;
-	struct psc_i2s *psc_i2s;
+	struct psc_dma *psc_dma;
 	struct bcom_task *bcom_task;
 	int irq;
 	struct snd_pcm_substream *stream;
@@ -30,7 +30,7 @@ struct psc_i2s_stream {
 };
 
 /**
- * psc_i2s - Private driver data
+ * psc_dma - Private driver data
  * @name: short name for this device ("PSC0", "PSC1", etc)
  * @psc_regs: pointer to the PSC's registers
  * @fifo_regs: pointer to the PSC's FIFO registers
@@ -42,7 +42,7 @@ struct psc_i2s_stream {
  * @playback: Playback stream context data
  * @capture: Capture stream context data
  */
-struct psc_i2s {
+struct psc_dma {
 	char name[32];
 	struct mpc52xx_psc __iomem *psc_regs;
 	struct mpc52xx_psc_fifo __iomem *fifo_regs;
@@ -53,8 +53,8 @@ struct psc_i2s {
 	u32 sicr;
 
 	/* per-stream data */
-	struct psc_i2s_stream playback;
-	struct psc_i2s_stream capture;
+	struct psc_dma_stream playback;
+	struct psc_dma_stream capture;
 
 	/* Statistics */
 	struct {
@@ -64,18 +64,18 @@ struct psc_i2s {
 };
 
 
-int psc_i2s_startup(struct snd_pcm_substream *substream,
+int psc_dma_startup(struct snd_pcm_substream *substream,
 			   struct snd_soc_dai *dai);
 
-int psc_i2s_hw_free(struct snd_pcm_substream *substream,
+int psc_dma_hw_free(struct snd_pcm_substream *substream,
 			   struct snd_soc_dai *dai);
 
-void psc_i2s_shutdown(struct snd_pcm_substream *substream,
+void psc_dma_shutdown(struct snd_pcm_substream *substream,
 			     struct snd_soc_dai *dai);
 
-int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
+int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
 			   struct snd_soc_dai *dai);
 
-extern struct snd_soc_platform psc_i2s_pcm_soc_platform;
+extern struct snd_soc_platform psc_dma_pcm_soc_platform;
 
 #endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */
sound/soc/fsl/mpc5200_psc_i2s.c +80 -80

288 lines not on this page · raw message

#8 lore raw

Re: [PATCH V1 03/13] Rename the PSC functions to DMA

Quoted 3 lines · Jon Smirl

Rename the functions in the mpc5200 DMA file from i2s based names to dma ones to reflect the file they are in.

I'm OK with these if Grant is?

author
#9 lore raw

PATCH 4/13 redo 2008f137e92220b98120c4803499cdddb2b0fb06

In reply to Jon Smirl

Reapply the changes from 2008f137e92220b98120c4803499cdddb2b0fb06 to mpc5200_dma.c since the code effected by this change moved to a different file.

---
 sound/soc/fsl/mpc5200_dma.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
sound/soc/fsl/mpc5200_dma.c +2 -1
index c82ef75..6850392 100644
@@ -314,7 +314,8 @@ void psc_dma_shutdown(struct snd_pcm_substream *substream,
 
 static const struct snd_pcm_hardware psc_dma_pcm_hardware = {
 	.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-		SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER,
+		SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
+		SNDRV_PCM_INFO_BATCH,
 	.formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |
 		   SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE,
 	.rate_min = 8000,
author
#10 lore raw

PATCH 5/13 Add a few more mpc5200 PSC defines

In reply to Jon Smirl

Add a few more mpc5200 PSC defines. More bit fields defines for mpc5200 PSC registers

---
 arch/powerpc/include/asm/mpc52xx_psc.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/mpc52xx_psc.h +10 -0
index a218da6..c323f4f 100644
@@ -28,6 +28,10 @@
 #define MPC52xx_PSC_MAXNUM	6
 
 /* Programmable Serial Controller (PSC) status register bits */
+#define MPC52xx_PSC_SR_UNEX_RX	0x0001
+#define MPC52xx_PSC_SR_DATA_VAL	0x0002
+#define MPC52xx_PSC_SR_DATA_OVR	0x0004
+#define MPC52xx_PSC_SR_CMDSEND	0x0008
 #define MPC52xx_PSC_SR_CDE	0x0080
 #define MPC52xx_PSC_SR_RXRDY	0x0100
 #define MPC52xx_PSC_SR_RXFULL	0x0200
@@ -61,6 +65,12 @@
 #define MPC52xx_PSC_RXTX_FIFO_EMPTY	0x0001
 
 /* PSC interrupt status/mask bits */
+#define MPC52xx_PSC_IMR_UNEX_RX_SLOT 0x0001
+#define MPC52xx_PSC_IMR_DATA_VALID	0x0002
+#define MPC52xx_PSC_IMR_DATA_OVR	0x0004
+#define MPC52xx_PSC_IMR_CMD_SEND	0x0008
+#define MPC52xx_PSC_IMR_ERROR		0x0040
+#define MPC52xx_PSC_IMR_DEOF		0x0080
 #define MPC52xx_PSC_IMR_TXRDY		0x0100
 #define MPC52xx_PSC_IMR_RXRDY		0x0200
 #define MPC52xx_PSC_IMR_DB		0x0400
#11 lore raw

Re: [PATCH V1 05/13] Add a few more mpc5200 PSC defines

Quoted 3 lines · Jon Smirl

Add a few more mpc5200 PSC defines. More bit fields defines for mpc5200 PSC registers

This is OK too, providing the PowerPC guys are happy with merging it via ALSA.

author
#12 lore raw

PATCH 6/13 Allow a custom ASOC fabric driver with soc-of-simple

In reply to Jon Smirl

Allow a custom ASOC fabric driver with soc-of-simple. Register multiple DAIs. If no custom fabric driver, supply a default one so that ASOC binding will complete.

---
 include/sound/soc-of-simple.h   |   16 +++-
 sound/last.c                    |    6 +
 sound/soc/codecs/tlv320aic26.c  |    2 
 sound/soc/fsl/Kconfig           |    2 
 sound/soc/fsl/mpc5200_psc_i2s.c |    4 -
 sound/soc/fsl/soc-of-simple.c   |  160 ++++++++++++++++++++++++++++++++-------
 6 files changed, 154 insertions(+), 36 deletions(-)
include/sound/soc-of-simple.h +12 -4
index a064e19..97d04af 100644
@@ -12,13 +12,21 @@
 #include <linux/of.h>
 #include <sound/soc.h>
 
+#define SOC_OF_SIMPLE_MAX_DAI 2
+
 int of_snd_soc_register_codec(struct snd_soc_codec_device *codec_dev,
 			      void *codec_data, struct snd_soc_dai *dai,
-			      struct device_node *node);
+			      int count, struct device_node *node);
+
+int of_snd_soc_register_cpu_dai(struct device_node *node,
+				 struct snd_soc_dai *cpu_dai, int count);
+
+int of_snd_soc_register_platform(struct snd_soc_platform *platform);
+
+int of_snd_soc_register_fabric(const char *name, struct snd_soc_ops *ops,
+								int (*init)(struct snd_soc_codec *codec));
 
-int of_snd_soc_register_platform(struct snd_soc_platform *platform,
-				 struct device_node *node,
-				 struct snd_soc_dai *cpu_dai);
+int of_snd_soc_register_default_fabric(void);
 
 #endif
 
sound/last.c +5 -1
index bdd0857..b6efece 100644
@@ -22,11 +22,15 @@
 #define SNDRV_MAIN_OBJECT_FILE
 #include <linux/init.h>
 #include <sound/core.h>
+#include <sound/soc-of-simple.h>
 
 static int __init alsa_sound_last_init(void)
 {
 	int idx, ok = 0;
-	
+
+#if defined(CONFIG_SND_SOC_OF_SIMPLE)
+	of_snd_soc_register_default_fabric();
+#endif 	
 	printk(KERN_INFO "ALSA device list:\n");
 	for (idx = 0; idx < SNDRV_CARDS; idx++)
 		if (snd_cards[idx] != NULL) {
sound/soc/codecs/tlv320aic26.c +1 -1
index 3387d9e..95a7ac9 100644
@@ -487,7 +487,7 @@ static int aic26_spi_probe(struct spi_device *spi)
 
 #if defined(CONFIG_SND_SOC_OF_SIMPLE)
 	/* Tell the of_soc helper about this codec */
-	of_snd_soc_register_codec(&aic26_soc_codec_dev, aic26, &aic26_dai,
+	of_snd_soc_register_codec(&aic26_soc_codec_dev, aic26, &aic26_dai, 1,
 				  spi->dev.archdata.of_node);
 #endif
 
sound/soc/fsl/Kconfig +1 -1
index dc79bdf..8060b95 100644
@@ -1,5 +1,5 @@
 config SND_SOC_OF_SIMPLE
-	tristate
+	bool
 	
 config SND_MPC52xx_DMA
 	tristate
sound/soc/fsl/mpc5200_psc_i2s.c +2 -2
index 12a7917..5dbf1bc 100644
@@ -353,8 +353,8 @@ static int __devinit psc_i2s_of_probe(struct of_device *op,
 	snd_soc_register_platform(&psc_dma_pcm_soc_platform);
 
 	/* Tell the ASoC OF helpers about it */
-	of_snd_soc_register_platform(&psc_dma_pcm_soc_platform, op->node,
-				     &psc_dma->dai);
+	of_snd_soc_register_platform(&mpc5200_audio_dma_platform);
+	of_snd_soc_register_cpu_dai(op->node, &psc_dma->dai, 1);
 
 	return 0;
 }
sound/soc/fsl/soc-of-simple.c +133 -27

226 lines not on this page · raw message

#13 lore raw

Re: [PATCH V1 06/13] Allow a custom ASOC fabric driver with soc-of-simple

Quoted 1 line · Jon Smirl

Allow a custom ASOC fabric driver with soc-of-simple. Register multiple DAIs. If no custom fabric driver, supply a default one so that ASOC binding will complete.

Hrm. I'm not sure the way you're providing a default behaviour here is going to work (see comments below). Would it not be better to have something in the OF tree that specifies non-default behaviour? Obviously that opens the whole can of worms with OpenFirmware not being able to cope with machine drivers well, though that's probably going to have to be dealt with at some point.

Also, note that it's spelt 'ASoC'. I'm fairly sure I've mentioned this to you before.

Review

Quoted 2 lines
(quoted diff) +2 -0
+#define SOC_OF_SIMPLE_MAX_DAI 2
+

Why not make this dynamic? It's also surprising to see this in the header, it should be an implementation detail.

include/sound/soc-of-simple.h line 23

Quoted 3 lines
include/sound/soc-of-simple.h +3 -0
+int of_snd_soc_register_cpu_dai(struct device_node *node,
+				 struct snd_soc_dai *cpu_dai, int count);
+

ASoC is moving towards having all DAIs register equivalently. Might be as well to consider supporting this here too, though the core isn't quite there yet.

sound/last.c line 33

Quoted 12 lines
sound/last.c +6 -1
+int of_snd_soc_register_default_fabric(void);
 
+#include <sound/soc-of-simple.h>
 
 static int __init alsa_sound_last_init(void)
 {
 	int idx, ok = 0;
-	
+
+#if defined(CONFIG_SND_SOC_OF_SIMPLE)
+	of_snd_soc_register_default_fabric();
+#endif 	

This approach relies on having things built in or being able to load the modules before the alsa_sound_last_init() is called. That's not something that's going to be reliably doable for all systems - netbooted development systems are a common example here.

sound/soc/codecs/tlv320aic26.c static int aic26_spi_probe(struct spi_device *spi) · line 492

Quoted 6 lines

#if defined(CONFIG_SND_SOC_OF_SIMPLE)

sound/soc/codecs/tlv320aic26.c +1 -1
 	/* Tell the of_soc helper about this codec */
-	of_snd_soc_register_codec(&aic26_soc_codec_dev, aic26, &aic26_dai,
+	of_snd_soc_register_codec(&aic26_soc_codec_dev, aic26, &aic26_dai, 1,
 				  spi->dev.archdata.of_node);
 #endif

If, as previously discussed, this were merged with the core you could pick most of this data out of the snd_soc_codec.

sound/soc/fsl/soc-of-simple.c of_snd_soc_get_device(struct device_node *codec_node) · line 73

Quoted 1 line
sound/soc/fsl/soc-of-simple.c +1 -0
+	of_soc->card.name = (char *)template_name;

This cast is suspect..

sound/soc/fsl/soc-of-simple.c static void of_snd_soc_register_device(struct of_snd_soc_device *of_soc) · line 89

Quoted 3 lines
sound/soc/fsl/soc-of-simple.c +2 -1
-	if ((!of_soc->device.codec_data) || (!of_soc->platform_node))
+	if ((!of_soc->device.codec_data) || (!of_soc->cpu_dai_node) ||
+									!of_soc->card.platform || !of_soc->card.name)

Looks like something went very wrong with the indentation here.

sound/soc/fsl/soc-of-simple.c int of_snd_soc_register_platform(struct snd_soc_platform *platform, · line 223

Quoted 1 line
sound/soc/fsl/soc-of-simple.c +1 -0
+	pr_info("registering ASoC platform driver: %s\n", platform->name);

pr_debug().

author
#14 lore raw

PATCH 7/13 Add SNDRV_PCM_FMTBIT_S32_BE as a valid AC97 format

In reply to Jon Smirl

Add SNDRV_PCM_FMTBIT_S32_BE as a valid AC97 format

---
 include/sound/soc-dai.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/sound/soc-dai.h +2 -1
index 496dc30..352d7ee 100644
@@ -79,7 +79,8 @@ struct snd_pcm_substream;
 #define SND_SOC_CLOCK_OUT		1
 
 #define SND_SOC_STD_AC97_FMTS (SNDRV_PCM_FMTBIT_S16_LE |\
-                               SNDRV_PCM_FMTBIT_S32_LE)
+                               SNDRV_PCM_FMTBIT_S32_LE |\
+                               SNDRV_PCM_FMTBIT_S32_BE)
 
 struct snd_soc_dai_ops;
 struct snd_soc_dai;
Applied
#15 lore raw

Re: [PATCH V1 07/13] Add SNDRV_PCM_FMTBIT_S32_BE as a valid AC97 format

Quoted 3 lines · Jon Smirl

Add SNDRV_PCM_FMTBIT_S32_BE as a valid AC97 format

Applied, thanks.

author
#16 lore raw

PATCH 8/13 Have the WM9712 driver self register itself

In reply to Jon Smirl

Have the WM9712 driver self register itself. This is needed to support device tree driver binding via the soc_of_simple code.

---
 sound/soc/codecs/wm9712.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
sound/soc/codecs/wm9712.c +34 -0
index 550c903..cb0e679 100644
@@ -20,6 +20,7 @@
 #include <sound/initval.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
+#include <sound/soc-of-simple.h>
 #include "wm9712.h"
 
 #define WM9712_VERSION "0.4"
@@ -740,6 +741,39 @@ struct snd_soc_codec_device soc_codec_dev_wm9712 = {
 };
 EXPORT_SYMBOL_GPL(soc_codec_dev_wm9712);
 
+static int __init wm9712_probe(struct platform_device *pdev)
+{
+	snd_soc_register_dais(wm9712_dai, ARRAY_SIZE(wm9712_dai));
+#if defined(CONFIG_SND_SOC_OF_SIMPLE)
+	/* Tell the of_soc helper about this codec */
+	of_snd_soc_register_codec(&soc_codec_dev_wm9712, pdev->dev.archdata.of_node,
+									wm9712_dai, ARRAY_SIZE(wm9712_dai),
+									pdev->dev.archdata.of_node);
+#endif
+	return 0;
+}
+
+static struct platform_driver wm9712_driver =
+{
+	.probe = wm9712_probe,
+	.driver = {
+			.name = "wm9712",
+	},
+};
+
+static __init int wm9712_driver_init(void)
+{
+	return platform_driver_register(&wm9712_driver);
+}
+
+static __exit void wm9712_driver_exit(void)
+{
+}
+
+module_init(wm9712_driver_init);
+module_exit(wm9712_driver_exit);
+
+
 MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver");
 MODULE_AUTHOR("Liam Girdwood");
 MODULE_LICENSE("GPL");
#17 lore raw

Re: [PATCH V1 08/13] Have the WM9712 driver self register itself

Quoted 3 lines · Jon Smirl

Have the WM9712 driver self register itself. This is needed to support device tree driver binding via the soc_of_simple code.

All the comments I made when you posted this earlier yesterday continue to apply.

author
#18 lore raw

PATCH 9/13 Main rewite of the mpc5200 audio DMA code

In reply to Jon Smirl

Rewrite the mpc5200 audio DMA code to support both I2S and AC97. Make it more robust.

---
 sound/soc/fsl/mpc5200_dma.c     |  503 +++++++++++++++++++++++++++++----------
 sound/soc/fsl/mpc5200_dma.h     |   32 +-
 sound/soc/fsl/mpc5200_psc_i2s.c |  198 +--------------
 3 files changed, 396 insertions(+), 337 deletions(-)
sound/soc/fsl/mpc5200_dma.c +369 -134
index 6850392..5ac2693 100644
@@ -23,6 +23,8 @@
 
 #include <sysdev/bestcomm/bestcomm.h>
 #include <sysdev/bestcomm/gen_bd.h>
+#include <asm/time.h>
+#include <asm/mpc52xx.h>
 #include <asm/mpc52xx_psc.h>
 
 #include "mpc5200_dma.h"
@@ -50,7 +52,7 @@ static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma)
 	if (psc_dma->capture.active && (isr & MPC52xx_PSC_IMR_ORERR))
 		psc_dma->stats.overrun_count++;
 
-	out_8(&regs->command, 4 << 4);	/* reset the error status */
+	out_8(&regs->command, MPC52xx_PSC_RST_ERR_STAT);
 
 	return IRQ_HANDLED;
 }
@@ -81,8 +83,21 @@ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s)
 		s->period_next_pt = s->period_start;
 }
 
+static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s)
+{
+	while (s->appl_ptr < s->runtime->control->appl_ptr) {
+
+		if (bcom_queue_full(s->bcom_task))
+			return;
+
+		s->appl_ptr += s->period_size;
+
+		psc_dma_bcom_enqueue_next_buffer(s);
+	}
+}
+
 /* Bestcomm DMA irq handler */
-static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream)
+static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream)
 {
 	struct psc_dma_stream *s = _psc_dma_stream;
 
@@ -90,12 +105,12 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream)
 	 * and enqueue a new one in it's place. */
 	while (bcom_buffer_done(s->bcom_task)) {
 		bcom_retrieve_buffer(s->bcom_task, NULL, NULL);
+
 		s->period_current_pt += s->period_bytes;
 		if (s->period_current_pt >= s->period_end)
 			s->period_current_pt = s->period_start;
-		psc_dma_bcom_enqueue_next_buffer(s);
-		bcom_enable(s->bcom_task);
 	}
+	psc_dma_bcom_enqueue_tx(s);
 
 	/* If the stream is active, then also inform the PCM middle layer
 	 * of the period finished event. */
@@ -105,49 +120,31 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream)
 	return IRQ_HANDLED;
 }
 
-/**
- * psc_dma_startup: create a new substream
- *
- * This is the first function called when a stream is opened.
- *
- * If this is the first stream open, then grab the IRQ and program most of
- * the PSC registers.
- */
-int psc_dma_startup(struct snd_pcm_substream *substream,
-			   struct snd_soc_dai *dai)
+static irqreturn_t psc_dma_bcom_irq_rx(int irq, void *_psc_dma_stream)
 {
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
-	int rc;
+	struct psc_dma_stream *s = _psc_dma_stream;
 
-	dev_dbg(psc_dma->dev, "psc_dma_startup(substream=%p)\n", substream);
+	/* For each finished period, dequeue the completed period buffer
+	 * and enqueue a new one in it's place. */
+	while (bcom_buffer_done(s->bcom_task)) {
+		bcom_retrieve_buffer(s->bcom_task, NULL, NULL);
 
-	if (!psc_dma->playback.active &&
-	    !psc_dma->capture.active) {
-		/* Setup the IRQs */
-		rc = request_irq(psc_dma->irq, &psc_dma_status_irq, IRQF_SHARED,
-				 "psc-dma-status", psc_dma);
-		rc |= request_irq(psc_dma->capture.irq,
-				  &psc_dma_bcom_irq, IRQF_SHARED,
-				  "psc-dma-capture", &psc_dma->capture);
-		rc |= request_irq(psc_dma->playback.irq,
-				  &psc_dma_bcom_irq, IRQF_SHARED,
-				  "psc-dma-playback", &psc_dma->playback);
-		if (rc) {
-			free_irq(psc_dma->irq, psc_dma);
-			free_irq(psc_dma->capture.irq,
-				 &psc_dma->capture);
-			free_irq(psc_dma->playback.irq,
-				 &psc_dma->playback);
-			return -ENODEV;
-		}
+		s->period_current_pt += s->period_bytes;
+		if (s->period_current_pt >= s->period_end)
+			s->period_current_pt = s->period_start;
+
+		psc_dma_bcom_enqueue_next_buffer(s);
 	}
 
-	return 0;
+	/* If the stream is active, then also inform the PCM middle layer
+	 * of the period finished event. */
+	if (s->active)
+		snd_pcm_period_elapsed(s->stream);
+
+	return IRQ_HANDLED;
 }
 
-int psc_dma_hw_free(struct snd_pcm_substream *substream,
-			   struct snd_soc_dai *dai)
+static int psc_dma_hw_free(struct snd_pcm_substream *substream)
 {
 	snd_pcm_set_runtime_buffer(substream, NULL);
 	return 0;
@@ -159,8 +156,7 @@ int psc_dma_hw_free(struct snd_pcm_substream *substream,
  * This function is called by ALSA to start, stop, pause, and resume the DMA
  * transfer of data.
  */
-int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
-			   struct snd_soc_dai *dai)
+static int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
@@ -170,6 +166,7 @@ int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
 	u16 imr;
 	u8 psc_cmd;
 	unsigned long flags;
+	int i;
 
 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
 		s = &psc_dma->capture;
@@ -189,25 +186,24 @@ int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
 				(s->period_bytes * runtime->periods);
 		s->period_next_pt = s->period_start;
 		s->period_current_pt = s->period_start;
+		s->period_size = runtime->period_size;
 		s->active = 1;
 
-		/* First; reset everything */
-		if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) {
-			out_8(&regs->command, MPC52xx_PSC_RST_RX);
-			out_8(&regs->command, MPC52xx_PSC_RST_ERR_STAT);
-		} else {
-			out_8(&regs->command, MPC52xx_PSC_RST_TX);
-			out_8(&regs->command, MPC52xx_PSC_RST_ERR_STAT);
-		}
+		s->runtime = runtime;
+		s->appl_ptr = s->runtime->control->appl_ptr - (runtime->period_size * runtime->periods);
 
-		/* Next, fill up the bestcomm bd queue and enable DMA.
+		/* Fill up the bestcomm bd queue and enable DMA.
 		 * This will begin filling the PSC's fifo. */
-		if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
+		if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) {
 			bcom_gen_bd_rx_reset(s->bcom_task);
-		else
+			for (i = 0; i < runtime->periods; i++)
+				if (!bcom_queue_full(s->bcom_task))
+					psc_dma_bcom_enqueue_next_buffer(s);
+		} else {
 			bcom_gen_bd_tx_reset(s->bcom_task);
-		while (!bcom_queue_full(s->bcom_task))
-			psc_dma_bcom_enqueue_next_buffer(s);
+			psc_dma_bcom_enqueue_tx(s);
+		}
+
 		bcom_enable(s->bcom_task);
 
 		/* Due to errata in the dma mode; need to line up enabling
@@ -227,30 +223,22 @@ int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
 		psc_cmd = MPC52xx_PSC_RX_ENABLE;
 		if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK)
 			psc_cmd |= MPC52xx_PSC_TX_ENABLE;
-		out_8(&regs->command, psc_cmd);
+		//out_8(&regs->command, psc_cmd);
+
+		out_8(&regs->command, MPC52xx_PSC_RST_ERR_STAT);
+
 		spin_unlock_irqrestore(&psc_dma->lock, flags);
 
 		break;
 
 	case SNDRV_PCM_TRIGGER_STOP:
-		/* Turn off the PSC */
 		s->active = 0;
-		if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) {
-			if (!psc_dma->playback.active) {
-				out_8(&regs->command, 2 << 4);	/* reset rx */
-				out_8(&regs->command, 3 << 4);	/* reset tx */
-				out_8(&regs->command, 4 << 4);	/* reset err */
-			}
-		} else {
-			out_8(&regs->command, 3 << 4);	/* reset tx */
-			out_8(&regs->command, 4 << 4);	/* reset err */
-			if (!psc_dma->capture.active)
-				out_8(&regs->command, 2 << 4);	/* reset rx */
-		}
 
 		bcom_disable(s->bcom_task);
-		while (!bcom_queue_empty(s->bcom_task))
-			bcom_retrieve_buffer(s->bcom_task, NULL, NULL);
+		if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
+			bcom_gen_bd_rx_reset(s->bcom_task);
+		else
+			bcom_gen_bd_tx_reset(s->bcom_task);
 
 		break;
 
@@ -265,44 +253,11 @@ int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
 		imr |= MPC52xx_PSC_IMR_TXEMP;
 	if (psc_dma->capture.active)
 		imr |= MPC52xx_PSC_IMR_ORERR;
-	out_be16(&regs->isr_imr.imr, imr);
+	out_be16(&regs->isr_imr.imr, psc_dma->imr | imr);
 
 	return 0;
 }
 
-/**
- * psc_dma_shutdown: shutdown the data transfer on a stream
- *
- * Shutdown the PSC if there are no other substreams open.
- */
-void psc_dma_shutdown(struct snd_pcm_substream *substream,
-			     struct snd_soc_dai *dai)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
-
-	dev_dbg(psc_dma->dev, "psc_dma_shutdown(substream=%p)\n", substream);
-
-	/*
-	 * If this is the last active substream, disable the PSC and release
-	 * the IRQ.
-	 */
-	if (!psc_dma->playback.active &&
-	    !psc_dma->capture.active) {
-
-		/* Disable all interrupts and reset the PSC */
-		out_be16(&psc_dma->psc_regs->isr_imr.imr, 0);
-		out_8(&psc_dma->psc_regs->command, 3 << 4); /* reset tx */
-		out_8(&psc_dma->psc_regs->command, 2 << 4); /* reset rx */
-		out_8(&psc_dma->psc_regs->command, 1 << 4); /* reset mode */
-		out_8(&psc_dma->psc_regs->command, 4 << 4); /* reset error */
-
-		/* Release irqs */
-		free_irq(psc_dma->irq, psc_dma);
-		free_irq(psc_dma->capture.irq, &psc_dma->capture);
-		free_irq(psc_dma->playback.irq, &psc_dma->playback);
-	}
-}
 
 /* ---------------------------------------------------------------------
  * The PSC DMA 'ASoC platform' driver
@@ -312,67 +267,93 @@ void psc_dma_shutdown(struct snd_pcm_substream *substream,
  * interaction with the attached codec
  */
 
-static const struct snd_pcm_hardware psc_dma_pcm_hardware = {
+static const struct snd_pcm_hardware psc_dma_hardware = {
 	.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
 		SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
 		SNDRV_PCM_INFO_BATCH,
-	.formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |
-		   SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE,
+	.formats = SNDRV_PCM_FMTBIT_S32_BE,
 	.rate_min = 8000,
 	.rate_max = 48000,
-	.channels_min = 2,
+	.channels_min = 1,
 	.channels_max = 2,
 	.period_bytes_max	= 1024 * 1024,
 	.period_bytes_min	= 32,
 	.periods_min		= 2,
 	.periods_max		= 256,
 	.buffer_bytes_max	= 2 * 1024 * 1024,
-	.fifo_size		= 0,
+	.fifo_size		= 512,
 };
 
-static int psc_dma_pcm_open(struct snd_pcm_substream *substream)
+static int psc_dma_open(struct snd_pcm_substream *substream)
 {
+	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
 	struct psc_dma_stream *s;
+	int rc;
 
-	dev_dbg(psc_dma->dev, "psc_dma_pcm_open(substream=%p)\n", substream);
+	dev_dbg(psc_dma->dev, "psc_dma_open(substream=%p)\n", substream);
 
 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
 		s = &psc_dma->capture;
 	else
 		s = &psc_dma->playback;
 
-	snd_soc_set_runtime_hwparams(substream, &psc_dma_pcm_hardware);
+	snd_soc_set_runtime_hwparams(substream, &psc_dma_hardware);
+
+	rc = snd_pcm_hw_constraint_integer(runtime,
+		SNDRV_PCM_HW_PARAM_PERIODS);
+	if (rc < 0) {
+		dev_err(substream->pcm->card->dev, "invalid buffer size\n");
+		return rc;
+	}
+
+	if (!psc_dma->playback.active &&
+	    !psc_dma->capture.active) {
+		/* Setup the IRQs */
+	}
 
 	s->stream = substream;
 	return 0;
 }
 
-static int psc_dma_pcm_close(struct snd_pcm_substream *substream)
+static int psc_dma_close(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
 	struct psc_dma_stream *s;
 
-	dev_dbg(psc_dma->dev, "psc_dma_pcm_close(substream=%p)\n", substream);
+	dev_dbg(psc_dma->dev, "psc_dma_close(substream=%p)\n", substream);
 
 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
 		s = &psc_dma->capture;
 	else
 		s = &psc_dma->playback;
 
+	if (!psc_dma->playback.active &&
+	    !psc_dma->capture.active) {
+
+		/* Disable all interrupts and reset the PSC */
+		out_be16(&psc_dma->psc_regs->isr_imr.imr, psc_dma->imr);
+		//out_8(&psc_dma->psc_regs->command, 3 << 4); /* reset tx */
+		//out_8(&psc_dma->psc_regs->command, 2 << 4); /* reset rx */
+		//out_8(&psc_dma->psc_regs->command, 1 << 4); /* reset mode */
+		//out_8(&psc_dma->psc_regs->command, 4 << 4); /* reset error */
+
+	}
+
 	s->stream = NULL;
 	return 0;
 }
 
 static snd_pcm_uframes_t
-psc_dma_pcm_pointer(struct snd_pcm_substream *substream)
+psc_dma_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
 	struct psc_dma_stream *s;
 	dma_addr_t count;
+	snd_pcm_uframes_t frames;
 
 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
 		s = &psc_dma->capture;
@@ -381,46 +362,63 @@ psc_dma_pcm_pointer(struct snd_pcm_substream *substream)
 
 	count = s->period_current_pt - s->period_start;
 
-	return bytes_to_frames(substream->runtime, count);
+	frames = bytes_to_frames(substream->runtime, count);
+	return frames;
+}
+
+static int
+psc_dma_hw_params(struct snd_pcm_substream *substream,
+			 struct snd_pcm_hw_params *params)
+{
+  	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
+
+  	return 0;
 }
 
-static struct snd_pcm_ops psc_dma_pcm_ops = {
-	.open		= psc_dma_pcm_open,
-	.close		= psc_dma_pcm_close,
+static struct snd_pcm_ops psc_dma_ops = {
+	.open		= psc_dma_open,
+	.close		= psc_dma_close,
+	.hw_free	= psc_dma_hw_free,
 	.ioctl		= snd_pcm_lib_ioctl,
-	.pointer	= psc_dma_pcm_pointer,
+	.pointer	= psc_dma_pointer,
+	.trigger	= psc_dma_trigger,
+	.hw_params	= psc_dma_hw_params,
 };
 
-static u64 psc_dma_pcm_dmamask = 0xffffffff;
-static int psc_dma_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
+static u64 psc_dma_dmamask = 0xffffffff;
+static int psc_dma_new(struct snd_card *card, struct snd_soc_dai *dai,
 			   struct snd_pcm *pcm)
 {
 	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
-	size_t size = psc_dma_pcm_hardware.buffer_bytes_max;
+	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
+	size_t size = psc_dma_hardware.buffer_bytes_max;
 	int rc = 0;
 
-	dev_dbg(rtd->socdev->dev, "psc_dma_pcm_new(card=%p, dai=%p, pcm=%p)\n",
+	dev_dbg(rtd->socdev->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n",
 		card, dai, pcm);
 
 	if (!card->dev->dma_mask)
-		card->dev->dma_mask = &psc_dma_pcm_dmamask;
+		card->dev->dma_mask = &psc_dma_dmamask;
 	if (!card->dev->coherent_dma_mask)
 		card->dev->coherent_dma_mask = 0xffffffff;
 
 	if (pcm->streams[0].substream) {
-		rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->dev, size,
+		rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, size,
 					&pcm->streams[0].substream->dma_buffer);
 		if (rc)
 			goto playback_alloc_err;
 	}
 
 	if (pcm->streams[1].substream) {
-		rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->dev, size,
+		rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, size,
 					&pcm->streams[1].substream->dma_buffer);
 		if (rc)
 			goto capture_alloc_err;
 	}
 
+	if (rtd->socdev->card->codec->ac97)
+		rtd->socdev->card->codec->ac97->private_data = psc_dma;
+
 	return 0;
 
  capture_alloc_err:
@@ -431,13 +429,13 @@ static int psc_dma_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
 	return -ENOMEM;
 }
 
-static void psc_dma_pcm_free(struct snd_pcm *pcm)
+static void psc_dma_free(struct snd_pcm *pcm)
 {
 	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
 	struct snd_pcm_substream *substream;
 	int stream;
 
-	dev_dbg(rtd->socdev->dev, "psc_dma_pcm_free(pcm=%p)\n", pcm);
+	dev_dbg(rtd->socdev->dev, "psc_dma_free(pcm=%p)\n", pcm);
 
 	for (stream = 0; stream < 2; stream++) {
 		substream = pcm->streams[stream].substream;
@@ -449,10 +447,247 @@ static void psc_dma_pcm_free(struct snd_pcm *pcm)
 	}
 }
 
-struct snd_soc_platform psc_dma_pcm_soc_platform = {
+struct snd_soc_platform mpc5200_audio_dma_platform = {
 	.name		= "mpc5200-psc-audio",
-	.pcm_ops	= &psc_dma_pcm_ops,
-	.pcm_new	= &psc_dma_pcm_new,
-	.pcm_free	= &psc_dma_pcm_free,
+	.pcm_ops	= &psc_dma_ops,
+	.pcm_new	= &psc_dma_new,
+	.pcm_free	= &psc_dma_free,
 };
+EXPORT_SYMBOL_GPL(mpc5200_audio_dma_platform);
+
+/* ---------------------------------------------------------------------
+ * Sysfs attributes for debugging
+ */
+
+static ssize_t psc_dma_status_show(struct device *dev,
+			   struct device_attribute *attr, char *buf)
+{
+	struct psc_dma *psc_dma = dev_get_drvdata(dev);
+
+	return sprintf(buf, "status=%.4x sicr=%.8x rfnum=%i rfstat=0x%.4x "
+			"tfnum=%i tfstat=0x%.4x\n",
+			in_be16(&psc_dma->psc_regs->sr_csr.status),
+			in_be32(&psc_dma->psc_regs->sicr),
+			in_be16(&psc_dma->fifo_regs->rfnum) & 0x1ff,
+			in_be16(&psc_dma->fifo_regs->rfstat),
+			in_be16(&psc_dma->fifo_regs->tfnum) & 0x1ff,
+			in_be16(&psc_dma->fifo_regs->tfstat));
+}
+
+static int *psc_dma_get_stat_attr(struct psc_dma *psc_dma, const char *name)
+{
+	if (strcmp(name, "playback_underrun") == 0)
+		return &psc_dma->stats.underrun_count;
+	if (strcmp(name, "capture_overrun") == 0)
+		return &psc_dma->stats.overrun_count;
+
+	return NULL;
+}
+
+static ssize_t psc_dma_stat_show(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct psc_dma *psc_dma = dev_get_drvdata(dev);
+	int *attrib;
+
+	attrib = psc_dma_get_stat_attr(psc_dma, attr->attr.name);
+	if (!attrib)
+		return 0;
+
+	return sprintf(buf, "%i\n", *attrib);
+}
+
+static ssize_t psc_dma_stat_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf,
+				  size_t count)
+{
+	struct psc_dma *psc_dma = dev_get_drvdata(dev);
+	int *attrib;
+
+	attrib = psc_dma_get_stat_attr(psc_dma, attr->attr.name);
+	if (!attrib)
+		return 0;
+
+	*attrib = simple_strtoul(buf, NULL, 0);
+	return count;
+}
+
+static DEVICE_ATTR(status, 0644, psc_dma_status_show, NULL);
+static DEVICE_ATTR(playback_underrun, 0644, psc_dma_stat_show,
+			psc_dma_stat_store);
+static DEVICE_ATTR(capture_overrun, 0644, psc_dma_stat_show,
+			psc_dma_stat_store);
+
+
+int mpc5200_audio_dma_create(struct of_device *op, struct snd_soc_dai *template, int tsize)
+{
+	phys_addr_t fifo;
+	struct psc_dma *psc_dma;
+	struct resource res;
+	int i, nDAI, size, psc_id, irq, rc;
+	const __be32 *prop;
+	void __iomem *regs;
+
+	/* Get the PSC ID */
+	prop = of_get_property(op->node, "cell-index", &size);
+	if (!prop || size < sizeof *prop)
+		return -ENODEV;
+	psc_id = be32_to_cpu(*prop);
+
+	/* Fetch the registers and IRQ of the PSC */
+	irq = irq_of_parse_and_map(op->node, 0);
+	if (of_address_to_resource(op->node, 0, &res)) {
+		dev_err(&op->dev, "Missing reg property\n");
+		return -ENODEV;
+	}
+	regs = ioremap(res.start, 1 + res.end - res.start);
+	if (!regs) {
+		dev_err(&op->dev, "Could not map registers\n");
+		return -ENODEV;
+	}
+
+	/* Allocate and initialize the driver private data */
+	psc_dma = kzalloc(sizeof *psc_dma, GFP_KERNEL);
+	if (!psc_dma) {
+		iounmap(regs);
+		return -ENOMEM;
+	}
+
+	spin_lock_init(&psc_dma->lock);
+	psc_dma->irq = irq;
+	psc_dma->psc_regs = regs;
+	psc_dma->fifo_regs = regs + sizeof *psc_dma->psc_regs;
+	psc_dma->dev = &op->dev;
+	psc_dma->playback.psc_dma = psc_dma;
+	psc_dma->capture.psc_dma = psc_dma;
+	snprintf(psc_dma->name, sizeof psc_dma->name, "PSC%u AC97", psc_id+1);
+
+	/* Fill out the CPU DAI structure */
+	nDAI = min(tsize, SOC_OF_SIMPLE_MAX_DAI);
+	for (i = 0; i < nDAI; i++) {
+		memcpy(&psc_dma->dai[i], &template[i], sizeof(struct snd_soc_dai));
+		psc_dma->dai[i].private_data = psc_dma;
+		snprintf(psc_dma->stream_name[i], PSC_STREAM_NAME_LEN, template[i].name, psc_dma->name);
+		psc_dma->dai[i].name = psc_dma->stream_name[i];
+		psc_dma->dai[i].id = psc_id;
+	}
+
+	/* Find the address of the fifo data registers and setup the
+	 * DMA tasks */
+	fifo = res.start + offsetof(struct mpc52xx_psc, buffer.buffer_32);
+	psc_dma->capture.bcom_task =
+		bcom_psc_gen_bd_rx_init(psc_id, 10, fifo, 512);
+	psc_dma->playback.bcom_task =
+		bcom_psc_gen_bd_tx_init(psc_id, 10, fifo);
+	if (!psc_dma->capture.bcom_task ||
+	    !psc_dma->playback.bcom_task) {
+		dev_err(&op->dev, "Could not allocate bestcomm tasks\n");
+		iounmap(regs);
+		kfree(psc_dma);
+		return -ENODEV;
+	}
+
+	/* Disable all interrupts and reset the PSC */
+	out_be16(&psc_dma->psc_regs->isr_imr.imr, psc_dma->imr);
+	out_8(&psc_dma->psc_regs->command, MPC52xx_PSC_RST_RX); /* reset receiver */
+	out_8(&psc_dma->psc_regs->command, MPC52xx_PSC_RST_TX); /* reset transmitter */
+	out_8(&psc_dma->psc_regs->command, MPC52xx_PSC_RST_ERR_STAT); /* reset error */
+	out_8(&psc_dma->psc_regs->command, MPC52xx_PSC_SEL_MODE_REG_1); /* reset mode */
+
+	/* Set up mode register;
+	 * First write: RxRdy (FIFO Alarm) generates rx FIFO irq
+	 * Second write: register Normal mode for non loopback
+	 */
+	out_8(&psc_dma->psc_regs->mode, 0);
+	out_8(&psc_dma->psc_regs->mode, 0);
+
+	/* Set the TX and RX fifo alarm thresholds */
+	out_be16(&psc_dma->fifo_regs->rfalarm, 0x100);
+	out_8(&psc_dma->fifo_regs->rfcntl, 0x4);
+	out_be16(&psc_dma->fifo_regs->tfalarm, 0x100);
+	out_8(&psc_dma->fifo_regs->tfcntl, 0x7);
+
+	/* Lookup the IRQ numbers */
+	psc_dma->playback.irq =
+		bcom_get_task_irq(psc_dma->playback.bcom_task);
+	psc_dma->capture.irq =
+		bcom_get_task_irq(psc_dma->capture.bcom_task);
+
+	rc = request_irq(psc_dma->irq, &psc_dma_status_irq, IRQF_SHARED,
+			 "psc-dma-status", psc_dma);
+	rc |= request_irq(psc_dma->capture.irq,
+			  &psc_dma_bcom_irq_rx, IRQF_SHARED,
+			  "psc-dma-capture", &psc_dma->capture);
+	rc |= request_irq(psc_dma->playback.irq,
+			  &psc_dma_bcom_irq_tx, IRQF_SHARED,
+			  "psc-dma-playback", &psc_dma->playback);
+	if (rc) {
+		free_irq(psc_dma->irq, psc_dma);
+		free_irq(psc_dma->capture.irq,
+			 &psc_dma->capture);
+		free_irq(psc_dma->playback.irq,
+			 &psc_dma->playback);
+		return -ENODEV;
+	}
+
+	/* Save what we've done so it can be found again later */
+	dev_set_drvdata(&op->dev, psc_dma);
+
+	/* Register the SYSFS files */
+	rc = device_create_file(psc_dma->dev, &dev_attr_status);
+	rc |= device_create_file(psc_dma->dev, &dev_attr_capture_overrun);
+	rc |= device_create_file(psc_dma->dev, &dev_attr_playback_underrun);
+	if (rc)
+		dev_info(psc_dma->dev, "error creating sysfs files\n");
+
+	rc = snd_soc_register_dais(psc_dma->dai, nDAI);
+	if (rc != 0) {
+		pr_err("Failed to register DAI\n");
+		return 0;
+	}
+
+	/* Tell the ASoC OF helpers about it */
+	of_snd_soc_register_cpu_dai(op->node, psc_dma->dai, nDAI);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(mpc5200_audio_dma_create);
+
+int mpc5200_audio_dma_destroy(struct of_device *op)
+{
+	struct psc_dma *psc_dma = dev_get_drvdata(&op->dev);
+
+	dev_dbg(&op->dev, "mpc5200_audio_dma_destroy()\n");
+
+	bcom_gen_bd_rx_release(psc_dma->capture.bcom_task);
+	bcom_gen_bd_tx_release(psc_dma->playback.bcom_task);
+
+	/* Release irqs */
+	free_irq(psc_dma->irq, psc_dma);
+	free_irq(psc_dma->capture.irq, &psc_dma->capture);
+	free_irq(psc_dma->playback.irq, &psc_dma->playback);
+
+	iounmap(psc_dma->psc_regs);
+	iounmap(psc_dma->fifo_regs);
+	kfree(psc_dma);
+	dev_set_drvdata(&op->dev, NULL);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(mpc5200_audio_dma_destroy);
+
+static int __init mpc5200_soc_platform_init(void)
+{
+	/* Tell the ASoC OF helpers about it */
+	of_snd_soc_register_platform(&mpc5200_audio_dma_platform);
+	return snd_soc_register_platform(&mpc5200_audio_dma_platform);
+}
+module_init(mpc5200_soc_platform_init);
+
+static void __exit mpc5200_soc_platform_exit(void)
+{
+	snd_soc_unregister_platform(&mpc5200_audio_dma_platform);
+}
+module_exit(mpc5200_soc_platform_exit);
 
sound/soc/fsl/mpc5200_dma.h +17 -15
index a33232c..d71e503 100644
@@ -5,8 +5,12 @@
 #ifndef __SOUND_SOC_FSL_MPC5200_DMA_H__
 #define __SOUND_SOC_FSL_MPC5200_DMA_H__
 
+#include <sound/soc-of-simple.h>
+
+#define PSC_STREAM_NAME_LEN 32
+
 /**
- * psc_dma_stream - Data specific to a single stream (playback or capture)
+ * psc_ac97_stream - Data specific to a single stream (playback or capture)
  * @active:		flag indicating if the stream is active
  * @psc_dma:		pointer back to parent psc_dma data structure
  * @bcom_task:		bestcomm task structure
@@ -17,6 +21,9 @@
  * @period_bytes:	size of DMA period in bytes
  */
 struct psc_dma_stream {
+	struct snd_pcm_runtime *runtime;
+	snd_pcm_uframes_t appl_ptr;
+
 	int active;
 	struct psc_dma *psc_dma;
 	struct bcom_task *bcom_task;
@@ -27,6 +34,7 @@ struct psc_dma_stream {
 	dma_addr_t period_next_pt;
 	dma_addr_t period_current_pt;
 	int period_bytes;
+	int period_size;
 };
 
 /**
@@ -48,9 +56,13 @@ struct psc_dma {
 	struct mpc52xx_psc_fifo __iomem *fifo_regs;
 	unsigned int irq;
 	struct device *dev;
-	struct snd_soc_dai dai;
+	struct snd_soc_dai dai[SOC_OF_SIMPLE_MAX_DAI];
+	char stream_name[SOC_OF_SIMPLE_MAX_DAI][PSC_STREAM_NAME_LEN];
 	spinlock_t lock;
 	u32 sicr;
+	uint sysclk;
+	int imr;
+	unsigned int slots;
 
 	/* per-stream data */
 	struct psc_dma_stream playback;
@@ -63,19 +75,9 @@ struct psc_dma {
 	} stats;
 };
 
+int mpc5200_audio_dma_create(struct of_device *op, struct snd_soc_dai *template, int tsize);
+int mpc5200_audio_dma_destroy(struct of_device *op);
 
-int psc_dma_startup(struct snd_pcm_substream *substream,
-			   struct snd_soc_dai *dai);
-
-int psc_dma_hw_free(struct snd_pcm_substream *substream,
-			   struct snd_soc_dai *dai);
-
-void psc_dma_shutdown(struct snd_pcm_substream *substream,
-			     struct snd_soc_dai *dai);
-
-int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
-			   struct snd_soc_dai *dai);
-
-extern struct snd_soc_platform psc_dma_pcm_soc_platform;
+extern struct snd_soc_platform mpc5200_audio_dma_platform;
 
 #endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */
sound/soc/fsl/mpc5200_psc_i2s.c +10 -188

242 lines not on this page · raw message

#19 lore raw

Re: [PATCH V1 09/13] Main rewite of the mpc5200 audio DMA code

sound/soc/fsl/mpc5200_dma.c void psc_dma_shutdown(struct snd_pcm_substream *substream, · line 274

Quoted 8 lines · Jon Smirl
sound/soc/fsl/mpc5200_dma.c +2 -3
-static const struct snd_pcm_hardware psc_dma_pcm_hardware = {
+static const struct snd_pcm_hardware psc_dma_hardware = {
 	.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
 		SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
 		SNDRV_PCM_INFO_BATCH,
-	.formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |
-		   SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE,
+	.formats = SNDRV_PCM_FMTBIT_S32_BE,

This seems like a major and very surprising reduction in functionality. Why is this required?

sound/soc/fsl/mpc5200_dma.c void psc_dma_shutdown(struct snd_pcm_substream *substream, · line 314

Quoted 4 lines
sound/soc/fsl/mpc5200_dma.c +4 -0
+	if (!psc_dma->playback.active &&
+	    !psc_dma->capture.active) {
+		/* Setup the IRQs */
+	}

Should this be implemented or removed?

sound/soc/fsl/mpc5200_dma.c void psc_dma_shutdown(struct snd_pcm_substream *substream, · line 344

Quoted 12 lines
sound/soc/fsl/mpc5200_dma.c +12 -0
+	if (!psc_dma->playback.active &&
+	    !psc_dma->capture.active) {
+
+		/* Disable all interrupts and reset the PSC */
+		out_be16(&psc_dma->psc_regs->isr_imr.imr, psc_dma->imr);
+		//out_8(&psc_dma->psc_regs->command, 3 << 4); /* reset tx */
+		//out_8(&psc_dma->psc_regs->command, 2 << 4); /* reset rx */
+		//out_8(&psc_dma->psc_regs->command, 1 << 4); /* reset mode */
+		//out_8(&psc_dma->psc_regs->command, 4 << 4); /* reset error */
+
+	}
+

The commented code should go.

author
#20 lore raw

Re: [PATCH V1 09/13] Main rewite of the mpc5200 audio DMA code

Quoted 13 lines · Mark Brown
Quoted 8 lines · Jon Smirl
sound/soc/fsl/mpc5200_dma.c +1 -1
-static const struct snd_pcm_hardware psc_dma_pcm_hardware = {
+static const struct snd_pcm_hardware psc_dma_hardware = {

      .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_BATCH,
-     .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |
-                SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE,
+     .formats = SNDRV_PCM_FMTBIT_S32_BE,

This seems like a major and very surprising reduction in functionality. Why is this required?

I think I did this backwards. The AC97 DAI should be SNDRV_PCM_FMTBIT_S32_BE only and the DMA engine allow all four.

Signature · 2 lines
Jon Smirl
[email protected]
#21 lore raw

Re: [PATCH V1 09/13] Main rewite of the mpc5200 audio DMA code

Quoted 7 lines · Jon Smirl

On Thu, May 14, 2009 at 6:51 AM, Mark Brown

Quoted 2 lines

This seems like a major and very surprising reduction in functionality. Why is this required?

I think I did this backwards. The AC97 DAI should be SNDRV_PCM_FMTBIT_S32_BE only and the DMA engine allow all four.

Yup, that'll work.

author
#22 lore raw

PATCH 10/13 Codec for STAC9766 used on the Efika

In reply to Jon Smirl

AC97 codec for STAC9766 used on the Efika. Support registration from device trees.
Datasheet: http://www.idt.com/products/getDoc.cfm?docID=13134007

---
 sound/soc/codecs/Kconfig    |    4 
 sound/soc/codecs/Makefile   |    2 
 sound/soc/codecs/stac9766.c |  491 +++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/stac9766.h |   21 ++
 4 files changed, 518 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/stac9766.c
 create mode 100644 sound/soc/codecs/stac9766.h
sound/soc/codecs/Kconfig +4 -0
index 1c19ad5..d86b0de 100644
@@ -19,6 +19,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_CS4270 if I2C
 	select SND_SOC_PCM3008
 	select SND_SOC_SSM2602 if I2C
+	select SND_SOC_STAC9766
 	select SND_SOC_TLV320AIC23 if I2C
 	select SND_SOC_TLV320AIC26 if SPI_MASTER
 	select SND_SOC_TLV320AIC3X if I2C
@@ -92,6 +93,9 @@ config SND_SOC_PCM3008
 config SND_SOC_SSM2602
 	tristate
 
+config SND_SOC_STAC9766
+	tristate
+
 config SND_SOC_TLV320AIC23
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 3d31b6b..c6998e4 100644
@@ -7,6 +7,7 @@ snd-soc-cs4270-objs := cs4270.o
 snd-soc-l3-objs := l3.o
 snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-ssm2602-objs := ssm2602.o
+snd-soc-stac9766-objs := stac9766.o
 snd-soc-tlv320aic23-objs := tlv320aic23.o
 snd-soc-tlv320aic26-objs := tlv320aic26.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
@@ -41,6 +42,7 @@ obj-$(CONFIG_SND_SOC_CS4270)	+= snd-soc-cs4270.o
 obj-$(CONFIG_SND_SOC_L3)	+= snd-soc-l3.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
 obj-$(CONFIG_SND_SOC_SSM2602)	+= snd-soc-ssm2602.o
+obj-$(CONFIG_SND_SOC_STAC9766)	+= snd-soc-stac9766.o
 obj-$(CONFIG_SND_SOC_TLV320AIC23)	+= snd-soc-tlv320aic23.o
 obj-$(CONFIG_SND_SOC_TLV320AIC26)	+= snd-soc-tlv320aic26.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)	+= snd-soc-tlv320aic3x.o
sound/soc/codecs/stac9766.c new file +491 -0

491 lines not on this page · raw message

sound/soc/codecs/stac9766.h new file +21 -0
new file mode 100644
index 0000000..65642eb
@@ -0,0 +1,21 @@
+/*
+ * stac9766.h  --  STAC9766 Soc Audio driver
+ */
+
+#ifndef _STAC9766_H
+#define _STAC9766_H
+
+#define AC97_STAC_PAGE0 0x1000
+#define AC97_STAC_DA_CONTROL (AC97_STAC_PAGE0 | 0x6A)
+#define AC97_STAC_ANALOG_SPECIAL (AC97_STAC_PAGE0 | 0x6E)
+#define AC97_STAC_STEREO_MIC 0x78
+
+/* STAC9766 DAI ID's */
+#define STAC9766_DAI_AC97_ANALOG		0
+#define STAC9766_DAI_AC97_DIGITAL		1
+
+extern struct snd_soc_dai stac9766_dai[];
+extern struct snd_soc_codec_device soc_codec_dev_stac9766;
+
+
+#endif
#23 lore raw

Re: [PATCH V1 10/13] Codec for STAC9766 used on the Efika

On Wed, May 13, 2009 at 09:59:20PM -0400, Jon Smirl wrote:

This looks mostly good - a lot of the issues below are fairly nitpicky, though the issue with the of_simple integration needs to be dealt with.

sound/soc/codecs/Kconfig config SND_SOC_ALL_CODECS · line 23

Quoted 3 lines
sound/soc/codecs/Kconfig +1 -0
 	select SND_SOC_SSM2602 if I2C
+	select SND_SOC_STAC9766
 	select SND_SOC_TLV320AIC23 if I2C

This needs to be '... if SND_SOC_AC97_BUS' as for all the other AC97 CODECs.

sound/soc/codecs/stac9766.c line 145

Quoted 8 lines
sound/soc/codecs/stac9766.c new file +8 -0
+{
+	u16 *cache = codec->reg_cache;
+
+	if (reg > AC97_STAC_PAGE0) {
+		stac9766_ac97_write(codec, AC97_INT_PAGING, 0);
+		soc_ac97_ops.write(codec->ac97, reg, val);
+		stac9766_ac97_write(codec, AC97_INT_PAGING, 1);
+		return 0;

This could use a comment explaining what's going on with the paging - I'd expect page 0 to be the default page.

sound/soc/codecs/stac9766.c line 211

Quoted 13 lines
sound/soc/codecs/stac9766.c new file +13 -0
+static int ac97_digital_prepare(struct snd_pcm_substream *substream,
+                                struct snd_soc_dai *dai)
+{
+	struct snd_soc_codec *codec = dai->codec;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	unsigned short reg, vra;
+
+	stac9766_ac97_write(codec, AC97_SPDIF, 0x2002);
+
+	vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS);
+
+	vra |= 0x5; /* Enable VRA and SPDIF out */
+	printk("var is %x\n", vra);

This looks like debug code that can be removed or turned into a pr_debug()?

sound/soc/codecs/stac9766.c line 221

Quoted 2 lines
sound/soc/codecs/stac9766.c new file +2 -0
+static int ac97_digital_trigger(struct snd_pcm_substream *substream,
+								int cmd, struct snd_soc_dai *dai)

Another indentation problem?

sound/soc/codecs/stac9766.c line 231

Quoted 6 lines
sound/soc/codecs/stac9766.c new file +6 -0
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_STOP:
+		vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS);
+		vra &= !0x04;
+		//stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra);
+		break;

Debug code that could be cleaned up?

sound/soc/codecs/stac9766.c line 245

Quoted 10 lines
sound/soc/codecs/stac9766.c new file +10 -0
+static int stac9766_set_bias_level(struct snd_soc_codec *codec,
+                                enum snd_soc_bias_level level)
+{
+	switch (level) {
+	case SND_SOC_BIAS_ON: /* full On */
+		stac9766_ac97_write(codec, AC97_POWERDOWN, 0x0000);
+		break;
+	case SND_SOC_BIAS_PREPARE: /* partial On */
+		stac9766_ac97_write(codec, AC97_POWERDOWN, 0x0000);
+		break;

You could skip the writes here - they're just doing the same thing as standby.

sound/soc/codecs/stac9766.c line 280

Quoted 13 lines
sound/soc/codecs/stac9766.c new file +13 -0
+static int stac9766_codec_resume(struct platform_device *pdev)
+{
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec *codec = socdev->card->codec;
+	u16 id;
+
+	/* give the codec an AC97 warm reset to start the link */
+	codec->ac97->bus->ops->warm_reset(codec->ac97);
+	id = soc_ac97_ops.read(codec->ac97, AC97_VENDOR_ID2);
+	if (id != 0x4c13) {
+		printk(KERN_ERR "stac9766 failed to resume");
+		return -EIO;
+	}

Shouldn't this use the reset function?

sound/soc/codecs/stac9766.c line 313

Quoted 3 lines
sound/soc/codecs/stac9766.c new file +3 -0
+		.rates = SNDRV_PCM_RATE_8000_48000,
+		.formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |
+				SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE,

Should use the standard define for AC97 formats here, and for the other DAIs.

sound/soc/codecs/stac9766.c line 414

Quoted 2 lines
sound/soc/codecs/stac9766.c new file +2 -0
+	snd_soc_add_controls(codec, stac9766_snd_ac97_controls, ARRAY_SIZE(
+	                                stac9766_snd_ac97_controls));

Odd place to wrap...

sound/soc/codecs/stac9766.c line 459

Quoted 3 lines
sound/soc/codecs/stac9766.c new file +3 -0
+static int __init stac9766_probe(struct platform_device *pdev)
+{
+	snd_soc_register_dais(stac9766_dai, ARRAY_SIZE(stac9766_dai));

The same issues as apply to the WM9712 change apply here.

author
#24 lore raw

PATCH 11/13 AC97 driver for mpc5200

In reply to Jon Smirl

AC97 driver for mpc5200

---
 sound/soc/fsl/Kconfig            |   11 +
 sound/soc/fsl/Makefile           |    1 
 sound/soc/fsl/mpc5200_psc_ac97.c |  379 ++++++++++++++++++++++++++++++++++++++
 sound/soc/fsl/mpc5200_psc_ac97.h |   13 +
 4 files changed, 404 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c
 create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h
sound/soc/fsl/Kconfig +11 -0
index 8060b95..d8f63f5 100644
@@ -30,3 +30,14 @@ config SND_SOC_MPC5200_I2S
 	select PPC_BESTCOMM_GEN_BD
 	help
 	  Say Y here to support the MPC5200 PSCs in I2S mode.
+
+config SND_SOC_MPC5200_AC97
+	tristate "Freescale MPC5200 PSC in AC97 mode driver"
+	depends on PPC_MPC52xx && PPC_BESTCOMM
+	select SND_SOC_OF_SIMPLE
+	select SND_MPC52xx_DMA
+	select PPC_BESTCOMM_GEN_BD
+	help
+	  Say Y here to support the MPC5200 PSCs in AC97 mode.
+
+
sound/soc/fsl/Makefile +1 -0
index 7731ef2..14631a1 100644
@@ -13,4 +13,5 @@ obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o
 # MPC5200 Platform Support
 obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o
 obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o
+obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o
 
sound/soc/fsl/mpc5200_psc_ac97.c new file +379 -0

379 lines not on this page · raw message

sound/soc/fsl/mpc5200_psc_ac97.h new file +13 -0
new file mode 100644
index 0000000..d028c55
@@ -0,0 +1,13 @@
+/*
+ * Freescale MPC5200 PSC in AC97 mode
+ * ALSA SoC Digital Audio Interface (DAI) driver
+ *
+ */
+
+#ifndef __SOUND_SOC_FSL_MPC52xx_PSC_AC97_H__
+#define __SOUND_SOC_FSL_MPC52xx_PSC_AC97_H__
+
+#define MPC5200_AC97_ANALOG 0
+#define MPC5200_AC97_DIGITAL 1
+
+#endif /* __SOUND_SOC_FSL_MPC52xx_PSC_AC97_H__ */
author
#25 lore raw

Re: [PATCH V1 11/13] AC97 driver for mpc5200

Quoted 1 line · Jon Smirl

AC97 driver for mpc5200

I made a mistake removing the debug info from this one. Add a quote on the pr_err() calls.

Signature · 2 lines
Jon Smirl
[email protected]
#26 lore raw

Re: [PATCH V1 11/13] AC97 driver for mpc5200

In reply to Jon Smirl

On Wed, May 13, 2009 at 09:59:22PM -0400, Jon Smirl wrote:

Looks mostly good but there's a few things that it'd be nice to address:

sound/soc/fsl/mpc5200_psc_ac97.c line 39

Quoted 3 lines
sound/soc/fsl/mpc5200_psc_ac97.c new file +3 -0
+MODULE_AUTHOR("Jon Smirl <[email protected]>");
+MODULE_DESCRIPTION("mpc5200 AC97 module");
+MODULE_LICENSE("GPL");

Normally this comes at the bottom of the file.

sound/soc/fsl/mpc5200_psc_ac97.c line 49

Quoted 9 lines
sound/soc/fsl/mpc5200_psc_ac97.c new file +9 -0
+#define DRV_NAME "mpc5200-psc-ac97"
+
+static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
+{
+	struct psc_dma *psc_dma = ac97->private_data;
+	int timeout;
+	unsigned int val;
+
+	spin_lock(&psc_dma->lock);

Does this need to protect against interrupts?

sound/soc/fsl/mpc5200_psc_ac97.c line 129

Quoted 4 lines
sound/soc/fsl/mpc5200_psc_ac97.c new file +4 -0
+static void psc_ac97_warm_reset(struct snd_ac97 *ac97)
+{
+	pr_info("psc_ac97_warm_reset\n");
+}

Remove this - it's only going to confuse things to provide it if you can't implement it, anything that actually needs the warm reset is going to get upset anyway.

sound/soc/fsl/mpc5200_psc_ac97.c line 148

Quoted 10 lines
sound/soc/fsl/mpc5200_psc_ac97.c new file +10 -0
+#ifdef CONFIG_PM
+static int psc_ac97_suspend(struct snd_soc_dai *dai)
+{
+	return 0;
+}
+
+static int psc_ac97_resume(struct snd_soc_dai *dai)
+{
+	return 0;
+}

All the suspend and resume stuff can be removed if there's no implementation.

sound/soc/fsl/mpc5200_psc_ac97.c line 246

Quoted 8 lines
sound/soc/fsl/mpc5200_psc_ac97.c new file +8 -0
+static int psc_ac97_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format)
+{
+	struct psc_dma *psc_dma = cpu_dai->private_data;
+	dev_dbg(psc_dma->dev, "psc_ac97_set_fmt(cpu_dai=%p, format=%i)\n",
+				cpu_dai, format);
+
+	return (format == SND_SOC_DAIFMT_AC97) ? 0 : -EINVAL;
+}

Remove this, there's no need to provide a set_fmt operation for AC97 DAIs.

author
#27 lore raw

PATCH 12/13 Fabric bindings for STAC9766 on the Efika

In reply to Jon Smirl

Fabric bindings for STAC9766 on the Efika. This includes an example of a custom fabric driver.

---
 arch/powerpc/platforms/52xx/efika.c |    8 +++
 sound/soc/fsl/Kconfig               |    8 +++
 sound/soc/fsl/Makefile              |    3 +
 sound/soc/fsl/efika-audio-fabric.c  |   95 +++++++++++++++++++++++++++++++++++
 4 files changed, 113 insertions(+), 1 deletions(-)
 create mode 100644 sound/soc/fsl/efika-audio-fabric.c
arch/powerpc/platforms/52xx/efika.c +7 -1
index a2068fa..c7a6a48 100644
@@ -211,12 +211,18 @@ static int __init efika_probe(void)
 	return 1;
 }
 
+static void __init efika_declare_platform_devices(void)
+{
+	mpc52xx_declare_of_platform_devices();
+	platform_device_register_simple("efika-audio-fabric", 0, NULL, 0);
+}
+
 define_machine(efika)
 {
 	.name			= EFIKA_PLATFORM_NAME,
 	.probe			= efika_probe,
 	.setup_arch		= efika_setup_arch,
-	.init			= mpc52xx_declare_of_platform_devices,
+	.init			= efika_declare_platform_devices,
 	.show_cpuinfo		= efika_show_cpuinfo,
 	.init_IRQ		= mpc52xx_init_irq,
 	.get_irq		= mpc52xx_get_irq,
sound/soc/fsl/Kconfig +8 -0
index d8f63f5..266c6b7 100644
@@ -40,4 +40,12 @@ config SND_SOC_MPC5200_AC97
 	help
 	  Say Y here to support the MPC5200 PSCs in AC97 mode.
 
+config SND_MPC52xx_SOC_EFIKA
+	tristate "SoC AC97 Audio support for bbplan Efika and STAC9766"
+	depends on PPC_EFIKA
+	select SND_SOC_MPC5200_AC97
+	select SND_SOC_STAC9766
+	help
+	  Say Y if you want to add support for sound on the Efika.
+
 
sound/soc/fsl/Makefile +3 -0
index 14631a1..f406470 100644
@@ -15,3 +15,6 @@ obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o
 obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o
 obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o
 
+# MPC5200 Machine Support
+obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o
+
sound/soc/fsl/efika-audio-fabric.c new file +95 -0

95 lines not on this page · raw message

author
#28 lore raw

PATCH 13/13 Support for AC97 on Phytec pmc030 base board.

In reply to Jon Smirl

Support for AC97 on Phytec pmc030 base board. This uses the generic fabric driver binding.

---
 arch/powerpc/boot/dts/pcm030.dts |    8 ++++++++
 sound/soc/fsl/Kconfig            |    7 +++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
arch/powerpc/boot/dts/pcm030.dts +8 -0
index 8958347..001c8ef 100644
@@ -190,6 +190,14 @@
 			cell-index = <0>;
 			reg = <0x2000 0x100>;
 			interrupts = <2 1 0>;
+
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			codec@0 {
+				compatible = "wlf,wm9712";
+				reg = <0x0>;
+			};
 		};
 
 		/* PSC2 port is used by CAN1/2 */
sound/soc/fsl/Kconfig +7 -0
index 266c6b7..11735e4 100644
@@ -48,4 +48,11 @@ config SND_MPC52xx_SOC_EFIKA
 	help
 	  Say Y if you want to add support for sound on the Efika.
 
+config SND_MPC52xx_SOC_PCM030
+	tristate "SoC AC97 Audio support for Phytec pcm030 and WM9712"
+	depends on PPC_MPC5200_SIMPLE
+	select SND_SOC_MPC5200_AC97
+	select SND_SOC_WM9712
+	help
+	  Say Y if you want to add support for sound on the Phytec pcm030 baseboard.
author
#29 lore raw
In reply to Jon Smirl
Quoted 5 lines · Jon Smirl

The following series implements audio support for the mpc5200. It adds an AC97 driver and STAC9766 codec driver. Board support for the Efika and Phytec pcm030 are also included. I'm sure everyone will have some edits on this first version.

Series is based on 13e2c86c20f5d07b20d5a6dee24bcdd2b30b859f from broonie/for-2.6.31
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git

I pushed the tree out to http://git.digispeaker.com

Signature · 2 lines
Jon Smirl
[email protected]
#30 lore raw
In reply to Jon Smirl
Quoted 5 lines · Jon Smirl

The following series implements audio support for the mpc5200. It adds an AC97 driver and STAC9766 codec driver. Board support for the Efika and Phytec pcm030 are also included. I'm sure everyone will have some edits on this first version.

BTW, please also cc: the linuxppc-dev mailing list for the next issue of this series.

Thanks,
g.

Quoted 53 lines

---

Jon Smirl (13):
     Support for AC97 on Phytec pmc030 base board. Fabric bindings for STAC9766 on the Efika
     AC97 driver for mpc5200
     Codec for STAC9766 used on the Efika
     Main rewite of the mpc5200 audio DMA code
     Have the WM9712 driver self register itself
     Add SNDRV_PCM_FMTBIT_S32_BE as a valid AC97 format Allow a custom ASOC fabric driver with soc-of-simple Add a few more mpc5200 PSC defines
     redo 2008f137e92220b98120c4803499cdddb2b0fb06 Rename the PSC functions to DMA
     Basic split of mpc5200 DMA code out from mpc5200_psc_i2s Temporarily undo 2008f137e92220b98120c4803499cdddb2b0fb06

 arch/powerpc/boot/dts/pcm030.dts       |    8 arch/powerpc/include/asm/mpc52xx_psc.h |   10 arch/powerpc/platforms/52xx/efika.c    |    8 include/sound/soc-dai.h                |    3 include/sound/soc-of-simple.h          |   16 +
 sound/last.c                           |    6 sound/soc/codecs/Kconfig               |    4 sound/soc/codecs/Makefile              |    2 sound/soc/codecs/stac9766.c            |  491 ++++++++++++++++++++++ sound/soc/codecs/stac9766.h            |   21 + sound/soc/codecs/tlv320aic26.c         |    2 sound/soc/codecs/wm9712.c              |   34 ++ sound/soc/fsl/Kconfig                  |   30 + sound/soc/fsl/Makefile                 |    6 sound/soc/fsl/efika-audio-fabric.c     |   95 ++++ sound/soc/fsl/mpc5200_dma.c            |  693 +++++++++++++++++++++++++++++++ sound/soc/fsl/mpc5200_dma.h            |   83 ++++ sound/soc/fsl/mpc5200_psc_ac97.c       |  379 +++++++++++++++++ sound/soc/fsl/mpc5200_psc_ac97.h       |   13 + sound/soc/fsl/mpc5200_psc_i2s.c        |  707 +------------------------------- sound/soc/fsl/soc-of-simple.c          |  160 ++++++-

 21 files changed, 2053 insertions(+), 718 deletions(-)

 create mode 100644 sound/soc/codecs/stac9766.c create mode 100644 sound/soc/codecs/stac9766.h create mode 100644 sound/soc/fsl/efika-audio-fabric.c create mode 100644 sound/soc/fsl/mpc5200_dma.c create mode 100644 sound/soc/fsl/mpc5200_dma.h create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h

--
Jon Smirl
[email protected]

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.