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 AEEBBC43334 for ; Wed, 8 Jun 2022 09:53:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 00695842F9; Wed, 8 Jun 2022 11:53:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id D7C4D84300; Wed, 8 Jun 2022 11:53:51 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 8449983FC8 for ; Wed, 8 Jun 2022 11:53:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 04F1D1424; Wed, 8 Jun 2022 02:53:48 -0700 (PDT) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2B61F3F73B; Wed, 8 Jun 2022 02:53:47 -0700 (PDT) Date: Wed, 8 Jun 2022 10:53:44 +0100 From: Andre Przywara To: "Milan P. =?UTF-8?B?U3RhbmnEhw==?=" Cc: u-boot@lists.denx.de, Samuel Holland , Simon Glass Subject: Re: [BUG] keyboard doesn't work on Olimex teres-I notebook Message-ID: <20220608105344.40f27bf8@donnerap.cambridge.arm.com> In-Reply-To: <20220608013042.48db72ff@slackpad.lan> References: <20220608013042.48db72ff@slackpad.lan> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 On Wed, 8 Jun 2022 01:30:42 +0100 Andre Przywara wrote: Hi, > On Tue, 19 Apr 2022 14:27:24 +0200 > Milan P. Stani=C4=87 wrote: >=20 > Hi Milan, >=20 > > [ Please CC to me, I'm not subscribed to mailing list ] > >=20 > > Hi, > >=20 > > On u-boot release 2022.04 keyboard doesn't work in u-boot on Olimex > > TERES-I notebook. =20 >=20 > Thanks for the report, and sorry for the delay! >=20 > > With git bisect I found that commit 35ae126c16a6a9149edc6638faaa247f67b= 8a400 > > is introduced this. Reverting this commit solved problem and in my test > > keyboard now works. =20 >=20 > Unfortunately just reverting this commit is not really the way forward, > but I had a closer look and few printf's later found the problem: > The USB PHY driver uses the legacy GPIO interface, which is now wrapped > in gpio-uclass.c, to call the actual DM functions. > The commit that you bisected to implements the recommended > .set_flags ops member, which relies on the GPIO being properly > configured before. Unfortunately those compat wrappers seem to be > broken, and not using .set_flags just papered over this problem before: > - A call to gpio_direction_output() fills the DM struct gpio_desc > *locally*, on the stack, so any setup is lost when the function > returns. The GPIO hardware is still configured as an output, but > U-Boot doesn't remember this. > - A call to gpio_direction_output() in the legacy interface is supposed > to also set the output value, but the compat wrapper does not > implement this. Scratch that part: that works, as the h/w routines are called inside dm_gpio_clrset_flags(), where we set the correct flags in our (temporary) struct gpio_desc, before calling the .set_flags implementation. Got tricked by the rather innocent function name. But still calling gpio_direction_output(), then later gpio_set_value() is broken. I guess we should fix it, maybe by forcing GPIOD_IS_OUT in the desc, before calling dm_gpio_set_value()? Cheers, Andre > - When .set_flags is implemented in a GPIO driver implementation, the > DM GPIO interface *requires* GPIOs to be configured before, but > since this information is lot, a call to gpio_set_value() does > nothing. >=20 > So while those issues looks like they demand fixing, in the generic > compat GPIO wrappers, I decided to upgrade the sunxi USB PHY driver to > just use the DM GPIO interface directly. Eventually this driver should > drop the U-Boot configured GPIOs, and use proper DT methods, but this > is a bigger change I'd rather not introduce that late in the > development cycle. > So for now I sent this patch, that should fix the issue: > https://lore.kernel.org/u-boot/20220608000604.3357-1-andre.przywara@arm.c= om/ >=20 > If you could please test this patch, then reply to that patch email, > for instance with a Tested-by:, this would be greatly appreciated! >=20 > Cheers, > Andre