From patchwork Tue Dec 5 13:46:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 750382 Delivered-To: patch@linaro.org Received: by 2002:adf:9b9d:0:b0:333:3a04:f257 with SMTP id d29csp1678766wrc; Tue, 5 Dec 2023 05:47:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9obCHG9JS3bUT3ddUJk0zIUgjS/BUoGffOieOHzscTYDoNPSfGzqaJbPs+gjeCszEOvB9 X-Received: by 2002:a5d:510d:0:b0:333:3fc7:f2bf with SMTP id s13-20020a5d510d000000b003333fc7f2bfmr2704773wrt.134.1701784079316; Tue, 05 Dec 2023 05:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701784079; cv=none; d=google.com; s=arc-20160816; b=L9iIlBKD3wHr5gIJ4qZL8z7RnUQDEVa8oc5O5oOQDhCkE5lcG+YGnT1a+E1qdPtxZx alU5HhbuuIFbjh+9Ei1uHeziQnBAagZnmlFuuFfhPhaOLYVffaSbpH9VqtL+6QaFeXbp MnIScrhhQwYoMYrZy3yRlevM30EFOUtYPOqxj7K3GIXSZSBERe0t+7n0c4QE0Lx5G4Tg 1o6og9XqEGbhztoDdaVHRxVcC58uKFYtQuiGzp1Cel+0ttaggAn18iFpvcUGrbimTRbO eLxaLdLqXie3cjlyO9z0Uaq/f+hPWJ7/JYKzF6LKzXEjlgnJy6BrO0nCKEFfyJ5rQdlx 3uMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ToeRg/qTzycp+tXwM62aTvWEHWd1IbuiLlCcu4hbrf0=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=wjMNlDEX5Odn5pmArecKZc5Bh3wvZAiHaRKYh9VobRl4n8jJzBFqagdVpfITVOgw+C MU1j6pFPXPq5tZ73h4uZAvbOK17I4M02vxDXWFEm64+gXDkZddzlwSYzEwNEOGh6qS4W fC+EJbf8j30NLp27Ibe8wTdWosRI8YUQ5X2vND+ZUbHQfWFdY7ora5IBEcguONy6zlex U3O8g3q41K+FJuW/OqLi0CuwQgTq1ZYxQZ8CMGFsFP/QxhO8dkFv5+LEH3vFbCzgtU1o SXC9uL4zWmDhciyhIMvgYH+pkR8k2QTa9KAsWaAeeyFa74J0iejvazJLhoTw4AFbMpoc lIsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k+LAhg9n; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id f10-20020a056000036a00b0032f7c4a499csi6083396wrf.109.2023.12.05.05.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 05:47:59 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k+LAhg9n; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 65B74878BA; Tue, 5 Dec 2023 14:47:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="k+LAhg9n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 38B9D87626; Tue, 5 Dec 2023 14:47:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) (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 4B10387745 for ; Tue, 5 Dec 2023 14:47:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c9f57d9952so37987361fa.3 for ; Tue, 05 Dec 2023 05:47:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701784023; x=1702388823; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ToeRg/qTzycp+tXwM62aTvWEHWd1IbuiLlCcu4hbrf0=; b=k+LAhg9nktRHJ/i6RTFz07vim1/dSgSKSP8YRrRnHVxLtgr2Jw+U6uXhdxDWZ1YEmi 6MPjEIkw6mLH6Px1Rhj/WNj3hNZuww06AMA857MZ5orpENH6oJeQTxcNQUlu3xeGTMBr +Z9bWIJ8SzdfAtpmRt26H/GEycH4OARHN/sHQIKqKk7nxZ/NcH4opP8Lcd0rOu/Z8U95 0R62Eu8HwnVHhHt7ZfFDdQd8FGKXQpQagqZ1b2QelEHOSayg25JR4bOjKx+gO4uQg408 ujj9qzQKPu62B4bP4HDa+BpMtSgzZESzxqlDYTM9fqur6XdLo7NAshhHS/AC+K55Biui n4yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701784023; x=1702388823; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ToeRg/qTzycp+tXwM62aTvWEHWd1IbuiLlCcu4hbrf0=; b=TV05IotwO0lH6ogEBemahcMbe+oicPSXtUp0QNfLq0PczxqvmindrUO2vOID5UbHzE 7HMNH33/KWAgdmPFOYl/YNzv30IWpF6yb1WqbC84XG/jpFl/HRdFkJg02PN1MdnvSsT5 Ax4qymFjHuZqlkVx47enVgCijC1QxpQ9YfpEH6XFPVNN9hvRCDpX2BPVzUqlwynu57N2 uzwZM69uv52Fv12oPdQYrUq/V88MoU3b/Z/J0JsQzbx8ED4Qj9jetkHJEUsw65UsTf7Q rxuw0O0tePAxfQgiA3TzaUEHgKMfn4gaFpB7a9EpHauWWWhejv/kcI2saMWmPBI+n4gr DrWw== X-Gm-Message-State: AOJu0YyfMcpCcY5YLQZtkKXgF7+ppCIFPk0D2X9c8rTujnDJ3AbYfoMb AJvMQ9kEY3+UNFzjBVWFUBymbg== X-Received: by 2002:a2e:8181:0:b0:2ca:dc7:6596 with SMTP id e1-20020a2e8181000000b002ca0dc76596mr1150249ljg.77.1701784023734; Tue, 05 Dec 2023 05:47:03 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id d10-20020a2e928a000000b002ca0e0c837asm369688ljh.100.2023.12.05.05.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 05:47:03 -0800 (PST) From: Caleb Connolly Date: Tue, 05 Dec 2023 13:46:50 +0000 Subject: [PATCH v6 5/9] gpio: qcom_pmic: support upstream DT MIME-Version: 1.0 Message-Id: <20231205-b4-qcom-dt-compat-v6-5-61d104a8f920@linaro.org> References: <20231205-b4-qcom-dt-compat-v6-0-61d104a8f920@linaro.org> In-Reply-To: <20231205-b4-qcom-dt-compat-v6-0-61d104a8f920@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=1856; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=tryPUJEelsn2aYdAYdxSHQ9xFfUTee+qQvSaqHDrkvA=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtR8zXPbN1haas9m3u6bGfOvJr5ws3Ssi92OPTL6S2ImG 4l9dzbpKGVhEORgkBVTZBE/scyyae1le43tCy7AzGFlAhnCwMUpABOJf8zw3+v7oW1bTzzqu/Hh 6u8jl+UytiX++fU1aumOe0HLhCfUTuBkZFi4V++iudFxsYmLHWf775aOlvxhqCbx3H3dqyqVt47 vvDwB X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Upstream uses the gpio-ranges property to define the number of GPIOs, support for parsing this when gpio-count is unspecified Additionally, drop the bank-name property as it isn't used in upstream, and we can just hardcode the bank name instead. Reviewed-by: Sumit Garg Tested-by: Sumit Garg Signed-off-by: Caleb Connolly Reviewed-by: Simon Glass --- drivers/gpio/qcom_pmic_gpio.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 7b83c67fa464..5221bd27825e 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -245,14 +245,39 @@ static int qcom_gpio_probe(struct udevice *dev) return 0; } +/* + * Parse basic GPIO count specified via the gpio-ranges property + * as specified in Linux devicetrees + * Returns < 0 on error, otherwise gpio count + */ +static int qcom_gpio_of_parse_ranges(struct udevice *dev) +{ + int ret; + struct ofnode_phandle_args args; + + ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), "gpio-ranges", + NULL, 3, 0, &args); + if (ret) + return log_msg_ret("gpio-ranges", ret); + + return args.args[2]; +} + static int qcom_gpio_of_to_plat(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + int ret; uc_priv->gpio_count = dev_read_u32_default(dev, "gpio-count", 0); - uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); - if (uc_priv->bank_name == NULL) - uc_priv->bank_name = "qcom_pmic"; + if (!uc_priv->gpio_count) { + ret = qcom_gpio_of_parse_ranges(dev); + if (ret > 0) + uc_priv->gpio_count = ret; + else + return ret; + } + + uc_priv->bank_name = "pmic"; return 0; }