Jump to content

Recommended Posts

Posted (edited)

Hello

 

I am trying to configure two mcp2515 CAN controllers and bind them to the mcp251x kernel driver.

 

I managed to get the first one working using Chip Select 0

 

I saw that cs-gpio can be used to use a GPIO pin as an extra CHIP select

 

Is it possible to directly map de second CHIP SELECT using a GPIO on the following device tree overlay ?

 

/dts-v1/;
/plugin/;

/ {
    compatible = "rockchip,rockpi","rockchip,rk3399";

    /* enable spi-dev for spi1 */
    fragment@0 {
        target = <&spi1>;
        __overlay__ {
            status = "okay";
        };
    };

    /* the interrupt pin of the can-controller */
    /* Hat uses physical pin 22 (GPIO4_D5) which translate to gpio 157 */ 

    fragment@1 {
    target = <&pinctrl>;
        __overlay__ {
            can1_pins: can1_pins {
                rockchip,pins = <4 157 0 &pcfg_output_low>;
            };
        };
    };

    /* the clock/oscillator of the can-controller */
    fragment@2 {
        target-path = "/";
        __overlay__ {
            /* external oscillator of mcp2515 on SPI1 */

            can1_osc: can1_osc {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency  = <16000000>;
                clock-output-names = "can1_osc";
            };
        };
    };

    /* the spi config of the can-controller itself binding everything together */

    fragment@3 {
        target = <&spi1>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>;
            can1: mcp2515@1 {
                reg = <1>;
                compatible = "microchip,mcp2515";
                pinctrl-names = "default";
                #pinctrl-0 = <&can1_pins>;
                spi-max-frequency = <10000000>;
                interrupt-parent = <&gpio4>;
                interrupts = <22 8>; 
                clocks = <&can1_osc>;
            };
        };
    };


    __overrides__ {
        oscillator = <&can1_osc>,"clock-frequency:0";
        spimaxfrequency = <&can1>,"spi-max-frequency:0";
        interrupt = <&can1_pins>,"rockchip,pins:0",<&can1>,"interrupts:0";
    };

};

 

Thanks in advance

Edited by Duarte Dias
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines