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 67E9CC3DA78 for ; Tue, 17 Jan 2023 18:15:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93EA982FE7; Tue, 17 Jan 2023 19:15:30 +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="zTeA4rXl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6CF0E80F98; Tue, 17 Jan 2023 19:15:28 +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 5785C855BA for ; Tue, 17 Jan 2023 19:15:26 +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=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=aNvPSG3ENCWw5A/Lw2VJp7jyrg4+J49TDkCMxjHmJS0=; b=zT eA4rXl+UnIRiNauBY9VW13IFg+ZJWvmxLO3MRmte/QwYyexAUrbsdNi3hKXHVJM87jgu9JhXHFrRo pl6/S6HnTn9jm/tdMUlKqE1fjLq7YkyheiCB+bEV8Yb5AkiMW6xmuVZgo0KcO8qVYuFm6QoHQUsxo O5NWebC6dgHMyE1gAzTI89XttOfwLXG17BGZlb8a6r1V15TvO4SwNxvsTkbTWuMg4O6gJGsMZ0wou e/zjfzik0EhaHcZOiRxdTuPBLDtiVOofHHL7KnsOGEY5y6EG23i3XFKH0sZf5p0lD1vVrWn0it/Oi tX6/UqXc5ei+3A/pAMaS+b5TgYwTH3hw==; Received: from [81.174.171.191] (helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pHqUU-0002MA-2p; Tue, 17 Jan 2023 18:15:22 +0000 From: John Keeping To: u-boot@lists.denx.de Cc: John Keeping , Quentin Schulz , Johan Jonker , Simon Glass , Philipp Tomsich , Kever Yang Subject: [PATCH] rockchip: derive GPIO bank from alias if available Date: Tue, 17 Jan 2023 18:15:07 +0000 Message-Id: <20230117181508.1582478-1-john@metanate.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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); uc_priv->bank_name = priv->name; return 0; -- 2.39.0