Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1267236

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

From Yoshinori Sato <ysato@users.sourceforge.jp>
Newsgroups linux.kernel
Subject [PATCH 1/4] h8300: clocksource: Use overflow interrupt
Date 2015-11-11 16:00 +0100
Message-ID <qtF2r-46D-33@gated-at.bofh.it> (permalink)
References <qsRyF-50w-15@gated-at.bofh.it> <qtF2q-46D-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Overflow interrupt is used for moving up of a count.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 01/15] clocksource/drivers/h8300_timer8: Fix compilation error with dev_warn Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-11-09 11:10 +0100
  [PATCH 05/15] clocksource/drivers/h8300_timer8: Remove unused macros Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-11-09 11:20 +0100
  Re: [PATCH 01/15] clocksource/drivers/h8300_timer8: Fix compilation  error with dev_warn Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-11-09 11:20 +0100
  [PATCH 03/15] clocksource/drivers/h8300_tpu: Remove pointless headers for TPU Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-11-09 11:20 +0100
    Re: [PATCH 03/15] clocksource/drivers/h8300_tpu: Remove pointless headers for TPU Yoshinori Sato <ysato@users.sourceforge.jp> - 2015-11-11 16:00 +0100
  [PATCH 10/15] clocksource/drivers/h8300_timer8: Retrieve the clock rate at init time Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-11-09 11:20 +0100
  [PATCH 04/15] clocksource/drivers/h8300_timer8: Remove unused headers Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-11-09 11:20 +0100
  [PATCH 3/4] h8300: clocksource: More simplify timer8_set_next Yoshinori Sato <ysato@users.sourceforge.jp> - 2015-11-11 16:00 +0100
  [PATCH 2/4] h8300: clocksource: Counter overflow fix Yoshinori Sato <ysato@users.sourceforge.jp> - 2015-11-11 16:00 +0100
  [PATCH 4/4] h8300: clocksource: remove unused local-variable. Yoshinori Sato <ysato@users.sourceforge.jp> - 2015-11-11 16:00 +0100
  [PATCH 0/4] h8300: clock driver update Yoshinori Sato <ysato@users.sourceforge.jp> - 2015-11-11 16:00 +0100
    [PATCH 1/4] h8300: clocksource: Use overflow interrupt Yoshinori Sato <ysato@users.sourceforge.jp> - 2015-11-11 16:00 +0100
      Re: [PATCH 1/4] h8300: clocksource: Use overflow interrupt Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-11-12 18:00 +0100
    Re: [PATCH 0/4] h8300: clock driver update Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-11-12 17:30 +0100

csiph-web