linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: tglx@linutronix.de, mingo@kernel.org
Cc: linux-kernel@vger.kernel.org, stanley.chu@mediatek.com,
	baolin.wang@linaro.org, Sudeep.Holla@arm.com,
	Orson Zhai <orsonzhai@gmail.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>
Subject: [PATCH 7/7] clocksource/drivers/sprd: Register one always-on timer to compensate suspend time
Date: Thu, 26 Jul 2018 12:15:30 +0200	[thread overview]
Message-ID: <1532600131-28168-7-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1532600131-28168-1-git-send-email-daniel.lezcano@linaro.org>

From: Baolin Wang <baolin.wang@linaro.org>

Since the clocksource framework has introduced one suspend clocksource to
compensate the suspend time, this patch registers one always-on timer as
the suspend clocksource.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/timer-sprd.c | 50 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/drivers/clocksource/timer-sprd.c b/drivers/clocksource/timer-sprd.c
index ef9ebea..430cb99 100644
--- a/drivers/clocksource/timer-sprd.c
+++ b/drivers/clocksource/timer-sprd.c
@@ -156,4 +156,54 @@ static int __init sprd_timer_init(struct device_node *np)
 	return 0;
 }
 
+static struct timer_of suspend_to = {
+	.flags = TIMER_OF_BASE | TIMER_OF_CLOCK,
+};
+
+static u64 sprd_suspend_timer_read(struct clocksource *cs)
+{
+	return ~(u64)readl_relaxed(timer_of_base(&suspend_to) +
+				   TIMER_VALUE_SHDW_LO) & cs->mask;
+}
+
+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);
+
+	return 0;
+}
+
+static void sprd_suspend_timer_disable(struct clocksource *cs)
+{
+	sprd_timer_disable(timer_of_base(&suspend_to));
+}
+
+static struct clocksource suspend_clocksource = {
+	.name	= "sprd_suspend_timer",
+	.rating	= 200,
+	.read	= sprd_suspend_timer_read,
+	.enable = sprd_suspend_timer_enable,
+	.disable = sprd_suspend_timer_disable,
+	.mask	= CLOCKSOURCE_MASK(32),
+	.flags	= CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP,
+};
+
+static int __init sprd_suspend_timer_init(struct device_node *np)
+{
+	int ret;
+
+	ret = timer_of_init(np, &suspend_to);
+	if (ret)
+		return ret;
+
+	clocksource_register_hz(&suspend_clocksource,
+				timer_of_rate(&suspend_to));
+
+	return 0;
+}
+
 TIMER_OF_DECLARE(sc9860_timer, "sprd,sc9860-timer", sprd_timer_init);
+TIMER_OF_DECLARE(sc9860_persistent_timer, "sprd,sc9860-suspend-timer",
+		 sprd_suspend_timer_init);
-- 
2.7.4


  parent reply	other threads:[~2018-07-26 10:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-26 10:13 [GIT PULL] timers for 4.19 Daniel Lezcano
2018-07-26 10:15 ` [PATCH 1/7] clocksource/drivers: Set clockevent device cpumask to cpu_possible_mask Daniel Lezcano
2018-07-26 10:15   ` [PATCH 2/7] clocksource/drivers/timer-mediatek: Add system timer bindings Daniel Lezcano
2018-07-26 10:15   ` [PATCH 3/7] clocksource/drivers/timer-mediatek: Rename mtk_timer to timer-mediatek Daniel Lezcano
2018-07-26 10:15   ` [PATCH 4/7] clocksource/drivers/timer-mediatek: Use specific prefix for GPT Daniel Lezcano
2018-07-26 10:15   ` [PATCH 5/7] clocksource/drivers/timer-mediatek: Convert the driver to timer-of Daniel Lezcano
2018-07-26 10:15   ` [PATCH 6/7] clocksource/drivers/timer-mediatek: Add support for system timer Daniel Lezcano
2018-07-26 10:15   ` Daniel Lezcano [this message]
2018-07-30 11:11 ` [GIT PULL] timers for 4.19 Thomas Gleixner
2018-07-30 12:24   ` Daniel Lezcano

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=1532600131-28168-7-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=Sudeep.Holla@arm.com \
    --cc=baolin.wang@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=stanley.chu@mediatek.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;
as well as URLs for NNTP newsgroup(s).