Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Enable hardware clock (RTC) on the Milk-V Pioneer
@ 2026-01-05 12:01 Michael Orlitzky
  2026-01-05 12:01 ` [PATCH 1/1] riscv: dts: sophgo: enable " Michael Orlitzky
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Orlitzky @ 2026-01-05 12:01 UTC (permalink / raw)
  To: unicorn_wang, inochiama
  Cc: robh, krzk+dt, conor+dt, pjw, palmer, aou, alex, devicetree,
	sophgo, linux-riscv

Add the DTS entries needed for the hardware clock on the Milk-V
Pioneer. I was able to get this working with an earlier (6.1.x) vendor
kernel, but it is disabled in the upstream DTS.

AFAIK this is the only hardware support remaining to be upstreamed.

Link: https://github.com/sophgo/linux/wiki#sg2042

Michael Orlitzky (1):
  riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer

 .../boot/dts/sophgo/sg2042-milkv-pioneer.dts  | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

-- 
2.52.0


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer
  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
  2026-01-05 12:07   ` Krzysztof Kozlowski
  2026-01-06  2:10   ` Chen Wang
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Orlitzky @ 2026-01-05 12:01 UTC (permalink / raw)
  To: unicorn_wang, inochiama
  Cc: robh, krzk+dt, conor+dt, pjw, palmer, aou, alex, devicetree,
	sophgo, linux-riscv

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer
  2026-01-05 12:01 ` [PATCH 1/1] riscv: dts: sophgo: enable " Michael Orlitzky
@ 2026-01-05 12:07   ` Krzysztof Kozlowski
  2026-01-06  2:10   ` Chen Wang
  1 sibling, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-05 12:07 UTC (permalink / raw)
  To: Michael Orlitzky, unicorn_wang, inochiama
  Cc: robh, krzk+dt, conor+dt, pjw, palmer, aou, alex, devicetree,
	sophgo, linux-riscv

On 05/01/2026 13:01, Michael Orlitzky wrote:
> 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".

Do not describe the diff. This is obvious. Explain WHY you are doing all
this.

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

Drop, irrelevant.

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

Drop, irrelevant. You describe here hardware, not Linux kernel config.
> 

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

Drop, obvious.

> 
> Signed-off-by: Michael Orlitzky <michael@orlitzky.com>
> ---
>  .../boot/dts/sophgo/sg2042-milkv-pioneer.dts  | 21 +++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 


Best regards,
Krzysztof

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer
  2026-01-05 12:01 ` [PATCH 1/1] riscv: dts: sophgo: enable " Michael Orlitzky
  2026-01-05 12:07   ` Krzysztof Kozlowski
@ 2026-01-06  2:10   ` Chen Wang
  1 sibling, 0 replies; 4+ messages in thread
From: Chen Wang @ 2026-01-06  2:10 UTC (permalink / raw)
  To: Michael Orlitzky, inochiama
  Cc: robh, krzk+dt, conor+dt, pjw, palmer, aou, alex, devicetree,
	sophgo, linux-riscv


On 1/5/2026 8:01 PM, Michael Orlitzky wrote:
> 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)>,

DTS changes LGTM.

Reviewed-by: Chen Wang <unicorn_wang@outlook.com>

For commit description issues, please refer to Krzysztof's suggestions.

Thanks,

Chen


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-06  2:11 UTC | newest]

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox