From: tomasz.figa@gmail.com (Tomasz Figa)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 06/18] clocksource: samsung_pwm_timer: Handle suspend/resume correctly
Date: Fri, 21 Jun 2013 00:12:51 +0200 [thread overview]
Message-ID: <1371766383-29077-7-git-send-email-tomasz.figa@gmail.com> (raw)
In-Reply-To: <1371766383-29077-1-git-send-email-tomasz.figa@gmail.com>
Current suspend/resume handling of the driver was broken, because:
- periodic timer was being enabled in CLOCK_EVT_MODE_RESUME mode, which
does not seem to be correct behavior looking at other platforms,
- PWM divisors need to be restored, but they were not,
- clockevent interrupt mask needs to be restored, but it was not,
- clocksource was being restored in clockevent resume callback.
This patch fixes issues mentioned above, making suspend/resume handling
in the driver correct.
Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
---
drivers/clocksource/samsung_pwm_timer.c | 42 ++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c
index ff150d1..2977043 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -196,17 +196,6 @@ static int samsung_set_next_event(unsigned long cycles,
return 0;
}
-static void samsung_timer_resume(void)
-{
- /* event timer restart */
- samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick - 1);
- samsung_time_start(pwm.event_id, true);
-
- /* source timer restart */
- samsung_time_setup(pwm.source_id, pwm.tcnt_max);
- samsung_time_start(pwm.source_id, true);
-}
-
static void samsung_set_mode(enum clock_event_mode mode,
struct clock_event_device *evt)
{
@@ -223,20 +212,29 @@ static void samsung_set_mode(enum clock_event_mode mode,
case CLOCK_EVT_MODE_UNUSED:
case CLOCK_EVT_MODE_SHUTDOWN:
- break;
-
case CLOCK_EVT_MODE_RESUME:
- samsung_timer_resume();
break;
}
}
+static void samsung_clockevent_resume(struct clock_event_device *cev)
+{
+ samsung_timer_set_prescale(pwm.event_id, pwm.tscaler_div);
+ samsung_timer_set_divisor(pwm.event_id, pwm.tdiv);
+
+ if (pwm.variant.has_tint_cstat) {
+ u32 mask = (1 << pwm.event_id);
+ writel(mask | (mask << 5), pwm.base + REG_TINT_CSTAT);
+ }
+}
+
static struct clock_event_device time_event_device = {
.name = "samsung_event_timer",
.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
.rating = 200,
.set_next_event = samsung_set_next_event,
.set_mode = samsung_set_mode,
+ .resume = samsung_clockevent_resume,
};
static irqreturn_t samsung_clock_event_isr(int irq, void *dev_id)
@@ -287,6 +285,20 @@ static void __init samsung_clockevent_init(void)
}
}
+static void samsung_clocksource_suspend(struct clocksource *cs)
+{
+ samsung_time_stop(pwm.source_id);
+}
+
+static void samsung_clocksource_resume(struct clocksource *cs)
+{
+ samsung_timer_set_prescale(pwm.source_id, pwm.tscaler_div);
+ samsung_timer_set_divisor(pwm.source_id, pwm.tdiv);
+
+ samsung_time_setup(pwm.source_id, pwm.tcnt_max);
+ samsung_time_start(pwm.source_id, true);
+}
+
static cycle_t samsung_clocksource_read(struct clocksource *c)
{
return ~readl_relaxed(pwm.source_reg);
@@ -296,6 +308,8 @@ static struct clocksource samsung_clocksource = {
.name = "samsung_clocksource_timer",
.rating = 250,
.read = samsung_clocksource_read,
+ .suspend = samsung_clocksource_suspend,
+ .resume = samsung_clocksource_resume,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};
--
1.8.2.1
next prev parent reply other threads:[~2013-06-20 22:12 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 22:12 [PATCH v2 00/18] Final Samsung PWM support cleanup Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 01/18] ARM: SAMSUNG: Unify base address definitions of timer block Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 02/18] ARM: SAMSUNG: Add new PWM platform device Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 03/18] ARM: SAMSUNG: Set PWM platform data Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 04/18] clocksource: samsung_pwm_timer: Cache clocksource register address Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 05/18] clocksource: samsung_pwm_timer: Do not use clocksource_mmio Tomasz Figa
2013-06-20 22:12 ` Tomasz Figa [this message]
2013-06-20 22:12 ` [PATCH v2 07/18] ARM: SAMSUNG: Move all platforms to new clocksource driver Tomasz Figa
2013-06-24 15:33 ` Kukjin Kim
2013-06-24 15:38 ` Tomasz Figa
2013-06-24 15:46 ` Kukjin Kim
2013-06-24 15:49 ` Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 08/18] ARM: SAMSUNG: Remove old samsung-time driver Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 09/18] ARM: SAMSUNG: Remove unused PWM timer IRQ chip code Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 10/18] pwm: samsung: Rename to pwm-samsung-legacy Tomasz Figa
2013-06-22 13:09 ` [PATCH v3 " Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 11/18] pwm: Add new pwm-samsung driver Tomasz Figa
2013-06-22 13:06 ` [PATCH v3 " Tomasz Figa
2013-06-24 15:22 ` Kukjin Kim
2013-06-24 15:37 ` Tomasz Figa
2013-06-24 17:49 ` Thierry Reding
2013-06-24 18:31 ` Tomasz Figa
2013-06-24 20:13 ` Thierry Reding
2013-06-24 20:32 ` Tomasz Figa
2013-06-24 20:53 ` Thierry Reding
2013-06-24 21:17 ` Tomasz Figa
2013-06-25 10:26 ` Thierry Reding
2013-06-25 11:19 ` Tomasz Figa
2013-06-25 15:18 ` Mark Brown
2013-06-25 16:41 ` Kukjin Kim
2013-06-25 16:30 ` Kukjin Kim
2013-06-20 22:12 ` [PATCH v2 12/18] ARM: SAMSUNG: Rework private data handling in dev-backlight Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 13/18] ARM: SAMSUNG: Modify board files to use new PWM platform device Tomasz Figa
2013-06-20 22:12 ` [PATCH v2 14/18] pwm: Remove superseded pwm-samsung-legacy driver Tomasz Figa
2013-06-20 22:13 ` [PATCH v2 15/18] ARM: SAMSUNG: Remove old PWM timer platform devices Tomasz Figa
2013-06-20 22:13 ` [PATCH v2 16/18] ARM: SAMSUNG: Remove pwm-clock infrastructure Tomasz Figa
2013-06-20 22:13 ` [PATCH v2 17/18] ARM: SAMSUNG: Remove remaining uses of plat/regs-timer.h header Tomasz Figa
2013-06-20 22:13 ` [PATCH v2 18/18] ARM: SAMSUNG: Remove " Tomasz Figa
2013-06-20 23:05 ` [PATCH v2 00/18] Final Samsung PWM support cleanup Tomasz Figa
2013-06-21 14:04 ` Arnd Bergmann
2013-06-22 13:10 ` Tomasz Figa
2013-06-22 18:01 ` Heiko Stübner
2013-06-22 18:04 ` Tomasz Figa
2013-06-24 0:14 ` Kukjin Kim
2013-06-22 19:34 ` Sylwester Nawrocki
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=1371766383-29077-7-git-send-email-tomasz.figa@gmail.com \
--to=tomasz.figa@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).