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.

PROCESSOR-SDK-AM62X: enable TCAN1044V CAN in the kernel

Part Number: PROCESSOR-SDK-AM62X
Other Parts Discussed in Thread: TCAN1044-Q1, TCAN1043

Hi Ti support ,

We have AM62X Custom board which has 2X TCAN1044-Q1 CAN transceiver and they are mapped to MCAN0 & MCU_CAN0 . I am using SDK 09_00_00_03. I did not find any Linux Driver for it.

Please help me how to enable CAN Interface in the kernel .

I enabled the  below kernel flags 

Please find can DTS file changes 

//added phandle for mcan0
&main_mcan0 {
pinctrl-names = "default";
pinctrl-0 = <&main_mcan0_pins_default>;
status = "okay";
};

&mcu_mcan1 {
pinctrl-names = "default";
pinctrl-0 = <&mcu_mcan0_pins_default>;
status = "okay";
};

//added for mcan0 pinmux

main_mcan0_pins_default: main_mcan0_pins_default {
pinctrl-single,pins = <
AM62X_IOPAD(0x1dc, PIN_INPUT, 0) /* (E15) AM62X_MCAN0_RX\G */
AM62X_IOPAD(0x1d8, PIN_OUTPUT, 0) /* (C15) AM62X_MCAN0_TX\G */
>;
};
//added for mcu_can0 pimux
mcu_mcan0_pins_default: mcu_mcan0_pins_default {
pinctrl-single,pins = <
AM62X_IOPAD(0x038, PIN_INPUT, 0) /* (B3) AM62X_MCU_MCAN0_RX\G */
AM62X_IOPAD(0x034, PIN_OUTPUT, 0) /* (D6) AM62X_MCU_MCAN0_TX\G */
>;
};

&main_gpio0 {
  p59{
          gpio-hog;
          gpios = <59 GPIO_ACTIVE_LOW>;
          output-low;
         line-name = "MCAN1_STB";
       };

};

  I found mcu_mcan0 node is not present in k3-am62-mcu.dtsi

Observed below Logs in kernel:

root@am62xx-evm:~# dmesg | grep can
[ 15.635177] HugeTLB: 0 KiB vmemmap can be freed for a 1.00 GiB page
[ 15.648535] HugeTLB: 0 KiB vmemmap can be freed for a 32.0 MiB page
[ 15.661882] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
[ 15.675229] HugeTLB: 0 KiB vmemmap can be freed for a 64.0 KiB page
[ 16.470584] can: controller area network core
[ 16.875630] m_can_platform 4e00000.can: m_can device registered (irq=0, version=32)
[ 16.886603] m_can_platform 20701000.can: m_can device registered (irq=248, version=32)


root@am62xx-evm:~# ip link set can1 type can bitrate 500000
root@am62xx-evm:~# ip link set up can1
root@am62xx-evm:~#  cansend can1 123#11223344556677

m_Can_platfrom  20701000.can can1 :buss-off

root@am62xx-evm:~#  cansend can1 123#11223344556677

root@am62xx-evm:~#  cansend can1 123#11223344556677

root@am62xx-evm:~# ip link set can0 type can bitrate 500000
root@am62xx-evm:~# ip link set up can0
root@am62xx-evm:~#  cansend can0 123#11223344556677

m_Can_platfrom  20701000.can can0 :buss-off

root@am62xx-evm:~#  cansend can0 123#11223344556677

root@am62xx-evm:~#  cansend can0 123#11223344556677

when i give first time cansnd command getting bus-off , then next time not getting bus-off but data is not sent

root@am62xx-evm:~#

Thanks,

