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.

CAN Driver on TDA4

Other Parts Discussed in Thread: TDA4VM

Hi,

I've seen can0 and can1 in terminal by ifconfig -a with the method you supplied(https://e2e.ti.com/support/processors/f/791/t/922168) and can set can0/can1 up. Thanks!

However, i meets another problem: when i execute "cansend can0 113##2AAAAAAAA", then returned info "m_can_platform 2701000.mcan can0: bus-off".

The changes are as follows:



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 6788a3611..b223fc97d 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 @@ -164,6 +164,21 @@ }; &main_pmx0 { + + 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 */ + >; + }; + sw10_button_pins_default: sw10_button_pins_default { pinctrl-single,pins = < J721E_IOPAD(0x0, PIN_INPUT, 7) /* (AC18) EXTINTn.GPIO0_0 */ @@ -180,6 +195,37 @@ pinctrl-single,pins = < J721E_IOPAD(0x230, PIN_INPUT, 7) /* (U2) ECAP0_IN_APWM_OUT.GPIO1_11 */ >; + 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#"; + }; + + 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_i2c0_pins_default: main-i2c0-pins-default { @@ -350,6 +396,15 @@ status = "disabled"; }; +&main_gpio0 { + p127 { + gpio-hog; + gpios = <127 GPIO_ACTIVE_HIGH>; + output-low; + line-name = "MCAN2_STB"; + }; +}; + &main_gpio2 { status = "disabled"; }; diff --git a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi index c036df124..e5d84e44d 100644 --- a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi +++ b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi @@ -1148,6 +1148,34 @@ clock-names = "gpio"; }; + m_can0: mcan@2701000 { + compatible = "bosch,m_can"; + reg = <0x0 0x2701000 0x0 0x200>, + <0x0 0x2708000 0x0 0x8000>; + reg-names = "m_can", "message_ram"; + power-domains = <&k3_pds 156 TI_SCI_PD_EXCLUSIVE>; + clocks = <&k3_clks 156 1>, <&k3_clks 156 0>; + clock-names = "cclk", "hclk"; + interrupts = <GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "int0", "int1"; + bosch,mram-cfg = <0x0 0 0 32 0 0 1 1>; + }; + + m_can2: mcan@2721000 { + compatible = "bosch,m_can"; + reg = <0x0 0x2721000 0x0 0x200>, + <0x0 0x2728000 0x0 0x8000>; + reg-names = "m_can", "message_ram"; + power-domains = <&k3_pds 160 TI_SCI_PD_EXCLUSIVE>; + clocks = <&k3_clks 160 1>, <&k3_clks 160 0>; + clock-names = "cclk", "hclk"; + interrupts = <GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "int0", "int1"; + bosch,mram-cfg = <0x0 0 0 32 0 0 1 1>; + }; + main_gpio2: gpio@610000 { compatible = "ti,j721e-gpio", "ti,keystone-gpio"; reg = <0x0 0x00610000 0x0 0x100>; -- 2.17.1

Regards

  • Hi,

    We will look into this and give you a feedback shortly - in the next day or two. 

    Can you please confirm that you are reporting this issue on the TI TDA4VM EVM and not on a custom board?

    Regards

    Karthik

  • Hi,

    The problem seems to be that the CAN message is not going out on the wire - and the controller might be trying to retransmit the same message again and again and hence pulling the CAN bus to a bus-off state. This is a state when the number of errors exceed a certain threshold.

    The message not successfully transmitting on the wire could be because of multiple reasons like:

    1. Transceiver configuration is wrong.
    2. Pinmux for CAN Tx or CAN Rx are not correct.
    3. The connection to CAN-H and CAN-L is not proper or the cable / wires have gone bad.
    4. ...

    I reviewed your patch (assuming this is the only change) and I see some problems:

    1. You are not pinmuxing the m_can0 and m_can2

    There is no pinctrl-0 field for both these nodes. This will not allow the controller to push out data from the SoC out to the transceiver and then to the CAN node. Please review the FAQ https://e2e.ti.com/support/processors/f/791/t/922168 and search for the pinctrl-0 field. The pinmux is done in the k3-j721e-common-proc-board.dts. Please add these node references to your patch.

    Note that along with the pinmux for the CAN Tx and CAN Rx we also need to mux the signals which enable the CAN transceivers. (explained in point 2)

    2. The GPIO0_127 is not pinmuxed needed for MCAN2 transceiver

    You are pulling the GPIO0_127 low by hogging it in main_gpio0 { ... } node. But the problem here is that you also need to pinmux this signal for the value to take in effect.

    This GPIO0_127 feeds in via a 2:1 MUX to the MCAN2_STB signal.

    To pinmux this please see the mygpio1_pins_default {...} node in the same patch in file k3-j721e-common-proc-board.dts

    I believe with the above fixed you should be good to go.

    With the current status one good test would be to run in internal loopback mode. In this mode there is no need for the data from the controller to come out of the SoC and hence this will remove the Pinmux and transceiver dependencies. If this fails it could be because the nodes status is not enabled (see k3-j721e-common-proc-board.dts - &m_can0 {...} node's status field. This is not there in your case.)

    To test internal loopback, please refer the same FAQ https://e2e.ti.com/support/processors/f/791/t/922168 . I have updated the section under Debug tips.

    Regards,

    Karan

  • Yes, I confirmed

  • Hi, 

        Thansk for your reply.

        After use your patch of the .dts file, we can test internal loopback mode ok. But it still can not output normally.

        

    3056.k3-j721e-common-proc-board.dts.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    // SPDX-License-Identifier: GPL-2.0
    /*
    * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
    */
    /dts-v1/;
    #include "k3-j721e-som-p0.dtsi"
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/input/input.h>
    #include <dt-bindings/sound/ti-mcasp.h>
    #include <dt-bindings/net/ti-dp83867.h>
    / {
    chosen {
    stdout-path = "serial2:115200n8";
    bootargs = "console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02800000";
    };
    gpio_keys: gpio-keys {
    compatible = "gpio-keys";
    autorepeat;
    pinctrl-names = "default";
    pinctrl-0 = <&sw10_button_pins_default &sw11_button_pins_default>;
    sw10: sw10 {
    label = "GPIO Key USER1";
    linux,code = <BTN_0>;
    gpios = <&main_gpio0 0 GPIO_ACTIVE_LOW>;
    };
    sw11: sw11 {
    label = "GPIO Key USER2";
    linux,code = <BTN_1>;
    gpios = <&wkup_gpio0 7 GPIO_ACTIVE_LOW>;
    };
    };
    evm_12v0: fixedregulator-evm12v0 {
    /* main supply */
    compatible = "regulator-fixed";
    regulator-name = "evm_12v0";
    regulator-min-microvolt = <12000000>;
    regulator-max-microvolt = <12000000>;
    regulator-always-on;
    regulator-boot-on;
    };
    vsys_3v3: fixedregulator-vsys3v3 {
    /* Output of LMS140 */
    compatible = "regulator-fixed";
    regulator-name = "vsys_3v3";
    regulator-min-microvolt = <3300000>;
    regulator-max-microvolt = <3300000>;
    vin-supply = <&evm_12v0>;
    regulator-always-on;
    regulator-boot-on;
    };
    vsys_5v0: fixedregulator-vsys5v0 {
    /* Output of LM5140 */
    compatible = "regulator-fixed";
    regulator-name = "vsys_5v0";
    regulator-min-microvolt = <5000000>;
    regulator-max-microvolt = <5000000>;
    vin-supply = <&evm_12v0>;
    regulator-always-on;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi,

    What is the error?

    Did you take care of the things I mentioned in https://e2e.ti.com/support/processors/f/791/p/950959/3515019#3515019 ?

    Regards,

    Karan

  • Hi,

    I can't measure the signal on Rx pin(J24 pin2). And PCAN send the can msg and connect to the J27(pin 1 and pin 3).

  • Hi,

        Maybe the tranceriver is not working.

       Beacuse i measure the pin6 and pin14 of the U70, they are low level. Pin 9 is high level. Pin12 and Pin13 are normal .

  • Hi,

    Good news. I fix the problem.

    That is my issue, i set the exp2 p06,p07,p13,p14 in wrong position.

    Now the new dts file can work fine.

    0842.k3-j721e-common-proc-board.dts.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    // SPDX-License-Identifier: GPL-2.0
    /*
    * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
    */
    /dts-v1/;
    #include "k3-j721e-som-p0.dtsi"
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/input/input.h>
    #include <dt-bindings/sound/ti-mcasp.h>
    #include <dt-bindings/net/ti-dp83867.h>
    / {
    chosen {
    stdout-path = "serial2:115200n8";
    bootargs = "console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02800000";
    };
    gpio_keys: gpio-keys {
    compatible = "gpio-keys";
    autorepeat;
    pinctrl-names = "default";
    pinctrl-0 = <&sw10_button_pins_default &sw11_button_pins_default>;
    sw10: sw10 {
    label = "GPIO Key USER1";
    linux,code = <BTN_0>;
    gpios = <&main_gpio0 0 GPIO_ACTIVE_LOW>;
    };
    sw11: sw11 {
    label = "GPIO Key USER2";
    linux,code = <BTN_1>;
    gpios = <&wkup_gpio0 7 GPIO_ACTIVE_LOW>;
    };
    };
    evm_12v0: fixedregulator-evm12v0 {
    /* main supply */
    compatible = "regulator-fixed";
    regulator-name = "evm_12v0";
    regulator-min-microvolt = <12000000>;
    regulator-max-microvolt = <12000000>;
    regulator-always-on;
    regulator-boot-on;
    };
    vsys_3v3: fixedregulator-vsys3v3 {
    /* Output of LMS140 */
    compatible = "regulator-fixed";
    regulator-name = "vsys_3v3";
    regulator-min-microvolt = <3300000>;
    regulator-max-microvolt = <3300000>;
    vin-supply = <&evm_12v0>;
    regulator-always-on;
    regulator-boot-on;
    };
    vsys_5v0: fixedregulator-vsys5v0 {
    /* Output of LM5140 */
    compatible = "regulator-fixed";
    regulator-name = "vsys_5v0";
    regulator-min-microvolt = <5000000>;
    regulator-max-microvolt = <5000000>;
    vin-supply = <&evm_12v0>;
    regulator-always-on;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX