From patchwork Wed Nov 8 16:20:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 742237 Delivered-To: patch@linaro.org Received: by 2002:ab3:760f:0:b0:23f:8cfb:5ad7 with SMTP id q15csp479323lte; Wed, 8 Nov 2023 08:21:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFrFABz8gueU6YqRinITReckiZYqdij+FmIB/cMsqakuxArTpztgmF5FrLJ03x+o9vD5zZG X-Received: by 2002:a50:8d19:0:b0:53f:b758:22a3 with SMTP id s25-20020a508d19000000b0053fb75822a3mr2010942eds.3.1699460498800; Wed, 08 Nov 2023 08:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699460498; cv=none; d=google.com; s=arc-20160816; b=OWzxc+eBlT6hQZrkctP23G63P5zCbU0Ag/h7Lc0HgnIGhWmdvt8iwjD3jrYTtaMN1O Jxi2+WH+v+cC0PZdl7zzGuHaxYVP9yKjmLjJLKQGE90wVbJjWDHu5JTH31nS92LCWQq5 YnT1G0VISVYGZbCtEvoHc/eEqNgqxMmB+21S5qcXsQ5GT1OhYH5Lw/MPr3LWbl6/Nm/U AKXQuXRGNLYatpEZDKg2eyo+8gVAMQsg+IFlOU9adEnmu7VTZy7djNhzH0hOQA6yXrse aZ87IpNyk7VCp+0c5uh+j2fbrSuCfOgxCJwNnTmhXT/0gYxj8d2QkbStjFSDuQ9OSLVV 4vpg== 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=g/BcRvYVxyQIqQqsUqqxR3SK7hKJpNeVaw561kxI/4c=; fh=i7Y9asrausL8i9nH7n7DTaWvEmliXkHtoWPkbew9DMg=; b=hB13ywrD9El+orpFTS0Z5om3BMMAqQW2yngsWbDo3EnJV0qSQB88fDLSFPd2sXxcu5 5vhIrxiJlTWWzZft551DfPdY68+E5UCwA4MAHwUx7azHpZbwSyG8ou75ge0zKAiC0jpW 2tlZbig/NTGt2Thy+wunuih21xwGHupp7w0DIKc0iCv3wGe7cMfy2MCaq+F1xuYoXMMs 1hcxxRimOl1xZ9PUn2P0cwZe9woYzQfJaQmmrwJ1iXOLOd/nDJi1pb834f+iBjfsQPaT iJVM/BdrIVKxo8wyKpw8OR1ELdNyo/kpgE27KumplY7e+V0C1tMLK8OvCs5ZJ+bvxvQW tz+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KPcGeHbb; 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 w19-20020a05640234d300b0053dfc4a26e9si6779697edc.414.2023.11.08.08.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:21:38 -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=KPcGeHbb; 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 E03C3875EA; Wed, 8 Nov 2023 17:21:10 +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="KPcGeHbb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B0D6B875A7; Wed, 8 Nov 2023 17:21:07 +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-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (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 4480587576 for ; Wed, 8 Nov 2023 17:21:05 +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-wr1-x42c.google.com with SMTP id ffacd0b85a97d-32f87b1c725so4870202f8f.3 for ; Wed, 08 Nov 2023 08:21:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699460464; x=1700065264; 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=g/BcRvYVxyQIqQqsUqqxR3SK7hKJpNeVaw561kxI/4c=; b=KPcGeHbbzxoyDniY0uIburWepP1upfILA1bxJvdFAyI2s4UcyZmiYR7hopEhcQpGVs 6Tfy81P4T7Wc+cMjtMDvD8zQcd0iYQeXplUAsIW5i5rvXD1aAQwS3NlLYrHdPLGXgJJS 0tTdbiEHIn9i0kh0onuqGnutEdAVTG1+ouDtgGrk+DUwW7blJCi4vMFMEghdEpdgZOw/ 9ykRYTHjWasKIc6pIhu79bOflEM8zC4DEIsuxP5+YaMKEDrVQgcRTyRUwXjbWIMTtEdV LarfQSaToXNlFItH5WjlXFiXhooGWZMcjCR4zUqAWmMMUhbZXdLNIpuVoaUULYwgLGZj qTGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699460464; x=1700065264; 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=g/BcRvYVxyQIqQqsUqqxR3SK7hKJpNeVaw561kxI/4c=; b=SuUKkz17saQ/stdH6QxciQNyXeICOg8HKFIaU3mEJVHYUfIf1J+mudZbVkkhg38E6q KAjmHTMPgdhunLIlwmmp8k/qW4IUPnzS/Hw4O+41D6PuApyTviTlByAilWepv+9M5zQj 7RHgwNtnDz6c3jPhS7mBFUsxEVil/b5ry9+VDe3g/Ot5kKxB6SKYyQuS85Lhoq6x7PQW K3ru8EENYwMXhjYWGa0G1lzjmys/OK+h4Zlx7Kg6Zs4G8/IqTvEmwCo7/YaZc1mXE3qq h7SDQQk4xVElTN4Pr2BJEbUkBtzNrNHD8JFLjHjLI6kHinyHemepWxi3yYWF9+LPT7G1 BrnA== X-Gm-Message-State: AOJu0YyhAVEWI3OswgeUAsznSS6rH0AhA3xj3lTg4CTQAAjKeOHZOSWI JjBABhHsnThAc2vUTPkrt97lOg== X-Received: by 2002:a05:6000:1acc:b0:32f:9ad3:860f with SMTP id i12-20020a0560001acc00b0032f9ad3860fmr1884413wry.52.1699460464686; Wed, 08 Nov 2023 08:21:04 -0800 (PST) Received: from lion.localdomain (host-92-25-138-185.as13285.net. [92.25.138.185]) by smtp.gmail.com with ESMTPSA id n7-20020a5d6607000000b0032db1d741a6sm5273660wru.99.2023.11.08.08.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:21:04 -0800 (PST) From: Caleb Connolly Date: Wed, 08 Nov 2023 16:20:55 +0000 Subject: [PATCH v2 3/5] gpio: qcom_pmic: fix support for upstream DT MIME-Version: 1.0 Message-Id: <20231108-b4-qcom-dt-compat-v2-3-713233c72948@linaro.org> References: <20231108-b4-qcom-dt-compat-v2-0-713233c72948@linaro.org> In-Reply-To: <20231108-b4-qcom-dt-compat-v2-0-713233c72948@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=1610; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=D5lrsqOiSzTZifF0ax83OPPwYm3Gu9vuJkk8F0Sfkcc=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhlTvrTkNeQ2exvN/7/5VNtPC77Jq89pTy1Y+f3WieV6+3 Xne69x8HaUsDIIcDLJiiiziJ5ZZNq29bK+xfcEFmDmsTCBDGLg4BWAiM+IZ/rtUrxbOrZt0ceEv Fa/LKjO/7VwUFy+is3IJQ8LqbzZ2P64x/E8UTfaTWHerLXBjr7Bxj9uazWfWr/Q/uH7hnA93Py9 OEdgJAA== 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 Linux devicetrees use the "gpio-ranges" property, add support for parsing it instead of "gpio-count" so that upstream DTs can be used with U-Boot. Signed-off-by: Caleb Connolly --- drivers/gpio/qcom_pmic_gpio.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 7b83c67fa464..647d4143ce14 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -245,11 +245,37 @@ 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); + if (!uc_priv->gpio_count) { + ret = qcom_gpio_of_parse_ranges(dev); + if (ret > 0) + uc_priv->gpio_count = ret; + else + printf("gpio-ranges error: %d\n", ret); + } uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); if (uc_priv->bank_name == NULL) uc_priv->bank_name = "qcom_pmic";