[PATCH 1/4] h8300: clocksource: Use overflow interrupt

From: Yoshinori Sato
Date: Wed Nov 11 2015 - 09:52:30 EST


Overflow interrupt is used for moving up of a count.

Signed-off-by: Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>
---
drivers/clocksource/h8300_timer16.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/clocksource/h8300_timer16.c b/drivers/clocksource/h8300_timer16.c
index f396605..53daf6a 100644
--- a/drivers/clocksource/h8300_timer16.c
+++ b/drivers/clocksource/h8300_timer16.c
@@ -14,7 +14,6 @@
#include <linux/of_irq.h>

#define TSTR 0
-#define TISRA 4
#define TISRC 6

#define TCR 0
@@ -27,10 +26,8 @@ struct timer16_priv {
unsigned long mapcommon;
unsigned short cs_enabled;
unsigned char enb;
- unsigned char imfa;
- unsigned char imiea;
unsigned char ovf;
- struct clk *clk;
+ unsigned char ovie;
};

static unsigned long timer16_get_counter(struct timer16_priv *p)
@@ -59,8 +56,8 @@ static irqreturn_t timer16_interrupt(int irq, void *dev_id)
{
struct timer16_priv *p = (struct timer16_priv *)dev_id;

- ctrl_outb(ctrl_inb(p->mapcommon + TISRA) & ~p->imfa,
- p->mapcommon + TISRA);
+ ctrl_outb(ctrl_inb(p->mapcommon + TISRC) & ~p->ovf,
+ p->mapcommon + TISRC);
p->total_cycles += 0x10000;

return IRQ_HANDLED;
@@ -91,6 +88,8 @@ static int timer16_enable(struct clocksource *cs)
p->total_cycles = 0;
ctrl_outw(0x0000, p->mapbase + TCNT);
ctrl_outb(0x83, p->mapbase + TCR);
+ ctrl_outb(ctrl_inb(p->mapcommon + TISRC) | p->ovie,
+ p->mapcommon + TISRC);
ctrl_outb(ctrl_inb(p->mapcommon + TSTR) | p->enb,
p->mapcommon + TSTR);

@@ -104,6 +103,8 @@ static void timer16_disable(struct clocksource *cs)

WARN_ON(!p->cs_enabled);

+ ctrl_outb(ctrl_inb(p->mapcommon + TISRC) & ~p->ovie,
+ p->mapcommon + TISRC);
ctrl_outb(ctrl_inb(p->mapcommon + TSTR) & ~p->enb,
p->mapcommon + TSTR);

@@ -118,6 +119,7 @@ static struct timer16_priv timer16_priv = {
.enable = timer16_enable,
.disable = timer16_disable,
.mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8),
+ .max_cycles = 0xffffffff,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
},
};
@@ -160,9 +162,9 @@ static void __init h8300_16timer_init(struct device_node *node)

timer16_priv.mapbase = (unsigned long)base[REG_CH];
timer16_priv.mapcommon = (unsigned long)base[REG_COMM];
+ timer16_priv.ovf = 1 << ch;
+ timer16_priv.ovie = 1 << (4 + ch);
timer16_priv.enb = 1 << ch;
- timer16_priv.imfa = 1 << ch;
- timer16_priv.imiea = 1 << (4 + ch);

ret = request_irq(irq, timer16_interrupt,
IRQF_TIMER, timer16_priv.cs.name, &timer16_priv);
@@ -172,7 +174,7 @@ static void __init h8300_16timer_init(struct device_node *node)
}

clocksource_register_hz(&timer16_priv.cs,
- clk_get_rate(timer16_priv.clk) / 8);
+ clk_get_rate(clk) / 8);
return;

unmap_comm:
--
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/