Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Orlitzky <michael@orlitzky.com>
To: unicorn_wang@outlook.com, inochiama@gmail.com
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
	alex@ghiti.fr, devicetree@vger.kernel.org,
	sophgo@lists.linux.dev, linux-riscv@lists.infradead.org
Subject: [PATCH 1/1] riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer
Date: Mon,  5 Jan 2026 07:01:29 -0500	[thread overview]
Message-ID: <20260105120129.58895-2-michael@orlitzky.com> (raw)
In-Reply-To: <20260105120129.58895-1-michael@orlitzky.com>

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@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@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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2026-01-05 12:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 12:01 [PATCH 0/1] Enable hardware clock (RTC) on the Milk-V Pioneer Michael Orlitzky
2026-01-05 12:01 ` Michael Orlitzky [this message]
2026-01-05 12:07   ` [PATCH 1/1] riscv: dts: sophgo: enable " Krzysztof Kozlowski
2026-01-06  2:10   ` Chen Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260105120129.58895-2-michael@orlitzky.com \
    --to=michael@orlitzky.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=inochiama@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=robh@kernel.org \
    --cc=sophgo@lists.linux.dev \
    --cc=unicorn_wang@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox