Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

add extra chip select pin on spi1

Featured Replies

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.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.