From patchwork Thu Sep 5 16:21:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 173172 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp939730ilq; Thu, 5 Sep 2019 09:21:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWeT/K/wyHtWUySAioZ4Xt8axJAcrI7K1lSukhduyxRu/by2nFEySsyGh8YP06AnR4ZdQe X-Received: by 2002:a62:2ccf:: with SMTP id s198mr1694039pfs.216.1567700502223; Thu, 05 Sep 2019 09:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567700502; cv=none; d=google.com; s=arc-20160816; b=sH2n4FFSZhJBd5jbgYhfgaS/o50UCaaCRf3srwUu8NXAorLuCgAsdqvZOH7XZBYOgK Px9lqXEdADzilW4HbFtt6aEDBkd2RNCqR+DXTs2ZaRpeV23WRcmE+GhmVLD9s6U8ihWc Ou2BBquPy7yTATcqX1wvmau/MOh8HUNxMMTaZDEIdOV3mVzob4y3Eona5w/pwqGmXtp7 FlPGvy98RkYgxq5Ouc7UV0VBN4Z+mpfb4loMf+u5pFihQSNGEIOKc3VUtMhqtdWxBcfP eHjZbTbauYWF5PBUIfCptnMVTyH/iSbz81J1uPbOOSGw/ah8ignM4ii5ZWzY3i4nT7WA 95mg== 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=o+d5weXmVV/j6fqOmGGOrYjxQytNRL0MecJZQBDT3SIqt8XZCBOTA/mbGlWXA1t2XD n3q8jY9WQ1mC+Fyb5Mr4NKNCACmkD8sOFIPoO/2lWAS/ZuHYDzXOF0aIo6LH2JJ/9MQB /+hSYxxBJyfbUVMjxR5TTlWPF+9zb41Ddynt2mje9FxKgNLXQThQy57ylJDGDicdzGaO yq64o44z29EdLdtf1Yz7jKaLdTLrxrJc7bbrIWN9DgE2Mp93ifnQRcDfr5bmCOSsO2WR yAm3M9o3F1ycn1TJie5ADvb2+7gY6l55suv3qFgJP/MCDlCZzEfe4E121EFLzd/yYqtB P9yw== 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-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-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 w4si2279001plq.1.2019.09.05.09.21.42 for ; Thu, 05 Sep 2019 09:21:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-watchdog-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-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-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 S1726462AbfIEQVl (ORCPT ); Thu, 5 Sep 2019 12:21:41 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46629 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbfIEQVl (ORCPT ); Thu, 5 Sep 2019 12:21:41 -0400 Received: by mail-wr1-f65.google.com with SMTP id h7so3483074wrt.13 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=tXpBNHZteUkzfdPIrrld01/xOYl98ad9cJiKpv1Fl3dyP7SCZHTcYUY5dermjLwU6L kvsYlW7OwUSmAfC54GFCVM5XIkPP/Ta69AxMewIAHUUcP0aVMyEB6Jyra3hu/B0iRhoO Gr6IXCEeQp/ZyY4TnO61uFHZV5/XEcCAurQLSFQwr0xuuj47643+yjFqTvP93T5GwEI9 dEWfp/lhiFRdeWHWGbj9EzJdaOi523HuHsM5SV+B55Uz0Wng77B28ACJPmBUxJytnTyX qDLk+k/BOUnk208GAqbFdXvuWjqnJtBzaikkz1d03lmk8OYv6hJXhwbQC1d78jJMuJQ1 m6KQ== X-Gm-Message-State: APjAAAXB1zoBp+x7Kgfdux0nGbojuVkR/l3RE4TbqusFdDOrmIOez5BW eosIkJyscdc9tAvufZ+riOASjA== 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 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@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(-) -- 2.23.0 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