[PATCH 1/1] riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer
Michael Orlitzky
michael at orlitzky.com
Mon Jan 5 04:01:29 PST 2026
These boards have a working hardware clock if you put a CR-1220
battery in them. Let's enable it:
1. Enable the (already defined) i2c0 by overriding the default
status = "disabled" with "okay".
2. Define the rtc on &i2c0. This is more or less the example from the
documentation (devicetree/bindings/rtc/rtc-ds1307.yaml), and it was
present in the same form in an earlier 6.1.x vendor kernel.
3. Copy the pinctrl stuff from &i2c1 and update the PINMUX constants
with the IIC0 values from dt-bindings/pinctrl/pinctrl-sg2042.h.
Afterwards, the new I2C and RTC can be enabled with,
* CONFIG_I2C_DESIGNWARE_CORE=y
* CONFIG_I2C_DESIGNWARE_PLATFORM=y
* CONFIG_RTC_DRV_DS1307=y
The new I2C should appear under /sys/devices/platform/soc, and with
any luck you'll have a clock the next time you boot:
[ T367] rtc-ds1307 5-0068: registered as rtc0
[ T367] rtc-ds1307 5-0068: setting system clock to ...
Signed-off-by: Michael Orlitzky <michael at orlitzky.com>
---
.../boot/dts/sophgo/sg2042-milkv-pioneer.dts | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts b/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts
index 54d8386bf9c0..ecf8c1e29079 100644
--- a/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts
+++ b/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts
@@ -52,6 +52,17 @@ &emmc {
status = "okay";
};
+&i2c0 {
+ pinctrl-0 = <&i2c0_cfg>;
+ pinctrl-names = "default";
+ status = "okay";
+
+ rtc: rtc at 68 {
+ compatible = "dallas,ds1307";
+ reg = <0x68>;
+ };
+};
+
&i2c1 {
pinctrl-0 = <&i2c1_cfg>;
pinctrl-names = "default";
@@ -89,6 +100,16 @@ sdhci-emmc-rst-pwr-pins {
};
};
+ i2c0_cfg: i2c0-cfg {
+ i2c0-pins {
+ pinmux = <PINMUX(PIN_IIC0_SDA, 0)>,
+ <PINMUX(PIN_IIC0_SCL, 0)>;
+ bias-pull-up;
+ drive-strength-microamp = <26800>;
+ input-schmitt-enable;
+ };
+ };
+
i2c1_cfg: i2c1-cfg {
i2c1-pins {
pinmux = <PINMUX(PIN_IIC1_SDA, 0)>,
--
2.52.0
More information about the linux-riscv
mailing list