I2S Clock Frequency

I’m trying to make the my two (2x) ICS-43432 - InvenSense microphone record properly.

I want to get a sampling rate of 48,000 KHz when recording.

In order to satisfy this requirement i have to set the SAI2 frequency to 24,576 MHz
Device tree elements :




as in the last screenshot, the commented line represents my attempt to assign clocks, but still getting
24,00 MHz in clk_summary and when trying to record with this command:

arecord -D hw:01 -f S32_LE -t wav -c 2 -V stereo -v -r 48000 file.wav

i get an error “hw params”

and it only works with sampling rate of 11500 or 11025

arecord -D hw:01 -f S32_LE -t wav -c 2 -V stereo -v -r 11025 file.wav ===> this will cause one
channel to record (low quality) and the other channel to generate high nosy sound.

PS: those mics tested on PI3 and works perfectly.

Hi @medaliyou,

When you conducted the tests on the Raspberry Pi 3, you used a similar DTS configuration like the one you are showing?

And about your pin muxing, why are you using only 0x1f on your values? I would expect a 32bit configuration on each pin.

Can you also confirm which BSP 5 are you using? (BSP 5.1, 5.2…)

Best regards,
André Curvello

Hi André,
The tests on PI3 we’re done by other team, i’m afraid i don’t have access to device tree.
BSP 5.2
I don’t understand you properly about pin muxing , why should i expand the configuration to 32 bit, while in documentation HERE pin config are written only on 6 bits ?

Also i m not sure where i should change the clock rates , in the SAI2 node or inside the SOUND2 node.

Best regards, Mohamed Ali Yousfi

Hi @medaliyou

Could you please attach the clk_summary output, dmesg log? also, git diff changes.

regarding clock rates, by using the assigned-clock-rates property in sai node, you can change/add clock ratings like assigned-clock-rates = <0>, <36864000>, <589824000>;.

@ashok.tx, could you have a look at his issue?

Hi @medaliyou

Is your issue solved?if no,
Could you provide the dmesg,clk_summary logs and git diff output ?
have you checked the mclk pin in DSO?if yes attach the snapshots.
Regarding the clock rates,you can use assign-clock-rates option in sai node to assign different clock frequencies.


Following the solution marked here (last comment)

link text

Inwas able to get the proper sampling rates on arecord

Did. Not test it yet on real hardware ( i will in the next hours )

But in the Kernel logs , pinctrl driver issues that i 've used the sgl5000 codedc’s

See this screenshot

I will test my ics43432 mic and see if it works with this pin issue.

Testing this configuration on the HW led to those errors on the attached dmesg.log , also i’ve attached the device tree diff.

dmesg.log: link text

DTSI diff: link text

And this is what i get if i try to record :

Hi @medaliyou

Thanks for the attached logs.

This is because sai1_mclk is already assigned to sgtl5000 codec and could not be shared with other codec.Please try with the dedicated sai2 mclk pins 98 or 135 like


note if you want to use this pin as sai2_mclk pin,you need to disable the default functionality i.e MX7D_PAD_SD2_RESET_B__GPIO5_IO11.

Are you using SGTL5000 codec?if not disable the same.

Hey , Thank you for responding

I’m not an expert and i have no previous experience with Embedded systems, i’m sorry if i mislead you.

Unfortunately MX7D_PAD_SD2_RESET_B__SAI2_MCLK is reserved for my LCD screen.

i can’t disable SGTL5000 it’s already in use.

As i attached before in the previous screenshots:

pinctrl_sai2: sai2-grp {
            fsl,pins = <
                    MX7D_PAD_SAI2_TX_SYNC__SAI2_TX_SYNC     0x1f    /* SODIMM 25 */
                    MX7D_PAD_SD2_DATA1__SAI2_TX_BCLK                0x1f    /* SODIMM 31 */ 
                    MX7D_PAD_SAI2_RX_DATA__SAI2_RX_DATA0    0x1f    /* SODIMM 32 */

This pin setup is already fixed.

BCLK have a frequency requirement (460 kHz to 3.379 MHz according to the data sheet)

with Fs = 44100 Hz
In my case: BCLK must be set to 2822400 Hz = Fs * 2 Channels * 32 BitDepth

I have to provide the proper Internal CLK frequency (i have no external OSC) to ** BCLK** in order to have Fs = (44100 OR 48000) Hz sample rate.

Hi @medaliyou

Please note sai1_mclk(not available at SOC module edge connector) is already used by SGTL5000.Disable the same at pinctrl_sai2_mclk node and add alternate mclk pins i.e SODIMM PIN 98( MX7D_PAD_SD2_RESET_B__SAI2_MCLK) or 135(MX7D_PAD_LPSR_GPIO1_IO02__SAI2_MCLK) if needed.

if possible,could you share the dts files for better understanding.

Hey, Thank you for responding

I’m afraid i can’t share the full device tree, But i attached the MIC HW Schema and the necessary device tree snippets (I removed all changes i made, and restore the device tree to it’s original state where my analog mic ICS43432 worked but only with sampling rate between 10000 and 11500 Hz ).

As i mentioned previously i’m have no previous experience with embedded systems,
that’s why i find difficulties to test things you pointed me to. I don’t know where exactly to define clock sources or clock rates.
Could you please Guide me to the exact DTS node (block) where i have to make the change (because after reviewing freescale imx7d.dts and others, every device tree looks different than the other, some define clocks & clock rate inside the CODEC node, or the SOUND node and others in the SAI phandle node)

In which node should i add Master clock MCLK and define clock rates ?

Also i’m wondering is it NORMAL to use SAI2_RX_DATA0 (SODIMM 32) and SAI2_TX_SYNC (SODIMM 25) ?

Should it be SAI2_RX_SYNC (SODIMM 77) ?

Thank you

101 /* ICS 43432 MEMS microphone */
102         sound2: sound-2 {
103                 compatible = "simple-audio-card";
104                 simple-audio-card,name = "ics43432";
105                 simple-audio-card,format = "i2s";
106                 status = "okay";
108                 dailink2: simple-audio-card,codec {
109                         sound-dai = <&ics43432>;
110                         clocks = <&clks IMX7D_SAI2_ROOT_CLK>;
111                 };
113                 simple-audio-card,cpu {
114                         sound-dai = <&sai2>;
115                 };
117         };
119         ics43432: codec@0 {
120                 #sound-dai-cells = <0>;
121                 compatible = "invensense,ics43432";
122                 status = "okay";
123         };
125         reg_3v3: regulator-3v3 {
126                 compatible = "regulator-fixed";
127                 regulator-name = "3.3V";
128                 regulator-min-microvolt = <3300000>;
129                 regulator-max-microvolt = <3300000>;
130         };

366 &sai2 {
367         pinctrl-names = "default";
368         pinctrl-0 = <&pinctrl_sai2>;
369         status = "okay";
370 };

627         pinctrl_sai2: sai2-grp {
628                 fsl,pins = <
629                         MX7D_PAD_SAI2_TX_SYNC__SAI2_TX_SYNC     0x1f    /* SODIMM 25 */
630                         MX7D_PAD_SD2_DATA1__SAI2_TX_BCLK        0x1f    /* SODIMM 31 */ 
631                         MX7D_PAD_SAI2_RX_DATA__SAI2_RX_DATA0    0x1f    /* SODIMM 32 */
632                 >;
633         };



Hi @medaliyou

Thanks for the attachments.

Could you please try with the attached device tree changes and let me know.

sound2: sound-2 {
                  compatible = "simple-audio-card";
                  simple-audio-card,name = "ics43432";
                  simple-audio-card,format = "i2s";
		  simple-audio-card,bitclock-master = <&dailink_master_cpu>;
		  simple-audio-card,frame-master = <&dailink_master_cpu>;
                  status = "okay";
                  dailink2: simple-audio-card,codec {
                          sound-dai = <&ics43432>;
                          clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
                  dailink_master_cpu: simple-audio-card,cpu {
                          sound-dai = <&sai2>;

   ics43432: codec@0 {
                  #sound-dai-cells = <0>;
                  compatible = "invensense,ics43432";
                  status = "okay";

 &sai2 {
          pinctrl-names = "default";
          pinctrl-0 = <&pinctrl_sai2>;
          assigned-clocks = <&clks IMX7D_SAI2_ROOT_SRC>,
			  <&clks IMX7D_SAI2_ROOT_CLK>,
                           <&clks IMX7D_PLL_AUDIO_POST_DIV>;
	  assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
	  assigned-clock-rates = <0>, <36864000>, <24288000>;
          status = "okay";

pinctrl_sai2: sai2-grp {
                  fsl,pins = <
                          MX7D_PAD_SAI2_TX_SYNC__SAI2_TX_SYNC     0x1f    /* SODIMM 25 */
                          MX7D_PAD_SD2_DATA1__SAI2_TX_BCLK        0x1f    /* SODIMM 31 */ 
                          MX7D_PAD_SAI2_RX_DATA__SAI2_RX_DATA0    0x1f    /* SODIMM 32 */

Hey agin,

I tried your solution, and still doesn’t work, the same fsl_sai issues about mclk0 error code -2 and others i provided in screenshots.

The clock rates are always wrong, no matter what i provide in DTS i always end up with the wrong clock settings.

With BSP3.0 and Kernel 4.14.Y the mic works but only with 11025 sampling rate.
I had the Mic working also only for 11025 with BSP5.2 and kernel 5.4.91 (current build) but now even when i restored the same original DTS isn’t working any more.

  • HW is fine.
  • Didn’t change Kernel’s Sound driver.





Hi @medaliyou

Could you provide the dmesg,clk_summary logs? I could not see any screenshots attached.

Sorry but they were correctly rendered for me .
I attached the picture below also

link text

Hi @medaliyou

Thanks for the attachments.Looking at the attachments, it’s clock issue only.
Try with the below clock rates at sai2 node and also probe SCK,SD,WS pins in oscilloscope.

assigned-clock-rates = <0>, <36864000>, <589824000>; 
assigned-clock-rates = <0>, <24576000>;

Hey, thank you again for responding

i just tested the first proposition:

assigned-clock-rates = <0>, <36864000>, <589824000>;

Unfortunately, it didn’t work. Even arecord won’t work.
Also i can’t measure with oscilloscope, because of arecord can’t start recording, and i have no signals to see, only some noise.

As you can see in the attached file, i saved the arecord commands, the dmesg logs and the clk_summary:

link text

i will try the second proposition

Hey Thank you for responding again,

(it’s not our subject but i’m having problems with this community platform, my uploaded files PNGs or TXTs won’t render or get saved, btw this is the 3rd time i’m writing this comment and i hope it persist and get published )

i tested the first clocks propositions and it didn’t work, i attached a file containing the dmesg logs, the arecord commands and the clk_summary

Note also that i can’t measure the frequencies with the oscilloscope because i can’t get the micro recording with arecord, so no signals at all only noises .

I will try the second proposition.

link text

I Got the same errors with the 2nd clock setup.

Still can’t derive required RATE

fsl-sai 308b0000.sai: ASoC: can’t set 308b0000.sai hw params: -22
fsl-sai 308b0000.sai: failed to derive required Rx rate: 705600