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.

TDA4VM: Possible to Configure SocketCAN to different MCAN ports?

Part Number: TDA4VM

Hello,

I was trying the SocketCAN interface on PSDK 7.1 and it's working nicely. However, I noticed the can0 interface maps to MCU MCAN0 (J30), and can1 interface maps to MCU MCAN1 (J31) on the common process board (CPB). Is it possible to reconfigure the SocketCAN interface to use MCAN0 (J27) and MCAN2 (J28)?

If not, is there a way to access MCAN0/MCAN2 from Linux application?

  • Hi,

    By default we only enable MCU MCAN0 and MCU MCAN1 in the Linux device tree.

    If you want to use MCAN0 and MCAN2 you need to make changes to the device tree k3-j721e-common-proc-board.dts.

    Changes will be related to:

    1. Pinmux CAN TX and RX transceiver GPIOs

    2. Enable the CAN transceivers

    You can take reference from the patch mentioned here - https://e2e.ti.com/support/processors/f/processors-forum/922168/faq-tda4vm-how-can-i-use-can-on-linux 

    Note that this patch was on an older SDK where we didn't have the device tree node for CAN, so you might want to pick and choose what you need from here. You will need 1 and 2 as mentioned above.

    Regards,

    Karan

  • Hi Karan,


    Thank you for the advice.  After making the suggested changes I was able to get MCAN0 and MCAN2 working with socketCAN.

    As a follow up question, how do I find the GPIO pin settings for the other MCAN interfaces besides 0 and 2? I also have a D3 RVP-TDA4VM board but it uses MCAN4 instead of MCAN2.

    For reference, here are my changes for PSDK 7.1.0. I only had to update k3-j721e-common-proc-board.dts, the file k3-j721e-main.dtsi is already up to date.

    diff --git a/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts b/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts
    index d1a2eb415..167825a73 100644
    --- a/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts
    +++ b/arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts
    @@ -262,6 +262,26 @@
                            J721E_IOPAD(0x214, PIN_OUTPUT, 4) /* (V4) MCAN1_TX.USB1_DRVVBUS */
                    >;
            };
    +
    +       mygpio1_pins_default: mygpio1_pins_default {
    +               pinctrl-single,pins = <
    +                       J721E_IOPAD(0x200, PIN_INPUT, 7) /* (AC4) UART1_CTSn.GPIO0_127 */
    +               >;
    +       };
    +
    +       mcan0_gpio_pins_default: mcan0_gpio_pins_default {
    +               pinctrl-single,pins = <
    +                       J721E_IOPAD(0x0208, PIN_INPUT, 0) /* (W5) MCAN0_RX:GPIO1_1 */
    +                       J721E_IOPAD(0x020c, PIN_OUTPUT, 0) /* (W6) MCAN0_TX:GPIO1_2 */
    +               >;
    +       };
    +
    +       mcan2_gpio_pins_default: mcan2_gpio_pins_default {
    +               pinctrl-single,pins = <
    +                       J721E_IOPAD(0x01f0, PIN_INPUT, 3) /* (AC2) MCAN2_RX.GPIO0_123 */
    +                       J721E_IOPAD(0x01f4, PIN_OUTPUT, 3) /* (AB1) MCAN2_TX.GPIO0_124 */
    +               >;
    +       };
     };
     
     &wkup_pmx0 {
    @@ -626,6 +646,22 @@
                    gpio-controller;
                    #gpio-cells = <2>;
     
    +               p06 {
    +                       /* P06 - MCAN0_EN  */
    +                       gpio-hog;
    +                       gpios = <6 GPIO_ACTIVE_HIGH>;
    +                       output-high;
    +                       line-name = "MCAN0_EN";
    +               };
    +
    +               p07 {
    +                       /* P07 - MCAN0_STB#  */
    +                       gpio-hog;
    +                       gpios = <7 GPIO_ACTIVE_HIGH>;
    +                       output-high;
    +                       line-name = "MCAN0_STB#";
    +               };
    +
                    p09 {
                            /* P11 - MCASP/TRACE_MUX_S0 */
                            gpio-hog;
    @@ -641,9 +677,34 @@
                            output-high;
                            line-name = "MCASP/TRACE_MUX_S1";
                    };
    +
    +    p13 {
    +                       /* P13 - MLB_MUX_SEL  */
    +                       gpio-hog;
    +                       gpios = <11 GPIO_ACTIVE_HIGH>;
    +                       output-low;
    +                       line-name = "MLB_MUX_SEL";
    +    };
    +
    +    p14 {
    +                       /* P14 - MCAN_MUX_SEL  */
    +                       gpio-hog;
    +                       gpios = <12 GPIO_ACTIVE_HIGH>;
    +                       output-low;
    +                       line-name = "MCAN_MUX_SEL";
    +    };
            };
     };
     
    +&main_gpio0 {
    +               p127 {
    +                       gpio-hog;
    +                       gpios = <127 GPIO_ACTIVE_HIGH>;
    +                       output-low;
    +                       line-name = "MCAN2_STB";
    +               };
    +};
    +
     &main_i2c1 {
            pinctrl-names = "default";
            pinctrl-0 = <&main_i2c1_pins_default>;
    @@ -923,6 +984,7 @@
            status = "disabled";
     };
     
    +/*
     &mcu_mcan0 {
            status = "okay";
            pinctrl-names = "default";
    @@ -933,7 +995,13 @@
                    max-bitrate = <5000000>;
            };
     };
    +*/
    +
    +&mcu_mcan0 {
    +       status = "disabled";
    +};
     
    +/*
     &mcu_mcan1 {
            status = "okay";
            pinctrl-names = "default";
    @@ -943,18 +1011,45 @@
                    max-bitrate = <5000000>;
            };
     };
    +*/
    +
    +&mcu_mcan1 {
    +       status = "disabled";
    +};
     
    +/*
     &main_mcan0 {
            status = "disabled";
     };
    +*/
    +
    +&main_mcan0 {
    +  status = "okay";
    +  pinctrl-names = "default";
    +  pinctrl-0 = <&mcan0_gpio_pins_default>;
    +  can-transceiver {
    +    max-bitrate = <5000000>;
    +  };
    +};
     
     &main_mcan1 {
            status = "disabled";
     };
     
    +/*
     &main_mcan2 {
            status = "disabled";
     };
    +*/
    +
    +&main_mcan2 {
    +       status = "okay";
    +       pinctrl-names = "default";
    +       pinctrl-0 = <&mcan2_gpio_pins_default &mygpio1_pins_default>;
    +       can-transceiver {
    +               max-bitrate = <5000000>;
    +       };
    +};
     
     &main_mcan3 {
            status = "disabled";
    

  • Hi,

    You need two things:

    1. Pinmux for the MCAN4_TX and MCAN4_RX signals. Use the Pinmux tool for that. https://dev.ti.com/sysconfig/?fromPinmux=true#/start 

    2. Enable the CAN transceiver connected to MCAN4.

    2.1 This will include Pinmuxing the signals which are connected to the EN and STB pins of the MCAN4 Transceiver and,

    2.2 Toggling those signals to enable the transceiver.

    Regards,

    Karan

  • Hi Karan,

    Thanks for the information. I will ask D3 for the pin mapping.

  • Thanks for confirmation. I will close this thread now. Let me know in case you need more help. Please mark this resolved.

    Regards,

    Karan