cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP15 ECO 5.0 Enabling SPI2 and SPIDEV (OPTEE error duplicate unit in stm32mp157.dsti)

debugging
Lead

Custom board. with STM32MP157

 

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

 

Problem: no ls /dev/spi*


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:

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

hmmm....

https://patchwork.kernel.org/project/spi-devel-general/patch/1427499742-26916-1-git-send-email-broonie@kernel.org/

https://yurovsky.github.io/2016/10/07/spidev-linux-devices.html

https://stackoverflow.com/questions/53634892/linux-spidev-why-it-shouldnt-be-directly-in-devicetree

 
Read comment:
I don't think compatible = "linux,spidev"; works for Linux kernel 5.15 onwards since commit 6840615f85f60. At least, I cannot get it to work in v6.0 and this seems the most likely reason.
 

The warning now seems to be enforced as  disabling spidev without a warning  in kernel 6x...

it's is wrong, "you should" know..

 

 

View solution in original post

3 REPLIES 3
debugging
Lead

Anyone ?

debugging
Lead

 

 

 

  DTC     build/core/arch/arm/dts/stm32mp157a-board-mx-lcd.dtb
core/arch/arm/dts/stm32mp157.dtsi:20.21-35.5: Warning (avoid_unnecessary_addr_size): /soc/dsi@5a000000: unnecessary #address-cells/#size-cells without "ranges", "dma-ranges" or child "reg" property
core/arch/arm/dts/stm32mp151.dtsi:416.22-428.5: Warning (unique_unit_address): /soc/spi@4000b000: duplicate unit-address (also used in node /soc/audio-controller@4000b000)
core/arch/arm/dts/stm32mp151.dtsi:441.22-453.5: Warning (unique_unit_address): /soc/spi@4000c000: duplicate unit-address (also used in node /soc/audio-controller@4000c000)
core/arch/arm/dts/stm32mp151.dtsi:739.22-751.5: Warning (unique_unit_address): /soc/spi@44004000: duplicate unit-address (also used in node /soc/audio-controller@44004000)

 

 

During OPTEE build this is reported. Not sure if the cause SPI2 can't be see on the bus? Whu does this happen, stm32mp151.dts is supposed not to be changed, is this a bug in ECO 5 or DT compiler ? Since I2S2 seems shared with other possible functions  only enabling SPI2 in the dts this error seems to occur .

 

 

i2s2: audio-controller@4000b000 {
			compatible = "st,stm32h7-i2s";
			#sound-dai-cells = <0>;
			reg = <0x4000b000 0x400>;
			interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
			dmas = <&dmamux1 39 0x400 0x01>,
			       <&dmamux1 40 0x400 0x01>;
			dma-names = "rx", "tx";
			status = "disabled";
		};
	spi2: spi@4000b000 {
			#address-cells = <1>;
			#size-cells = <0>;
			compatible = "st,stm32h7-spi";
			reg = <0x4000b000 0x400>;
			interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&rcc SPI2_K>;
			resets = <&rcc SPI2_R>;
			dmas = <&dmamux1 39 0x400 0x05>,
			       <&dmamux1 40 0x400 0x05>;
			dma-names = "rx", "tx";
			status = "disabled";
		};

 

 

 

hmmm....

https://patchwork.kernel.org/project/spi-devel-general/patch/1427499742-26916-1-git-send-email-broonie@kernel.org/

https://yurovsky.github.io/2016/10/07/spidev-linux-devices.html

https://stackoverflow.com/questions/53634892/linux-spidev-why-it-shouldnt-be-directly-in-devicetree

 
Read comment:
I don't think compatible = "linux,spidev"; works for Linux kernel 5.15 onwards since commit 6840615f85f60. At least, I cannot get it to work in v6.0 and this seems the most likely reason.
 

The warning now seems to be enforced as  disabling spidev without a warning  in kernel 6x...

it's is wrong, "you should" know..