Naresh

  • Hi , 

    Any update on this ?

    Thanks ,

    Naresh

  • Hi,

    Could you please provide a diagram of how the interface is connected to other CAN device?

    I have two links for you to review. The first one might be more useful to you. I thought there was a page concerning the dtsi support that you are mentioning but I am not seeing it at the moment, I will check into this and get back to you in a day or so. The second one is the kernel user guide which has the commands you are already using.

    How-to guide for MCAN

    Kernel User guide

    Best Regards,

    Schuyler

  • Hi Schuyler,

    Thanks for info .

    when i issue below command , its throwing error

    ip link set can0 type can bitrate 50000 fd on
    RTNETLINK answers : operation not supported

    I just enabled MCAN only , disabling the MCU_CAN0 for now .
    below is the log for MCAN0 (can0 is node):



    Please help me on this issue.

    Thanks,

    Naresh

  • Hi Naresh,

    About the MCAN node not being present on the k3-am62-mcu.dtsi, it is actually present. Refer to: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi?h=ti-linux-6.1.y-cicd#n164.

    The device tree binding that might work for TCAN1044 is ti,tcan104x-can.yaml, which is for TCAN104x CAN transceiver phy.

    The bus-off, might be a wrong connection somewhere, or it could also be how you are powering the CAN transceivers. By chance, are you powering the CAN transceivers using the AM62x SK? If so, the 3.3V and 5V power rails on J3 header are not enabled by default and that might be your issue.

    A schematic or description of your connections with CAN transceiver would also be helpful here.

    ~ Judith

  • Hi Judith ,

    Thanks for information .

    in 1st post i mentioned dts file info , can you please veirfy ?

    examples:: 

    #include <dt-bindings/gpio/gpio.h>

    transceiver1: can-phy {
    compatible = "ti,tcan1043";
    #phy-cells = <0>;
    max-bitrate = <5000000>;
    standby-gpios = <&wakeup_gpio1 16 GPIO_ACTIVE_LOW>;
    enable-gpios = <&main_gpio1 67 GPIO_ACTIVE_HIGH>;
    mux-states = <&mux0 1>;
    };

    I observed ti,tcan104x-can.yaml file where tcan1043 driver is not present

    may i know what are theese  mux settings -> mux-states = <&mux0 1>;  from device tree ?

    for my board standby gpios there , not having enable gpios ?

    I guess bus-off error due to STB signal ? 

    do we need to connect STB signal to GND ?

    Thanks,

    Naresh

  • Hi Naresh,

    The driver for compatible = "ti,tcan1043"; is there in Linux, refer to drivers/phy/phy-can-transceiver.c. As you can see, Standby and Enable signals are optional  and if you do not need them, you could omit from device tree.

    May I ask what is your use-case? Is it required for your to enable these signals?

    Are you using TI EVM or custom board?

    I am no expert with regards with hardware or TCAN transceiver, but here is my best guess:

    The mux-states device tree property is:  "mux controller node to route the signals from controller to transceiver".

    If you look at AM64 GP EVM, you could see the following: we do have a mux to determine where to route CAN signals, but the "S" select pin on the mux is brought to GND using 10K resistor. Therefore, we do not include mux-states = <&mux0 1>; in the device tree node. In your case, this might be different, is there a mux between your SoC and CAN transceiver?

    The STB is routed to an IO expander, where signal name is MCAN0_STB_3V3,  and therefore we use: standby-gpios = <&exp1 9 GPIO_ACTIVE_HIGH>; for STB. The same logic can apply for enable GPIO.



    For the following questions:

    1. for my board standby gpios there , not having enable gpios ?
    2.
    I guess bus-off error due to STB signal ?
    3. do we need to connect STB signal to GND ?

    We require more information about your hardware layout in order to answer these questions.

    ~ Judith

  • Hi Judith ,

    Thanks for info .

    After connected STB signal to GND ,

    we are able to send and recieve the CAN transaction using can analyser .

    Please find the below steps for Testing for MCAN0 :

    we tried with below bitrate and datarate combinations :  bitrate =125kbps, datarate=2mbps  /  bitrate =500kbps, datarate=2mbps/bitrate=500kbps,datarate=5mbps.

    • ifconfig -a can0 down   
    • ip link set can0 type can bitrate 50000
    • ip link set can0 type can bitrate 50000 fd on  -  , this throwing RTNETLINK : operation is not supported .
    • ip link set can0 type can bitrate 1000000 dbitrate 4000000 fd on
    • ifconfig -a can0 up

      Send CAN 2.0 frame  - working

    • cansend can0 123#DEADBEEF

                on can analyser i am able to recieving the data ,  from sending the data from can analyser  and receiving the data in board.

               Send CAN FD frame   - Not working 

    • cansend can0 113##2AAAAAAAA

                Send CAN FD frame with BRS  - Not working 

    • cansend can0 143##1AAAAAAAAA

    Just for info,  i added below device tree CAN info  in  "/ " node of k3-am625-sk.dts  . please let me know  ,Am i right ?  with/without theese deivce tree changes ,above testing were performed .

    transceiver1: can-phy0 {
    compatible = "ti,tcan1043";
    #phy-cells = <0>;
    max-bitrate = <5000000>;
    pinctrl-names = "default";
    pinctrl-0 = <&main_mcan0_pins_default>;

    };

    please help me why this failing when i excute this command => ip link set can0 type can bitrate 50000 fd on  

    Thanks,

    Naresh

  • Hi Naresh,

    ok, so there is an example overlay in the Processor SDK called k3-am62x-sk-mcan.dtso. You could refer to this overlay if you like: git.ti.com/.../k3-am62x-sk-mcan.dtso

    In your transceiver node:

    transceiver1: can-phy0 {
    compatible = "ti,tcan1043";
    #phy-cells = <0>;
    max-bitrate = <5000000>;
    pinctrl-names = "default";
    pinctrl-0 = <&main_mcan0_pins_default>;
    
    };


    the last two lines should go in the MCAN node, like so:
    &main_mcan0 {
        pinctrl-names = "default";
        pinctrl-0 = <&main_mcan0_pins_default>;
        phys = <&transceiver1>;
        status = "okay";
    };


    ~ Judith

  • You have each node correct in your first post and it seems like you also have:

    &main_gpio0 {
      p59{
              gpio-hog;
              gpios = <59 GPIO_ACTIVE_LOW>;
              output-low;
             line-name = "MCAN1_STB";
           };
    
    };



    so the following should apply for you:

    standby-gpios = <&exp1 <GPIO # for p59> GPIO_ACTIVE_HIGH>;


    But if you simply want to connect STB to GND, you can. This allows the transceiver to work in normal mode only, according to the datasheet: www.ti.com/.../tcan1044-q1.pdf

    ~ Judith

  • Hi Judith ,

    Thanks for informatoin,

    If i configure as below in dts file , so can0 node is not showing.

    root@am62xx-evm:~# ifconfig -a
    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:65536 Metric:1
    RX packets:250 errors:0 dropped:0 overruns:0 frame:0
    TX packets:250 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:16424 (16.0 KiB) TX bytes:16424 (16.0 KiB)

    wwan0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
    POINTOPOINT NOARP MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

    wwan1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
    POINTOPOINT NOARP MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

    => Enabled trnasciever node in kernel menuconfig  also , driver -> phys substsem -> can tranciever

    DTS file confguration: 

    //added for mcan0

    main_pmxo {
    main_mcan0_pins_default: main_mcan0_pins_default {
    pinctrl-single,pins = <
    AM62X_IOPAD(0x1dc, PIN_INPUT, 0) /* (E15) AM62X_MCAN0_RX\G */
    AM62X_IOPAD(0x1d8, PIN_OUTPUT, 0) /* (C15) AM62X_MCAN0_TX\G */
    //AM62X_IOPAD(0x0ec, PIN_INPUT, 7) /* (AA24) STB0 */
    >;
    };

    };

    &main_mcan0 {
    pinctrl-names = "default";
    pinctrl-0 = <&main_mcan0_pins_default>;
    phys = <&transceiver1>;
    status = "okay";
    };

    below added under / node

    transceiver1: can-phy0 {
    compatible = "ti,tcan1043";    // i tired both names tcan1043 ,tcan1042
    #phy-cells = <0>;
    max-bitrate = <5000000>;
    pinctrl-names = "default";
    pinctrl-0 = <&main_mcan0_pins_default>;

    };

    TCAN1044 is our can chipset, tcan1043 &tcan1042 ?

    what i missing please let me know ?

    Please help me on this .

    Thanks,

    Naresh