Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Vitaly Wool <vitalywool@gmail.com>
To: ralf@linux-mips.org
Cc: linux-mips@linux-mips.org
Subject: [PATCH][respin] pnx8550: fix system timer support
Date: Thu, 28 Dec 2006 17:14:05 +0300	[thread overview]
Message-ID: <20061228171405.b1e3eed8.vitalywool@gmail.com> (raw)

Hello Ralf,

the patch inlined below restores proper time accounting for PNX8550-based boards. It also gets rid of #ifdef in the generic code which becomes unnecessary then.

It's functionally identical to the previous patch with the same name but it has minor comments from Atsushi and Sergei taken into account.

 arch/mips/kernel/time.c                 |    2 -
 arch/mips/philips/pnx8550/common/time.c |   45 +++++++++++++++++++++++++++-----
 2 files changed, 38 insertions(+), 9 deletions(-)

Signed-off-by: Vitaly Wool <vwool@ru.mvista.com>

Index: linux-mips.git/arch/mips/kernel/time.c
===================================================================
--- linux-mips.git.orig/arch/mips/kernel/time.c
+++ linux-mips.git/arch/mips/kernel/time.c
@@ -94,10 +94,8 @@ static void c0_timer_ack(void)
 {
 	unsigned int count;
 
-#ifndef CONFIG_SOC_PNX8550	/* pnx8550 resets to zero */
 	/* Ack this timer interrupt and set the next one.  */
 	expirelo += cycles_per_jiffy;
-#endif
 	write_c0_compare(expirelo);
 
 	/* Check to see if we have missed any timer interrupts.  */
Index: linux-mips.git/arch/mips/philips/pnx8550/common/time.c
===================================================================
--- linux-mips.git.orig/arch/mips/philips/pnx8550/common/time.c
+++ linux-mips.git/arch/mips/philips/pnx8550/common/time.c
@@ -29,11 +29,22 @@
 #include <asm/hardirq.h>
 #include <asm/div64.h>
 #include <asm/debug.h>
+#include <asm/time.h>
 
 #include <int.h>
 #include <cm.h>
 
-extern unsigned int mips_hpt_frequency;
+static unsigned long cpj;
+
+static cycle_t hpt_read(void)
+{
+	return read_c0_count2();
+}
+
+static void timer_ack(void)
+{
+	write_c0_compare(cpj);
+}
 
 /*
  * pnx8550_time_init() - it does the following things:
@@ -68,27 +79,47 @@ void pnx8550_time_init(void)
 	 * HZ timer interrupts per second.
 	 */
 	mips_hpt_frequency = 27UL * ((1000000UL * n)/(m * pow2p));
+	cpj = (mips_hpt_frequency + HZ / 2) / HZ;
+	timer_ack();
+
+	/* Setup Timer 2 */
+	write_c0_count2(0);
+	write_c0_compare2(0xffffffff);
+
+	clocksource_mips.read = hpt_read;
+	mips_timer_ack = timer_ack;
+}
+
+static irqreturn_t monotonic_interrupt(int irq, void *dev_id)
+{
+	/* Timer 2 clear interrupt */
+	write_c0_compare2(-1);
+	return IRQ_HANDLED;
 }
 
+static struct irqaction monotonic_irqaction = {
+	.handler = monotonic_interrupt,
+	.flags = IRQF_DISABLED,
+	.name = "Monotonic timer",
+};
+
 void __init plat_timer_setup(struct irqaction *irq)
 {
 	int configPR;
 
 	setup_irq(PNX8550_INT_TIMER1, irq);
+	setup_irq(PNX8550_INT_TIMER2, &monotonic_irqaction);
 
-	/* Start timer1 */
+	/* Timer 1 start */
 	configPR = read_c0_config7();
 	configPR &= ~0x00000008;
 	write_c0_config7(configPR);
 
-	/* Timer 2 stop */
+	/* Timer 2 start */
 	configPR = read_c0_config7();
-	configPR |= 0x00000010;
+	configPR &= ~0x00000010;
 	write_c0_config7(configPR);
 
-	write_c0_count2(0);
-	write_c0_compare2(0xffffffff);
-
 	/* Timer 3 stop */
 	configPR = read_c0_config7();
 	configPR |= 0x00000020;

             reply	other threads:[~2006-12-28 14:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-28 14:14 Vitaly Wool [this message]
2006-12-28 16:16 ` [PATCH][respin] pnx8550: fix system timer support Atsushi Nemoto
2006-12-28 16:20   ` Vitaly Wool
2007-01-02 14:05     ` Daniel Laird
2007-01-02 16:06       ` Atsushi Nemoto
2007-01-02 17:17         ` Daniel Laird
2007-01-03 13:37           ` Daniel Laird
2007-01-03 13:57           ` Atsushi Nemoto
2007-01-03 14:34             ` Daniel Laird

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=20061228171405.b1e3eed8.vitalywool@gmail.com \
    --to=vitalywool@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.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