From patchwork Wed Feb 24 17:46:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylvain Lemieux X-Patchwork-Id: 8410431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C82469F52D for ; Wed, 24 Feb 2016 17:49:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE93920225 for ; Wed, 24 Feb 2016 17:49:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E642520222 for ; Wed, 24 Feb 2016 17:49:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYdXz-0002Mz-La; Wed, 24 Feb 2016 17:48:23 +0000 Received: from mail-io0-x242.google.com ([2607:f8b0:4001:c06::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYdXE-0001mh-5N for linux-arm-kernel@lists.infradead.org; Wed, 24 Feb 2016 17:47:38 +0000 Received: by mail-io0-x242.google.com with SMTP id l127so3213993iof.1 for ; Wed, 24 Feb 2016 09:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pAX/4tNGK/6x1flaHhutTFxemJIQEyihNFLJnDOonbo=; b=N43ro28OtHMvmis/dZ+n4DgkOjwofWskgLRVb+9U5xoXv43xoa0sK1KAzrBJC9+fdT XQJpPWwlAcadLTEQvk7nelXHFdrsVPaowKOwQaiOS+Pxc5DupdQG0PtOijX2hYKdRzr/ T/ND+h/eHnbgv9m+IzG99J/8M9E5yP6hlZTbD7L5s05Rro+E7AAe2LfHChZQUEDUdRwM D3G2cVfmrIN1iYg/+Yrou9vSFbEN2M4s53zaMofiv/ZQr4WVYXEGeZfpl77scXqtKB2J 5H+BTdZSojuAshkCg/SScagXLasrtdT/qPepzIIG46/aI9LrfmWcyDR0ygUZWoHogusf HwkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pAX/4tNGK/6x1flaHhutTFxemJIQEyihNFLJnDOonbo=; b=dcXXnx8xwMXYE9J6PwYcmUVNrfPtinRnLCN2zchxwDY7Yb9mI9tbNWuWDu6MY5GQPz w+xH3P8cwP2cZbgB2Xz7up1bDU9+nC83TeCW/bdtfUkQLCQJWcLeqOVkifVHwXhuXQQx 4zvuK47wI1Dfrk7GvMZwdCJVkeujp1fqirxtMMuxu83UbGufSxIY1pzLi1Sew2hUfuYf iZkMqUTLu1Uzue1y05mzlHYoXKCHJohi5pgP7zZpvpMPCEdsYuaPMzdLpdP93b3POJK1 m7WjjGnSmOfXuM0zZ4o5OS5Q6Tr0B1in9cJIW2Y+CmE90d0IXWmzZW6JzY4iMqK7vTUT Vhyg== X-Gm-Message-State: AG10YOTtW9arUEpw5XsQh2ZT39joQqxZ4v645g1WfYnDv9/KAiFA/Y29WGB0VYVddxV+3w== X-Received: by 10.107.136.162 with SMTP id s34mr38178328ioi.142.1456336035295; Wed, 24 Feb 2016 09:47:15 -0800 (PST) Received: from CABRO3AP00510.americas.tsp.ad ([74.51.240.241]) by smtp.gmail.com with ESMTPSA id pk7sm13494524igb.17.2016.02.24.09.47.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2016 09:47:13 -0800 (PST) From: Sylvain Lemieux To: linux-arm-kernel@lists.infradead.org, wim@iguana.be, manabian@gmail.com Subject: [PATCH v3 2/6] watchdog: pnx4008: add restart handler Date: Wed, 24 Feb 2016 12:46:54 -0500 Message-Id: <1456336018-6620-3-git-send-email-slemieux.tyco@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1456336018-6620-1-git-send-email-slemieux.tyco@gmail.com> References: <1456336018-6620-1-git-send-email-slemieux.tyco@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160224_094736_499170_CC331F70 X-CRM114-Status: GOOD ( 15.47 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stigge@antcom.de, linux-watchdog@vger.kernel.org, linux@roeck-us.net, vz@mleia.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, T_DKIM_INVALID,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 From: Sylvain Lemieux Add restart handler capability to the driver; the restart handler implementation was taken from "mach-lpc32xx" ("lpc23xx_restart" function). Signed-off-by: Sylvain Lemieux --- Changes from v2 to v3: - remove explicit clock enable from restart handler. - verify "register_restart_handler" return value. - add call to unregister_restart_handler". - do the restart handling directly in "pnx4008_restart_handler". Changes from v1 to v2: - new patch in v2. drivers/watchdog/pnx4008_wdt.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c index 88264a2..80ee4af 100644 --- a/drivers/watchdog/pnx4008_wdt.c +++ b/drivers/watchdog/pnx4008_wdt.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include /* WatchDog Timer - Chapter 23 Page 207 */ @@ -77,6 +79,7 @@ static bool nowayout = WATCHDOG_NOWAYOUT; static unsigned int heartbeat = DEFAULT_HEARTBEAT; +static struct notifier_block restart_handler; static DEFINE_SPINLOCK(io_lock); static void __iomem *wdt_base; @@ -124,6 +127,19 @@ static int pnx4008_wdt_set_timeout(struct watchdog_device *wdd, return 0; } +static int pnx4008_restart_handler(struct notifier_block *this, + unsigned long mode, void *cmd) +{ + /* Instant assert of RESETOUT_N with pulse length 1mS */ + writel(13000, WDTIM_PULSE(wdt_base)); + writel(M_RES2 | RESFRC1 | RESFRC2, WDTIM_MCTRL(wdt_base)); + + /* Wait for watchdog to reset system */ + mdelay(1000); + + return NOTIFY_DONE; +} + static const struct watchdog_info pnx4008_wdt_ident = { .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, @@ -157,6 +173,15 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt_base)) return PTR_ERR(wdt_base); + /* Register restart handler. */ + restart_handler.notifier_call = pnx4008_restart_handler; + restart_handler.priority = 128; + ret = register_restart_handler(&restart_handler); + if (ret) { + dev_warn(&pdev->dev, "cannot register restart handler\n"); + return ret; + } + wdt_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(wdt_clk)) return PTR_ERR(wdt_clk); @@ -189,6 +214,7 @@ disable_clk: static int pnx4008_wdt_remove(struct platform_device *pdev) { + unregister_restart_handler(&restart_handler); watchdog_unregister_device(&pnx4008_wdd); clk_disable_unprepare(wdt_clk);