Skip to content

Commit

Permalink
clocksource: samsung_pwm_timer: Correct programming of clock events
Browse files Browse the repository at this point in the history
In current code, the tick count value programmed to the hardware is
always decremented by one. This is reasonable for periodic mode, since
there is one extra tick between 0 and COUNT (after reloading), but it
makes oneshot events happen 1 tick earlier than requested, because the
interrupt is triggered on transition from 1 to 0.

This patch removes the decrementation from PWM channel setup code and
moves it instead to periodic timer setup, to make both periodic and
oneshot modes work correctly.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
  • Loading branch information
Tomasz Figa authored and Olof Johansson committed Apr 28, 2013
1 parent e9b852b commit 6fe4dfd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/clocksource/samsung_pwm_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ static void samsung_time_setup(unsigned int channel, unsigned long tcnt)

tcon = __raw_readl(pwm.base + REG_TCON);

tcnt--;

tcon &= ~(TCON_START(tcon_chan) | TCON_AUTORELOAD(tcon_chan));
tcon |= TCON_MANUALUPDATE(tcon_chan);

Expand Down Expand Up @@ -187,7 +185,7 @@ static int samsung_set_next_event(unsigned long cycles,
static void samsung_timer_resume(void)
{
/* event timer restart */
samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick);
samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick - 1);
samsung_time_start(pwm.event_id, true);

/* source timer restart */
Expand All @@ -202,7 +200,7 @@ static void samsung_set_mode(enum clock_event_mode mode,

switch (mode) {
case CLOCK_EVT_MODE_PERIODIC:
samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick);
samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick - 1);
samsung_time_start(pwm.event_id, true);
break;

Expand Down

0 comments on commit 6fe4dfd

Please sign in to comment.