Tool/software:
Hi TI's experts,
HW env: our own tda4ven board
SW env:sdk10.0
We need to implement SPI data transmission and reception between the external MCU (RH850) and A53. How can SPI be enabled in kernel?
Regards.
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:
Hi TI's experts,
HW env: our own tda4ven board
SW env:sdk10.0
We need to implement SPI data transmission and reception between the external MCU (RH850) and A53. How can SPI be enabled in kernel?
Regards.
Hi Xie,
I recently helped a developer on a different SoC for enabling SPI in the kernel in this thread: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1436992/tda4vm-q1-j721e
Please reference the patch to configure SPI. The kernel driver changes and compatible field can be the same as the patch in the other E2E thread, but you will need to pinmux the device tree appropriately for your TDA4VEN board.
Regards,
Takuma
Hi Xie,
Please reference this appnote if not already: https://www.ti.com/lit/an/sprad26/sprad26.pdf?ts=1732143558409&ref_url=https%253A%252F%252Fwww.google.com%252F
The section "4 SPI: Slave Mode Enabling and Validation on Linux" goes through both how to set spi mode to slave and enabling DMA.
Regards,
Takuma
Hi Takuma,
There is a strange phenomenon here. I hope you can help answer it.
After I excute "spidev_test -v -D /dev/spidev0.0" on the console.From the data on the logic analyzer, I found that the data from SPI TX appears on MISO, which is not an expected phenomenon. I believe that the data from SOC SPI TX should be on MOSI.
Can you help me check out where the problem is?


Regrads.
Hi Takuma,
I think the spidev0.0 is in master mode.
Can you check if my modifications are correct?

