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.

[参考译文] SK-AM68:40引脚接头 SPI 从器件的正确引脚配置

Guru**** 2455360 points
Other Parts Discussed in Thread: AM68, SYSCONFIG

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1439057/sk-am68-correct-pin-configuration-for-40-pin-header-spi-slave

器件型号:SK-AM68
主题中讨论的其他器件:AM68SysConfig

工具与软件:

您好!

我目前正在尝试将 am68配置为 SPI 从器件、通过基础板的40引脚接头接收来自外部主器件的信号。 我目前的问题是、当我使用 ioctl 尝试从 spidev0.0读取时、它在函数调用中挂起、我怀疑这是因为没有接收到时钟信号。 我主要想知道我的引脚配置或 DMA 配置是否错误。 以下是我到目前为止采取的步骤:

1) 1)启用40引脚接头-我手动将 k3-am68-sk-rpi-hdr-ehrpwm.dtbo 添加到 meta-ti 中 am68-sk.conf 文件中的 kernel_DEVICETREE 字符串中。

2) 2)创建一个 MCU_SPI1器件(这是 PROC125E2原理图中列出的连接到40引脚接头的 SPI 连接)、从现有 RPI 接头条目中删除引脚配置、并使用正确的引脚多路复用器为 MCU_SPI1创建一个新的引脚配置。

3) 3)添加从此链接找到的相应 DMA 条目: https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j721s2/psil_cfg.html

   我在 k3-psil-j721s2.c 文件中发现 Rx 条目应该是0x7200、因此我确定了相应的 Tx 条目应该是0xf200。

请注意、我已将 CONFIG_SPI_SLAVE=y、CONFIG_SPI_SPIDEV=y 和 CONFIG_SPI_OMAP24xx=y 添加到我的 KCONFIG 中、以防缺少一些内容。

下面是所有相关的修补程序,如果它有点长,道歉

1.

diff --git a/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi
index 3131e7b..4c7a7d5 100644
--- a/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi
@@ -433,6 +433,8 @@
 		interrupts = <GIC_SPI 849 IRQ_TYPE_LEVEL_HIGH>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+		dmas = <&mcu_udmap 0xf200>, <&mcu_udmap 0x7200>;
+		dma-names = "tx0", "rx0";
 		power-domains = <&k3_pds 348 TI_SCI_PD_EXCLUSIVE>;
 		clocks = <&k3_clks 348 2>;
 		status = "disabled";

2.

diff --git a/arch/arm64/boot/dts/ti/k3-am68-sk-base-board.dts b/arch/arm64/boot/dts/ti/k3-am68-sk-base-board.dts
index 32aea58..7a8ca0d 100644
--- a/arch/arm64/boot/dts/ti/k3-am68-sk-base-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-am68-sk-base-board.dts
@@ -31,6 +31,7 @@
 		can1 = &mcu_mcan1;
 		can2 = &main_mcan6;
 		can3 = &main_mcan7;
+		spi0 = &mcu_spi1;
 		ethernet0 = &cpsw_port1;
 	};
 
@@ -394,16 +395,26 @@
 	mcu_rpi_header_gpio0_pins0_default: mcu-rpi-header-gpio0-default-pins-0 {
 		pinctrl-single,pins = <
 			J721S2_WKUP_IOPAD(0x118, PIN_INPUT, 7) /* (G25) WKUP_GPIO0_66 */
-			J721S2_WKUP_IOPAD(0x05C, PIN_INPUT, 7) /* (E24) MCU_SPI1_D0.WKUP_GPIO0_1 */
-			J721S2_WKUP_IOPAD(0x060, PIN_INPUT, 7) /* (C28) MCU_SPI1_D1.WKUP_GPIO0_2 */
-			J721S2_WKUP_IOPAD(0x058, PIN_INPUT, 7) /* (D26) MCU_SPI1_CLK.WKUP_GPIO0_0 */
+			/* J721S2_WKUP_IOPAD(0x05C, PIN_INPUT, 0) /* (E24) MCU_SPI1_D0.WKUP_GPIO0_1 */
+			/* J721S2_WKUP_IOPAD(0x060, PIN_INPUT, 0) /* (C28) MCU_SPI1_D1.WKUP_GPIO0_2 */
+			/* J721S2_WKUP_IOPAD(0x058, PIN_INPUT, 0) /* (D26) MCU_SPI1_CLK.WKUP_GPIO0_0 */
 			J721S2_WKUP_IOPAD(0x094, PIN_INPUT, 7) /* (D25) MCU_SPI1_CS2.WKUP_GPIO0_15*/
 			J721S2_WKUP_IOPAD(0x0B8, PIN_INPUT, 7) /* (G27) WKUP_GPIO0_56 */
 			J721S2_WKUP_IOPAD(0x114, PIN_INPUT, 7) /* (J26) WKUP_GPIO0_57 */
 			J721S2_WKUP_IOPAD(0x11C, PIN_INPUT, 7) /* (J27) WKUP_GPIO0_67 */
-			J721S2_WKUP_IOPAD(0x064, PIN_INPUT, 7) /* (C27) MCU_SPI1_CS0.WKUP_GPIO0_3 */
+			/* J721S2_WKUP_IOPAD(0x064, PIN_INPUT, 0) /* (C27) MCU_SPI1_CS0.WKUP_GPIO0_3 */
 		>;
 	};
