-
Notifications
You must be signed in to change notification settings - Fork 5.4k
mcp2515 overlay support to SPI bus 1 on RPI 3 #1804
Description
I tested the additional spi bus 1 on RPI3 after enabling the overlay in config.txt file
dtoverlay=spi1-3cs
the 3 chip selects spi1.0 / spi1.1 / spi1.2, all works fine with an mcp3008 ADC chip, so there is no problem at all with this bus and its corresponding chip selects.
Now, I wanted to write .dts source that supports the functionality of mcp2515 on this additional SPI bus. Very similar to what a contributor before did @petit_miner to the overlay mcp2515-can1-overlay.dts but i changed every spi0 to spi1, the mcp2515 worked but spi0.1 disappeared and the chipselects of "SPI 1" were not properly functioning, that is if connecting the mcp2515 module to spi1.0 or spi1.1 they both works which is not right.
here is my trial, i didn't change much except using spi1 instead of spi0.
the original dts file is found on your repository rpi-4.4.y , this is what i used to modify and recompile
My modifications are:
`
/*
* Device tree overlay for mcp251x/can2 on spi1.0
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
/* disable spi-dev for spi1.0 */
fragment@0 {
target = <&spi1>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
/* the interrupt pin of the can-controller */
fragment@2 {
target = <&gpio>;
__overlay__ {
can2_pins: can2_pins {
brcm,pins = <25>; /* it is the default pin and it will be overriden */
brcm,function = <0>; /* input */
};
};
};
/* the clock/oscillator of the can-controller */
fragment@3 {
target-path = "/clocks";
__overlay__ {
/* external oscillator of mcp2515 on SPI1.0 */
can2_osc: can2_osc {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <16000000>;
};
};
};
/* the spi config of the can-controller itself binding everything together */
fragment@4 {
target = <&spi1>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
can2: mcp2515@0 {
reg = <0>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <&can2_pins>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpio>;
interrupts = <25 0x2>;
clocks = <&can2_osc>;
};
};
};
__overrides__ {
oscillator = <&can2_osc>,"clock-frequency:0";
spimaxfrequency = <&can2>,"spi-max-frequency:0";
interrupt = <&can2_pins>,"brcm,pins:0",<&can2>,"interrupts:0";
};
};
`
please what i am doing wrong or what needs to be changed in order to have the mcp2515 overlay correctly uses the spi1.0 / spi1.1 / spi1.2 overlays.
Thanks
I am using Raspbian: Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux