I want to use GPIO Pi16 on the 13 pin expansion header of the board.
This pin is claimed by the kernel for the ethernet MAC.
According to the SOC Datasheet this pin has the option to provide a 25 MHz clock signal for the ethernet MAC,
which is not relevant for this board.
Thanks to this Topic https://forum.armbian.com/topic/30274-armbian-build-how-to-modify-dts-file-to-change-gpio-mapping/
and the device tree source files https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts,
https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi and
https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi
i managed to create an overlay named sun50i-h616-fix-emac-pin.dts to release the GPIO pin from the ethernet MAC/kernel.
/dts-v1/;
/plugin/;
/ {
compatible = "allwinner,sun50i-h616";
fragment@0 {
target=<&pio>;
__overlay__{
ext_rgmii_pins: rgmii-pins {
pins = "PI0", "PI1", "PI2", "PI3", "PI4",
"PI5", "PI7", "PI8", "PI9", "PI10",
"PI11", "PI12", "PI13", "PI14", "PI15";
function = "emac0";
drive-strength = <40>;
};
};
};
fragment@1 {
target = <&emac0>;
__overlay__ {
pinctrl-0 = <&ext_rgmii_pins>;
};
};
};
sudo armbian-add-overlay /boot/sun50i-h616-fix-emac-pin.dts
Even though I don't really understand how to write device tree overlays, surprisingly I could compile and apply the overlay to the kernel with the command above and it did its job.
The GPIO is available now and the ethernet connection still works.
Can someone who actually understands this subject review my code and include this change in the right form at the right spot?