I followed this document to configure mcu SPI2 and SPI4, and ran the use case and found that neither party accepted the data
SPI Enablement and Validation on TDA4 Family.pdf
Here is the log that runs
root@j721s2-evm:/home/spi-test# ls -l /sys/class/spi* /sys/class/spi_master: total 0 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi0 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/40320000.spi/spi_master/spi0 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi1 -> ../../devices/platform/bus@100000/2110000.spi/spi_master/spi1 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi2 -> ../../devices/platform/bus@100000/2120000.spi/spi_master/spi2 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi3 -> ../../devices/platform/bus@100000/2130000.spi/spi_master/spi3 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi4 -> ../../devices/platform/bus@100000/2150000.spi/spi_master/spi4 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi5 -> ../../devices/platform/bus@100000/2160000.spi/spi_master/spi5 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi6 -> ../../devices/platform/bus@100000/2170000.spi/spi_master/spi6 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi7 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/47000000.syscon/47040000.spi/spi_master/spi7 /sys/class/spi_slave: total 0 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi8 -> ../../devices/platform/bus@100000/2100000.spi/spi_slave/spi8 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spi9 -> ../../devices/platform/bus@100000/2140000.spi/spi_slave/spi9 /sys/class/spidev: total 0 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spidev0.0 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/40320000.spi/spi_master/spi0/spi0.0/spidev/spidev0.0 lrwxrwxrwx 1 root root 0 Dec 16 07:58 spidev9.0 -> ../../devices/platform/bus@100000/2140000.spi/spi_slave/spi9/spi9.0/spidev/spidev9.0 root@j721s2-evm:/home/spi-test# ./spidev_test -v -D /dev/spidev9.0 -p slave-hello-to-master & [1] 1201 spi mode: 0x0[ 4339.144088] [slave][byd:omap2_mcspi_transfer_one:1091] pos bits per word: 8 max speed: 500000 Hz (500 kHz) [ 4339.150710] [slave][byd:omap2_mcspi_txrx_pio:654] pos word_len=8 root@j721s2-evm:/home/spi-test# [ 4340.161299] spidev spi9.0: RXS timed out TX | 73 6C 61 76 65 2D 68 65 6C 6C 6F 2D 74 6F 2D 6D 61 73 74 65 72 __ __ __ __ __ __ __ __ __ __ __ |slave-hello-to-master| RX | 2F 73 79 73 74 65 6D 2E 73 6C 69 63 65 2F 73 79 73 74 65 6D 64 __ __ __ __ __ __ __ __ __ __ __ |/system.slice/systemd| root@j721s2-evm:/home/spi-test# ./spidev_test -v -D /dev/spidev0.0 -p master-hello-to-slave spi mode: 0x0[ 4349.375580] [master][byd:omap2_mcspi_transfer_one:1091] pos bits per word: 8 max speed: 500000 Hz (500 kHz) [ 4349.382259] [master][byd:omap2_mcspi_txrx_pio:654] pos word_len=8 TX | 6D 61 73 74 65 72 2D 68 65 6C 6C 6F 2D 74 6F 2D 73 6C 61 76 65 __ __ __ __ __ __ __ __ __ __ __ |master-hello-to-slave| RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ |.....................| [1]+ Done ./spidev_test -v -D /dev/spidev9.0 -p slave-hello-to-master root@j721s2-evm:/home/spi-test#
Here are the code modifications
diff --git a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2-common-proc-board.dts b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2-common-proc-board.dts index 5d57dc2b1..9785847cb 100644 --- a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2-common-proc-board.dts +++ b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2-common-proc-board.dts +&main_spi4 { + status="okay"; + spi-slave; + slave@0 { + spi-max-frequency = <24000000>; + reg = <0>; + compatible = "linux,spidev"; + }; +}; + +&mcu_spi2 { + status="okay"; + spidev@0 { + spi-max-frequency = <24000000>; + reg = <0>; + compatible = "linux,spidev"; + }; +}; diff --git a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2-main.dtsi b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2-main.dtsi index c566dec93..01e9649a3 100644 --- a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2-main.dtsi +++ b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2-main.dtsi main_spi1: spi@2110000 { @@ -1385,6 +1387,8 @@ main_spi4: spi@2140000 { #size-cells = <0>; clocks = <&k3_clks 343 1>; power-domains = <&k3_pds 343 TI_SCI_PD_EXCLUSIVE>; + dmas = <&main_udmap 0xc618>, <&main_udmap 0x4618>; + dma-names = "tx0", "rx0"; }; main_spi5: spi@2150000 { diff --git a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2.dtsi b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2.dtsi index 75bc8dfac..25dab477a 100644 --- a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2.dtsi +++ b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/boot/dts/ti/k3-j721s2.dtsi @@ -145,6 +145,7 @@ cbass_mcu_wakeup: bus@28380000 { #size-cells = <2>; ranges = <0x00 0x28380000 0x00 0x28380000 0x00 0x03880000>, /* MCU NAVSS*/ <0x00 0x40200000 0x00 0x40200000 0x00 0x00998400>, /* First peripheral window */ + <0x00 0x40320000 0x00 0x40320000 0x00 0x00000400>, /* MCU SPI2 */ <0x00 0x40f00000 0x00 0x40f00000 0x00 0x00020000>, /* CTRL_MMR0 */ <0x00 0x41000000 0x00 0x41000000 0x00 0x00020000>, /* MCU R5F Core0 */ <0x00 0x41400000 0x00 0x41400000 0x00 0x00020000>, /* MCU R5F Core1 */ diff --git a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/configs/tisdk_j721s2-evm_defconfig b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/configs/tisdk_j721s2-evm_defconfig index a68a36227..e992df20a 100644 --- a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/configs/tisdk_j721s2-evm_defconfig +++ b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/arch/arm64/configs/tisdk_j721s2-evm_defconfig @@ -3110,9 +3110,11 @@ CONFIG_SPI_PL022=y # SPI Protocol Masters # # CONFIG_SPI_SPIDEV is not set +CONFIG_SPI_SPIDEV=y # CONFIG_SPI_LOOPBACK_TEST is not set # CONFIG_SPI_TLE62X0 is not set # CONFIG_SPI_SLAVE is not set +CONFIG_SPI_SLAVE=y CONFIG_SPI_DYNAMIC=y CONFIG_SPMI=y # CONFIG_HSI is not set diff --git a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/drivers/dma/ti/k3-psil-j721s2.c b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/drivers/dma/ti/k3-psil-j721s2.c index 6fd6c203f..2bca38749 100644 --- a/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/drivers/dma/ti/k3-psil-j721s2.c +++ b/board-support/linux-5.10.153+gitAUTOINC+90c3a58fd2-g90c3a58fd2/drivers/dma/ti/k3-psil-j721s2.c @@ -78,14 +78,17 @@ static struct psil_ep j721s2_src_ep_map[] = { PSIL_PDMA_XY_PKT(0x4601), PSIL_PDMA_XY_PKT(0x4602), PSIL_PDMA_XY_PKT(0x4603), + PSIL_PDMA_XY_PKT(0x4604), PSIL_PDMA_XY_PKT(0x4605), PSIL_PDMA_XY_PKT(0x4606), PSIL_PDMA_XY_PKT(0x4607), + PSIL_PDMA_XY_PKT(0x4608), PSIL_PDMA_XY_PKT(0x4609), PSIL_PDMA_XY_PKT(0x460a), PSIL_PDMA_XY_PKT(0x460b), + PSIL_PDMA_XY_PKT(0x460c), PSIL_PDMA_XY_PKT(0x460d), PSIL_PDMA_XY_PKT(0x460e), @@ -248,6 +251,16 @@ static struct psil_ep j721s2_dst_ep_map[] = { /* SA2UL */ PSIL_SA2UL(0xf500, 1), PSIL_SA2UL(0xf501, 1), + /* PDMA10 (PDMA_MISC_G2) - SPI4 */ + PSIL_PDMA_XY_PKT(0xc618), + PSIL_PDMA_XY_PKT(0xc619), + PSIL_PDMA_XY_PKT(0xc61a), + PSIL_PDMA_XY_PKT(0xc61b), }; struct psil_ep_map j721s2_ep_map = {
I think DMA didn't work, because when configuring DMA, it was configured with reference to k3-psil-j721e.c, I don't know how PSIL_PDMA_XY_PKT is matched, can you tell me, thanks