cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Configuration issue

RBorr.1
Associate

Hi,

I am working on a project where the hardware platform is based on STM32MP157c and the OS is Linux 4.19.9 .

I am facing on a issue about device tree spi configuration.

Following SPI_overview on wiki.st.com kernel config has been modified with:

CONFIG_SPI=y

CONFIG_SPI_MASTER=y

CONFIG_SPI_STM32=y

CONFIG_SPI_SPIDEV=y

while dts file has been modified adding spi2 DT configuration:

&spi2{

   pinctrl-names = "default", "sleep";

   pinctrl-0 = <&spi2_pins_mx>;

   pinctrl-1 = <&spi2_sleep_pins_mx>;

       cs-gpios = <&gpioi 0 0>;

   status = "okay";

   /* USER CODE BEGIN spi2 */

       spidev@0x00 {

               compatible = "spidev";

               #address-cells = <1>;

               #size-cells = <0>;

               reg = <0>; /* CS #0 */

               spi-max-frequency = <10000000>;

       };

   /* USER CODE END spi2 */

};

When the system goes up on /dev "spi" is not present and the dmesg reports the following error:

[ 1.782858] spi_stm32 4000b000.spi: clk rate = 0

[ 1.786353] spi_stm32: probe of 4000b000.spi failed with error -22

Attached config and dts files

Kind Regards

Renato

This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
PatrickF
ST Employee

Hello,

did you configure the SPI kernel clock source in RCC ?

You could try to build a dummy project using CubeMx and retrofit the right portions in your Device Tree files (likely TF-A ones)

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
RBorr.1
Associate

Hi Patrick,

after the changes on RCC on TF-A dbs file, as suggested, the spi is now available.

Thanks a lot

Best Regards

Renato

Hello,

I was trying to solve the same issue as the author described during the whole last week

I remember having checked RCC configuration and SPI (spi5 I use) was configured as it should. However after reading your post I checked again, and found something weird on my tf-a dts file: even though it had a first definition of RCC with spi5 configured, at the end of my file in section "user code addons" there was a redefinition of RCC config with spi5 not configured. I removed this redefinition and the issue resolved. I don't understand why CubeMX put it there but removing it fixed my problem.

I uploaded this dts file so you may see it yourself, because I think this may be a CubeMX bug.