cancel
Showing results for 
Search instead for 
Did you mean: 

Setting SPI clock to 20 MHz and beyond

JSamo.2
Associate II

Hello,

my system is based on an STM32MP151x, running embedded Linux (Buildroot generated + all the ST patches, v5.3.56). I am suing an SPI connection to an external hardware but so far, i am not able to set the SPI clock to 20MHz and higher.

Looking at the code (spidev, spi) it looks like the controller is just picking the default value (12 MHz) whatever the value i am using in my IOCTL call (i am using user space spidev ioctl to setup the SPI).

Is there a specific DTS section i might have omitted which would allow me to setup these higher SPI speeds ?

Thanks,

Jacques

1 ACCEPTED SOLUTION

Accepted Solutions

Yes, most clock setup are in TF-A (and/or OP-TEE if used).

Files could be quickly are generated by CubeMX where clock setup is maybe more friendly than reading reference manual and Device Tree bindings and source code.

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.

View solution in original post

3 REPLIES 3
PatrickF
ST Employee

Hi @JSamo.2​ ,

Maybe look at your Device Tree:

spi-max-frequency = <xxxx>;

https://wiki.st.com/stm32mpu/wiki/SPI_device_tree_configuration#DT_configuration_-28board_level-29

and as well as related SPI kernel clock setting which should be high enough for the required output frequency.

st,pkcs = <......>;

https://wiki.st.com/stm32mpu/wiki/Clock_device_tree_configuration#STM32MP15x_lines

https://github.com/STMicroelectronics/arm-trusted-firmware/blob/v2.6-stm32mp/fdts/stm32mp15xx-dkx.dtsi#L237

12MHz is likely because the SPI receive a 24MHz kernel clock (HSE) and so the driver is selecting the highest possible choice with this clock.

Regards,

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

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.
JSamo.2
Associate II

Thanks for the answer.

I understand that this st,pkcs setting is to be done in the TF-A dts ?

Yes, most clock setup are in TF-A (and/or OP-TEE if used).

Files could be quickly are generated by CubeMX where clock setup is maybe more friendly than reading reference manual and Device Tree bindings and source code.

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.