From mboxrd@z Thu Jan 1 00:00:00 1970 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 2A8B2C38147 for ; Wed, 18 Jan 2023 16:13:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2908185603; Wed, 18 Jan 2023 17:13:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=metanate.com header.i=@metanate.com header.b="uTgeFIo/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74A2785603; Wed, 18 Jan 2023 17:13:38 +0100 (CET) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0258782FE7 for ; Wed, 18 Jan 2023 17:13:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=john@metanate.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=In-Reply-To:Content-Type:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=nOpU6HRLvWElSKzvJl/jnBLykKCY9wpPUeGDb2zOr2g=; b=uTgeF Io/7k8ZnecuRBlfVgDOHcb2WiNkbpoELznufHa8R48MhhJUpckrRI+uH+Wc2lFW9OIt+gxhXPC0ml O9CSodkPH7utcka0dpGsxhzDCA7T3Evt2uBP4Z/ci46wImvoLFI+ifSAhBjvKEaIt4rofW+LwJzxY sl4q68B3llDrzjfqN7I9n1YAeZdVn1LQm7145f/BeGqEJh4zgvEyVQej9Zoj5NO/0j/Qbfo4Vp/eW vvOOsXRFy0VUVxKFT9d0R3NxG1/8xI7bo563eIfYP+pfLw2L1gLnRhf6olK13D6ewWxfWaasXtspE feepcaXgiF0ztWV9oUKmqq+fKrhVA==; Received: from dougal.metanate.com ([192.168.88.1] helo=donbot) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIB46-0003wo-F1; Wed, 18 Jan 2023 16:13:30 +0000 Date: Wed, 18 Jan 2023 16:13:29 +0000 From: John Keeping To: Johan Jonker Cc: u-boot@lists.denx.de, Quentin Schulz , Simon Glass , Philipp Tomsich , Kever Yang Subject: Re: [PATCH] rockchip: derive GPIO bank from alias if available Message-ID: References: <20230117181508.1582478-1-john@metanate.com> <98e06ac6-511a-28a7-c659-4cd91c064ad7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98e06ac6-511a-28a7-c659-4cd91c064ad7@gmail.com> X-Authenticated: YES 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.6 at phobos.denx.de X-Virus-Status: Clean On Tue, Jan 17, 2023 at 08:52:22PM +0100, Johan Jonker wrote: > > > On 1/17/23 19:15, John Keeping wrote: > > Upstream device trees now use standard node names like "gpio@ff..." but > > the rk_gpio driver expects a name like "gpio0@ff..." (note the index > > before the @). > > > > This is not a change that can be made in a -u-boot.dtsi file, so > > updating to the latest upstream device trees requires updating the > > driver. > > > > Other GPIO drivers already use the sequence number to derive the bank. > > This can be set explicitly using an alias in the device tree (which can > > be added in a -u-boot.dtsi file) but Rockchip GPIO banks are defined in > > order in the device tree anyway so when no aliases are supplied the > > indexes should still be correct. > > > > Note that the bank name is only used by the `gpio` command or > > potentially by board code via dm_gpio_lookup_name() and related > > functions; it is not used by driver code which will lookup GPIOs from > > the device tree by phandle. No Rockchip platforms make any use of > > dm_gpio_lookup_name() or `gpio` in the boot scripts. > > > > Cc: Quentin Schulz > > Cc: Johan Jonker > > Signed-off-by: John Keeping > > --- > > drivers/gpio/rk_gpio.c | 6 ++---- > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c > > index 68f30157a9..8568f10cd0 100644 > > --- a/drivers/gpio/rk_gpio.c > > +++ b/drivers/gpio/rk_gpio.c > > @@ -142,7 +142,6 @@ static int rockchip_gpio_probe(struct udevice *dev) > > { > > struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); > > struct rockchip_gpio_priv *priv = dev_get_priv(dev); > > - char *end; > > int ret; > > > > priv->regs = dev_read_addr_ptr(dev); > > @@ -151,9 +150,8 @@ static int rockchip_gpio_probe(struct udevice *dev) > > return ret; > > > > uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK; > > - end = strrchr(dev->name, '@'); > > - priv->bank = trailing_strtoln(dev->name, end); > > - priv->name[0] = 'A' + priv->bank; > > > + > > + priv->name[0] = 'A' + dev_seq(dev); > > Some comments. Have a look if it's useful. > === > 1: > Tested with rk3066a mk808 in only full u-boot. > > The gpio banks have a number gap. > > aliases { > gpio0 = &gpio0; > gpio1 = &gpio1; > gpio2 = &gpio2; > gpio3 = &gpio3; > gpio4 = &gpio4; > > gpio6 = &gpio6; > }; > > With aliases gpio6 is called G. > Without gpio6 is called F. > There's no name consistency for command scripts. True, but those scripts are going to be board specific and already depend on board data. The name will be consistent per board. > === > 2: > For example: rk3288-evb-u-boot.dtsi > > What happens in tpl or spl with only gpio3 and gpio8 in dt-plat.c. Is the bank name used in tpl/spl at all? There's no script support there and it could only be used in board code. > Or with SPL FDT blob: > > [v1,01/17] rockchip: spl: fix reloc gd and FDT blob pointer > http://patchwork.ozlabs.org/project/uboot/patch/20220508150825.21711-2-jbx6244@gmail.com/ > > Not in use in mainline. Just saying there's more possible in SPL/TPL. > === > The use of aliases is more of something of an additional thing that we not always can count on that is there. Again this is board specific - if a board wants this scheme of GPIO naming it can enable aliases and rely on that. I have been thinking of another option which is a bigger change to the bank name - it doesn't have to be a letter, could we use the register address as the bank name? So the GPIO would be something like ff750000.1 (although I don't know how the naming scheme works, so having a separator may not work). What do you think of that idea? Regards, John