OSDN Git Service

h8300: Timer disable before change value.
authorYoshinori Sato <ysato@users.sourceforge.jp>
Sun, 31 May 2015 14:23:15 +0000 (23:23 +0900)
committerYoshinori Sato <ysato@users.sourceforge.jp>
Tue, 20 Oct 2015 02:30:08 +0000 (11:30 +0900)
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
drivers/clocksource/h8300_timer8.c

index f9b3b70..e83db7b 100644 (file)
@@ -100,11 +100,12 @@ static void timer8_set_next(struct timer8_priv *p, unsigned long delta)
                dev_warn(&p->pdev->dev, "delta out of range\n");
        now = timer8_get_counter(p);
        p->tcora = delta;
-       ctrl_outb(ctrl_inb(p->mapbase + _8TCR) 0x40, p->mapbase + _8TCR);
+       ctrl_outb(ctrl_inb(p->mapbase + _8TCR) & ~0x40, p->mapbase + _8TCR);
        if (delta > now)
                ctrl_outw(delta, p->mapbase + TCORA);
        else
                ctrl_outw(now + 1, p->mapbase + TCORA);
+       ctrl_outb(ctrl_inb(p->mapbase + _8TCR) | 0x40, p->mapbase + _8TCR);
 
        raw_spin_unlock_irqrestore(&p->lock, flags);
 }
@@ -146,6 +147,7 @@ static void timer8_stop(struct timer8_priv *p)
        raw_spin_lock_irqsave(&p->lock, flags);
 
        ctrl_outw(0x0000, p->mapbase + _8TCR);
+       ctrl_outw(0x0000, p->mapbase + _8TCNT);
 
        raw_spin_unlock_irqrestore(&p->lock, flags);
 }
@@ -165,7 +167,6 @@ static void timer8_clock_event_start(struct timer8_priv *p, int periodic)
        ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift);
        ced->max_delta_ns = clockevent_delta2ns(0xffff, ced);
        ced->min_delta_ns = clockevent_delta2ns(0x0001, ced);
-
        timer8_set_next(p, periodic?(p->rate + HZ/2) / HZ:0x10000);
 }