AnsweredAssumed Answered

How to Enable FlexCAN in device tree on iMX6QP custom board

Question asked by Kishor R on Feb 10, 2017
Latest reply on Apr 13, 2017 by roger lee

I am trying to enable FlexCAN bus 1 and 2 on iMX6QP based custom hardware.
The two CAN buses are connected from iMX6 as below

GPIO_7    : CAN-TX1
GPIO_8    : CAN-RX1
GPIO-4-5  : CAN-STBY1

KEY_COL4 : CAN-TX2
KEY_ROW4 : CAN-RX2
GPIO-6-10 : CAN-STBY2

 

The device tree is defined as below:
arch/arm/boot/dts/imx6qdl.dtsi
================================

 

/ {
        aliases {
                flexcan0 = &flexcan1;
                flexcan1 = &flexcan2;
                gpio0 = &gpio1;
...
...

 

  soc {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "simple-bus";
                interrupt-parent = <&intc>;
                ranges;

 

                caam_sm: caam-sm@00100000 {
                        compatible = "fsl,imx6q-caam-sm";
                        reg = <0x00100000 0x3fff>;
                };

 

     flexcan1: can@02090000 {
                                compatible = "fsl,imx6q-flexcan";
                                reg = <0x02090000 0x4000>;
                                interrupts = <0 110 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&clks IMX6QDL_CLK_CAN1_IPG>,
                                         <&clks IMX6QDL_CLK_CAN1_SERIAL>;
                                clock-names = "ipg", "per";
                                stop-mode = <&gpr 0x34 28 0x10 17>;
                                status = "enabled";
                        };

 

    flexcan2: can@02094000 {
                                compatible = "fsl,imx6q-flexcan";
                                reg = <0x02094000 0x4000>;
                                interrupts = <0 111 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&clks IMX6QDL_CLK_CAN2_IPG>,
                                         <&clks IMX6QDL_CLK_CAN2_SERIAL>;
                                clock-names = "ipg", "per";
                                stop-mode = <&gpr 0x34 29 0x10 18>;
                                status = "enabled";
                        };

 


arch/arm/boot/dts/imx6q.dtsi
=====================

 

&flexcan1 {
                 pinctrl_flexcan1_1: flexcan1grp {
                fsl,pins = <
                        MX6QDL_PAD_GPIO_7__FLEXCAN1_TX          0x1b0b0
                        MX6QDL_PAD_GPIO_8__FLEXCAN1_RX          0x1b0b0
                >;
        };
};

 


&flexcan2 {
        pinctrl_flexcan2_1: flexcan2grp {
                fsl,pins = <
                        MX6QDL_PAD_KEY_COL4__FLEXCAN2_TX        0x1b0b0
                        MX6QDL_PAD_KEY_ROW4__FLEXCAN2_RX        0x1b0b0
                >;
        };

 

};

 

arch/arm/boot/dts/imx6q-sabresd.dts
===================================

 

&flexcan1 {

 

         status = "okay";
};

 

&flexcan2 {

 

         status = "okay";
};

 

I observe CAN0 and CAN1 interfaces are up.
root@QPU2:~# ifconfig can0
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          UP RUNNING NOARP  MTU:16  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:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:142


root@QPU2:~# ifconfig can1
can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          UP RUNNING NOARP  MTU:16  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:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:143

 

I have connected both the CAN ports to KOMODO CAN analyser. When I send packets I do not see any packets sent out from either of the ports. I have run the internal loopback test which is successful.

 

ip link set can0 up type can bitrate 125000
ifconfig can0 up
ifconfig can0
cansend can0 100#1122334455667788

 

I suspect some issue with the device tree configuration. Appreciate if anyone could provide some pointers to the problem I am facing.

 

Thanks
Kishor

Outcomes