cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP15 ECO 5.0 Enabling SPI2 and SPIDEV

debugging
Senior III

Custom board. with STM32MP157

 

Objective is the use spidev to test and make transfer over the SPI2 bus.

Problem: /dev/spi* cannot be see on the bus.


Added SPI2 using cubeMX to a project without these and generate the files.
Compare the files generated with files generated for configuration w/o SPI2

 

1. stm32mp151.dts contains the nodes for spi2
No changes needed/made

2. TFA
No differences found

 

3. OP-TEE
- Added ETZPC nodes for SPI2

DECPROT(STM32MP1_ETZPC_SPI2_ID, DECPROT_NS_RW, DECPROT_UNLOCK)

- Added the clock
CLK_SPI2S23_PLL4P

Note: These changes are not mentioned in the WIKI

 

4. U-Boot
- Added pinctrl nodes
- Added device nodes


5. Kernel
- In board_defconfig file add the requirements as per the  SPI WIKI.
- Added pinctrl nodes (same as uboot)
- Added device nodes (same as uboot)

 

6. for the nodes the dma deletion was uncommented, otherwise the following errors appears in dmesg. The PIO error was fixed by using the cs property in the device node, instead of PI0  i Pinctrl section (CubeMX added it into the pinctrl section, in CubeMX full duplex master was selected)

root@stm32mp1:~# dmesg | grep spi
[ 1.910965] spi_stm32 4000b000.spi: failed to request tx dma channel
[ 1.916230] spi_stm32 4000b000.spi: failed to request rx dma channel

[ 1.922486] stm32mp157-pinctrl soc:pinctrl@50002000: pin PI0 already requested by 4000b000.spi; cannot claim for GPIOI:128
[ 1.940990] spi_stm32 4000b000.spi: spi controller registration failed: -22
[ 1.947960] spi_stm32: probe of 4000b000.spi failed with error -22

Note: For I2C6 a similar issue was resolved by adding I@2C6 into the scmi file. but for SPI2 there seems no clock defined.

7. dts entries:

 

&spi2 {

pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi2_pins_mx>;
pinctrl-1 = <&spi2_sleep_pins_mx>;
cs-gpios = <&gpioi 0 GPIO_ACTIVE_LOW>;
status = "okay";
// /delete-property/dmas;
// /delete-property/dma-names;

spidev@0 {
compatible = "linux,spidev";
spi-max-frequency = <25000000>;
////st,spi-midi-ns = <4000>;
reg = <0>;
};
};

 

pinctrl

 

spi2_pins_mx: spi2_mx-0 {
pins {
pinmux = //<STM32_PINMUX('I', 0, AF5)>, /* SPI2_NSS */
<STM32_PINMUX('I', 1, AF5)>, /* SPI2_SCK */
<STM32_PINMUX('I', 2, AF5)>, /* SPI2_MISO */
<STM32_PINMUX('I', 3, AF5)>; /* SPI2_MOSI */
bias-disable;
drive-push-pull;
slew-rate = <1>;
};
};

spi2_sleep_pins_mx: spi2_sleep_mx-0 {
pins {
pinmux = // <STM32_PINMUX('I', 0, ANALOG)>, /* SPI2_NSS */
<STM32_PINMUX('I', 1, ANALOG)>, /* SPI2_SCK */
<STM32_PINMUX('I', 2, ANALOG)>, /* SPI2_MISO */
<STM32_PINMUX('I', 3, ANALOG)>; /* SPI2_MOSI */
};
};

 

8. dmesg shows:

dmesg | grep spi
[ 1.836302] spi_stm32 4000b000.spi: driver initialized (master mode)

9. ls /sys/class/sp*
/sys/class/spi_master:
spi0

/sys/class/spi_slave:

 

 

0 REPLIES 0