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.

J784S4XEVM: Device tree and mux configuration to access main_spi5 on J26 expansion pin header

Part Number: J784S4XEVM

Hello,

I am trying to connect an external SPI device to the J784S4XEVM by getting main_spi5 working on the J26 expansion pin header. This header is specifically for breaking out a main domain SPI port to physical pins so I assume it should relatively straight forward to enable this but I am running into multiple issues.


I have started by just trying to bring up main_spi5 as a spidev device to run a loopback test before trying to get the actual spi device working.

I am using this SDK: ti-processor-sdk-linux-adas-j784s4-evm-09_00_01_02

Here are the modifications I have made to the k3-j784s4-evm.dts file:

diff --git a/J784S4-EVM/kernel/k3-j784s4-evm.dts b/J784S4-EVM/kernel/k3-j784s4-evm.dts
index b2970e9..18dc1a1 100644
--- a/J784S4-EVM/kernel/k3-j784s4-evm.dts
+++ b/J784S4-EVM/kernel/k3-j784s4-evm.dts
@@ -10,6 +10,7 @@
#include <dt-bindings/net/ti-dp83867.h>
#include <dt-bindings/gpio/gpio.h>
#include "k3-j784s4.dtsi"
+#include <dt-bindings/interrupt-controller/irq.h>
+               spi0 = &main_spi5;
        };
 
        memory@80000000 {
@@ -641,6 +643,22 @@
                        J784S4_IOPAD(0x024, PIN_OUTPUT, 0) /* (AH34) MCAN16_TX */
                >;
        };
+
+       main_spi5_pins_default: main_spi5_pins_default {
+               pinctrl-single,pins = <
+                       J784S4_IOPAD(0x07c, PIN_INPUT, 8) /* (AJ38) MCASP0_AXR3.SPI5_CLK */
+                       J784S4_IOPAD(0x068, PIN_INPUT, 8) /* (AE38) MCAN0_RX.SPI5_CS0 */
+                       J784S4_IOPAD(0x064, PIN_INPUT, 8) /* (AF38) MCAN0_TX.SPI5_CS1 */
+                       J784S4_IOPAD(0x070, PIN_INPUT, 8) /* (AH38) MCAN1_RX.SPI5_D0 */
+                       J784S4_IOPAD(0x088, PIN_INPUT, 11) /* (AF36) MCASP0_AXR6.SPI5_D1 */
+               >;
+       };
+
+       j36_header_gpio0_pins_default: j36_header_gpio0_pins_default {
+               pinctrl-single,pins = <
+                       J784S4_IOPAD(0x084, PIN_INPUT, 7) /* (AG38) MCASP0_AXR5.GPIO0_33 */
+               >;
+       };
};
 
&wkup_pmx0 {
@@ -976,6 +994,8 @@
 
&main_gpio0 {
        status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&j36_header_gpio0_pins_default>;
};
 
&mcu_cpsw {
@@ -1470,3 +1490,27 @@
        pinctrl-0 = <&main_mcan16_pins_default>;
        phys = <&transceiver3>;
};
+
+&main_spi5 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&main_spi5_pins_default>;
+       status="okay";
+
+       spidev@0 {
+        spi-max-frequency = <24000000>;
+        reg = <0>;
+        compatible = "linux,spidev";
+    };
+
+       // icm42688@0 {
+       //      compatible = "invensense,icm42688";
+       //      reg = <0>;
+       //      spi-max-frequency = <24000000>;
+       //      spi-cpha;
+       //      spi-cpol;
+       //      interrupt-parent = <&main_gpio0>;
+       //      interrupts = <33 IRQ_TYPE_EDGE_RISING>;
+       //              vdd-supply = <&vdd_sd_dv>;
+       //              vddio-supply = <&vdd_sd_dv>;
+       // };
+};
\ No newline at end of file


Here are the linux modules I am include on top of the default defconfig:

