Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-31 Thread Fabio Estevam
On Tue, Jan 26, 2016 at 9:01 AM, Felipe Ferreri Tonello
 wrote:

> Actually yes, thanks! I didn't know about the existence of fsl-asoc-card.
>
> I get some errors but I don't think they actually matter:
> [   19.734494] fsl-asrc 2034000.asrc: driver registered
> [   19.738707] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
> [   19.738717] fsl-asoc-card sound: snd_soc_register_card failed (-517)
> [   19.741556] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
> [   19.741564] fsl-asoc-card sound: snd_soc_register_card failed (-517)
> [   19.774591] fsl-asoc-card sound: cs4271-hifi <-> 2028000.ssi mapping ok
> [   19.781507] fsl-asoc-card sound: ASoC: no source widget found for
> ASRC-Playback
> [   19.790065] fsl-asoc-card sound: ASoC: Failed to add route
> ASRC-Playback -> direct -> CPU-Playback
> [   19.805349] fsl-asoc-card sound: ASoC: no sink widget found for
> ASRC-Capture
> [   19.817222] fsl-asoc-card sound: ASoC: Failed to add route
> CPU-Capture -> direct -> ASRC-Capture
>
> The codec is producing sound, which is good. Any idea on why these
> errors are been triggered?

Nicolin's patch should fix these warnings:
https://lkml.org/lkml/2016/1/31/8


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-26 Thread Nicolin Chen
On Tue, Jan 26, 2016 at 09:05:42AM -0200, Fabio Estevam wrote:
> On Tue, Jan 26, 2016 at 9:01 AM, Felipe Ferreri Tonello
>  wrote:
> 
> > Actually yes, thanks! I didn't know about the existence of fsl-asoc-card.
> >
> > I get some errors but I don't think they actually matter:
> > [   19.734494] fsl-asrc 2034000.asrc: driver registered
> > [   19.738707] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
> > [   19.738717] fsl-asoc-card sound: snd_soc_register_card failed (-517)
> > [   19.741556] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
> > [   19.741564] fsl-asoc-card sound: snd_soc_register_card failed (-517)

Deferred probes shouldn't be a problem.

> > [   19.774591] fsl-asoc-card sound: cs4271-hifi <-> 2028000.ssi mapping ok

Link is mapped.

> > [   19.781507] fsl-asoc-card sound: ASoC: no source widget found for
> > ASRC-Playback
> > [   19.790065] fsl-asoc-card sound: ASoC: Failed to add route
> > ASRC-Playback -> direct -> CPU-Playback
> > [   19.805349] fsl-asoc-card sound: ASoC: no sink widget found for
> > ASRC-Capture
> > [   19.817222] fsl-asoc-card sound: ASoC: Failed to add route
> > CPU-Capture -> direct -> ASRC-Capture

You may ignore these "failures" if you don't have ASRC at all. It's
optional based on the SoC design or platform requirement. Refer to:
Documentation/devicetree/bindings/sound/fsl-asoc-card.txt

But I think the log over here could be less confusing. I may try to
clean it later.

Thanks
Nicolin


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-26 Thread Mark Brown
On Tue, Jan 26, 2016 at 09:50:46AM -0600, Rob Herring wrote:
> On Tue, Jan 26, 2016 at 3:43 AM, Felipe Ferreri Tonello

> >> This should be an exact list of possible strings and valid combinations.

No, there is no sense in trying to document all possible combinations as
this would result in so many combinations that it would dominate the
documentation.  The restrictions should all come from the physical
limitations of what you can connect and should therefore be sufficiently
obvious from their definition.

> > This is the exact list for this version of this driver. At least that is
> > what I can verify on my hardware (custom build).

> What are AINA, AINB, etc. then?

These are CODEC pins and should be documented in the CODEC binding
rather than repeated for every machine using the CODEC.


signature.asc
Description: PGP signature


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-26 Thread Rob Herring
On Tue, Jan 26, 2016 at 3:43 AM, Felipe Ferreri Tonello
 wrote:
