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.

TDA4VH-Q1: Enabling MAIN_MCAN5 for Linux on EVM

Part Number: TDA4VH-Q1
Other Parts Discussed in Thread: TDA4VH

Tool/software:

Hello,

I am trying to enable MCAN5 on the TDA4VH EVM by modifying the device tree. Since I added NCAN5-related nodes the device shows up under /proc and /sys/class/net however I am not able to send CAN frames through the transceiver (I am able to use the CAN5 in loopback mode though). I suspect my standby or pinctrl definitions are not correct. Since the STB pin is on the expander I was not sure how to properly declare it in the transceiver node. Could you please help me with the CAN configuration? 

// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include "k3-pinctrl.h"

#define R_CAN_STB 7 /*P7*/ //MCAN5_STB
#define CANUART_MUX_SEL0_GPIO 13 /*P15*/
#define CANUART_MUX2_SEL1_GPIO 14 /*P16*/
#define CANUART_MUX1_SEL1_GPIO 15 /*P17*/ //unused in this file
#define USER_LED1_GPIO 22 /*P26*/
#define USER_LED2_GPIO 23 /*P27*/
// aliases {
//     mcan5 = "main_mcan5";
// };
&exp2 {
    /* User LEDs */

    user-led1 {
        gpio-hog;
        gpios = <USER_LED1_GPIO (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
        output-low;    /* Start with LED on */
        line-name = "USER_LED1";
    };

    user-led2 {
        gpio-hog;
        gpios = <USER_LED2_GPIO (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
        output-high;    /* Start with LED off */
        line-name = "USER_LED2";
    };
    
    //can standby
    /*MCAN5_STB*/
    r_can_stb {
        gpio-hog;
        gpios = <R_CAN_STB (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
        line-name = "MCAN5_STB";
    };

    /*canuart pinmux*/
    // for MCAN5, MCAN4(mux2) and  MCAN3(mux1)
    // shared  betweeen both muxes
    // disables SPI5
    canuart-mux-sel0 {
        gpio-hog;
        gpios = <CANUART_MUX_SEL0_GPIO (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
        line-name = "CANUART_MUX_SEL0";
        output-high;    /* Start with LED off */

    };
};

&{/} {

    transceiver5: can-phy5 {
		compatible = "ti,tcan1042";
		#phy-cells = <0>;
		max-bitrate = <5000000>;
		// pinctrl-names = "default";
		// pinctrl-0 = <&main_mcan5_gpio_pins_default>;
		standby-gpios = <&exp2 R_CAN_STB (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
	};
};

&main_pmx0 {
    main_mcan5_pins_default: main-mcan5-pins-default {
        pinctrl-single,pins = <
            /* Adjust these based on your specific pinmux */
            J784S4_IOPAD(0x038, PIN_OUTPUT, 0) /* (AK35) MCASP0_ACLKX.CAN5_TX */
            J784S4_IOPAD(0x03C, PIN_INPUT, 0)  /* (AK38) MCASP0_AFSX.CAN5_RX */
        >;
    };

    // main_mcan5_gpio_pins_default: main-mcan5-gpio-pins-default {
    //     pinctrl-single,pins = <
    //     >;
    // };
};

&main_mcan5 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&main_mcan5_pins_default>;
	phys = <&transceiver5>;
};

Thanks in advance

  • Hi Ozan,

    MCAN5 is a muxed output. Following taken from the schematic file that can be downloaded from "Design files" section on the EVM product page: https://www.ti.com/tool/J784S4XEVM 

    The mux in use is this mux: https://www.ti.com/lit/ds/symlink/sn74cbt16214c.pdf

    You will need to turn off/on the S0/S1/S2 signals in device tree so that the B2 lines are outputted:

    Additionally, MCAN5 has an additional mux between MCASP and MCAN5:

    So, this documentation for the mux will need to be referenced: https://www.ti.com/lit/ds/symlink/sn74cb3q3257.pdf

    Specifically, B2 will need to be selected.

    Alternatively, instead of MCAN5, the mcu_mcan0, mcu_mcan1, main_mcan16, and main_mcan4 does not need these extra muxing so these MCAN interfaces can be used instead with relatively lower effort than MCAN5.

    Regards,

    Takuma

  • Hello Takuma,

    Thanks for your reply. I am already using the CAN busses you mentioned. As you can see in the DTSO file,

    • I am already enabling the pinmux (MUX2) through GPIO expander 2 (EXP2).
    • CANUART_MUX_SEL2 is hardwired as HIGH,
    • CANUART_MUX1_SEL1 and CANUART_MUX2_SEL1 have pull-up resistors, so they should be high when unused as well.
    • CANUART_MUX_SEL0 is set to high below


    I also set the pads for TX/RX lines.


    MAIN_MCAN5 device is defined here and I am able to see it in /sys/class/net/, and bring it up using ip.

    However, as I mentioned earlier, one thing is different. The stand-by pin is also on EXP2. For the transceiver node;

    Does pinctrl-0 property need to be defined since the pin is controlled by EXP2 and not SoC? In other MCANs where this is controlled by the SoC ___gpio_pins_default is used to set pinmux of the PAD . Since this R_CAN_STB pin doesn't need muxing, not sure how this property (and gpio_pins_default node) should be defined.

    I am having a hard time identifying what I am missing. Any insight would be appreciated.

    Best,

    Ozan

    PS: You bring an interesting point though: MCAN5 TX and RX are present in two nets.  Can I jsut use this secondary set of pins and not touch MUX1 and MUX2?

  • Hi Ozan,

    PS: You bring an interesting point though: MCAN5 TX and RX are present in two nets.  Can I jsut use this secondary set of pins and not touch MUX1 and MUX2?

    If designing a custom board, yes. But on TI EVM the AC35 and AE35 are pinned out for RGMII instead of MCAN. So, only AK35 and AK38 can be used for MCAN5 on TI EVM.

    My current suspicion for not seeing the MCAN output is still the muxing, but the second portion of muxing. To quote my previous response:

    Additionally, MCAN5 has an additional mux between MCASP and MCAN5:

    So, this documentation for the mux will need to be referenced: https://www.ti.com/lit/ds/symlink/sn74cb3q3257.pdf

    Specifically, B2 will need to be selected.

    By default, I see a DNI (Do Not Install) for the pull up resistor in EVM schematics and the line is instead pulled down, so default should select B1. We will want B2 to be selected for MCAN5 output, so outputting high the AUDIO_MUX_SEL on exp1 looks to be the missing piece.

    Regards,

    Takuma

  • Hi Takuma,

    I configured the other MUX you mentioned and the MCAN5 network now work!. But it seems enabling only one of the muxes is enough. I disabled the other one and I was still able to communicate through the CAN interface. I assume I set one of the MUX pings wrong.

    Also, the pin numbers in the DTBs don't match the schematic, but they line up with pin names listed in the GPIO expansion nodes' gpio-line-names property.

    Thank you,
    Ozan