All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Oberritter <obi@saftware.de>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] 2/3 Support mpc8xx watchdog of dbox2 (2.4.22-pre6)
Date: 19 Jul 2003 15:30:24 +0200	[thread overview]
Message-ID: <1058621424.585.22.camel@localhost> (raw)
In-Reply-To: <1058620870.585.15.camel@localhost>

[-- Attachment #1: Type: text/plain, Size: 164 bytes --]

This one adds support for the watchdog timer which is unfortunately
active before the kernel starts and can not be disabled without patching
the binary bootloader.

[-- Attachment #2: linux-2.4.22-pre6-dbox2-watchdog.diff --]
[-- Type: text/x-patch, Size: 3276 bytes --]

diff -Naur linux-2.4.22-pre6/arch/ppc/kernel/m8xx_setup.c linux-2.4.22-pre6-dbox2/arch/ppc/kernel/m8xx_setup.c
--- linux-2.4.22-pre6/arch/ppc/kernel/m8xx_setup.c	2003-06-13 16:51:31.000000000 +0200
+++ linux-2.4.22-pre6-dbox2/arch/ppc/kernel/m8xx_setup.c	2003-07-15 09:16:34.000000000 +0200
@@ -117,6 +117,22 @@
 	printk ("timebase_interrupt()\n");
 }
 
+#ifdef CONFIG_DBOX2
+void m8xx_reset_watchdog(void)
+{
+	((volatile immap_t *)IMAP_ADDR)->im_siu_conf.sc_swsr = 0x556c; /* write magic1 */
+	((volatile immap_t *)IMAP_ADDR)->im_siu_conf.sc_swsr = 0xaa39; /* write magic2 */
+}
+
+void pit_interrupt(int irq, void * dev, struct pt_regs * regs)
+{
+	m8xx_reset_watchdog();
+
+	/* clear irq */
+	((volatile immap_t *)IMAP_ADDR)->im_sit.sit_piscr |= PISCR_PS;
+}
+#endif
+
 /* The decrementer counts at the system (internal) clock frequency divided by
  * sixteen, or external oscillator divided by four.  We force the processor
  * to use system clock divided by sixteen.
@@ -125,6 +141,10 @@
 {
 	bd_t	*binfo = (bd_t *)__res;
 	int freq, fp, divisor;
+#ifdef CONFIG_DBOX2
+	unsigned long sypcr;
+	unsigned short pitc, swtc, swp;
+#endif	
 
 	/* Unlock the SCCR. */
 	((volatile immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk = ~KAPWR_KEY;
@@ -184,6 +204,42 @@
 	if (request_irq(DEC_INTERRUPT, timebase_interrupt, 0, "tbint",
 				NULL) != 0)
 		panic("Could not allocate timer IRQ!");
+
+#ifdef CONFIG_DBOX2
+	sypcr = ((volatile immap_t *)IMAP_ADDR)->im_siu_conf.sc_sypcr;
+
+	if ((sypcr >> 2) & 0x1) {
+	    m8xx_reset_watchdog();
+
+	    if (sypcr >> 16)
+		swtc = sypcr >> 16;
+	    else
+		swtc = 0xFFFF;
+
+	    if (sypcr & 0x1)
+		swp = 2048;
+	    else
+		swp = 1;
+
+#define PITRTCLK 8192
+
+	    /* Fire trigger if half of the wdt ticked down */
+	    if ((swp * swtc) > (UINT_MAX / PITRTCLK))
+		pitc = swtc * swp / binfo->bi_intfreq * PITRTCLK / 2;
+	    else
+		pitc = PITRTCLK * swtc * swp / binfo->bi_intfreq / 2;
+
+	    ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_pitc = pitc << 16;
+	    ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_piscr = (mk_int_int_mask(PIT_INTERRUPT) << 8) | PISCR_PIE | PISCR_PTE;
+
+	    if (request_8xxirq(PIT_INTERRUPT, pit_interrupt, 0, "pit", NULL) != 0)
+		    panic("mpc8xx-wdt: could not allocate pit irq!");
+
+	    printk(KERN_INFO "mpc8xx-wdt: active wdt found (SWTC: 0x%04X, SWP: 0x%01X)\n", sypcr >> 16, sypcr & 0x1);
+	    printk(KERN_INFO "mpc8xx-wdt: keep-alive trigger activated (PITC: 0x%04X)\n", pitc);
+	}
+#endif
+
 }
 
 /* The RTC on the MPC8xx is an internal register.
diff -Naur linux-2.4.22-pre6/arch/ppc/kernel/time.c linux-2.4.22-pre6-dbox2/arch/ppc/kernel/time.c
--- linux-2.4.22-pre6/arch/ppc/kernel/time.c	2003-06-13 16:51:31.000000000 +0200
+++ linux-2.4.22-pre6-dbox2/arch/ppc/kernel/time.c	2003-07-15 09:16:34.000000000 +0200
@@ -71,6 +71,10 @@
 
 extern int do_sys_settimeofday(struct timeval *tv, struct timezone *tz);
 
+#ifdef CONFIG_DBOX2
+extern void m8xx_reset_watchdog(void);
+#endif
+
 /* keep track of when we need to update the rtc */
 time_t last_rtc_update;
 extern rwlock_t xtime_lock;
@@ -320,6 +324,9 @@
 		sec = ppc_md.get_rtc_time();
 		elapsed = 0;
 		do {
+#ifdef CONFIG_DBOX2
+			m8xx_reset_watchdog();
+#endif
 			old_stamp = stamp; 
 			old_sec = sec;
 			stamp = get_native_tbl();

  reply	other threads:[~2003-07-19 13:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-19 13:21 [PATCH] 1/3 Support mpc823 board dbox2 (2.4.22-pre6) Andreas Oberritter
2003-07-19 13:30 ` Andreas Oberritter [this message]
2003-07-19 13:36 ` [PATCH] 3/3 handle level triggered irqs on " Andreas Oberritter

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=1058621424.585.22.camel@localhost \
    --to=obi@saftware.de \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.