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
PatrickF
ST Employee

Hi,

the following wiki page could help you:

https://wiki.st.com/stm32mpu/wiki/SAI_device_tree_configuration

https://wiki.st.com/stm32mpu/wiki/I2S_device_tree_configuration (Although we recommend to use SAI which is more flexible than SPI/I2S)

https://wiki.st.com/stm32mpu/wiki/I2C_device_tree_configuration

As an example, on STM32MP157F-DK2 board, there is a CS42L51 codec feed by SAI and controlled by I2C. Generating DT from CubeMx for this board could help you.

Regards

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Patrick,

Thanks 

Our customized stm32mp1 board has codec which required i2s1 MCLK enabled, before codec probe read the basic i2c read chip command need to validate further,

Note:

The board does not have provision to get a crystal to feed MCLK of codec, so that's out of option, any easy way to enable always MCLK free running always, any u-boot patch or mechanism to make MCLK work always 12MHZ ?

So with alone I2S1 audio driver, we cannot generate free running I2S1_MCLK? If not, should we need to enable SAI block to get MCLK feed to I2S block.

Ara.1
Senior

@PatrickF​ any feedback on

Hi @Ara.1​ , have you confirmed that it is a missing MCLK clock issue and not another issue around I2C ?

I'm not SW expert, if confirmed that your codec need such clock to allow I2C accesses, I assume that Linux will not probe the I2S until the I2C has succeeded, and I2C need the i2S clock to succeed (chicken and egg issue). Maybe also link to Linux probing order (which we did not master)

I think the Codecs we use on our board does not have this clock constraint to answer over I2C or the codec driver does not need to access I2C to probe the SAI.

Don't know if any trick is possible with DT to skip the I2C read in your case. Maybe there could be solution to feed a clock to the codec from another source/pin.

I'm sorry I cannot help much more, maybe check with sgtl5000 support too.

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

I escalate internally the issue to experts, maybe they have some answers.

Could you confirm that MCLK is never present, even for a short time ? (as sgtl5000 driver seems to enable it, read the I2C and disable it immediately in case of error).

Could you confirm which OpenSTLinux ecosystem you are using ?

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Ara.1
Senior

Hi Patrick,

I have Not seen any mclk clock generation thought out until I end up in add some dummy written codec driver to probe success as an alternative, and some hack in I2S DRIVER, which calls set_sysclk in i2s driver to get 11.3 MHz.

And what I have observed is mclk will only get activated during playback commands,

another try:

BUILT sgtl5000 as a kernel module then if I do insmod on codec sgtl5000 then i2c probe only got succeed, but still actual sgtl5000 codec driver is not called if I add.

Yes, am using openST yocto build.

Bernard PUEL
ST Employee

Hello,

Which kernel version are you using (should be 5.10.x) ? This patch was added only recently: ASoC: stm32: i2s: add master clock provider.

Could you share your device tree ? in your soundcard declaration, you should have the "routing" property on top of the I2S and codec nodes.

I2S wiki page is not up to date but this is the same principle as for SAI, see: https://wiki.st.com/stm32mpu/wiki/SAI_device_tree_configuration#Setting_SAI_as_a_master_clock_provider

I will enter an internal ticket to update the I2S wiki page.

Bernard PUEL
ST Employee

Ok I saw your dts in another thread, it seems only "routing" property should be revised in the soundcard declaration.

Ara.1
Senior

Added routing property, still MCLK is zero before sgtl5000 i2c probe.

sound0:sound@0 {

            compatible = "audio-graph-card";

            label = "STM32MP1-I2S1";

routing =

"Playback" , "MCLK",

"Capture" , "MCLK",

"MICL" , "Mic Bias";

            dais = <&i2s1_port>;

            status = "okay";

      };