CAN over SPI

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN over SPI

1,311 Views
BaNe
Contributor IV

Hi

I am using im8mq-evk board to test out a SPI to CAN converter. Namely the MCP2515 chip. I connected to ECSPI1 Signals with disconnecting the stuff on the evk board.

I removed all other uses of the pins from DTS file and added the pin configuration to iomuxc

        pinctrl_ecspi1: ecspi1grp {
            fsl,pins = <
                MX8MQ_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI        0x10b0
                MX8MQ_IOMUXC_ECSPI1_MISO_ECSPI1_MISO        0x10b0
                MX8MQ_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK        0x10b0
            >;
        };

        pinctrl_ecspi1_cs: ecspi1grp_cs {
            fsl,pins = <
                MX8MQ_IOMUXC_ECSPI1_SS0_ECSPI1_SS0        0x10b0
            >;
        };

        pinctrl_ecspi1irq: ecspi1irqgrp {
            fsl,pins = <
                MX8MQ_IOMUXC_UART3_TXD_GPIO5_IO27        0x4000056
            >;
        };

I also added DTS node for the clock of the chip and for ECSPI1

/ {

...

        clocks {
        can0_osc: clock@7 {
            compatible = "fixed-clock";
            #clock-cells = <0>;
            clock-frequency = <8000000>;
        };
    };

}

&ecspi1 {

    fsl,spi-num-chipselects = <1>;
    cs-gpios = <&gpio5 9 GPIO_ACTIVE_LOW>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_ecspi1_cs>;
    status = "okay";

    can0: mcp2515@0 {

        #address-cells = <1>;
        #size-cells = <0>;
            reg = <0>;
            compatible = "microchip,mcp2515";
        spi-max-frequency = <10000000>;
            clocks = <&can0_osc>;
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_ecspi1irq>;
            interrupt-parent = <&gpio5>;
            interrupts = <27 IRQ_TYPE_EDGE_FALLING>;
    };

};

For the kernel I added builtin support for mcp251x devices.

After booting up I do not get a clock signal on SCLK pin. I do not get any recognized devices on SPI bus. But I can see that device support is available.

root@imx8mqevk:~# ls /sys/bus/spi/drivers
ds3234  m25p80  mcp251x  mmc_spi  mtd_dataflash  spidev
root@imx8mqevk:~# ls /sys/bus/spi/devices/
root@imx8mqevk:~#

Labels (2)
Tags (3)
0 Kudos
1 Reply

941 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Bastian,

you may find useful this document

Interfacing FXLS8471Q with i.MX6Q 

Other useful threads will be

How to check if SPI is working? 

Bringing spidev ioctl handlers to user space and running spidev_test app on imx6. 


Regards,
Carlos
NXP Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos