From patchwork Sun Jul 6 18:42:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 4491121 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A34189F26C for ; Sun, 6 Jul 2014 18:41:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACB2E202E6 for ; Sun, 6 Jul 2014 18:41:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 85BDA2024C for ; Sun, 6 Jul 2014 18:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752411AbaGFSl0 (ORCPT ); Sun, 6 Jul 2014 14:41:26 -0400 Received: from gloria.sntech.de ([95.129.55.99]:48168 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752312AbaGFSlZ (ORCPT ); Sun, 6 Jul 2014 14:41:25 -0400 Received: from ip9234425c.dynamic.kabel-deutschland.de ([146.52.66.92] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1X3rNK-0004QX-SM; Sun, 06 Jul 2014 20:41:22 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Guenter Roeck Cc: linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Wim Van Sebroeck , linux-samsung-soc@vger.kernel.org, Tomasz Figa , Mike Turquette Subject: [RFC PATCH 1/3] watchdog: s3c2410: add restart notifier Date: Sun, 06 Jul 2014 20:42:50 +0200 Message-ID: <10183342.ZfePbPvRx9@diego> User-Agent: KMail/4.11.5 (Linux/3.13-1-amd64; KDE/4.11.3; x86_64; ; ) In-Reply-To: <1531376.ijR0PPyvmJ@diego> References: <1531376.ijR0PPyvmJ@diego> MIME-Version: 1.0 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On a lot of Samsung systems the watchdog is responsible for restarting the system and until now this code was contained in plat-samsung/watchdog-reset.c . With the introduction of the restart notifiers, this code can now move into driver itself, removing the need for arch-specific code. Tested on a S3C2442 based GTA02 Signed-off-by: Heiko Stuebner --- drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 7c6ccd0..3f89912 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -41,6 +41,7 @@ #include #include #include +#include #define S3C2410_WTCON 0x00 #define S3C2410_WTDAT 0x04 @@ -438,6 +439,31 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt) } #endif +static struct s3c2410_wdt *s3c2410wdt_restart_ctx; +static int s3c2410wdt_restart_notify(struct notifier_block *this, + unsigned long mode, void *cmd) +{ + void __iomem *wdt_base = s3c2410wdt_restart_ctx->reg_base; + + /* disable watchdog, to be safe */ + writel(0, wdt_base + S3C2410_WTCON); + + /* put initial values into count and data */ + writel(0x80, wdt_base + S3C2410_WTCNT); + writel(0x80, wdt_base + S3C2410_WTDAT); + + /* set the watchdog to go and reset... */ + writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV16 | + S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x20), + wdt_base + S3C2410_WTCON); + + return NOTIFY_DONE; +} + +static struct notifier_block s3c2410wdt_restart_notifier = { + .notifier_call = s3c2410wdt_restart_notify, +}; + static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt) { unsigned int rst_stat; @@ -592,6 +618,11 @@ static int s3c2410wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, wdt); + s3c2410wdt_restart_ctx = wdt; + ret = register_restart_notifier(&s3c2410wdt_restart_notifier); + if (ret) + pr_err("cannot register restart notifier, %d\n", ret); + /* print out a statement of readiness */ wtcon = readl(wdt->reg_base + S3C2410_WTCON); @@ -621,6 +652,8 @@ static int s3c2410wdt_remove(struct platform_device *dev) int ret; struct s3c2410_wdt *wdt = platform_get_drvdata(dev); + unregister_restart_notifier(&s3c2410wdt_restart_notifier); + ret = s3c2410wdt_mask_and_disable_reset(wdt, true); if (ret < 0) return ret;