cancel
Showing results for 
Search instead for 
Did you mean: 

sgtl5000 codec dsi i2c

Ara.1
Senior

Hi All,

i am using stm32mp1 with i2c on sgtl5000 codec and control lines are over carrier i2s

i am getting kernel soc sgtl5000.c error

sgtl5000 0-000a: Error reading chip id -6

<STM32_PINMUX('A', 15, AF5)>; /* I2S1_WS */

<STM32_PINMUX('Z', 0, AF5)>, /* I2S1_CK */

                  <STM32_PINMUX('Z', 1, AF5)>, /* I2S1_SDI */

                  <STM32_PINMUX('Z', 2, AF5)>, /* I2S1_SDO */

                  <STM32_PINMUX('Z', 6, AF5)>; /* I2S1_MCK */

Any reference dts on i2s1 would be helpful.. and suggest on kernel error .

52 REPLIES 52
Bernard PUEL
ST Employee

Do you confirm you are oin 5.10.x KErnel ?

Ara.1
Senior

Hi Bernard

no i am on 4.19.49 linux, but i merged latest 5.10.X SOC/ stm32mp1_i2s.c and codec new changes merged.

Bernard PUEL
ST Employee

Ok I will check with experts if there are no other dependencies.

On codec driver, we can see, you will never reach I2c read id error while the MCLK is not enabled. Is this also what you saw the first time ?

https://github.com/torvalds/linux/blob/master/sound/soc/codecs/sgtl5000.c#L1608

Ara.1
Senior

yes i am seeing the same thing, MCLK is not enabled here are few work around made,

a. i add a dummy soc- sound as a master and got MCK 11.3 MHz 

b. made sgtl5000 as a kernel module

c. insmod snd-soc-sgtl5000.ko

found only sgtl5000 probed successfully, but codec probe did not got called sgtl5000_probe

Bernard PUEL
ST Employee

OK. After review with experts, here are our conclusions:

  • the external codec requiring MCLK to finish I2c init, I2s part will never solve the issue (MCLK is triggered by ASOC power management and will never happen if the external codec cannot pass I2C init).
  • I2s is the MCLK provider so the best way to solve this mutual dependency would be to make a hack in I2c driver to be consumer of this MCLK clock. That way, the MCLK will be activated as soon as the I2c will request it (so before external codec init).
  • This is not a clean solution but it should work.
Ara.1
Senior

could you brief be how the routing property will makes the always generation of i2s mclk

and will i get patch for Setting I2S as a master clock provider this should be always on while stm32_i2s_probe ?

Bernard PUEL
ST Employee

Could you please share your device tree (i2s, I2c and  sgtl5000) ?

Because it seems to me you have all (but in separate threads) so I would like to check your latest one.

Ara.1
Senior

Hi Bernard,

&i2s1 {

#clock-cells = <0>;

clocks = <&rcc SPI1>, <&rcc SPI1_K>, <&rcc PLL3_Q>, <&rcc PLL3_R>;

clock-names = "pclk", "i2sclk", "x8k", "x11k";

#sound-dai-cells = <1>;

status = "okay";

i2s1_port: ports {

#address-cells = <1>;

#size-cells = <0>;

i2s2_endpoint: port@0 {

reg = <0>;

remote-endpoint = <&sgtl5000_tx_endpoint>;

system-clock-frequency = <48000>;

system-clock-direction-out;

frame-master;

bitclock-master;

format = "i2s";

mclk-fs = <256>;

};

};

};

sound0:sound@0 {

compatible = "audio-graph-card";

label = "STM32MP1-I2S1";

routing =

"Playback" , "MCLK1",

"Capture" , "MCLK1";

dais = <&i2s1_port>;

status = "okay";

};

sgtl5000: sgtl5000.0-000a@a {

compatible = "fsl,sgtl5000";

reg = <0x0a>;

#sound-dai-cells = <0>;

clocks = <&i2s1>;

clock-names = "mclk";

status = "okay";

VDDD-supply = <&v1v8_audio>;

VDDA-supply = <&v3v3_fix>;

VDDIO-supply = <&v3v3_fix>;

ports {

#address-cells = <1>;

#size-cells = <0>;

port@0 {

reg = <0>;

sgtl5000_tx_endpoint: endpoint@0 {

reg = <0>;

remote-endpoint = <&i2s2_endpoint>;

};

};

};

};

Bernard PUEL
ST Employee

I/ You should have this structure:

&i2c {

      sgtl5000 {

            clocks = <&i2s1>;

            …

      };

};

II/ If not already tested, did you try to increase this delay in codec driver:

https://github.com/torvalds/linux/blob/master/sound/soc/codecs/sgtl5000.c#L1628

Ara.1
Senior

Sorry it was under i2c node only i missed

i am using 4.19.XX but have the changes of ,mainly mclk provider but looks like

i have tried udelay(), still no MCLK

linux/stm32_i2s.c at master · torvalds/linux · GitHub

and i observe that i2s-mclk clocks out if any codec stream activity, like playback, capture. may you point out how to make always clock enable with configuring 11.XX MHz frequency in following

Observation:

if i made SGTL5000 as a codec as a kernel module it does respond to i2c command, but only i2c probe got success, and still sgtl5000_probe did not get called,

the codec stream activity done by dummy codec, so i have suggestion in following probe requirement which will work.

static int stm32_i2s_probe(struct platform_device *pdev)------------by default always clock enable

{

  1. stm32_i2s_configure(cpu_dai, params, substream);
  2. if (STM32_I2S_IS_MASTER(i2s))
  3. ret = stm32_i2s_configure_clock(cpu_dai, params);

}

so that SGTL5000 always get MCLK software, and reacts to i2c commands, is that possible ?