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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3E69C433F5 for ; Wed, 6 Apr 2022 15:33:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CB83E83DC7; Wed, 6 Apr 2022 17:33:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="FOu3uYHD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5E6C983DC7; Wed, 6 Apr 2022 17:33:03 +0200 (CEST) Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 606ED83DBC for ; Wed, 6 Apr 2022 17:32:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x82e.google.com with SMTP id v2so4898894qtc.5 for ; Wed, 06 Apr 2022 08:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZpdJxOd3B/FxBDKnrZSPjwEWJvs2cIk1j/zmNAomUrw=; b=FOu3uYHDVe3z83T7jz7G2ngwbWsIZvPUwXmVA2oYvhimj5er/oU/mwlF8Ab1VrDRLh m5m+h80/f8rPwk0Dduc2BBK0s1r79Sbzt1kSUDRpadL/nYr0bXyz5VtHSHoIQPfjYPsy LXDDp+eAoF1qXtWbUOr1tbUK+lkGOB9KpOHuY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZpdJxOd3B/FxBDKnrZSPjwEWJvs2cIk1j/zmNAomUrw=; b=AjTikvjtCEftRqRthFGsJ+cR7mYSxIyVBsxLXjJnry8DcBalNTFNwqamDK/46R9BBk qYNKfE2DUPRTe1OyUB36X3jd7A/t/y+UuRloi8DM99tMzn1aO86Nxvh7FfyanQ0D5R1C EYHavSS8FcNiaBkD+bod8MbdUDEkMgsuhYYPQm6PIknSkW1V5Bo2LtcbGzoJCB09MONd K5X2XpRm/7BnVjjXGjdAX+jufITAXBYK4Rrn6NXLOvMEnNtNh63HPY41z4I/gGVuk85o d7CoGXzYMJoZgQQg/76Bz5vM/MuGDU6K0Nm4LRWYg4EOFuq0m+wud8cdOCr3tbFVNOlw kEKQ== X-Gm-Message-State: AOAM530MxumQycOPbgcGVUgHZn4QR/PY2Fprx9Werae6rzn67jn/F92y Q3eI72W+9Ui7CO6H5gbWi/4feDe2u+z86w== X-Google-Smtp-Source: ABdhPJwK6lIVy56Kd2oAXq2Qgi17nzJT9LEMD4tNoVuDRk4tGtEBOJ5URz6MZ6i+RTnULYndkHrvBw== X-Received: by 2002:a05:620a:c4b:b0:67e:11a2:7cfb with SMTP id u11-20020a05620a0c4b00b0067e11a27cfbmr5939043qki.9.1649259174946; Wed, 06 Apr 2022 08:32:54 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-2ef0-5dff-fedb-a8ba.res6.spectrum.com. [2603:6081:7b01:cbda:2ef0:5dff:fedb:a8ba]) by smtp.gmail.com with ESMTPSA id b21-20020a05620a04f500b0067b4895472esm10128527qkh.5.2022.04.06.08.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:32:53 -0700 (PDT) Date: Wed, 6 Apr 2022 11:32:52 -0400 From: Tom Rini To: Tim Harvey Cc: u-boot , Sean Anderson Subject: Re: [PATCH] driver: gpio: fix gpio glitch for output-high gpio-hog Message-ID: <20220406153252.GE14282@bill-the-cat> References: <20220303020108.11453-1-tharvey@gateworks.com> <20220406122731.GY9042@bill-the-cat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vv4Sf/kQfcwinyKX" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean --vv4Sf/kQfcwinyKX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 06, 2022 at 08:30:31AM -0700, Tim Harvey wrote: > On Wed, Apr 6, 2022 at 5:27 AM Tom Rini wrote: > > > > On Wed, Mar 02, 2022 at 06:01:08PM -0800, Tim Harvey wrote: > > > > > A gpio-hog can be specified as output-low, output-high, or input where > > > output-low means 'de-asserted' and 'output-high' means asserted vs > > > voltage levels. > > > > > > When a hog is probed gpio_request_tail() calls dm_gpio_set_dir_flags() > > > which ends up setting the GPIO as an output with a driven 'de-asserte= d' > > > value prior to setting the desired value the hog was configured for. > > > While I'm not sure it makes sense to set the output level while simply > > > 'requesting' a GPIO the result of this is that if the hog is configur= ed > > > for output-high the request call sets it first as output low before > > > gpio_hog_probe() sets it to the configured value causing the gpio to > > > 'glitch' which may be undesired for certain applications. > > > > > > Fix this by setting the GPIOD_IS_OUT_ACTIVE flag for hogs configured = as > > > output-high. > > > > > > This was tested with the following hogs: > > > > > > /* active-high output-low (de-asserted) GPIO should drive 0 */ > > > gpio1 { > > > gpio-hog; > > > output-low; > > > gpios =3D <1 GPIO_ACTIVE_HIGH>; > > > line-name =3D "gpio1"; > > > }; > > > > > > /* active-high output-high (asserted) GPIO should drive 1 */ > > > /* before patch this would first drive 0 then 1 */ > > > gpio2 { > > > gpio-hog; > > > output-high; > > > gpios =3D <2 GPIO_ACTIVE_HIGH>; > > > line-name =3D "gpio2"; > > > }; > > > > > > /* active-low output-low (de-asserted) GPIO should drive 1 */ > > > gpio3 { > > > gpio-hog; > > > output-low; > > > gpios =3D <3 GPIO_ACTIVE_LOW>; > > > line-name =3D "gpio3#"; > > > }; > > > > > > /* active-low output-high (asserted) GPIO should drive 0 */ > > > /* before patch this would first drive 0 then 1 */ > > > gpio4 { > > > gpio-hog; > > > output-high; > > > gpios =3D <4 GPIO_ACTIVE_LOW>; > > > line-name =3D "gpio4#"; > > > }; > > > > > > Cc: Sean Anderson > > > Signed-off-by: Tim Harvey > > > > This breaks the ut_dm_dm_test_gpio test which I guess needs to be > > updated. > > >=20 > Tom, >=20 > That's kind of funny I suppose because the behavior is clearly wrong. >=20 > Is fixing the test something that needs to be done for the patch to be > applied, or needs to be done by me? I'm not familiar with the test > framework or how to execute it. For running the tests, please see: https://u-boot.readthedocs.io/en/latest/develop/testing.html and you're going to need to take a look at test/dm/gpio.c as where to fix what. And yes, a v2 that addresses the test as well is what I need. Thanks! --=20 Tom --vv4Sf/kQfcwinyKX Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmJNsqAACgkQFHw5/5Y0 tyzozgwAi2Wug8eTIXW+Fqb/QXiikjlhJcz6gvnQvHvhgO6PXo7UK0qIXBVXmeEF ahXsQykmokltIJOqANJAI9ZqrSnn2qNlF+oQ4lyQMJ/YrJLDEP5pOrMk9zs9pFwq 2HeBPvK4JdwR2mg+PbdnicB4aMfO05gdEfyVV0KTlblB6vh2IYj9AwoBJBgrpRro yJRtAvboUSw/DJ/6SbOTVCnoZDOmkfeLO619Q7GBwEQhaP0/SHQqxvWhLvV86orM fQdZrOyOCNmOs32MAQmC62JOFZFVtgcUbxFxUujV5cNVSP9VpT4XhYYbGW8hSd2V ZuQLjIxrCjexHV4ES5s5uIwzfo1jBtoME90Cmw+OBJFvHhklMF+LpAo0q//APCSZ T8e9Eq8iB/s313SVcSJc/L/L3ON339ddshNi1t7uX2MNWJeRfVfLU5o9out7Wx+0 gsJCDqNDTp2CVNAwUL0HqQjHPB2wAwpQ7P3Ig/ew/oTphk6RWkPgmhYRJDVECECx bg0gh3Lo =jS2l -----END PGP SIGNATURE----- --vv4Sf/kQfcwinyKX--