From patchwork Thu Nov 30 20:22:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 748516 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1103842wrn; Thu, 30 Nov 2023 12:24:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkwG+ljiBrRhAyFFJuUmRnhnhlLKKUje0HCXF6amguibz/XgmXIQpNWekEO/h+eafot0VG X-Received: by 2002:a05:6a20:c189:b0:187:ce5a:2a87 with SMTP id bg9-20020a056a20c18900b00187ce5a2a87mr25247953pzb.12.1701375845713; Thu, 30 Nov 2023 12:24:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375845; cv=none; d=google.com; s=arc-20160816; b=TyiUNcVEuzFn7Mf9cPgP/KpRqbxnjkJPt7J6O+8B8bUUY1RVjckiqjJHFb1UfRgVZv riBLgl6hucXk9Kn16HENC4jVBmVbznyi7BVWevoaUXgyPNo6crgTBgNh5z2y7ZNI6SIY b0+DxDoDU18pVVI/MYlUcyce0M78lbHafKZjxaAVOk2nAgGLXMOdAPCxe+3Bo2XQl5G7 lLpPstqzqf8qKGzZquqaNTFFcWwKE87d9GBllQt6jCLMCz2c4WN29vdD2ODAMjsCw/U9 YzWvdTJ8QZom3t05jB8qUeh3leBbwpolAsa1zr7T1Xe1cY2eMSVq9zIwiuj5TfJQ8D/v TeDg== 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=+LJakeFglSK5HTWJWr8yiQtiZQ8ZDLzW8xWntxzGnv4=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=kpnPF4NnqeI/+i7RHmblcnNOnmGjfb3y30EPLD/Goa/R+f6m6zH1/nKi+5U19ytsX1 t/9IkUT76JD62kMamNkfFlKsAZuOxv+cddnOgXGL+nbsy2J5KytFn3HEUyeb1OBcBIXE uGh/JWhrkemTE+uKuYs6uP99D2TYIFrSyTODlOCYvcr0OO03NaQahBOdzprIYbhJojfV R9xynFcTRFQGSeDZ/J4eWdF0hMFxiCavs7wf11wKPylKh0vgNHzFd4EZ4cdxYkVXq5ti r3/N6M6WvwnZrsBaSYnrCSsMrXoPAVdUDegN6Xa4LChhJzkHK1QfEcjy6Mnis+G5PaAS GF8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ga986KJw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id b21-20020a6567d5000000b005b96cbfacdesi1980494pgs.196.2023.11.30.12.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:24:05 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ga986KJw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 AAC118771E; Thu, 30 Nov 2023 21:22:57 +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="Ga986KJw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 99E188770B; Thu, 30 Nov 2023 21:22:54 +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-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (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 564A9876F6 for ; Thu, 30 Nov 2023 21:22:52 +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-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40b399a6529so16460185e9.1 for ; Thu, 30 Nov 2023 12:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375772; x=1701980572; 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=+LJakeFglSK5HTWJWr8yiQtiZQ8ZDLzW8xWntxzGnv4=; b=Ga986KJwMUmxPQBijFu0ekmu1KvLPTJ6a/n/WnLVB7WZXzwtX0Hh0X+ho1QtDz37bC GI8BmhBZflDt5g7T0hnmZpS3sVs3KMVLOSQ1nIBVGrMG3d9oU80csbpH9tGaM9O2rr8T 7T/ERF78zbnzc2s+qfpVNpzbvfbTozK0M18ADrmnGpjO5hXFBRfT2+iftLMVfx/HmqZI haNNt3oOR9kiv7ewiyPke4GwMqVOCqjQSEOpfm9OjozakVYWgzNx5MmqhuDoG3tZ89iF shf3dZxHZtcGpyw8wMPkbBF97STe//ZHPCK30g/cuxlCmJFSJW1aNKgteK2rRNknvkUb G+qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375772; x=1701980572; 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=+LJakeFglSK5HTWJWr8yiQtiZQ8ZDLzW8xWntxzGnv4=; b=mKbj6r5Qj78C7S3jZgPLSqRP1qBlXxvGphiFEoqnBBXwNGEKEmb5Ov+31OaU5+WWiQ yaAD1t5rIwY7OTII6LCFkwJbfnE35kHuxLVZeNsC1MU0m9VML3if2fKJvLdRBJrGX1Ng lmd5xo8L5i0Nt4xl3Y8cV7ANvnIdcof4vxGtLAZdAVoOWJK1vaKRc1WFoIhKPASizhdz 5eulA0CL4eQxUL7bqRKcLcgbXRoC/8B5ml++NLfO9gyAGqMD2sxczb2iP1OEQLOofkwr hFztyd4THmkAqEu2SAhJQKxE/pGVUgj3o/UlI8Rk40q1KLrCYwlxqHVg3HBo2qa3Zl8+ 1bow== X-Gm-Message-State: AOJu0YwbupqTpsG4kau8x5V7c+pRVNLjmFevPiBO84z/FIR+/zQWopBf 3eLcHu3fMu5KU37aTuWJKXip+w== X-Received: by 2002:a05:600c:5248:b0:40b:5e4a:234d with SMTP id fc8-20020a05600c524800b0040b5e4a234dmr43587wmb.79.1701375771871; Thu, 30 Nov 2023 12:22:51 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:51 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:29 +0000 Subject: [PATCH v5 5/9] gpio: qcom_pmic: support upstream DT MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-5-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@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=2187; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=ZRJaS/vffm1bIpnsc4l89aGGwKuzPhD3ry9Iqf7YtrE=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM92JNk+a8PrVSYaP3F0+2lgnqHP75FzgZFd2Yj+XFB NXWrDLrKGVhEORgkBVTZBE/scyyae1le43tCy7AzGFlAhnCwMUpABNRZGNk6Oz1yBS50JARarVv 05oCTe3328wuek22VPkb+iKzUUx+AcN/n4mbFs7/+tLw9p6DXyJ23zwu56yz9ka+6xQvFg6z8DM s4QA= 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. Signed-off-by: Caleb Connolly --- drivers/gpio/qcom_pmic_gpio.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 7b83c67fa464..54f4dbd2b84e 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -245,23 +245,48 @@ 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; } static const struct udevice_id qcom_gpio_ids[] = { - { .compatible = "qcom,pm8916-gpio" }, - { .compatible = "qcom,pm8994-gpio" }, /* 22 GPIO's */ - { .compatible = "qcom,pm8998-gpio" }, - { .compatible = "qcom,pms405-gpio" }, + { .compatible = "qcom,pm8916-gpio", }, + { .compatible = "qcom,pm8994-gpio", }, + { .compatible = "qcom,pm8998-gpio", }, + { .compatible = "qcom,pms405-gpio", }, { } };