From patchwork Tue Jul 5 00:10:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12905876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9EC7C43334 for ; Tue, 5 Jul 2022 00:10:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229921AbiGEAKq (ORCPT ); Mon, 4 Jul 2022 20:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiGEAKp (ORCPT ); Mon, 4 Jul 2022 20:10:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554827679; Mon, 4 Jul 2022 17:10:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D46A5617CC; Tue, 5 Jul 2022 00:10:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F723C3411E; Tue, 5 Jul 2022 00:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656979844; bh=GZXdKDMAyi94zceUrqKEoALCT5a3//6hTpa2tObUO3U=; h=From:To:Cc:Subject:Date:From; b=k7YOU1K4x82eEDkkeGHZhkXb8G+rEx4IzH3e8hIuYfBamCcpWrtk14Tuw2kBIPK76 3BbSZA44l3Qv//AgrOaGIPBokdCzzDJXKI8pP4G1ROdgkFbpELmEMZoZj98uwZip6R pSVo8BNNd0zysUDd8yVE/QepF0N35vjOaLSwr0kzTR69g/GGnatauULax1XZHaJ7dJ aoary8r2/08bFNkREfLwITFPdFh0eKc2KFgPJTGTXHWdOm0861vXdzXoJBmvfOozYJ p30LCl+MnLdnj9HX+3hqNhiKiYCx4hs9Z3J67T1tFCkcJXXBpFKLAb/fpp0+H2uLNH baLBeoJ1rbSKQ== Received: by pali.im (Postfix) id 7C05979F; Tue, 5 Jul 2022 02:10:41 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Wim Van Sebroeck , Guenter Roeck , Rob Herring Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Date: Tue, 5 Jul 2022 02:10:22 +0200 Message-Id: <20220705001023.14660-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org GPIO is optional and used for WDI logic. Signed-off-by: Pali Rohár --- Changes in v3: * Extend description --- Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml index ab9641e845db..a0cf9e6c371d 100644 --- a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml +++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml @@ -27,6 +27,10 @@ properties: description: This is a 1-byte memory-mapped address maxItems: 1 + gpios: + description: Optional GPIO used for controlling WDI (watchdog input) when WDI bit is not mapped to memory + maxItems: 1 + required: - compatible - reg From patchwork Tue Jul 5 00:10:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12905877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DDADC43334 for ; Tue, 5 Jul 2022 00:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbiGEAKs (ORCPT ); Mon, 4 Jul 2022 20:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230240AbiGEAKr (ORCPT ); Mon, 4 Jul 2022 20:10:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363A07679; Mon, 4 Jul 2022 17:10:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C543E617C7; Tue, 5 Jul 2022 00:10:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F5CAC3411E; Tue, 5 Jul 2022 00:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656979845; bh=49WWV0PmMuNRg/toHTxKXTpcl6lIvnWwBTpEL9Jpxkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rv45oJlYmwVtT9maPUlCgydT5QmYW1wdIDcDGWzYRptDQZXtY8tEmpD3aYMUtZy/2 PZNNH6tfw56s1HWcioN9aYkAyAUDNWTNg7t0pRCPgDGtQsqlYdguO9sNpWJKuDdSUM WQY8lG5PI2u0v+bh8Bykht1TJFZUgoDk15TrjgJbTVcg4YTLlpRxUqNyW22YDGgmzI 8a/1/87I5+Pa1ob1Za4rTRFSBBOIae2BPDZqcbjB3lHua+N6/J7yPdpzp2FrAoalbZ JzMov3JLO2AAwobqk4gW/kJIUuEzGYW5CffvGXXCqCafodAT6LcZs/bSDNeqOHWCZI Rkn1QROl8JuCg== Received: by pali.im (Postfix) id 7D1317AE; Tue, 5 Jul 2022 02:10:42 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Wim Van Sebroeck , Guenter Roeck , Rob Herring Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Date: Tue, 5 Jul 2022 02:10:23 +0200 Message-Id: <20220705001023.14660-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220705001023.14660-1-pali@kernel.org> References: <20220705001023.14660-1-pali@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org On some boards is WDI logic of max6370 chip connected via GPIO. So extend max63xx_wdt driver to allow specifying WDI logic via GPIO. Signed-off-by: Pali Rohár --- Changes in v3: * Use gpiod_set_value() Changes in v2: * Usage of dev_err_probe() * Fixing assignment of wdt->ping * Remove clearing of wdt->gpio_wdi * Move YAML change to separate patch --- drivers/watchdog/max63xx_wdt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c index 9e1541cfae0d..4718695837f6 100644 --- a/drivers/watchdog/max63xx_wdt.c +++ b/drivers/watchdog/max63xx_wdt.c @@ -27,6 +27,7 @@ #include #include #include +#include #define DEFAULT_HEARTBEAT 60 #define MAX_HEARTBEAT 60 @@ -53,6 +54,9 @@ struct max63xx_wdt { void __iomem *base; spinlock_t lock; + /* GPIOs */ + struct gpio_desc *gpio_wdi; + /* WDI and WSET bits write access routines */ void (*ping)(struct max63xx_wdt *wdt); void (*set)(struct max63xx_wdt *wdt, u8 set); @@ -158,6 +162,17 @@ static const struct watchdog_info max63xx_wdt_info = { .identity = "max63xx Watchdog", }; +static void max63xx_gpio_ping(struct max63xx_wdt *wdt) +{ + spin_lock(&wdt->lock); + + gpiod_set_value(wdt->gpio_wdi, 1); + udelay(1); + gpiod_set_value(wdt->gpio_wdi, 0); + + spin_unlock(&wdt->lock); +} + static void max63xx_mmap_ping(struct max63xx_wdt *wdt) { u8 val; @@ -225,10 +240,19 @@ static int max63xx_wdt_probe(struct platform_device *pdev) return -EINVAL; } + wdt->gpio_wdi = devm_gpiod_get(dev, NULL, GPIOD_FLAGS_BIT_DIR_OUT); + if (IS_ERR(wdt->gpio_wdi) && PTR_ERR(wdt->gpio_wdi) != -ENOENT) + return dev_err_probe(dev, PTR_ERR(wdt->gpio_wdi), + "unable to request gpio: %ld\n", + PTR_ERR(wdt->gpio_wdi)); + err = max63xx_mmap_init(pdev, wdt); if (err) return err; + if (!IS_ERR(wdt->gpio_wdi)) + wdt->ping = max63xx_gpio_ping; + platform_set_drvdata(pdev, &wdt->wdd); watchdog_set_drvdata(&wdt->wdd, wdt);