Skip to contentSkip to conversation

Add support for freescale watchdog to CPM serial driver.

PATCH/RFCv2 Jochen Friedrich 5 participants 11 messages Jan 17, 2008 – Jan 18, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

If a freescale watchdog device node is present, reset the watchdog while waiting for serial input.

---

arch/powerpc/boot/Makefile     |    2 +-
arch/powerpc/boot/cpm-serial.c |    6 ++++
arch/powerpc/boot/cuboot-8xx.c |    1 +
arch/powerpc/boot/ops.h        |    2 +
arch/powerpc/boot/watchdog.c   |   65 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 75 insertions(+), 1 deletions(-)

create mode 100644 arch/powerpc/boot/watchdog.c

arch/powerpc/boot/Makefile +0 -0
index d1e625c..66edf77 100644
@@ -56,7 +56,7 @@ src-wlib := string.S crt0.S stdio.c main.c \
		gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
		4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
		cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \
-		fsl-soc.c mpc8xx.c pq2.c
+		fsl-soc.c mpc8xx.c pq2.c watchdog.c
src-plat := of.c cuboot-52xx.c cuboot-83xx.c cuboot-85xx.c holly.c \
		cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
		ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
arch/powerpc/boot/cpm-serial.c +3 -0
index 28296fa..56b5fda 100644
@@ -6,6 +6,9 @@
 *
 * It is assumed that the firmware (or the platform file) has already set
 * up the port.
+ *
+ * If a watchdog node exists, periodically reset the watchdog while waiting
+ * for console input.
 */
 

#include "types.h"
@@ -154,6 +157,9 @@ static void cpm_serial_putc(unsigned char c)

static unsigned char cpm_serial_tstc(void)
{
+
+ watchdog_poke();
+

	barrier();
	return !(rbdf->sc & 0x8000);
}
arch/powerpc/boot/cuboot-8xx.c +0 -0
index c202c88..767670e 100644
@@ -43,5 +43,6 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
	CUBOOT_INIT();
	fdt_init(_dtb_start);
	serial_console_init();
+	watchdog_init();
	platform_ops.fixups = platform_fixups;
}
arch/powerpc/boot/ops.h +0 -0
index 6036a98..0701359 100644
@@ -86,6 +86,8 @@ int mpsc_console_init(void *devp, struct serial_console_data *scdp);

int cpm_console_init(void *devp, struct serial_console_data *scdp); int mpc5200_psc_console_init(void *devp, struct serial_console_data *scdp); int uartlite_console_init(void *devp, struct serial_console_data *scdp); +void watchdog_poke(void);
+void watchdog_init(void);
void *simple_alloc_init(char *base, unsigned long heap_size,

			unsigned long granularity, unsigned long max_allocs);

extern void flush_cache(void *, unsigned long);

arch/powerpc/boot/watchdog.c new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.5.3.8
#1 lore raw
Quoted 11 lines · On Thu, 17 Jan 2008 13:32:35 +0100 Jochen Friedrich <[email protected]> wrote:

If a freescale watchdog device node is present, reset the watchdog while waiting for serial input.

---
 arch/powerpc/boot/Makefile     |    2 +-
 arch/powerpc/boot/cpm-serial.c |    6 ++++
 arch/powerpc/boot/cuboot-8xx.c |    1 +
 arch/powerpc/boot/ops.h        |    2 +
 arch/powerpc/boot/watchdog.c   |   65 ++++++++++++++++++++++++++++++++++++++++

I am just wondering if maybe that file name is to generic.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#2 lore raw
In reply to Jochen Friedrich

arch/powerpc/boot/watchdog.c line 43

Quoted 7 lines · Jochen Friedrich
arch/powerpc/boot/watchdog.c new file +7 -0
+void watchdog_poke(void)
+{
+    if (wdt) {
+        out_be16(&wdt->swsrr, 0x556c);
+        out_be16(&wdt->swsrr, 0xaa39);
+    }
+}

This should be a function pointer, to allow for other watchdog types.

-Scott

#3 lore raw
Quoted 9 lines · Scott Wood

arch/powerpc/boot/watchdog.c line 43

Quoted 7 lines
arch/powerpc/boot/watchdog.c new file +7 -0
+void watchdog_poke(void)
+{
+    if (wdt) {
+        out_be16(&wdt->swsrr, 0x556c);
+        out_be16(&wdt->swsrr, 0xaa39);
+    }
+}

This should be a function pointer, to allow for other watchdog types.

Thanks for the comments. Stephen Rothwell also asked if the filename watchdog.c is too generic. I think the pq watchdog is easy enough to keep it in the generic watchdog.c file, but the function pointer definitely is the way to go. I'll resubmit.

Thanks,
Jochen

#4 lore raw
In reply to Jochen Friedrich
Quoted 2 lines · On Thu, 17 Jan 2008 13:32:35 +0100 Jochen Friedrich <[email protected]> wrote:

If a freescale watchdog device node is present, reset the watchdog while waiting for serial input.

Why ? We normally rely on user space for watchdog management as only the fact user space is behaving really proves a box is happy ?

Alan

#5 lore raw

Hi Alan,

Quoted 5 lines
Quoted 2 lines

If a freescale watchdog device node is present, reset the watchdog while waiting for serial input.

Why ? We normally rely on user space for watchdog management as only the fact user space is behaving really proves a box is happy ?

This is in the boot wrapper code, not in the linux kernel.

Thanks,
Jochen

#6 lore raw
Quoted 9 lines · On Fri, 18 Jan 2008 19:47:43 +0100 Jochen Friedrich <[email protected]> wrote:

Hi Alan,

Quoted 5 lines
Quoted 2 lines

If a freescale watchdog device node is present, reset the watchdog while waiting for serial input.

Why ? We normally rely on user space for watchdog management as only the fact user space is behaving really proves a box is happy ?

This is in the boot wrapper code, not in the linux kernel.

Ok now that makes sense, thanks

#7 lore raw
Quoted 8 lines · Alan Cox
Quoted 5 lines · On Fri, 18 Jan 2008 19:47:43 +0100 Jochen Friedrich <[email protected]> wrote:

Hi Alan,

Quoted 3 lines
Quoted 2 lines

If a freescale watchdog device node is present, reset the watchdog while waiting for serial input.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Why ? We normally rely on user space for watchdog management as only the fact user space is behaving really proves a box is happy ?

This is in the boot wrapper code, not in the linux kernel.

Ok now that makes sense, thanks

So I'll ask, what serial input are you waiting for from the boot wrapper?

- k

#8 lore raw
Quoted 1 line · Kumar Gala

So I'll ask, what serial input are you waiting for from the boot wrapper?

The bootwrapper has a command line editing prompt. It's fairly gratuitous in the presence of semi-decent firmware, but it's there nonetheless.

-Scott

#9 lore raw
In reply to Kumar Gala

Hi Kumar,

Quoted 3 lines
Quoted 1 line

Ok now that makes sense, thanks

So I'll ask, what serial input are you waiting for from the boot wrapper?

It's the editor for the kernel command line.

Thanks,
Jochen

#10 lore raw
Quoted 6 lines · Jochen Friedrich

Hi Kumar,

Quoted 2 lines
Quoted 1 line

Ok now that makes sense, thanks

So I'll ask, what serial input are you waiting for from the boot wrapper?

It's the editor for the kernel command line.

thanks, learn something everyday.

- k