PocketBeagle MCP2515 SPI1 device tree overlay for Macchina adapter /opt/source/bb.org-overlays/src/arm/PB-MCP2515.dts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/dts-v1/; | |
/plugin/; | |
#include <dt-bindings/gpio/gpio.h> | |
#include <dt-bindings/pinctrl/am33xx.h> | |
#include <dt-bindings/interrupt-controller/irq.h> | |
/* | |
Macchina SPI0 for SWCAN MCP2515 is PocketBeagle SPI1 | |
Macchina PB adapter J3 is PB P1 | |
Macchina PB adapter J2 is next to J3 / PB P1 | |
Macchina PB adapter J4 is PB P2 | |
Macchina PB adapter J1 is next to J4 / PB P2 | |
https://github.com/macchina/pocketbeagle-adapter-hardware/blob/master/SCH-01010%20R0%20SCHEM_RELEASE.PDF | |
https://github.com/macchina/m2-hardware/tree/master/M2-B | |
https://github.com/macchina/m2-hardware/blob/master/M2-B/Interface%20Board%20PCB.pdf | |
M2 J3 is plugs into PB adapter J2, next to PB P1 (which is PB adapter J3) | |
M2 J4 is plugs into PB adapter J1, next to PB P2 (which is PB adapter J4) | |
M2 J4.20: SWC nINT <-> P2.8 | |
M2 J3.6 : SWC_nRESET <-> P2.32 | |
M2 J4.9 : SWC_M0 <-> P2.6 | |
M2 J4.28: SWC_M1 <-> P2.18 | |
M2 J3.30: SWC_CLK <-> NC | |
M2 J4.25: SWC_SOF <-> NC | |
M2 J4.29: SWC_nRX0BF <-> NC | |
M2 J4.30: SWC_nRX1BF <-> NC | |
M2 J4.27: SPI0_CLK <-> PB adapter J2.27: SPI1_CLK | |
M2 J4.24: SPI0_MISO <-> PB adapter J2.24: SPI1_MISO | |
M2 J4.26: SPI0_MOSI <-> PB adapter J2.26: SPI1_MOSI | |
M2 J3.25: SPI0_nCS3 <-> PB adapter J1.25: SPI1_CS | |
PB adapter J4.25: SPI1_MOSI <-> PB 2.25: SPI1_MOSI | |
PB adapter J4.27: SPI1_MISO <-> PB 2.27: SPI1_MISO | |
PB adapter J4.29: SPI1_CLK <-> PB 2.29: SPI1_CLK | |
PB adapter J4.31: SPI1_CS <-> PB 2.31: SPI1_CS | |
1006 Signals 1006 headers2 1010/PB header | |
SWC nRESET J3P6 P2-32 | |
SPI0_nCS3 J3P25 P2-31 | |
SPI0 MISO J4P24 P2-27 | |
SPI0 MOSI J4P26 P2-25 | |
SPI0 CLK J4P27 P2-29 | |
SWC nINT J4P20 P2-8 | |
SWC nRX0BF J4P29 NC | |
SWC nRX1BF J4P30 NC | |
SWC SOF J4P25 NC | |
SWC CLK J3P30 NC | |
SWC M0 J4P9 P2-6 | |
SWC M1 J4P28 P2-18 | |
*/ | |
/ { | |
fragment@0 { | |
target = <&ocp>; | |
__overlay__ { | |
/* | |
M2 J4.20: SWC nINT <-> P2.8 <&gpio1 28 0>, needs GPIO input | |
M2 J3.6 : SWC_nRESET <-> P2.32 GPIO 112 / PRU0.2, <&gpio3 16 0>, needs GPIO OUTPUT | |
M2 J4.9 : SWC_M0 <-> P2.6 | |
M2 J4.28: SWC_M1 <-> P2.18 | |
*/ | |
P2_08_pinmux { status = "disabled"; }; /* SWC nINT */ | |
P2_32_pinmux { status = "disabled"; }; /* SWC nRESET */ | |
P2_25_pinmux { status = "disabled"; }; /* MOSI - gpio1_9 */ | |
P2_27_pinmux { status = "disabled"; }; /* MISO - gpio1_8 */ | |
P2_29_pinmux { status = "disabled"; }; /* CLK - gpio0_7 */ | |
P2_31_pinmux { status = "disabled"; }; /* CS - gpio0_19 */ | |
}; | |
}; | |
fragment@1 { | |
target = <&spi1>; | |
__overlay__ { | |
status = "okay"; | |
spidev@1 { | |
status = "disabled"; | |
}; | |
}; | |
}; | |
fragment@2 { | |
target = <&spi1>; | |
__overlay__ { | |
status = "okay"; | |
pinctrl-names = "default"; | |
/* | |
M2 J4.20: SWC nINT <-> P2.8 <&gpio1 28 0>, needs GPIO input | |
M2 J3.6 : SWC_nRESET <-> P2.32 GPIO 112 / PRU0.2, <&gpio3 16 0>, needs GPIO OUTPUT | |
M2 J4.9 : SWC_M0 <-> P2.6 GPIO 57, needs GPIO OUTPUT | |
M2 J4.28: SWC_M1 <-> P2.18 GPIO 47, needs GPIO OUTPUT | |
*/ | |
pinctrl-0 = < | |
/* connected to MCP2515 pin 19 _RESET | |
hopefully pullup will enable the chip */ | |
&P2_32_gpio_pu_pin | |
/* SWC nINT */ | |
&P2_08_gpio_input_pin | |
/* SPI1 */ | |
&P2_31_spi_cs_pin | |
&P2_29_spi_sclk_pin | |
&P2_27_spi_pin | |
&P2_25_spi_pin | |
>; | |
channel@0{ status = "disabled"; }; | |
channel@1{ status = "disabled"; }; | |
}; | |
}; | |
fragment@3 { | |
target = <&am33xx_pinmux>; | |
__overlay__ { | |
mcp2515_int: mcp2515_int { | |
pinctrl-single,pins = < 0x00c 0x37 >; | |
}; | |
}; | |
}; | |
fragment@4 { | |
target-path = "/"; | |
__overlay__ { | |
mcp2515_clock: mcp2515_clock { | |
compatible = "fixed-clock"; | |
#clock-cells = <0>; | |
clock-frequency = <8000000>; | |
}; | |
}; | |
}; | |
fragment@5 { | |
target = <&spi1>; | |
__overlay__ { | |
#address-cells = <1>; | |
#size-cells = <0>; | |
can0: mcp2515@0 { | |
status = "okay"; | |
reg = <0>; | |
compatible = "microchip,mcp2515"; | |
pinctrl-names = "default"; | |
pinctrl-0 = <&mcp2515_int>; | |
spi-max-frequency = <10000000>; | |
interrupt-parent = <&gpio1>; | |
interrupts = <3 2>; | |
clocks = <&mcp2515_clock>; | |
mcp251x,oscillator-frequency = <8000000>; | |
mcp251x,irq-gpios = <&gpio1 28 0>; | |
mcp251x,stay-awake = <1>; | |
mcp251x,enable-clkout = <1>; | |
}; | |
}; | |
}; | |
__overrides__ { | |
oscillator = <&mcp2515_clock>,"clock-frequency:0"; | |
spimaxfrequency = <&can0>,"spi-max-frequency:0"; | |
interrupt = <&mcp2515_int>,"pinctrl-single,pins:0",<&can0>,"interrupts:0"; | |
}; | |
}; |
The active-low MCP2515 RESET pin is connected to PocketBeagle P2.32.
I have confirmed that P2.32 is 3.3V so the pull-up configuration in this device tree overlay does seem to work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
more information in this gist:
https://gist.github.com/pdp7/283e39a63645e47c3ed86b8207bac79d