2024-08-25 08:52 PM
Hello,
I am wondering what could be the best way to write a device tree that sets the STM32MP1 as SAI SLAVE with a CODEC also running as SAI slave. The HW design I am studying has the following specs:
1) STM32MP1 with ALSA and one SAI interface.
2) A codec chipset running as SAI slave.
3) The Si5351B part running as a MASTER clock providing the SAI bit and frame (L/R) clocks to both the SoC and CODEC.
I understand such a setup is a little out of the norm. How can the device tree be modified on the SAI side to avoid the STM32MP1 to become a MASTER. The snippet of a possible device tree is below.
How can I force the STM32MP1 to be a SLAVE on SAI?
I would imagine writing the device tree as follows:
&sai1{
pinctrl-names = "default", "sleep";
pinctrl-0 = <&sai1b_pins_mx>;
pinctrl-1 = <&sai1b_sleep_pins_mx>;
status = "okay";
/* USER CODE BEGIN sai1 */
/* Specify external clock sources for SAI1
We MUST add the clock-names according to the doc. */
clocks = <&rcc SAI1>, <&rcc PLL3_Q>, <&rcc PLL3_R>, <&si5351b_clk0>, <&si5351b_clk1>;
clock-names = "pclk", "x8k", "x11k", "sclk", "lrclk";
/* USER CODE END sai1 */
sai1b:audio-controller@4400a024{
status = "okay";
/* USER CODE BEGIN sai1b */
dma-names = "tx";
mode = "i2s-slave"; /* Set SAI interface to slave mode */
sai1b_port: port {
sai1b_endpoint: endpoint {
remote-endpoint = <&CODEC_tx_endpoint>;
format = "i2s";
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <32>;
bitclock-master = <0>; /* SAI is not the bit clock master */
frame-master = <0>; /* SAI is not the frame sync master */
/* Synchronization configuration */
st,sync = "lrclk"; /* Synchronization signal source */
};
};
/* USER CODE END sai1b */
};
};
The couple of tests performed on a target device are showing that a similar device tree as above still put the STM32MP1 as a MASTER.
Please comment on this.
I am also reading the driver code and the notion of EXTERNAL is unclear to me, are we talking about a signal External to SAI or External to the SoC?
The code reference for the ST driver is: https://github.com/STMicroelectronics/linux/blob/v5.15-stm32mp/sound/soc/stm/stm32_sai.c and https://github.com/STMicroelectronics/linux/blob/v5.15-stm32mp/sound/soc/stm/stm32_sai_sub.c
Solved! Go to Solution.
2024-08-28 01:35 AM
Hello @MToum.1,
You need to remove these two lines from SAI DT entry to configure it as slave:
frame-master;
bitclock-master;
Feel free to look into the SAI DT configuration wiki page.
The following page could help as well : Soundcard configuration.
BR,
Christophe
2024-08-28 01:35 AM
Hello @MToum.1,
You need to remove these two lines from SAI DT entry to configure it as slave:
frame-master;
bitclock-master;
Feel free to look into the SAI DT configuration wiki page.
The following page could help as well : Soundcard configuration.
BR,
Christophe