> Hi Rob,
>
> On 26/01/16 02:29, Rob Herring wrote:
>> On Mon, Jan 25, 2016 at 05:53:23PM +, Felipe F. Tonello wrote:
>>> This is the initial imx-cs427x device-tree-only machine driver working with
>>> fsl_ssi driver. More features can be added on top of it later.
>>>
>>> Signed-off-by: Felipe F. Tonello 
>>> ---
>>>  .../devicetree/bindings/sound/imx-audio-cs427x.txt |  47 +
>>>  sound/soc/fsl/Kconfig  |  12 ++
>>>  sound/soc/fsl/Makefile |   2 +
>>>  sound/soc/fsl/imx-cs427x.c | 218 
>>> +
>>>  4 files changed, 279 insertions(+)
>>>  create mode 100644 
>>> Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
>>>  create mode 100644 sound/soc/fsl/imx-cs427x.c
>>>
>>> diff --git a/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt 
>>> b/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
>>> new file mode 100644
>>> index ..295f60b19418
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
>>> @@ -0,0 +1,47 @@
>>> +Freescale i.MX audio complex with CS4271 or CS4272 codec
>>
>> Do all the i.MX audio bindings really vary more that the codec? Seems
>> like a lot of duplication.
>
> I agree, but that how it is today. These platform drivers for imx are
> similar but not identical. Looking at them I would guess that they have
> 50 to 60% of duplicated code.
>
> I believe we can add this driver and work on re-using the code on a
> future series of patches.
>
>>
>>> +
>>> +Required properties:
>>> +
>>> +  - compatible  : "fsl,imx-audio-cs427x"
>>> +
>>> +  - model   : The user-visible name of this sound complex
>>> +
>>> +  - ssi-controller  : The phandle of the i.MX SSI controller
>>> +
>>> +  - audio-codec : The phandle of the CS4271 audio codec
>>> +
>>> +  - audio-routing   : A list of the connections between audio components.
>>> +  Each entry is a pair of strings, the first being the
>>> +  connection's sink, the second being the connection's
>>> +  source. Valid names could be power supplies, CS427x
>>> +  pins, and the jacks on the board:
>>> +
>>> +  Board connectors:
>>> +   * Mic Jack
>>> +   * Headphone Jack
>>
>> This should be an exact list of possible strings and valid combinations.
>
> This is the exact list for this version of this driver. At least that is
> what I can verify on my hardware (custom build).

What are AINA, AINB, etc. then?

Also, model should have its string documented. I should be able to
write the example from the documentation.

Rob


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-26 Thread Mark Brown
On Tue, Jan 26, 2016 at 09:43:58AM +, Felipe Ferreri Tonello wrote:
> On 26/01/16 02:29, Rob Herring wrote:

> > Do all the i.MX audio bindings really vary more that the codec? Seems 
> > like a lot of duplication.

> I agree, but that how it is today. These platform drivers for imx are
> similar but not identical. Looking at them I would guess that they have
> 50 to 60% of duplicated code.

> I believe we can add this driver and work on re-using the code on a
> future series of patches.

We have fsl-asoc-card which is supposed to allow reuse similar to
simple-card for devices which have an audmux.


signature.asc
Description: PGP signature


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-26 Thread Fabio Estevam
On Tue, Jan 26, 2016 at 9:01 AM, Felipe Ferreri Tonello
 wrote:

> Actually yes, thanks! I didn't know about the existence of fsl-asoc-card.
>
> I get some errors but I don't think they actually matter:
> [   19.734494] fsl-asrc 2034000.asrc: driver registered
> [   19.738707] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
> [   19.738717] fsl-asoc-card sound: snd_soc_register_card failed (-517)
> [   19.741556] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
> [   19.741564] fsl-asoc-card sound: snd_soc_register_card failed (-517)
> [   19.774591] fsl-asoc-card sound: cs4271-hifi <-> 2028000.ssi mapping ok
> [   19.781507] fsl-asoc-card sound: ASoC: no source widget found for
> ASRC-Playback
> [   19.790065] fsl-asoc-card sound: ASoC: Failed to add route
> ASRC-Playback -> direct -> CPU-Playback
> [   19.805349] fsl-asoc-card sound: ASoC: no sink widget found for
> ASRC-Capture
> [   19.817222] fsl-asoc-card sound: ASoC: Failed to add route
> CPU-Capture -> direct -> ASRC-Capture
>
> The codec is producing sound, which is good. Any idea on why these
> errors are been triggered?

