From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Cixi Geng <cixi.geng@linux.dev>,
daniel.lezcano@linaro.org, tglx@linutronix.de
Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clocksource/drivers/sprd: Enable register for timer counter from 32 bit to 64 bit
Date: Mon, 22 Sep 2025 11:53:07 +0800 [thread overview]
Message-ID: <c85ffa6a-f885-47fc-b807-609f966e34c5@linux.alibaba.com> (raw)
In-Reply-To: <20250911082507.7697-1-cixi.geng@linux.dev>
On 2025/9/11 16:25, Cixi Geng wrote:
> From: Enlin Mu <enlin.mu@unisoc.com>
>
> Using 32 bit for suspend compensation, the max compensation time is 36
> hours(working clock is 32k).In some IOT devices, the suspend time may
> be long, even exceeding 36 hours. Therefore, a 64 bit timer counter
> is needed for counting.
>
> Signed-off-by: Enlin Mu <enlin.mu@unisoc.com>
> Signed-off-by: Cixi Geng <cixi.geng@linux.dev>
> ---
> drivers/clocksource/timer-sprd.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/clocksource/timer-sprd.c b/drivers/clocksource/timer-sprd.c
> index 430cb99d8d79..742ee88b05d0 100644
> --- a/drivers/clocksource/timer-sprd.c
> +++ b/drivers/clocksource/timer-sprd.c
> @@ -30,6 +30,7 @@
> #define TIMER_VALUE_SHDW_HI 0x1c
>
> #define TIMER_VALUE_LO_MASK GENMASK(31, 0)
> +#define TIMER_VALUE_HI_MASK GENMASK(31, 0)
>
> static void sprd_timer_enable(void __iomem *base, u32 flag)
> {
> @@ -162,15 +163,23 @@ static struct timer_of suspend_to = {
>
> static u64 sprd_suspend_timer_read(struct clocksource *cs)
> {
> - return ~(u64)readl_relaxed(timer_of_base(&suspend_to) +
> - TIMER_VALUE_SHDW_LO) & cs->mask;
> + u32 lo, hi;
> +
> + lo = readl_relaxed(timer_of_base(&suspend_to) +
> + TIMER_VALUE_SHDW_LO);
> + hi = readl_relaxed(timer_of_base(&suspend_to) +
> + TIMER_VALUE_SHDW_HI);
Can you align your code like the previous code?
> + return ~(((u64)hi << 32) | lo);
> }
>
> static int sprd_suspend_timer_enable(struct clocksource *cs)
> {
> - sprd_timer_update_counter(timer_of_base(&suspend_to),
> - TIMER_VALUE_LO_MASK);
> - sprd_timer_enable(timer_of_base(&suspend_to), TIMER_CTL_PERIOD_MODE);
> + writel_relaxed(TIMER_VALUE_LO_MASK,
> + timer_of_base(&suspend_to) + TIMER_LOAD_LO);
> + writel_relaxed(TIMER_VALUE_HI_MASK,
> + timer_of_base(&suspend_to) + TIMER_LOAD_HI);
> + sprd_timer_enable(timer_of_base(&suspend_to),
> + TIMER_CTL_PERIOD_MODE|TIMER_CTL_64BIT_WIDTH);
Ditto. Otherwise LGTM.
>
> return 0;
> }
> @@ -186,7 +195,7 @@ static struct clocksource suspend_clocksource = {
> .read = sprd_suspend_timer_read,
> .enable = sprd_suspend_timer_enable,
> .disable = sprd_suspend_timer_disable,
> - .mask = CLOCKSOURCE_MASK(32),
> + .mask = CLOCKSOURCE_MASK(64),
> .flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP,
> };
>
next prev parent reply other threads:[~2025-09-22 3:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 8:25 Cixi Geng
2025-09-22 3:53 ` Baolin Wang [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-05-22 8:14 Enlin Mu
2024-06-05 3:15 ` Chunyan Zhang
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=c85ffa6a-f885-47fc-b807-609f966e34c5@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=cixi.geng@linux.dev \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=tglx@linutronix.de \
--cc=zhang.lyra@gmail.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
all inboxes | Powered by JetHome®