Skip to contentSkip to conversation

AC97 driver for mpc5200

PATCH Superseded Jon Smirl 7 participants 25 messages May 25, 2009 – May 26, 2009

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Jon Smirl

author
#0 lore raw

v4 cover AC97 driver for mpc5200

Version 4. Changed timeouts to use relax_cpu() instead of udelay(). Fixed locking to lock bestcomm instead of registers. Code reorg as requested in the various comments. Removed sysfs over/underrun reporting. Removed reset retries. Removing the retries makes the driver fail to load about 5% of the time. An oscilliscope is needed to figure out what is going on with failed resets. Both pcm030 and Efika ocasionally fail to reset and they use different codec chips.

---

Jon Smirl (5):
Fabric bindings for STAC9766 on the Efika
Support for AC97 on Phytec pmc030 base board.
AC97 driver for mpc5200
Main rewite of the mpc5200 audio DMA code
The macro spin_event_timeout() takes a condition and timeout value

 arch/powerpc/include/asm/delay.h    |   33 +++
 sound/soc/fsl/Kconfig               |   27 ++
 sound/soc/fsl/Makefile              |    5 
 sound/soc/fsl/efika-audio-fabric.c  |   90 +++++++
 sound/soc/fsl/mpc5200_dma.c         |  442 ++++++++++++++++++++++-------------
 sound/soc/fsl/mpc5200_dma.h         |   43 ++-
 sound/soc/fsl/mpc5200_psc_ac97.c    |  331 ++++++++++++++++++++++++++
 sound/soc/fsl/mpc5200_psc_ac97.h    |   15 +
 sound/soc/fsl/mpc5200_psc_i2s.c     |  247 +++-----------------
 sound/soc/fsl/mpc5200_psc_i2s.h     |   12 +
 sound/soc/fsl/pcm030-audio-fabric.c |   90 +++++++
 11 files changed, 946 insertions(+), 389 deletions(-)
 create mode 100644 sound/soc/fsl/efika-audio-fabric.c
 create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c
 create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h
 create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h
 create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c
Signature · 2 lines
Jon Smirl
[email protected]
author
#1 lore raw

PATCH v4 1/5 The macro spin_event_timeout() takes a condition and timeout value

