Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1508586iob; Fri, 29 Apr 2022 06:57:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyihHWA3hp/pS53EqWk4U8diDEr9nX4ssqastXdU0B5Ppsvr6OCzeVlV/a+bp/RRdZRlutQ X-Received: by 2002:a2e:9d06:0:b0:24c:7dee:4d58 with SMTP id t6-20020a2e9d06000000b0024c7dee4d58mr24689938lji.177.1651240664339; Fri, 29 Apr 2022 06:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651240664; cv=none; d=google.com; s=arc-20160816; b=DGl70wXWPqaiZfTcfyK5gMfKQqs1yQWYMJb8oWsIGcjsoDwNMjBgyF2bovejtUBqMp 3Li6rGqakJ6Tl/5NS/WmXM96jQ9tq6oqJgsA4lvyZrsLvivzmrcUbDCCRgR+swRCCXqt ucyoWSyTF//MF642A4GXqYnqBxoYWzk67CHPSJEiohJFt7L+asJaFMivBS2zhaCDnyEa qS41TpjpWFWkA87zEddUjHuvWJwUTLnHXglK06L2a0Of4+hBktKLUSxDWfhvZkUmnPx3 RwS8O4C7FxxffJf8HqBEEYXtzAjUWqUeh2Cc5ZP5UHGwsAKhCAFcM0oqPIHEVowUgAx0 E5MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=y2ZaKMDL9fkv+EP8iPdRSnriZUgb+CuW446lPH8Z/os=; b=jIJEyQy/do2OCCbgBGi961kb5PXu826oyTVjiqfv2cmlx/0lkd70cKRj2n0XAvhC+D uFx6i7kk6uMoNOuvMLckk7p2KlSnno6He+2aiV5R3FPv6N7hpKyaoyJVzzmYB/QW3Pud oM5xrCybbNn4Q5ANVFM3vQoJywM1JoHOw50BhQoSNg8x5Q0rJcPDXT+ayvrl6vDkBzG0 CXIQSHYDaMfIlldBP8ckChRco12T2ngN8JSbMtJEz/uA+GtSD2N3lXVUrxXkx+EKl/P4 bhQH84aGS/XRe6t41yqg3gqh7Hqj3Q8howQ1K8841jZnn56thho3FEy2goDKghC0JExE 6/1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tFon7tQH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd25-20020a05651c169900b0024f21f2ce4csi6953959ljb.414.2022.04.29.06.57.17; Fri, 29 Apr 2022 06:57:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tFon7tQH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359766AbiD2NXw (ORCPT + 99 others); Fri, 29 Apr 2022 09:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359753AbiD2NXp (ORCPT ); Fri, 29 Apr 2022 09:23:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6F3EB6478; Fri, 29 Apr 2022 06:20:26 -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 ams.source.kernel.org (Postfix) with ESMTPS id 54B4FB833F7; Fri, 29 Apr 2022 13:20:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C45B0C385A4; Fri, 29 Apr 2022 13:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651238423; bh=rHVYr57dbOsqQzVGO8ZUi+05f97hAqo5rq0GSWs8oNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tFon7tQHLarg5gre2seT0mH3cSWZoXUXwW0QTQ+oDGO+HBypTAl7c675rnYZ0/kZt VvXR6Yy4P9islJsz6yqTN9wqXIasqjWT7qL2Co9nCrCqPBOfFZUW+2T9SKdPRU/Ht4 yFX+gDj6Y3xndZcMikWHkksAvwZQxZv5S13qMh8Pna/Tn/WqSV2scd4efTL6to0Xgj r2eczmfvtNm8+OBpxL6dSGcTCq1ApnPCd/FSmV58SSxDlgR7/jYtnlSkuDuEqf8nPM qKIezZetKwLoIxjRPh3dhnB7bJIu8FnUqE7Vtxh+kjSLGah99+XzR+cl/SZNAEFCII 2a6hyHtdmn3dA== Received: by pali.im (Postfix) id 4D5CCCAF; Fri, 29 Apr 2022 15:20:21 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=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 v2 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Date: Fri, 29 Apr 2022 15:13:49 +0200 Message-Id: <20220429131349.21229-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220429131349.21229-1-pali@kernel.org> References: <20220429131349.21229-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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..6e43f9e6d7eb 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_cansleep(wdt->gpio_wdi, 1); + udelay(1); + gpiod_set_value_cansleep(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); -- 2.20.1