Adding Nicolin on Cc.


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-26 Thread Felipe Ferreri Tonello
Hi Fabio,

On 26/01/16 09:47, Fabio Estevam wrote:
> Hi Felipe,
> 
> On Tue, Jan 26, 2016 at 7:43 AM, Felipe Ferreri Tonello
>  wrote:
> 
>> I agree, but that how it is today. These platform drivers for imx are
>> similar but not identical. Looking at them I would guess that they have
>> 50 to 60% of duplicated code.
> 
> Would simple-audio-card or fsl-asoc-card help in this case?
> 

Actually yes, thanks! I didn't know about the existence of fsl-asoc-card.

I get some errors but I don't think they actually matter:
[   19.734494] fsl-asrc 2034000.asrc: driver registered
[   19.738707] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[   19.738717] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[   19.741556] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[   19.741564] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[   19.774591] fsl-asoc-card sound: cs4271-hifi <-> 2028000.ssi mapping ok
[   19.781507] fsl-asoc-card sound: ASoC: no source widget found for
ASRC-Playback
[   19.790065] fsl-asoc-card sound: ASoC: Failed to add route
ASRC-Playback -> direct -> CPU-Playback
[   19.805349] fsl-asoc-card sound: ASoC: no sink widget found for
ASRC-Capture
[   19.817222] fsl-asoc-card sound: ASoC: Failed to add route
CPU-Capture -> direct -> ASRC-Capture

The codec is producing sound, which is good. Any idea on why these
errors are been triggered?

-- 
Felipe


0x92698E6A.asc
Description: application/pgp-keys


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-26 Thread Fabio Estevam
Hi Felipe,

On Tue, Jan 26, 2016 at 7:43 AM, Felipe Ferreri Tonello
 wrote:

> I agree, but that how it is today. These platform drivers for imx are
> similar but not identical. Looking at them I would guess that they have
> 50 to 60% of duplicated code.

Would simple-audio-card or fsl-asoc-card help in this case?


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-26 Thread Felipe Ferreri Tonello
Hi Rob,

On 26/01/16 02:29, Rob Herring wrote:
> On Mon, Jan 25, 2016 at 05:53:23PM +, Felipe F. Tonello wrote:
>> This is the initial imx-cs427x device-tree-only machine driver working with
>> fsl_ssi driver. More features can be added on top of it later.
>>
>> Signed-off-by: Felipe F. Tonello 
>> ---
>>  .../devicetree/bindings/sound/imx-audio-cs427x.txt |  47 +
>>  sound/soc/fsl/Kconfig  |  12 ++
>>  sound/soc/fsl/Makefile |   2 +
>>  sound/soc/fsl/imx-cs427x.c | 218 
>> +
>>  4 files changed, 279 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
>>  create mode 100644 sound/soc/fsl/imx-cs427x.c
>>
>> diff --git a/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt 
>> b/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
>> new file mode 100644
>> index ..295f60b19418
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
>> @@ -0,0 +1,47 @@
>> +Freescale i.MX audio complex with CS4271 or CS4272 codec
> 
> Do all the i.MX audio bindings really vary more that the codec? Seems 
> like a lot of duplication.

I agree, but that how it is today. These platform drivers for imx are
similar but not identical. Looking at them I would guess that they have
50 to 60% of duplicated code.

I believe we can add this driver and work on re-using the code on a
future series of patches.

> 
>> +
>> +Required properties:
>> +
>> +  - compatible  : "fsl,imx-audio-cs427x"
>> +
>> +  - model   : The user-visible name of this sound complex
>> +
>> +  - ssi-controller  : The phandle of the i.MX SSI controller
>> +
>> +  - audio-codec : The phandle of the CS4271 audio codec
>> +
>> +  - audio-routing   : A list of the connections between audio components.
>> +  Each entry is a pair of strings, the first being the
>> +  connection's sink, the second being the connection's
>> +  source. Valid names could be power supplies, CS427x
>> +  pins, and the jacks on the board:
>> +
>> +  Board connectors:
>> +   * Mic Jack
>> +   * Headphone Jack
> 
> This should be an exact list of possible strings and valid combinations.