(in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns the result of the condition when the loop was terminated.

This primary purpose of this macro is to poll on a hardware register until a status bit changes. The timeout ensures that the loop still terminates if the bit doesn't change as expected. This macro makes it easier for driver developers to perform this kind of operation properly.

---
 arch/powerpc/include/asm/delay.h |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/delay.h +33 -0
index f9200a6..fedf037 100644
@@ -2,8 +2,11 @@
 #define _ASM_POWERPC_DELAY_H
 #ifdef __KERNEL__
 
+#include <asm/time.h>
+
 /*
  * Copyright 1996, Paul Mackerras.
+ * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -30,5 +33,35 @@ extern void udelay(unsigned long usecs);
 #define mdelay(n)	udelay((n) * 1000)
 #endif
 
+/**
+ * spin_event_timeout - spin until a condition gets true or a timeout elapses
+ * @condition: a C expression to evalate
+ * @timeout: timeout, in microseconds
+ * @delay: the number of microseconds to delay between eache evaluation of
+ *         @condition
+ * @rc: the last value of the condition
+ *
+ * The process spins until the condition evaluates to true (non-zero) or the
+ * timeout elapses.  Upon exit, @rc contains the value of the condition. This
+ * allows you to test the condition without incurring any side effects.
+ *
+ * This primary purpose of this macro is to poll on a hardware register
+ * until a status bit changes.  The timeout ensures that the loop still
+ * terminates even if the bit never changes.  The delay is for devices that
+ * need a delay in between successive reads.
+ *
+ * gcc will optimize out the if-statement if @delay is a constant.
+ */
+#define spin_event_timeout(condition, timeout, delay, rc)                   \
+{                                                                           \
+	unsigned long __loops = tb_ticks_per_usec * timeout;                \
+	unsigned long __start = get_tbl();                                  \
+	while ((rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \
+		if (delay)                                                  \
+			udelay(delay);                                      \
+		else	                                                    \
+			cpu_relax();                                        \
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_DELAY_H */
author
#7 lore raw

PATCH v4 2/5 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.

---
 sound/soc/fsl/Kconfig           |    1 
 sound/soc/fsl/mpc5200_dma.c     |  442 ++++++++++++++++++++++++---------------
 sound/soc/fsl/mpc5200_dma.h     |   43 ++--
 sound/soc/fsl/mpc5200_psc_i2s.c |  247 ++++------------------
 sound/soc/fsl/mpc5200_psc_i2s.h |   12 +
 5 files changed, 356 insertions(+), 389 deletions(-)
 create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h
sound/soc/fsl/Kconfig +0 -1
index dc79bdf..1918c78 100644
@@ -25,7 +25,6 @@ config SND_SOC_MPC8610_HPCD
 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
sound/soc/fsl/mpc5200_dma.c +274 -168

644 lines not on this page · raw message

sound/soc/fsl/mpc5200_dma.h +28 -15

81 lines not on this page · raw message

sound/soc/fsl/mpc5200_psc_i2s.c +42 -205

331 lines not on this page · raw message

sound/soc/fsl/mpc5200_psc_i2s.h new file +12 -0
new file mode 100644
index 0000000..ce55e07
@@ -0,0 +1,12 @@
+/*
+ * Freescale MPC5200 PSC in I2S mode
+ * ALSA SoC Digital Audio Interface (DAI) driver
+ *
+ */
+
+#ifndef __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__
+#define __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__
+
+extern struct snd_soc_dai psc_i2s_dai[];
+
+#endif /* __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__ */
author
#14 lore raw

PATCH v4 3/5 AC97 driver for mpc5200

In reply to Jon Smirl

AC97 driver for mpc5200

I've implemented retries for when the AC97 hardware doesn't reset on first try. About 10% of the time both the Efika and pcm030 AC97 codecs don't reset on first try and need to be poked multiple times. Failure is indicated by not having the link clock start ticking. Every once in a while even five pokes won't get the link started and I have to power cycle.

---
 sound/soc/fsl/Kconfig            |   11 +
 sound/soc/fsl/Makefile           |    1 
 sound/soc/fsl/mpc5200_psc_ac97.c |  331 ++++++++++++++++++++++++++++++++++++++
 sound/soc/fsl/mpc5200_psc_ac97.h |   15 ++
 4 files changed, 358 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 1918c78..3bce952 100644
@@ -29,3 +29,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 AC97_BUS
+	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 +331 -0

331 lines not on this page · raw message

sound/soc/fsl/mpc5200_psc_ac97.h new file +15 -0
new file mode 100644
index 0000000..4bc18c3
@@ -0,0 +1,15 @@
+/*
+ * 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__
+
+extern struct snd_soc_dai psc_ac97_dai[];
+
+#define MPC5200_AC97_NORMAL 0
+#define MPC5200_AC97_SPDIF 1
+
+#endif /* __SOUND_SOC_FSL_MPC52xx_PSC_AC97_H__ */
author
#17 lore raw

PATCH v4 4/5 Support for AC97 on Phytec pmc030 base board.

In reply to Jon Smirl

Support for AC97 on Phytec pmc030 base board. A wm9712 AC97 codec is used.

---
 sound/soc/fsl/Kconfig               |    7 +++
 sound/soc/fsl/Makefile              |    3 +
 sound/soc/fsl/pcm030-audio-fabric.c |   90 +++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c
sound/soc/fsl/Kconfig +7 -0
index 3bce952..79579ae 100644
@@ -39,4 +39,11 @@ config SND_SOC_MPC5200_AC97
 	help
 	  Say Y here to support the MPC5200 PSCs in AC97 mode.
 
+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.
 
sound/soc/fsl/Makefile +3 -0
index 14631a1..66d88c8 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_PCM030) += pcm030-audio-fabric.o
+
sound/soc/fsl/pcm030-audio-fabric.c new file +90 -0

90 lines not on this page · raw message

author
#18 lore raw

PATCH v4 5/5 Fabric bindings for STAC9766 on the Efika

In reply to Jon Smirl

Fabric bindings for STAC9766 AC97 codec on the Efika.

---
 sound/soc/fsl/Kconfig              |    8 +++
 sound/soc/fsl/Makefile             |    1 
 sound/soc/fsl/efika-audio-fabric.c |   90 ++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/fsl/efika-audio-fabric.c
sound/soc/fsl/Kconfig +8 -0
index 79579ae..f571c6e 100644
@@ -47,3 +47,11 @@ config SND_MPC52xx_SOC_PCM030
 	help
 	  Say Y if you want to add support for sound on the Phytec pcm030 baseboard.
 
+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 +1 -0
index 66d88c8..a83a739 100644
@@ -17,4 +17,5 @@ obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o
 
 # MPC5200 Machine Support
 obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o
+obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o
 
sound/soc/fsl/efika-audio-fabric.c new file +90 -0

90 lines not on this page · raw message

#15 lore raw
In reply to Jon Smirl
Quoted 1 line · Jon Smirl

+       spin_event_timeout(1, 3, 0, rc);

Ugh, don't do this. Just use udelay!

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#19 lore raw
In reply to Jon Smirl
Quoted 1 line · Jon Smirl

     The macro spin_event_timeout() takes a condition and timeout value

My patch is already set to go through the powerpc tree, so there's no need to repost it here. Please, you changed the title of the patch.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#16 lore raw
In reply to Timur Tabi
Quoted 5 lines · Timur Tabi
Quoted 1 line · Jon Smirl

+       spin_event_timeout(1, 3, 0, rc);

Ugh, don't do this.  Just use udelay!

heh; indeed. My objection to udelay is that it burns cycles it the test loop that could be used to decide whether or not the loop is complete. Not an issue when the explicit goal is to burn a fixed number of cycles.

g.

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

Re: [PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value

In reply to Jon Smirl
Quoted 44 lines · Jon Smirl

(in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns the result of the condition when the loop was terminated.

This primary purpose of this macro is to poll on a hardware register until a status bit changes. The timeout ensures that the loop still terminates if the bit doesn't change as expected. This macro makes it easier for driver developers to perform this kind of operation properly.

---
 arch/powerpc/include/asm/delay.h |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/delay.h +13 -0
index f9200a6..fedf037 100644
@@ -2,8 +2,11 @@
 #define _ASM_POWERPC_DELAY_H
 #ifdef __KERNEL__
 
+#include <asm/time.h>
+
 /*
  * Copyright 1996, Paul Mackerras.
+ * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -30,5 +33,35 @@ extern void udelay(unsigned long usecs);
 #define mdelay(n)	udelay((n) * 1000)
 #endif
 
+/**
+ * spin_event_timeout - spin until a condition gets true or a timeout elapses
+ * @condition: a C expression to evalate
+ * @timeout: timeout, in microseconds
+ * @delay: the number of microseconds to delay between eache evaluation of
+ *         @condition
+ * @rc: the last value of the condition
+ *
+ * The process spins until the condition evaluates to true (non-zero) or the
+ * timeout elapses.  Upon exit, @rc contains the value of the condition. This

arch/powerpc/include/asm/delay.h extern void udelay(unsigned long usecs); · line 55

Quoted 10 lines
arch/powerpc/include/asm/delay.h +10 -0
+ * allows you to test the condition without incurring any side effects.
+ *
+ * This primary purpose of this macro is to poll on a hardware register
+ * until a status bit changes.  The timeout ensures that the loop still
+ * terminates even if the bit never changes.  The delay is for devices that
+ * need a delay in between successive reads.
+ *
+ * gcc will optimize out the if-statement if @delay is a constant.
+ */
+#define spin_event_timeout(condition, timeout, delay, rc)                   \

static inline function, returning rc, instead of a macro?

arch/powerpc/include/asm/delay.h extern void udelay(unsigned long usecs); · line 67

Quoted 12 lines
arch/powerpc/include/asm/delay.h +10 -0
+{                                                                           \
+	unsigned long __loops = tb_ticks_per_usec * timeout;                \
+	unsigned long __start = get_tbl();                                  \
+	while ((rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \
+		if (delay)                                                  \
+			udelay(delay);                                      \
+		else	                                                    \
+			cpu_relax();                                        \
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_DELAY_H */

With kind regards,

Geert Uytterhoeven
Software Architect
Techsoft Centre

Technology and Software Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   [email protected]
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V. VAT BE 0413.825.160 · RPR Brussels Fortis · BIC GEBABEBB · IBAN BE41293037680010

#20 lore raw
In reply to Timur Tabi
Quoted 6 lines · Timur Tabi
Quoted 1 line · Jon Smirl

? ? ?The macro spin_event_timeout() takes a condition and timeout value

My patch is already set to go through the powerpc tree, so there's no need to repost it here. Please, you changed the title of the patch.

Indeed. Since this is a new driver I'm happy to let the code go in without the new function and then sort itself out in the merge window.

#24 lore raw
In reply to Jon Smirl
Quoted 1 line · Jon Smirl

reset retries. Removing the retries makes the driver fail to load about 5% of the time. An oscilliscope is

Please also send a patch sorting this out in the STAC9766 driver as requested. Other than that and the udelay() thing it looks like we can merge this now - there's the reset issue and probably other things to clean up but it'd be better to do those as incremental patches.

Quoted 2 lines

needed to figure out what is going on with failed resets. Both pcm030 and Efika ocasionally fail to reset and they use different codec chips.

Like I say, it may be worth checking into the startup of the master clock for the CODECs, especially if it's an output from the SoC on both boards.

author
#21 lore raw
In reply to Timur Tabi
Quoted 6 lines · Timur Tabi
Quoted 1 line · Jon Smirl

     The macro spin_event_timeout() takes a condition and timeout value

My patch is already set to go through the powerpc tree, so there's no need to repost it here.  Please, you changed the title of the patch.

I'm changing the code, I removed the ! on the rc. Geert just asked to have it changed to an in-line too.

I forgot to add the title line so it used the beginning of the comment.

Quoted 5 lines

--
Timur Tabi
Linux kernel developer at Freescale

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

Re: [PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value

In reply to Geert Uytterhoeven
Quoted 1 line · Geert Uytterhoeven

static inline function, returning rc, instead of a macro?

It won't work as an inline function ...

Quoted 3 lines
Quoted 3 lines

+     unsigned long __loops = tb_ticks_per_usec * timeout;                \
+     unsigned long __start = get_tbl();                                  \
+     while ((rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \

There's no way to pass a expression to an inline function. It has to be a macro. Here, the loop evaluates "condition" at every pass. If this were an inline function, "condition" would be evaluated once when the function were called, and never again.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#22 lore raw
In reply to Jon Smirl
Quoted 4 lines · Jon Smirl
Quoted 3 lines · Timur Tabi
Quoted 1 line · Jon Smirl

=A0 =A0 =A0The macro spin_event_timeout() takes a condition and timeout=

value

Quoted 5 lines
Quoted 3 lines

My patch is already set to go through the powerpc tree, so there's no need to repost it here. =A0Please, you changed the title of the patch.

I'm changing the code,

My code? If you want to make your own version of spin_event_timeout, then you should change the name and keep it local to your C files.

Quoted 2 lines

I removed the ! on the rc. Geert just asked to
have it changed to an in-line too.

And Geert's request won't work.

--=20
Timur Tabi
Linux kernel developer at Freescale

#23 lore raw
In reply to Jon Smirl
Quoted 7 lines · Jon Smirl
Quoted 2 lines · Timur Tabi

My patch is already set to go through the powerpc tree, so there's no need to repost it here. ?Please, you changed the title of the patch.

I'm changing the code, I removed the ! on the rc. Geert just asked to have it changed to an in-line too.

If you're doing that you need make it explicit and submit an incremental patch against the PowerPC tree. You'll also need to take care of any affected users there.

#4 lore raw

Re: [PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value

In reply to Timur Tabi
Quoted 7 lines · Timur Tabi
Quoted 1 line · Geert Uytterhoeven

static inline function, returning rc, instead of a macro?

It won't work as an inline function ...

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

+     unsigned long __loops = tb_ticks_per_usec * timeout;                \
+     unsigned long __start = get_tbl();                                  \
+     while ((rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \

There's no way to pass a expression to an inline function. It has to be a macro. Here, the loop evaluates "condition" at every pass. If this were an inline function, "condition" would be evaluated once when the function were called, and never again.

You're right, I missed that part. Sorry about that.

However, you can still improve useability by making the macro return the rc, instead of letting the caller pass it, cfr. wait_event_timeout() and friends.

With kind regards,

Geert Uytterhoeven
Software Architect
Techsoft Centre

Technology and Software Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   [email protected]
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010

#5 lore raw

Re: [PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value

Quoted 2 lines · Geert Uytterhoeven

However, you can still improve useability by making the macro return the rc, instead of letting the caller pass it, cfr. wait_event_timeout() and friends.

Either that, or it should at least use the do { ... } while (0) construct to make the macro a statement. All multi-line macros need to either use ({ ... }) or do { ... } while (0) to make sure they behave well.

	Arnd <><
#6 lore raw

Re: [PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value

Quoted 3 lines · Arnd Bergmann
Quoted 2 lines · Geert Uytterhoeven

However, you can still improve useability by making the macro return the rc, instead of letting the caller pass it, cfr. wait_event_timeout() and friends.

I had that originally, but somewhere during the seven revisions of my macro, it got lost.

I'll post a v9 soon. This version will take 3 parameters and return __ret, so Jon will need to change his code (sorry).

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
author
#10 lore raw

Re: [PATCH V4 2/5] Main rewite of the mpc5200 audio DMA code

Quoted 10 lines · Grant Likely
Quoted 6 lines · Mark Brown
Quoted 3 lines · Jon Smirl

Rewrite the mpc5200 audio DMA code to support both I2S and AC97.

Grant, I'm OK with that if you are?

Put in the V5 version this one has this in the h file:

-int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
- struct snd_soc_dai *dai);
+/* whack this after Timur's patch is merged in to arch/powerpc/include/asm/delay.h */
+#define spin_event_timeout(condition, timeout, delay, rc) \
+{ \

+       unsigned long __loops = tb_ticks_per_usec * timeout;                \
+       unsigned long __start = get_tbl();                                  \
+       while ((rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \
+               if (delay)                                                  \
+                       udelay(delay);                                      \
+               else                                                        \
+                       cpu_relax();                                        \

+}
+/* whack this after Timur's patch is merged in to arch/powerpc/include/asm/delay.h */

Quoted 8 lines

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

Re: [PATCH V4 2/5] Main rewite of the mpc5200 audio DMA code

Quoted 9 lines · Jon Smirl
Quoted 7 lines · Grant Likely
Quoted 5 lines · Mark Brown
Quoted 3 lines · Jon Smirl

Rewrite the mpc5200 audio DMA code to support both I2S and AC97.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Grant, I'm OK with that if you are?

Put in the V5 version this one has this in the h file:

-int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct snd_soc_dai *=

dai);

Quoted 3 lines

+/* whack this after Timur's patch is merged in to arch/powerpc/include/asm/delay.h */
+#define spin_event_timeout(condition, timeout, delay, rc) =A0 =A0 =A0 =

=A0 =A0 =A0 =A0 =A0 =A0 \

Quoted 1 line

+{ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 \

Quoted 1 line

+ =A0 =A0 =A0 unsigned long __loops =3D tb_ticks_per_usec * timeout; =A0 =

=A0 =A0 =A0 =A0 =A0 =A0 =A0\

Quoted 1 line

+ =A0 =A0 =A0 unsigned long __start =3D get_tbl(); =A0 =A0 =A0 =A0 =A0 =

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\

Quoted 1 line

+ =A0 =A0 =A0 while ((rc =3D (condition)) && (tb_ticks_since(__start) <=

=3D __loops)) \

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (delay) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 udelay(delay); =A0 =A0 =A0 =

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 else =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= \

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cpu_relax(); =A0 =A0 =A0 =

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\

Quoted 3 lines
(quoted diff) +2 -0
+}
+/* whack this after Timur's patch is merged in to

arch/powerpc/include/asm/delay.h */

sure, no problem if it will grease the merge.

g.

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

#12 lore raw

Re: [PATCH V4 2/5] Main rewite of the mpc5200 audio DMA code

In reply to Jon Smirl
Quoted 17 lines · Jon Smirl

Put in the V5 version this one has this in the h file:

sound/soc/fsl/mpc5200_dma.h +1 -2
-int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd,
-                          struct snd_soc_dai *dai);
+/* whack this after Timur's patch is merged in to

arch/powerpc/include/asm/delay.h */

sound/soc/fsl/mpc5200_dma.h +11 -0
+#define spin_event_timeout(condition, timeout, delay, rc)                   \
+{                                                                           \
+       unsigned long __loops = tb_ticks_per_usec * timeout;                \
+       unsigned long __start = get_tbl();                                  \
+       while ((rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \
+               if (delay)                                                  \
+                       udelay(delay);                                      \
+               else                                                        \
+                       cpu_relax();                                        \
+}
+/* whack this after Timur's patch is merged in to
Quoted 1 line

arch/powerpc/include/asm/delay.h */

It won't be that simple. V9 of my patch changes the number of parameters, so not only will you need to whack this copy of the macro, you'll also need to change the callers.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#13 lore raw

Re: [alsa-devel] [PATCH V4 2/5] Main rewite of the mpc5200 audio DMA code

Quoted 3 lines · Timur Tabi

It won't be that simple. V9 of my patch changes the number of parameters, so not only will you need to whack this copy of the macro, you'll also need to change the callers.

OK, in the interests of cutting down on the amount of review here I've applied v5 of the series and then marked the AC97 machine drivers as BROKEN for the time being - once everything lands in mainline we can make sure that the driver is in sync with the final spin_event_timeout() API and remove the BROKEN marking.