Enable hardware clock (RTC) on the Milk-V Pioneer
Subsystems (3)
cover Enable hardware clock (RTC) on the Milk-V Pioneer
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.
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(+)
Signature · 1 line
2.52.0
PATCH 1/1 riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer
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 ...
--- .../boot/dts/sophgo/sg2042-milkv-pioneer.dts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)
arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +21 -0
@@ -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)>,
Signature · 1 line
2.52.0
Re: [PATCH 1/1] riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer
Quoted 5 lines · Michael Orlitzky
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.
Quoted 7 lines
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.
Quoted 6 lines
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.
Quoted 7 lines
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.
Quoted 6 lines
Signed-off-by Michael Orlitzky <[email protected]>--- .../boot/dts/sophgo/sg2042-milkv-pioneer.dts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)
Best regards,
Krzysztof
Re: [PATCH 1/1] riscv: dts: sophgo: enable hardware clock (RTC) on the Milk-V Pioneer
In reply to Michael OrlitzkyQuoted 59 lines · Michael Orlitzky
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=yThe 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 <[email protected]>--- .../boot/dts/sophgo/sg2042-milkv-pioneer.dts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +14
-0@@ -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)>,
arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts sdhci-emmc-rst-pwr-pins { · line 115
Quoted 10 lines
arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +7
-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.
For commit description issues, please refer to Krzysztof's suggestions.
Thanks,
Chen