This is the exact list for this version of this driver. At least that is
what I can verify on my hardware (custom build).

> 
>> +  - mux-int-port: The internal port of the i.MX audio muxer (AUDMUX)
>> +
>> +  - 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,imx6-rex-cs427x",
>> +"fsl,imx-audio-cs427x";
>> +model = "audio-cs427x";
>> +ssi-controller = <&ssi1>;
>> +audio-codec = <&cs4271>;
>> +audio-routing =
>> +"Mic Jack", "AINA",
>> +"Mic Jack", "AINB",
>> +"Headphone Jack", "AOUTA+",
>> +"Headphone Jack", "AOUTA-",
>> +"Headphone Jack", "AOUTB+",
>> +"Headphone Jack", "AOUTB-";
>> +mux-int-port = <1>;
>> +mux-ext-port = <3>;
>> +};

Felipe


0x92698E6A.asc
Description: application/pgp-keys


Re: [PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-25 Thread Rob Herring
On Mon, Jan 25, 2016 at 05:53:23PM +, Felipe F. Tonello wrote:
> This is the initial imx-cs427x device-tree-only machine driver working with
> fsl_ssi driver. More features can be added on top of it later.
> 
> Signed-off-by: Felipe F. Tonello 
> ---
>  .../devicetree/bindings/sound/imx-audio-cs427x.txt |  47 +
>  sound/soc/fsl/Kconfig  |  12 ++
>  sound/soc/fsl/Makefile |   2 +
>  sound/soc/fsl/imx-cs427x.c | 218 
> +
>  4 files changed, 279 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
>  create mode 100644 sound/soc/fsl/imx-cs427x.c
> 
> diff --git a/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt 
> b/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
> new file mode 100644
> index ..295f60b19418
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
> @@ -0,0 +1,47 @@
> +Freescale i.MX audio complex with CS4271 or CS4272 codec

Do all the i.MX audio bindings really vary more that the codec? Seems 
like a lot of duplication.

> +
> +Required properties:
> +
> +  - compatible   : "fsl,imx-audio-cs427x"
> +
> +  - model: The user-visible name of this sound complex
> +
> +  - ssi-controller   : The phandle of the i.MX SSI controller
> +
> +  - audio-codec  : The phandle of the CS4271 audio codec
> +
> +  - audio-routing: A list of the connections between audio components.
> +   Each entry is a pair of strings, the first being the
> +   connection's sink, the second being the connection's
> +   source. Valid names could be power supplies, CS427x
> +   pins, and the jacks on the board:
> +
> +   Board connectors:
> +* Mic Jack
> +* Headphone Jack

This should be an exact list of possible strings and valid combinations.

> +  - mux-int-port : The internal port of the i.MX audio muxer (AUDMUX)
> +
> +  - 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,imx6-rex-cs427x",
> + "fsl,imx-audio-cs427x";
> + model = "audio-cs427x";
> + ssi-controller = <&ssi1>;
> + audio-codec = <&cs4271>;
> + audio-routing =
> + "Mic Jack", "AINA",
> + "Mic Jack", "AINB",
> + "Headphone Jack", "AOUTA+",
> + "Headphone Jack", "AOUTA-",
> + "Headphone Jack", "AOUTB+",
> + "Headphone Jack", "AOUTB-";
> + mux-int-port = <1>;
> + mux-ext-port = <3>;
> +};


[PATCH] ASoC: fsl: add imx-cs427x machine driver

2016-01-25 Thread Felipe F. Tonello
This is the initial imx-cs427x device-tree-only machine driver working with
fsl_ssi driver. More features can be added on top of it later.

Signed-off-by: Felipe F. Tonello 
---
 .../devicetree/bindings/sound/imx-audio-cs427x.txt |  47 +
 sound/soc/fsl/Kconfig  |  12 ++
 sound/soc/fsl/Makefile |   2 +
 sound/soc/fsl/imx-cs427x.c | 218 +
 4 files changed, 279 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
 create mode 100644 sound/soc/fsl/imx-cs427x.c

