Integrating the CS4349 driver to fsl-asoc-card imx6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Integrating the CS4349 driver to fsl-asoc-card imx6

2,026 Views
atillametetured
Contributor V

Hello,

We have a custom board with Cirrus CS4349 Codec on it. It is connected via I2C3 and also AUDMUX4 TXD,TXC and TXFS. CS4349 is a codec which does not require an external master clock. We are having problems with the limnux integration and I would be very glad to get some help on this subject. i.MX6 is the master and it is one way data transfer from imx to codec. imx should supply both the data and bclk and frame sync

Here is how we set up the device tree;

sound {
   compatible = "fsl,imx-audio-cs4349";
   model = "imx-audio-cs4349";
   ssi-controller = <&ssi2>;
   audio-codec = <&codec>;
   audio-routing =
      "Line Out Jack", "AOUT1L",
      "Line Out Jack", "AOUT1R",
      "Line Out Jack", "AOUT2L",
      "Line Out Jack", "AOUT2R",
      "Line Out Jack", "AOUT3L",
      "Line Out Jack", "AOUT3R",
      "Line Out Jack", "AOUT4L",
      "Line Out Jack", "AOUT4R",
      "AIN1L", "Line In Jack",
      "AIN1R", "Line In Jack",
      "AIN2L", "Line In Jack",
      "AIN2R", "Line In Jack";
      mux-int-port = <1>;
      mux-ext-port = <4>;
};

&audmux {
   pinctrl-names = "default";
   pinctrl-0 = <&pinctrl_audmux>;
   status = "okay";
};

&i2c3 {

   clock-frequency = <50000>;
   pinctrl-names = "default";
   pinctrl-0 = <&pinctrl_i2c3>;
   status = "okay";

   codec: cs4349@48 {
      compatible = "cirrus,cs4349";
      reg = <0x48>;
      reset-gpios = <&gpio4 27 0>;

   };
};

pinctrl_audmux: audmuxgrp {
   fsl,pins = <
      MX6QDL_PAD_DISP0_DAT20__AUD4_TXC 0x130b0 /*ARM-I2S-BCLK*/
      MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x130b0 /*ARM-I2S-D0*/
      MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS 0x130b0 /* ARM-I2S-LRCLK */

   >;

};

&ssi2 {
   fsl,mode = "i2s-master";
   status = "okay";
};

And in fsl-asoc-card.c we added the following;

}else if (of_device_is_compatible(np, "fsl,imx-audio-cs4349")) {
   codec_dai_name = "cs4349_hifi";
   priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;

We are getting the following;

[ 3.113057] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[ 3.119475] fsl-asoc-card sound: snd_soc_register_card failed (-517)

and also;

[ 3.339876] fsl-asoc-card sound: ASoC: no sink widget found for Playback
[ 3.346614] fsl-asoc-card sound: ASoC: Failed to add route CPU-Playback -> di rect -> Playback
[ 3.355167] fsl-asoc-card sound: ASoC: no source widget found for Capture
[ 3.361981] fsl-asoc-card sound: ASoC: Failed to add route Capture -> direct -> CPU-Capture
[ 3.370360] fsl-asoc-card sound: ASoC: no source widget found for AOUT1L
[ 3.377086] fsl-asoc-card sound: ASoC: Failed to add route AOUT1L -> direct - > Line Out Jack
[ 3.385546] fsl-asoc-card sound: ASoC: no source widget found for AOUT1R
[ 3.392271] fsl-asoc-card sound: ASoC: Failed to add route AOUT1R -> direct - > Line Out Jack
[ 3.400732] fsl-asoc-card sound: ASoC: no source widget found for AOUT2L
[ 3.407456] fsl-asoc-card sound: ASoC: Failed to add route AOUT2L -> direct - > Line Out Jack
[ 3.415923] fsl-asoc-card sound: ASoC: no source widget found for AOUT2R
[ 3.422648] fsl-asoc-card sound: ASoC: Failed to add route AOUT2R -> direct - > Line Out Jack
[ 3.431108] fsl-asoc-card sound: ASoC: no source widget found for AOUT3L
[ 3.437843] fsl-asoc-card sound: ASoC: Failed to add route AOUT3L -> direct - > Line Out Jack
[ 3.446302] fsl-asoc-card sound: ASoC: no source widget found for AOUT3R
[ 3.453025] fsl-asoc-card sound: ASoC: Failed to add route AOUT3R -> direct - > Line Out Jack
[ 3.461483] fsl-asoc-card sound: ASoC: no source widget found for AOUT4L
[ 3.468208] fsl-asoc-card sound: ASoC: Failed to add route AOUT4L -> direct - > Line Out Jack
[ 3.476667] fsl-asoc-card sound: ASoC: no source widget found for AOUT4R
[ 3.483391] fsl-asoc-card sound: ASoC: Failed to add route AOUT4R -> direct - > Line Out Jack
[ 3.491853] fsl-asoc-card sound: ASoC: no sink widget found for AIN1L
[ 3.498317] fsl-asoc-card sound: ASoC: Failed to add route Line In Jack -> di rect -> AIN1L
[ 3.506603] fsl-asoc-card sound: ASoC: no sink widget found for AIN1R
[ 3.513067] fsl-asoc-card sound: ASoC: Failed to add route Line In Jack -> di rect -> AIN1R
[ 3.521354] fsl-asoc-card sound: ASoC: no sink widget found for AIN2L
[ 3.527818] fsl-asoc-card sound: ASoC: Failed to add route Line In Jack -> di rect -> AIN2L
[ 3.536105] fsl-asoc-card sound: ASoC: no sink widget found for AIN2R
[ 3.542568] fsl-asoc-card sound: ASoC: Failed to add route Line In Jack -> di rect -> AIN2R

[ 3.553063] fsl-asoc-card sound: failed to set sysclk in fsl_asoc_card_late_p robe
[ 3.560573] fsl-asoc-card sound: ASoC: cs4349-audio late_probe() failed: -524
[ 3.573863] fsl-asoc-card sound: snd_soc_register_card failed (-524)

I understand routing errors are normal but what about the ASoC: CPU DAI (null) not registered and failed to set sysclk in fsl_asoc_card_late_p robe errors? How do we fix this? 

Here is the link to cs4349 driver;

Linux/sound/soc/codecs/cs4349.c - Linux Cross Reference - Free Electrons 

linux/cs4349.h at master · torvalds/linux · GitHub 

Please help us wtih the topic, its getting quite frustrating because we tried to change many things so far with no luck.

Regards,

Mete 

Labels (5)
0 Kudos
5 Replies

1,155 Views
igorpadykov
NXP Employee
NXP Employee

Hi Atilla

for "failed to set sysclk" issue one can try to add " sysclk" entry to codec

as in patch

No sound captured with SGTL5000 on i.MX6 in I²S master mode - Patchwork 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,155 Views
atillametetured
Contributor V

Hello Igor,

That worked great thank you very much!

Now I have one more question, we have two codecs in our design, they share the bclk and fsclk but not the data line. They both use AUDMUX4 TXC and AUDMUX4 TXFS but one uses AUDMUX4 TXD and other AUDMUX3 TXD. We got one codec working with your suggestion but linux doesnt recognise the second one. Here is how we modified the code for that;

sound1 {
   compatible = "fsl,imx-audio-cs4349";
   model = "imx-audio-cs4349-1";
   ssi-controller = <&ssi2>;
   audio-codec = <&codec1>;
   audio-routing =
   "Line Out Jack", "AOUT1L",
   "Line Out Jack", "AOUT1R",
   "Line Out Jack", "AOUT2L",
   "Line Out Jack", "AOUT2R",
   "Line Out Jack", "AOUT3L",
   "Line Out Jack", "AOUT3R",
   "Line Out Jack", "AOUT4L",
   "Line Out Jack", "AOUT4R",
   "AIN1L", "Line In Jack",
   "AIN1R", "Line In Jack",
   "AIN2L", "Line In Jack",
   "AIN2R", "Line In Jack";
   mux-int-port = <2>;
   mux-ext-port = <4>;
};

sound2 {
   compatible = "fsl,imx-audio-cs4349";
   model = "imx-audio-cs4349-2";
   ssi-controller = <&ssi1>;
   audio-codec = <&codec2>;
   audio-routing =
   "Line Out Jack", "AOUT1L",
   "Line Out Jack", "AOUT1R",
   "Line Out Jack", "AOUT2L",
   "Line Out Jack", "AOUT2R",
   "Line Out Jack", "AOUT3L",
   "Line Out Jack", "AOUT3R",
   "Line Out Jack", "AOUT4L",
   "Line Out Jack", "AOUT4R",
   "AIN1L", "Line In Jack",
   "AIN1R", "Line In Jack",
   "AIN2L", "Line In Jack",
   "AIN2R", "Line In Jack";
   mux-int-port = <1>;
   mux-ext-port = <3>;
};

&i2c3 {
   clock-frequency = <100000>;
   pinctrl-names = "default";
   pinctrl-0 = <&pinctrl_i2c3>;
   status = "okay";

   codec1: cs4349@48 {
   compatible = "cirrus,cs4349";
   reg = <0x48>;
   reset-gpios = <&gpio4 27 0>;
   sysclk = <24000000>;
   };

   codec2: cs4349@49 {
   compatible = "cirrus,cs4349";
   reg = <0x49>;
   reset-gpios = <&gpio4 27 0>;
   sysclk = <24000000>;
   };
};

pinctrl_audmux_1: audmuxgrp_1 {
   fsl,pins = <
      MX6QDL_PAD_DISP0_DAT20__AUD4_TXC 0x130b0 /*ARM-I2S-BCLK*/
      MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x130b0 /*ARM-I2S-D0 */
      MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS 0x130b0 /* ARM-I2S-LRCLK*/
      MX6QDL_PAD_DISP0_DAT23__AUD4_RXD 0x130b0
>;
};

pinctrl_audmux_2: audmuxgrp_2 {
   fsl,pins = <
      MX6QDL_PAD_DISP0_DAT20__AUD4_TXC 0x130b0 /*ARM-I2S-BCLK*/
      MX6QDL_PAD_CSI0_DAT5__AUD3_TXD 0x130b0 /*ARM-I2S-D1 */
      MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS 0x130b0 /* ARM-I2S-LRCLK*/
      MX6QDL_PAD_DISP0_DAT23__AUD4_RXD 0x130b0
>;
};

&audmux {
   pinctrl-names = "default";
   pinctrl-0 = <&pinctrl_audmux_1 &pinctrl_audmux_2>;
   status = "okay";
};

&ssi1 {
   fsl,mode = "i2s-master";
   status = "okay";
};

&ssi2 {
   fsl,mode = "i2s-master";
   status = "okay";
};

0 Kudos

1,155 Views
igorpadykov
NXP Employee
NXP Employee

Hi Atilla

I am afraid such configuration when second codec (actually handled by ssi1 & AUDMUX3 TXD)

uses clocks from ssi2, will not work, as ssi1 and ssi2 are not fully synchronized.

Seems there is no way to fully synchronize them.

Best regards
igor

0 Kudos

1,155 Views
atillametetured
Contributor V

Hello Igor,

Thank you for your reply.

Is there no way that this hardware configuration can work then? Can we use the ssi2 & audmux3 txd for the second sound output?

Regards,

Mete

0 Kudos

1,155 Views
igorpadykov
NXP Employee
NXP Employee

Hi Atilla

 

second codec uses ssi1 & AUDMUX3 and only ss1 signals
should be used for it

 

Best regards
igor

0 Kudos