Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1937966imm; Tue, 22 May 2018 11:49:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpbJZhuvc9vEDC9GZshNsymVst1zBFdvw1FnuPoimUFRcRuL+0BkHUqo2Yy+WrP6RWeKvt7 X-Received: by 2002:a17:902:b589:: with SMTP id a9-v6mr25167686pls.161.1527014941198; Tue, 22 May 2018 11:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527014941; cv=none; d=google.com; s=arc-20160816; b=ta3IfAJAgxKAUsNqI+yKXUKrXb62gcSw8vjgPLuQtKZV1tVs684joy//Ixre1jEvTq f8w1/h08kw6lBbKeOXQUCSmkPZ4ibciuELSYvNqWUWMybgnTy7JDOOkxpR9AXKBxOpip RNlgdVcdqDWjxuJrv5/REut8viK3R5DSt4p1IGLAGs5TzCrHL6VQZi/KwIESOza7Khvz sjb96m/V/Hsixlj8lZV8wZ7iXINKj9zp7XfOvWG197BuQaPPA8MoZoo7sRordTp7i/5g 8vqjBxPDq7p6XBjXahjx6SWcMN8o/3N9APLRKTCSExfAdyH5MDCgphdiQaYodyOmfm82 whVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Jkfk/vmdzxfquXSh1Qg6AhVY1hn/WREz3T4y64iMDHY=; b=0l2Nm53KMtxjAXaLialxwgSscOTzsfCcAP/T/UnMM2rRSL2/Glmil5pz/yGQhMnatz IEgSeyYyyyMU6TjjiwZ4BOPp8hHWYFSG26LPxeQJBNncKmuXPKRhWdgZ7WXTtTjtLuzS +SZ58ibGea/NOk+nofmmERxVdHqDEReqMVa/Ftaz/LcuR01BVMhG21+d1SousZ4u4Zqz XOfLbL1X75PeiSrXwhx0I14XcwIWXQNNZb0rFOFPoB20XAoqfiIjRR1Uzz8vpU+mOVr8 /xVhnrz41hTztZME5bgWAATPrEUmmH6wiiT+KaRFrT7D/M28ocD0A1WbggfaoMvvNoAn DGdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=EZX7H74w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32-v6si17310984pls.157.2018.05.22.11.48.46; Tue, 22 May 2018 11:49:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=EZX7H74w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbeEVSrr (ORCPT + 99 others); Tue, 22 May 2018 14:47:47 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:41433 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbeEVSro (ORCPT ); Tue, 22 May 2018 14:47:44 -0400 Received: by mail-qt0-f193.google.com with SMTP id g13-v6so24796201qth.8 for ; Tue, 22 May 2018 11:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Jkfk/vmdzxfquXSh1Qg6AhVY1hn/WREz3T4y64iMDHY=; b=EZX7H74wxR9clbKJAebx/sHkcgpHS0GeF236da5KY/7NRv/1v4xN12ZFaOyFcwW5Ko Eosb8rhdEIJuHAAXiPmdtmMZgekDDAVxtqmhxM6no8r+UqbTgYmxTN5wKfikmJKV1SWy 0cLbooAoAgyq6q6x7YW5Ux7s+CiTzVXm26mjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Jkfk/vmdzxfquXSh1Qg6AhVY1hn/WREz3T4y64iMDHY=; b=P9WeegGcIgj3g8ETe90smzC6LOA9JOsEZoWdnH9i5EhoAwD5FG4J21aIt+A3mbj8Je utKvvPuq8HBHEGTkLGMlxAfV3FodaWQScd/L+PjyezfsI4uVyYSdy4IrxkGm85ScESBZ s9JhQW5WTQOUxqD2UgvKDb9lraoUrf0gNyK/rWkZ5BEpTPjyahojfQdL6OWnIqApR+2e SOgd8pHvUiX0sT0pt7MsfQuYHPClq7RuCZWpDvohRkPvBMXNy0ke9wi1NWT7fkU9dnIj Iby6ES6tAeAFyIeJ/WASn+k4+vnDFN9dhtGUI0CgKsJT6iIFF6P9J7uM2TMxo+RTDKnT AUjw== X-Gm-Message-State: ALKqPwfanaJRexPGRhEjGXpC7sQsVs2wgkOH6E1JwCAp1V5+mnN9rNq4 1/ic3BEUJHeTNbca97UeghHH1w== X-Received: by 2002:ac8:21b4:: with SMTP id 49-v6mr17298905qty.315.1527014864212; Tue, 22 May 2018 11:47:44 -0700 (PDT) Received: from lbrmn-lnxub44-1.ric.broadcom.com ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id i69-v6sm192501qke.87.2018.05.22.11.47.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 May 2018 11:47:43 -0700 (PDT) From: Ray Jui To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Mark Rutland , Frank Rowand , Catalin Marinas , Will Deacon Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Ray Jui Subject: [PATCH 3/5] watchdog: sp805: set WDOG_HW_RUNNING when appropriate Date: Tue, 22 May 2018 11:47:18 -0700 Message-Id: <1527014840-21236-4-git-send-email-ray.jui@broadcom.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1527014840-21236-1-git-send-email-ray.jui@broadcom.com> References: <1527014840-21236-1-git-send-email-ray.jui@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the watchdog hardware is already enabled during the boot process, when the Linux watchdog driver loads, it should reset the watchdog and tell the watchdog framework. As a result, ping can be generated from the watchdog framework, until the userspace watchdog daemon takes over control Signed-off-by: Ray Jui Reviewed-by: Vladimir Olovyannikov Reviewed-by: Scott Branden --- drivers/watchdog/sp805_wdt.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index 1484609..408ffbe 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -42,6 +42,7 @@ /* control register masks */ #define INT_ENABLE (1 << 0) #define RESET_ENABLE (1 << 1) + #define ENABLE_MASK (INT_ENABLE | RESET_ENABLE) #define WDTINTCLR 0x00C #define WDTRIS 0x010 #define WDTMIS 0x014 @@ -74,6 +75,18 @@ module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Set to 1 to keep watchdog running after device release"); +/* returns true if wdt is running; otherwise returns false */ +static bool wdt_is_running(struct watchdog_device *wdd) +{ + struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); + + if ((readl_relaxed(wdt->base + WDTCONTROL) & ENABLE_MASK) == + ENABLE_MASK) + return true; + else + return false; +} + /* This routine finds load value that will reset system in required timout */ static int wdt_setload(struct watchdog_device *wdd, unsigned int timeout) { @@ -239,6 +252,15 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) watchdog_init_timeout(&wdt->wdd, 0, &adev->dev); wdt_setload(&wdt->wdd, wdt->wdd.timeout); + /* + * If HW is already running, enable/reset the wdt and set the running + * bit to tell the wdt subsystem + */ + if (wdt_is_running(&wdt->wdd)) { + wdt_enable(&wdt->wdd); + set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); + } + ret = watchdog_register_device(&wdt->wdd); if (ret) { dev_err(&adev->dev, "watchdog_register_device() failed: %d\n", -- 2.1.4