From 6079f7238c5ee17ecb41a95e5235322732d14295 Mon Sep 17 00:00:00 2001
From: zhangweizhen <zhangweizhen@mit.cn>
Date: Wed, 20 Nov 2024 20:00:30 +0800
Subject: [PATCH] =?UTF-8?q?spi:=E4=BD=BF=E8=83=BDspidev=E8=AE=BE=E5=A4=87(?=
=?UTF-8?q?=E5=8D=95=E5=89=8D=E4=BD=BF=E7=94=A8spi2)--20241120?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Change-Id: Ifcd9b7d10ae0ac6298a4c9cfaaa4f2ab167b011d
---
.../arch/arm64/boot/dts/ti/k3-am62p-main.dtsi | 2 +-
.../arch/arm64/boot/dts/ti/k3-j722s-evm.dts | 24 +++++++++++++++++--
.../arch/arm64/configs/defconfig | 4 ++--
.../drivers/spi/spidev.c | 2 ++
4 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti/k3-am62p-main.dtsi b/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti/k3-am62p-main.dtsi
index 48898ed15..fd486776a 100644
--- a/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti/k3-am62p-main.dtsi
+++ b/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti/k3-am62p-main.dtsi
@@ -549,7 +549,7 @@ main_spi2: spi@20120000 {
#size-cells = <0>;
power-domains = <&k3_pds 143 TI_SCI_PD_EXCLUSIVE>;
clocks = <&k3_clks 143 0>;
- status = "disabled";
+ status = "okay";
};
main_gpio_intr: interrupt-controller@a00000 {
diff --git a/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti/k3-j722s-evm.dts b/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti/k3-j722s-evm.dts
index aece85af5..5c044f50e 100644
--- a/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti/k3-j722s-evm.dts
+++ b/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti/k3-j722s-evm.dts
@@ -435,6 +435,15 @@ audio_ext_refclk1_pins_default: audio-ext-refclk1-default-pins {
J722S_IOPAD(0x0a0, PIN_OUTPUT, 1) /* (N24) GPMC0_WPn.AUDIO_EXT_REFCLK1 */
>;
};
+
+ spi2_pins_default: spi2-default-pins {
+ pinctrl-single,pins = <
+ J722S_IOPAD(0x01EC, PIN_INPUT, 3) /* (A22) SPI2_CLK */
+ J722S_IOPAD(0x01AC, PIN_INPUT, 1) /* (C27) SPI2_CS0 */
+ J722S_IOPAD(0x0198, PIN_INPUT, 1) /* (A26) SPI2_D1 */
+ J722S_IOPAD(0x0194, PIN_INPUT, 1) /* (A25) SPI2_D0 */
+ >;
+ };
};
&cpsw3g {
@@ -621,7 +630,7 @@ tlv320aic3106: audio-codec@1b {
};
&main_i2c1 {
- status = "okay";
+ status = "disabled";
pinctrl-names = "default";
pinctrl-0 = <&main_i2c1_pins_default>;
clock-frequency = <100000>;
@@ -734,7 +743,7 @@ pca9543_1: i2c-mux@71 {
&ospi0 {
pinctrl-names = "default";
pinctrl-0 = <&ospi0_pins_default>;
- status = "okay";
+ status = "disabled";
ospi0_nor: flash@0 {
compatible = "jedec,spi-nor";
@@ -1103,3 +1112,14 @@ audio_refclk1: clock@82e4 {
#clock-cells = <0>;
};
};
+
+&main_spi2 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi2_pins_default>;
+ status = "okay";
+ spidev@0 {
+ spi-max-frequency = <24000000>;
+ reg = <0>;
+ compatible = "ti,spi-evm";
+ };
+};
diff --git a/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/configs/defconfig b/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/configs/defconfig
index 7c6e8e9a3..236a0e6c0 100644
--- a/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/configs/defconfig
+++ b/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/arch/arm64/configs/defconfig
@@ -579,7 +579,7 @@ CONFIG_SPI_MESON_SPICC=m
CONFIG_SPI_MESON_SPIFC=m
CONFIG_SPI_MT65XX=y
CONFIG_SPI_MTK_NOR=m
-CONFIG_SPI_OMAP24XX=m
+CONFIG_SPI_OMAP24XX=y
CONFIG_SPI_ORION=y
CONFIG_SPI_PL022=y
CONFIG_SPI_ROCKCHIP=y
@@ -595,7 +595,7 @@ CONFIG_SPI_SH_MSIOF=m
CONFIG_SPI_SUN6I=y
CONFIG_SPI_TEGRA210_QUAD=m
CONFIG_SPI_TEGRA114=m
-CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_SPIDEV=y
CONFIG_SPI_SLAVE=y
CONFIG_SPMI=y
CONFIG_SPMI_MTK_PMIF=m
diff --git a/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/drivers/spi/spidev.c b/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/drivers/spi/spidev.c
index d13dc15cc..e68212263 100644
--- a/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/drivers/spi/spidev.c
+++ b/psdkla/board-support/ti-linux-kernel-6.6.32+git-ti/drivers/spi/spidev.c
@@ -714,6 +714,7 @@ static const struct spi_device_id spidev_spi_ids[] = {
{ .name = "spi-authenta" },
{ .name = "em3581" },
{ .name = "si3210" },
+ { .name = "spi-evm" },
{},
};
MODULE_DEVICE_TABLE(spi, spidev_spi_ids);
@@ -742,6 +743,7 @@ static const struct of_device_id spidev_dt_ids[] = {
{ .compatible = "semtech,sx1301", .data = &spidev_of_check },
{ .compatible = "silabs,em3581", .data = &spidev_of_check },
{ .compatible = "silabs,si3210", .data = &spidev_of_check },
+ { .compatible = "ti,spi-evm", .data = &spidev_of_check },
{},
};
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
--
2.34.1
Regards.
Hi Xie,
I looked through the patch, and it looks to be fine.
Could you try an experiment where you try to enable two SPI interfaces and do communications between the two? Loopback to itself is theoretically possible, but not something that is a practical usecase, so it is not something that is considered in design. The MOSI/MISO without an actual slave device could be what is causing the issue.
Regards,
Takuma
Hi Takuma,
Thanks for support! customer have resolved this issue:
spi*-omap2.c driver code have some register to setting the d0 and d1, customer try to set the d0 as input, and set the d1 as output can fix their issue.
BR,
Biao