From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
Cc: a.zummo@towertech.it, linux-rtc@vger.kernel.org,
linux-kernel@vger.kernel.org, TimGuo-oc@zhaoxin.com,
CooperYan@zhaoxin.com, QiyuanWang@zhaoxin.com,
HerryYang@zhaoxin.com, CobeChen@zhaoxin.com,
YanchenSun@zhaoxin.com
Subject: Re: [PATCH] rtc: Fix set RTC time delay 500ms on some Zhaoxin SOCs
Date: Mon, 16 Aug 2021 10:24:01 +0200 [thread overview]
Message-ID: <YRogod0HB4d7Og4E@piout.net> (raw)
In-Reply-To: <1629121638-3246-1-git-send-email-TonyWWang-oc@zhaoxin.com>
Hello,
On 16/08/2021 21:47:18+0800, Tony W Wang-oc wrote:
> When the RTC divider is changed from reset to an operating time base,
> the first update cycle should be 500ms later. But on some Zhaoxin SOCs,
> this first update cycle is one second later.
>
> So set RTC time on these Zhaoxin SOCs will causing 500ms delay.
>
Can you explain what is the relationship between writing the divider and
the 500ms delay?
Isn't the issue that you are using systohc and set_offset_nsec is set to
NSEC_PER_SEC / 2 ?
> Skip setup RTC divider on these SOCs in mc146818_set_time to fix it.
>
> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
> ---
> drivers/rtc/rtc-mc146818-lib.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
> index dcfaf09..322f94b 100644
> --- a/drivers/rtc/rtc-mc146818-lib.c
> +++ b/drivers/rtc/rtc-mc146818-lib.c
> @@ -190,8 +190,18 @@ int mc146818_set_time(struct rtc_time *time)
> spin_lock_irqsave(&rtc_lock, flags);
> save_control = CMOS_READ(RTC_CONTROL);
> CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
> +
> +#ifdef CONFIG_X86
> + if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR ||
> + boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) &&
> + (boot_cpu_data.x86 <= 7 && boot_cpu_data.x86_model <= 59))) {
> + save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
> + CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
> + }
> +#else
> save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
> CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
> +#endif
>
> #ifdef CONFIG_MACH_DECSTATION
> CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
> @@ -209,7 +219,15 @@ int mc146818_set_time(struct rtc_time *time)
> #endif
>
> CMOS_WRITE(save_control, RTC_CONTROL);
> +
> +#ifdef CONFIG_X86
> + if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR ||
> + boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) &&
> + (boot_cpu_data.x86 <= 7 && boot_cpu_data.x86_model <= 59)))
> + CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
> +#else
> CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
> +#endif
>
> spin_unlock_irqrestore(&rtc_lock, flags);
>
> --
> 2.7.4
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2021-08-16 8:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 13:47 [PATCH] rtc: Fix set RTC time delay 500ms on some Zhaoxin SOCs Tony W Wang-oc
2021-08-16 8:24 ` Alexandre Belloni [this message]
2021-08-16 10:03 ` Tony W Wang-oc
2021-08-16 12:36 ` Alexandre Belloni
2021-08-17 11:09 ` tonywwang-oc
2021-08-17 13:21 ` Alexandre Belloni
2021-08-18 3:54 ` tonywwang-oc
2021-10-26 11:42 ` tonywwang-oc
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=YRogod0HB4d7Og4E@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=CobeChen@zhaoxin.com \
--cc=CooperYan@zhaoxin.com \
--cc=HerryYang@zhaoxin.com \
--cc=QiyuanWang@zhaoxin.com \
--cc=TimGuo-oc@zhaoxin.com \
--cc=TonyWWang-oc@zhaoxin.com \
--cc=YanchenSun@zhaoxin.com \
--cc=a.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
/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