Skip to content

Commit af7d1cc

Browse files
petit-minerpopcornmix
authored andcommitted
Added support for 2 mcp2515 CAN Bus IC
See: #1018 #1049 #1052
1 parent c35c31d commit af7d1cc

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

arch/arm/boot/dts/overlays/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dtb-$(RPI_DT_OVERLAYS) += iqaudio-dac-overlay.dtb
2929
dtb-$(RPI_DT_OVERLAYS) += iqaudio-dacplus-overlay.dtb
3030
dtb-$(RPI_DT_OVERLAYS) += lirc-rpi-overlay.dtb
3131
dtb-$(RPI_DT_OVERLAYS) += mcp2515-can0-overlay.dtb
32+
dtb-$(RPI_DT_OVERLAYS) += mcp2515-can1-overlay.dtb
3233
dtb-$(RPI_DT_OVERLAYS) += mmc-overlay.dtb
3334
dtb-$(RPI_DT_OVERLAYS) += mz61581-overlay.dtb
3435
dtb-$(RPI_DT_OVERLAYS) += piscreen-overlay.dtb

arch/arm/boot/dts/overlays/README

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ Params: gpio_out_pin GPIO for output (default "17")
328328

329329

330330
Name: mcp2515-can0
331-
Info: Configures the MCP2515 CAN controller
331+
Info: Configures the MCP2515 CAN controller on spi0.0
332332
Load: dtoverlay=mcp2515-can0,<param>=<val>
333333
Params: oscillator Clock frequency for the CAN controller (Hz)
334334

@@ -337,6 +337,16 @@ Params: oscillator Clock frequency for the CAN controller (Hz)
337337
interrupt GPIO for interrupt signal
338338

339339

340+
Name: mcp2515-can1
341+
Info: Configures the MCP2515 CAN controller on spi0.1
342+
Load: dtoverlay=mcp2515-can1,<param>=<val>
343+
Params: oscillator Clock frequency for the CAN controller (Hz)
344+
345+
spimaxfrequency Maximum SPI frequence (Hz)
346+
347+
interrupt GPIO for interrupt signal
348+
349+
340350
Name: mmc
341351
Info: Selects the bcm2835-mmc SD/MMC driver, optionally with overclock
342352
Load: dtoverlay=mmc,<param>=<val>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Device tree overlay for mcp251x/can1 on spi0.1 edited by petit_miner
3+
*/
4+
5+
/dts-v1/;
6+
/plugin/;
7+
8+
/ {
9+
compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
10+
/* disable spi-dev for spi0.1 */
11+
fragment@0 {
12+
target = <&spi0>;
13+
__overlay__ {
14+
status = "okay";
15+
spidev@1{
16+
status = "disabled";
17+
};
18+
};
19+
};
20+
21+
/* the interrupt pin of the can-controller */
22+
fragment@1 {
23+
target = <&gpio>;
24+
__overlay__ {
25+
can1_pins: can1_pins {
26+
brcm,pins = <25>;
27+
brcm,function = <0>; /* input */
28+
};
29+
};
30+
};
31+
32+
/* the clock/oscillator of the can-controller */
33+
fragment@2 {
34+
target-path = "/clocks";
35+
__overlay__ {
36+
/* external oscillator of mcp2515 on spi0.1 */
37+
can1_osc: can1_osc {
38+
compatible = "fixed-clock";
39+
#clock-cells = <0>;
40+
clock-frequency = <16000000>;
41+
};
42+
};
43+
};
44+
45+
/* the spi config of the can-controller itself binding everything together */
46+
fragment@3 {
47+
target = <&spi0>;
48+
__overlay__ {
49+
/* needed to avoid dtc warning */
50+
#address-cells = <1>;
51+
#size-cells = <0>;
52+
can1: mcp2515@1 {
53+
reg = <1>;
54+
compatible = "microchip,mcp2515";
55+
pinctrl-names = "default";
56+
pinctrl-0 = <&can1_pins>;
57+
spi-max-frequency = <10000000>;
58+
interrupt-parent = <&gpio>;
59+
interrupts = <25 0x2>;
60+
clocks = <&can1_osc>;
61+
};
62+
};
63+
};
64+
__overrides__ {
65+
oscillator = <&can1_osc>,"clock-frequency:0";
66+
spimaxfrequency = <&can1>,"spi-max-frequency:0";
67+
interrupt = <&can1_pins>,"brcm,pins:0",<&can1>,"interrupts:0";
68+
};
69+
};

0 commit comments

Comments
 (0)