[alsa-devel] [PATCH v2 00/17] ASoC: add imx-sgtl5000 machine driver working with fsl_ssi
Changes since v1: * Address comments from Mark, Timur, and Sascha (Thanks for review). * Drop patches that have been applied by Mark.
Richard Zhao (2): ARM: imx: convert audmux to a platform driver ASoC: fsl: add dt support for imx-audmux
Shawn Guo (15): ASoC: imx: move eukrea audmux call into ASoC machine driver ASoC: imx: move phycore audmux call into ASoC machine driver ARM: imx: merge audmux-v1 and audmux-v2 ASoC: imx: move audmux driver into sound/soc/imx ASoC: imx: rename audmux prefix mxc to imx ASoC: imx: separate imx-pcm bits from imx-ssi driver ASoC: imx: add an explicit Kconfig option for imx-ssi driver ASoC: fsl: separate SSI and DMA Kconfig options ASoC: imx: merge sound/soc/imx into sound/soc/fsl ASoC: fsl: create fsl_utils to accommodate the common functions ASoC: fsl: check property 'compatible' for the machine name ASoC: fsl: make fsl_ssi driver compilable on ARM/IMX ASoC: fsl: remove the fatal error checking on codec-handle ASoC: fsl: let fsl_ssi work with imx pcm and machine drivers ASoC: fsl: add imx-sgtl5000 machine driver
.../bindings/sound/imx-audio-sgtl5000.txt | 24 +++ .../devicetree/bindings/sound/imx-audmux.txt | 13 ++ arch/arm/mach-imx/Kconfig | 6 - arch/arm/mach-imx/eukrea_mbimx27-baseboard.c | 20 -- arch/arm/mach-imx/eukrea_mbimxsd-baseboard.c | 1 - arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 17 -- arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 17 -- arch/arm/mach-imx/mach-pca100.c | 13 -- arch/arm/mach-imx/mach-pcm043.c | 13 -- arch/arm/mach-imx/mm-imx21.c | 6 + arch/arm/mach-imx/mm-imx25.c | 7 + arch/arm/mach-imx/mm-imx27.c | 7 + arch/arm/mach-imx/mm-imx3.c | 13 ++ arch/arm/mach-imx/mm-imx5.c | 22 +++ arch/arm/plat-mxc/Kconfig | 6 - arch/arm/plat-mxc/Makefile | 2 - arch/arm/plat-mxc/audmux-v1.c | 64 ------- arch/arm/plat-mxc/include/mach/audmux.h | 60 ------- sound/soc/Kconfig | 1 - sound/soc/Makefile | 1 - sound/soc/fsl/Kconfig | 124 +++++++++++++- sound/soc/fsl/Makefile | 29 +++- sound/soc/{imx => fsl}/eukrea-tlv320.c | 42 ++++- sound/soc/fsl/fsl_ssi.c | 139 ++++++++++++---- sound/soc/fsl/fsl_utils.c | 135 ++++++++++++++ sound/soc/fsl/fsl_utils.h | 27 +++ .../audmux-v2.c => sound/soc/fsl/imx-audmux.c | 185 +++++++++++++++----- sound/soc/fsl/imx-audmux.h | 60 +++++++ sound/soc/{imx => fsl}/imx-pcm-dma-mx2.c | 2 +- sound/soc/{imx => fsl}/imx-pcm-fiq.c | 0 sound/soc/fsl/imx-pcm.c | 105 +++++++++++ sound/soc/fsl/imx-pcm.h | 32 ++++ sound/soc/fsl/imx-sgtl5000.c | 181 +++++++++++++++++++ sound/soc/{imx => fsl}/imx-ssi.c | 90 +---------- sound/soc/{imx => fsl}/imx-ssi.h | 16 +-- sound/soc/fsl/mpc8610_hpcd.c | 159 ++---------------- sound/soc/{imx => fsl}/mx27vis-aic32x4.c | 20 +- sound/soc/fsl/p1022_ds.c | 181 ++------------------ sound/soc/{imx => fsl}/phycore-ac97.c | 27 +++- sound/soc/{imx => fsl}/wm1133-ev1.c | 25 ++-- sound/soc/imx/Kconfig | 60 ------- sound/soc/imx/Makefile | 19 -- 42 files changed, 1140 insertions(+), 831 deletions(-)
On Mon, Mar 05, 2012 at 10:30:48PM +0800, Shawn Guo wrote:
Changes since v1:
- Address comments from Mark, Timur, and Sascha (Thanks for review).
- Drop patches that have been applied by Mark.
I see you've ignored my comments about reordering the patches so they can be applied more easily :(
On Mon, Mar 05, 2012 at 02:20:10PM +0000, Mark Brown wrote:
On Mon, Mar 05, 2012 at 10:30:48PM +0800, Shawn Guo wrote:
Changes since v1:
- Address comments from Mark, Timur, and Sascha (Thanks for review).
- Drop patches that have been applied by Mark.
I see you've ignored my comments about reordering the patches so they can be applied more easily :(
Sorry, if it makes your life hard. But I hope I can win ack from Sascha and Timur soon, so that the series can be applied as a whole anyway.
On Mon, Mar 05, 2012 at 10:44:03PM +0800, Shawn Guo wrote:
On Mon, Mar 05, 2012 at 02:20:10PM +0000, Mark Brown wrote:
I see you've ignored my comments about reordering the patches so they can be applied more easily :(
Sorry, if it makes your life hard. But I hope I can win ack from Sascha and Timur soon, so that the series can be applied as a whole anyway.
If you resend again please do pull out those two commits, in general smaller serieses doing one thing are much better.
It moves eukrea audmux configuration call from board file into ASoC machine driver eukrea-tlv320, so that it gets aligned wm1133-ev1 and mx27vis-aic32x4, and more importantly it will ease the moving of audmux into sound/soc/imx as a platform driver later.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- arch/arm/mach-imx/eukrea_mbimx27-baseboard.c | 20 ------------ arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 17 ---------- arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 17 ---------- sound/soc/imx/eukrea-tlv320.c | 40 +++++++++++++++++++++-- 4 files changed, 36 insertions(+), 58 deletions(-)
diff --git a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c index 5db3e14..5f2f91d 100644 --- a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c +++ b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c @@ -32,7 +32,6 @@ #include <mach/common.h> #include <mach/iomux-mx27.h> #include <mach/hardware.h> -#include <mach/audmux.h>
#include "devices-imx27.h"
@@ -306,25 +305,6 @@ void __init eukrea_mbimx27_baseboard_init(void) mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins, ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
-#if defined(CONFIG_SND_SOC_EUKREA_TLV320) \ - || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE) - /* SSI unit master I2S codec connected to SSI_PINS_4*/ - mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, - MXC_AUDMUX_V1_PCR_SYN | - MXC_AUDMUX_V1_PCR_TFSDIR | - MXC_AUDMUX_V1_PCR_TCLKDIR | - MXC_AUDMUX_V1_PCR_RFSDIR | - MXC_AUDMUX_V1_PCR_RCLKDIR | - MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | - MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | - MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) - ); - mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4, - MXC_AUDMUX_V1_PCR_SYN | - MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) - ); -#endif - imx27_add_imx_uart1(&uart_pdata); imx27_add_imx_uart2(&uart_pdata); #if !defined(MACH_EUKREA_CPUIMX27_USEUART4) diff --git a/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c b/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c index 66e8726..2cf603e 100644 --- a/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c +++ b/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c @@ -31,7 +31,6 @@ #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <mach/mx25.h> -#include <mach/audmux.h>
#include "devices-imx25.h"
@@ -241,22 +240,6 @@ void __init eukrea_mbimxsd25_baseboard_init(void) ARRAY_SIZE(eukrea_mbimxsd_pads))) printk(KERN_ERR "error setting mbimxsd pads !\n");
-#if defined(CONFIG_SND_SOC_EUKREA_TLV320) - /* SSI unit master I2S codec connected to SSI_AUD5*/ - mxc_audmux_v2_configure_port(0, - MXC_AUDMUX_V2_PTCR_SYN | - MXC_AUDMUX_V2_PTCR_TFSDIR | - MXC_AUDMUX_V2_PTCR_TFSEL(4) | - MXC_AUDMUX_V2_PTCR_TCLKDIR | - MXC_AUDMUX_V2_PTCR_TCSEL(4), - MXC_AUDMUX_V2_PDCR_RXDSEL(4) - ); - mxc_audmux_v2_configure_port(4, - MXC_AUDMUX_V2_PTCR_SYN, - MXC_AUDMUX_V2_PDCR_RXDSEL(0) - ); -#endif - imx25_add_imx_uart1(&uart_pdata); imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata); imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata); diff --git a/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c b/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c index 0f0af02..fd8bf8a 100644 --- a/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c +++ b/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c @@ -38,7 +38,6 @@ #include <mach/hardware.h> #include <mach/common.h> #include <mach/iomux-mx35.h> -#include <mach/audmux.h>
#include "devices-imx35.h"
@@ -252,22 +251,6 @@ void __init eukrea_mbimxsd35_baseboard_init(void) ARRAY_SIZE(eukrea_mbimxsd_pads))) printk(KERN_ERR "error setting mbimxsd pads !\n");
-#if defined(CONFIG_SND_SOC_EUKREA_TLV320) - /* SSI unit master I2S codec connected to SSI_AUD4 */ - mxc_audmux_v2_configure_port(0, - MXC_AUDMUX_V2_PTCR_SYN | - MXC_AUDMUX_V2_PTCR_TFSDIR | - MXC_AUDMUX_V2_PTCR_TFSEL(3) | - MXC_AUDMUX_V2_PTCR_TCLKDIR | - MXC_AUDMUX_V2_PTCR_TCSEL(3), - MXC_AUDMUX_V2_PDCR_RXDSEL(3) - ); - mxc_audmux_v2_configure_port(3, - MXC_AUDMUX_V2_PTCR_SYN, - MXC_AUDMUX_V2_PDCR_RXDSEL(0) - ); -#endif - imx35_add_imx_uart1(&uart_pdata); imx35_add_ipu_core(&mx3_ipu_data); imx35_add_mx3_sdc_fb(&mx3fb_pdata); diff --git a/sound/soc/imx/eukrea-tlv320.c b/sound/soc/imx/eukrea-tlv320.c index 1c1fdd1..bfcb6d9 100644 --- a/sound/soc/imx/eukrea-tlv320.c +++ b/sound/soc/imx/eukrea-tlv320.c @@ -23,6 +23,7 @@ #include <sound/pcm.h> #include <sound/soc.h> #include <asm/mach-types.h> +#include <mach/audmux.h>
#include "../codecs/tlv320aic23.h" #include "imx-ssi.h" @@ -97,12 +98,43 @@ static struct platform_device *eukrea_tlv320_snd_device; static int __init eukrea_tlv320_init(void) { int ret; - - if (!machine_is_eukrea_cpuimx27() && !machine_is_eukrea_cpuimx25sd() - && !machine_is_eukrea_cpuimx35sd() - && !machine_is_eukrea_cpuimx51sd()) + int int_port = 0, ext_port; + + if (machine_is_eukrea_cpuimx27()) { + mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, + MXC_AUDMUX_V1_PCR_SYN | + MXC_AUDMUX_V1_PCR_TFSDIR | + MXC_AUDMUX_V1_PCR_TCLKDIR | + MXC_AUDMUX_V1_PCR_RFSDIR | + MXC_AUDMUX_V1_PCR_RCLKDIR | + MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | + MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | + MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) + ); + mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4, + MXC_AUDMUX_V1_PCR_SYN | + MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) + ); + } else if (machine_is_eukrea_cpuimx25sd() || + machine_is_eukrea_cpuimx35sd() || + machine_is_eukrea_cpuimx51sd()) { + ext_port = machine_is_eukrea_cpuimx25sd() ? 4 : 3; + mxc_audmux_v2_configure_port(int_port, + MXC_AUDMUX_V2_PTCR_SYN | + MXC_AUDMUX_V2_PTCR_TFSDIR | + MXC_AUDMUX_V2_PTCR_TFSEL(ext_port) | + MXC_AUDMUX_V2_PTCR_TCLKDIR | + MXC_AUDMUX_V2_PTCR_TCSEL(ext_port), + MXC_AUDMUX_V2_PDCR_RXDSEL(ext_port) + ); + mxc_audmux_v2_configure_port(ext_port, + MXC_AUDMUX_V2_PTCR_SYN, + MXC_AUDMUX_V2_PDCR_RXDSEL(int_port) + ); + } else { /* return happy. We might run on a totally different machine */ return 0; + }
eukrea_tlv320_snd_device = platform_device_alloc("soc-audio", -1); if (!eukrea_tlv320_snd_device)
On Mon, Mar 05, 2012 at 10:30:49PM +0800, Shawn Guo wrote:
It moves eukrea audmux configuration call from board file into ASoC machine driver eukrea-tlv320, so that it gets aligned wm1133-ev1 and mx27vis-aic32x4, and more importantly it will ease the moving of audmux into sound/soc/imx as a platform driver later.
Sascha, this and the second patch look totally uncontroversial - can we just apply them now so we don't need to keep reviewing them?
How will this stand up to an machine audio fabric that, like imx-sgtl5000 going around BSPs and Linaro and so on since the dawn of time, supports multiple boards but very different audmux configurations? Is this just a stopgap until the DT properly describes it?
On Mon, Mar 05, 2012 at 11:55:07AM -0600, Matt Sealey wrote:
How will this stand up to an machine audio fabric that, like
"This" would be a lot more meaningful if you'd included some context in your reply so the reader could tell what you were talking about.
imx-sgtl5000 going around BSPs and Linaro and so on since the dawn of time, supports multiple boards but very different audmux configurations? Is this just a stopgap until the DT properly describes it?
What are the limitations which you see in the new code?
On Mon, Mar 05, 2012 at 05:46:13PM +0000, Mark Brown wrote:
On Mon, Mar 05, 2012 at 10:30:49PM +0800, Shawn Guo wrote:
It moves eukrea audmux configuration call from board file into ASoC machine driver eukrea-tlv320, so that it gets aligned wm1133-ev1 and mx27vis-aic32x4, and more importantly it will ease the moving of audmux into sound/soc/imx as a platform driver later.
Sascha, this and the second patch look totally uncontroversial - can we just apply them now so we don't need to keep reviewing them?
For patches 01-08 I can give my:
Acked-by: Sascha Hauer s.hauer@pengutronix.de
The rest I would like to test. Shawn, on what is this series based? It neither applies on v3.3-rc6 nor on arm-soc/for-next.
Sascha
On Mon, Mar 05, 2012 at 08:27:59PM +0100, Sascha Hauer wrote: ...
For patches 01-08 I can give my:
Acked-by: Sascha Hauer s.hauer@pengutronix.de
The rest I would like to test. Shawn, on what is this series based? It neither applies on v3.3-rc6 nor on arm-soc/for-next.
As I intend to have the series go through Mark's tree, I based it on sound/for-next.
On Mon, Mar 05, 2012 at 08:27:59PM +0100, Sascha Hauer wrote:
For patches 01-08 I can give my:
Acked-by: Sascha Hauer s.hauer@pengutronix.de
Great, applied all those - thanks!
It moves phycore audmux configuration call from board file into ASoC machine driver phycore-ac97 to ease converting audmux into a platform driver later. It moves phycore audmux configuration call from board file into ASoC machine driver phycore-ac97, so that it gets aligned with wm1133-ev1 and mx27vis-aic32x4, and more importantly it will ease the moving of audmux into sound/soc/imx as a platform driver later.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- arch/arm/mach-imx/mach-pca100.c | 13 ------------- arch/arm/mach-imx/mach-pcm043.c | 13 ------------- sound/soc/imx/phycore-ac97.c | 26 +++++++++++++++++++++++++- 3 files changed, 25 insertions(+), 27 deletions(-)
diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c index d3b9c6b..541152e 100644 --- a/arch/arm/mach-imx/mach-pca100.c +++ b/arch/arm/mach-imx/mach-pca100.c @@ -36,7 +36,6 @@ #include <mach/hardware.h> #include <mach/iomux-mx27.h> #include <asm/mach/time.h> -#include <mach/audmux.h> #include <mach/irqs.h> #include <mach/ulpi.h>
@@ -359,18 +358,6 @@ static void __init pca100_init(void)
imx27_soc_init();
- /* SSI unit */ - mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, - MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */ - MXC_AUDMUX_V1_PCR_TFCSEL(3) | - MXC_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */ - MXC_AUDMUX_V1_PCR_RXDSEL(3)); - mxc_audmux_v1_configure_port(3, - MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */ - MXC_AUDMUX_V1_PCR_TFCSEL(0) | - MXC_AUDMUX_V1_PCR_TFSDIR | - MXC_AUDMUX_V1_PCR_RXDSEL(0)); - ret = mxc_gpio_setup_multiple_pins(pca100_pins, ARRAY_SIZE(pca100_pins), "PCA100"); if (ret) diff --git a/arch/arm/mach-imx/mach-pcm043.c b/arch/arm/mach-imx/mach-pcm043.c index 06dc106..237474f 100644 --- a/arch/arm/mach-imx/mach-pcm043.c +++ b/arch/arm/mach-imx/mach-pcm043.c @@ -37,7 +37,6 @@ #include <mach/common.h> #include <mach/iomux-mx35.h> #include <mach/ulpi.h> -#include <mach/audmux.h>
#include "devices-imx35.h"
@@ -362,18 +361,6 @@ static void __init pcm043_init(void)
mxc_iomux_v3_setup_multiple_pads(pcm043_pads, ARRAY_SIZE(pcm043_pads));
- mxc_audmux_v2_configure_port(3, - MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ - MXC_AUDMUX_V2_PTCR_TFSEL(0) | - MXC_AUDMUX_V2_PTCR_TFSDIR, - MXC_AUDMUX_V2_PDCR_RXDSEL(0)); - - mxc_audmux_v2_configure_port(0, - MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ - MXC_AUDMUX_V2_PTCR_TCSEL(3) | - MXC_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */ - MXC_AUDMUX_V2_PDCR_RXDSEL(3)); - imx35_add_fec(NULL); platform_add_devices(devices, ARRAY_SIZE(devices)); imx35_add_imx2_wdt(NULL); diff --git a/sound/soc/imx/phycore-ac97.c b/sound/soc/imx/phycore-ac97.c index 6ac1211..a59692e 100644 --- a/sound/soc/imx/phycore-ac97.c +++ b/sound/soc/imx/phycore-ac97.c @@ -18,6 +18,7 @@ #include <sound/pcm.h> #include <sound/soc.h> #include <asm/mach-types.h> +#include <mach/audmux.h>
static struct snd_soc_card imx_phycore;
@@ -50,9 +51,32 @@ static int __init imx_phycore_init(void) { int ret;
- if (!machine_is_pcm043() && !machine_is_pca100()) + if (machine_is_pca100()) { + mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, + MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */ + MXC_AUDMUX_V1_PCR_TFCSEL(3) | + MXC_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */ + MXC_AUDMUX_V1_PCR_RXDSEL(3)); + mxc_audmux_v1_configure_port(3, + MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */ + MXC_AUDMUX_V1_PCR_TFCSEL(0) | + MXC_AUDMUX_V1_PCR_TFSDIR | + MXC_AUDMUX_V1_PCR_RXDSEL(0)); + } else if (machine_is_pcm043()) { + mxc_audmux_v2_configure_port(3, + MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ + MXC_AUDMUX_V2_PTCR_TFSEL(0) | + MXC_AUDMUX_V2_PTCR_TFSDIR, + MXC_AUDMUX_V2_PDCR_RXDSEL(0)); + mxc_audmux_v2_configure_port(0, + MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ + MXC_AUDMUX_V2_PTCR_TCSEL(3) | + MXC_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */ + MXC_AUDMUX_V2_PDCR_RXDSEL(3)); + } else { /* return happy. We might run on a totally different machine */ return 0; + }
imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1); if (!imx_phycore_snd_ac97_device)
It merges audmux-v1 and audmux-v2 under arch/arm/plat-mxc into one.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- arch/arm/mach-imx/Kconfig | 12 +++--- arch/arm/plat-mxc/Kconfig | 5 +-- arch/arm/plat-mxc/Makefile | 3 +- arch/arm/plat-mxc/audmux-v1.c | 64 --------------------------- arch/arm/plat-mxc/{audmux-v2.c => audmux.c} | 29 +++++++++++- 5 files changed, 34 insertions(+), 79 deletions(-) delete mode 100644 arch/arm/plat-mxc/audmux-v1.c rename arch/arm/plat-mxc/{audmux-v2.c => audmux.c} (89%)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 4defb97..495a854 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -46,7 +46,7 @@ config SOC_IMX21 bool select MACH_MX21 select CPU_ARM926T - select ARCH_MXC_AUDMUX_V1 + select ARCH_MXC_AUDMUX select IMX_HAVE_DMA_V1 select IMX_HAVE_IOMUX_V1 select MXC_AVIC @@ -55,7 +55,7 @@ config SOC_IMX25 bool select ARCH_MX25 select CPU_ARM926T - select ARCH_MXC_AUDMUX_V2 + select ARCH_MXC_AUDMUX select ARCH_MXC_IOMUX_V3 select MXC_AVIC
@@ -63,7 +63,7 @@ config SOC_IMX27 bool select MACH_MX27 select CPU_ARM926T - select ARCH_MXC_AUDMUX_V1 + select ARCH_MXC_AUDMUX select IMX_HAVE_DMA_V1 select IMX_HAVE_IOMUX_V1 select MXC_AVIC @@ -72,7 +72,7 @@ config SOC_IMX31 bool select CPU_V6 select IMX_HAVE_PLATFORM_MXC_RNGA - select ARCH_MXC_AUDMUX_V2 + select ARCH_MXC_AUDMUX select MXC_AVIC select SMP_ON_UP if SMP
@@ -80,7 +80,7 @@ config SOC_IMX35 bool select CPU_V6 select ARCH_MXC_IOMUX_V3 - select ARCH_MXC_AUDMUX_V2 + select ARCH_MXC_AUDMUX select HAVE_EPIT select MXC_AVIC select SMP_ON_UP if SMP @@ -89,7 +89,7 @@ config SOC_IMX5 select CPU_V7 select MXC_TZIC select ARCH_MXC_IOMUX_V3 - select ARCH_MXC_AUDMUX_V2 + select ARCH_MXC_AUDMUX select ARCH_HAS_CPUFREQ select ARCH_MX5 bool diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig index dcebb12..0461d16 100644 --- a/arch/arm/plat-mxc/Kconfig +++ b/arch/arm/plat-mxc/Kconfig @@ -88,10 +88,7 @@ config IMX_HAVE_IOMUX_V1 config ARCH_MXC_IOMUX_V3 bool
-config ARCH_MXC_AUDMUX_V1 - bool - -config ARCH_MXC_AUDMUX_V2 +config ARCH_MXC_AUDMUX bool
config IRAM_ALLOC diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile index 076db84f..530c81d 100644 --- a/arch/arm/plat-mxc/Makefile +++ b/arch/arm/plat-mxc/Makefile @@ -14,8 +14,7 @@ obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o obj-$(CONFIG_MXC_PWM) += pwm.o obj-$(CONFIG_MXC_ULPI) += ulpi.o obj-$(CONFIG_MXC_USE_EPIT) += epit.o -obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o -obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o +obj-$(CONFIG_ARCH_MXC_AUDMUX) += audmux.o obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o ifdef CONFIG_SND_IMX_SOC diff --git a/arch/arm/plat-mxc/audmux-v1.c b/arch/arm/plat-mxc/audmux-v1.c deleted file mode 100644 index 1180bef..0000000 --- a/arch/arm/plat-mxc/audmux-v1.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2009 Pengutronix, Sascha Hauer s.hauer@pengutronix.de - * - * Initial development of this code was funded by - * Phytec Messtechnik GmbH, http://www.phytec.de - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include <linux/module.h> -#include <linux/err.h> -#include <linux/io.h> -#include <linux/clk.h> -#include <mach/audmux.h> -#include <mach/hardware.h> - -static void __iomem *audmux_base; - -static unsigned char port_mapping[] = { - 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c, -}; - -int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr) -{ - if (!audmux_base) { - printk("%s: not configured\n", __func__); - return -ENOSYS; - } - - if (port >= ARRAY_SIZE(port_mapping)) - return -EINVAL; - - writel(pcr, audmux_base + port_mapping[port]); - - return 0; -} -EXPORT_SYMBOL_GPL(mxc_audmux_v1_configure_port); - -static int mxc_audmux_v1_init(void) -{ -#ifdef CONFIG_MACH_MX21 - if (cpu_is_mx21()) - audmux_base = MX21_IO_ADDRESS(MX21_AUDMUX_BASE_ADDR); - else -#endif -#ifdef CONFIG_MACH_MX27 - if (cpu_is_mx27()) - audmux_base = MX27_IO_ADDRESS(MX27_AUDMUX_BASE_ADDR); - else -#endif - (void)0; - - return 0; -} - -postcore_initcall(mxc_audmux_v1_init); diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux.c similarity index 89% rename from arch/arm/plat-mxc/audmux-v2.c rename to arch/arm/plat-mxc/audmux.c index 8cced35..b49a39f 100644 --- a/arch/arm/plat-mxc/audmux-v2.c +++ b/arch/arm/plat-mxc/audmux.c @@ -165,6 +165,24 @@ static inline void audmux_debugfs_init(void) } #endif
+static const uint8_t port_mapping[] = { + 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c, +}; + +int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr) +{ + if (!audmux_base) + return -ENOSYS; + + if (port >= ARRAY_SIZE(port_mapping)) + return -EINVAL; + + writel(pcr, audmux_base + port_mapping[port]); + + return 0; +} +EXPORT_SYMBOL_GPL(mxc_audmux_v1_configure_port); + int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, unsigned int pdcr) { @@ -184,7 +202,7 @@ int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, } EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port);
-static int mxc_audmux_v2_init(void) +static int mxc_audmux_init(void) { int ret; if (cpu_is_mx51()) { @@ -209,11 +227,16 @@ static int mxc_audmux_v2_init(void) return ret; } audmux_base = MX25_IO_ADDRESS(MX25_AUDMUX_BASE_ADDR); + } else if (cpu_is_mx27()) { + audmux_base = MX27_IO_ADDRESS(MX27_AUDMUX_BASE_ADDR); + } else if (cpu_is_mx21()) { + audmux_base = MX21_IO_ADDRESS(MX21_AUDMUX_BASE_ADDR); }
- audmux_debugfs_init(); + if (!cpu_is_mx2()) + audmux_debugfs_init();
return 0; }
-postcore_initcall(mxc_audmux_v2_init); +postcore_initcall(mxc_audmux_init);
From: Richard Zhao richard.zhao@linaro.org
It coverts audmux to a platform driver, so that it can be moved into sound/soc/imx and adopt device tree support later.
Signed-off-by: Richard Zhao richard.zhao@linaro.org Signed-off-by: Shawn Guo shawn.guo@linaro.org --- arch/arm/mach-imx/mm-imx21.c | 6 ++ arch/arm/mach-imx/mm-imx25.c | 7 ++ arch/arm/mach-imx/mm-imx27.c | 7 ++ arch/arm/mach-imx/mm-imx3.c | 13 ++++ arch/arm/mach-imx/mm-imx5.c | 22 +++++++ arch/arm/plat-mxc/audmux.c | 127 ++++++++++++++++++++++++++++++------------ 6 files changed, 147 insertions(+), 35 deletions(-)
diff --git a/arch/arm/mach-imx/mm-imx21.c b/arch/arm/mach-imx/mm-imx21.c index 3f05dfe..14d540e 100644 --- a/arch/arm/mach-imx/mm-imx21.c +++ b/arch/arm/mach-imx/mm-imx21.c @@ -75,6 +75,10 @@ void __init mx21_init_irq(void) mxc_init_irq(MX21_IO_ADDRESS(MX21_AVIC_BASE_ADDR)); }
+static const struct resource imx21_audmux_res[] __initconst = { + DEFINE_RES_MEM(MX21_AUDMUX_BASE_ADDR, SZ_4K), +}; + void __init imx21_soc_init(void) { mxc_register_gpio("imx21-gpio", 0, MX21_GPIO1_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); @@ -85,4 +89,6 @@ void __init imx21_soc_init(void) mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0);
imx_add_imx_dma(); + platform_device_register_simple("imx21-audmux", 0, imx21_audmux_res, + ARRAY_SIZE(imx21_audmux_res)); } diff --git a/arch/arm/mach-imx/mm-imx25.c b/arch/arm/mach-imx/mm-imx25.c index cc4d152..153b457 100644 --- a/arch/arm/mach-imx/mm-imx25.c +++ b/arch/arm/mach-imx/mm-imx25.c @@ -83,6 +83,10 @@ static struct sdma_platform_data imx25_sdma_pdata __initdata = { .script_addrs = &imx25_sdma_script, };
+static const struct resource imx25_audmux_res[] __initconst = { + DEFINE_RES_MEM(MX25_AUDMUX_BASE_ADDR, SZ_16K), +}; + void __init imx25_soc_init(void) { /* i.mx25 has the i.mx31 type gpio */ @@ -93,4 +97,7 @@ void __init imx25_soc_init(void)
/* i.mx25 has the i.mx35 type sdma */ imx_add_imx_sdma("imx35-sdma", MX25_SDMA_BASE_ADDR, MX25_INT_SDMA, &imx25_sdma_pdata); + /* i.mx25 has the i.mx31 type audmux */ + platform_device_register_simple("imx31-audmux", 0, imx25_audmux_res, + ARRAY_SIZE(imx25_audmux_res)); } diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c index 96dd1f5..8cb3f5e 100644 --- a/arch/arm/mach-imx/mm-imx27.c +++ b/arch/arm/mach-imx/mm-imx27.c @@ -75,6 +75,10 @@ void __init mx27_init_irq(void) mxc_init_irq(MX27_IO_ADDRESS(MX27_AVIC_BASE_ADDR)); }
+static const struct resource imx27_audmux_res[] __initconst = { + DEFINE_RES_MEM(MX27_AUDMUX_BASE_ADDR, SZ_4K), +}; + void __init imx27_soc_init(void) { /* i.mx27 has the i.mx21 type gpio */ @@ -86,4 +90,7 @@ void __init imx27_soc_init(void) mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0);
imx_add_imx_dma(); + /* imx27 has the imx21 type audmux */ + platform_device_register_simple("imx21-audmux", 0, imx27_audmux_res, + ARRAY_SIZE(imx27_audmux_res)); } diff --git a/arch/arm/mach-imx/mm-imx3.c b/arch/arm/mach-imx/mm-imx3.c index 31807d2..2530c15 100644 --- a/arch/arm/mach-imx/mm-imx3.c +++ b/arch/arm/mach-imx/mm-imx3.c @@ -158,6 +158,10 @@ static struct sdma_platform_data imx31_sdma_pdata __initdata = { .script_addrs = &imx31_to2_sdma_script, };
+static const struct resource imx31_audmux_res[] __initconst = { + DEFINE_RES_MEM(MX31_AUDMUX_BASE_ADDR, SZ_16K), +}; + void __init imx31_soc_init(void) { int to_version = mx31_revision() >> 4; @@ -175,6 +179,8 @@ void __init imx31_soc_init(void) }
imx_add_imx_sdma("imx31-sdma", MX31_SDMA_BASE_ADDR, MX31_INT_SDMA, &imx31_sdma_pdata); + platform_device_register_simple("imx31-audmux", 0, imx31_audmux_res, + ARRAY_SIZE(imx31_audmux_res)); } #endif /* ifdef CONFIG_SOC_IMX31 */
@@ -241,6 +247,10 @@ static struct sdma_platform_data imx35_sdma_pdata __initdata = { .script_addrs = &imx35_to2_sdma_script, };
+static const struct resource imx35_audmux_res[] __initconst = { + DEFINE_RES_MEM(MX35_AUDMUX_BASE_ADDR, SZ_16K), +}; + void __init imx35_soc_init(void) { int to_version = mx35_revision() >> 4; @@ -259,5 +269,8 @@ void __init imx35_soc_init(void) }
imx_add_imx_sdma("imx35-sdma", MX35_SDMA_BASE_ADDR, MX35_INT_SDMA, &imx35_sdma_pdata); + /* i.mx35 has the i.mx31 type audmux */ + platform_device_register_simple("imx31-audmux", 0, imx35_audmux_res, + ARRAY_SIZE(imx35_audmux_res)); } #endif /* ifdef CONFIG_SOC_IMX35 */ diff --git a/arch/arm/mach-imx/mm-imx5.c b/arch/arm/mach-imx/mm-imx5.c index bc17dfe..90d7880 100644 --- a/arch/arm/mach-imx/mm-imx5.c +++ b/arch/arm/mach-imx/mm-imx5.c @@ -170,6 +170,18 @@ static struct sdma_platform_data imx53_sdma_pdata __initdata = { .script_addrs = &imx53_sdma_script, };
+static const struct resource imx50_audmux_res[] __initconst = { + DEFINE_RES_MEM(MX50_AUDMUX_BASE_ADDR, SZ_16K), +}; + +static const struct resource imx51_audmux_res[] __initconst = { + DEFINE_RES_MEM(MX51_AUDMUX_BASE_ADDR, SZ_16K), +}; + +static const struct resource imx53_audmux_res[] __initconst = { + DEFINE_RES_MEM(MX53_AUDMUX_BASE_ADDR, SZ_16K), +}; + void __init imx50_soc_init(void) { /* i.mx50 has the i.mx31 type gpio */ @@ -179,6 +191,10 @@ void __init imx50_soc_init(void) mxc_register_gpio("imx31-gpio", 3, MX50_GPIO4_BASE_ADDR, SZ_16K, MX50_INT_GPIO4_LOW, MX50_INT_GPIO4_HIGH); mxc_register_gpio("imx31-gpio", 4, MX50_GPIO5_BASE_ADDR, SZ_16K, MX50_INT_GPIO5_LOW, MX50_INT_GPIO5_HIGH); mxc_register_gpio("imx31-gpio", 5, MX50_GPIO6_BASE_ADDR, SZ_16K, MX50_INT_GPIO6_LOW, MX50_INT_GPIO6_HIGH); + + /* i.mx50 has the i.mx31 type audmux */ + platform_device_register_simple("imx31-audmux", 0, imx50_audmux_res, + ARRAY_SIZE(imx50_audmux_res)); }
void __init imx51_soc_init(void) @@ -191,6 +207,9 @@ void __init imx51_soc_init(void)
/* i.mx51 has the i.mx35 type sdma */ imx_add_imx_sdma("imx35-sdma", MX51_SDMA_BASE_ADDR, MX51_INT_SDMA, &imx51_sdma_pdata); + /* i.mx51 has the i.mx31 type audmux */ + platform_device_register_simple("imx31-audmux", 0, imx51_audmux_res, + ARRAY_SIZE(imx51_audmux_res)); }
void __init imx53_soc_init(void) @@ -206,4 +225,7 @@ void __init imx53_soc_init(void)
/* i.mx53 has the i.mx35 type sdma */ imx_add_imx_sdma("imx35-sdma", MX53_SDMA_BASE_ADDR, MX53_INT_SDMA, &imx53_sdma_pdata); + /* i.mx53 has the i.mx31 type audmux */ + platform_device_register_simple("imx31-audmux", 0, imx53_audmux_res, + ARRAY_SIZE(imx53_audmux_res)); } diff --git a/arch/arm/plat-mxc/audmux.c b/arch/arm/plat-mxc/audmux.c index b49a39f..a8c9e04 100644 --- a/arch/arm/plat-mxc/audmux.c +++ b/arch/arm/plat-mxc/audmux.c @@ -1,4 +1,6 @@ /* + * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012 Linaro Ltd. * Copyright 2009 Pengutronix, Sascha Hauer s.hauer@pengutronix.de * * Initial development of this code was funded by @@ -15,14 +17,16 @@ * GNU General Public License for more details. */
-#include <linux/module.h> -#include <linux/err.h> -#include <linux/io.h> #include <linux/clk.h> #include <linux/debugfs.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/platform_device.h> #include <linux/slab.h> #include <mach/audmux.h> -#include <mach/hardware.h> + +#define DRIVER_NAME "imx-audmux"
static struct clk *audmux_clk; static void __iomem *audmux_base; @@ -140,7 +144,7 @@ static const struct file_operations audmux_debugfs_fops = { .llseek = default_llseek, };
-static void audmux_debugfs_init(void) +static void __init audmux_debugfs_init(void) { int i; char buf[20]; @@ -159,18 +163,48 @@ static void audmux_debugfs_init(void) i); } } + +static void __exit audmux_debugfs_remove(void) +{ + debugfs_remove_recursive(audmux_debugfs_root); +} #else static inline void audmux_debugfs_init(void) { } + +static inline void audmux_debugfs_remove(void) +{ +} #endif
+enum imx_audmux_type { + IMX21_AUDMUX, + IMX31_AUDMUX, +} audmux_type; + +static struct platform_device_id imx_audmux_ids[] = { + { + .name = "imx21-audmux", + .driver_data = IMX21_AUDMUX, + }, { + .name = "imx31-audmux", + .driver_data = IMX31_AUDMUX, + }, { + /* sentinel */ + } +}; +MODULE_DEVICE_TABLE(platform, imx_audmux_ids); + static const uint8_t port_mapping[] = { 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c, };
int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr) { + if (audmux_type != IMX21_AUDMUX) + return -EINVAL; + if (!audmux_base) return -ENOSYS;
@@ -186,6 +220,9 @@ EXPORT_SYMBOL_GPL(mxc_audmux_v1_configure_port); int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, unsigned int pdcr) { + if (audmux_type != IMX31_AUDMUX) + return -EINVAL; + if (!audmux_base) return -ENOSYS;
@@ -202,41 +239,61 @@ int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, } EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port);
-static int mxc_audmux_init(void) +static int __init imx_audmux_probe(struct platform_device *pdev) { - int ret; - if (cpu_is_mx51()) { - audmux_base = MX51_IO_ADDRESS(MX51_AUDMUX_BASE_ADDR); - } else if (cpu_is_mx31()) { - audmux_base = MX31_IO_ADDRESS(MX31_AUDMUX_BASE_ADDR); - } else if (cpu_is_mx35()) { - audmux_clk = clk_get(NULL, "audmux"); - if (IS_ERR(audmux_clk)) { - ret = PTR_ERR(audmux_clk); - printk(KERN_ERR "%s: cannot get clock: %d\n", __func__, - ret); - return ret; - } - audmux_base = MX35_IO_ADDRESS(MX35_AUDMUX_BASE_ADDR); - } else if (cpu_is_mx25()) { - audmux_clk = clk_get(NULL, "audmux"); - if (IS_ERR(audmux_clk)) { - ret = PTR_ERR(audmux_clk); - printk(KERN_ERR "%s: cannot get clock: %d\n", __func__, - ret); - return ret; - } - audmux_base = MX25_IO_ADDRESS(MX25_AUDMUX_BASE_ADDR); - } else if (cpu_is_mx27()) { - audmux_base = MX27_IO_ADDRESS(MX27_AUDMUX_BASE_ADDR); - } else if (cpu_is_mx21()) { - audmux_base = MX21_IO_ADDRESS(MX21_AUDMUX_BASE_ADDR); + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + audmux_base = devm_request_and_ioremap(&pdev->dev, res); + if (!audmux_base) + return -EADDRNOTAVAIL; + + audmux_clk = clk_get(&pdev->dev, "audmux"); + if (IS_ERR(audmux_clk)) { + dev_dbg(&pdev->dev, "cannot get clock: %ld\n", + PTR_ERR(audmux_clk)); + audmux_clk = NULL; }
- if (!cpu_is_mx2()) + audmux_type = pdev->id_entry->driver_data; + if (audmux_type == IMX31_AUDMUX) audmux_debugfs_init();
return 0; }
-postcore_initcall(mxc_audmux_init); +static int __exit imx_audmux_remove(struct platform_device *pdev) +{ + if (audmux_type == IMX31_AUDMUX) + audmux_debugfs_remove(); + clk_put(audmux_clk); + + return 0; +} + +static struct platform_driver imx_audmux_driver = { + .probe = imx_audmux_probe, + .remove = __exit_p(imx_audmux_remove), + .id_table = imx_audmux_ids, + .driver = { + .name = DRIVER_NAME, + .owner = THIS_MODULE, + } +}; + +static int __init imx_audmux_init(void) +{ + return platform_driver_register(&imx_audmux_driver); +} +subsys_initcall(imx_audmux_init); + +static void __exit imx_audmux_exit(void) +{ + platform_driver_unregister(&imx_audmux_driver); +} +module_exit(imx_audmux_exit); + +MODULE_DESCRIPTION("Freescale i.MX AUDMUX driver"); +MODULE_AUTHOR("Sascha Hauer s.hauer@pengutronix.de"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRIVER_NAME);
As audmux becomes a platform driver and its callers are all ASoC machine drivers, there is no reason to keep it in arch folder, so move it to sound/soc/imx.
One bonus point would be those ASoC machine drivers stop including mach/audmux.h, since it's been moved to sound/soc/imx/imx-audmux.h. This should be a move to the right direction in terms of single kernel image goal.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- arch/arm/mach-imx/Kconfig | 6 ------ arch/arm/mach-imx/eukrea_mbimxsd-baseboard.c | 1 - arch/arm/plat-mxc/Kconfig | 3 --- arch/arm/plat-mxc/Makefile | 1 - sound/soc/imx/Kconfig | 7 +++++++ sound/soc/imx/Makefile | 2 ++ sound/soc/imx/eukrea-tlv320.c | 2 +- .../audmux.c => sound/soc/imx/imx-audmux.c | 3 ++- .../mach/audmux.h => sound/soc/imx/imx-audmux.h | 6 +++--- sound/soc/imx/mx27vis-aic32x4.c | 2 +- sound/soc/imx/phycore-ac97.c | 3 ++- sound/soc/imx/wm1133-ev1.c | 3 +-- 12 files changed, 19 insertions(+), 20 deletions(-) rename arch/arm/plat-mxc/audmux.c => sound/soc/imx/imx-audmux.c (99%) rename arch/arm/plat-mxc/include/mach/audmux.h => sound/soc/imx/imx-audmux.h (96%)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 495a854..3919fba 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -46,7 +46,6 @@ config SOC_IMX21 bool select MACH_MX21 select CPU_ARM926T - select ARCH_MXC_AUDMUX select IMX_HAVE_DMA_V1 select IMX_HAVE_IOMUX_V1 select MXC_AVIC @@ -55,7 +54,6 @@ config SOC_IMX25 bool select ARCH_MX25 select CPU_ARM926T - select ARCH_MXC_AUDMUX select ARCH_MXC_IOMUX_V3 select MXC_AVIC
@@ -63,7 +61,6 @@ config SOC_IMX27 bool select MACH_MX27 select CPU_ARM926T - select ARCH_MXC_AUDMUX select IMX_HAVE_DMA_V1 select IMX_HAVE_IOMUX_V1 select MXC_AVIC @@ -72,7 +69,6 @@ config SOC_IMX31 bool select CPU_V6 select IMX_HAVE_PLATFORM_MXC_RNGA - select ARCH_MXC_AUDMUX select MXC_AVIC select SMP_ON_UP if SMP
@@ -80,7 +76,6 @@ config SOC_IMX35 bool select CPU_V6 select ARCH_MXC_IOMUX_V3 - select ARCH_MXC_AUDMUX select HAVE_EPIT select MXC_AVIC select SMP_ON_UP if SMP @@ -89,7 +84,6 @@ config SOC_IMX5 select CPU_V7 select MXC_TZIC select ARCH_MXC_IOMUX_V3 - select ARCH_MXC_AUDMUX select ARCH_HAS_CPUFREQ select ARCH_MX5 bool diff --git a/arch/arm/mach-imx/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-imx/eukrea_mbimxsd-baseboard.c index d817fc8..aaa592f 100644 --- a/arch/arm/mach-imx/eukrea_mbimxsd-baseboard.c +++ b/arch/arm/mach-imx/eukrea_mbimxsd-baseboard.c @@ -37,7 +37,6 @@ #include <mach/hardware.h> #include <mach/common.h> #include <mach/iomux-mx51.h> -#include <mach/audmux.h>
#include "devices-imx51.h"
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig index 0461d16..c722f9c 100644 --- a/arch/arm/plat-mxc/Kconfig +++ b/arch/arm/plat-mxc/Kconfig @@ -88,9 +88,6 @@ config IMX_HAVE_IOMUX_V1 config ARCH_MXC_IOMUX_V3 bool
-config ARCH_MXC_AUDMUX - bool - config IRAM_ALLOC bool select GENERIC_ALLOCATOR diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile index 530c81d..e81290c 100644 --- a/arch/arm/plat-mxc/Makefile +++ b/arch/arm/plat-mxc/Makefile @@ -14,7 +14,6 @@ obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o obj-$(CONFIG_MXC_PWM) += pwm.o obj-$(CONFIG_MXC_ULPI) += ulpi.o obj-$(CONFIG_MXC_USE_EPIT) += epit.o -obj-$(CONFIG_ARCH_MXC_AUDMUX) += audmux.o obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o ifdef CONFIG_SND_IMX_SOC diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig index aa4294b..d3b7166 100644 --- a/sound/soc/imx/Kconfig +++ b/sound/soc/imx/Kconfig @@ -16,11 +16,15 @@ config SND_MXC_SOC_MX2 select SND_SOC_DMAENGINE_PCM tristate
+config SND_SOC_IMX_AUDMUX + tristate + config SND_MXC_SOC_WM1133_EV1 tristate "Audio on the the i.MX31ADS with WM1133-EV1 fitted" depends on MACH_MX31ADS_WM1133_EV1 && EXPERIMENTAL select SND_SOC_WM8350 select SND_MXC_SOC_FIQ + select SND_SOC_IMX_AUDMUX help Enable support for audio on the i.MX31ADS with the WM1133-EV1 PMIC board with WM8835x fitted. @@ -30,6 +34,7 @@ config SND_SOC_MX27VIS_AIC32X4 depends on MACH_IMX27_VISSTRIM_M10 && I2C select SND_SOC_TLV320AIC32X4 select SND_MXC_SOC_MX2 + select SND_SOC_IMX_AUDMUX help Say Y if you want to add support for SoC audio on Visstrim SM10 board with TLV320AIC32X4 codec. @@ -40,6 +45,7 @@ config SND_SOC_PHYCORE_AC97 select SND_SOC_AC97_BUS select SND_SOC_WM9712 select SND_MXC_SOC_FIQ + select SND_SOC_IMX_AUDMUX help Say Y if you want to add support for SoC audio on Phytec phyCORE and phyCARD boards in AC97 mode @@ -53,6 +59,7 @@ config SND_SOC_EUKREA_TLV320 depends on I2C select SND_SOC_TLV320AIC23 select SND_MXC_SOC_FIQ + select SND_SOC_IMX_AUDMUX help Enable I2S based access to the TLV320AIC23B codec attached to the SSI interface diff --git a/sound/soc/imx/Makefile b/sound/soc/imx/Makefile index d6d609b..5c40541 100644 --- a/sound/soc/imx/Makefile +++ b/sound/soc/imx/Makefile @@ -2,10 +2,12 @@ snd-soc-imx-objs := imx-ssi.o snd-soc-imx-fiq-objs := imx-pcm-fiq.o snd-soc-imx-mx2-objs := imx-pcm-dma-mx2.o +snd-soc-imx-audmux-objs := imx-audmux.o
obj-$(CONFIG_SND_IMX_SOC) += snd-soc-imx.o obj-$(CONFIG_SND_MXC_SOC_FIQ) += snd-soc-imx-fiq.o obj-$(CONFIG_SND_MXC_SOC_MX2) += snd-soc-imx-mx2.o +obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o
# i.MX Machine Support snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o diff --git a/sound/soc/imx/eukrea-tlv320.c b/sound/soc/imx/eukrea-tlv320.c index bfcb6d9..b375ed4 100644 --- a/sound/soc/imx/eukrea-tlv320.c +++ b/sound/soc/imx/eukrea-tlv320.c @@ -23,10 +23,10 @@ #include <sound/pcm.h> #include <sound/soc.h> #include <asm/mach-types.h> -#include <mach/audmux.h>
#include "../codecs/tlv320aic23.h" #include "imx-ssi.h" +#include "imx-audmux.h"
#define CODEC_CLOCK 12000000
diff --git a/arch/arm/plat-mxc/audmux.c b/sound/soc/imx/imx-audmux.c similarity index 99% rename from arch/arm/plat-mxc/audmux.c rename to sound/soc/imx/imx-audmux.c index a8c9e04..7b16266 100644 --- a/arch/arm/plat-mxc/audmux.c +++ b/sound/soc/imx/imx-audmux.c @@ -24,7 +24,8 @@ #include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> -#include <mach/audmux.h> + +#include "imx-audmux.h"
#define DRIVER_NAME "imx-audmux"
diff --git a/arch/arm/plat-mxc/include/mach/audmux.h b/sound/soc/imx/imx-audmux.h similarity index 96% rename from arch/arm/plat-mxc/include/mach/audmux.h rename to sound/soc/imx/imx-audmux.h index 6fda788..5136d948 100644 --- a/arch/arm/plat-mxc/include/mach/audmux.h +++ b/sound/soc/imx/imx-audmux.h @@ -1,5 +1,5 @@ -#ifndef __MACH_AUDMUX_H -#define __MACH_AUDMUX_H +#ifndef __IMX_AUDMUX_H +#define __IMX_AUDMUX_H
#define MX27_AUDMUX_HPCR1_SSI0 0 #define MX27_AUDMUX_HPCR2_SSI1 1 @@ -57,4 +57,4 @@ int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr); int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, unsigned int pdcr);
-#endif /* __MACH_AUDMUX_H */ +#endif /* __IMX_AUDMUX_H */ diff --git a/sound/soc/imx/mx27vis-aic32x4.c b/sound/soc/imx/mx27vis-aic32x4.c index 155899c..dbfad0f 100644 --- a/sound/soc/imx/mx27vis-aic32x4.c +++ b/sound/soc/imx/mx27vis-aic32x4.c @@ -32,11 +32,11 @@ #include <sound/soc-dapm.h> #include <sound/tlv.h> #include <asm/mach-types.h> -#include <mach/audmux.h> #include <mach/iomux-mx27.h>
#include "../codecs/tlv320aic32x4.h" #include "imx-ssi.h" +#include "imx-audmux.h"
#define MX27VIS_AMP_GAIN 0 #define MX27VIS_AMP_MUTE 1 diff --git a/sound/soc/imx/phycore-ac97.c b/sound/soc/imx/phycore-ac97.c index a59692e..7dab077 100644 --- a/sound/soc/imx/phycore-ac97.c +++ b/sound/soc/imx/phycore-ac97.c @@ -18,7 +18,8 @@ #include <sound/pcm.h> #include <sound/soc.h> #include <asm/mach-types.h> -#include <mach/audmux.h> + +#include "imx-audmux.h"
static struct snd_soc_card imx_phycore;
diff --git a/sound/soc/imx/wm1133-ev1.c b/sound/soc/imx/wm1133-ev1.c index 37480c9..15056d6 100644 --- a/sound/soc/imx/wm1133-ev1.c +++ b/sound/soc/imx/wm1133-ev1.c @@ -21,10 +21,9 @@ #include <sound/pcm_params.h> #include <sound/soc.h>
-#include <mach/audmux.h> - #include "imx-ssi.h" #include "../codecs/wm8350.h" +#include "imx-audmux.h"
/* There is a silicon mic on the board optionally connected via a solder pad * SP1. Define this to enable it.
It renames the legacy name mxc used in audmux function and macro to imx.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/imx/eukrea-tlv320.c | 44 +++++++++++++++--------------- sound/soc/imx/imx-audmux.c | 30 ++++++++++---------- sound/soc/imx/imx-audmux.h | 58 +++++++++++++++++++------------------- sound/soc/imx/mx27vis-aic32x4.c | 18 ++++++------ sound/soc/imx/phycore-ac97.c | 40 +++++++++++++------------- sound/soc/imx/wm1133-ev1.c | 22 +++++++------- 6 files changed, 106 insertions(+), 106 deletions(-)
diff --git a/sound/soc/imx/eukrea-tlv320.c b/sound/soc/imx/eukrea-tlv320.c index b375ed4..7d4475c 100644 --- a/sound/soc/imx/eukrea-tlv320.c +++ b/sound/soc/imx/eukrea-tlv320.c @@ -101,35 +101,35 @@ static int __init eukrea_tlv320_init(void) int int_port = 0, ext_port;
if (machine_is_eukrea_cpuimx27()) { - mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, - MXC_AUDMUX_V1_PCR_SYN | - MXC_AUDMUX_V1_PCR_TFSDIR | - MXC_AUDMUX_V1_PCR_TCLKDIR | - MXC_AUDMUX_V1_PCR_RFSDIR | - MXC_AUDMUX_V1_PCR_RCLKDIR | - MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | - MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | - MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) + imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, + IMX_AUDMUX_V1_PCR_SYN | + IMX_AUDMUX_V1_PCR_TFSDIR | + IMX_AUDMUX_V1_PCR_TCLKDIR | + IMX_AUDMUX_V1_PCR_RFSDIR | + IMX_AUDMUX_V1_PCR_RCLKDIR | + IMX_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | + IMX_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | + IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) ); - mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4, - MXC_AUDMUX_V1_PCR_SYN | - MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) + imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4, + IMX_AUDMUX_V1_PCR_SYN | + IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) ); } else if (machine_is_eukrea_cpuimx25sd() || machine_is_eukrea_cpuimx35sd() || machine_is_eukrea_cpuimx51sd()) { ext_port = machine_is_eukrea_cpuimx25sd() ? 4 : 3; - mxc_audmux_v2_configure_port(int_port, - MXC_AUDMUX_V2_PTCR_SYN | - MXC_AUDMUX_V2_PTCR_TFSDIR | - MXC_AUDMUX_V2_PTCR_TFSEL(ext_port) | - MXC_AUDMUX_V2_PTCR_TCLKDIR | - MXC_AUDMUX_V2_PTCR_TCSEL(ext_port), - MXC_AUDMUX_V2_PDCR_RXDSEL(ext_port) + imx_audmux_v2_configure_port(int_port, + IMX_AUDMUX_V2_PTCR_SYN | + IMX_AUDMUX_V2_PTCR_TFSDIR | + IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) | + IMX_AUDMUX_V2_PTCR_TCLKDIR | + IMX_AUDMUX_V2_PTCR_TCSEL(ext_port), + IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port) ); - mxc_audmux_v2_configure_port(ext_port, - MXC_AUDMUX_V2_PTCR_SYN, - MXC_AUDMUX_V2_PDCR_RXDSEL(int_port) + imx_audmux_v2_configure_port(ext_port, + IMX_AUDMUX_V2_PTCR_SYN, + IMX_AUDMUX_V2_PDCR_RXDSEL(int_port) ); } else { /* return happy. We might run on a totally different machine */ diff --git a/sound/soc/imx/imx-audmux.c b/sound/soc/imx/imx-audmux.c index 7b16266..87f8768 100644 --- a/sound/soc/imx/imx-audmux.c +++ b/sound/soc/imx/imx-audmux.c @@ -32,8 +32,8 @@ static struct clk *audmux_clk; static void __iomem *audmux_base;
-#define MXC_AUDMUX_V2_PTCR(x) ((x) * 8) -#define MXC_AUDMUX_V2_PDCR(x) ((x) * 8 + 4) +#define IMX_AUDMUX_V2_PTCR(x) ((x) * 8) +#define IMX_AUDMUX_V2_PDCR(x) ((x) * 8 + 4)
#ifdef CONFIG_DEBUG_FS static struct dentry *audmux_debugfs_root; @@ -80,8 +80,8 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, if (audmux_clk) clk_enable(audmux_clk);
- ptcr = readl(audmux_base + MXC_AUDMUX_V2_PTCR(port)); - pdcr = readl(audmux_base + MXC_AUDMUX_V2_PDCR(port)); + ptcr = readl(audmux_base + IMX_AUDMUX_V2_PTCR(port)); + pdcr = readl(audmux_base + IMX_AUDMUX_V2_PDCR(port));
if (audmux_clk) clk_disable(audmux_clk); @@ -89,7 +89,7 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n", pdcr, ptcr);
- if (ptcr & MXC_AUDMUX_V2_PTCR_TFSDIR) + if (ptcr & IMX_AUDMUX_V2_PTCR_TFSDIR) ret += snprintf(buf + ret, PAGE_SIZE - ret, "TxFS output from %s, ", audmux_port_string((ptcr >> 27) & 0x7)); @@ -97,7 +97,7 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, ret += snprintf(buf + ret, PAGE_SIZE - ret, "TxFS input, ");
- if (ptcr & MXC_AUDMUX_V2_PTCR_TCLKDIR) + if (ptcr & IMX_AUDMUX_V2_PTCR_TCLKDIR) ret += snprintf(buf + ret, PAGE_SIZE - ret, "TxClk output from %s", audmux_port_string((ptcr >> 22) & 0x7)); @@ -107,11 +107,11 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
- if (ptcr & MXC_AUDMUX_V2_PTCR_SYN) { + if (ptcr & IMX_AUDMUX_V2_PTCR_SYN) { ret += snprintf(buf + ret, PAGE_SIZE - ret, "Port is symmetric"); } else { - if (ptcr & MXC_AUDMUX_V2_PTCR_RFSDIR) + if (ptcr & IMX_AUDMUX_V2_PTCR_RFSDIR) ret += snprintf(buf + ret, PAGE_SIZE - ret, "RxFS output from %s, ", audmux_port_string((ptcr >> 17) & 0x7)); @@ -119,7 +119,7 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, ret += snprintf(buf + ret, PAGE_SIZE - ret, "RxFS input, ");
- if (ptcr & MXC_AUDMUX_V2_PTCR_RCLKDIR) + if (ptcr & IMX_AUDMUX_V2_PTCR_RCLKDIR) ret += snprintf(buf + ret, PAGE_SIZE - ret, "RxClk output from %s", audmux_port_string((ptcr >> 12) & 0x7)); @@ -201,7 +201,7 @@ static const uint8_t port_mapping[] = { 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c, };
-int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr) +int imx_audmux_v1_configure_port(unsigned int port, unsigned int pcr) { if (audmux_type != IMX21_AUDMUX) return -EINVAL; @@ -216,9 +216,9 @@ int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr)
return 0; } -EXPORT_SYMBOL_GPL(mxc_audmux_v1_configure_port); +EXPORT_SYMBOL_GPL(imx_audmux_v1_configure_port);
-int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, +int imx_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, unsigned int pdcr) { if (audmux_type != IMX31_AUDMUX) @@ -230,15 +230,15 @@ int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, if (audmux_clk) clk_enable(audmux_clk);
- writel(ptcr, audmux_base + MXC_AUDMUX_V2_PTCR(port)); - writel(pdcr, audmux_base + MXC_AUDMUX_V2_PDCR(port)); + writel(ptcr, audmux_base + IMX_AUDMUX_V2_PTCR(port)); + writel(pdcr, audmux_base + IMX_AUDMUX_V2_PDCR(port));
if (audmux_clk) clk_disable(audmux_clk);
return 0; } -EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port); +EXPORT_SYMBOL_GPL(imx_audmux_v2_configure_port);
static int __init imx_audmux_probe(struct platform_device *pdev) { diff --git a/sound/soc/imx/imx-audmux.h b/sound/soc/imx/imx-audmux.h index 5136d948..04ebbab 100644 --- a/sound/soc/imx/imx-audmux.h +++ b/sound/soc/imx/imx-audmux.h @@ -24,37 +24,37 @@ #define MX51_AUDMUX_PORT7 6
/* Register definitions for the i.MX21/27 Digital Audio Multiplexer */ -#define MXC_AUDMUX_V1_PCR_INMMASK(x) ((x) & 0xff) -#define MXC_AUDMUX_V1_PCR_INMEN (1 << 8) -#define MXC_AUDMUX_V1_PCR_TXRXEN (1 << 10) -#define MXC_AUDMUX_V1_PCR_SYN (1 << 12) -#define MXC_AUDMUX_V1_PCR_RXDSEL(x) (((x) & 0x7) << 13) -#define MXC_AUDMUX_V1_PCR_RFCSEL(x) (((x) & 0xf) << 20) -#define MXC_AUDMUX_V1_PCR_RCLKDIR (1 << 24) -#define MXC_AUDMUX_V1_PCR_RFSDIR (1 << 25) -#define MXC_AUDMUX_V1_PCR_TFCSEL(x) (((x) & 0xf) << 26) -#define MXC_AUDMUX_V1_PCR_TCLKDIR (1 << 30) -#define MXC_AUDMUX_V1_PCR_TFSDIR (1 << 31) +#define IMX_AUDMUX_V1_PCR_INMMASK(x) ((x) & 0xff) +#define IMX_AUDMUX_V1_PCR_INMEN (1 << 8) +#define IMX_AUDMUX_V1_PCR_TXRXEN (1 << 10) +#define IMX_AUDMUX_V1_PCR_SYN (1 << 12) +#define IMX_AUDMUX_V1_PCR_RXDSEL(x) (((x) & 0x7) << 13) +#define IMX_AUDMUX_V1_PCR_RFCSEL(x) (((x) & 0xf) << 20) +#define IMX_AUDMUX_V1_PCR_RCLKDIR (1 << 24) +#define IMX_AUDMUX_V1_PCR_RFSDIR (1 << 25) +#define IMX_AUDMUX_V1_PCR_TFCSEL(x) (((x) & 0xf) << 26) +#define IMX_AUDMUX_V1_PCR_TCLKDIR (1 << 30) +#define IMX_AUDMUX_V1_PCR_TFSDIR (1 << 31)
/* Register definitions for the i.MX25/31/35/51 Digital Audio Multiplexer */ -#define MXC_AUDMUX_V2_PTCR_TFSDIR (1 << 31) -#define MXC_AUDMUX_V2_PTCR_TFSEL(x) (((x) & 0xf) << 27) -#define MXC_AUDMUX_V2_PTCR_TCLKDIR (1 << 26) -#define MXC_AUDMUX_V2_PTCR_TCSEL(x) (((x) & 0xf) << 22) -#define MXC_AUDMUX_V2_PTCR_RFSDIR (1 << 21) -#define MXC_AUDMUX_V2_PTCR_RFSEL(x) (((x) & 0xf) << 17) -#define MXC_AUDMUX_V2_PTCR_RCLKDIR (1 << 16) -#define MXC_AUDMUX_V2_PTCR_RCSEL(x) (((x) & 0xf) << 12) -#define MXC_AUDMUX_V2_PTCR_SYN (1 << 11) - -#define MXC_AUDMUX_V2_PDCR_RXDSEL(x) (((x) & 0x7) << 13) -#define MXC_AUDMUX_V2_PDCR_TXRXEN (1 << 12) -#define MXC_AUDMUX_V2_PDCR_MODE(x) (((x) & 0x3) << 8) -#define MXC_AUDMUX_V2_PDCR_INMMASK(x) ((x) & 0xff) - -int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr); - -int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, +#define IMX_AUDMUX_V2_PTCR_TFSDIR (1 << 31) +#define IMX_AUDMUX_V2_PTCR_TFSEL(x) (((x) & 0xf) << 27) +#define IMX_AUDMUX_V2_PTCR_TCLKDIR (1 << 26) +#define IMX_AUDMUX_V2_PTCR_TCSEL(x) (((x) & 0xf) << 22) +#define IMX_AUDMUX_V2_PTCR_RFSDIR (1 << 21) +#define IMX_AUDMUX_V2_PTCR_RFSEL(x) (((x) & 0xf) << 17) +#define IMX_AUDMUX_V2_PTCR_RCLKDIR (1 << 16) +#define IMX_AUDMUX_V2_PTCR_RCSEL(x) (((x) & 0xf) << 12) +#define IMX_AUDMUX_V2_PTCR_SYN (1 << 11) + +#define IMX_AUDMUX_V2_PDCR_RXDSEL(x) (((x) & 0x7) << 13) +#define IMX_AUDMUX_V2_PDCR_TXRXEN (1 << 12) +#define IMX_AUDMUX_V2_PDCR_MODE(x) (((x) & 0x3) << 8) +#define IMX_AUDMUX_V2_PDCR_INMMASK(x) ((x) & 0xff) + +int imx_audmux_v1_configure_port(unsigned int port, unsigned int pcr); + +int imx_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, unsigned int pdcr);
#endif /* __IMX_AUDMUX_H */ diff --git a/sound/soc/imx/mx27vis-aic32x4.c b/sound/soc/imx/mx27vis-aic32x4.c index dbfad0f..976f857 100644 --- a/sound/soc/imx/mx27vis-aic32x4.c +++ b/sound/soc/imx/mx27vis-aic32x4.c @@ -207,16 +207,16 @@ static int __init mx27vis_aic32x4_init(void) }
/* Connect SSI0 as clock slave to SSI1 external pins */ - mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, - MXC_AUDMUX_V1_PCR_SYN | - MXC_AUDMUX_V1_PCR_TFSDIR | - MXC_AUDMUX_V1_PCR_TCLKDIR | - MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1) | - MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1) + imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, + IMX_AUDMUX_V1_PCR_SYN | + IMX_AUDMUX_V1_PCR_TFSDIR | + IMX_AUDMUX_V1_PCR_TCLKDIR | + IMX_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1) | + IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1) ); - mxc_audmux_v1_configure_port(MX27_AUDMUX_PPCR1_SSI_PINS_1, - MXC_AUDMUX_V1_PCR_SYN | - MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) + imx_audmux_v1_configure_port(MX27_AUDMUX_PPCR1_SSI_PINS_1, + IMX_AUDMUX_V1_PCR_SYN | + IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) );
ret = mxc_gpio_setup_multiple_pins(mx27vis_amp_pins, diff --git a/sound/soc/imx/phycore-ac97.c b/sound/soc/imx/phycore-ac97.c index 7dab077..f8da6dd 100644 --- a/sound/soc/imx/phycore-ac97.c +++ b/sound/soc/imx/phycore-ac97.c @@ -53,27 +53,27 @@ static int __init imx_phycore_init(void) int ret;
if (machine_is_pca100()) { - mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, - MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */ - MXC_AUDMUX_V1_PCR_TFCSEL(3) | - MXC_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */ - MXC_AUDMUX_V1_PCR_RXDSEL(3)); - mxc_audmux_v1_configure_port(3, - MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */ - MXC_AUDMUX_V1_PCR_TFCSEL(0) | - MXC_AUDMUX_V1_PCR_TFSDIR | - MXC_AUDMUX_V1_PCR_RXDSEL(0)); + imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, + IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */ + IMX_AUDMUX_V1_PCR_TFCSEL(3) | + IMX_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */ + IMX_AUDMUX_V1_PCR_RXDSEL(3)); + imx_audmux_v1_configure_port(3, + IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */ + IMX_AUDMUX_V1_PCR_TFCSEL(0) | + IMX_AUDMUX_V1_PCR_TFSDIR | + IMX_AUDMUX_V1_PCR_RXDSEL(0)); } else if (machine_is_pcm043()) { - mxc_audmux_v2_configure_port(3, - MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ - MXC_AUDMUX_V2_PTCR_TFSEL(0) | - MXC_AUDMUX_V2_PTCR_TFSDIR, - MXC_AUDMUX_V2_PDCR_RXDSEL(0)); - mxc_audmux_v2_configure_port(0, - MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ - MXC_AUDMUX_V2_PTCR_TCSEL(3) | - MXC_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */ - MXC_AUDMUX_V2_PDCR_RXDSEL(3)); + imx_audmux_v2_configure_port(3, + IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ + IMX_AUDMUX_V2_PTCR_TFSEL(0) | + IMX_AUDMUX_V2_PTCR_TFSDIR, + IMX_AUDMUX_V2_PDCR_RXDSEL(0)); + imx_audmux_v2_configure_port(0, + IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */ + IMX_AUDMUX_V2_PTCR_TCSEL(3) | + IMX_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */ + IMX_AUDMUX_V2_PDCR_RXDSEL(3)); } else { /* return happy. We might run on a totally different machine */ return 0; diff --git a/sound/soc/imx/wm1133-ev1.c b/sound/soc/imx/wm1133-ev1.c index 15056d6..fe54a69 100644 --- a/sound/soc/imx/wm1133-ev1.c +++ b/sound/soc/imx/wm1133-ev1.c @@ -267,17 +267,17 @@ static int __init wm1133_ev1_audio_init(void) unsigned int ptcr, pdcr;
/* SSI0 mastered by port 5 */ - ptcr = MXC_AUDMUX_V2_PTCR_SYN | - MXC_AUDMUX_V2_PTCR_TFSDIR | - MXC_AUDMUX_V2_PTCR_TFSEL(MX31_AUDMUX_PORT5_SSI_PINS_5) | - MXC_AUDMUX_V2_PTCR_TCLKDIR | - MXC_AUDMUX_V2_PTCR_TCSEL(MX31_AUDMUX_PORT5_SSI_PINS_5); - pdcr = MXC_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT5_SSI_PINS_5); - mxc_audmux_v2_configure_port(MX31_AUDMUX_PORT1_SSI0, ptcr, pdcr); - - ptcr = MXC_AUDMUX_V2_PTCR_SYN; - pdcr = MXC_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT1_SSI0); - mxc_audmux_v2_configure_port(MX31_AUDMUX_PORT5_SSI_PINS_5, ptcr, pdcr); + ptcr = IMX_AUDMUX_V2_PTCR_SYN | + IMX_AUDMUX_V2_PTCR_TFSDIR | + IMX_AUDMUX_V2_PTCR_TFSEL(MX31_AUDMUX_PORT5_SSI_PINS_5) | + IMX_AUDMUX_V2_PTCR_TCLKDIR | + IMX_AUDMUX_V2_PTCR_TCSEL(MX31_AUDMUX_PORT5_SSI_PINS_5); + pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT5_SSI_PINS_5); + imx_audmux_v2_configure_port(MX31_AUDMUX_PORT1_SSI0, ptcr, pdcr); + + ptcr = IMX_AUDMUX_V2_PTCR_SYN; + pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT1_SSI0); + imx_audmux_v2_configure_port(MX31_AUDMUX_PORT5_SSI_PINS_5, ptcr, pdcr);
wm1133_ev1_snd_device = platform_device_alloc("soc-audio", -1); if (!wm1133_ev1_snd_device)
Currently the imx-ssi.c[h] accommodates the imx-pcm common bits which are shared between imx-pcm-dma-mx2 and imx-pcm-fiq drivers. It assumes that imx-pcm-dma-mx2 and imx-pcm-fiq will always be used together with imx-ssi driver. However this becomes untrue when we see that driver sound/soc/fsl/fsl_ssi could possibly work with imx-pcm-dma-mx2 too.
The patch moves the imx-pcm common bits from imx-ssi.c[h] into new files imx-pcm.c[h], and let imx-pcm-dma-mx2 and imx-pcm-fiq drivers build it in, so that imx-pcm-dma-mx2 can work with no dependency on imx-ssi driver.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/imx/Kconfig | 7 ++- sound/soc/imx/Makefile | 9 ++-- sound/soc/imx/imx-pcm-dma-mx2.c | 2 +- sound/soc/imx/imx-pcm.c | 105 +++++++++++++++++++++++++++++++++++++++ sound/soc/imx/imx-pcm.h | 32 ++++++++++++ sound/soc/imx/imx-ssi.c | 88 -------------------------------- sound/soc/imx/imx-ssi.h | 16 +------ 7 files changed, 150 insertions(+), 109 deletions(-) create mode 100644 sound/soc/imx/imx-pcm.c create mode 100644 sound/soc/imx/imx-pcm.h
diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig index d3b7166..2566032 100644 --- a/sound/soc/imx/Kconfig +++ b/sound/soc/imx/Kconfig @@ -8,13 +8,18 @@ menuconfig SND_IMX_SOC
if SND_IMX_SOC
+config SND_SOC_IMX_PCM + tristate + config SND_MXC_SOC_FIQ - select FIQ tristate + select FIQ + select SND_SOC_IMX_PCM
config SND_MXC_SOC_MX2 select SND_SOC_DMAENGINE_PCM tristate + select SND_SOC_IMX_PCM
config SND_SOC_IMX_AUDMUX tristate diff --git a/sound/soc/imx/Makefile b/sound/soc/imx/Makefile index 5c40541..e9ed362 100644 --- a/sound/soc/imx/Makefile +++ b/sound/soc/imx/Makefile @@ -1,14 +1,15 @@ # i.MX Platform Support snd-soc-imx-objs := imx-ssi.o -snd-soc-imx-fiq-objs := imx-pcm-fiq.o -snd-soc-imx-mx2-objs := imx-pcm-dma-mx2.o snd-soc-imx-audmux-objs := imx-audmux.o
obj-$(CONFIG_SND_IMX_SOC) += snd-soc-imx.o -obj-$(CONFIG_SND_MXC_SOC_FIQ) += snd-soc-imx-fiq.o -obj-$(CONFIG_SND_MXC_SOC_MX2) += snd-soc-imx-mx2.o obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o
+obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o +snd-soc-imx-pcm-y := imx-pcm.o +snd-soc-imx-pcm-$(CONFIG_SND_MXC_SOC_FIQ) += imx-pcm-fiq.o +snd-soc-imx-pcm-$(CONFIG_SND_MXC_SOC_MX2) += imx-pcm-dma-mx2.o + # i.MX Machine Support snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o snd-soc-phycore-ac97-objs := phycore-ac97.o diff --git a/sound/soc/imx/imx-pcm-dma-mx2.c b/sound/soc/imx/imx-pcm-dma-mx2.c index 471e221..e43c8fa 100644 --- a/sound/soc/imx/imx-pcm-dma-mx2.c +++ b/sound/soc/imx/imx-pcm-dma-mx2.c @@ -31,7 +31,7 @@
#include <mach/dma.h>
-#include "imx-ssi.h" +#include "imx-pcm.h"
static bool filter(struct dma_chan *chan, void *param) { diff --git a/sound/soc/imx/imx-pcm.c b/sound/soc/imx/imx-pcm.c new file mode 100644 index 0000000..93dc360 --- /dev/null +++ b/sound/soc/imx/imx-pcm.c @@ -0,0 +1,105 @@ +/* + * Copyright 2009 Sascha Hauer s.hauer@pengutronix.de + * + * This code is based on code copyrighted by Freescale, + * Liam Girdwood, Javier Martin and probably others. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include <linux/dma-mapping.h> +#include <linux/module.h> +#include <sound/pcm.h> +#include <sound/soc.h> +#include "imx-pcm.h" + +int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + int ret; + + ret = dma_mmap_writecombine(substream->pcm->card->dev, vma, + runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); + + pr_debug("%s: ret: %d %p 0x%08x 0x%08x\n", __func__, ret, + runtime->dma_area, + runtime->dma_addr, + runtime->dma_bytes); + return ret; +} +EXPORT_SYMBOL_GPL(snd_imx_pcm_mmap); + +static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) +{ + struct snd_pcm_substream *substream = pcm->streams[stream].substream; + struct snd_dma_buffer *buf = &substream->dma_buffer; + size_t size = IMX_SSI_DMABUF_SIZE; + + buf->dev.type = SNDRV_DMA_TYPE_DEV; + buf->dev.dev = pcm->card->dev; + buf->private_data = NULL; + buf->area = dma_alloc_writecombine(pcm->card->dev, size, + &buf->addr, GFP_KERNEL); + if (!buf->area) + return -ENOMEM; + buf->bytes = size; + + return 0; +} + +static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); + +int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_card *card = rtd->card->snd_card; + struct snd_pcm *pcm = rtd->pcm; + int ret = 0; + + if (!card->dev->dma_mask) + card->dev->dma_mask = &imx_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); + if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { + ret = imx_pcm_preallocate_dma_buffer(pcm, + SNDRV_PCM_STREAM_PLAYBACK); + if (ret) + goto out; + } + + if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { + ret = imx_pcm_preallocate_dma_buffer(pcm, + SNDRV_PCM_STREAM_CAPTURE); + if (ret) + goto out; + } + +out: + return ret; +} +EXPORT_SYMBOL_GPL(imx_pcm_new); + +void imx_pcm_free(struct snd_pcm *pcm) +{ + struct snd_pcm_substream *substream; + struct snd_dma_buffer *buf; + int stream; + + for (stream = 0; stream < 2; stream++) { + substream = pcm->streams[stream].substream; + if (!substream) + continue; + + buf = &substream->dma_buffer; + if (!buf->area) + continue; + + dma_free_writecombine(pcm->card->dev, buf->bytes, + buf->area, buf->addr); + buf->area = NULL; + } +} +EXPORT_SYMBOL_GPL(imx_pcm_free); diff --git a/sound/soc/imx/imx-pcm.h b/sound/soc/imx/imx-pcm.h new file mode 100644 index 0000000..b5f5c3a --- /dev/null +++ b/sound/soc/imx/imx-pcm.h @@ -0,0 +1,32 @@ +/* + * Copyright 2009 Sascha Hauer s.hauer@pengutronix.de + * + * This code is based on code copyrighted by Freescale, + * Liam Girdwood, Javier Martin and probably others. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef _IMX_PCM_H +#define _IMX_PCM_H + +/* + * Do not change this as the FIQ handler depends on this size + */ +#define IMX_SSI_DMABUF_SIZE (64 * 1024) + +struct imx_pcm_dma_params { + int dma; + unsigned long dma_addr; + int burstsize; +}; + +int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma); +int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); +void imx_pcm_free(struct snd_pcm *pcm); + +#endif /* _IMX_PCM_H */ diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c index 9af3a5b..4f81ed4 100644 --- a/sound/soc/imx/imx-ssi.c +++ b/sound/soc/imx/imx-ssi.c @@ -363,94 +363,6 @@ static const struct snd_soc_dai_ops imx_ssi_pcm_dai_ops = { .trigger = imx_ssi_trigger, };
-int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int ret; - - ret = dma_mmap_writecombine(substream->pcm->card->dev, vma, - runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); - - pr_debug("%s: ret: %d %p 0x%08x 0x%08x\n", __func__, ret, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); - return ret; -} -EXPORT_SYMBOL_GPL(snd_imx_pcm_mmap); - -static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) -{ - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - size_t size = IMX_SSI_DMABUF_SIZE; - - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = pcm->card->dev; - buf->private_data = NULL; - buf->area = dma_alloc_writecombine(pcm->card->dev, size, - &buf->addr, GFP_KERNEL); - if (!buf->area) - return -ENOMEM; - buf->bytes = size; - - return 0; -} - -static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); - -int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - struct snd_pcm *pcm = rtd->pcm; - int ret = 0; - - if (!card->dev->dma_mask) - card->dev->dma_mask = &imx_pcm_dmamask; - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { - ret = imx_pcm_preallocate_dma_buffer(pcm, - SNDRV_PCM_STREAM_PLAYBACK); - if (ret) - goto out; - } - - if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { - ret = imx_pcm_preallocate_dma_buffer(pcm, - SNDRV_PCM_STREAM_CAPTURE); - if (ret) - goto out; - } - -out: - return ret; -} -EXPORT_SYMBOL_GPL(imx_pcm_new); - -void imx_pcm_free(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; - - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (!substream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - - dma_free_writecombine(pcm->card->dev, buf->bytes, - buf->area, buf->addr); - buf->area = NULL; - } -} -EXPORT_SYMBOL_GPL(imx_pcm_free); - static int imx_ssi_dai_probe(struct snd_soc_dai *dai) { struct imx_ssi *ssi = dev_get_drvdata(dai->dev); diff --git a/sound/soc/imx/imx-ssi.h b/sound/soc/imx/imx-ssi.h index 1072dfb..5744e86 100644 --- a/sound/soc/imx/imx-ssi.h +++ b/sound/soc/imx/imx-ssi.h @@ -187,12 +187,7 @@
#include <linux/dmaengine.h> #include <mach/dma.h> - -struct imx_pcm_dma_params { - int dma; - unsigned long dma_addr; - int burstsize; -}; +#include "imx-pcm.h"
struct imx_ssi { struct platform_device *ac97_dev; @@ -218,13 +213,4 @@ struct imx_ssi { struct platform_device *soc_platform_pdev_fiq; };
-int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma); -int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); -void imx_pcm_free(struct snd_pcm *pcm); - -/* - * Do not change this as the FIQ handler depends on this size - */ -#define IMX_SSI_DMABUF_SIZE (64 * 1024) - #endif /* _IMX_SSI_H */
Currently ASoC:imx uses menuconfig option SND_IMX_SOC selects imx-ssi driver, and it works because all the machine driver covered by the menuconfig need to build imx-ssi driver in. However, it will not work any more if we have a imx based machine driver going into the menuconfig while working with fsl_ssi driver (sound/soc/fsl/fsl_ssi.c) rather than imx-ssi one.
The patch adds an explicit Kconfig option SND_SOC_IMX_SSI for imx-ssi driver, so that it can be selected independently from the menuconfig option SND_IMX_SOC.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/imx/Kconfig | 7 +++++++ sound/soc/imx/Makefile | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig index 2566032..810acaa 100644 --- a/sound/soc/imx/Kconfig +++ b/sound/soc/imx/Kconfig @@ -8,6 +8,9 @@ menuconfig SND_IMX_SOC
if SND_IMX_SOC
+config SND_SOC_IMX_SSI + tristate + config SND_SOC_IMX_PCM tristate
@@ -30,6 +33,7 @@ config SND_MXC_SOC_WM1133_EV1 select SND_SOC_WM8350 select SND_MXC_SOC_FIQ select SND_SOC_IMX_AUDMUX + select SND_SOC_IMX_SSI help Enable support for audio on the i.MX31ADS with the WM1133-EV1 PMIC board with WM8835x fitted. @@ -40,6 +44,7 @@ config SND_SOC_MX27VIS_AIC32X4 select SND_SOC_TLV320AIC32X4 select SND_MXC_SOC_MX2 select SND_SOC_IMX_AUDMUX + select SND_SOC_IMX_SSI help Say Y if you want to add support for SoC audio on Visstrim SM10 board with TLV320AIC32X4 codec. @@ -51,6 +56,7 @@ config SND_SOC_PHYCORE_AC97 select SND_SOC_WM9712 select SND_MXC_SOC_FIQ select SND_SOC_IMX_AUDMUX + select SND_SOC_IMX_SSI help Say Y if you want to add support for SoC audio on Phytec phyCORE and phyCARD boards in AC97 mode @@ -65,6 +71,7 @@ config SND_SOC_EUKREA_TLV320 select SND_SOC_TLV320AIC23 select SND_MXC_SOC_FIQ select SND_SOC_IMX_AUDMUX + select SND_SOC_IMX_SSI help Enable I2S based access to the TLV320AIC23B codec attached to the SSI interface diff --git a/sound/soc/imx/Makefile b/sound/soc/imx/Makefile index e9ed362..f5db3e9 100644 --- a/sound/soc/imx/Makefile +++ b/sound/soc/imx/Makefile @@ -1,8 +1,8 @@ # i.MX Platform Support -snd-soc-imx-objs := imx-ssi.o +snd-soc-imx-ssi-objs := imx-ssi.o snd-soc-imx-audmux-objs := imx-audmux.o
-obj-$(CONFIG_SND_IMX_SOC) += snd-soc-imx.o +obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o
obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o
The fsl_ssi driver will possibly be shared between Freescale PowerPC and ARM/IMX families, so give it a separate Kconfig option. Then fsl_ssi driver can possibly be selected independently from selecting PowerPC DMA based PCM driver.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/fsl/Kconfig | 15 +++++++++------ sound/soc/fsl/Makefile | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index d754d34..ca693b2 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,10 +1,11 @@ config SND_MPC52xx_DMA tristate
-# ASoC platform support for the Freescale PowerPC SOCs that have an SSI and -# an Elo DMA controller, such as the MPC8610 and P1022. You will still need to -# select a platform driver and a codec driver. -config SND_SOC_POWERPC_SSI +config SND_SOC_FSL_SSI + tristate + depends on FSL_SOC + +config SND_SOC_POWERPC_DMA tristate depends on FSL_SOC
@@ -12,7 +13,8 @@ config SND_SOC_MPC8610_HPCD tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" # I2C is necessary for the CS4270 driver depends on MPC8610_HPCD && I2C - select SND_SOC_POWERPC_SSI + select SND_SOC_FSL_SSI + select SND_SOC_POWERPC_DMA select SND_SOC_CS4270 select SND_SOC_CS4270_VD33_ERRATA default y if MPC8610_HPCD @@ -23,7 +25,8 @@ config SND_SOC_P1022_DS tristate "ALSA SoC support for the Freescale P1022 DS board" # I2C is necessary for the WM8776 driver depends on P1022_DS && I2C - select SND_SOC_POWERPC_SSI + select SND_SOC_FSL_SSI + select SND_SOC_POWERPC_DMA select SND_SOC_WM8776 default y if P1022_DS help diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index b4a38c0..95d483f 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -9,7 +9,8 @@ obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o # Freescale PowerPC SSI/DMA Platform Support snd-soc-fsl-ssi-objs := fsl_ssi.o snd-soc-fsl-dma-objs := fsl_dma.o -obj-$(CONFIG_SND_SOC_POWERPC_SSI) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o +obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o +obj-$(CONFIG_SND_SOC_POWERPC_DMA) += snd-soc-fsl-dma.o
# MPC5200 Platform Support obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o
Shawn Guo wrote:
The fsl_ssi driver will possibly be shared between Freescale PowerPC and ARM/IMX families, so give it a separate Kconfig option. Then fsl_ssi driver can possibly be selected independently from selecting PowerPC DMA based PCM driver.
This patch is going to require an update to the defconfigs, because by default, it sets audio as disabled.
menuconfig SND_POWERPC_SOC tristate "SoC Audio for Freescale PowerPC CPUs" depends on FSL_SOC help Say Y or M if you want to add support for codecs attached to the PowerPC CPUs.
The P1022DS uses mpc85xx_smp_defconfig and mpc85xx_defconfig. The MPC8610HPCD uses mpc8610_hpcd_defconfig.
On Wed, Mar 07, 2012 at 02:20:29PM -0600, Timur Tabi wrote:
Shawn Guo wrote:
The fsl_ssi driver will possibly be shared between Freescale PowerPC and ARM/IMX families, so give it a separate Kconfig option. Then fsl_ssi driver can possibly be selected independently from selecting PowerPC DMA based PCM driver.
This patch is going to require an update to the defconfigs, because by default, it sets audio as disabled.
I guess you meant the next patch (#10) require an update, since SND_POWERPC_SOC is introduced in that patch.
Regards, Shawn
menuconfig SND_POWERPC_SOC tristate "SoC Audio for Freescale PowerPC CPUs" depends on FSL_SOC help Say Y or M if you want to add support for codecs attached to the PowerPC CPUs.
The P1022DS uses mpc85xx_smp_defconfig and mpc85xx_defconfig. The MPC8610HPCD uses mpc8610_hpcd_defconfig.
Freescale PowerPC and ARM/IMX families share the same SSI IP block. The patch merges sound/soc/imx into sound/soc/fsl, so that the possible code sharing and consolidation can happen.
This is a plain merge, except that menuconfig SND_POWERPC_SOC is added in Kconfig for PowerPC platform as a correspondence to SND_IMX_SOC for IMX platform.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/Kconfig | 1 - sound/soc/Makefile | 1 - sound/soc/fsl/Kconfig | 92 ++++++++++++++++++++++++++++++ sound/soc/fsl/Makefile | 22 +++++++ sound/soc/{imx => fsl}/eukrea-tlv320.c | 2 +- sound/soc/{imx => fsl}/imx-audmux.c | 0 sound/soc/{imx => fsl}/imx-audmux.h | 0 sound/soc/{imx => fsl}/imx-pcm-dma-mx2.c | 0 sound/soc/{imx => fsl}/imx-pcm-fiq.c | 0 sound/soc/{imx => fsl}/imx-pcm.c | 0 sound/soc/{imx => fsl}/imx-pcm.h | 0 sound/soc/{imx => fsl}/imx-ssi.c | 2 +- sound/soc/{imx => fsl}/imx-ssi.h | 0 sound/soc/{imx => fsl}/mx27vis-aic32x4.c | 0 sound/soc/{imx => fsl}/phycore-ac97.c | 0 sound/soc/{imx => fsl}/wm1133-ev1.c | 0 sound/soc/imx/Kconfig | 79 ------------------------- sound/soc/imx/Makefile | 22 ------- 18 files changed, 116 insertions(+), 105 deletions(-) rename sound/soc/{imx => fsl}/eukrea-tlv320.c (99%) rename sound/soc/{imx => fsl}/imx-audmux.c (100%) rename sound/soc/{imx => fsl}/imx-audmux.h (100%) rename sound/soc/{imx => fsl}/imx-pcm-dma-mx2.c (100%) rename sound/soc/{imx => fsl}/imx-pcm-fiq.c (100%) rename sound/soc/{imx => fsl}/imx-pcm.c (100%) rename sound/soc/{imx => fsl}/imx-pcm.h (100%) rename sound/soc/{imx => fsl}/imx-ssi.c (99%) rename sound/soc/{imx => fsl}/imx-ssi.h (100%) rename sound/soc/{imx => fsl}/mx27vis-aic32x4.c (100%) rename sound/soc/{imx => fsl}/phycore-ac97.c (100%) rename sound/soc/{imx => fsl}/wm1133-ev1.c (100%) delete mode 100644 sound/soc/imx/Kconfig delete mode 100644 sound/soc/imx/Makefile
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 91c9855..0f85f6d 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig @@ -35,7 +35,6 @@ source "sound/soc/blackfin/Kconfig" source "sound/soc/davinci/Kconfig" source "sound/soc/ep93xx/Kconfig" source "sound/soc/fsl/Kconfig" -source "sound/soc/imx/Kconfig" source "sound/soc/jz4740/Kconfig" source "sound/soc/nuc900/Kconfig" source "sound/soc/omap/Kconfig" diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 2feaf37..363dfd6 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -12,7 +12,6 @@ obj-$(CONFIG_SND_SOC) += blackfin/ obj-$(CONFIG_SND_SOC) += davinci/ obj-$(CONFIG_SND_SOC) += ep93xx/ obj-$(CONFIG_SND_SOC) += fsl/ -obj-$(CONFIG_SND_SOC) += imx/ obj-$(CONFIG_SND_SOC) += jz4740/ obj-$(CONFIG_SND_SOC) += mid-x86/ obj-$(CONFIG_SND_SOC) += mxs/ diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index ca693b2..19856a0 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,3 +1,15 @@ +config SND_SOC_FSL_SSI + tristate + +menuconfig SND_POWERPC_SOC + tristate "SoC Audio for Freescale PowerPC CPUs" + depends on FSL_SOC + help + Say Y or M if you want to add support for codecs attached to + the PowerPC CPUs. + +if SND_POWERPC_SOC + config SND_MPC52xx_DMA tristate
@@ -68,3 +80,83 @@ config SND_MPC52xx_SOC_EFIKA help Say Y if you want to add support for sound on the Efika.
+endif # SND_POWERPC_SOC + +menuconfig SND_IMX_SOC + tristate "SoC Audio for Freescale i.MX CPUs" + depends on ARCH_MXC + help + Say Y or M if you want to add support for codecs attached to + the i.MX CPUs. + +if SND_IMX_SOC + +config SND_SOC_IMX_SSI + tristate + +config SND_SOC_IMX_PCM + tristate + +config SND_MXC_SOC_FIQ + tristate + select FIQ + select SND_SOC_IMX_PCM + +config SND_MXC_SOC_MX2 + tristate + select SND_SOC_DMAENGINE_PCM + select SND_SOC_IMX_PCM + +config SND_SOC_IMX_AUDMUX + tristate + +config SND_MXC_SOC_WM1133_EV1 + tristate "Audio on the the i.MX31ADS with WM1133-EV1 fitted" + depends on MACH_MX31ADS_WM1133_EV1 && EXPERIMENTAL + select SND_SOC_WM8350 + select SND_MXC_SOC_FIQ + select SND_SOC_IMX_AUDMUX + select SND_SOC_IMX_SSI + help + Enable support for audio on the i.MX31ADS with the WM1133-EV1 + PMIC board with WM8835x fitted. + +config SND_SOC_MX27VIS_AIC32X4 + tristate "SoC audio support for Visstrim M10 boards" + depends on MACH_IMX27_VISSTRIM_M10 && I2C + select SND_SOC_TLV320AIC32X4 + select SND_MXC_SOC_MX2 + select SND_SOC_IMX_AUDMUX + select SND_SOC_IMX_SSI + help + Say Y if you want to add support for SoC audio on Visstrim SM10 + board with TLV320AIC32X4 codec. + +config SND_SOC_PHYCORE_AC97 + tristate "SoC Audio support for Phytec phyCORE (and phyCARD) boards" + depends on MACH_PCM043 || MACH_PCA100 + select SND_SOC_AC97_BUS + select SND_SOC_WM9712 + select SND_MXC_SOC_FIQ + select SND_SOC_IMX_AUDMUX + select SND_SOC_IMX_SSI + help + Say Y if you want to add support for SoC audio on Phytec phyCORE + and phyCARD boards in AC97 mode + +config SND_SOC_EUKREA_TLV320 + tristate "Eukrea TLV320" + depends on MACH_EUKREA_MBIMX27_BASEBOARD \ + || MACH_EUKREA_MBIMXSD25_BASEBOARD \ + || MACH_EUKREA_MBIMXSD35_BASEBOARD \ + || MACH_EUKREA_MBIMXSD51_BASEBOARD + depends on I2C + select SND_SOC_TLV320AIC23 + select SND_MXC_SOC_FIQ + select SND_SOC_IMX_AUDMUX + select SND_SOC_IMX_SSI + help + Enable I2S based access to the TLV320AIC23B codec attached + to the SSI interface + +endif # SND_IMX_SOC diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 95d483f..36c257f 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -21,3 +21,25 @@ obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o
+# i.MX Platform Support +snd-soc-imx-ssi-objs := imx-ssi.o +snd-soc-imx-audmux-objs := imx-audmux.o + +obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o +obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o + +obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o +snd-soc-imx-pcm-y := imx-pcm.o +snd-soc-imx-pcm-$(CONFIG_SND_MXC_SOC_FIQ) += imx-pcm-fiq.o +snd-soc-imx-pcm-$(CONFIG_SND_MXC_SOC_MX2) += imx-pcm-dma-mx2.o + +# i.MX Machine Support +snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o +snd-soc-phycore-ac97-objs := phycore-ac97.o +snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o +snd-soc-wm1133-ev1-objs := wm1133-ev1.o + +obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o +obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o +obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o +obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o diff --git a/sound/soc/imx/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c similarity index 99% rename from sound/soc/imx/eukrea-tlv320.c rename to sound/soc/fsl/eukrea-tlv320.c index 7d4475c..efb9ede 100644 --- a/sound/soc/imx/eukrea-tlv320.c +++ b/sound/soc/fsl/eukrea-tlv320.c @@ -7,7 +7,7 @@ * which is Copyright 2009 Simtec Electronics * and on sound/soc/imx/phycore-ac97.c which is * Copyright 2009 Sascha Hauer, Pengutronix s.hauer@pengutronix.de - * + * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your diff --git a/sound/soc/imx/imx-audmux.c b/sound/soc/fsl/imx-audmux.c similarity index 100% rename from sound/soc/imx/imx-audmux.c rename to sound/soc/fsl/imx-audmux.c diff --git a/sound/soc/imx/imx-audmux.h b/sound/soc/fsl/imx-audmux.h similarity index 100% rename from sound/soc/imx/imx-audmux.h rename to sound/soc/fsl/imx-audmux.h diff --git a/sound/soc/imx/imx-pcm-dma-mx2.c b/sound/soc/fsl/imx-pcm-dma-mx2.c similarity index 100% rename from sound/soc/imx/imx-pcm-dma-mx2.c rename to sound/soc/fsl/imx-pcm-dma-mx2.c diff --git a/sound/soc/imx/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c similarity index 100% rename from sound/soc/imx/imx-pcm-fiq.c rename to sound/soc/fsl/imx-pcm-fiq.c diff --git a/sound/soc/imx/imx-pcm.c b/sound/soc/fsl/imx-pcm.c similarity index 100% rename from sound/soc/imx/imx-pcm.c rename to sound/soc/fsl/imx-pcm.c diff --git a/sound/soc/imx/imx-pcm.h b/sound/soc/fsl/imx-pcm.h similarity index 100% rename from sound/soc/imx/imx-pcm.h rename to sound/soc/fsl/imx-pcm.h diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/fsl/imx-ssi.c similarity index 99% rename from sound/soc/imx/imx-ssi.c rename to sound/soc/fsl/imx-ssi.c index 4f81ed4..cf3ed03 100644 --- a/sound/soc/imx/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -28,7 +28,7 @@ * value. When we read the same register two times (and the register still * contains the same value) these status bits are not set. We work * around this by not polling these bits but only wait a fixed delay. - * + * */
#include <linux/clk.h> diff --git a/sound/soc/imx/imx-ssi.h b/sound/soc/fsl/imx-ssi.h similarity index 100% rename from sound/soc/imx/imx-ssi.h rename to sound/soc/fsl/imx-ssi.h diff --git a/sound/soc/imx/mx27vis-aic32x4.c b/sound/soc/fsl/mx27vis-aic32x4.c similarity index 100% rename from sound/soc/imx/mx27vis-aic32x4.c rename to sound/soc/fsl/mx27vis-aic32x4.c diff --git a/sound/soc/imx/phycore-ac97.c b/sound/soc/fsl/phycore-ac97.c similarity index 100% rename from sound/soc/imx/phycore-ac97.c rename to sound/soc/fsl/phycore-ac97.c diff --git a/sound/soc/imx/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c similarity index 100% rename from sound/soc/imx/wm1133-ev1.c rename to sound/soc/fsl/wm1133-ev1.c diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig deleted file mode 100644 index 810acaa..0000000 --- a/sound/soc/imx/Kconfig +++ /dev/null @@ -1,79 +0,0 @@ -menuconfig SND_IMX_SOC - tristate "SoC Audio for Freescale i.MX CPUs" - depends on ARCH_MXC - help - Say Y or M if you want to add support for codecs attached to - the i.MX SSI interface. - - -if SND_IMX_SOC - -config SND_SOC_IMX_SSI - tristate - -config SND_SOC_IMX_PCM - tristate - -config SND_MXC_SOC_FIQ - tristate - select FIQ - select SND_SOC_IMX_PCM - -config SND_MXC_SOC_MX2 - select SND_SOC_DMAENGINE_PCM - tristate - select SND_SOC_IMX_PCM - -config SND_SOC_IMX_AUDMUX - tristate - -config SND_MXC_SOC_WM1133_EV1 - tristate "Audio on the the i.MX31ADS with WM1133-EV1 fitted" - depends on MACH_MX31ADS_WM1133_EV1 && EXPERIMENTAL - select SND_SOC_WM8350 - select SND_MXC_SOC_FIQ - select SND_SOC_IMX_AUDMUX - select SND_SOC_IMX_SSI - help - Enable support for audio on the i.MX31ADS with the WM1133-EV1 - PMIC board with WM8835x fitted. - -config SND_SOC_MX27VIS_AIC32X4 - tristate "SoC audio support for Visstrim M10 boards" - depends on MACH_IMX27_VISSTRIM_M10 && I2C - select SND_SOC_TLV320AIC32X4 - select SND_MXC_SOC_MX2 - select SND_SOC_IMX_AUDMUX - select SND_SOC_IMX_SSI - help - Say Y if you want to add support for SoC audio on Visstrim SM10 - board with TLV320AIC32X4 codec. - -config SND_SOC_PHYCORE_AC97 - tristate "SoC Audio support for Phytec phyCORE (and phyCARD) boards" - depends on MACH_PCM043 || MACH_PCA100 - select SND_SOC_AC97_BUS - select SND_SOC_WM9712 - select SND_MXC_SOC_FIQ - select SND_SOC_IMX_AUDMUX - select SND_SOC_IMX_SSI - help - Say Y if you want to add support for SoC audio on Phytec phyCORE - and phyCARD boards in AC97 mode - -config SND_SOC_EUKREA_TLV320 - tristate "Eukrea TLV320" - depends on MACH_EUKREA_MBIMX27_BASEBOARD \ - || MACH_EUKREA_MBIMXSD25_BASEBOARD \ - || MACH_EUKREA_MBIMXSD35_BASEBOARD \ - || MACH_EUKREA_MBIMXSD51_BASEBOARD - depends on I2C - select SND_SOC_TLV320AIC23 - select SND_MXC_SOC_FIQ - select SND_SOC_IMX_AUDMUX - select SND_SOC_IMX_SSI - help - Enable I2S based access to the TLV320AIC23B codec attached - to the SSI interface - -endif # SND_IMX_SOC diff --git a/sound/soc/imx/Makefile b/sound/soc/imx/Makefile deleted file mode 100644 index f5db3e9..0000000 --- a/sound/soc/imx/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# i.MX Platform Support -snd-soc-imx-ssi-objs := imx-ssi.o -snd-soc-imx-audmux-objs := imx-audmux.o - -obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o -obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o - -obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o -snd-soc-imx-pcm-y := imx-pcm.o -snd-soc-imx-pcm-$(CONFIG_SND_MXC_SOC_FIQ) += imx-pcm-fiq.o -snd-soc-imx-pcm-$(CONFIG_SND_MXC_SOC_MX2) += imx-pcm-dma-mx2.o - -# i.MX Machine Support -snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o -snd-soc-phycore-ac97-objs := phycore-ac97.o -snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o -snd-soc-wm1133-ev1-objs := wm1133-ev1.o - -obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o -obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o -obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o -obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o
On Mon, Mar 05, 2012 at 10:30:58PM +0800, Shawn Guo wrote:
Freescale PowerPC and ARM/IMX families share the same SSI IP block. The patch merges sound/soc/imx into sound/soc/fsl, so that the possible code sharing and consolidation can happen.
This is a plain merge, except that menuconfig SND_POWERPC_SOC is added in Kconfig for PowerPC platform as a correspondence to SND_IMX_SOC for IMX platform.
Signed-off-by: Shawn Guo shawn.guo@linaro.org
sound/soc/Kconfig | 1 - sound/soc/Makefile | 1 - sound/soc/fsl/Kconfig | 92 ++++++++++++++++++++++++++++++ sound/soc/fsl/Makefile | 22 +++++++ sound/soc/{imx => fsl}/eukrea-tlv320.c | 2 +- sound/soc/{imx => fsl}/imx-audmux.c | 0 sound/soc/{imx => fsl}/imx-audmux.h | 0 sound/soc/{imx => fsl}/imx-pcm-dma-mx2.c | 0
Maybe this is the right time to rename this file to something like imx-pcm-dma.c since it has nothing to do with mx2 anymore.
Sascha
On Mon, Mar 05, 2012 at 06:39:10PM +0100, Sascha Hauer wrote:
On Mon, Mar 05, 2012 at 10:30:58PM +0800, Shawn Guo wrote:
Freescale PowerPC and ARM/IMX families share the same SSI IP block. The patch merges sound/soc/imx into sound/soc/fsl, so that the possible code sharing and consolidation can happen.
This is a plain merge, except that menuconfig SND_POWERPC_SOC is added in Kconfig for PowerPC platform as a correspondence to SND_IMX_SOC for IMX platform.
Signed-off-by: Shawn Guo shawn.guo@linaro.org
sound/soc/Kconfig | 1 - sound/soc/Makefile | 1 - sound/soc/fsl/Kconfig | 92 ++++++++++++++++++++++++++++++ sound/soc/fsl/Makefile | 22 +++++++ sound/soc/{imx => fsl}/eukrea-tlv320.c | 2 +- sound/soc/{imx => fsl}/imx-audmux.c | 0 sound/soc/{imx => fsl}/imx-audmux.h | 0 sound/soc/{imx => fsl}/imx-pcm-dma-mx2.c | 0
Maybe this is the right time to rename this file to something like imx-pcm-dma.c since it has nothing to do with mx2 anymore.
Ok, will do.
On Mon, Mar 05, 2012 at 06:39:10PM +0100, Sascha Hauer wrote:
On Mon, Mar 05, 2012 at 10:30:58PM +0800, Shawn Guo wrote:
Freescale PowerPC and ARM/IMX families share the same SSI IP block. The patch merges sound/soc/imx into sound/soc/fsl, so that the possible code sharing and consolidation can happen.
This is a plain merge, except that menuconfig SND_POWERPC_SOC is added in Kconfig for PowerPC platform as a correspondence to SND_IMX_SOC for IMX platform.
Signed-off-by: Shawn Guo shawn.guo@linaro.org
sound/soc/Kconfig | 1 - sound/soc/Makefile | 1 - sound/soc/fsl/Kconfig | 92 ++++++++++++++++++++++++++++++ sound/soc/fsl/Makefile | 22 +++++++ sound/soc/{imx => fsl}/eukrea-tlv320.c | 2 +- sound/soc/{imx => fsl}/imx-audmux.c | 0 sound/soc/{imx => fsl}/imx-audmux.h | 0 sound/soc/{imx => fsl}/imx-pcm-dma-mx2.c | 0
Maybe this is the right time to rename this file to something like imx-pcm-dma.c since it has nothing to do with mx2 anymore.
Ok, will change it in the next post.
There is some amount of code duplication between mpc8610_hpcd and p1022_ds machine drivers, and the same code will be duplicated again when another new machine driver is added. The patch creates fsl_utils to accommodate the common functions to stop the code duplication.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/fsl/Kconfig | 5 ++ sound/soc/fsl/Makefile | 2 + sound/soc/fsl/fsl_utils.c | 135 ++++++++++++++++++++++++++++++++++++ sound/soc/fsl/fsl_utils.h | 27 +++++++ sound/soc/fsl/mpc8610_hpcd.c | 157 +++--------------------------------------- sound/soc/fsl/p1022_ds.c | 149 +++------------------------------------- 6 files changed, 189 insertions(+), 286 deletions(-) create mode 100644 sound/soc/fsl/fsl_utils.c create mode 100644 sound/soc/fsl/fsl_utils.h
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 19856a0..e579671 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,6 +1,9 @@ config SND_SOC_FSL_SSI tristate
+config SND_SOC_FSL_UTILS + tristate + menuconfig SND_POWERPC_SOC tristate "SoC Audio for Freescale PowerPC CPUs" depends on FSL_SOC @@ -26,6 +29,7 @@ config SND_SOC_MPC8610_HPCD # I2C is necessary for the CS4270 driver depends on MPC8610_HPCD && I2C select SND_SOC_FSL_SSI + select SND_SOC_FSL_UTILS select SND_SOC_POWERPC_DMA select SND_SOC_CS4270 select SND_SOC_CS4270_VD33_ERRATA @@ -38,6 +42,7 @@ config SND_SOC_P1022_DS # I2C is necessary for the WM8776 driver depends on P1022_DS && I2C select SND_SOC_FSL_SSI + select SND_SOC_FSL_UTILS select SND_SOC_POWERPC_DMA select SND_SOC_WM8776 default y if P1022_DS diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 36c257f..02b3e53 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -8,8 +8,10 @@ obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o
# Freescale PowerPC SSI/DMA Platform Support snd-soc-fsl-ssi-objs := fsl_ssi.o +snd-soc-fsl-utils-objs := fsl_utils.o snd-soc-fsl-dma-objs := fsl_dma.o obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o +obj-$(CONFIG_SND_SOC_FSL_UTILS) += snd-soc-fsl-utils.o obj-$(CONFIG_SND_SOC_POWERPC_DMA) += snd-soc-fsl-dma.o
# MPC5200 Platform Support diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c new file mode 100644 index 0000000..4370c28 --- /dev/null +++ b/sound/soc/fsl/fsl_utils.c @@ -0,0 +1,135 @@ +/** + * Freescale ALSA SoC Machine driver utility + * + * Author: Timur Tabi timur@freescale.com + * + * Copyright 2010 Freescale Semiconductor, Inc. + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed "as is" without any warranty of any + * kind, whether express or implied. + */ + +#include <linux/module.h> +#include <linux/of_address.h> +#include <linux/of_i2c.h> +#include <sound/soc.h> + +#include "fsl_utils.h" + +/** + * fsl_asoc_get_codec_dev_name - determine the dev_name for a codec node + * + * @np: pointer to the I2C device tree node + * @buf: buffer to be filled with the dev_name of the I2C device + * @len: the length of the buffer + * + * This function determines the dev_name for an I2C node. This is the name + * that would be returned by dev_name() if this device_node were part of a + * 'struct device' It's ugly and hackish, but it works. + * + * The dev_name for such devices include the bus number and I2C address. For + * example, "cs4270.0-004f". + */ +int fsl_asoc_get_codec_dev_name(struct device_node *np, char *buf, size_t len) +{ + const u32 *iprop; + u32 addr; + char temp[DAI_NAME_SIZE]; + struct i2c_client *i2c; + + of_modalias_node(np, temp, DAI_NAME_SIZE); + + iprop = of_get_property(np, "reg", NULL); + if (!iprop) + return -EINVAL; + + addr = be32_to_cpup(iprop); + + /* We need the adapter number */ + i2c = of_find_i2c_device_by_node(np); + if (!i2c) { + put_device(&i2c->dev); + return -ENODEV; + } + + snprintf(buf, len, "%s.%u-%04x", temp, i2c->adapter->nr, addr); + put_device(&i2c->dev); + + return 0; +} +EXPORT_SYMBOL(fsl_asoc_get_codec_dev_name); + +/** + * fsl_asoc_get_dma_channel - determine the dma channel for a SSI node + * + * @ssi_np: pointer to the SSI device tree node + * @name: name of the phandle pointing to the dma channel + * @dai: ASoC DAI link pointer to be filled with platform_name + * @dma_channel_id: dma channel id to be returned + * @dma_id: dma id to be returned + * + * This function determines the dma and channel id for given SSI node. It + * also discovers the platform_name for the ASoC DAI link. + */ +int fsl_asoc_get_dma_channel(struct device_node *ssi_np, + const char *name, + struct snd_soc_dai_link *dai, + unsigned int *dma_channel_id, + unsigned int *dma_id) +{ + struct resource res; + struct device_node *dma_channel_np, *dma_np; + const u32 *iprop; + int ret; + + dma_channel_np = of_parse_phandle(ssi_np, name, 0); + if (!dma_channel_np) + return -EINVAL; + + if (!of_device_is_compatible(dma_channel_np, "fsl,ssi-dma-channel")) { + of_node_put(dma_channel_np); + return -EINVAL; + } + + /* Determine the dev_name for the device_node. This code mimics the + * behavior of of_device_make_bus_id(). We need this because ASoC uses + * the dev_name() of the device to match the platform (DMA) device with + * the CPU (SSI) device. It's all ugly and hackish, but it works (for + * now). + * + * dai->platform name should already point to an allocated buffer. + */ + ret = of_address_to_resource(dma_channel_np, 0, &res); + if (ret) { + of_node_put(dma_channel_np); + return ret; + } + snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s", + (unsigned long long) res.start, dma_channel_np->name); + + iprop = of_get_property(dma_channel_np, "cell-index", NULL); + if (!iprop) { + of_node_put(dma_channel_np); + return -EINVAL; + } + *dma_channel_id = be32_to_cpup(iprop); + + dma_np = of_get_parent(dma_channel_np); + iprop = of_get_property(dma_np, "cell-index", NULL); + if (!iprop) { + of_node_put(dma_np); + return -EINVAL; + } + *dma_id = be32_to_cpup(iprop); + + of_node_put(dma_np); + of_node_put(dma_channel_np); + + return 0; +} +EXPORT_SYMBOL(fsl_asoc_get_dma_channel); + +MODULE_AUTHOR("Timur Tabi timur@freescale.com"); +MODULE_DESCRIPTION("Freescale ASoC utility code"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/fsl/fsl_utils.h b/sound/soc/fsl/fsl_utils.h new file mode 100644 index 0000000..44d1436 --- /dev/null +++ b/sound/soc/fsl/fsl_utils.h @@ -0,0 +1,27 @@ +/** + * Freescale ALSA SoC Machine driver utility + * + * Author: Timur Tabi timur@freescale.com + * + * Copyright 2010 Freescale Semiconductor, Inc. + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed "as is" without any warranty of any + * kind, whether express or implied. + */ + +#ifndef _FSL_UTILS_H +#define _FSL_UTILS_H + +#define DAI_NAME_SIZE 32 + +struct snd_soc_dai_link; +struct device_node; + +int fsl_asoc_get_codec_dev_name(struct device_node *np, char *buf, size_t len); +int fsl_asoc_get_dma_channel(struct device_node *ssi_np, const char *name, + struct snd_soc_dai_link *dai, + unsigned int *dma_channel_id, + unsigned int *dma_id); + +#endif /* _FSL_UTILS_H */ diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c index fcf9302..7ead1e5 100644 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ b/sound/soc/fsl/mpc8610_hpcd.c @@ -14,18 +14,16 @@ #include <linux/interrupt.h> #include <linux/of_device.h> #include <linux/slab.h> -#include <linux/of_i2c.h> #include <sound/soc.h> #include <asm/fsl_guts.h>
#include "fsl_dma.h" #include "fsl_ssi.h" +#include "fsl_utils.h"
/* There's only one global utilities register */ static phys_addr_t guts_phys;
-#define DAI_NAME_SIZE 32 - /** * mpc8610_hpcd_data: machine-specific ASoC device data * @@ -181,141 +179,6 @@ static struct snd_soc_ops mpc8610_hpcd_ops = { };
/** - * get_node_by_phandle_name - get a node by its phandle name - * - * This function takes a node, the name of a property in that node, and a - * compatible string. Assuming the property is a phandle to another node, - * it returns that node, (optionally) if that node is compatible. - * - * If the property is not a phandle, or the node it points to is not compatible - * with the specific string, then NULL is returned. - */ -static struct device_node *get_node_by_phandle_name(struct device_node *np, - const char *name, - const char *compatible) -{ - const phandle *ph; - int len; - - ph = of_get_property(np, name, &len); - if (!ph || (len != sizeof(phandle))) - return NULL; - - np = of_find_node_by_phandle(*ph); - if (!np) - return NULL; - - if (compatible && !of_device_is_compatible(np, compatible)) { - of_node_put(np); - return NULL; - } - - return np; -} - -/** - * get_parent_cell_index -- return the cell-index of the parent of a node - * - * Return the value of the cell-index property of the parent of the given - * node. This is used for DMA channel nodes that need to know the DMA ID - * of the controller they are on. - */ -static int get_parent_cell_index(struct device_node *np) -{ - struct device_node *parent = of_get_parent(np); - const u32 *iprop; - - if (!parent) - return -1; - - iprop = of_get_property(parent, "cell-index", NULL); - of_node_put(parent); - - if (!iprop) - return -1; - - return be32_to_cpup(iprop); -} - -/** - * codec_node_dev_name - determine the dev_name for a codec node - * - * This function determines the dev_name for an I2C node. This is the name - * that would be returned by dev_name() if this device_node were part of a - * 'struct device' It's ugly and hackish, but it works. - * - * The dev_name for such devices include the bus number and I2C address. For - * example, "cs4270.0-004f". - */ -static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) -{ - const u32 *iprop; - int addr; - char temp[DAI_NAME_SIZE]; - struct i2c_client *i2c; - - of_modalias_node(np, temp, DAI_NAME_SIZE); - - iprop = of_get_property(np, "reg", NULL); - if (!iprop) - return -EINVAL; - - addr = be32_to_cpup(iprop); - - /* We need the adapter number */ - i2c = of_find_i2c_device_by_node(np); - if (!i2c) - return -ENODEV; - - snprintf(buf, len, "%s.%u-%04x", temp, i2c->adapter->nr, addr); - - return 0; -} - -static int get_dma_channel(struct device_node *ssi_np, - const char *name, - struct snd_soc_dai_link *dai, - unsigned int *dma_channel_id, - unsigned int *dma_id) -{ - struct resource res; - struct device_node *dma_channel_np; - const u32 *iprop; - int ret; - - dma_channel_np = get_node_by_phandle_name(ssi_np, name, - "fsl,ssi-dma-channel"); - if (!dma_channel_np) - return -EINVAL; - - /* Determine the dev_name for the device_node. This code mimics the - * behavior of of_device_make_bus_id(). We need this because ASoC uses - * the dev_name() of the device to match the platform (DMA) device with - * the CPU (SSI) device. It's all ugly and hackish, but it works (for - * now). - * - * dai->platform name should already point to an allocated buffer. - */ - ret = of_address_to_resource(dma_channel_np, 0, &res); - if (ret) - return ret; - snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s", - (unsigned long long) res.start, dma_channel_np->name); - - iprop = of_get_property(dma_channel_np, "cell-index", NULL); - if (!iprop) { - of_node_put(dma_channel_np); - return -EINVAL; - } - - *dma_channel_id = be32_to_cpup(iprop); - *dma_id = get_parent_cell_index(dma_channel_np); - of_node_put(dma_channel_np); - - return 0; -} - -/** * mpc8610_hpcd_probe: platform probe function for the machine driver * * Although this is a machine driver, the SSI node is the "master" node with @@ -353,8 +216,8 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) machine_data->dai[0].ops = &mpc8610_hpcd_ops;
/* Determine the codec name, it will be used as the codec DAI name */ - ret = codec_node_dev_name(codec_np, machine_data->codec_name, - DAI_NAME_SIZE); + ret = fsl_asoc_get_codec_dev_name(codec_np, machine_data->codec_name, + DAI_NAME_SIZE); if (ret) { dev_err(&pdev->dev, "invalid codec node %s\n", codec_np->full_name); @@ -458,9 +321,10 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
/* Find the playback DMA channel to use. */ machine_data->dai[0].platform_name = machine_data->platform_name[0]; - ret = get_dma_channel(np, "fsl,playback-dma", &machine_data->dai[0], - &machine_data->dma_channel_id[0], - &machine_data->dma_id[0]); + ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", + &machine_data->dai[0], + &machine_data->dma_channel_id[0], + &machine_data->dma_id[0]); if (ret) { dev_err(&pdev->dev, "missing/invalid playback DMA phandle\n"); goto error; @@ -468,9 +332,10 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
/* Find the capture DMA channel to use. */ machine_data->dai[1].platform_name = machine_data->platform_name[1]; - ret = get_dma_channel(np, "fsl,capture-dma", &machine_data->dai[1], - &machine_data->dma_channel_id[1], - &machine_data->dma_id[1]); + ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", + &machine_data->dai[1], + &machine_data->dma_channel_id[1], + &machine_data->dma_id[1]); if (ret) { dev_err(&pdev->dev, "missing/invalid capture DMA phandle\n"); goto error; diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c index d32ec46..60f7bb8 100644 --- a/sound/soc/fsl/p1022_ds.c +++ b/sound/soc/fsl/p1022_ds.c @@ -14,12 +14,12 @@ #include <linux/interrupt.h> #include <linux/of_device.h> #include <linux/slab.h> -#include <linux/of_i2c.h> #include <sound/soc.h> #include <asm/fsl_guts.h>
#include "fsl_dma.h" #include "fsl_ssi.h" +#include "fsl_utils.h"
/* P1022-specific PMUXCR and DMUXCR bit definitions */
@@ -57,8 +57,6 @@ static inline void guts_set_dmuxcr(struct ccsr_guts_85xx __iomem *guts, /* There's only one global utilities register */ static phys_addr_t guts_phys;
-#define DAI_NAME_SIZE 32 - /** * machine_data: machine-specific ASoC device data * @@ -191,136 +189,6 @@ static struct snd_soc_ops p1022_ds_ops = { };
/** - * get_node_by_phandle_name - get a node by its phandle name - * - * This function takes a node, the name of a property in that node, and a - * compatible string. Assuming the property is a phandle to another node, - * it returns that node, (optionally) if that node is compatible. - * - * If the property is not a phandle, or the node it points to is not compatible - * with the specific string, then NULL is returned. - */ -static struct device_node *get_node_by_phandle_name(struct device_node *np, - const char *name, const char *compatible) -{ - np = of_parse_phandle(np, name, 0); - if (!np) - return NULL; - - if (!of_device_is_compatible(np, compatible)) { - of_node_put(np); - return NULL; - } - - return np; -} - -/** - * get_parent_cell_index -- return the cell-index of the parent of a node - * - * Return the value of the cell-index property of the parent of the given - * node. This is used for DMA channel nodes that need to know the DMA ID - * of the controller they are on. - */ -static int get_parent_cell_index(struct device_node *np) -{ - struct device_node *parent = of_get_parent(np); - const u32 *iprop; - int ret = -1; - - if (!parent) - return -1; - - iprop = of_get_property(parent, "cell-index", NULL); - if (iprop) - ret = be32_to_cpup(iprop); - - of_node_put(parent); - - return ret; -} - -/** - * codec_node_dev_name - determine the dev_name for a codec node - * - * This function determines the dev_name for an I2C node. This is the name - * that would be returned by dev_name() if this device_node were part of a - * 'struct device' It's ugly and hackish, but it works. - * - * The dev_name for such devices include the bus number and I2C address. For - * example, "cs4270-codec.0-004f". - */ -static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) -{ - const u32 *iprop; - int addr; - char temp[DAI_NAME_SIZE]; - struct i2c_client *i2c; - - of_modalias_node(np, temp, DAI_NAME_SIZE); - - iprop = of_get_property(np, "reg", NULL); - if (!iprop) - return -EINVAL; - - addr = be32_to_cpup(iprop); - - /* We need the adapter number */ - i2c = of_find_i2c_device_by_node(np); - if (!i2c) - return -ENODEV; - - snprintf(buf, len, "%s.%u-%04x", temp, i2c->adapter->nr, addr); - - return 0; -} - -static int get_dma_channel(struct device_node *ssi_np, - const char *name, - struct snd_soc_dai_link *dai, - unsigned int *dma_channel_id, - unsigned int *dma_id) -{ - struct resource res; - struct device_node *dma_channel_np; - const u32 *iprop; - int ret; - - dma_channel_np = get_node_by_phandle_name(ssi_np, name, - "fsl,ssi-dma-channel"); - if (!dma_channel_np) - return -EINVAL; - - /* Determine the dev_name for the device_node. This code mimics the - * behavior of of_device_make_bus_id(). We need this because ASoC uses - * the dev_name() of the device to match the platform (DMA) device with - * the CPU (SSI) device. It's all ugly and hackish, but it works (for - * now). - * - * dai->platform name should already point to an allocated buffer. - */ - ret = of_address_to_resource(dma_channel_np, 0, &res); - if (ret) { - of_node_put(dma_channel_np); - return ret; - } - snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s", - (unsigned long long) res.start, dma_channel_np->name); - - iprop = of_get_property(dma_channel_np, "cell-index", NULL); - if (!iprop) { - of_node_put(dma_channel_np); - return -EINVAL; - } - - *dma_channel_id = be32_to_cpup(iprop); - *dma_id = get_parent_cell_index(dma_channel_np); - of_node_put(dma_channel_np); - - return 0; -} - -/** * p1022_ds_probe: platform probe function for the machine driver * * Although this is a machine driver, the SSI node is the "master" node with @@ -358,7 +226,8 @@ static int p1022_ds_probe(struct platform_device *pdev) mdata->dai[0].ops = &p1022_ds_ops;
/* Determine the codec name, it will be used as the codec DAI name */ - ret = codec_node_dev_name(codec_np, mdata->codec_name, DAI_NAME_SIZE); + ret = fsl_asoc_get_codec_dev_name(codec_np, mdata->codec_name, + DAI_NAME_SIZE); if (ret) { dev_err(&pdev->dev, "invalid codec node %s\n", codec_np->full_name); @@ -454,9 +323,9 @@ static int p1022_ds_probe(struct platform_device *pdev)
/* Find the playback DMA channel to use. */ mdata->dai[0].platform_name = mdata->platform_name[0]; - ret = get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0], - &mdata->dma_channel_id[0], - &mdata->dma_id[0]); + ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0], + &mdata->dma_channel_id[0], + &mdata->dma_id[0]); if (ret) { dev_err(&pdev->dev, "missing/invalid playback DMA phandle\n"); goto error; @@ -464,9 +333,9 @@ static int p1022_ds_probe(struct platform_device *pdev)
/* Find the capture DMA channel to use. */ mdata->dai[1].platform_name = mdata->platform_name[1]; - ret = get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1], - &mdata->dma_channel_id[1], - &mdata->dma_id[1]); + ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1], + &mdata->dma_channel_id[1], + &mdata->dma_id[1]); if (ret) { dev_err(&pdev->dev, "missing/invalid capture DMA phandle\n"); goto error;
On Mon, Mar 05, 2012 at 10:30:59PM +0800, Shawn Guo wrote:
+/**
- fsl_asoc_get_codec_dev_name - determine the dev_name for a codec node
- @np: pointer to the I2C device tree node
- @buf: buffer to be filled with the dev_name of the I2C device
- @len: the length of the buffer
- This function determines the dev_name for an I2C node. This is the name
- that would be returned by dev_name() if this device_node were part of a
- 'struct device' It's ugly and hackish, but it works.
- The dev_name for such devices include the bus number and I2C address. For
- example, "cs4270.0-004f".
- */
+int fsl_asoc_get_codec_dev_name(struct device_node *np, char *buf, size_t len)
This doesn't seem at all Freescale specific, it should be a generic helper, and in fact there already is one - the machine driver can set codec_of_node in the card structure to point to the device node and then the core should figure out binding to the device for you. If it doesn't we should fix the core.
Mark Brown wrote:
This doesn't seem at all Freescale specific, it should be a generic helper, and in fact there already is one - the machine driver can set codec_of_node in the card structure to point to the device node and then the core should figure out binding to the device for you. If it doesn't we should fix the core.
Can we do that in another patch set, so that it doesn't hold up Shawn's work? All this patch does is move the code from one file to another, so it's not like he's adding a feature incorrectly.
On Mon, Mar 05, 2012 at 09:48:53AM -0600, Timur Tabi wrote:
Mark Brown wrote:
This doesn't seem at all Freescale specific, it should be a generic helper, and in fact there already is one - the machine driver can set codec_of_node in the card structure to point to the device node and then the core should figure out binding to the device for you. If it doesn't we should fix the core.
Can we do that in another patch set, so that it doesn't hold up Shawn's work? All this patch does is move the code from one file to another, so it's not like he's adding a feature incorrectly.
Well, it shouldn't be much effort - instead of removing the code just delete it mostly - and there's other issues that need to be looked at anyway. There's also the arch/arm stuff that needs review...
On Mon, Mar 05, 2012 at 02:49:20PM +0000, Mark Brown wrote:
On Mon, Mar 05, 2012 at 10:30:59PM +0800, Shawn Guo wrote:
+/**
- fsl_asoc_get_codec_dev_name - determine the dev_name for a codec node
- @np: pointer to the I2C device tree node
- @buf: buffer to be filled with the dev_name of the I2C device
- @len: the length of the buffer
- This function determines the dev_name for an I2C node. This is the name
- that would be returned by dev_name() if this device_node were part of a
- 'struct device' It's ugly and hackish, but it works.
- The dev_name for such devices include the bus number and I2C address. For
- example, "cs4270.0-004f".
- */
+int fsl_asoc_get_codec_dev_name(struct device_node *np, char *buf, size_t len)
This doesn't seem at all Freescale specific, it should be a generic helper, and in fact there already is one - the machine driver can set codec_of_node in the card structure to point to the device node and then the core should figure out binding to the device for you. If it doesn't we should fix the core.
Yeah, the core support works, so will remove the function here and use the core support.
Check /compatible rather than /model to determine the machine name. The p1022ds older device trees get a different /model from the new ones, while /compatible is consistent there, so checking /compatible will save the bother of detecting older p1022ds device trees.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/fsl/fsl_ssi.c | 6 +++--- sound/soc/fsl/mpc8610_hpcd.c | 2 +- sound/soc/fsl/p1022_ds.c | 32 +++++--------------------------- 3 files changed, 9 insertions(+), 31 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 3e06696..2eb407f 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -716,12 +716,12 @@ static int __devinit fsl_ssi_probe(struct platform_device *pdev) }
/* Trigger the machine driver's probe function. The platform driver - * name of the machine driver is taken from the /model property of the + * name of the machine driver is taken from /compatible property of the * device tree. We also pass the address of the CPU DAI driver * structure. */ - sprop = of_get_property(of_find_node_by_path("/"), "model", NULL); - /* Sometimes the model name has a "fsl," prefix, so we strip that. */ + sprop = of_get_property(of_find_node_by_path("/"), "compatible", NULL); + /* Sometimes the compatible name has a "fsl," prefix, so we strip it. */ p = strrchr(sprop, ','); if (p) sprop = p + 1; diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c index 7ead1e5..4195182 100644 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ b/sound/soc/fsl/mpc8610_hpcd.c @@ -411,7 +411,7 @@ static struct platform_driver mpc8610_hpcd_driver = { .probe = mpc8610_hpcd_probe, .remove = __devexit_p(mpc8610_hpcd_remove), .driver = { - /* The name must match the 'model' property in the device tree, + /* The name must match 'compatible' property in the device tree, * in lowercase letters. */ .name = "snd-soc-mpc8610hpcd", diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c index 60f7bb8..e3680ce 100644 --- a/sound/soc/fsl/p1022_ds.c +++ b/sound/soc/fsl/p1022_ds.c @@ -412,6 +412,11 @@ static struct platform_driver p1022_ds_driver = { .probe = p1022_ds_probe, .remove = __devexit_p(p1022_ds_remove), .driver = { + /* + * The name must match 'compatible' property in the device tree, + * in lowercase letters. + */ + .name = "snd-soc-p1022ds", .owner = THIS_MODULE, }, }; @@ -425,33 +430,6 @@ static int __init p1022_ds_init(void) { struct device_node *guts_np; struct resource res; - const char *sprop; - - /* - * Check if we're actually running on a P1022DS. Older device trees - * have a model of "fsl,P1022" and newer ones use "fsl,P1022DS", so we - * need to support both. The SSI driver uses that property to link to - * the machine driver, so have to match it. - */ - sprop = of_get_property(of_find_node_by_path("/"), "model", NULL); - if (!sprop) { - pr_err("snd-soc-p1022ds: missing /model node"); - return -ENODEV; - } - - pr_debug("snd-soc-p1022ds: board model name is %s\n", sprop); - - /* - * The name of this board, taken from the device tree. Normally, this is a* - * fixed string, but some P1022DS device trees have a /model property of - * "fsl,P1022", and others have "fsl,P1022DS". - */ - if (strcasecmp(sprop, "fsl,p1022ds") == 0) - p1022_ds_driver.driver.name = "snd-soc-p1022ds"; - else if (strcasecmp(sprop, "fsl,p1022") == 0) - p1022_ds_driver.driver.name = "snd-soc-p1022"; - else - return -ENODEV;
/* Get the physical address of the global utilities registers */ guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts");
Provide different pair of accessors for accessing SSI registers on PowerPC and ARM/IMX, so that fsl_ssi driver can be built on both architectures.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/fsl/fsl_ssi.c | 60 +++++++++++++++++++++++++++++----------------- 1 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 2eb407f..d31d1ba 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -11,11 +11,14 @@ */
#include <linux/init.h> +#include <linux/io.h> #include <linux/module.h> #include <linux/interrupt.h> #include <linux/device.h> #include <linux/delay.h> #include <linux/slab.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> #include <linux/of_platform.h>
#include <sound/core.h> @@ -26,6 +29,21 @@
#include "fsl_ssi.h"
+#ifdef PPC +#define read_ssi(addr) in_be32(addr) +#define write_ssi(val, addr) out_be32(addr, val) +#define write_ssi_mask(addr, clear, set) clrsetbits_be32(addr, clear, set) +#elif defined ARM +#define read_ssi(addr) readl(addr) +#define write_ssi(val, addr) writel(val, addr) +static inline void write_ssi_mask(void __iomem *addr, u32 clear, u32 set) +{ + u32 val = readl(addr); + val = (val & ~clear) | set; + writel(val, addr); +} +#endif + /** * FSLSSI_I2S_RATES: sample rates supported by the I2S * @@ -145,7 +163,7 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) were interrupted for. We mask it with the Interrupt Enable register so that we only check for events that we're interested in. */ - sisr = in_be32(&ssi->sisr) & SIER_FLAGS; + sisr = read_ssi(&ssi->sisr) & SIER_FLAGS;
if (sisr & CCSR_SSI_SISR_RFRC) { ssi_private->stats.rfrc++; @@ -260,7 +278,7 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
/* Clear the bits that we set */ if (sisr2) - out_be32(&ssi->sisr, sisr2); + write_ssi(sisr2, &ssi->sisr);
return ret; } @@ -295,7 +313,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, * SSI needs to be disabled before updating the registers we set * here. */ - clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN); + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0);
/* * Program the SSI into I2S Slave Non-Network Synchronous mode. @@ -303,20 +321,18 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, * * FIXME: Little-endian samples require a different shift dir */ - clrsetbits_be32(&ssi->scr, + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, CCSR_SSI_SCR_TFR_CLK_DIS | CCSR_SSI_SCR_I2S_MODE_SLAVE | (synchronous ? CCSR_SSI_SCR_SYN : 0));
- out_be32(&ssi->stcr, - CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | + write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TEFS | - CCSR_SSI_STCR_TSCKP); + CCSR_SSI_STCR_TSCKP, &ssi->stcr);
- out_be32(&ssi->srcr, - CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFEN0 | + write_ssi(CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFEN0 | CCSR_SSI_SRCR_RFSI | CCSR_SSI_SRCR_REFS | - CCSR_SSI_SRCR_RSCKP); + CCSR_SSI_SRCR_RSCKP, &ssi->srcr);
/* * The DC and PM bits are only used if the SSI is the clock @@ -324,7 +340,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, */
/* Enable the interrupts and DMA requests */ - out_be32(&ssi->sier, SIER_FLAGS); + write_ssi(SIER_FLAGS, &ssi->sier);
/* * Set the watermark for transmit FIFI 0 and receive FIFO 0. We @@ -339,9 +355,9 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, * make this value larger (and maybe we should), but this way * data will be written to memory as soon as it's available. */ - out_be32(&ssi->sfcsr, - CCSR_SSI_SFCSR_TFWM0(ssi_private->fifo_depth - 2) | - CCSR_SSI_SFCSR_RFWM0(ssi_private->fifo_depth - 2)); + write_ssi(CCSR_SSI_SFCSR_TFWM0(ssi_private->fifo_depth - 2) | + CCSR_SSI_SFCSR_RFWM0(ssi_private->fifo_depth - 2), + &ssi->sfcsr);
/* * We keep the SSI disabled because if we enable it, then the @@ -417,7 +433,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, unsigned int sample_size = snd_pcm_format_width(params_format(hw_params)); u32 wl = CCSR_SSI_SxCCR_WL(sample_size); - int enabled = in_be32(&ssi->scr) & CCSR_SSI_SCR_SSIEN; + int enabled = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN;
/* * If we're in synchronous mode, and the SSI is already enabled, @@ -439,9 +455,9 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, /* In synchronous mode, the SSI uses STCCR for capture */ if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) || ssi_private->cpu_dai_drv.symmetric_rates) - clrsetbits_be32(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, wl); + write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, wl); else - clrsetbits_be32(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl); + write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl);
return 0; } @@ -466,19 +482,19 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - setbits32(&ssi->scr, + write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE); else - setbits32(&ssi->scr, + write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE); break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - clrbits32(&ssi->scr, CCSR_SSI_SCR_TE); + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TE, 0); else - clrbits32(&ssi->scr, CCSR_SSI_SCR_RE); + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0); break;
default: @@ -510,7 +526,7 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, if (!ssi_private->first_stream) { struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
- clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN); + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0); } }
As Documentation/devicetree/bindings/powerpc/fsl/ssi.txt documented, codec-handle is an optional property, so missing it should not be a fatal error.
More importantly, the imx machine drivers to be added working with fsl_ssi will not have this property, as they use new ASoC machine driver binding mechanism.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/fsl/fsl_ssi.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index d31d1ba..290728d 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -638,12 +638,6 @@ static int __devinit fsl_ssi_probe(struct platform_device *pdev) if (!of_device_is_available(np)) return -ENODEV;
- /* Check for a codec-handle property. */ - if (!of_get_property(np, "codec-handle", NULL)) { - dev_err(&pdev->dev, "missing codec-handle property\n"); - return -ENODEV; - } - /* We only support the SSI in "I2S Slave" mode */ sprop = of_get_property(np, "fsl,mode", NULL); if (!sprop || strcmp(sprop, "i2s-slave")) {
Makes necessary changes on fsl_ssi to let it work with imx pcm and machine drivers.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/fsl/fsl_ssi.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 68 insertions(+), 1 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 290728d..8c8ca9c 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -28,6 +28,7 @@ #include <sound/soc.h>
#include "fsl_ssi.h" +#include "imx-pcm.h"
#ifdef PPC #define read_ssi(addr) in_be32(addr) @@ -36,7 +37,7 @@ #elif defined ARM #define read_ssi(addr) readl(addr) #define write_ssi(val, addr) writel(val, addr) -static inline void write_ssi_mask(void __iomem *addr, u32 clear, u32 set) +static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set) { u32 val = readl(addr); val = (val & ~clear) | set; @@ -112,6 +113,11 @@ struct fsl_ssi_private { struct device_attribute dev_attr; struct platform_device *pdev;
+ int ssi_on_imx; + struct platform_device *imx_pcm_pdev; + struct imx_pcm_dma_params dma_params_tx; + struct imx_pcm_dma_params dma_params_rx; + struct { unsigned int rfrc; unsigned int tfrc; @@ -409,6 +415,12 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, ssi_private->second_stream = substream; }
+ if (ssi_private->ssi_on_imx) + snd_soc_dai_set_dma_data(dai, substream, + (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? + &ssi_private->dma_params_tx : + &ssi_private->dma_params_rx); + return 0; }
@@ -702,6 +714,38 @@ static int __devinit fsl_ssi_probe(struct platform_device *pdev) /* Older 8610 DTs didn't have the fifo-depth property */ ssi_private->fifo_depth = 8;
+ if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx1-ssi")) { + u32 dma_events[2]; + ssi_private->ssi_on_imx = 1; + /* + * FIXME: The dma burst size must equal to ssi watermark + * setting on imx. We have burstsize be "fifo_depth - 2" + * here because "fifo_depth - 2" rather than fifo_depth is + * being written into watermark register in fsl_ssi_startup(). + * Is this something needs to be fixed for PowerPC? + */ + ssi_private->dma_params_tx.burstsize = + ssi_private->fifo_depth - 2; + ssi_private->dma_params_rx.burstsize = + ssi_private->fifo_depth - 2; + ssi_private->dma_params_tx.dma_addr = + ssi_private->ssi_phys + offsetof(struct ccsr_ssi, stx0); + ssi_private->dma_params_rx.dma_addr = + ssi_private->ssi_phys + offsetof(struct ccsr_ssi, srx0); + /* + * TODO: This is a temporary solution and should be changed + * to use generic DMA binding later when the helplers get in. + */ + ret = of_property_read_u32_array(pdev->dev.of_node, + "fsl,ssi-dma-events", dma_events, 2); + if (ret) { + dev_err(&pdev->dev, "could not get dma events\n"); + goto error_irq; + } + ssi_private->dma_params_tx.dma = dma_events[0]; + ssi_private->dma_params_rx.dma = dma_events[1]; + } + /* Initialize the the device_attribute structure */ dev_attr = &ssi_private->dev_attr; sysfs_attr_init(&dev_attr->attr); @@ -725,6 +769,24 @@ static int __devinit fsl_ssi_probe(struct platform_device *pdev) goto error_dev; }
+ /* + * In case of imx, the machine driver uses new binding which does + * not require SSI driver to trigger machine driver's probe, but + * the pcm device needs to be registered here. + */ + if (ssi_private->ssi_on_imx) { + ssi_private->imx_pcm_pdev = + platform_device_register_simple("imx-pcm-audio", + -1, NULL, 0); + if (IS_ERR(ssi_private->imx_pcm_pdev)) { + ret = PTR_ERR(ssi_private->imx_pcm_pdev); + goto error_dev; + } else { + /* success for imx */ + return 0; + } + } + /* Trigger the machine driver's probe function. The platform driver * name of the machine driver is taken from /compatible property of the * device tree. We also pass the address of the CPU DAI driver @@ -750,6 +812,8 @@ static int __devinit fsl_ssi_probe(struct platform_device *pdev)
error_dai: snd_soc_unregister_dai(&pdev->dev); + if (ssi_private->ssi_on_imx) + platform_device_unregister(ssi_private->imx_pcm_pdev);
error_dev: dev_set_drvdata(&pdev->dev, NULL); @@ -776,6 +840,8 @@ static int fsl_ssi_remove(struct platform_device *pdev)
platform_device_unregister(ssi_private->pdev); snd_soc_unregister_dai(&pdev->dev); + if (ssi_private->ssi_on_imx) + platform_device_unregister(ssi_private->imx_pcm_pdev); device_remove_file(&pdev->dev, &ssi_private->dev_attr);
free_irq(ssi_private->irq, ssi_private); @@ -789,6 +855,7 @@ static int fsl_ssi_remove(struct platform_device *pdev)
static const struct of_device_id fsl_ssi_ids[] = { { .compatible = "fsl,mpc8610-ssi", }, + { .compatible = "fsl,imx1-ssi", }, {} }; MODULE_DEVICE_TABLE(of, fsl_ssi_ids);
From: Richard Zhao richard.zhao@linaro.org
It adds device tree probe support for imx-audmux driver.
Signed-off-by: Richard Zhao richard.zhao@linaro.org Signed-off-by: Shawn Guo shawn.guo@linaro.org --- .../devicetree/bindings/sound/imx-audmux.txt | 13 +++++++++++++ sound/soc/fsl/imx-audmux.c | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/imx-audmux.txt
diff --git a/Documentation/devicetree/bindings/sound/imx-audmux.txt b/Documentation/devicetree/bindings/sound/imx-audmux.txt new file mode 100644 index 0000000..215aa98 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/imx-audmux.txt @@ -0,0 +1,13 @@ +Freescale Digital Audio Mux (AUDMUX) device + +Required properties: +- compatible : "fsl,imx21-audmux" for AUDMUX version firstly used on i.MX21, + or "fsl,imx31-audmux" for the version firstly used on i.MX31. +- reg : Should contain AUDMUX registers location and length + +Example: + +audmux@021d8000 { + compatible = "fsl,imx6q-audmux", "fsl,imx31-audmux"; + reg = <0x021d8000 0x4000>; +}; diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c index 87f8768..b83699d 100644 --- a/sound/soc/fsl/imx-audmux.c +++ b/sound/soc/fsl/imx-audmux.c @@ -22,6 +22,8 @@ #include <linux/err.h> #include <linux/io.h> #include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/slab.h>
@@ -197,6 +199,13 @@ static struct platform_device_id imx_audmux_ids[] = { }; MODULE_DEVICE_TABLE(platform, imx_audmux_ids);
+static const struct of_device_id imx_audmux_dt_ids[] = { + { .compatible = "fsl,imx21-audmux", .data = &imx_audmux_ids[0], }, + { .compatible = "fsl,imx31-audmux", .data = &imx_audmux_ids[1], }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, imx_audmux_dt_ids); + static const uint8_t port_mapping[] = { 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c, }; @@ -243,6 +252,8 @@ EXPORT_SYMBOL_GPL(imx_audmux_v2_configure_port); static int __init imx_audmux_probe(struct platform_device *pdev) { struct resource *res; + const struct of_device_id *of_id = + of_match_device(imx_audmux_dt_ids, &pdev->dev);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); audmux_base = devm_request_and_ioremap(&pdev->dev, res); @@ -256,6 +267,8 @@ static int __init imx_audmux_probe(struct platform_device *pdev) audmux_clk = NULL; }
+ if (of_id) + pdev->id_entry = of_id->data; audmux_type = pdev->id_entry->driver_data; if (audmux_type == IMX31_AUDMUX) audmux_debugfs_init(); @@ -279,6 +292,7 @@ static struct platform_driver imx_audmux_driver = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, + .of_match_table = imx_audmux_dt_ids, } };
On Mon, Mar 05, 2012 at 10:31:04PM +0800, Shawn Guo wrote:
From: Richard Zhao richard.zhao@linaro.org
It adds device tree probe support for imx-audmux driver.
Applied this one as well, thanks. This really should've been in with all the other audmux motion stuff, there's no dependency on it having been moved into the fsl directory so it just makes it harder to apply (but as it was a straight move git am figured it out).
As a general rule put bugfixes first, then minor cleanups, then things that are internal to existing files (like this) and finally anything invasive. Basically, do the urgent stuff first and then work up in terms of how big/tricky the changes are. This makes it easier to get things applied which is especially important with a large series like this as it makes review easier and means you have fewer out of tree patches to keep track of.
On 6 March 2012 20:49, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
On Mon, Mar 05, 2012 at 10:31:04PM +0800, Shawn Guo wrote:
From: Richard Zhao richard.zhao@linaro.org
It adds device tree probe support for imx-audmux driver.
Applied this one as well, thanks. This really should've been in with all the other audmux motion stuff, there's no dependency on it having been moved into the fsl directory so it just makes it harder to apply (but as it was a straight move git am figured it out).
As a general rule put bugfixes first, then minor cleanups, then things that are internal to existing files (like this) and finally anything invasive. Basically, do the urgent stuff first and then work up in terms of how big/tricky the changes are. This makes it easier to get things applied which is especially important with a large series like this as it makes review easier and means you have fewer out of tree patches to keep track of.
Thanks for the suggestion, Mark.
Regards, Shawn
This is the initial imx-sgtl5000 machine driver support with only playback dai link implemented. More features can be added on top of it later.
It's a device tree only machine driver working with fsl_ssi driver.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- .../bindings/sound/imx-audio-sgtl5000.txt | 24 +++ sound/soc/fsl/Kconfig | 12 ++ sound/soc/fsl/Makefile | 2 + sound/soc/fsl/imx-sgtl5000.c | 181 ++++++++++++++++++++ 4 files changed, 219 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt create mode 100644 sound/soc/fsl/imx-sgtl5000.c
diff --git a/Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt b/Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt new file mode 100644 index 0000000..22b3f03 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt @@ -0,0 +1,24 @@ +Freescale i.MX audio complex with SGTL5000 codec + +Required properties: +- compatible : "fsl,imx-audio-sgtl5000" +- fsl,model : The user-visible name of this sound complex +- fsl,ssi-controller : The phandle of the i.MX SSI controller +- fsl,audio-codec : The phandle of the SGTL5000 audio codec +- fsl,mux-int-port : The internal port of the i.MX audio muxer (AUDMUX) +- fsl,mux-ext-port : The external port of the i.MX audio muxer + +Note: The AUDMUX port numbering should start at 1, which is consistent with +hardware manual. + +Example: + +sound { + compatible = "fsl,imx51-babbage-sgtl5000", + "fsl,imx-audio-sgtl5000"; + fsl,model = "imx51-babbage-sgtl5000"; + fsl,ssi-controller = <&ssi1>; + fsl,audio-codec = <&sgtl5000>; + fsl,mux-int-port = <1>; + fsl,mux-ext-port = <3>; +}; diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index e579671..42a3842 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -164,4 +164,16 @@ config SND_SOC_EUKREA_TLV320 Enable I2S based access to the TLV320AIC23B codec attached to the SSI interface
+config SND_SOC_IMX_SGTL5000 + tristate "SoC Audio support for i.MX boards with sgtl5000" + depends on OF && I2C + select SND_SOC_SGTL5000 + select SND_MXC_SOC_MX2 + select SND_SOC_IMX_AUDMUX + select SND_SOC_FSL_SSI + select SND_SOC_FSL_UTILS + help + Say Y if you want to add support for SoC audio on an i.MX board with + a sgtl5000 codec. + endif # SND_IMX_SOC diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 02b3e53..5ae854b 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -40,8 +40,10 @@ snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o snd-soc-phycore-ac97-objs := phycore-ac97.o snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o snd-soc-wm1133-ev1-objs := wm1133-ev1.o +snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o
obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o +obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c new file mode 100644 index 0000000..f34ebd8 --- /dev/null +++ b/sound/soc/fsl/imx-sgtl5000.c @@ -0,0 +1,181 @@ +/* + * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012 Linaro Ltd. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_platform.h> +#include <sound/soc.h> + +#include "../codecs/sgtl5000.h" +#include "fsl_utils.h" +#include "imx-audmux.h" + +struct imx_sgtl5000_data { + struct snd_soc_dai_link dai[2]; + struct snd_soc_card card; + char codec_name[DAI_NAME_SIZE]; + char codec_dai_name[DAI_NAME_SIZE]; + char platform_name[DAI_NAME_SIZE]; + unsigned int clk_frequency; +}; + +static int imx_sgtl5000_dai_init(struct snd_soc_pcm_runtime *rtd) +{ + struct imx_sgtl5000_data *data = container_of(rtd->card, + struct imx_sgtl5000_data, card); + struct device *dev = rtd->card->dev; + int ret; + + ret = snd_soc_dai_set_fmt(rtd->codec_dai, SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM); + if (ret) { + dev_err(dev, "could not set codec driver audio format\n"); + return ret; + } + + ret = snd_soc_dai_set_sysclk(rtd->codec_dai, SGTL5000_SYSCLK, + data->clk_frequency, SND_SOC_CLOCK_IN); + if (ret) { + dev_err(dev, "could not set codec driver clock params\n"); + return ret; + } + + return 0; +} + +static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device_node *ssi_np, *codec_np; + struct platform_device *ssi_pdev; + struct imx_sgtl5000_data *data; + int int_port, ext_port; + int ret; + + ret = of_property_read_u32(np, "fsl,mux-int-port", &int_port); + if (ret) { + dev_err(&pdev->dev, "mux-int-port missing or invalid\n"); + return -EINVAL; + } + ret = of_property_read_u32(np, "fsl,mux-ext-port", &ext_port); + if (ret) { + dev_err(&pdev->dev, "mux-ext-port missing or invalid\n"); + return -EINVAL; + } + + /* + * The port numbering in the hardware manual starts at 1, while + * the audmux API expects it starts at 0. + */ + int_port--; + ext_port--; + imx_audmux_v2_configure_port(int_port, + IMX_AUDMUX_V2_PTCR_SYN | + IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) | + IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | + IMX_AUDMUX_V2_PTCR_TFSDIR | + IMX_AUDMUX_V2_PTCR_TCLKDIR, + IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port)); + imx_audmux_v2_configure_port(ext_port, + IMX_AUDMUX_V2_PTCR_SYN | + IMX_AUDMUX_V2_PTCR_TCSEL(int_port), + IMX_AUDMUX_V2_PDCR_RXDSEL(int_port)); + + ssi_np = of_parse_phandle(pdev->dev.of_node, "fsl,ssi-controller", 0); + codec_np = of_parse_phandle(pdev->dev.of_node, "fsl,audio-codec", 0); + if (!ssi_np || !codec_np) { + dev_err(&pdev->dev, "phandle missing or invalid\n"); + return -EINVAL; + } + + ssi_pdev = of_find_device_by_node(ssi_np); + if (!ssi_pdev) { + dev_err(&pdev->dev, "failed to find SSI platform device\n"); + return -EINVAL; + } + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = of_property_read_u32(codec_np, "clock-frequency", + &data->clk_frequency); + if (ret) { + dev_err(&pdev->dev, "clock-frequency missing or invalid\n"); + return -EINVAL; + } + + ret = fsl_asoc_get_codec_dev_name(codec_np, data->codec_name, + DAI_NAME_SIZE); + if (ret) { + dev_err(&pdev->dev, "failed to get codec name\n"); + return -EINVAL; + } + + data->dai[0].name = "HiFi Tx"; + data->dai[0].stream_name = "HiFi Playback"; + data->dai[0].codec_dai_name = "sgtl5000"; + data->dai[0].codec_name = data->codec_name; + data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev); + data->dai[0].platform_name = "imx-pcm-audio"; + data->dai[0].init = &imx_sgtl5000_dai_init; + + data->card.dev = &pdev->dev; + ret = snd_soc_of_parse_card_name(&data->card, "fsl,model"); + if (ret) + return ret; + data->card.num_links = 1; + data->card.dai_link = data->dai; + + ret = snd_soc_register_card(&data->card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); + return ret; + } + + platform_set_drvdata(pdev, data); + of_node_put(codec_np); + + return 0; +} + +static int __devexit imx_sgtl5000_remove(struct platform_device *pdev) +{ + struct imx_sgtl5000_data *data = platform_get_drvdata(pdev); + + snd_soc_unregister_card(&data->card); + + return 0; +} + +static const struct of_device_id imx_sgtl5000_dt_ids[] = { + { .compatible = "fsl,imx-audio-sgtl5000", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, imx_sgtl5000_dt_ids); + +static struct platform_driver imx_sgtl5000_driver = { + .driver = { + .name = "imx-sgtl5000", + .owner = THIS_MODULE, + .of_match_table = imx_sgtl5000_dt_ids, + }, + .probe = imx_sgtl5000_probe, + .remove = __devexit_p(imx_sgtl5000_remove), +}; +module_platform_driver(imx_sgtl5000_driver); + +MODULE_AUTHOR("Shawn Guo shawn.guo@linaro.org"); +MODULE_DESCRIPTION("Freescale i.MX SGTL5000 ASoC machine driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:imx-sgtl5000");
On Mon, Mar 05, 2012 at 10:31:05PM +0800, Shawn Guo wrote:
- ret = snd_soc_dai_set_fmt(rtd->codec_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBM_CFM);
- if (ret) {
dev_err(dev, "could not set codec driver audio format\n");
return ret;
- }
This you can just set in the card struct, no need for explicit code at all.
- ret = of_property_read_u32(np, "fsl,mux-int-port", &int_port);
- if (ret) {
dev_err(&pdev->dev, "mux-int-port missing or invalid\n");
return -EINVAL;
- }
- ret = of_property_read_u32(np, "fsl,mux-ext-port", &ext_port);
- if (ret) {
dev_err(&pdev->dev, "mux-ext-port missing or invalid\n");
return -EINVAL;
- }
It seems very odd to have namespacing on the individual property names. Why are you doing that? The properties are already defined in terms of the device binding. Though everyone else is doing it so not really a problem.
- /*
* The port numbering in the hardware manual starts at 1, while
* the audmux API expects it starts at 0.
*/
- int_port--;
- ext_port--;
Should have error checking somewhere to make sure that the user remembered this.
- imx_audmux_v2_configure_port(int_port,
IMX_AUDMUX_V2_PTCR_SYN |
IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) |
IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) |
IMX_AUDMUX_V2_PTCR_TFSDIR |
IMX_AUDMUX_V2_PTCR_TCLKDIR,
IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port));
I'm not sure we've really gained much from converting to a platform driver given that the device just registers something globally...
On Mon, Mar 05, 2012 at 02:46:01PM +0000, Mark Brown wrote:
On Mon, Mar 05, 2012 at 10:31:05PM +0800, Shawn Guo wrote:
- ret = snd_soc_dai_set_fmt(rtd->codec_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBM_CFM);
- if (ret) {
dev_err(dev, "could not set codec driver audio format\n");
return ret;
- }
This you can just set in the card struct, no need for explicit code at all.
Yes, I just tried. It also works but a little bit differently. We only set_fmt for codec_dai here, while ASoC core will set_fmt for both codec_dai and cpu_dai if dai_link->dai_fmt is set. However, the fsl_ssi does not provide .set_fmt implementation, and consequently we will see error message below, which does not impact functionality though.
fsl-ssi-dai 83fcc000.ssi: Failed to set DAI format: -22
I hope we keep the code as it is now and improve later when fsl_ssi gets improved.
- ret = of_property_read_u32(np, "fsl,mux-int-port", &int_port);
- if (ret) {
dev_err(&pdev->dev, "mux-int-port missing or invalid\n");
return -EINVAL;
- }
- ret = of_property_read_u32(np, "fsl,mux-ext-port", &ext_port);
- if (ret) {
dev_err(&pdev->dev, "mux-ext-port missing or invalid\n");
return -EINVAL;
- }
It seems very odd to have namespacing on the individual property names. Why are you doing that? The properties are already defined in terms of the device binding. Though everyone else is doing it so not really a problem.
The general device tree binding practice is we'd better have a vendor prefix on the property name, if the property applies on specific vendor drivers instead of common ones across different vendors.
- /*
* The port numbering in the hardware manual starts at 1, while
* the audmux API expects it starts at 0.
*/
- int_port--;
- ext_port--;
Should have error checking somewhere to make sure that the user remembered this.
Because different i.MX SoC may have different internal and external port number, I do not think of a way to check that. And I would not worry about it that much, since all the hardware documents number the port from 1, while device tree user/author will have to look at those documents for the data.
- imx_audmux_v2_configure_port(int_port,
IMX_AUDMUX_V2_PTCR_SYN |
IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) |
IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) |
IMX_AUDMUX_V2_PTCR_TFSDIR |
IMX_AUDMUX_V2_PTCR_TCLKDIR,
IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port));
I'm not sure we've really gained much from converting to a platform driver given that the device just registers something globally...
Converting audmux to a platform driver does not change anything about that. It makes device tree support easier, and gets the audmux users (imx machine drivers) stay away from including <mach/audmux.h>.
On Tue, Mar 06, 2012 at 03:39:02PM +0800, Shawn Guo wrote:
On Mon, Mar 05, 2012 at 02:46:01PM +0000, Mark Brown wrote:
This you can just set in the card struct, no need for explicit code at all.
Yes, I just tried. It also works but a little bit differently. We only set_fmt for codec_dai here, while ASoC core will set_fmt for both codec_dai and cpu_dai if dai_link->dai_fmt is set. However, the fsl_ssi does not provide .set_fmt implementation, and consequently we will see error message below, which does not impact functionality though.
fsl-ssi-dai 83fcc000.ssi: Failed to set DAI format: -22
I hope we keep the code as it is now and improve later when fsl_ssi gets improved.
No, we should fix the core to work better in this case - not having a DAI operation is perfectly normal and should be supported.
- ret = of_property_read_u32(np, "fsl,mux-int-port", &int_port);
- ret = of_property_read_u32(np, "fsl,mux-ext-port", &ext_port);
It seems very odd to have namespacing on the individual property names. Why are you doing that? The properties are already defined in terms of the device binding. Though everyone else is doing it so not really a problem.
The general device tree binding practice is we'd better have a vendor prefix on the property name, if the property applies on specific vendor drivers instead of common ones across different vendors.
There's nothing generic about this device, it only applies to a specific combination of things and in so far as it applies to those the properties are generic - any board combining i.MX and this CODEC is going to have an audmux.
- /*
* The port numbering in the hardware manual starts at 1, while
* the audmux API expects it starts at 0.
*/
- int_port--;
- ext_port--;
Should have error checking somewhere to make sure that the user remembered this.
Because different i.MX SoC may have different internal and external port number, I do not think of a way to check that. And I would not
In that case the audmux code should be validating the arguments.
worry about it that much, since all the hardware documents number the port from 1, while device tree user/author will have to look at those documents for the data.
OTOH the in kernel API uses a different numbering and if the user is porting their existing code over to device tree...
- imx_audmux_v2_configure_port(int_port,
IMX_AUDMUX_V2_PTCR_SYN |
IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) |
IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) |
IMX_AUDMUX_V2_PTCR_TFSDIR |
IMX_AUDMUX_V2_PTCR_TCLKDIR,
IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port));
I'm not sure we've really gained much from converting to a platform driver given that the device just registers something globally...
Converting audmux to a platform driver does not change anything about that. It makes device tree support easier, and gets the audmux users (imx machine drivers) stay away from including <mach/audmux.h>.
It's not actually fixed anything in the APIs though and we've now also got a race in the driver probes since the audmux now need to come up via the device model instead of just being there - we could try to configure the audmux with no platform driver bound. We should really have the audmux as at least an aux_dev in the card to make sure it's there.
On Tue, Mar 06, 2012 at 12:02:47PM +0000, Mark Brown wrote:
On Tue, Mar 06, 2012 at 03:39:02PM +0800, Shawn Guo wrote:
On Mon, Mar 05, 2012 at 02:46:01PM +0000, Mark Brown wrote:
This you can just set in the card struct, no need for explicit code at all.
Yes, I just tried. It also works but a little bit differently. We only set_fmt for codec_dai here, while ASoC core will set_fmt for both codec_dai and cpu_dai if dai_link->dai_fmt is set. However, the fsl_ssi does not provide .set_fmt implementation, and consequently we will see error message below, which does not impact functionality though.
fsl-ssi-dai 83fcc000.ssi: Failed to set DAI format: -22
I hope we keep the code as it is now and improve later when fsl_ssi gets improved.
No, we should fix the core to work better in this case - not having a DAI operation is perfectly normal and should be supported.
So something like this?
@@ -1536,12 +1536,8 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) "Failed to set DAI format: %d\n", ret);
- ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai, - dai_link->dai_fmt); - if (ret != 0) - dev_warn(card->rtd[i].cpu_dai->dev, - "Failed to set DAI format: %d\n", - ret); + snd_soc_dai_set_fmt(card->rtd[i].cpu_dai, + dai_link->dai_fmt); } }
- ret = of_property_read_u32(np, "fsl,mux-int-port", &int_port);
- ret = of_property_read_u32(np, "fsl,mux-ext-port", &ext_port);
It seems very odd to have namespacing on the individual property names. Why are you doing that? The properties are already defined in terms of the device binding. Though everyone else is doing it so not really a problem.
The general device tree binding practice is we'd better have a vendor prefix on the property name, if the property applies on specific vendor drivers instead of common ones across different vendors.
There's nothing generic about this device, it only applies to a specific combination of things and in so far as it applies to those the properties are generic - any board combining i.MX and this CODEC is going to have an audmux.
Since you agreed it's not really a problem, I would like to do what everyone else is doing.
- /*
* The port numbering in the hardware manual starts at 1, while
* the audmux API expects it starts at 0.
*/
- int_port--;
- ext_port--;
Should have error checking somewhere to make sure that the user remembered this.
Because different i.MX SoC may have different internal and external port number, I do not think of a way to check that. And I would not
In that case the audmux code should be validating the arguments.
What we can check is only where the number starts and probably where it ends. That requires audmux driver have the ranges of internal port and external port for each i.MX SoC encoded. For DT case, we may have the ranges defined in device tree, while for non-DT case, we then need to introduce platform_data to pass that piece of data. In the end, this check does not guarantee the correctness, and developers have to give the correct port number. So is it really worth it?
worry about it that much, since all the hardware documents number the port from 1, while device tree user/author will have to look at those documents for the data.
OTOH the in kernel API uses a different numbering and if the user is porting their existing code over to device tree...
Whoever is porting the code will need to look at the audmux binding document, where we have a big note regarding this.
- imx_audmux_v2_configure_port(int_port,
IMX_AUDMUX_V2_PTCR_SYN |
IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) |
IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) |
IMX_AUDMUX_V2_PTCR_TFSDIR |
IMX_AUDMUX_V2_PTCR_TCLKDIR,
IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port));
I'm not sure we've really gained much from converting to a platform driver given that the device just registers something globally...
Converting audmux to a platform driver does not change anything about that. It makes device tree support easier, and gets the audmux users (imx machine drivers) stay away from including <mach/audmux.h>.
It's not actually fixed anything in the APIs though
I'm not fixing the APIs. Instead, I'm adding device tree support for audmux driver, while converting it to platform driver make that easy.
and we've now also got a race in the driver probes since the audmux now need to come up via the device model instead of just being there
The race is solved by having audmux device registered in a subsys_initcall.
- we could try to configure
the audmux with no platform driver bound.
Before this series, the audmux is configured with no platform driver bound. I'm confused here. Are you saying we are moving to a wrong direction?
We should really have the audmux as at least an aux_dev in the card to make sure it's there.
I do not understand how aux_dev can help here. Being a device encoded in device tree, audmux device should have been created by DT core, and all we need to do is registering the audmux driver to get it bound to audmux device.
On Tue, Mar 06, 2012 at 09:34:18PM +0800, Shawn Guo wrote:
On Tue, Mar 06, 2012 at 12:02:47PM +0000, Mark Brown wrote:
No, we should fix the core to work better in this case - not having a DAI operation is perfectly normal and should be supported.
So something like this?
@@ -1536,12 +1536,8 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
if (ret != 0)
dev_warn(card->rtd[i].cpu_dai->dev,
"Failed to set DAI format: %d\n",
ret);
It should still complain but it should check to see if there was an actual set_fmt op and only complain then, probably we should change all the noop error codes for the accessor functions to be -ENOTSUPP or something and then change the check here to look for ret != 0 && ret != ENOTSUPP.
There's nothing generic about this device, it only applies to a specific combination of things and in so far as it applies to those the properties are generic - any board combining i.MX and this CODEC is going to have an audmux.
Since you agreed it's not really a problem, I would like to do what everyone else is doing.
Well, "everyone else" in this context is only Tegra right now so there's a case for nipping this in the bud too :)
In that case the audmux code should be validating the arguments.
What we can check is only where the number starts and probably where it ends. That requires audmux driver have the ranges of internal port and external port for each i.MX SoC encoded. For DT case, we may have the ranges defined in device tree, while for non-DT case, we then need to introduce platform_data to pass that piece of data. In the end, this check does not guarantee the correctness, and developers have to give the correct port number. So is it really worth it?
It does seem concerning and error prone that there's two different numbering schemes for the audmux APIs.
OTOH the in kernel API uses a different numbering and if the user is porting their existing code over to device tree...
Whoever is porting the code will need to look at the audmux binding document, where we have a big note regarding this.
If there's one universal truth about system integrators it's that they always read the documentation and don't ever just copy things from an example and tweak it till it works. :)
It's not actually fixed anything in the APIs though
I'm not fixing the APIs. Instead, I'm adding device tree support for audmux driver, while converting it to platform driver make that easy.
I know, that's kind of the problem. You've moved the device registration to the device model but not done anything on the top level to ensure that we actually managed to do so.
and we've now also got a race in the driver probes since the audmux now need to come up via the device model instead of just being there
The race is solved by having audmux device registered in a subsys_initcall.
And hoping that it does actually get registered and successfully loads and that it doesn't get built as a module which could get set up in a different order, plus the edge cases where users actively unbind the driver from the device.
- we could try to configure
the audmux with no platform driver bound.
Before this series, the audmux is configured with no platform driver bound. I'm confused here. Are you saying we are moving to a wrong direction?
Previously just building the code was enough, it'd unconditionally initialise itself in early init and we were fine. Now there's a bunch of different ways in which someone could break things since we're using the device model so we need to make sure we work with those.
We should really have the audmux as at least an aux_dev in the card to make sure it's there.
I do not understand how aux_dev can help here. Being a device encoded in device tree, audmux device should have been created by DT core, and all we need to do is registering the audmux driver to get it bound to audmux device.
None of that stuff does anything to ensure that the audmux is present before the card comes up.
On Mon, Mar 05, 2012 at 10:31:05PM +0800, Shawn Guo wrote:
This is the initial imx-sgtl5000 machine driver support with only playback dai link implemented. More features can be added on top of it later.
Are there problems with capturing? It should be trivial to add and it would be much more confident that this series as a whole works as expected.
Sascha
There is in the BSP but the BSP driver is trying to be way too fancy with I2S settings on the imx-ssi driver you wrote (it works well for AC97, but for SSI in I2S slave mode there are so many hacks upon hacks "they" have presented, it'd never mainline)
Having the codec provide clocks in slave mode works great in fsl-ssi because it doesn't set the chip up any other way, but I've had serious problems here whereby playing back a 48khz, 16-bit audio stream and recording in ANYTHING else seems to make the playback stream slow motion, but I can't trace whether it's the SSI config (seems unlikely as the only valid STXCCR bit in slave mode is the word length) or the codec config. In theory the playback and capture should be serialized by the driver, though, right? It wouldn't be possible to be a slave to the codec if it had to run the clock two different rates at the same time.. app1 sends a sample buffer, codec does dma, app2 requests capture buffer, codec does dma, they can't happen at the same time, maybe we are missing an important mutex or spinlock here that would enforce this and stop the configuration changing mid-stream.. I'm far from the ALSA expert though)
If adding capture support means having to make the SSI driver work in I2S master mode and do the laborious work of actually dividing the SSI clock, configuring the external PLL etc. so it can clock the codec appropriately for this mode then that's what will have to be done, and I agree with Sascha, whatever the solution it should be something that gets done now (not least because I kind of want audio here.. :) along with quite possibly adapting the current imx-ssi driver (as opposed to the fsl-ssi driver) to be fsl-ssi-ac97 vs fsl-ssi-imx so we have dedicated operation (which will make the AC97/FIQ select much easier to determine).
While we're at it; did anyone patch arch/arm/mach-imx/ssi-fiq.S to be compiled in .arm mode yet? I can't find it in a tree or the list but I could be wrong. I am sure we mutually agreed (or at least Russell decided) on this to get thumb kernels to build again since none of the dependent processors/config selections are M-profile?
On Mon, Mar 05, 2012 at 12:09:13PM -0600, Matt Sealey wrote:
There is in the BSP but the BSP driver is trying to be way too fancy with I2S settings on the imx-ssi driver you wrote (it works well for AC97, but for SSI in I2S slave mode there are so many hacks upon hacks "they" have presented, it'd never mainline)
Having the codec provide clocks in slave mode works great in fsl-ssi because it doesn't set the chip up any other way, but I've had serious problems here whereby playing back a 48khz, 16-bit audio stream and recording in ANYTHING else seems to make the playback stream slow motion, but I can't trace whether it's the SSI config (seems unlikely as the only valid STXCCR bit in slave mode is the word length) or the codec config. In theory the playback and capture should be serialized by the driver, though, right? It wouldn't be possible to be a slave to the codec if it had to run the clock two different rates at the same time.. app1 sends a sample buffer, codec does dma, app2 requests capture buffer, codec does dma, they can't happen at the same time, maybe we are missing an important mutex or spinlock here that would enforce this and stop the configuration changing mid-stream.. I'm far from the ALSA expert though)
If adding capture support means having to make the SSI driver work in I2S master mode and do the laborious work of actually dividing the SSI clock, configuring the external PLL etc. so it can clock the codec appropriately for this mode then that's what will have to be done, and I agree with Sascha, whatever the solution it should be something that gets done now (not least because I kind of want audio here.. :) along with quite possibly adapting the current imx-ssi driver (as opposed to the fsl-ssi driver) to be fsl-ssi-ac97 vs fsl-ssi-imx so we have dedicated operation (which will make the AC97/FIQ select much easier to determine).
master mode shouldn't be necessary to get the sgtl5000 work with both recording and playback. I have seen it working on the babbage board in slave mode on some internal branch. I never got the sgtl5000 mainline driver to work though.
While we're at it; did anyone patch arch/arm/mach-imx/ssi-fiq.S to be compiled in .arm mode yet? I can't find it in a tree or the list but I could be wrong. I am sure we mutually agreed (or at least Russell decided) on this to get thumb kernels to build again since none of the dependent processors/config selections are M-profile?
I think we agreed on compiliing this in arm mode but nobody has sent a patch yet.
Sascha
On Mon, Mar 05, 2012 at 12:09:13PM -0600, Matt Sealey wrote:
There is in the BSP but the BSP driver is trying to be way too fancy with I2S settings on the imx-ssi driver you wrote (it works well for AC97, but for SSI in I2S slave mode there are so many hacks upon hacks "they" have presented, it'd never mainline)
I'm really having a very hard time comprehending this paragraph, and indeed much of the rest of your mail. The lack of any context isn't helping here... There is what exactly in the BSP?
codec config. In theory the playback and capture should be serialized by the driver, though, right? It wouldn't be possible to be a slave to
That would be *really* bad, simultaneous playback and record is very widely used.
the codec if it had to run the clock two different rates at the same time.. app1 sends a sample buffer, codec does dma, app2 requests capture buffer, codec does dma, they can't happen at the same time, maybe we are missing an important mutex or spinlock here that would enforce this and stop the configuration changing mid-stream.. I'm far from the ALSA expert though)
If the hardware has constraints on the sample rates the driver should be telling the application about this. For the very common case where you need the same rate for playback and record there's framework support for doing this, the relevant driver just needs to set the symmetric_rates flag and the core will do everything. Note that the ALSA APIs are racy here.
Mark Brown wrote:
That would be *really* bad, simultaneous playback and record is very widely used.
Especially since I already have that working on PowerPC. I went through great lengths to get the device tree binding and the code working in this regard.
If the hardware has constraints on the sample rates the driver should be telling the application about this. For the very common case where you need the same rate for playback and record there's framework support for doing this, the relevant driver just needs to set the symmetric_rates flag and the core will do everything.
And my driver currently does this. If the SSI is wired up in synchronous mode, sample rate/size locking is enabled.
On Mon, Mar 05, 2012 at 06:42:32PM +0100, Sascha Hauer wrote:
On Mon, Mar 05, 2012 at 10:31:05PM +0800, Shawn Guo wrote:
This is the initial imx-sgtl5000 machine driver support with only playback dai link implemented. More features can be added on top of it later.
Are there problems with capturing? It should be trivial to add and it would be much more confident that this series as a whole works as expected.
I worked all day long to try to give that answer. Here it is.
No, there is no problem with capturing on fsl_ssi + imx_pcm_dma + imx_sgtl5000 side. But there is a problem with sgtl5000 codec driver. With that problem fixed in sgtl5000, this series works just fine with capturing. (I'm not sure I want to fix it within this series though, as it's already big enough.)
On Tue, Mar 06, 2012 at 11:50:57PM +0800, Shawn Guo wrote:
On Mon, Mar 05, 2012 at 06:42:32PM +0100, Sascha Hauer wrote:
On Mon, Mar 05, 2012 at 10:31:05PM +0800, Shawn Guo wrote:
This is the initial imx-sgtl5000 machine driver support with only playback dai link implemented. More features can be added on top of it later.
Are there problems with capturing? It should be trivial to add and it would be much more confident that this series as a whole works as expected.
I worked all day long to try to give that answer. Here it is.
No, there is no problem with capturing on fsl_ssi + imx_pcm_dma + imx_sgtl5000 side. But there is a problem with sgtl5000 codec driver. With that problem fixed in sgtl5000, this series works just fine with capturing. (I'm not sure I want to fix it within this series though, as it's already big enough.)
Thanks a lot for testing this. In this case I'm fine with this series and can likely Ack your next iteration. You can skip capture support from this series as you said it's big enough. It's enough for me when you say it works on your branch.
Sascha
Shawn Guo wrote:
Changes since v1:
- Address comments from Mark, Timur, and Sascha (Thanks for review).
- Drop patches that have been applied by Mark.
So I'm testing them now, and I get this on boot:
ALSA device list: No soundcards found.
This happens frequently to my drivers whenever something in ASoC changes. And it's a pain to debug because ASoC never tells me what's wrong.
I'm debugging it now. I'll let you know when I find something.
On Wed, Mar 07, 2012 at 03:05:48PM -0600, Timur Tabi wrote:
This happens frequently to my drivers whenever something in ASoC changes. And it's a pain to debug because ASoC never tells me what's wrong.
Turn on the debug logging in soc-core.c and it'll chatter away about what's up; not finding cards is a perfectly normal thing s we're not too verbose.
Mark Brown wrote:
Turn on the debug logging in soc-core.c and it'll chatter away about what's up; not finding cards is a perfectly normal thing s we're not too verbose.
So it turns out there are a couple problems.
1) This patch is missing:
http://patchwork.ozlabs.org/patch/128533/
Our exalted maintainer apparently forgot to apply this patch in a timely manner for 3.3, so it probably won't make it. But that's something I'll just have to deal with.
2) The p1022_ds.c needs the equivalent of this patch:
http://mailman.alsa-project.org/pipermail/alsa-devel/2011-November/046253.ht...
I have no idea how the P1022DS ever worked, because the WM8776 driver has always needed the SND_SOC_DAIFMT_Cxx_xxx macro defined.
Apparently, p1022_ds.c needs to set a value for SND_SOC_DAIFMT_INV_MASK. I tried SND_SOC_DAIFMT_NB_NF, and that seems to work.
Shawn, I'd make the change myself, but I don't want to step on your toes while doing it. Do you want to make it yourself?
On Wed, Mar 07, 2012 at 05:03:00PM -0600, Timur Tabi wrote:
Our exalted maintainer apparently forgot to apply this patch in a timely manner for 3.3, so it probably won't make it. But that's something I'll just have to deal with.
Probably work asking for it to have a CC to stable added (or ask Greg directly if it gets applied without one) - people are getting better at deploying stable updates so it'll save you some pain if it's in there.
On Wed, Mar 07, 2012 at 05:03:00PM -0600, Timur Tabi wrote: ...
Shawn, I'd make the change myself, but I don't want to step on your toes while doing it. Do you want to make it yourself?
I'd prefer you do it too.
Shawn Guo wrote:
Shawn, I'd make the change myself, but I don't want to step on your toes while doing it. Do you want to make it yourself?
I'd prefer you do it too.
Ok.
Shawn Guo wrote:
Changes since v1:
- Address comments from Mark, Timur, and Sascha (Thanks for review).
- Drop patches that have been applied by Mark.
I've tested this patchset, and after adding the changes that I pointed out in my previous email, audio still works on the P1022DS and MPC8610HPCD.
Therefore:
Acked-by: Timur Tabi timur@freescale.com
On Wed, Mar 07, 2012 at 05:18:31PM -0600, Timur Tabi wrote:
I've tested this patchset, and after adding the changes that I pointed out in my previous email, audio still works on the P1022DS and MPC8610HPCD.
Therefore:
Acked-by: Timur Tabi timur@freescale.com
Excellent, it's great to see the SSI drivers merged! Shawn, could you please resend the unapplied patches with all the relevant acks collected and tweaks that people requested just to make sure I've got everything.
I know Sascha wanted some slightly larger changes to the new card driver so if you want to hold off on that until you've done the updates that's fine but it'd be good to get all the other stuff merging the drivers together for 3.4 if we can.
On Thu, Mar 08, 2012 at 12:02:07PM +0000, Mark Brown wrote:
On Wed, Mar 07, 2012 at 05:18:31PM -0600, Timur Tabi wrote:
I've tested this patchset, and after adding the changes that I pointed out in my previous email, audio still works on the P1022DS and MPC8610HPCD.
Therefore:
Acked-by: Timur Tabi timur@freescale.com
Excellent, it's great to see the SSI drivers merged! Shawn, could you please resend the unapplied patches with all the relevant acks collected and tweaks that people requested just to make sure I've got everything.
Sure. I got interrupted from the work during the past 2 days, but I'm resuming it now.
I know Sascha wanted some slightly larger changes to the new card driver so if you want to hold off on that until you've done the updates that's fine but it'd be good to get all the other stuff merging the drivers together for 3.4 if we can.
That's my goal too.
On Wed, Mar 07, 2012 at 05:18:31PM -0600, Timur Tabi wrote:
Shawn Guo wrote:
Changes since v1:
- Address comments from Mark, Timur, and Sascha (Thanks for review).
- Drop patches that have been applied by Mark.
I've tested this patchset, and after adding the changes that I pointed out in my previous email, audio still works on the P1022DS and MPC8610HPCD.
Thanks a lot, Timur.
Therefore:
Acked-by: Timur Tabi timur@freescale.com
What are the patches I can apply your ack? Or every one in this series?
On Mar 8, 2012, at 7:11 AM, "Shawn Guo" shawn.guo@linaro.org wrote:
What are the patches I can apply your ack? Or every one in this series?
The whole series. I didn't test individual patches, so I don't know if any one of them is bad by itself.
participants (6)
-
Mark Brown
-
Matt Sealey
-
Sascha Hauer
-
Shawn Guo
-
Tabi Timur-B04825
-
Timur Tabi