Mcp2515 overlay for BananaPi M64

Hi,

I have working can interface on BPi-M2-zero. The CAN hardware is Waveshare rs485-can-hat board that uses microchip mcp2515. I would like to use the same can board with BPi-M64. Unfortunatelly, I have a problem with overlay.

I found that this chip has external interrupts on ports: B, G, H, L. I selected PB6 for that and rewired mcp2515 to that pin. The other difference is that M64 has spi1 wired to 40-pins connector (it was spi0 in M2-zero case).

When overlay is loaded following error is reported:

Applying kernel provided DT overlay sun50i-a64-mcp2515-can0.dtbo
failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND

What I am doing wrong? Regards, Piotr Romaniuk

PS overlay is built by:

$ dtc -O dtb -o sun50i-a64-mcp2515-can0.dtbo sun50i-a64-mcp2515-can0.dts
sun50i-a64-mcp2515-can0.dts:37.12-47.6: Warning (unit_address_vs_reg): /fragment@2/__overlay__/mcp2515: node has a reg or ranges property, but no unit name
sun50i-a64-mcp2515-can0.dts:37.12-47.6: Warning (spi_bus_reg): /fragment@2/__overlay__/mcp2515: SPI bus unit address format error, expected "0"
sun50i-a64-mcp2515-can0.dts:9.15-17.5: Warning (avoid_unnecessary_addr_size): /fragment@0/__overlay__: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property

I copy .dtbo file to /boot/dtb/allwinner/overlay/

In armbianEnv.txt there is a line: overlay=mcp2515-can0

kernel: Linux 5.15.80-sunxi64

My overlay:

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun50i-a64";

        fragment@0 {
                target-path = "/clocks";
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <1>;
                        can0_osc_fixed: can0_osc_fixed {
                                compatible = "fixed-clock";
                                #clock-cells = <0>;
                                clock-frequency  = <12000000>;
                        };
                };
        };

        fragment@1 {
                target = <&pio>;
                __overlay__ {
                        can0_pin_irq: can0_pin_irq {
                                pins = "PB6";
                                function = "irq";
                                bias-pull-up;
                        };
                };
        };

        fragment@2 {
                target = <&spi1>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "okay";
                        mcp2515 {
                                reg = <0>;
                                compatible = "microchip,mcp2515";
                                pinctrl-names = "default";
                                pinctrl-0 = <&can0_pin_irq>;
                                spi-max-frequency = <2000000>;
                                interrupt-parent = <&pio>;
                                interrupts = <1 6 2>; /* PB6IRQ_TYPE_falling-edg
e */
                                clocks = <&can0_osc_fixed>;
                                status = "okay";
                        };
                };
        };
};

I checked in /sys/firmware/basic/… There is no /clocks path in device tree.

The part:

fragment@0 {
                target-path = "/clocks";

Should be replaced by:

fragment@0 {
                target-path = "/";

Alias for spi1 sould be added as well.

PR