+
+	mcu_spi1_pins_default: mcu-spi1-default-pins {
+		pinctrl-single,pins = <
+			J721S2_IOPAD(0x05c, PIN_INPUT_PULLUP, 0) /* (E24) MCU_SPI1_D0 */
+			J721S2_IOPAD(0x060, PIN_INPUT_PULLUP, 0) /* (C28) MCU_SPI1_D1 */
+			J721S2_IOPAD(0x064, PIN_INPUT_PULLUP, 0) /* (C27) MCU_SPI1_CS0 */
+			J721S2_IOPAD(0x058, PIN_INPUT, 0) /* (D26) MCU_SPI1_CLK */
+		>;
+	};
+
 };
 
 &wkup_pmx3 {
@@ -508,6 +519,23 @@
 	};
 };
 
+&mcu_spi1 {
+
+
+
+	
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&mcu_spi1_pins_default>;
+	spi-slave;
+	slave@0 {
+
+		reg = <0>;
+		spi-max-frequency = <24000000>;
+		compatible = "rohm,dh2228fv";
+	};
+};
+

3.

diff --git a/arch/arm64/boot/dts/ti/k3-j721s2.dtsi b/arch/arm64/boot/dts/ti/k3-j721s2.dtsi
index 6b36f5d..bc112e4 100644
--- a/arch/arm64/boot/dts/ti/k3-j721s2.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j721s2.dtsi
@@ -152,6 +152,7 @@
 			ranges = <0x00 0x28380000 0x00 0x28380000 0x00 0x03880000>, /* MCU NAVSS*/
 				 <0x00 0x40200000 0x00 0x40200000 0x00 0x00998400>, /* First peripheral window */
 				 <0x00 0x40f00000 0x00 0x40f00000 0x00 0x00020000>, /* CTRL_MMR0 */
+				 <0x00 0x40310000 0x00 0x40310000 0x00 0x00000400>, /* MCU SPI1 */
 				 <0x00 0x41000000 0x00 0x41000000 0x00 0x00020000>, /* MCU R5F Core0 */
 				 <0x00 0x41400000 0x00 0x41400000 0x00 0x00020000>, /* MCU R5F Core1 */
 				 <0x00 0x41c00000 0x00 0x41c00000 0x00 0x00100000>, /* MCU SRAM */

4.

diff --git a/drivers/dma/ti/k3-psil-j721s2.c b/drivers/dma/ti/k3-psil-j721s2.c
index ba08bdc..be768e8 100644
--- a/drivers/dma/ti/k3-psil-j721s2.c
+++ b/drivers/dma/ti/k3-psil-j721s2.c
@@ -248,6 +248,11 @@ static struct psil_ep j721s2_dst_ep_map[] = {
 	/* SA2UL */
 	PSIL_SA2UL(0xf500, 1),
 	PSIL_SA2UL(0xf501, 1),
+	/* MCU_PDMA_SPI1 */
+	PSIL_PDMA_XY_PKT(0xf200),
+	PSIL_PDMA_XY_PKT(0xf201),
+	PSIL_PDMA_XY_PKT(0xf202),
+	PSIL_PDMA_XY_PKT(0xf203),
 };

我一直主要使用此文档作为指南、但它没有介绍如何使用外部引脚作为输入

https://www.ti.com/lit/pdf/sprad26

KR、

Matt