From patchwork Fri Mar 4 18:44:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylvain Lemieux X-Patchwork-Id: 8507061 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 A8B2A9F38C for ; Fri, 4 Mar 2016 18:46:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C465020138 for ; Fri, 4 Mar 2016 18:46:55 +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 E68A4200ED for ; Fri, 4 Mar 2016 18:46:54 +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 1abuj7-0008UF-Kr; Fri, 04 Mar 2016 18:45:25 +0000 Received: from mail-ig0-x243.google.com ([2607:f8b0:4001:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1abuiW-00074Y-4e for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2016 18:44:50 +0000 Received: by mail-ig0-x243.google.com with SMTP id ir4so185981igb.3 for ; Fri, 04 Mar 2016 10:44:28 -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=VJcsxS27p18eXXYDN7KS2pP+yCM/9VLna+Y74HbD+g0=; b=HbbQibi2upfxuzOMtQkvUzdZPOWBRsZbjZ4894Gt8K4gNKU9/gPl9mO1HoB0Ijfocv PrwDmQL513NygFlNvsrufpQuGLbA90l2lEfvhko/c7nlhz+9tXYaz4hcVQWqqBvfkFLy SXElqaeaHVTYhteQaIjOxzBQoHKVmtC+4775D5VjoEUCqzRbmTwHpKERk2GyZfT8TxSB tLXMTgLoyD5Twy6zJp4CufUw2D5F8zAXvP8eojgIK28m+wTjtsFkf0Xot8iVGMMk5Cld x/l+JMJ3vh+GsJCepAyLe4U/qtugXCPfUmXmPCrQTx/N7BtE426u97FMxj23NRYrkGQe Yi+A== 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=VJcsxS27p18eXXYDN7KS2pP+yCM/9VLna+Y74HbD+g0=; b=GveFVzmkQ6Ot5E12AejO8bauFOn6A3ZQDv8V9vkaXEePj0rjRpBQ56hU/4U2f20e+Y Md/VYSrU700kRejlJ4StZfO2qP/baKjgKLfCrlxy4KS13YkV5aADcroKQgd808yo4FhK 2H3RHlswPGIOSfpFYvByaNpJ0OOZNdHI3lGvu1oHoiVf2a4TYiSWm7GM2u2trZb775gZ CJJxPhqHpbNdJsuf6XdMwgsib0wz+Jb7vUybOp8Ksg2bDtWBXaHwyuET8ODuKuvIq+2x IpVDva+3DxECzRh5WqkU4BonWzv/k3YMuPvZ360evqtf60/yVddZ1ZD9v95hMecIrbI/ p9RQ== X-Gm-Message-State: AD7BkJJQfJLBV0CEMUgE5vF6K4YUDZTiypq67G1xfGtRnrqS+BlCOt0CSTl87GNOsVATig== X-Received: by 10.50.111.8 with SMTP id ie8mr390631igb.29.1457117068243; Fri, 04 Mar 2016 10:44:28 -0800 (PST) Received: from CABRO3AP00510.americas.tsp.ad ([74.51.240.241]) by smtp.gmail.com with ESMTPSA id nh19sm146470igb.2.2016.03.04.10.44.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2016 10:44:26 -0800 (PST) From: Sylvain Lemieux To: linux-arm-kernel@lists.infradead.org, arnd@arndb.de, linux@roeck-us.net, manabian@gmail.com Subject: [PATCH v7 2/6] watchdog: pnx4008: add restart handler Date: Fri, 4 Mar 2016 13:44:06 -0500 Message-Id: <1457117050-13543-3-git-send-email-slemieux.tyco@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1457117050-13543-1-git-send-email-slemieux.tyco@gmail.com> References: <1457117050-13543-1-git-send-email-slemieux.tyco@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160304_104448_525166_367B4014 X-CRM114-Status: GOOD ( 14.50 ) 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, wim@iguana.be, linux-watchdog@vger.kernel.org, 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 Reviewed-by: Guenter Roeck --- Changes from v6 to v7: - Added Reviewed-by from v6. Changes from v5 to v6: - none. Changes from v4 to v5: - Rebased on the following patch: http://permalink.gmane.org/gmane.linux.watchdog/3364/ Changes from v3 to v4: - none. 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c index 88264a2..f3be522 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 */ @@ -124,6 +126,19 @@ static int pnx4008_wdt_set_timeout(struct watchdog_device *wdd, return 0; } +static int pnx4008_restart_handler(struct watchdog_device *wdd, + 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, @@ -135,6 +150,7 @@ static const struct watchdog_ops pnx4008_wdt_ops = { .start = pnx4008_wdt_start, .stop = pnx4008_wdt_stop, .set_timeout = pnx4008_wdt_set_timeout, + .restart = pnx4008_restart_handler, }; static struct watchdog_device pnx4008_wdd = { @@ -169,6 +185,7 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) WDIOF_CARDRESET : 0; pnx4008_wdd.parent = &pdev->dev; watchdog_set_nowayout(&pnx4008_wdd, nowayout); + watchdog_set_restart_priority(&pnx4008_wdd, 128); pnx4008_wdt_stop(&pnx4008_wdd); /* disable for now */