Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1274981ybe; Thu, 5 Sep 2019 12:59:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3/vRrWOml1OCj7tNGlu6MHV5t1/beOGi93VB1XLMpJFQDQxWljywXX+W6gbVfZq7nhTlA X-Received: by 2002:aa7:9341:: with SMTP id 1mr6259614pfn.202.1567713549059; Thu, 05 Sep 2019 12:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567713549; cv=none; d=google.com; s=arc-20160816; b=Xmpubg/VnORctFTmNmnHnSuKFOb2S744FXgRO99WLpigKIiNICnvCnLAMwCLSyttw7 6iQLuGlChaeroD0gbzbfGR/W+nD36wblXkd0ve/W/VZ/s6IaWP+Gz4Et7j5fpwtzt4FH ZBTXG3NkqoY7fSewrHRVEeHglMZOkrpEBP+GDrmQgxNzT3kfpr3ng+YqJ2Tu9o/DhaYA ubM05GeAPGx3n/Q/NORgE5LqQkxF00X+pDXmeYU/P0tKvUwKakb9UOvDtMA2g9mZc+o4 ZZxBpv9fzp7YXJcoQbT1btc94K6lx8kHTYKe2FoWY3h1XlX/LYI4flTQuZ3ukI1mhOgU Aglw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+9iLVBaa77JA8FyvG+ioZMPXcw60MqtuvgoQBEbIVQs=; b=A35LKN9nZFXDydhOXE5gG8mwKRWD7Bh5mGRWbu3z5h4UQFlEszJJJe7+RYy/bDjWfD 7yW2us1H5p9kKbjsR5iaEMh6yEhN3mUj92Q8jlPMF9KNNlLHUUt6nolFUAUQuFs/mqag nQfFZxQ42Cv4ScRAIETiKnyqQJBZ6/jmjrihP6OoJmr8JWyN1LHxclVNpCaH8NE3GLo8 3tLYVuk41i75qFPrH0AdAfTaM7LLCMvr5RSyHPTQ/iL2sFnWAp7GkImnwA93qly0HPSD j5a/AcVtHabKwMg/YM982SusOyDN4bIz0bcNHsuVBIVB4EJR6Prcr4Emt63W+5b6Vfrd rbVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IiMddi9X; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si2855276plz.299.2019.09.05.12.58.52; Thu, 05 Sep 2019 12:59:09 -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=@linaro.org header.s=google header.b=IiMddi9X; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729134AbfIEQVm (ORCPT + 99 others); Thu, 5 Sep 2019 12:21:42 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39960 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbfIEQVl (ORCPT ); Thu, 5 Sep 2019 12:21:41 -0400 Received: by mail-wr1-f66.google.com with SMTP id w13so3505213wru.7 for ; Thu, 05 Sep 2019 09:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+9iLVBaa77JA8FyvG+ioZMPXcw60MqtuvgoQBEbIVQs=; b=IiMddi9XvQ+WhSZ/tO/2VdQVWHIifwCGUsJHL8xdl+HVbJw73QtadzdFxVoc7b8lCt LfpjaOnqC/L+IcJ/9IYr9kUTYkluemZQtJWpEoN3DIs4YDXXShm1Ugmyxok55XqovOJM IHqSdYIMkcB/X2NcnFtomsciSyvLxMQLI1zs9XTp7OnCecrOezcZHl3w7XaNEA7v0hGU HmlhGS+QkdpfWDYKJD2blpohVRa7Y0r+964nsxfNGlzvFvszzjkSAyRaE8UJrsMoC3uP XXYkRFe+njHAhSI7FKiWqFybTT9CJRsbmfhrryUXS/EieDGxrghx8pHrlaC1rWnn8SVr q3Gw== 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:mime-version :content-transfer-encoding; bh=+9iLVBaa77JA8FyvG+ioZMPXcw60MqtuvgoQBEbIVQs=; b=CTg87jKCz3A5tKzmaNF0DjJaLYjUcFbH9oze/Zpzq+GwHO/pE31LbTRC2Tkkjfx49U OKNsoOHTjcVJuVQttO/gbpw2vonF6fNx1JTNFKH9njkMvrXAHPWZQOIelI6qMgEnibh4 b78IQMj/B7m4oKqXYKAEzcUjvMo+Z8GcqXCRpWWjaFRt1gHzw/jZgRnx8zYM7az03DwB 1EMdBUU8ie1pXCGGTNLkqnAZj+uuReBbdjKudTdSxLiwu6tEBGKNIkdnLoCaIaLJVI0E 9afIHh5jdjer5zhwOJFcf5iCVPX1/7EyUo6ZQ9OWXxlYDfMuyC4TXnGttam+8id1UHzK ULZA== X-Gm-Message-State: APjAAAV5ORTHI/gf7RFF16REY3XNmfedCtNZtb/QGXPcvtLM32lxZVSy 1/wDPZ3Rp8SZqKLlXi+VS70rvg== X-Received: by 2002:a5d:4a81:: with SMTP id o1mr3143492wrq.328.1567700499515; Thu, 05 Sep 2019 09:21:39 -0700 (PDT) Received: from localhost.localdomain (124.red-83-36-179.dynamicip.rima-tde.net. [83.36.179.124]) by smtp.gmail.com with ESMTPSA id i73sm4183550wmg.33.2019.09.05.09.21.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Sep 2019 09:21:38 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, agross@kernel.org, wim@linux-watchdog.org Cc: linux-arm-msm@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org Subject: [PATCH] watchdog: qcom: add support for the bark interrupt Date: Thu, 5 Sep 2019 18:21:35 +0200 Message-Id: <20190905162135.2618-1-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the bark interrupt to notify the bark event. Since the bark and bite timeouts are identical, increase the bite timeout by one second so that the bark event can be logged to the console. Signed-off-by: Jorge Ramirez-Ortiz --- drivers/watchdog/qcom-wdt.c | 42 ++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c index 7be7f87be28f..5eaf92084b93 100644 --- a/drivers/watchdog/qcom-wdt.c +++ b/drivers/watchdog/qcom-wdt.c @@ -10,6 +10,7 @@ #include #include #include +#include enum wdt_reg { WDT_RST, @@ -41,6 +42,8 @@ struct qcom_wdt { unsigned long rate; void __iomem *base; const u32 *layout; + unsigned int irq; + const struct device *dev; }; static void __iomem *wdt_addr(struct qcom_wdt *wdt, enum wdt_reg reg) @@ -54,15 +57,37 @@ struct qcom_wdt *to_qcom_wdt(struct watchdog_device *wdd) return container_of(wdd, struct qcom_wdt, wdd); } +static inline int qcom_wdt_enable(struct qcom_wdt *wdt) +{ + if (wdt->irq < 0) + return 1; + + /* enable timeout with interrupt */ + return 3; +} + +static irqreturn_t qcom_wdt_irq(int irq, void *cookie) +{ + struct qcom_wdt *wdt = (struct qcom_wdt *) cookie; + + dev_warn(wdt->dev, "barking, one second countdown to reset\n"); + + return IRQ_HANDLED; +} + static int qcom_wdt_start(struct watchdog_device *wdd) { struct qcom_wdt *wdt = to_qcom_wdt(wdd); + unsigned int bark, bite; + + bark = wdd->timeout; + bite = wdt->irq < 0 ? bark : bark + 1; writel(0, wdt_addr(wdt, WDT_EN)); writel(1, wdt_addr(wdt, WDT_RST)); - writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BARK_TIME)); - writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BITE_TIME)); - writel(1, wdt_addr(wdt, WDT_EN)); + writel(bark * wdt->rate, wdt_addr(wdt, WDT_BARK_TIME)); + writel(bite * wdt->rate, wdt_addr(wdt, WDT_BITE_TIME)); + writel(qcom_wdt_enable(wdt), wdt_addr(wdt, WDT_EN)); return 0; } @@ -210,10 +235,21 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->wdd.max_timeout = 0x10000000U / wdt->rate; wdt->wdd.parent = dev; wdt->layout = regs; + wdt->dev = &pdev->dev; if (readl(wdt_addr(wdt, WDT_STS)) & 1) wdt->wdd.bootstatus = WDIOF_CARDRESET; + wdt->irq = platform_get_irq(pdev, 0); + if (wdt->irq >= 0) { + ret = devm_request_irq(&pdev->dev, wdt->irq, qcom_wdt_irq, + IRQF_TRIGGER_RISING, "wdog_bark", wdt); + if (ret) { + dev_err(&pdev->dev, "failed to request irq\n"); + return ret; + } + } + /* * If 'timeout-sec' unspecified in devicetree, assume a 30 second * default, unless the max timeout is less than 30 seconds, then use -- 2.23.0