From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Kumar Gala <galak@kernel.crashing.org>, Wim Van Sebroeck <wim@iguana.be>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
Scott Wood <scottwood@freescale.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 6/8] [WATCHDOG] mpc8xxx_wdt: add support for MPC8xx watchdogs
Date: Mon, 2 Jun 2008 21:38:46 +0400 [thread overview]
Message-ID: <20080602173846.GF30705@polina.dev.rtsoft.ru> (raw)
In-Reply-To: <20080602173726.GA24556@polina.dev.rtsoft.ru>
The mpc8xxx_wdt driver is using two registers: SWSRR to push magic
numbers, and SWCRR to control the watchdog. Both registers are available
on the MPC8xx, and seem to have the same offsets and semantics as in
MPC83xx/MPC86xx watchdogs. The only difference is prescale value. So this
driver simply works on the MPC8xx CPUs.
One quirk is needed for the MPC8xx, though. It has small prescale value
and slow CPU, so the watchdog resets board prior to the driver has time
to load. To solve this we should split initialization in two steps: start
ping the watchdog early, and register the watchdog userspace interface
later.
MPC823 seem to be the first CPU in MPC8xx line, so we use fsl,mpc823-wdt
compatible matching.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Tested-by: Jochen Friedrich <jochen@scram.de>
---
drivers/watchdog/Kconfig | 3 +-
drivers/watchdog/mpc8xxx_wdt.c | 44 ++++++++++++++++++++++++++++++----------
2 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 008eaa6..f9e617b 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -684,10 +684,11 @@ config 8xx_WDT
config 8xxx_WDT
tristate "MPC8xxx Platform Watchdog Timer"
- depends on PPC_83xx || PPC_86xx
+ depends on PPC_8xx || PPC_83xx || PPC_86xx
help
This driver is for a SoC level watchdog that exists on some
Freescale PowerPC processors. So far this driver supports:
+ - MPC8xx watchdogs
- MPC83xx watchdogs
- MPC86xx watchdogs
diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c
index 2f0681f..0f7e165 100644
--- a/drivers/watchdog/mpc8xxx_wdt.c
+++ b/drivers/watchdog/mpc8xxx_wdt.c
@@ -1,5 +1,5 @@
/*
- * mpc8xxx_wdt.c - MPC83xx/MPC86xx watchdog userspace interface
+ * mpc8xxx_wdt.c - MPC8xx/MPC83xx/MPC86xx watchdog userspace interface
*
* Authors: Dave Updegraff <dave@cray.org>
* Kumar Gala <galak@kernel.crashing.org>
@@ -207,13 +207,6 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
goto err_unmap;
}
- ret = misc_register(&mpc8xxx_wdt_miscdev);
- if (ret) {
- pr_err("cannot register miscdev on minor=%d (err=%d)\n",
- WATCHDOG_MINOR, ret);
- goto err_unmap;
- }
-
/* Calculate the timeout in seconds */
if (prescale)
timeout_sec = (timeout * wdt_type->prescaler) / freq;
@@ -234,6 +227,7 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
return 0;
err_unmap:
iounmap(wd_base);
+ wd_base = NULL;
return ret;
}
@@ -261,6 +255,12 @@ static const struct of_device_id mpc8xxx_wdt_match[] = {
.hw_enabled = true,
},
},
+ {
+ .compatible = "fsl,mpc823-wdt",
+ .data = &(struct mpc8xxx_wdt_type) {
+ .prescaler = 0x800,
+ },
+ },
{},
};
MODULE_DEVICE_TABLE(of, mpc8xxx_wdt_match);
@@ -275,20 +275,42 @@ static struct of_platform_driver mpc8xxx_wdt_driver = {
},
};
+/*
+ * We do wdt initialization in two steps: arch_initcall probes the wdt
+ * very early to start pinging the watchdog (misc devices are not yet
+ * available), and later module_init() just registers the misc device.
+ */
+static int __init mpc8xxx_wdt_init_late(void)
+{
+ int ret;
+
+ if (!wd_base)
+ return -ENODEV;
+
+ ret = misc_register(&mpc8xxx_wdt_miscdev);
+ if (ret) {
+ pr_err("cannot register miscdev on minor=%d (err=%d)\n",
+ WATCHDOG_MINOR, ret);
+ return ret;
+ }
+ return 0;
+}
+module_init(mpc8xxx_wdt_init_late);
+
static int __init mpc8xxx_wdt_init(void)
{
return of_register_platform_driver(&mpc8xxx_wdt_driver);
}
+arch_initcall(mpc8xxx_wdt_init);
static void __exit mpc8xxx_wdt_exit(void)
{
of_unregister_platform_driver(&mpc8xxx_wdt_driver);
}
-
-subsys_initcall(mpc8xxx_wdt_init);
module_exit(mpc8xxx_wdt_exit);
MODULE_AUTHOR("Dave Updegraff, Kumar Gala");
-MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx/MPC86xx uProcessors");
+MODULE_DESCRIPTION("Driver for watchdog timer in MPC8xx/MPC83xx/MPC86xx "
+ "uProcessors");
MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
--
1.5.5.1
next prev parent reply other threads:[~2008-06-02 17:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-02 17:37 [PATCH 0/8 v4] mpc83xx_wdt rework, support for mpc8610 and mpc8xx Anton Vorontsov
2008-06-02 17:38 ` [PATCH 1/8] [WATCHDOG] mpc83xx_wdt: fix checkpatch issues Anton Vorontsov
2008-06-02 19:43 ` Alan Cox
2008-06-02 20:49 ` Anton Vorontsov
2008-06-02 17:38 ` [PATCH 2/8] [WATCHDOG] mpc83xx_wdt: convert to the OF platform driver Anton Vorontsov
2008-06-02 17:38 ` [PATCH 3/8] [WATCHDOG] mpc83xx_wdt: add support for MPC86xx CPUs Anton Vorontsov
2008-06-02 17:38 ` [PATCH 4/8] [WATCHDOG] mpc83xx_wdt: rename to mpc8xxx_wdt Anton Vorontsov
2008-06-02 17:38 ` [PATCH 5/8] [WATCHDOG] mpc8xxx_wdt: various renames, mostly s/mpc83xx/mpc8xxx/g Anton Vorontsov
2008-06-02 17:38 ` Anton Vorontsov [this message]
2008-06-02 17:38 ` [PATCH 7/8] [POWERPC] fsl_soc: remove mpc83xx_wdt code Anton Vorontsov
2008-06-02 17:38 ` [PATCH 8/8] [POWERPC] 86xx: mpc8610_hpcd: add watchdog node Anton Vorontsov
2008-06-03 23:48 ` [PATCH 0/8 v4] mpc83xx_wdt rework, support for mpc8610 and mpc8xx Andrew Morton
2008-06-04 0:17 ` Anton Vorontsov
2008-06-04 0:32 ` Andrew Morton
2008-06-04 4:07 ` Paul Mackerras
2008-06-04 4:15 ` Andrew Morton
2008-06-04 17:31 ` Randy Dunlap
2008-06-04 12:27 ` Anton Vorontsov
2008-06-07 17:57 ` [PATCH -mm] watchdog: mpc8xxx_wdt: fix build Anton Vorontsov
-- strict thread matches above, loose matches on Subject: below --
2008-05-19 18:37 [PATCH 0/8 v4] mpc83xx_wdt rework, support for mpc8610 and mpc8xx Anton Vorontsov
2008-05-19 18:37 ` [PATCH 6/8] [WATCHDOG] mpc8xxx_wdt: add support for MPC8xx watchdogs Anton Vorontsov
2008-05-15 16:52 [PATCH 0/8 v3] mpc83xx_wdt rework, support for mpc8610 and mpc8xx Anton Vorontsov
2008-05-15 16:54 ` [PATCH 6/8] [WATCHDOG] mpc8xxx_wdt: add support for MPC8xx watchdogs Anton Vorontsov
2008-05-16 9:17 ` Jochen Friedrich
2008-05-16 11:46 ` Anton Vorontsov
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=20080602173846.GF30705@polina.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=akpm@linux-foundation.org \
--cc=galak@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=scottwood@freescale.com \
--cc=sfr@canb.auug.org.au \
--cc=wim@iguana.be \
/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;
as well as URLs for NNTP newsgroup(s).