2024-08-04 10:52 PM - edited 2024-08-07 08:56 PM
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:
Solved! Go to Solution.
2024-08-08 04:33 AM - edited 2024-08-08 08:22 AM
hmmm....
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
The warning now seems to be enforced as disabling spidev without a warning in kernel 6x...
it's is wrong, "you should" know..
2024-08-05 06:58 AM - edited 2024-08-05 08:08 AM
Anyone ?
2024-08-07 08:48 PM - edited 2024-08-07 08:52 PM
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";
};
2024-08-08 04:33 AM - edited 2024-08-08 08:22 AM
hmmm....
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
The warning now seems to be enforced as disabling spidev without a warning in kernel 6x...
it's is wrong, "you should" know..