From patchwork Tue Jun 18 15:20:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 2744531 Return-Path: X-Original-To: patchwork-linux-arm@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 1EFF6C0AB1 for ; Tue, 18 Jun 2013 17:55:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 181D020249 for ; Tue, 18 Jun 2013 17:55:31 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F321720248 for ; Tue, 18 Jun 2013 17:55:28 +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 1UoxmF-0003vP-TR; Tue, 18 Jun 2013 15:25:03 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uoxkh-0003NM-N1; Tue, 18 Jun 2013 15:23:23 +0000 Received: from mail-pd0-f172.google.com ([209.85.192.172]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uoxjn-0003Gc-EV for linux-arm-kernel@lists.infradead.org; Tue, 18 Jun 2013 15:22:28 +0000 Received: by mail-pd0-f172.google.com with SMTP id z10so4037442pdj.3 for ; Tue, 18 Jun 2013 08:22:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=pCpe58cd9oE94+byj9TzkZZnUgFq3yE4/EqZ1QcfuAI=; b=LLhUS8RHw3M6gCA0hH2pExIHe843EkiAxN46ieVt3fIYkVOk2gBN/utzwOTQT90/Vw LbPGnNVLf99pL4zkjlmrmRnE+vcHX66bhXZO+RKcby3Caf90K5VYnBYv67U9AJw2wx3w MEo4/FefGeE0dVi5jm+MCsW6CV6Pg9utrbOoGiKatbwYqrrc2nOyx9yGBrgPqUDQM8oW /LSdxVOV2opCTJoU7HR1hSDZgTeJTLVVwPoh8luUVwrgd9fvwHYryr85+libXKcxzdGf E52z9ILVP75X5szEgcO7/77qXoprspAG5/BfNmOd+KQSJe+hICjEbBzGHD3OXnmRgU89 /ilQ== X-Received: by 10.66.251.39 with SMTP id zh7mr2616176pac.62.1371568926550; Tue, 18 Jun 2013 08:22:06 -0700 (PDT) Received: from localhost ([122.167.240.191]) by mx.google.com with ESMTPSA id sq5sm20106011pab.11.2013.06.18.08.22.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 18 Jun 2013 08:22:05 -0700 (PDT) From: Viresh Kumar To: wim@iguana.be Subject: [PATCH V3 10/14] watchdog/mpcore_wdt: Add support for WDIOC_GETBOOTSTATUS IOCTL Date: Tue, 18 Jun 2013 20:50:34 +0530 Message-Id: <80203f4eb36a430fafe91ac90102fd932987ad49.1371535243.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQn3hpf8eGi35GJZcExt1cgkLvvYWjPvNDzdh6XD0EcGlh1TVqK2TScg+7LJnDJAC4wxx7PR X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130618_112227_605713_3431EBD7 X-CRM114-Status: GOOD ( 13.06 ) X-Spam-Score: -1.9 (-) Cc: marc.zyngier@arm.com, Viresh Kumar , linux-watchdog@vger.kernel.org, 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=-5.4 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 mpcore watchdog can give last boot status, whether we got a watchdog reset or not, via bit 0 of TWD_WDOG_RESETSTAT register. This patch adds support to return correct status if WDIOC_GETBOOTSTATUS cmd is called with ioctl. Signed-off-by: Viresh Kumar --- arch/arm/include/asm/smp_twd.h | 2 ++ drivers/watchdog/mpcore_wdt.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h index 7b2899c..a62bcfa 100644 --- a/arch/arm/include/asm/smp_twd.h +++ b/arch/arm/include/asm/smp_twd.h @@ -18,6 +18,8 @@ #define TWD_TIMER_CONTROL_PERIODIC (1 << 1) #define TWD_TIMER_CONTROL_IT_ENABLE (1 << 2) +#define TWD_WDOG_RESETSTAT_MASK 0x1 + #include struct twd_local_timer { diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c index d8917ad..43f749d 100644 --- a/drivers/watchdog/mpcore_wdt.c +++ b/drivers/watchdog/mpcore_wdt.c @@ -151,6 +151,7 @@ static int mpcore_wdt_set_heartbeat(struct watchdog_device *wdd, unsigned int t) static const struct watchdog_info mpcore_wdt_info = { .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | + WDIOF_CARDRESET | WDIOF_MAGICCLOSE, .identity = "MPcore Watchdog", }; @@ -216,6 +217,9 @@ static int mpcore_wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, wdt); watchdog_set_drvdata(&wdt->wdd, wdt); + wdt->wdd.bootstatus = (readl_relaxed(wdt->base + TWD_WDOG_RESETSTAT) & + TWD_WDOG_RESETSTAT_MASK) ? WDIOF_CARDRESET : 0; + mpcore_wdt_stop(&wdt->wdd); ret = watchdog_register_device(&wdt->wdd);