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 26472C00140 for ; Tue, 26 Jul 2022 16:25:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D2E54840F9; Tue, 26 Jul 2022 18:25:25 +0200 (CEST) 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="5phiyqHe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 60977840FE; Tue, 26 Jul 2022 18:25:24 +0200 (CEST) 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 8838F8215A for ; Tue, 26 Jul 2022 18:25:21 +0200 (CEST) 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=Pb+kVL54aLMSropwZxiuTNRE73VCa0uu35gr60121vA=; b=5p hiyqHeBsBvNsJE5/5EigdotYte7yK0ChcphSYcacrq8Pu7jFWTNISDYvfiJT7x0NtnBbwycD7P+Ft Wp0AsE6JsbgSiP1Jh8JmSv2kUf2sbUvaf6a95INQG3UV1bhnSwhUuosNgXbsvjGPyz9wkGVI/2A7j FsNhb4xUrZOqUl60mp6fkRb6CcSosPzgu8ouNdQkdCekuoNnhYzehER/EJYf6XhXcqKWJUIzZ6D9C KXyPRVYCimENapG/kT9JsI74GVPe6iCLMC1q9yMRl5v4Txcg93WeVdcg+dXFClEvd0hocOXlN0HKn zRzgb8je9DoUqOc1WB1Vnx9aWNjQGgcA==; 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 1oGNMz-0001lP-JP; Tue, 26 Jul 2022 17:25:18 +0100 From: John Keeping To: u-boot@lists.denx.de Cc: John Keeping , Simon Glass , Philipp Tomsich , Kever Yang Subject: [PATCH/RFC] rockchip: derive GPIO bank from alias if available Date: Tue, 26 Jul 2022 17:25:09 +0100 Message-Id: <20220726162509.1304234-1-john@metanate.com> X-Mailer: git-send-email 2.37.1 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. When a sequence number is given explicitly via an alias it makes sense to use this for the bank number (and aliases can be added via -u-boot.dtsi when they are not present upstream), so make this the preferred scheme for assigning a bank index, falling back to the current method if no alias is defined. Signed-off-by: John Keeping --- I'm not sure if it would be better just to use dev_seq(dev) unconditionally here. If no aliases are defined, then the device tree nodes are in the right order for all Rockchip SoCs anyway so the sequence numbers will be sensible. But this feels like the change with less risk of unintentionally introducing a regression. drivers/gpio/rk_gpio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c index 68f30157a9..b2f6d0e925 100644 --- a/drivers/gpio/rk_gpio.c +++ b/drivers/gpio/rk_gpio.c @@ -151,8 +151,13 @@ 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); + + ret = dev_read_alias_seq(dev, &priv->bank); + if (ret) { + end = strrchr(dev->name, '@'); + priv->bank = trailing_strtoln(dev->name, end); + } + priv->name[0] = 'A' + priv->bank; uc_priv->bank_name = priv->name; -- 2.37.1