The i2c3 bus on the Orange Pi Zero3 is disabled by default. This post will show you how to enable it by patching the Device Tree Source (DTS) file in the mainline kernel source. Please check this post for instructions on how to build the mainline DTB for the Orange Pi Zero3.
In general there are two ways to enable an i2c bus on an ARM SBC:
- Use the DTO (Device Tree Overlay) mechanism to enable the i2c bus at runtime in U-Boot, the offical Orange Pi Zero3 OS uses this way.
- Patch the DTS file and rebuild the DTB binary.
I prefer the second way because it is eaiser for me to maintain. I am running Fedora Server on Orange Pi Zero3, I only need to use i2c3 to connect a battery backed RTC (Real Time Clock) module to the board, option 1 does not provide any advantage for me.
The patch for the DTS file
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts b/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts
index b3b1b8692125..deb0c1b38b5d 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts
@@ -10,6 +10,14 @@
/ {
model = "OrangePi Zero3";
compatible = "xunlong,orangepi-zero3", "allwinner,sun50i-h618";
+
+ aliases {
+ i2c0 = &i2c0;
+ i2c1 = &i2c1;
+ i2c2 = &i2c2;
+ i2c3 = &i2c3;
+ i2c4 = &i2c4;
+ };
};
&emac0 {
@@ -87,6 +95,13 @@ reg_dcdc3: dcdc3 {
};
};
+&i2c3 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c3_ph_pins>;
+ status = "okay";
+};
+
+
&pio {
vcc-pc-supply = <®_dldo1>;
vcc-pf-supply = <®_dldo1>;
The aliases section is to ensure that i2c3 on the board is named as i2c3 in Linux, otherwise it will be named as i2c0 in Linux.
You may need to patch the mainline dts with the previous patch before applying this patch.
To apply the patch, you can use the following commands:
git apply /tmp/0002-orangepi-zero3-dts-i2c3-linux-6.6.patch
Or use my build_dtb_orangepi_zero3.sh script to build the DTB binary.
A prebuilt DTB file with i2c3 enabled can be downloaded here