Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp79720pxb; Wed, 23 Mar 2022 13:27:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/4oKrtrMyucL7msBSgESymiIe5Wbbh2kBjc3oZjPXfNQSs+yQ676uo+Dm290UbL0+GOKH X-Received: by 2002:a17:907:c00b:b0:6df:cd40:afc4 with SMTP id ss11-20020a170907c00b00b006dfcd40afc4mr1968786ejc.629.1648067249056; Wed, 23 Mar 2022 13:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648067249; cv=none; d=google.com; s=arc-20160816; b=RLkBcL/QbMS6YXhQZb3W8g5mbraJxRBBRGfmWU4bboGloEa/xkK89YPoYIbh+no9VU kLphcN70/YTmQrSwzhkVABXA0/jLyKhS3JkaZbKZpRmrNwEjB5h/9FvicVmUKm14Ivi1 xbmjoZIaA38MDL0KHbtuc7q0bE3A1cmitq9AN7NqksrWZC+uMXKmD/siyv6WcYb9I8N1 5Xf4d2td31g/woP6CvRVqepIi5RamXx4n82KANvzP6NTPzHfiU8NjeCQM6YvEW7NWk68 WkOA0HNegJxqObA+RuLG/ud7TdS0jQTpqvzplMSbvlciCzS1YLnHCovQhWBV7ZhDWScc vDhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=+qaXC3e57Tiy30ZXHo3R6JiVE4H5pqyKCj5fJD4m4ys=; b=Gttir83lnsEMkRDzB56n5MTx2nuS8JjTWmfxVsHXRmBwy2p05kZ1S4O0Zl45F4LvMg e7SBHbbANUrStzlfpMBN+k51f1y8h0fcSPA1AkA1e9JM6yxxiDPbk2S8KljzZf9i3Fwu wrdlcIvSbTBJ7LrTsjhzM7V5VRKcy4Uwmqkg6OI9x+1lS2XMtDsHvpwMOI1pUYSC9G78 0+8E+PmjUPlRou73qmSW8F1Br4zRj8aDLItnOcsGTQMkLSHhB1qGFlVLPK5XeQp5g9WQ 5l6gfhLtW3QNdxJdY/H2k3qv9UsQ2VlI23Qrhp8JoZJdcV7LnXc3d1hnklGdiXBJia2G Kt6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=zqNNso2f; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a50cdc2000000b00418c2b5be89si13926749edj.363.2022.03.23.13.27.02; Wed, 23 Mar 2022 13:27:29 -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=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=zqNNso2f; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242986AbiCWI70 (ORCPT + 99 others); Wed, 23 Mar 2022 04:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242843AbiCWI7Y (ORCPT ); Wed, 23 Mar 2022 04:59:24 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6A3C7307A for ; Wed, 23 Mar 2022 01:57:52 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id h7so1558474lfl.2 for ; Wed, 23 Mar 2022 01:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=+qaXC3e57Tiy30ZXHo3R6JiVE4H5pqyKCj5fJD4m4ys=; b=zqNNso2fFQIURdKn+WCA/vJQdsxFIVL22/L/nbroH9TaQ5BMjR9n+6Qg4QmAR/7Q4b jxP6IL+fSjauUtN0GUsgR5rScJGv/jpBLVydr0e7AG0CmeTB6iIgC8goReiBaudA8nC0 lmIS4pgYLY4nqwCxRznov31I79k3xiuaCGMqac26PV9V8Nwp/dA7Ri/tqKwsNpX9OL1W EJuMCxFR4sx2DB+N+ZVNRgrrSfGWuynXnK4FIFTBgC2miCWqxn1o4apcFsxQcoVyQIL7 XnhlHsW+2m6Xzvk25IsPVBqYFOCE1YNoPHHrO+PX8+Fa+35BE7DUFrVAyhHOdEoTdF5d 9qdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=+qaXC3e57Tiy30ZXHo3R6JiVE4H5pqyKCj5fJD4m4ys=; b=ZIcETYcFIQTEx5ZS2zAFDrQT88KEVYHDJGYMWCS30zZPoJhh5iPXHIN+WSuveE+pow QjMnpvMIXb/l+c6oh46gOTH/rKSCENU3YNplMb7cOjQHE/MBCCMv8WWyADIV8GWpUTPE mDnEA99m4WtIjVzrLj74oBB1T03SxtRKpKdPD3Ou68epBSdlomGecyC+W5PdOUGZG7rx RTX4kPbX1S4IYgLPozotB4bX0Fr4RPhLWZIPQMujieANzi7IjTsRTbyawswQi7v0aFDZ CLhzc0Tps+U08HokkUJYyu1QIZzmNmViUENsDnVO6MvIMqV10uzk+Eb7TZ5ngmq0w54U aZPQ== X-Gm-Message-State: AOAM533jkHkFtehcklJ6a2+yDxCGbGWKMoPLPQo/DHjDZYbFTtnZRrdP D/e4kYLvFyGGtQGTQM02AGMwhKgPGcU/yw== X-Received: by 2002:a05:6512:1585:b0:445:908b:ad71 with SMTP id bp5-20020a056512158500b00445908bad71mr20542778lfb.200.1648025870850; Wed, 23 Mar 2022 01:57:50 -0700 (PDT) Received: from wkz-x280 (a124.broadband3.quicknet.se. [46.17.184.124]) by smtp.gmail.com with ESMTPSA id y23-20020a2e95d7000000b00247e4e386aasm2684910ljh.121.2022.03.23.01.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 01:57:49 -0700 (PDT) From: Tobias Waldekranz To: Guenter Roeck , Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] watchdog: gpio_wdt: Support GPO lines with the toggle algorithm In-Reply-To: <8b41a486-92af-2f2d-ba05-205650a90ee2@roeck-us.net> References: <20220322222911.519238-1-tobias@waldekranz.com> <8b41a486-92af-2f2d-ba05-205650a90ee2@roeck-us.net> Date: Wed, 23 Mar 2022 09:57:49 +0100 Message-ID: <87tubphwqa.fsf@waldekranz.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Tue, Mar 22, 2022 at 17:04, Guenter Roeck wrote: > On 3/22/22 15:29, Tobias Waldekranz wrote: >> Support using GPO lines (i.e. GPIOs that are output-only) with >> gpio_wdt using the "toggle" algorithm. >> >> Since its inception, gpio_wdt has configured its GPIO line as an input >> when using the "toggle" algorithm, even though it is used as an output >> when kicking. This needlessly barred hardware with output-only pins >> from using the driver. >> >> Signed-off-by: Tobias Waldekranz >> --- >> >> Hi, >> >> This patch has been in our downstream tree for a long time. We need it >> because our kick GPIO can't be used as an input. >> >> What I really can't figure out is why the driver would request the pin >> as in input, when it's always going to end up being used as an output >> anyway. >> >> So I thought I'd send it upstream in the hopes of either getting it >> merged, or an explanation as to why it is needed. >> > > I _think_ the assumption / idea was that "toggle" implies that the output > is connected to a pull-up resistor and that the pin either floats or is > pulled down to ground, causing the signal to toggle. I don't know if/how > that works in practice, though. Ah I see. Yeah I'm not sure it has the intended effect. AFAIK, that type of connection should be specified using the GPIOD_OUT_LOW_OPEN_DRAIN flag, no? Beyond that though, it seems unnecessary for the driver to impose that restriction. If an open drain configuration is required on the GPIO, then I think that should be specified via the device tree. Looking at some code, gpiod_configure_flags seems to support this: if (lflags & GPIO_OPEN_DRAIN) set_bit(FLAG_OPEN_DRAIN, &desc->flags); else if (dflags & GPIOD_FLAGS_BIT_OPEN_DRAIN) { /* * This enforces open drain mode from the consumer side. * This is necessary for some busses like I2C, but the lookup * should *REALLY* have specified them as open drain in the * first place, so print a little warning here. */ set_bit(FLAG_OPEN_DRAIN, &desc->flags); gpiod_warn(desc, "enforced open drain please flag it properly in DT/ACPI DSDT/board file\n"); } In other words, a DT node like this... &watchdog { compatible = "linux,wdt-gpio"; gpios = <&my-gpio 42 GPIO_ACTIVE_HIGH>; }; ...the GPIO will behave like it does with the "level" algo today. If an open-drain config is required, using this binding... &watchdog { compatible = "linux,wdt-gpio"; gpios = <&my-gpio 42 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; }; ...will give you that. In other words, with this patch applied, the setup of the GPIO is completely deferred to the device tree. In the general case, my guess is that who ever wrote that has a better chance of specifying the correct flags.