hi TI
I have the following questions on TDA4VM SPI:
- How to enable SPI instances of TDA4VM?
- How to enable SPIDEV on TD4VM SDK?
I want to usb spi0 and spi1 in the driver of SPI_DEV in linux
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.
hi TI
I have the following questions on TDA4VM SPI:
I want to usb spi0 and spi1 in the driver of SPI_DEV in linux
Hi,
Please refer the application note: https://www.ti.com/lit/pdf/sprad26?keyMatch=DRA821
Regards,
Keerthy
this is I add the code:
Index: ti/k3-j721e-common-proc-board.dts
===================================================================
--- ti/k3-j721e-common-proc-board.dts (revision 3142)
+++ ti/k3-j721e-common-proc-board.dts (working copy)
@@ -240,6 +240,26 @@
>;
};
+ main_spi0_pins_default: main_spi0_pins_default {
+ pinctrl-single,pins = <
+ J721E_IOPAD(0x1c8, PIN_INPUT, 0) /* (AA1) SPI0_CLK */
+ J721E_IOPAD(0x1c0, PIN_INPUT, 0) /* (AA2) SPI0_CS0 */
+ J721E_IOPAD(0x1cc, PIN_INPUT, 0) /* (AB5) SPI0_D0 */
+ J721E_IOPAD(0x1d0, PIN_INPUT, 0) /* (AA3) SPI0_D1 */
+ J721E_IOPAD(0x264, PIN_INPUT, 7) /* (T29) MMC2_DAT2.GPIO1_24 */
+ >;
+ };
+
+ main_spi1_pins_default: main_spi1_pins_default {
+ pinctrl-single,pins = <
+ J721E_IOPAD(0x1dc, PIN_INPUT, 0) /* (Y1) SPI1_CLK */
+ J721E_IOPAD(0x1d4, PIN_INPUT, 0) /* (Y3) SPI1_CS0 */
+ J721E_IOPAD(0x1e0, PIN_INPUT, 0) /* (Y5) SPI1_D0 */
+ J721E_IOPAD(0x1e4, PIN_INPUT, 0) /* (Y2) SPI1_D1 */
+ J721E_IOPAD(0xb0, PIN_INPUT, 7) /* (AF28) PRG0_PRU0_GPO0.GPIO0_43 */
+ >;
+ };
+
@@ -1202,6 +1223,33 @@
status = "disabled";
};
+&main_spi0 {
+ status="okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&main_spi0_pins_default>;
+ spi-slave;
+ slave@0 {
+ spi-max-frequency = <10000000>;
+ reg = <0>;
+ compatible = "linux,spidev";
+ };
+};
+
&serdes_wiz4 {
status = "disabled";
};
Index: ti/k3-j721e-main.dtsi
===================================================================
--- ti/k3-j721e-main.dtsi (revision 3142)
+++ ti/k3-j721e-main.dtsi (working copy)
@@ -1339,7 +1339,43 @@
clocks = <&k3_clks 193 0>;
power-domains = <&k3_pds 193 TI_SCI_PD_EXCLUSIVE>;
};
-
+
+ main_spi0: spi@2100000 {
+ compatible = "ti,am654-mcspi", "ti,omap4-mcspi";
+ reg = <0x0 0x2100000 0x0 0x400>;
+ interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clocks = <&k3_clks 266 0>;
+ power-domains = <&k3_pds 266 TI_SCI_PD_EXCLUSIVE>;
+ dmas = <&main_udmap 0xc600>, <&main_udmap 0xc600>;
+ dma-names = "tx0", "rx0";
+ };
d5520: video-decoder@4300000 {
/* IMG D5520 driver configuration */
compatible = "img,d5500-vxd";
@@ -1348,6 +1384,8 @@
interrupts = <GIC_SPI 180 IRQ_TYPE_LEVEL_HIGH>;
};
There are two warnings:
arch/arm64/boot/dts/ti/k3-j721e-main.dtsi:1343.25-1353.4: Warning (spi_bus_bridge): /bus@100000/spi@2100000: incorrect #address-cells for SPI bus
arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dtb: Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge'
Hi Zhao,
Some of the PSIL thread numbers for SPI0/1 are missing:
So please add below change:
diff --git a/drivers/dma/ti/k3-psil-j721e.c b/drivers/dma/ti/k3-psil-j721e.c index 34e3fc565..169d29f63 100644 --- a/drivers/dma/ti/k3-psil-j721e.c +++ b/drivers/dma/ti/k3-psil-j721e.c @@ -266,6 +266,15 @@ static struct psil_ep j721e_dst_ep_map[] = { PSIL_ETHERNET(0xc205), PSIL_ETHERNET(0xc206), PSIL_ETHERNET(0xc207), + /* PDMA8 (PDMA_MISC_G0) - SPI0-1 */ + PSIL_PDMA_XY_PKT(0xc600), + PSIL_PDMA_XY_PKT(0xc601), + PSIL_PDMA_XY_PKT(0xc602), + PSIL_PDMA_XY_PKT(0xc603), + PSIL_PDMA_XY_PKT(0xc604), + PSIL_PDMA_XY_PKT(0xc605), + PSIL_PDMA_XY_PKT(0xc606), + PSIL_PDMA_XY_PKT(0xc607), /* CPSW9 */ PSIL_ETHERNET(0xca00), PSIL_ETHERNET(0xca01),
Also main_spi0 node should be as below:
+ main_spi0: spi@2100000 {
+ compatible = "ti,am654-mcspi", "ti,omap4-mcspi";
+ reg = <0x0 0x2100000 0x0 0x400>;
+ interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clocks = <&k3_clks 266 0>;
+ power-domains = <&k3_pds 266 TI_SCI_PD_EXCLUSIVE>;
+ dmas = <&main_udmap 0xc600>, <&main_udmap 0x4600>;
+ dma-names = "tx0", "rx0";
+ };
And dmas properties for main_spi1 will be
+ dmas = <&main_udmap 0xc604>, <&main_udmap 0x4604>;
+ dma-names = "tx0", "rx0";
Best Regards,
Keerthy
My modifications are the same as yours, but transfer failed in tx and rx.
I also test zhe spi4 and mcu spi2,but transfer failed.
root@j7-evm:~# ls -l /sys/class/spi*
/sys/class/spi_master:
total 0
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spi2 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/40320000.mcu-spi2/spi_master/spi2
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spi3 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/47000000.fss/47040000.spi/spi_master/spi3
/sys/class/spi_slave:
total 0
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spi0 -> ../../devices/platform/bus@100000/2100000.spi/spi_slave/spi0
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spi1 -> ../../devices/platform/bus@100000/2110000.spi/spi_slave/spi1
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spi4 -> ../../devices/platform/bus@100000/2140000.spi/spi_slave/spi4
/sys/class/spidev:
total 0
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spidev0.0 -> ../../devices/platform/bus@100000/2100000.spi/spi_slave/spi0/spi0.0/spidev/spidev0.0
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spidev1.0 -> ../../devices/platform/bus@100000/2110000.spi/spi_slave/spi1/spi1.0/spidev/spidev1.0
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spidev2.0 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/40320000.mcu-spi2/spi_master/spi2/spi2.0/spidev/spidev2.0
lrwxrwxrwx 1 root root 0 Apr 10 00:05 spidev4.0 -> ../../devices/platform/bus@100000/2140000.spi/spi_slave/spi4/spi4.0/spidev/spidev4.0
root@j7-evm:/home# echo spidev > /sys/class/spi_slave/spi4/slave
root@j7-evm:/home# ./spidev_test -v -D /dev/spidev4.0 -p slave-hello-to-master &
[1] 1323
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
root@j7-evm:/home#
root@j7-evm:/home# ./spidev_test -v -D /dev/spidev2.0 -p master-hello-to-slave
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
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 __ __ __ __ __ __ __ __ __ __ __ |.....................|
Index: board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts
===================================================================
--- board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts (revision 3150)
+++ board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts (working copy)
@@ -240,6 +240,26 @@
>;
};
+ main_spi0_pins_default: main_spi0_pins_default {
+ pinctrl-single,pins = <
+ J721E_IOPAD(0x1c8, PIN_INPUT, 0) /* (AA1) SPI0_CLK */
+ J721E_IOPAD(0x1c0, PIN_INPUT, 0) /* (AA2) SPI0_CS0 */
+ J721E_IOPAD(0x1cc, PIN_INPUT, 0) /* (AB5) SPI0_D0 */
+ J721E_IOPAD(0x1d0, PIN_INPUT, 0) /* (AA3) SPI0_D1 */
+ J721E_IOPAD(0x264, PIN_INPUT, 7) /* (T29) MMC2_DAT2.GPIO1_24 */
+ >;
+ };
+
+ main_spi1_pins_default: main_spi1_pins_default {
+ pinctrl-single,pins = <
+ J721E_IOPAD(0x1dc, PIN_INPUT, 0) /* (Y1) SPI1_CLK */
+ J721E_IOPAD(0x1d4, PIN_INPUT, 0) /* (Y3) SPI1_CS0 */
+ J721E_IOPAD(0x1e0, PIN_INPUT, 0) /* (Y5) SPI1_D0 */
+ J721E_IOPAD(0x1e4, PIN_INPUT, 0) /* (Y2) SPI1_D1 */
+ J721E_IOPAD(0xb0, PIN_INPUT, 7) /* (AF28) PRG0_PRU0_GPO0.GPIO0_43 */
+ >;
+ };
+
mcasp10_pins_default: mcasp10_pins_default {
pinctrl-single,pins = <
J721E_IOPAD(0x158, PIN_OUTPUT_PULLDOWN, 12) /* (U23) RGMII5_TX_CTL.MCASP10_ACLKX */
@@ -271,6 +291,7 @@
J721E_IOPAD(0x240, PIN_INPUT, 0) /* (R26) MMC1_DAT3 */
J721E_IOPAD(0x258, PIN_INPUT, 0) /* (P23) MMC1_SDCD */
J721E_IOPAD(0x25c, PIN_INPUT, 0) /* (R28) MMC1_SDWP */
>;
};
@@ -1202,6 +1223,60 @@
status = "disabled";
};
+&main_spi0 {
+ status="okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&main_spi0_pins_default>;
+ spi-slave;
+ slave@0 {
+ spi-max-frequency = <10000000>;
+ reg = <0>;
+ compatible = "linux,spidev";
+
+ request_pin {
+ request-gpio = <&main_gpio1 24 GPIO_ACTIVE_LOW>;
+ active_time = <1>; /* ms */
+ };
+ };
+};
+
+&main_spi1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&main_spi1_pins_default>;
+ status="okay";
+
+ spi-slave;
+
+ slave@0 {
+ spi-max-frequency = <10000000>;
+ reg = <0>;
+ compatible = "linux,spidev";
+ request_pin {
+ request-gpio = <&main_gpio0 43 GPIO_ACTIVE_LOW>;
+ active_time = <1>; /* ms */
+ };
+ };
+};
+
+&mcu_spi2 {
+ status="okay";
+ spidev@0 {
+ spi-max-frequency = <10000000>;
+ reg = <0>;
+ compatible = "linux,spidev";
+ };
+};
+
+&main_spi4 {
+ status="okay";
+ spi-slave;
+ slave@0 {
+ spi-max-frequency = <10000000>;
+ reg = <0>;
+ compatible = "linux,spidev";
+ };
+};
+
&serdes_wiz4 {
status = "disabled";
};
Index: board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
===================================================================
--- board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi (revision 3150)
+++ board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi (working copy)
@@ -1339,7 +1339,43 @@
clocks = <&k3_clks 193 0>;
power-domains = <&k3_pds 193 TI_SCI_PD_EXCLUSIVE>;
};
+
+ main_spi0: spi@2100000 {
+ compatible = "ti,am654-mcspi", "ti,omap4-mcspi";
+ reg = <0x0 0x2100000 0x0 0x400>;
+ interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clocks = <&k3_clks 266 0>;
+ power-domains = <&k3_pds 266 TI_SCI_PD_EXCLUSIVE>;
+ dmas = <&main_udmap 0xc600>, <&main_udmap 0x4600>;
+ dma-names = "tx0", "rx0";
+ };
+
+ main_spi1: spi@2110000 {
+ compatible = "ti,am654-mcspi", "ti,omap4-mcspi";
+ reg = <0x0 0x2110000 0x0 0x400>;
+ interrupts = <GIC_SPI 185 IRQ_TYPE_LEVEL_HIGH>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clocks = <&k3_clks 267 0>;
+ power-domains = <&k3_pds 267 TI_SCI_PD_EXCLUSIVE>;
+ dmas = <&main_udmap 0xc604>, <&main_udmap 0x4604>;
+ dma-names = "tx0", "rx0";
+ };
+ main_spi4: spi@2140000 {
+ compatible = "ti,am654-mcspi","ti,omap4-mcspi";
+ reg = <0x0 0x2140000 0x0 0x400>;
+ interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&k3_clks 270 1>;
+ power-domains = <&k3_pds 270 TI_SCI_PD_EXCLUSIVE>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ dmas = <&main_udmap 0xc618>, <&main_udmap 0x4618>;
+ dma-names = "tx0", "rx0";
+ };
+
d5520: video-decoder@4300000 {
/* IMG D5520 driver configuration */
compatible = "img,d5500-vxd";
Index: board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi
===================================================================
--- board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi (revision 3150)
+++ board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi (working copy)
@@ -69,7 +69,15 @@
#address-cells = <1>;
#size-cells = <1>;
};
-
+ mcu_spi2: mcu-spi2@40320000 {
+ compatible = "ti,am654-mcspi","ti,omap4-mcspi";
+ reg = <0x0 0x40320000 0x0 0x400>;
+ interrupts = <GIC_SPI 850 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&k3_clks 276 1>;
+ power-domains = <&k3_pds 276 TI_SCI_PD_EXCLUSIVE>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
wkup_uart0: serial@42300000 {
compatible = "ti,j721e-uart", "ti,am654-uart";
reg = <0x00 0x42300000 0x00 0x100>;
Index: board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e.dtsi
===================================================================
--- board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e.dtsi (revision 3150)
+++ board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/boot/dts/ti/k3-j721e.dtsi (working copy)
@@ -40,6 +40,8 @@
rproc6 = &c66_0;
rproc7 = &c66_1;
rproc8 = &c71_0;
+ spi0 = &main_spi0;
+ spi1 = &main_spi1;
};
chosen { };
@@ -179,6 +181,7 @@
<0x00 0x41c00000 0x00 0x41c00000 0x00 0x00100000>, /* MCU SRAM */
<0x00 0x42040000 0x00 0x42040000 0x00 0x03ac2400>, /* WKUP peripheral window */
<0x00 0x45100000 0x00 0x45100000 0x00 0x00c24000>, /* MMRs, remaining NAVSS */
+ <0x00 0x40320000 0x00 0x40320000 0x00 0x00000400>, /* MCU SPI2 */
<0x00 0x46000000 0x00 0x46000000 0x00 0x00200000>, /* CPSW */
<0x00 0x47000000 0x00 0x47000000 0x00 0x00068400>, /* OSPI register space */
<0x00 0x50000000 0x00 0x50000000 0x00 0x10000000>, /* FSS OSPI0/1 data region 0 */
Index: board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/configs/tisdk_j7-evm_defconfig
===================================================================
--- board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/configs/tisdk_j7-evm_defconfig (revision 3150)
+++ board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/arch/arm64/configs/tisdk_j7-evm_defconfig (working copy)
@@ -2854,10 +2854,10 @@
#
# 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
Index: board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/drivers/dma/ti/k3-psil-j721e.c
===================================================================
--- board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/drivers/dma/ti/k3-psil-j721e.c (revision 3150)
+++ board-support/linux-5.4.106+gitAUTOINC+023faefa70-g023faefa70/drivers/dma/ti/k3-psil-j721e.c (working copy)
@@ -131,8 +131,8 @@
PSIL_PDMA_XY_PKT(0x4627),
PSIL_PDMA_XY_PKT(0x4628),
PSIL_PDMA_XY_PKT(0x4629),
/* PDMA13 (PDMA_USART_G0) - UART0-1 */
PSIL_PDMA_XY_PKT(0x4700),
PSIL_PDMA_XY_PKT(0x4701),
@@ -224,6 +224,45 @@
/* SA2UL */
PSIL_SA2UL(0xf500, 1),
PSIL_SA2UL(0xf501, 1),
+
+ /* PDMA_SPI_G0 - SPI1 */
+ PSIL_PDMA_XY_PKT(0xc600),
+ PSIL_PDMA_XY_PKT(0xc601),
+ PSIL_PDMA_XY_PKT(0xc602),
+ PSIL_PDMA_XY_PKT(0xc603),
+ PSIL_PDMA_XY_PKT(0xc604),
+ PSIL_PDMA_XY_PKT(0xc605),
+ PSIL_PDMA_XY_PKT(0xc606),
+ PSIL_PDMA_XY_PKT(0xc607),
+ /* PDMA_SPI_G2 - SPI3 */
+ PSIL_PDMA_XY_PKT(0xc60c),
+ PSIL_PDMA_XY_PKT(0xc60d),
+ PSIL_PDMA_XY_PKT(0xc60e),
+ PSIL_PDMA_XY_PKT(0xc60f),
+ PSIL_PDMA_XY_PKT(0xc610),
+ PSIL_PDMA_XY_PKT(0xc611),
+ PSIL_PDMA_XY_PKT(0xc612),
+ PSIL_PDMA_XY_PKT(0xc613),
+
+ /* PDMA_SPI_G4 - SPI5 */
+ PSIL_PDMA_XY_PKT(0xc618),
+ PSIL_PDMA_XY_PKT(0xc619),
+ PSIL_PDMA_XY_PKT(0xc61a),
+ PSIL_PDMA_XY_PKT(0xc61b),
+ PSIL_PDMA_XY_PKT(0xc61c),
+ PSIL_PDMA_XY_PKT(0xc61d),
+ PSIL_PDMA_XY_PKT(0xc61e),
+ PSIL_PDMA_XY_PKT(0xc61f),
+
+ /* PDMA_SPI_G6 - SPI7 */
+ PSIL_PDMA_XY_PKT(0xc624),
+ PSIL_PDMA_XY_PKT(0xc625),
+ PSIL_PDMA_XY_PKT(0xc626),
+ PSIL_PDMA_XY_PKT(0xc627),
+ PSIL_PDMA_XY_PKT(0xc628),
+ PSIL_PDMA_XY_PKT(0xc629),
+ PSIL_PDMA_XY_PKT(0xc62a),
+ PSIL_PDMA_XY_PKT(0xc62b),
};
struct psil_ep_map j721e_ep_map = {
Hi,
I do not see the pin muxing for the MAIN_SPI4 & MCU_SPI2. Please copy them from the application note shared.
- Keerthy