Skip to main content
Ara.1
Associate III
August 6, 2021
Question

sgtl5000 codec dsi i2c

  • August 6, 2021
  • 42 replies
  • 11268 views

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 .

This topic has been closed for replies.

42 replies

PatrickF
Technical Moderator
August 25, 2021

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.NEW ! Sidekick STM32 AI agent, see here
Ara.1
Ara.1Author
Associate III
August 25, 2021

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
Ara.1Author
Associate III
August 25, 2021

@PatrickF​ any feedback on

PatrickF
Technical Moderator
August 26, 2021

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.NEW ! Sidekick STM32 AI agent, see here
Ara.1
Ara.1Author
Associate III
August 26, 2021

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
Technical Moderator
August 26, 2021

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
Technical Moderator
August 26, 2021

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

Ara.1
Ara.1Author
Associate III
August 31, 2021

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";

      };

Bernard PUEL
Technical Moderator
August 31, 2021

Do you confirm you are oin 5.10.x KErnel ?

Ara.1
Ara.1Author
Associate III
August 31, 2021

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
Technical Moderator
August 31, 2021

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
Ara.1Author
Associate III
August 31, 2021

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