Tool/software: Code Composer Studio
I have the following questions on TDA4VM SPI:
- How to enable SPI instances of TDA4VM?
- How to enable SPIDEV on TD4VM SDK?
- How to exercise from user space the TI J7/TDA4x SPI interface?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
I have the following questions on TDA4VM SPI:
Please find the answers in order:
1) How to enable SPI instances of TDA4VM?
For example lets us take main domain spi6 instance. To enable spi6 we need to add the device tree node & the corresponding pinmux node.
diff --git a/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts b/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts index 6788a3611..77b845354 100644 --- a/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts +++ b/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts @@ -170,6 +170,18 @@ >; }; + spi6_pins_default: spi6_pins_default { + pinctrl-single,pins = < + J721E_IOPAD(0x9c, PIN_INPUT, 4) /* (AC22) PRG1_PRU1_GPO17.SPI6_CLK */ + J721E_IOPAD(0x74, PIN_INPUT, 4) /* (AC21) PRG1_PRU1_GPO7.SPI6_CS0 */ + J721E_IOPAD(0x28, PIN_INPUT, 4) /* (AG20) PRG1_PRU0_GPO9.SPI6_CS1 */ + J721E_IOPAD(0x2c, PIN_INPUT, 4) /* (AD21) PRG1_PRU0_GPO10.SPI6_CS2 */ + J721E_IOPAD(0x7c, PIN_INPUT, 4) /* (AF21) PRG1_PRU1_GPO9.SPI6_CS3 */ + J721E_IOPAD(0xa0, PIN_INPUT, 4) /* (AJ22) PRG1_PRU1_GPO18.SPI6_D0 */ + J721E_IOPAD(0xa4, PIN_INPUT, 4) /* (AH22) PRG1_PRU1_GPO19.SPI6_D1 */ + >; + }; + diff --git a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi index c036df124..edc42720f 100644 --- a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi +++ b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi @@ -74,6 +74,16 @@ }; }; + main_spi6: spi@2160000 { + compatible = "ti,am654-mcspi","ti,omap4-mcspi"; + reg = <0x0 0x2160000 0x0 0x400>; + interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&k3_clks 272 1>; + power-domains = <&k3_pds 272 TI_SCI_PD_EXCLUSIVE>; + #address-cells = <1>; + #size-cells = <0>; + }; +
CONFIG_SPI_OMAP24XX=y is already set in arch/arm64/configs/tisdk_j7-evm_defconfig. The SPI master driver is
drivers/spi/spi-omap2-mcspi.c
2) How to enable SPIDEV on TD4VM SDK?
Add a spidev node inside the spi6 node like below:
+&main_spi6 { + pinctrl-names = "default"; + pinctrl-0 = <&spi6_pins_default>; + status="okay"; + + spidev@0 { + + spi-max-frequency = <24000000>; + reg = <0>; + compatible = "linux,spidev"; +}; +};
Enable CONFIG_SPI_SPIDEV=y explicitly in arch/arm64/configs/tisdk_j7-evm_defconfig.
Once you boot Linux one should entries like below:
ls -l /sys/class/spi* /sys/class/spi_master: total 0 lrwxrwxrwx 1 root root 0 Jun 17 14:17 spi6 -> ../../devices/platform/interconnect@100000/2160000.spi/spi_master/spi6 /sys/class/spidev: total 0 lrwxrwxrwx 1 root root 0 Jun 17 14:17 spidev6.0 -> ../../devices/platform/interconnect@100000/2160000.spi/spi_master/spi6/spi6.0/spidev/spidev6.0
3. How to exercise from user space the TI J7/TDA4x SPI interface?
The Linux kernel provides spidev_test tool. We need just build & use that. Follow the instructions here:
cd ti-processor-sdk-linux-automotive-j7-evm-07_00_01/board-support/linux-5.4.40+gitAUTOINC+66cf445b76-g66cf445b76/tools/spi make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- cp spidev_test /media/$user/rootfs
The above should build spidev_test binary in the tools/spi folder and copy that to rootfs of your target filesystem.
Basic test output:
/spidev_test -v -D /dev/spidev6.0 spi mode: 0x0 bits per word: 8 max speed: 500000 Hz (500 KHz) TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D |......@.........................| RX | FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF |................................|
We can use our own TX and check if TX line is transmitting custom TX bytes using:
/spidev_test -v -D /dev/spidev6.0 -p "HELLOWORLD" spi mode: 0x0 bits per word: 8 max speed: 500000 Hz (500 KHz) TX | 48 45 4C 4C 4F 57 4F 52 4C 44 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |HELLOWORLD| RX | FF FF FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |..........|
Since there is no Slave the RX we always see 0xFF.
Please find the patch attached here:0001-arm64-dts-ti-k3-j721e-common-proc-board-Enable-spi6-.patch
spidev_test binary attached here: spidev_test
Best Regards,
Keerthy