diff --git a/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt 
b/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
new file mode 100644
index ..295f60b19418
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/imx-audio-cs427x.txt
@@ -0,0 +1,47 @@
+Freescale i.MX audio complex with CS4271 or CS4272 codec
+
+Required properties:
+
+  - compatible : "fsl,imx-audio-cs427x"
+
+  - model  : The user-visible name of this sound complex
+
+  - ssi-controller : The phandle of the i.MX SSI controller
+
+  - audio-codec: The phandle of the CS4271 audio codec
+
+  - audio-routing  : A list of the connections between audio components.
+ Each entry is a pair of strings, the first being the
+ connection's sink, the second being the connection's
+ source. Valid names could be power supplies, CS427x
+ pins, and the jacks on the board:
+
+ Board connectors:
+  * Mic Jack
+  * Headphone Jack
+
+  - mux-int-port   : The internal port of the i.MX audio muxer (AUDMUX)
+
+  - 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,imx6-rex-cs427x",
+   "fsl,imx-audio-cs427x";
+   model = "audio-cs427x";
+   ssi-controller = <&ssi1>;
+   audio-codec = <&cs4271>;
+   audio-routing =
+   "Mic Jack", "AINA",
+   "Mic Jack", "AINB",
+   "Headphone Jack", "AOUTA+",
+   "Headphone Jack", "AOUTA-",
+   "Headphone Jack", "AOUTB+",
+   "Headphone Jack", "AOUTB-";
+   mux-int-port = <1>;
+   mux-ext-port = <3>;
+};
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 14dfdee05fd5..8696b5c42dd8 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -263,6 +263,18 @@ config SND_SOC_IMX_SGTL5000
  Say Y if you want to add support for SoC audio on an i.MX board with
  a sgtl5000 codec.
 
+config SND_SOC_IMX_CS427x
+   tristate "SoC Audio support for i.MX boards with cs4271 or cs4272"
+   depends on OF && (I2C || SPI)
+   select SND_SOC_CS4271_I2C if I2C
+   select SND_SOC_CS4271_SPI if SPI_MASTER
+   select SND_SOC_IMX_PCM_DMA
+   select SND_SOC_IMX_AUDMUX
+   select SND_SOC_FSL_SSI
+   help
+ Say Y if you want to add support for SoC audio on an i.MX board with
+ a CS4271 or CS4272 codec over either SPI or I2C.
+
 config SND_SOC_IMX_SPDIF
tristate "SoC Audio support for i.MX boards with S/PDIF"
select SND_SOC_IMX_PCM_DMA
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index d28dc25c9375..334d183e3a17 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -54,6 +54,7 @@ snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o
 snd-soc-wm1133-ev1-objs := wm1133-ev1.o
 snd-soc-imx-es8328-objs := imx-es8328.o
 snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o
+snd-soc-imx-cs427x-objs := imx-cs427x.o
 snd-soc-imx-wm8962-objs := imx-wm8962.o
 snd-soc-imx-spdif-objs := imx-spdif.o
 snd-soc-imx-mc13783-objs := imx-mc13783.o
@@ -64,6 +65,7 @@ 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_ES8328) += snd-soc-imx-es8328.o
 obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
+obj-$(CONFIG_SND_SOC_IMX_CS427x) += snd-soc-imx-cs427x.o
 obj-$(CONFIG_SND_SOC_IMX_WM8962) += snd-soc-imx-wm8962.o
 obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o
 obj-$(CONFIG_SND_SOC_IMX_MC13783) += snd-soc-imx-mc13783.o
diff --git a/sound/soc/fsl/imx-cs427x.c b/sound/soc/fsl/imx-cs427x.c
new file mode 100644
index ..45c56013822b
--- /dev/null
+++ b/sound/soc/fsl/imx-cs427x.c
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2015 ROLI Ltd.
+ * Author: Felipe F. Tonello 
+ *
+ * Based on imx-sgtl5000.c
+ * 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 th