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 DE8E5C54E76 for ; Tue, 17 Jan 2023 19:52:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5E2B885103; Tue, 17 Jan 2023 20:52:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="Zr5lMRZ3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 52325855A8; Tue, 17 Jan 2023 20:52:27 +0100 (CET) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 93F5E80CB0 for ; Tue, 17 Jan 2023 20:52:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jbx6244@gmail.com Received: by mail-ed1-x52e.google.com with SMTP id w14so29311098edi.5 for ; Tue, 17 Jan 2023 11:52:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zPeY0XqwJIUoUBWIik/7qCltkB1kMEb22PhM1cSKBMg=; b=Zr5lMRZ3Y7h4CZ9leTlCpu+HnBA8ngYzuXNQwP2zd4GcCW5e29serPtnPstCpkta8v aaarc4X1DEmKP8Fyp0DuqV8bGSkXwY5Jhncj7xi9qspTwvr+TZmnUf9LrtFoRcXYuSnw ziADic8nvfKDmXUkAt6YTltZZIZqqQ6uqY//EDXLhHZrxRe2pTYFq85HNCeOlUZJa0fo CKQrscGK2qtqEqgEvULFVB2MDlLUAdTvCvX5tA/0cR4wGFLeNBMFDyz0Zsl9ASL3jPcx /YNCyU1CZ3TT+gVxYmuZ2aMCMq6icykRsw3SFKA4+cZg1fZ7xQIwuZdL99ti5znrVdAx loDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zPeY0XqwJIUoUBWIik/7qCltkB1kMEb22PhM1cSKBMg=; b=bbCn50VBsNg19jUsMFC7GnJjzv4efhFnSCBBI7AlUmng3uQ41QQIUYweZrmXxm810F rqJK5lFeQukFvD3I7qtc8iqLUgidYTvKjTkv8X//Dnb69WrF/+XwpBHTz8oB2e6q5TvQ Px9r8LYNWH/Po1meGFTbq1q2GbCrecxGPvAicQLRWqv7C+luR+0GwMlgQUYDHAbkkX2i QDKTv85Fon93iWff4a6UaMiTEsROnn24pANj+DvcXNDXtFx3MbDD3pHWumAbXDua5x+N WkTzJ6oJ275yHFcf++hjfKTce+ccau/9fpl6ebkf0QzuaVvoe3TtXOtIt/Ur2hhEUivY 17BA== X-Gm-Message-State: AFqh2krFGkkbXrmK/r5WA1sOzBbegHxIHA9Y+6qE6fRTdToBABcpsD3T E6/qMM9XOzYpYOEQr26OZjc= X-Google-Smtp-Source: AMrXdXuSNc0LKuMFQ4kXg1xbPTVQnJMDwX29iS7b6G+7IwhdB1BcTZddGOz3ZBofgo4Xq6HeQ+cvKg== X-Received: by 2002:a05:6402:5d3:b0:49b:58ca:ebbc with SMTP id n19-20020a05640205d300b0049b58caebbcmr5056204edx.32.1673985144161; Tue, 17 Jan 2023 11:52:24 -0800 (PST) Received: from [192.168.2.1] (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id q10-20020a056402032a00b004845b9b7589sm13236072edw.73.2023.01.17.11.52.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Jan 2023 11:52:23 -0800 (PST) Message-ID: <98e06ac6-511a-28a7-c659-4cd91c064ad7@gmail.com> Date: Tue, 17 Jan 2023 20:52:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH] rockchip: derive GPIO bank from alias if available To: John Keeping , u-boot@lists.denx.de Cc: Quentin Schulz , Simon Glass , Philipp Tomsich , Kever Yang References: <20230117181508.1582478-1-john@metanate.com> Content-Language: en-US From: Johan Jonker In-Reply-To: <20230117181508.1582478-1-john@metanate.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 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); Hi, 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. === 2: For example: rk3288-evb-u-boot.dtsi What happens in tpl or spl with only gpio3 and gpio8 in dt-plat.c. 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. Johan > uc_priv->bank_name = priv->name; > > return 0;