diff --git a/J784S4-EVM/kernel/defconfig b/J784S4-EVM/kernel/defconfig
index 75a1e86..fc74d20 100644
--- a/J784S4-EVM/kernel/defconfig
+++ b/J784S4-EVM/kernel/defconfig
@@ -575,7 +575,11 @@ CONFIG_SPI_IMX=m
CONFIG_SPI_FSL_DSPI=y
CONFIG_SPI_MESON_SPICC=m
CONFIG_SPI_MESON_SPIFC=m
-CONFIG_SPI_OMAP24XX=m
+CONFIG_REGMAP_SPI=y
+CONFIG_SPI_DYNAMIC=y
+CONFIG_SPI_MEM=y
+CONFIG_SPI_OMAP24XX=y
+CONFIG_SND_SOC_I2C_AND_SPI=y
CONFIG_SPI_ORION=y
CONFIG_SPI_PL022=y
CONFIG_SPI_ROCKCHIP=y
@@ -589,7 +593,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_PINCTRL_MAX77620=y
@@ -1012,6 +1016,12 @@ CONFIG_USB_CDC_COMPOSITE=m
CONFIG_USB_G_SERIAL=m
CONFIG_USB_G_MULTI=m
CONFIG_USB_G_MULTI_CDC=y
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_F_RNDIS=m
+CONFIG_USB_CONFIGS_RNDIS=y
+CONFIG_USB_ETH_RNDIS=y
+CONFIG_USB_FUNCTIONFS_RNDIS=y
+CONFIG_USB_G_MULTI_RNDIS=y
CONFIG_TYPEC=m
CONFIG_TYPEC_TCPM=m
CONFIG_TYPEC_TCPCI=m
@@ -1291,6 +1301,21 @@ CONFIG_EXTCON_USBC_CROS_EC=y
CONFIG_OMAP_GPMC=y
CONFIG_RENESAS_RPCIF=m
CONFIG_IIO=y
+CONFIG_IIO_BUFFER=y
+CONFIG_IIO_BUFFER_CB=y
+CONFIG_IIO_BUFFER_DMA=y
+CONFIG_IIO_BUFFER_DMAENGINE=y
+CONFIG_IIO_BUFFER_HW_CONSUMER=y
+CONFIG_IIO_KFIFO_BUF=y
+CONFIG_IIO_TRIGGERED_BUFFER=y
+CONFIG_IIO_CONFIGFS=y
+CONFIG_IIO_TRIGGER=y
+CONFIG_IIO_CONSUMERS_PER_TRIGGER=2
+CONFIG_IIO_SW_DEVICE=y
+CONFIG_IIO_SW_TRIGGER=y
+CONFIG_IIO_TRIGGERED_EVENT=y
+CONFIG_INV_ICM42600_SPI=m
+CONFIG_IIO_INTERRUPT_TRIGGER=y
CONFIG_EXYNOS_ADC=y
CONFIG_MAX9611=m
CONFIG_QCOM_SPMI_VADC=m


I see the spi in question in /sys/class/spi_master so I think the device tree isn’t entirely wrong:

root@j784s4-evm:~# ls -l /sys/class/spi*
/sys/class/spi_master:
total 0
lrwxrwxrwx 1 root root 0 Oct 30  2022 spi0 -> ../../devices/platform/bus@100000/2150000.spi/spi_master/spi0
lrwxrwxrwx 1 root root 0 Oct 30  2022 spi1 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/47000000.bus/47040000.spi/spi_master/spi1
lrwxrwxrwx 1 root root 0 Oct 30  2022 spi2 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/47000000.bus/47050000.spi/spi_master/spi2
 
/sys/class/spi_slave:
total 0
 
/sys/class/spidev:
total 0


However, it does not show up as a spidev device in /dev or /sys/class. 


The other issue I am having is with configuring the muxes on the board to switch the SPI5 pins to the J26 expansion header.

I tried just configuring the pins on J26 as GPIO to test if I have the muxes configured correctly. I can toggle the pins in sysfs but I do not see the voltage on the physical pins change so I suspect there is something wrong with my muxing.

I am trying to configure the muxes as such:

 

Since CANUART_MUX_SEL2 is tied to 3V3 and  CANUART_MUX_SEL0 is from a DIP switch, I only need to set CANUART_MUX1/2_SEL1 to L:



 

Configuring the 3 mux pins to H L H I am just toggling the two selector pins (P16 and P17) on the gpiochip472 (which I have confirmed with the i2c address is the Expander2).

echo 488 > /sys/class/gpio/export
echo 489 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio488/direction
echo out > /sys/class/gpio/gpio489/direction
echo 0 > /sys/class/gpio/gpio488/value
echo 0 > /sys/class/gpio/gpio489/value


However, I see no change in the behavior of the pins on J26 when I toggle the two mux pins.

If anyone has any experience with either of these two things or has gotten the SPI working on J26 it would be much appreciated.

