From: Jochen Friedrich <jochen@scram.de>
To: linuxppc-dev@ozlabs.org
Cc: Scott Wood <scottwood@freescale.com>, linux-kernel@vger.kernel.org
Subject: [PATCH/RFC] Add support for freescale watchdog to CPM serial driver.
Date: Fri, 28 Dec 2007 16:18:36 +0100 [thread overview]
Message-ID: <477513CC.3060109@scram.de> (raw)
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/cpm-serial.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/boot/cpm-serial.c b/arch/powerpc/boot/cpm-serial.c
index 28296fa..d85f038 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"
@@ -50,7 +53,16 @@ struct cpm_bd {
u8 *addr; /* Buffer address in host memory */
};
+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 void *cpcr;
+static struct pq_wdt *wdt;
static struct cpm_param *param;
static struct cpm_smc *smc;
static struct cpm_scc *scc;
@@ -154,6 +166,11 @@ static void cpm_serial_putc(unsigned char c)
static unsigned char cpm_serial_tstc(void)
{
+ if (wdt) {
+ out_be16(&wdt->swsrr, 0x556c);
+ out_be16(&wdt->swsrr, 0xaa39);
+ }
+
barrier();
return !(rbdf->sc & 0x8000);
}
@@ -178,7 +195,7 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)
void *reg_virt[2];
int is_smc = 0, is_cpm2 = 0, n;
unsigned long reg_phys;
- void *parent, *muram;
+ void *parent, *muram, *watchdog;
if (dt_is_compatible(devp, "fsl,cpm1-smc-uart")) {
is_smc = 1;
@@ -260,6 +277,20 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)
if (n < 4)
return -1;
+ 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, ®_phys, NULL))
+ return -1;
+ reg_virt[0] = (void *)reg_phys;
+ }
+ wdt = reg_virt[0];
+ }
+
scdp->open = cpm_serial_open;
scdp->putc = cpm_serial_putc;
scdp->getc = cpm_serial_getc;
--
1.5.3.7
WARNING: multiple messages have this Message-ID (diff)
From: Jochen Friedrich <jochen@scram.de>
To: linuxppc-dev@ozlabs.org
Cc: linux-kernel@vger.kernel.org,
Scott Wood <scottwood@freescale.com>,
Vitaly Bordug <vitb@kernel.crashing.org>
Subject: [PATCH/RFC] Add support for freescale watchdog to CPM serial driver.
Date: Fri, 28 Dec 2007 16:18:36 +0100 [thread overview]
Message-ID: <477513CC.3060109@scram.de> (raw)
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/cpm-serial.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/boot/cpm-serial.c b/arch/powerpc/boot/cpm-serial.c
index 28296fa..d85f038 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"
@@ -50,7 +53,16 @@ struct cpm_bd {
u8 *addr; /* Buffer address in host memory */
};
+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 void *cpcr;
+static struct pq_wdt *wdt;
static struct cpm_param *param;
static struct cpm_smc *smc;
static struct cpm_scc *scc;
@@ -154,6 +166,11 @@ static void cpm_serial_putc(unsigned char c)
static unsigned char cpm_serial_tstc(void)
{
+ if (wdt) {
+ out_be16(&wdt->swsrr, 0x556c);
+ out_be16(&wdt->swsrr, 0xaa39);
+ }
+
barrier();
return !(rbdf->sc & 0x8000);
}
@@ -178,7 +195,7 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)
void *reg_virt[2];
int is_smc = 0, is_cpm2 = 0, n;
unsigned long reg_phys;
- void *parent, *muram;
+ void *parent, *muram, *watchdog;
if (dt_is_compatible(devp, "fsl,cpm1-smc-uart")) {
is_smc = 1;
@@ -260,6 +277,20 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)
if (n < 4)
return -1;
+ 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, ®_phys, NULL))
+ return -1;
+ reg_virt[0] = (void *)reg_phys;
+ }
+ wdt = reg_virt[0];
+ }
+
scdp->open = cpm_serial_open;
scdp->putc = cpm_serial_putc;
scdp->getc = cpm_serial_getc;
--
1.5.3.7
next reply other threads:[~2007-12-28 15:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-28 15:18 Jochen Friedrich [this message]
2007-12-28 15:18 ` [PATCH/RFC] Add support for freescale watchdog to CPM serial driver Jochen Friedrich
2008-01-02 17:45 ` Scott Wood
2008-01-02 17:45 ` Scott Wood
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=477513CC.3060109@scram.de \
--to=jochen@scram.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=scottwood@freescale.com \
/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.