From patchwork Mon Dec 2 18:14:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 3266591 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA4879F377 for ; Mon, 2 Dec 2013 18:16:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8BF2C20220 for ; Mon, 2 Dec 2013 18:16:54 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2914B20272 for ; Mon, 2 Dec 2013 18:16:53 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VnY2M-0000tQ-8l; Mon, 02 Dec 2013 18:16:02 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VnY22-0003xr-0Z; Mon, 02 Dec 2013 18:15:42 +0000 Received: from mail-ie0-f201.google.com ([209.85.223.201]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VnY1y-0003vg-CI for linux-arm-kernel@lists.infradead.org; Mon, 02 Dec 2013 18:15:39 +0000 Received: by mail-ie0-f201.google.com with SMTP id at1so2572884iec.0 for ; Mon, 02 Dec 2013 10:15:09 -0800 (PST) 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; bh=pHQ3LqUEabwXJn6NbrrOWS3jQMXeqHADLBSKSeDkyiA=; b=QNLCnfkpCNuEFax0qBweaQDrzFqYpqKR+cmpDowEUMh+6ALN4Mp+GRdi5tVaewgNRT 5uSAykNon4E9BXOCLUzrvhDV1DgIk0xgN53my70UKAAuDZqRY9Mrdu29pI6Ts5tB3cj0 65RyhVZjNBdx3tMbxfXb0xwoDiP2H3Ua3wws6lYawhdyu68GK8pZeJdY4Bl8WuAIRcxY RBYnBrQbiiHxxLWCPlZuGwdGKdnTYAXHYzjL/CXVY+UWc7TsQaNMiWmywp8eWNySOr9S Emdhlbo2Q+21xUEtnuV8SkLaJef/HAutcMOW6TVjw7wEjfIBwnqVyAfrnHmERF4L+uL5 Edaw== X-Gm-Message-State: ALoCoQm7OQQtO0rTU4meJ+rw/ZoPTjJ/RCp7BTvze8AGwGiBR/8ljuLRr5Mt2vgVwtl13se3Epb7pDZisuobUPhhYL+zrabw0INW+e8CXRAikTmk1PI0JJ8M7XXEyp8a3lV5AYMaAqGMBRn1KAYQPxZyfVA7LI4800jgdnRdt65NDaxlSuuy0wRy1CcB58rRiKk6x7euDAUfnOhO1R4lqvUk1lKiwlBcpQ== X-Received: by 10.182.53.165 with SMTP id c5mr22054151obp.0.1386008109407; Mon, 02 Dec 2013 10:15:09 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id h47si9071317yhn.0.2013.12.02.10.15.09 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Dec 2013 10:15:09 -0800 (PST) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.72.141]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 10EDD5A4202; Mon, 2 Dec 2013 10:15:09 -0800 (PST) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id A43DD808CD; Mon, 2 Dec 2013 10:15:08 -0800 (PST) From: Doug Anderson To: Wim Van Sebroeck , Guenter Roeck Subject: [PATCH] watchdog: s3c2410_wdt: Report when the watchdog reset the system Date: Mon, 2 Dec 2013 10:14:41 -0800 Message-Id: <1386008082-28740-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.8.4.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131202_131538_447933_8443655E X-CRM114-Status: GOOD ( 16.83 ) X-Spam-Score: -2.6 (--) Cc: Kukjin Kim , linux-watchdog@vger.kernel.org, Leela Krishna Amudala , linux-kernel@vger.kernel.org, Tomasz Figa , Doug Anderson , linux-samsung-soc@vger.kernel.org, Ben Dooks , Olof Johansson , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 A good watchdog driver is supposed to report when it was responsible for resetting the system. Implement this for the s3c2410, at least on exynos5250 and exynos5420 where we already have a pointer to the PMU registers to read the information. Signed-off-by: Doug Anderson --- This patch is based atop Leela Krishna's recent series that ends with (ARM: dts: update watchdog device nodes for Exynos5250 and Exynos5420) AKA . drivers/watchdog/s3c2410_wdt.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 47f4dcf..2c87d37 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -62,9 +62,13 @@ #define CONFIG_S3C2410_WATCHDOG_ATBOOT (0) #define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME (15) +#define RST_STAT_REG_OFFSET 0x0404 #define WDT_DISABLE_REG_OFFSET 0x0408 #define WDT_MASK_RESET_REG_OFFSET 0x040c #define QUIRK_NEEDS_PMU_CONFIG (1 << 0) +#define QUIRK_HAS_RST_STAT (1 << 1) +#define QUIRKS_NEED_PMUREG (QUIRK_NEEDS_PMU_CONFIG | \ + QUIRK_HAS_RST_STAT) static bool nowayout = WATCHDOG_NOWAYOUT; static int tmr_margin; @@ -98,6 +102,9 @@ MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug (default 0)"); * timer reset functionality. * @mask_bit: Bit number for the watchdog timer in the disable register and the * mask reset register. + * @rst_stat_reg: Offset in pmureg for the register that has the reset status. + * @rst_stat_bit: Bit number in the rst_stat register indicating a watchdog + * reset. * @quirks: A bitfield of quirks. */ @@ -105,6 +112,8 @@ struct s3c2410_wdt_variant { int disable_reg; int mask_reset_reg; int mask_bit; + int rst_stat_reg; + int rst_stat_bit; u32 quirks; }; @@ -131,14 +140,20 @@ static const struct s3c2410_wdt_variant drv_data_exynos5250 = { .disable_reg = WDT_DISABLE_REG_OFFSET, .mask_reset_reg = WDT_MASK_RESET_REG_OFFSET, .mask_bit = 20, - .quirks = QUIRK_NEEDS_PMU_CONFIG + .rst_stat_reg = RST_STAT_REG_OFFSET, + .rst_stat_bit = 20, + .quirks = QUIRK_NEEDS_PMU_CONFIG | + QUIRK_HAS_RST_STAT, }; static const struct s3c2410_wdt_variant drv_data_exynos5420 = { .disable_reg = WDT_DISABLE_REG_OFFSET, .mask_reset_reg = WDT_MASK_RESET_REG_OFFSET, .mask_bit = 0, - .quirks = QUIRK_NEEDS_PMU_CONFIG + .rst_stat_reg = RST_STAT_REG_OFFSET, + .rst_stat_bit = 9, + .quirks = QUIRK_NEEDS_PMU_CONFIG | + QUIRK_HAS_RST_STAT, }; static const struct of_device_id s3c2410_wdt_match[] = { @@ -423,6 +438,25 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt) } #endif +static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt) +{ + unsigned int bootstatus = 0; + int ret; + + if (wdt->drv_data->quirks & QUIRK_HAS_RST_STAT) { + unsigned int rst_stat; + + ret = regmap_read(wdt->pmureg, wdt->drv_data->rst_stat_reg, + &rst_stat); + if (ret) + dev_warn(wdt->dev, "Couldn't get RST_STAT register\n"); + else if (rst_stat & BIT(wdt->drv_data->rst_stat_bit)) + bootstatus |= WDIOF_CARDRESET; + } + + return bootstatus; +} + /* s3c2410_get_wdt_driver_data */ static inline struct s3c2410_wdt_variant * get_wdt_drv_data(struct platform_device *pdev) @@ -460,7 +494,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) wdt->wdt_device = s3c2410_wdd; wdt->drv_data = get_wdt_drv_data(pdev); - if (wdt->drv_data->quirks & QUIRK_NEEDS_PMU_CONFIG) { + if (wdt->drv_data->quirks & QUIRKS_NEED_PMUREG) { wdt->pmureg = syscon_regmap_lookup_by_phandle(dev->of_node, "samsung,syscon-phandle"); if (IS_ERR(wdt->pmureg)) { @@ -531,6 +565,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev) watchdog_set_nowayout(&wdt->wdt_device, nowayout); + wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt); + ret = watchdog_register_device(&wdt->wdt_device); if (ret) { dev_err(dev, "cannot register watchdog (%d)\n", ret);