From patchwork Wed Aug 20 00:45:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 4746821 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F3D51C0338 for ; Wed, 20 Aug 2014 00:47:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F15C2015D for ; Wed, 20 Aug 2014 00:47:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3848820155 for ; Wed, 20 Aug 2014 00:47:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752204AbaHTAq1 (ORCPT ); Tue, 19 Aug 2014 20:46:27 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35489 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728AbaHTAqW (ORCPT ); Tue, 19 Aug 2014 20:46:22 -0400 Received: by mail-pa0-f53.google.com with SMTP id rd3so11100662pab.12 for ; Tue, 19 Aug 2014 17:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=T9WsiMsCxCxlJOFY9E60preRm31+nrvokr/VLr3pdPE=; b=X5XcjberYiiBJQCaA1gvy2+i9Rxvmc5he3Z63FRR1OkkD9i03wQ2abKL02lvFD0iDE UZ2ChOuMu1mxEvW3edGnt+OKZTgDiit0uW491URaaLDxBI7gZ4oEALWkc8wMh/TxWHIE MuGOLEZpNI5ixIWE3fjRJDeYBivhZjtVdpTYUGZa30wyixxRmsnSZWmAGurmtNLm9Ehv bE8EXzuEYykJQWRAdsRr8aI8Ot121BXtWvP0yf2rc/+wLI5jtM6omYe0CgNxJfHivfQn 1ab0/PY+JKLV/Gi8D27Xj4NhXGOUU1YoLfudj0cdjhBr+L77bJLJza+xEAdU+0HIqYV0 PNlA== X-Received: by 10.68.245.162 with SMTP id xp2mr47881703pbc.60.1408495582104; Tue, 19 Aug 2014 17:46:22 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by mx.google.com with ESMTPSA id ff1sm20516478pbd.93.2014.08.19.17.46.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 Aug 2014 17:46:21 -0700 (PDT) From: Guenter Roeck To: Russell King , Wim Van Sebroeck , Catalin Marinas , Maxime Ripard , Andrew Morton Cc: linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Will Deacon , Arnd Bergmann , Heiko Stuebner , Jonas Jensen , Randy Dunlap , Steven Rostedt , Ingo Molnar , Dmitry Eremin-Solenikov , David Woodhouse , Tomasz Figa , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH v7 09/11] watchdog: s3c2410: add restart handler Date: Tue, 19 Aug 2014 17:45:36 -0700 Message-Id: <1408495538-27480-10-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408495538-27480-1-git-send-email-linux@roeck-us.net> References: <1408495538-27480-1-git-send-email-linux@roeck-us.net> 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 From: Heiko Stübner 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 handlers, 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 Signed-off-by: Guenter Roeck --- v7: Added patch to series. drivers/watchdog/s3c2410_wdt.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 7c6ccd0..2955aef 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #define S3C2410_WTCON 0x00 #define S3C2410_WTDAT 0x04 @@ -128,6 +130,7 @@ struct s3c2410_wdt { unsigned long wtdat_save; struct watchdog_device wdt_device; struct notifier_block freq_transition; + struct notifier_block restart_handler; struct s3c2410_wdt_variant *drv_data; struct regmap *pmureg; }; @@ -438,6 +441,31 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt) } #endif +static int s3c2410wdt_restart(struct notifier_block *this, + unsigned long mode, void *cmd) +{ + struct s3c2410_wdt *wdt = container_of(this, struct s3c2410_wdt, + restart_handler); + void __iomem *wdt_base = wdt->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); + + /* wait for reset to assert... */ + mdelay(500); + + return NOTIFY_DONE; +} + static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt) { unsigned int rst_stat; @@ -592,6 +620,12 @@ static int s3c2410wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, wdt); + wdt->restart_handler.notifier_call = s3c2410wdt_restart; + wdt->restart_handler.priority = 128; + ret = register_restart_handler(&wdt->restart_handler); + if (ret) + pr_err("cannot register restart handler, %d\n", ret); + /* print out a statement of readiness */ wtcon = readl(wdt->reg_base + S3C2410_WTCON); @@ -621,6 +655,8 @@ static int s3c2410wdt_remove(struct platform_device *dev) int ret; struct s3c2410_wdt *wdt = platform_get_drvdata(dev); + unregister_restart_handler(&wdt->restart_handler); + ret = s3c2410wdt_mask_and_disable_reset(wdt, true); if (ret < 0) return ret;