Thanks,
Devin

  • Hi Devin,

    So on top of the dts changes you have made(Those look fine) replace the below exp2 arch/arm64/boot/dts/ti/k3-j784s4-evm.dts node in:

        exp2: gpio@22 {
            compatible = "ti,tca6424";
            reg = <0x22>;
            gpio-controller;
            #gpio-cells = <2>;
    
            gpio-line-names = "R_GPIO_RGMII1_RST", "ENET2_I2CMUX_SEL", "GPIO_USD_PWR_EN",
                      "USBC_PWR_EN", "USBC_MODE_SEL1", "USBC_MODE_SEL0",
                      "GPIO_LIN_EN", "R_CAN_STB", "CTRL_PM_I2C_OE#",
                      "ENET2_EXP_PWRDN", "ENET2_EXP_SPARE2", "CDCI2_RSTZ",
                      "USB2.0_MUX_SEL", "CANUART_MUX_SEL0", "CANUART_MUX2_SEL1",
                      "CANUART_MUX1_SEL1", "ENET1_EXP_PWRDN", "ENET1_EXP_RESETZ",
                      "ENET1_I2CMUX_SEL", "ENET1_EXP_SPARE2", "ENET2_EXP_RESETZ",
                      "USER_INPUT1", "USER_LED1", "USER_LED2";
            p8-hog {
                /* P10 - PM_I2C_CTRL_OE */
                gpio-hog;
                gpios = <8 GPIO_ACTIVE_HIGH>;
                output-high;
                line-name = "CTRL_PM_I2C_OE";
            };
    
            p13-hog {
                /* P15 - CANUART_MUX_SEL0 */
                gpio-hog;
                gpios = <13 GPIO_ACTIVE_HIGH>;
                output-high;
                line-name = "CANUART_MUX_SEL0";
            };
    
            p14-hog {
                /* P16 - CANUART_MUX2_SEL1 */
                gpio-hog;
                gpios = <14 GPIO_ACTIVE_HIGH>;
                output-low;
                line-name = "CANUART_MUX2_SEL1";
            };
    
            p15-hog {
                /* P17 - CANUART_MUX1_SEL1 */
                gpio-hog;
                gpios = <15 GPIO_ACTIVE_HIGH>;
                output-low;
                line-name = "CANUART_MUX1_SEL1";
            };
        };

    With that TX/RX loop back should work:

    root@j784s4-evm:~# /opt/ltp/testcases/bin/ddt/spidev_test -D /dev/spidev2.0 
    spi mode: 0
    bits per word: 8
    max speed: 500000 Hz (500 KHz)
    number of words to be transfered: 100
    --------tx data-----------
    
    00 01 02 03 04 05 
    06 07 08 09 0A 0B 
    0C 0D 0E 0F 10 11 
    12 13 14 15 16 17 
    18 19 1A 1B 1C 1D 
    1E 1F 20 21 22 23 
    24 25 26 27 28 29 
    2A 2B 2C 2D 2E 2F 
    30 31 32 33 34 35 
    36 37 38 39 3A 3B 
    3C 3D 3E 3F 40 41 
    42 43 44 45 46 47 
    48 49 4A 4B 4C 4D 
    4E 4F 50 51 52 53 
    54 55 56 57 58 59 
    5A 5B 5C 5D 5E 5F 
    60 61 62 63 
    ---------rx data----------
    
    00 01 02 03 04 05 
    06 07 08 09 0A 0B 
    0C 0D 0E 0F 10 11 
    12 13 14 15 16 17 
    18 19 1A 1B 1C 1D 
    1E 1F 20 21 22 23 
    24 25 26 27 28 29 
    2A 2B 2C 2D 2E 2F 
    30 31 32 33 34 35 
    36 37 38 39 3A 3B 
    3C 3D 3E 3F 40 41 
    42 43 44 45 46 47 
    48 49 4A 4B 4C 4D 
    4E 4F 50 51 52 53 
    54 55 56 57 58 59 
    5A 5B 5C 5D 5E 5F 
    60 61 62 63 

    Best Regards,
    Keerthy

  • Hi Keerthy,

    Thanks for your response. This did not solve either problem for me, spidev does not show up still and I still cannot see GPIO toggles on the J26 pins. 

    Also, when I read the values on the GPIO expander 2 pins that you added to the device tree I actually don't see the values specified in the device tree. I think you added the wrong pin number to the gpio-hog nodes but even when corrected it doesn't seem to change. When I read the values and directions from the pins I see they are still input and their values are as such:

    root@j784s4-evm:/sys/class/gpio# cat gpio482/value
    0
    root@j784s4-evm:/sys/class/gpio# cat gpio487/value
    1
    root@j784s4-evm:/sys/class/gpio# cat gpio488/value
    1
    root@j784s4-evm:/sys/class/gpio# cat gpio489/value
    0

    E.g. I corrected this:

    - p14-hog {
    + p16-hog {
    /* P16 - CANUART_MUX2_SEL1 */
    gpio-hog;
    - gpios = <14 GPIO_ACTIVE_HIGH>;
    + gpios = <16 GPIO_ACTIVE_HIGH>;
    output-low;
    line-name = "CANUART_MUX2_SEL1";
    };
    


    Also, I have made another topic to focus on the first issue of spidev as that may be unrelated to the mux: 
    e2e.ti.com/.../j784s4xevm-device-tree-config-not-enabling-main_spi5-correctly

  • Keerthy, would you be able to share k3-j784s4-evm.dts and your defconfig file since it seems like your spidev is working?

    Also could you share any details of how you built the device tree and kernel (ie SDK version).

    Also, I have made a separate thread for just discussing enabling SPI rather than the mux issue:
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1277735/j784s4xevm-device-tree-config-not-enabling-main_spi5-correctly

  • Devin,

    You don't have to do anything with the configs. I was able to spidev on 8.6 SDK.

    Can you dump out the pinmux registers from Linux using devmem2?

    For example:

    devmem2 0x11c07c

    Best Regards,

    Keerthy

  • Keerthy, I have now been able to get spidev to show up by switching to 8.6 SDK. This is without any modifications to the configs. However, the output of the SPI pins is still not showing up on the physical pins.

    Here is devmem2 0x11c07c:

    root@j784s4-evm:~# devmem2 0x11c07c
    /dev/mem opened.
    Memory mapped at address 0xffff92084000.
    Read at address 0x0011C07C (0xffff9208407c): 0x00050008


    Could you please share your entire k3-j784s4-evm.dts file from the 8.6 SDK where SPI is working on the physical pins?

    Thanks,
    Devin Bell

  • Hi Devin,

    Keerthy, I have now been able to get spidev to show up by switching to 8.6 SDK. This is without any modifications to the configs. However, the output of the SPI pins is still not showing up on the physical pins.

    That is good.

    Please find the evm.dts file working on my side. I shorted the RX-TX pins and I could see the loop back working.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/k3_2D00_j784s4_2D00_evm.dts

    The zoomed in Image of the connection on J26 to short TX/RX.

    Logs with RX and TX loop back.

    root@j784s4-evm:~# /opt/ltp/testcases/bin/ddt/spidev_test -D /dev/spidev0.0
    spi mode: 0
    bits per word: 8
    max speed: 500000 Hz (500 KHz)
    number of words to be transfered: 100
    --------tx data-----------
    
    00 01 02 03 04 05 
    06 07 08 09 0A 0B 
    0C 0D 0E 0F 10 11 
    12 13 14 15 16 17 
    18 19 1A 1B 1C 1D 
    1E 1F 20 21 22 23 
    24 25 26 27 28 29 
    2A 2B 2C 2D 2E 2F 
    30 31 32 33 34 35 
    36 37 38 39 3A 3B 
    3C 3D 3E 3F 40 41 
    42 43 44 45 46 47 
    48 49 4A 4B 4C 4D 
    4E 4F 50 51 52 53 
    54 55 56 57 58 59 
    5A 5B 5C 5D 5E 5F 
    60 61 62 63 
    ---------rx data----------
    
    00 01 02 03 04 05 
    06 07 08 09 0A 0B 
    0C 0D 0E 0F 10 11 
    12 13 14 15 16 17 
    18 19 1A 1B 1C 1D 
    1E 1F 20 21 22 23 
    24 25 26 27 28 29 
    2A 2B 2C 2D 2E 2F 
    30 31 32 33 34 35 
    36 37 38 39 3A 3B 
    3C 3D 3E 3F 40 41 
    42 43 44 45 46 47 
    48 49 4A 4B 4C 4D 
    4E 4F 50 51 52 53 
    54 55 56 57 58 59 
    5A 5B 5C 5D 5E 5F 
    60 61 62 63 
    root@j784s4-evm:~# [ 1

    Best Regards,
    Keerthy