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 64CBAC636D4 for ; Mon, 13 Feb 2023 22:28:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A5CD385763; Mon, 13 Feb 2023 23:28: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=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="NY/rZi6k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9602C857F0; Mon, 13 Feb 2023 23:27:57 +0100 (CET) Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) (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 7EEDA854EF for ; Mon, 13 Feb 2023 23:27:54 +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=macroalpha82@gmail.com Received: by mail-oi1-x231.google.com with SMTP id dt8so11603335oib.0 for ; Mon, 13 Feb 2023 14:27:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2nqNCmfGIDCX8AljsH3ZocCeLRn0iqwl88zSiiexn7A=; b=NY/rZi6kIqDEFgeQD28IPmHCuuTZvJQMoZ7R4SAZOvSA/RzWaQ0u01UykUl6AV3BRc wInJm7boLTvTuT3b2P0KkClhNO+c5zzKKsFtckijjqxSc57tkQltd73BxepSFMaaa1k9 kRXklM/a6pF1flBnddLaoaoNIvtgfQeb3Tm0S95r4cWMUWl7D0u+UXcXW8UkTh38xPI4 RL28zuS/kWtoNszzkWwdgGPfmViZ9nk3PLeHCSOlI36GU8wVRSnac+S0cw0DtfPP99jz QqmG7bYGPpfY67zV1WNQ0SVk/+Ui819898CtcmomxB9t4FCWM6dG9Ag5Y51maMHFS3fD OWHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2nqNCmfGIDCX8AljsH3ZocCeLRn0iqwl88zSiiexn7A=; b=4elH67u9YOk54UEoU2XiN1itUUOv9a1cG40hK7RzEJrRr/qJEgSx57+sJ0cxzEu34Y tvPUDGPiq5ppEHjGIv4UX5atLdmmBiccmiXFLGmH/f9OaQFOEtvHXDDeY4yhw4LyARs7 MOHIBxTFZl/ojJ/pcL/AClf63z4nrBcRhqv1yG5Fhh7R0w1rRZ19nJNa1vCNORqlfWI0 YgpU+4V2qgj2suoisepBPHLL4CecuJt5d0IN36SUKC86TsqJk8ysg7PBX98msebHTxuh 8yXvKhQM+hKkwByGMuKCG9Eb6aHZPAc/oX/dk8N/A9bwyWuIf4H7bX1HQIup+ex0nbMl DM3w== X-Gm-Message-State: AO0yUKUKf2ZEAlf3y0jSAQ9ULeTYviv1htec4g/bB5FiINCG5JH7/G8H Z741onLCU90mt7ArrSdYYaLC71jAk7s= X-Google-Smtp-Source: AK7set9KAorLZmBsDzt1XZ+VBowMykM6tSGcMb+QTM55zvJd7Bv9TFZcI1CPiSoPpnHVi/zEDiibIw== X-Received: by 2002:a05:6808:3a85:b0:35e:9090:2969 with SMTP id fb5-20020a0568083a8500b0035e90902969mr201600oib.13.1676327273000; Mon, 13 Feb 2023 14:27:53 -0800 (PST) Received: from localhost.localdomain ([76.244.6.13]) by smtp.gmail.com with ESMTPSA id bf16-20020a056808191000b0037d790218c1sm3044085oib.9.2023.02.13.14.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 14:27:52 -0800 (PST) From: Chris Morgan To: u-boot@lists.denx.de Cc: heiko@sntech.de, sjg@chromium.org, philipp.tomsich@vrull.eu, kever.yang@rock-chips.com, chenjh@rock-chips.com, pgwipeout@gmail.com, heiko.stuebner@theobroma-systems.com, Chris Morgan Subject: [PATCH V2 1/9] gpio: gpio-rockchip: parse gpio-ranges for bank id Date: Mon, 13 Feb 2023 16:27:34 -0600 Message-Id: <20230213222742.135093-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213222742.135093-1-macroalpha82@gmail.com> References: <20230213222742.135093-1-macroalpha82@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Chris Morgan Use the new devicetree property of gpio-ranges to determine the GPIO bank ID. Preserve the "old" way of doing things too, so that boards can be migrated and tested gradually (I only have a 3566 and 3326 to test). Signed-off-by: Chris Morgan --- drivers/gpio/rk_gpio.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c index 68f30157a9..98a79b5f4d 100644 --- a/drivers/gpio/rk_gpio.c +++ b/drivers/gpio/rk_gpio.c @@ -142,6 +142,7 @@ 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); + struct ofnode_phandle_args args; char *end; int ret; @@ -150,9 +151,22 @@ static int rockchip_gpio_probe(struct udevice *dev) if (ret) return ret; - uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK; - end = strrchr(dev->name, '@'); - priv->bank = trailing_strtoln(dev->name, end); + /* + * If "gpio-ranges" is present in the devicetree use it to parse + * the GPIO bank ID, otherwise use the legacy method. + */ + ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), + "gpio-ranges", NULL, 3, + 0, &args); + if (!ret || ret != -ENOENT) { + uc_priv->gpio_count = args.args[2]; + priv->bank = args.args[1] / args.args[2]; + } else { + 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; uc_priv->bank_name = priv->name; -- 2.34.1