Skip to contentSkip to conversation

mfd: rk8xx-core: Don't stop RTC during RK809/RK817 probe

PATCH In review Arash Golgol 2 participants 3 messages Nov 1 – Nov 2 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: rk8xx-core: Don't stop RTC during RK809/RK817 probe

RK809 and RK817 have an internal RTC that is managed by the rtc-rk808 driver. During probe, rk8xx-core stops the RTC by setting RTC_STOP in RK817_RTC_CTRL_REG (via rk817_pre_init_reg), and rtc-rk808 later starts it again in its own probe function.

This unnecessary stop/start cycle makes the RTC lose about 1.9 seconds on every boot or reboot, as measured on an ASUS Tinker Edge R. It also leaves the RTC stopped until the next boot if power is lost between rk8xx_probe() and rk808_rtc_probe().

Fix this by dropping the RTC_STOP entry from rk817_pre_init_reg.

Tested on ASUS Tinker Edge R (RK3399Pro), which uses an RK809 PMIC.

Fixes 586c1b4125b3 ("mfd: rk808: Add RK817 and RK809 support")
---
 drivers/mfd/rk8xx-core.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mfd/rk8xx-core.c +0 -1
index 3dcf6abfda74..887b0adf332a 100644
@@ -203,7 +203,6 @@ static const struct rk808_reg_data rk816_pre_init_reg[] = {
 };
 
 static const struct rk808_reg_data rk817_pre_init_reg[] = {
-	{RK817_RTC_CTRL_REG, RTC_STOP, RTC_STOP},
 	/* Codec specific registers */
 	{ RK817_CODEC_DTOP_VUCTL, MASK_ALL, 0x03 },
 	{ RK817_CODEC_DTOP_VUCTIME, MASK_ALL, 0x00 },
Signature · 1 line
2.34.1
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

RK809 and RK817 have an internal RTC that is managed by the rtc-rk808 driver. During probe, rk8xx-core stops the RTC by setting RTC_STOP in RK817_RTC_CTRL_REG (via rk817_pre_init_reg), and rtc-rk808 later starts it again in its own probe function.

This unnecessary stop/start cycle makes the RTC lose about 1.9 seconds on every boot or reboot, as measured on an ASUS Tinker Edge R. It also leaves the RTC stopped until the next boot if power is lost between rk8xx_probe() and rk808_rtc_probe().

Quoted 6 lines

Fix this by dropping the RTC_STOP entry from rk817_pre_init_reg.

Tested on ASUS Tinker Edge R (RK3399Pro), which uses an RK809 PMIC.

Fixes 586c1b4125b3 ("mfd: rk808: Add RK817 and RK809 support")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Arash Golgol

Hi,

Quoted 34 lines · Arash Golgol

RK809 and RK817 have an internal RTC that is managed by the rtc-rk808 driver. During probe, rk8xx-core stops the RTC by setting RTC_STOP in RK817_RTC_CTRL_REG (via rk817_pre_init_reg), and rtc-rk808 later starts it again in its own probe function.

This unnecessary stop/start cycle makes the RTC lose about 1.9 seconds on every boot or reboot, as measured on an ASUS Tinker Edge R. It also leaves the RTC stopped until the next boot if power is lost between rk8xx_probe() and rk808_rtc_probe().

Fix this by dropping the RTC_STOP entry from rk817_pre_init_reg.

Tested on ASUS Tinker Edge R (RK3399Pro), which uses an RK809 PMIC.

Fixes 586c1b4125b3 ("mfd: rk808: Add RK817 and RK809 support")
---
 drivers/mfd/rk8xx-core.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mfd/rk8xx-core.c +0 -2
index 3dcf6abfda74..887b0adf332a 100644
@@ -203,7 +203,6 @@ static const struct rk808_reg_data rk816_pre_init_reg[] = {
 };
 
 static const struct rk808_reg_data rk817_pre_init_reg[] = {
-       {RK817_RTC_CTRL_REG, RTC_STOP, RTC_STOP},
        /* Codec specific registers */
        { RK817_CODEC_DTOP_VUCTL, MASK_ALL, 0x03 },
        { RK817_CODEC_DTOP_VUCTIME, MASK_ALL, 0x00 },
--
Quoted 2 lines

2.34.1

A short follow-up on the conditions of my test, which I only understood after sending this patch.

On my board (RK809 on an RK3399Pro) rk8xx-core is built in, but rtc-rk808 was built as a module. The MFD pre-init stops the RTC about 0.4 s after boot, and the counter then stays stopped until udev loads rtc-rk808 and its probe clears STOP (about 2.2 s in my log, after init has already started). That window is what I measured as a loss of about 1.9 s per boot; with the line removed the loss is gone.

I have not yet measured this with rtc-rk808 built in. I expect the window to be much shorter in that case, but the RTC_STOP write is still unnecessary, and with a modular driver (or a deferred probe) it makes the RTC lose time on every boot.

If it helps, I can send a v2 with the commit message reworded to describe the problem in these terms.

Signature · 2 lines
Regards,
Arash Golgol