public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru•mvista.com>
To: Kumar Gala <galak@kernel•crashing.org>
Cc: "linuxppc-dev@ozlabs•org list" <linuxppc-dev@ozlabs•org>,
	Wim Van Sebroeck <wim@iguana•be>,
	Scott Wood <scottwood@freescale•com>,
	Timur Tabi <timur@freescale•com>
Subject: [PATCH] [WATCHDOG] mpc8xxx_wdt: add support for MPC8xx watchdogs
Date: Tue, 13 May 2008 19:55:07 +0400	[thread overview]
Message-ID: <20080513155507.GA25624@polina.dev.rtsoft.ru> (raw)
In-Reply-To: <8C355C2C-C029-4F02-A5B0-DA8173FAFF69@kernel.crashing.org>

Only build-tested.

Signed-off-by: Anton Vorontsov <avorontsov@ru•mvista.com>
---

On Tue, May 13, 2008 at 09:50:26AM -0500, Kumar Gala wrote:
>
> On May 13, 2008, at 9:14 AM, Anton Vorontsov wrote:
>
>> Hi all,
>>
>> Thanks for the review, here is the new version.
>>
>> Changes since v1:
>>
>> - Scott Wood asked for mpc83xx_wdt on multiplatform kernels. Done via
>>  OF platform driver;
>> - Kumar Gala asked for mpc83xx_wdt -> mpc8xxx_wdt rename. Done in two
>>  steps;
>> - Segher Boessenkool noticed a negligence in the wdt device tree node.
>>  Fixed by removing mpc83xx_wdt compatible entry.
>
> any possibility of making this work on 8xx per Jochen's comment?  (see  
> mpc8xx_wdt.c)

[ Oops. Jochen, sorry I forgot to Cc you this time. ]

I think it should work with the patch inlined here, and this node
in the device tree.

soc@ff000000 {
	....
	wdt@0 {
		device_type = "watchdog";
		compatible = "fsl,mpc885-wdt";
		reg = <0 0x100>;
	};
	....
};

Not tested though. And also no support for RTC-driven timer tweak
(anybody willing are welcomed to implement this ;-).

 drivers/watchdog/Kconfig       |    2 +-
 drivers/watchdog/mpc8xxx_wdt.c |   31 +++++++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index bd9044f..06b1119 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -684,7 +684,7 @@ config 8xx_WDT
 
 config 8xxx_WDT
 	tristate "MPC8xxx Watchdog Timer"
-	depends on PPC_83xx || PPC_86xx
+	depends on FSL_SOC
 
 config MV64X60_WDT
 	tristate "MV64X60 (Marvell Discovery) Watchdog Timer"
diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c
index b582441..a93b512 100644
--- a/drivers/watchdog/mpc8xxx_wdt.c
+++ b/drivers/watchdog/mpc8xxx_wdt.c
@@ -42,6 +42,11 @@ struct mpc8xxx_wdt {
 	u8 res2[0xF0];
 };
 
+struct mpc8xxx_wdt_type {
+	int prescaler;
+	bool hw_enabled;
+};
+
 static struct mpc8xxx_wdt __iomem *wd_base;
 
 static u16 timeout = 0xffff;
@@ -182,6 +187,7 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
 {
 	int ret;
 	struct device_node *np = ofdev->node;
+	struct mpc8xxx_wdt_type *wdt_type = match->data;
 	u32 freq = fsl_get_sys_freq();
 	bool enabled;
 
@@ -193,7 +199,7 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
 		return -ENOMEM;
 
 	enabled = in_be32(&wd_base->swcrr) & SWCRR_SWEN;
-	if (!enabled && of_device_is_compatible(np, "fsl,mpc8610-wdt")) {
+	if (!enabled && wdt_type->hw_enabled) {
 		pr_info("mpc8xxx_wdt: could not be enabled in software\n");
 		ret = -ENOSYS;
 		goto err_unmap;
@@ -208,7 +214,7 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
 
 	/* Calculate the timeout in seconds */
 	if (prescale)
-		timeout_sec = (timeout * 0x10000) / freq;
+		timeout_sec = (timeout * wdt_type->prescaler) / freq;
 	else
 		timeout_sec = timeout / freq;
 
@@ -240,8 +246,25 @@ static int __devexit mpc8xxx_wdt_remove(struct of_device *ofdev)
 }
 
 static const struct of_device_id mpc8xxx_wdt_match[] = {
-	{ .compatible = "mpc83xx_wdt", },
-	{ .compatible = "fsl,mpc8610-wdt", },
+	{
+		.compatible = "mpc83xx_wdt",
+		.data = &(struct mpc8xxx_wdt_type) {
+			.prescaler = 0x10000,
+		},
+	},
+	{
+		.compatible = "fsl,mpc8610-wdt",
+		.data = &(struct mpc8xxx_wdt_type) {
+			.prescaler = 0x10000,
+			.hw_enabled = true,
+		},
+	},
+	{
+		.compatible = "fsl,mpc885-wdt",
+		.data = &(struct mpc8xxx_wdt_type) {
+			.prescaler = 0x800,
+		},
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, mpc8xxx_wdt_match);
-- 
1.5.5.1

  reply	other threads:[~2008-05-13 15:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-13 14:14 [PATCH 0/6 v2] mpc83xx_wdt rework, support for mpc8610 Anton Vorontsov
2008-05-13 14:14 ` [PATCH 1/6] [WATCHDOG] mpc83xx_wdt: convert to the OF platform driver Anton Vorontsov
2008-05-13 23:32   ` Stephen Rothwell
2008-05-13 14:14 ` [PATCH 2/6] [WATCHDOG] mpc83xx_wdt: add support for MPC86xx CPUs Anton Vorontsov
2008-05-13 14:14 ` [PATCH 3/6] [WATCHDOG] mpc83xx_wdt: rename to mpc8xxx_wdt Anton Vorontsov
2008-05-14  1:45   ` Stephen Rothwell
2008-05-14  1:48     ` Stephen Rothwell
2008-05-14 12:25       ` Anton Vorontsov
2008-05-14  3:53     ` Chen Gong
2008-05-14 15:03       ` Kumar Gala
2008-05-15  3:11         ` Chen Gong
2008-05-13 14:15 ` [PATCH 4/6] [WATCHDOG] mpc8xxx_wdt: various renames, mostly s/mpc83xx/mpc8xxx/g Anton Vorontsov
2008-05-13 14:15 ` [PATCH 5/6] [POWERPC] fsl_soc: remove mpc83xx_wdt code Anton Vorontsov
2008-05-13 14:15 ` [PATCH 6/6] [POWERPC] 86xx: mpc8610_hpcd: add watchdog node Anton Vorontsov
2008-05-13 16:16   ` Scott Wood
2008-05-13 14:50 ` [PATCH 0/6 v2] mpc83xx_wdt rework, support for mpc8610 Kumar Gala
2008-05-13 15:55   ` Anton Vorontsov [this message]
2008-05-13 16:12     ` [PATCH] [WATCHDOG] mpc8xxx_wdt: add support for MPC8xx watchdogs 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=20080513155507.GA25624@polina.dev.rtsoft.ru \
    --to=avorontsov@ru$(echo .)mvista.com \
    --cc=galak@kernel$(echo .)crashing.org \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=scottwood@freescale$(echo .)com \
    --cc=timur@freescale$(echo .)com \
    --cc=wim@iguana$(echo .)be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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