Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3628625rwb; Sat, 12 Nov 2022 09:15:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6h1xZGWlzeFmHAZNWxi0hWgVMEgT8ROILiJ5Aa4iy4NUupACtDqWCOGQsYqbNL0B+Mlru2 X-Received: by 2002:aa7:9385:0:b0:56b:dd28:4f6e with SMTP id t5-20020aa79385000000b0056bdd284f6emr7904176pfe.0.1668273334571; Sat, 12 Nov 2022 09:15:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668273334; cv=none; d=google.com; s=arc-20160816; b=f2NVaw5cU++EXujYUu4Qtyvq0Rh8IZjBxBhpGQ/kr//DvtNwL/XyitypOVCcfdLlek qTGYqmxWwWBz710UQYvyIlwZm9jFk6r3+yCiiidnA6ncmdyqtfkPNimhOzTQVZhG8fxW 3foUwZSWiyJ/SaoInMNMv7c5bUvd2FA1AH6Lb591zKFV+UEWhl+bAdLNcdRDttalfI35 sj7lZnn+OJdm2uAXU+yAY4VSa1tOrSvYRlztMIP5XDdfCla9al2+7Co09922F9Nr4HrN TnE6BeNGk9Gr7w8b7Ia200Nfqa4ZIaxUo42dio9fcFlFF/iqv2y5Y4XuNmJcd27mLsFr kg0w== 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:subject:cc:to:from:date :dkim-signature; bh=wHZZMFxdczd/vR4e5BINvpJeCr0E9gfB9daEI2n0Uq0=; b=Ftx5jtmOnYajfWU2LdtDSj5MeH+9Z5EuAhQ/w+ichdo3pSmvjE2sf+IgQBwbXa1vI8 +fA+FjVf5O0EW/UcdZ5RJGUrNDB9Jy1rWsY8ghLbcR72OHk759DWWDhJtKRaBDIgFDvy 4PVtvhZeizAJQW8uE8qyqMyjpl1oXIHR2YKckJtz1vXSWGhPp1MbPF/eNJUH+mBVwB2Z /+cn+k0rtESa4GVCG2cY1mKK6G5aidJuIS95ZXPv72QBW1/VsiQ3Wakb8lPa1wuwxhxt p4EP/BNM9fFfChGl+oL+Ua1BOOs0EVJWURg0QkRSm2hs+FXSswOWTk5cWqKAO4anIchY yNRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TNrSzxuh; 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 o2-20020a17090a0a0200b0020354bcfe09si5026219pjo.129.2022.11.12.09.15.15; Sat, 12 Nov 2022 09:15:34 -0800 (PST) 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=TNrSzxuh; 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 S235010AbiKLQy4 (ORCPT + 90 others); Sat, 12 Nov 2022 11:54:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232659AbiKLQyy (ORCPT ); Sat, 12 Nov 2022 11:54:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 887E4E44; Sat, 12 Nov 2022 08:54:53 -0800 (PST) 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 2249060C74; Sat, 12 Nov 2022 16:54:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9B2BC433D6; Sat, 12 Nov 2022 16:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668272092; bh=1McgPERC3DCrHC2oJEgF7eHWRQMMJ5k3OBizaJyxN6k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TNrSzxuhzPGEBZGvcoaHPweIKIoznIKz1mdVOR+RjRmb5cOTpkIm2ag1M6K/lNg18 zAo43DPGPlRcDsfWnlLBpZmB58ZixLMBu9gvcQ2JKXHvolavaQViH67H72nWXKON27 qB+Kz8VB9LuLu1D6nq1s5diD+LV9NIU+e/NkxsftgIq3TXzJ1dxqM5bSurBRLYbEFC QFE9jG4iTgTVHZw6pRGorPRwElrNvkNCL94jznuFzTv4iBLU0m0rDmYrMeJGoka4C6 XsZrnS7hPcQyS+kJTX3vSSBQ24vvz4CwNYmUy6qGRdIGTHXMa/aokxySfjVN1SmuvR Uo4ieaCMgbEUg== Date: Sat, 12 Nov 2022 17:07:05 +0000 From: Jonathan Cameron To: Rasmus Villemoes Cc: Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , devicetree@vger.kernel.org, Rob Herring , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio Message-ID: <20221112170705.7efe1673@jic23-huawei> In-Reply-To: <20221111143921.742194-6-linux@rasmusvillemoes.dk> References: <20221111143921.742194-1-linux@rasmusvillemoes.dk> <20221111143921.742194-6-linux@rasmusvillemoes.dk> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 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 Fri, 11 Nov 2022 15:39:21 +0100 Rasmus Villemoes wrote: > We have a board where the reset pin of the ad74412 is connected to a > gpio, but also pulled low by default. Hence to get the chip out of > reset, the driver needs to know about that gpio and set it high before > attempting to communicate with it. I'm a little confused on polarity here. The pin is a !reset so we need to drive it low briefly to trigger a reset. I'm guessing for your board the pin is set to active low? (an example in the dt would have made that clearer) Hence the pulse in here to 1 is actually briefly driving it low before restoring to high? For a pin documented as !reset that seems backwards though you have called it reset so that is fine, but this description doesn't make that celar. Perhaps just add some more description here to make it clear the GPIO is active low, and then refer to setting it to true and false to avoid the confusing high / low terminology which are inverted... > > When a reset-gpio is given in device tree, use that instead of the > software reset. According to the data sheet, the two methods are > functionally equivalent. > > Signed-off-by: Rasmus Villemoes > --- > drivers/iio/addac/ad74413r.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c > index 9f77d2f514de..af09d43f921c 100644 > --- a/drivers/iio/addac/ad74413r.c > +++ b/drivers/iio/addac/ad74413r.c > @@ -71,6 +71,7 @@ struct ad74413r_state { > struct regmap *regmap; > struct device *dev; > struct iio_trigger *trig; > + struct gpio_desc *reset_gpio; > > size_t adc_active_channels; > struct spi_message adc_samples_msg; > @@ -393,6 +394,13 @@ static int ad74413r_reset(struct ad74413r_state *st) > { > int ret; > > + if (st->reset_gpio) { > + gpiod_set_value_cansleep(st->reset_gpio, 1); > + fsleep(50); > + gpiod_set_value_cansleep(st->reset_gpio, 0); > + return 0; > + } > + > ret = regmap_write(st->regmap, AD74413R_REG_CMD_KEY, > AD74413R_CMD_KEY_RESET1); > if (ret) > @@ -1316,6 +1324,10 @@ static int ad74413r_probe(struct spi_device *spi) > if (IS_ERR(st->regmap)) > return PTR_ERR(st->regmap); > > + st->reset_gpio = devm_gpiod_get_optional(st->dev, "reset", GPIOD_OUT_LOW); > + if (IS_ERR(st->reset_gpio)) > + return PTR_ERR(st->reset_gpio); > + > st->refin_reg = devm_regulator_get_optional(st->dev, "refin"); > if (IS_ERR(st->refin_reg)) { > ret = PTR_ERR(st->refin_reg);