Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2775463rdb; Mon, 4 Dec 2023 07:15:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGf4HcmuS0y5Aob5I/E6//UxrUAq0SKAsfzZ55B5Hs5fryX6SOBNM4oMVizHQPQHh+U4aCj X-Received: by 2002:a17:90b:4d0b:b0:286:5742:dfce with SMTP id mw11-20020a17090b4d0b00b002865742dfcemr4491194pjb.4.1701702942671; Mon, 04 Dec 2023 07:15:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701702942; cv=none; d=google.com; s=arc-20160816; b=Wd08Ooy0ERsnx0fUTzJYYLe0gtuUWJc0ebHDYgO+EBPZmF3Jr7eOZa0T5bZaAaHE6j FeraIFRmaxHQHrR0XmG4WPlL0WJC/tUFcPAEnSpjGyBhHL7B+wqxh2VGQWumduD76OFt JgwzEIKLeBKn8+HXlP2dK+CXU9hWpPvgIrJa5q0lqHCdNGCT9AEVqijFohk0kPZKi89C VT46JgYu2ETKXvQjIDtf5zREpK8kBtaaXcI1m5hMynd8dtPxiPIEEYtqhSb47MSpuGZs FeE65RTg1t5l2RQp0TuPFOpn9j9h81QnK0HXrZocVYr0Om6wo2lwe8RcrM7bFqbTv8cd oo0A== 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=0hHW+W7kQBWNymgCZyeSEeeH2T+xy3ZQ6eEfSAshZ8E=; fh=sqieTvBxhfIVwhknj5TTCKn6UI71QdImv9DAT3Xqv4g=; b=XsAqkWrw5OfFWBxC5Xci2f27TwQ9hQH5Kn1TtmYM8DlV38SlJj74LtNE/pjwyy0W56 Ku053aUOSvn2R9BnaZupTSR8b2pkJvhoPa9vWS20Yms27FabhLEzlIB3fWvDGxfgLASj 0pOShSUADBuIfIU/o82wLDV6mNSmpvjJ3gPeDDzTqMHTW3nizucWe/rhFpEBrPJ17rxf yRrc1JUQ4YrbCIZUug3QCGjZrkdwqecEmfX5Qqho7BKge4I4yeqjdlrER4iPjkWa38ub Of/IBU9XmZWBXyXNWUDhZlCks3zHdAppp9XD3pxg4BVPVLFDWAT07YFwXKWrMxS/UzFL DzSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="LUQ/JInB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id kk17-20020a17090b4a1100b00286bc991cd5si1352373pjb.86.2023.12.04.07.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:15:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="LUQ/JInB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E1801807615E; Mon, 4 Dec 2023 07:15:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233714AbjLDPPS (ORCPT + 99 others); Mon, 4 Dec 2023 10:15:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231594AbjLDPPR (ORCPT ); Mon, 4 Dec 2023 10:15:17 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3FCEB2 for ; Mon, 4 Dec 2023 07:15:23 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08FE8C433C7; Mon, 4 Dec 2023 15:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701702923; bh=BOM1EV4bba9ClKDdr+6k5WZ62Teyd2Rgs3hahYp9izU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LUQ/JInBnw5u1yUBx5xwlGXP3zGOWSnHAHgjcjOFSt2LaTNvH/Wv1HGtE/A1I5xvG IPZolxBQTkEFTyh2zuOtZC1SqLsPRS6dhNeW+DQ0OXzdAxSozQx7bEoNyPgZkBD68z hjki1mfO12qJWC5nqLDwwztW6ippl+hpJvIXSEBlt0GHp/FhmpB+VIe9N1O7mp9BEV pek0XoAOUGO9VlpSWNvLWrNnlHuY5F2fhTuvdFhtpbFbdVCE9QZxdkkS3zV93eUgD9 no6gIb5Km2xfKFp39bJqSfpOJVO0rRwPY4Q5Esyq5Bbn2dej/uybaU2mblNjKer9w7 XjuCRgMGdQMvg== Date: Mon, 4 Dec 2023 15:15:14 +0000 From: Jonathan Cameron To: Nuno =?UTF-8?B?U8Oh?= Cc: David Lechner , nuno.sa@analog.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Olivier MOYSAN , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Lars-Peter Clausen , Michael Hennerich Subject: Re: [PATCH 04/12] iio: adc: ad9467: fix reset gpio handling Message-ID: <20231204151514.4e2c8ada@jic23-huawei> In-Reply-To: <3925cb4b6453644c889675c20329b3477a06fcd5.camel@gmail.com> References: <20231121-dev-iio-backend-v1-0-6a3d542eba35@analog.com> <20231121-dev-iio-backend-v1-4-6a3d542eba35@analog.com> <3925cb4b6453644c889675c20329b3477a06fcd5.camel@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 04 Dec 2023 07:15:34 -0800 (PST) On Sat, 02 Dec 2023 09:36:47 +0100 Nuno S=C3=A1 wrote: > On Fri, 2023-12-01 at 11:01 -0600, David Lechner wrote: > > On Fri, Dec 1, 2023 at 2:47=E2=80=AFAM Nuno S=C3=A1 wrote: =20 > > >=20 > > > On Thu, 2023-11-30 at 15:41 -0600, David Lechner wrote: =20 > > > > On Tue, Nov 21, 2023 at 4:17=E2=80=AFAM Nuno Sa via B4 Relay > > > > wrote: =20 > > > > >=20 > > > > > From: Nuno Sa > > > > >=20 > > > > > The reset gpio was being requested with GPIOD_OUT_LOW which means= , not > > > > > asserted. Then it was being asserted but never de-asserted which = means > > > > > the devices was left in reset. Fix it by de-asserting the gpio. = =20 > > > >=20 > > > > It could be helpful to update the devicetree bindings to state the > > > > expected active-high or active-low setting for this gpio so it is > > > > clear which state means asserted. > > > > =20 > > >=20 > > > You could state that the chip is active low but I don't see that chan= ge that > > > important for now. Not sure if this is clear and maybe that's why you= r comment. > > > GPIOD_OUT_HIGH has nothing to do with active high or low. It just mea= ns, "get me > > > the > > > pin in the asserted state". > > > =20 > >=20 > > I would assume that this bug happened in the first place because > > someone forgot GPIOD_OUT_LOW in the devicetree when they were > > developing the driver. So this is why I suggested that updating the > > devicetree binding docs so that future users are less likely to make > > the same mistake. Currently, the bindings don't even have reset-gpios > > in the examples. =20 >=20 > Hmm, I think you're missing the point... The bug has nothing to do with d= evicetree. > This is what was happening: >=20 > 1) We were calling devm_gpiod_get_optional() with GPIOD_OUT_LOW. What thi= s means is > that you get an output gpio deasserted. Hence the device is out of reset.= And here is > the important part... what you have in dts does not matter. If you have a= ctive low, > it means the pin level will be 1. If you have high, the pin level is 0. A= nd this is > all handled by gpiolib for you.=20 >=20 > 2) Then, we called gpiod_direction_output(..., 1), which means set the di= rection out > (which is actually not needed since it was already done when getting the = pin) and > assert the pin. Hence, reset the device. And we were never de-asserting t= he pin so > the device would be left in reset. Functionally I believe David is correct. Flipping the DT would 'fix' this. It's all down to a nreset vs reset pin description. In this case I guess it's defined a a 'not reset' on the datasheet which is= what is causing the confusion. It's not uncommon for people to refer to a reset= when they mean a "not reset" with assumptions on polarity to match. Jonathan >=20 > - Nuno S=C3=A1