This is similar to 20230710 - Enable CAN on MangoPi, but I was not able to finish it.
- Linux example and docs of the overlay
- Another example of how to implement it
- People adding the CAN Controller on OrangePi
Connections
In the board the is silkscreen to say what is the pin 1 of the SPI interface.
Get the SPI reg
$/sys/class/spi_master# ls
spi0
Overlay
/dts-v1/;
/plugin/;
/ {
compatible = "allwinner,d1-nezha\0allwinner,sun20i-d1";
fragment@0 {
target-path = "/";
__overlay__ {
#address-cells = <1>;
#size-cells = <1>;
/* External crystal oscillator on the board */
can0_osc_fixed: can0_osc_fixed {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <8000000>;
phandle = <0x81>;
};
};
};
fragment@1 {
target = <0x23>; // pinctrl@2000000
__overlay__ {
can0_pin_irq: can0_pin_irq {
pins = "PC1";
function = "irq";
phandle = <0x85>;
};
};
};
fragment@2 {
target = <&spi@4026000>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
mcp2515 {
reg = <0>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <0x85>;
spi-max-frequency = <10000000>;
interrupt-parent = <0x24>; // pinctrl@2000000
interrupts = <0x85 0x04>; // IRQ LINE
clocks = <0x81>;
status = "okay";
};
};
};
};