LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
@ 2008-01-17 12:32 Jochen Friedrich
  2008-01-18  0:38 ` Stephen Rothwell
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jochen Friedrich @ 2008-01-17 12:32 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-kernel, Scott Wood, Vitaly Bordug

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

Signed-off-by: Jochen Friedrich <jochen@scram.de>
---
 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

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index d1e625c..66edf77 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -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 \
diff --git a/arch/powerpc/boot/cpm-serial.c b/arch/powerpc/boot/cpm-serial.c
index 28296fa..56b5fda 100644
--- a/arch/powerpc/boot/cpm-serial.c
+++ b/arch/powerpc/boot/cpm-serial.c
@@ -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);
 }
diff --git a/arch/powerpc/boot/cuboot-8xx.c b/arch/powerpc/boot/cuboot-8xx.c
index c202c88..767670e 100644
--- a/arch/powerpc/boot/cuboot-8xx.c
+++ b/arch/powerpc/boot/cuboot-8xx.c
@@ -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;
 }
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 6036a98..0701359 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -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);
diff --git a/arch/powerpc/boot/watchdog.c b/arch/powerpc/boot/watchdog.c
new file mode 100644
index 0000000..6c50052
--- /dev/null
+++ b/arch/powerpc/boot/watchdog.c
@@ -0,0 +1,65 @@
+/*
+ * PQ Watchdog
+ *
+ * Copyright 2008 Jochen Friedrich <jochen@scram.de>
+ *
+ * Search for PowerQUICC type watchdog devices. Provide a callback to
+ * periodically reset the watchdog while waiting for console input.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "types.h"
+#include "io.h"
+#include "ops.h"
+
+struct pq_wdt {
+	u32 res0;
+	u32 swcrr; /* System watchdog control register */
+	u32 swcnr; /* System watchdog count register */
+	u8  res1[2];
+	u16 swsrr; /* System watchdog service register */
+};
+
+static struct pq_wdt *wdt;
+
+void watchdog_poke(void)
+{
+	if (wdt) {
+		out_be16(&wdt->swsrr, 0x556c);
+		out_be16(&wdt->swsrr, 0xaa39);
+	}
+}
+
+void watchdog_init(void)
+{
+	void *reg_virt[2];
+	int n;
+	unsigned long reg_phys;
+	void *watchdog;
+
+	watchdog = finddevice("/soc/wdt");
+	if (watchdog && (dt_is_compatible(watchdog, "fsl,pq1-wdt") ||
+			 dt_is_compatible(watchdog, "fsl,pq2-wdt") ||
+			 dt_is_compatible(watchdog, "fsl,pq2pro-wdt"))) {
+		n = getprop(watchdog, "virtual-reg", reg_virt,
+			 sizeof(reg_virt));
+		if (n < (int)sizeof(reg_virt)) {
+			if (!dt_xlate_reg(watchdog, 0, &reg_phys, NULL))
+				return;
+			reg_virt[0] = (void *)reg_phys;
+		}
+		wdt = reg_virt[0];
+	}
+}
-- 
1.5.3.8


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-17 12:32 [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver Jochen Friedrich
@ 2008-01-18  0:38 ` Stephen Rothwell
  2008-01-18 17:04 ` Scott Wood
  2008-01-18 18:39 ` Alan Cox
  2 siblings, 0 replies; 11+ messages in thread
From: Stephen Rothwell @ 2008-01-18  0:38 UTC (permalink / raw)
  To: Jochen Friedrich; +Cc: linuxppc-dev, Scott Wood, linux-kernel

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

On Thu, 17 Jan 2008 13:32:35 +0100 Jochen Friedrich <jochen@scram.de> wrote:
>
> If a freescale watchdog device node is present, reset the watchdog
> while waiting for serial input.
> 
> Signed-off-by: Jochen Friedrich <jochen@scram.de>
> ---
>  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.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-17 12:32 [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver Jochen Friedrich
  2008-01-18  0:38 ` Stephen Rothwell
@ 2008-01-18 17:04 ` Scott Wood
  2008-01-18 17:33   ` Jochen Friedrich
  2008-01-18 18:39 ` Alan Cox
  2 siblings, 1 reply; 11+ messages in thread
From: Scott Wood @ 2008-01-18 17:04 UTC (permalink / raw)
  To: Jochen Friedrich; +Cc: linuxppc-dev, linux-kernel, Vitaly Bordug

Jochen Friedrich wrote:
> +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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-18 17:04 ` Scott Wood
@ 2008-01-18 17:33   ` Jochen Friedrich
  0 siblings, 0 replies; 11+ messages in thread
From: Jochen Friedrich @ 2008-01-18 17:33 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, linux-kernel, Vitaly Bordug, Stephen Rothwell

Scott Wood schrieb:

>> +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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-17 12:32 [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver Jochen Friedrich
  2008-01-18  0:38 ` Stephen Rothwell
  2008-01-18 17:04 ` Scott Wood
@ 2008-01-18 18:39 ` Alan Cox
  2008-01-18 18:47   ` Jochen Friedrich
  2 siblings, 1 reply; 11+ messages in thread
From: Alan Cox @ 2008-01-18 18:39 UTC (permalink / raw)
  To: Jochen Friedrich; +Cc: linuxppc-dev, linux-kernel, Scott Wood, Vitaly Bordug

On Thu, 17 Jan 2008 13:32:35 +0100
Jochen Friedrich <jochen@scram.de> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-18 18:39 ` Alan Cox
@ 2008-01-18 18:47   ` Jochen Friedrich
  2008-01-18 20:40     ` Alan Cox
  0 siblings, 1 reply; 11+ messages in thread
From: Jochen Friedrich @ 2008-01-18 18:47 UTC (permalink / raw)
  To: Alan Cox; +Cc: linuxppc-dev, linux-kernel, Scott Wood, Vitaly Bordug

Hi Alan,

>> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-18 18:47   ` Jochen Friedrich
@ 2008-01-18 20:40     ` Alan Cox
  2008-01-18 21:51       ` Kumar Gala
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Cox @ 2008-01-18 20:40 UTC (permalink / raw)
  To: Jochen Friedrich; +Cc: linuxppc-dev, linux-kernel, Scott Wood, Vitaly Bordug

On Fri, 18 Jan 2008 19:47:43 +0100
Jochen Friedrich <jochen@scram.de> wrote:

> Hi Alan,
> 
> >> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-18 20:40     ` Alan Cox
@ 2008-01-18 21:51       ` Kumar Gala
  2008-01-18 21:54         ` Scott Wood
  2008-01-18 21:56         ` Jochen Friedrich
  0 siblings, 2 replies; 11+ messages in thread
From: Kumar Gala @ 2008-01-18 21:51 UTC (permalink / raw)
  To: Alan Cox
  Cc: Jochen Friedrich, linuxppc-dev, linux-kernel, Scott Wood, Vitaly Bordug


On Jan 18, 2008, at 2:40 PM, Alan Cox wrote:

> On Fri, 18 Jan 2008 19:47:43 +0100
> Jochen Friedrich <jochen@scram.de> wrote:
>
>> Hi Alan,
>>
>>>> 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

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

- k

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-18 21:51       ` Kumar Gala
@ 2008-01-18 21:54         ` Scott Wood
  2008-01-18 21:56         ` Jochen Friedrich
  1 sibling, 0 replies; 11+ messages in thread
From: Scott Wood @ 2008-01-18 21:54 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Alan Cox, Jochen Friedrich, linuxppc-dev, linux-kernel, Vitaly Bordug

Kumar Gala wrote:
> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-18 21:51       ` Kumar Gala
  2008-01-18 21:54         ` Scott Wood
@ 2008-01-18 21:56         ` Jochen Friedrich
  2008-01-18 22:08           ` Kumar Gala
  1 sibling, 1 reply; 11+ messages in thread
From: Jochen Friedrich @ 2008-01-18 21:56 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Alan Cox, linuxppc-dev, linux-kernel, Scott Wood, Vitaly Bordug

Hi Kumar,

>> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver.
  2008-01-18 21:56         ` Jochen Friedrich
@ 2008-01-18 22:08           ` Kumar Gala
  0 siblings, 0 replies; 11+ messages in thread
From: Kumar Gala @ 2008-01-18 22:08 UTC (permalink / raw)
  To: Jochen Friedrich
  Cc: Alan Cox, linuxppc-dev, linux-kernel, Scott Wood, Vitaly Bordug


On Jan 18, 2008, at 3:56 PM, Jochen Friedrich wrote:

> Hi Kumar,
>
>>> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-01-18 22:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-17 12:32 [PATCH/RFCv2] [POWERPC] Add support for freescale watchdog to CPM serial driver Jochen Friedrich
2008-01-18  0:38 ` Stephen Rothwell
2008-01-18 17:04 ` Scott Wood
2008-01-18 17:33   ` Jochen Friedrich
2008-01-18 18:39 ` Alan Cox
2008-01-18 18:47   ` Jochen Friedrich
2008-01-18 20:40     ` Alan Cox
2008-01-18 21:51       ` Kumar Gala
2008-01-18 21:54         ` Scott Wood
2008-01-18 21:56         ` Jochen Friedrich
2008-01-18 22:08           ` Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).