From patchwork Mon Oct 16 20:54:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 115990 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4110459qgn; Mon, 16 Oct 2017 13:56:53 -0700 (PDT) X-Received: by 10.84.133.132 with SMTP id f4mr4591130plf.197.1508187413435; Mon, 16 Oct 2017 13:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508187413; cv=none; d=google.com; s=arc-20160816; b=z3DFP3GFKC9Pf5CWV7nv3ApKmTOn3kEw6zAHXRMDWRmvOUvXExGrcFatEtYrLji352 RI//8GHnlhYsDNv3b+73XN3ngSTBwXiqUMMXOy85O+L+xPnvlhzI3fBll2BmrMtOutsc ulUiW//E5BGWZNEmW33X4jgaLbQaivppiMN5GSEZz6aJxxbrVR3DMBmg7rp1uJnx8IXY V+jbCfjTim/jumV4JHRcsStDLjJC7atY6qLD8p4Kmg+eyRoq5DjJt6JHvE3jNKTSL/3Z 2gC93nB1um3vZAe+t4wK/svIy7GmrreRbaGH2E8X08Gzly+/efncTuCcJlxo9DmJelQm Yt4g== 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=foFCpQt4kL9VzngFO5Xm2Se9UphMHwcivrYPLWquyLI=; b=MNS2jnWJ1E4S2+PIBBgpvzvBdnKjqsc/jiF4usYC3pLKwIEbo6pWMykJz9ohaIudMz AYgNt0f6NfPENDVMOS0owaiWBMJqbAFOjGoOXonLYe1mwVEZLaki6mpk+5uhCyYApam7 koqM1Ovt72PXe+SOgAAO9oFHFFNPGbJ/HADjMtcJowDSB4tHu0xw+SPM+5PfLfUXnGFL O8uXLKixuJI/JWP5+Jjwl63Iy+aqFE6gleF80vLfP+nWbQgUW2IEN9jpT2bpnbksmA5x w1Jj94Ys1C6er/SIM5aATB0MGidb+MVZAFfcEjIFqIGT4BX3FWlZmGlIQ0gAbj4RwAzw tVeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Zwwt+UI8; 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=fail (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 m6si533400pff.595.2017.10.16.13.56.53 for ; Mon, 16 Oct 2017 13:56:53 -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=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Zwwt+UI8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756675AbdJPU4x (ORCPT ); Mon, 16 Oct 2017 16:56:53 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:52110 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755144AbdJPU4w (ORCPT ); Mon, 16 Oct 2017 16:56:52 -0400 Received: by mail-lf0-f41.google.com with SMTP id r129so18496637lff.8 for ; Mon, 16 Oct 2017 13:56:51 -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:in-reply-to:references; bh=9A+BNOiDa3aYLS3oENhnKHPLSc8SUB0rAx6vyyhxbwY=; b=Zwwt+UI8P3DiHBO/jpZyreHRlWYnxCLy/m9cS6Bd1fwdF8v2JzMcoXUaKIwbCqAkfY UnEMh8lnDMj38TOR4phzMFf0wK4YYqKYI1bgFFLZ5gKmvqvKlLL2Mr9xP3Sn00TryCGN I84iSTk2/NQG5N2oDHzDXCBhEvyaLri+e9l9w= 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=9A+BNOiDa3aYLS3oENhnKHPLSc8SUB0rAx6vyyhxbwY=; b=PRnqkEHTff7m3uuNK/1pZmLBUUAsx/OVECbA467gF37732ilifpBPTOWe3DD7D0LYu qrR16gmMIy5rj3+Ejk5O3ycG5oHH+6DUdvihBBEdGxiXtFsLWXwkC+m17Siswb7Ps9Ez wwWcOA+D/sAelZ4IcYdu81FOld0FmpYdXM7mJ6CoEwBq/DpOz92bWgOCAuhXdiqEFeAV W2pjljSyGQK/+zAEaC4nlAl4tErdEgwPYWDHbopApliprlzzKKYnjOHb6jmL/X8ziNhk 22NAO2wJUT5B7n/D/geLfYDx8uBZ0f/9j1b4jsbHZhyjpy6E0tOTHYqLePtlMS9uCSUh UwNg== X-Gm-Message-State: AMCzsaWPM9NTIMhsUwB/dtV75eu/JWKFQDLbCl3/r8nMEQqtFEm5oeoA wUG+1Zk6a+lVBesZZ34/eF1Ysw== X-Google-Smtp-Source: ABhQp+QX/KHsUrc0LV7KnoCqP6tRMflJgFCjSgIojbMMyBhJ5XDOLaMufQuy2i11hw9t1/HpjlAbTA== X-Received: by 10.25.40.149 with SMTP id o143mr3483891lfo.237.1508187411093; Mon, 16 Oct 2017 13:56:51 -0700 (PDT) Received: from localhost.localdomain (c-5f7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.95]) by smtp.gmail.com with ESMTPSA id s88sm2131227lje.40.2017.10.16.13.56.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 13:56:50 -0700 (PDT) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck , Jonas Jensen , Andrew Jeffery , Joel Stanley Cc: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, Linus Walleij Subject: [PATCH 3/5 v2] watchdog: ftwdt010: Make interrupt optional Date: Mon, 16 Oct 2017 22:54:25 +0200 Message-Id: <20171016205427.4297-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016205427.4297-1-linus.walleij@linaro.org> References: <20171016205427.4297-1-linus.walleij@linaro.org> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The Moxart does not appear to be using the interrupt from the watchdog timer, maybe it's not even routed, so as to support more architectures with this driver, make the interrupt optional. While we are at it: actually enable the use of the interrupt if present by setting the right bit in the control register and define the missing control register bits. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Fix surplus flag assignment of enable |= WDCR_CLOCK_5MHZ --- drivers/watchdog/ftwdt010_wdt.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Guenter Roeck diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c index 637ffd812f0b..a9c2912ee280 100644 --- a/drivers/watchdog/ftwdt010_wdt.c +++ b/drivers/watchdog/ftwdt010_wdt.c @@ -30,6 +30,8 @@ #define WDRESTART_MAGIC 0x5AB9 #define WDCR_CLOCK_5MHZ BIT(4) +#define WDCR_WDEXT BIT(3) +#define WDCR_WDINTR BIT(2) #define WDCR_SYS_RST BIT(1) #define WDCR_ENABLE BIT(0) @@ -39,6 +41,7 @@ struct ftwdt010_wdt { struct watchdog_device wdd; struct device *dev; void __iomem *base; + bool has_irq; }; static inline @@ -50,14 +53,17 @@ struct ftwdt010_wdt *to_ftwdt010_wdt(struct watchdog_device *wdd) static int ftwdt010_wdt_start(struct watchdog_device *wdd) { struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); + u32 enable; writel(wdd->timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD); writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART); /* set clock before enabling */ - writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST, - gwdt->base + FTWDT010_WDCR); - writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST | WDCR_ENABLE, - gwdt->base + FTWDT010_WDCR); + enable = WDCR_CLOCK_5MHZ | WDCR_SYS_RST; + writel(enable, gwdt->base + FTWDT010_WDCR); + if (gwdt->has_irq) + enable |= WDCR_WDINTR; + enable |= WDCR_ENABLE; + writel(enable, gwdt->base + FTWDT010_WDCR); return 0; } @@ -133,10 +139,6 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) if (IS_ERR(gwdt->base)) return PTR_ERR(gwdt->base); - irq = platform_get_irq(pdev, 0); - if (!irq) - return -EINVAL; - gwdt->dev = dev; gwdt->wdd.info = &ftwdt010_wdt_info; gwdt->wdd.ops = &ftwdt010_wdt_ops; @@ -158,10 +160,14 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) writel(reg, gwdt->base + FTWDT010_WDCR); } - ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0, - "watchdog bark", gwdt); - if (ret) - return ret; + irq = platform_get_irq(pdev, 0); + if (irq) { + ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0, + "watchdog bark", gwdt); + if (ret) + return ret; + gwdt->has_irq = true; + } ret = devm_watchdog_register_device(dev, &gwdt->wdd); if (ret) {