From patchwork Tue Nov 14 13:48:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 743774 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2176768wrw; Tue, 14 Nov 2023 05:49:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGelqw99Rh4VdMYFoXFeQ5y5Gc6tzCGPevFsFmny2T3aC1KBuYEddxbAlpe2rLvp/H837MA X-Received: by 2002:a17:906:c0d6:b0:9c7:fd91:4309 with SMTP id bn22-20020a170906c0d600b009c7fd914309mr7746638ejb.0.1699969743705; Tue, 14 Nov 2023 05:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699969743; cv=none; d=google.com; s=arc-20160816; b=YYdrV/Sm8PkeAeVLqioUtrehoXObWCJL89kD9A/yLjnH6uAS5l49jKx/sX0l2ZVqIt H9TJ490TmpyYCvQB/POBO8maOyJaC+8aY7x+bVBiH9/vQW+9OvHa2oMIOULqx4N0hiw6 roiT132Wk/91jq0RSYBE8kZ2KGq8tC7sc0er04YIuOU+/kCCVarMcN3BzxM53MXSX2Qt 1oygFj6Qw0wrmU1+aep3lZBFS6aSPU36rert4TpWtUEnTw4RvbIZN+t9nogBKS0rOVw1 TdXTc/J3O+cby0wUjc9JNSEJI+eUgaCsP0LO59/yrXWYRvDTYQSSDhijJt4xT1dqkQqs Z57g== 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=pcPpqjCyVm/6ofdhTTiOBgtbsnh3mMlC3FejEkmFNLk=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=lqT+pAY6hO9A/Z8tlb9RpRnb4t5zWSU+VBSVi6C/fHKiRIzm9CKF1JE/jGhpzhj0Rm OUtfMhEemBuYa0zE3jg49haciG9vJ1qF0zNwmn5ckGiyIQzlNVWIVb8YlN29pIumzIIs y4dtTOj4TX1/ti16U8kN1Dp7wD1dEcJKfPqoq3K61IMosawdtX2IerNTCuiGvln2i4U7 RQYWthsqWRGy1XObgE7f8YTT5oSxy8LR+7vfkDdGqLb694MsAXIEWrtSl3BI1UE+1pGP 0u0qvOOMJSySNFCMQCPLCSPkqOg3YvC3ebNXQeNachlxmg60SdkdZMXWwQ5Ujz+4rS2m aaQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dn1Wl1zm; 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 hs39-20020a1709073ea700b009e5e6f03ebcsi4204936ejc.659.2023.11.14.05.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:49:03 -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=dn1Wl1zm; 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 394FC8747E; Tue, 14 Nov 2023 14:48:54 +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="dn1Wl1zm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E89B3871E4; Tue, 14 Nov 2023 14:48:52 +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-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 1F29387215 for ; Tue, 14 Nov 2023 14:48:51 +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-x335.google.com with SMTP id 5b1f17b1804b1-4083f61322fso44006395e9.1 for ; Tue, 14 Nov 2023 05:48:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699969730; x=1700574530; 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=pcPpqjCyVm/6ofdhTTiOBgtbsnh3mMlC3FejEkmFNLk=; b=dn1Wl1zmoxuaDSRN4Hd3tiEJ/bEltJlEzIiMJ3/0ZQEEj6TaKSbGEugr0h7EXe6fCe TSfiF5NrqNOLzwgbltKKA3jHE9XurXBncMY+gPwKpvPOwqE8rAfnflfykqyK38uthrKX McvVW9FZQpFRKNccF388jIE2E8AkcTc6PQJEe4icODOygm6Uw6pOBeYSrOBrLi+hYHS0 iDrx8z8hICm5X2rwy1Oo55eLXuE1tX/Ir+E9utitTxBJQz2boFi+FjUrelcA52pMJSME gfAxTphowq3++fz7QrFjrVgGdhUmSPEQhATHAPeeRSsuoy9xi3KD660p8TRgZLZAhhgB Kbyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699969730; x=1700574530; 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=pcPpqjCyVm/6ofdhTTiOBgtbsnh3mMlC3FejEkmFNLk=; b=ZwmjKcgIGi9Imk+qMv+aFSF9N6XLmTDSNV5byllSQlOG5k9yEO+9LlxMVxG46TjwN+ UzcupxGUwsqJMDvpAYyCiIFEerp92z6UlPXISKoPeEU2O1jUAzTZ/Ek5lWiycN3dvaTL XpKND+s78Nb8Dk5hmgboXDIGjYy6IxAZM5wcPIx7o4NnLqpW4iQDu014Z5+DTYIQ2Ls1 AEM7odHcNrynP7xKRQ0iwhOMNCLG7kYxYI2UnKgxWUdqvl3rfsfAMlj600JUdyRvUCVK bNxQGt7Tgq9fkgKe34X9xW0a8y6QZz1dVR7JKSc/OADQ3oA+BzbFvL0AWd+8TTHrMJln NT0w== X-Gm-Message-State: AOJu0YwyPE8y/yEPLQeZCjGCkrgQuWyvXOAy0td+FQjmcCV1bY858Il3 6BytuZWCCAqbZ37WfXeUixxwjg== X-Received: by 2002:a05:600c:5247:b0:405:39c1:a98b with SMTP id fc7-20020a05600c524700b0040539c1a98bmr7567467wmb.20.1699969730577; Tue, 14 Nov 2023 05:48:50 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id w10-20020a5d4b4a000000b003313426f136sm7804220wrs.39.2023.11.14.05.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:48:50 -0800 (PST) From: Caleb Connolly Date: Tue, 14 Nov 2023 13:48:47 +0000 Subject: [PATCH v3 1/5] gpio: qcom_pmic: fix silent dev_read_addr downcast MIME-Version: 1.0 Message-Id: <20231114-b4-qcom-dt-compat-v3-1-88a92f8f00ba@linaro.org> References: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@linaro.org> In-Reply-To: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@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=1527; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=L/Hg6krN7n0rquWuC6IguNE2GC8qLGvDuF5QKrLiC1o=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtTgqgNytb5LBf4ePLMrTHFBiNz8r1aXS+ujxXXucGvPU OoM3tLaUcrCIMjBICumyCJ+Ypll09rL9hrbF1yAmcPKBDKEgYtTACYSHc7IsKClzsyzOCdUuboj UfFeRN+R9x/efMue4VTpznX9ItOuAIZ/9s/f8i7e9zLW1kTi/Stj1q9nFvlacRzZ0HExckXytMJ oRQA= 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 priv->pid is uint32_t, but dev_read_addr() returns a uint64_t on arm64, with the upper bits being used for error codes. Do error checking before downcasting to u32 to prevent errors being silently ignored. Signed-off-by: Caleb Connolly Reviewed-by: Sumit Garg --- drivers/gpio/qcom_pmic_gpio.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 65feb453ebc3..e5841f502953 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -221,11 +221,14 @@ static int qcom_gpio_probe(struct udevice *dev) { struct qcom_gpio_bank *priv = dev_get_priv(dev); int reg; + u64 pid; - priv->pid = dev_read_addr(dev); - if (priv->pid == FDT_ADDR_T_NONE) + pid = dev_read_addr(dev); + if (pid == FDT_ADDR_T_NONE) return log_msg_ret("bad address", -EINVAL); + priv->pid = pid; + /* Do a sanity check */ reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE); if (reg != REG_TYPE_VAL) @@ -328,11 +331,14 @@ static int qcom_pwrkey_probe(struct udevice *dev) { struct qcom_gpio_bank *priv = dev_get_priv(dev); int reg; + u64 pid; - priv->pid = dev_read_addr(dev); - if (priv->pid == FDT_ADDR_T_NONE) + pid = dev_read_addr(dev); + if (pid == FDT_ADDR_T_NONE) return log_msg_ret("bad address", -EINVAL); + priv->pid = pid; + /* Do a sanity check */ reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE); if (reg != 0x1) From patchwork Tue Nov 14 13:48:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 743775 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2176845wrw; Tue, 14 Nov 2023 05:49:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcLR+Dj9i6L/3Gy3AZJDqn9nMA2fmFKRe/qRgA9B9xkv5FTw6A7qdocX5dUfXrq4gGgktP X-Received: by 2002:a19:ad41:0:b0:509:15a3:d295 with SMTP id s1-20020a19ad41000000b0050915a3d295mr6640531lfd.45.1699969753291; Tue, 14 Nov 2023 05:49:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699969753; cv=none; d=google.com; s=arc-20160816; b=yqop/Z2YVAQ+CfJhCmZtyp1P8usSYCTh4DpLhew8Q95zo3pRf/4txmnjiYyvc4p7AF eQRWGtE/aL2RAEXhXXIn0sYoRhqDPKCFmOXwGiAjVSBsmU6SyfEFUJdMc8hnO2lMldK4 kbMZOuZ6Ot1x6XPbB+i5JgqWQoywoSio+yvEOJ/VAUDspExh5xGv2SgTErsqjKU/CoZT e6MZSpod8Dp/bxNvEmw9/EQ4pODU6BbIKEPFCcK200jIljMbLUrsFHCu88FotdOjZtrP 9XRu0WH9mAVqLWqmnTKzv0q3+YdYKFObyU9/iRz2kV8lxY+XP9LMrueQfuPCgEkCwhCO OCAw== 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=TGGSuc6BnUGX7iB0QidxuNUl3WSz9RgEcMYRvfqAbrI=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=sH5Tu2SVv+4fBBbFyVtI5H4sYrWVM8Q3mfJqkeIREBXY+PEOkEJSEY+WoMLbWNaugt FDtogKQ/pvld2ThypCLtnowVrpPCZoB1GgBIDul5LWgcm+/pj28WIvUnuJ+r+4n8//db e0HUsv1QE7d2zXPTjqEFPCKFQyoQX4gKdTzzb4owVg4aeQ2g0fB6qeAtsFR8hPwwZUrv dNrxMzS2qUTpSu9aRFSCUaFY2Zos82NT+fBLUHGtufZ3gbhQpKM/w4G7RGIKoLu31IaB bEMhzQR5/34G7tFVtGWhqtSNWiA0h3vjj7CCa0gKWF3hKdzuYh+14XUbhxRGJbvWLTjP AMlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e7apqyRS; 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 a1-20020a509b41000000b0053e1cb26246si3747384edj.141.2023.11.14.05.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:49:13 -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=e7apqyRS; 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 AB13487215; Tue, 14 Nov 2023 14:48:55 +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="e7apqyRS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CE28987446; Tue, 14 Nov 2023 14:48: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-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 585638745D for ; Tue, 14 Nov 2023 14:48: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-wr1-x432.google.com with SMTP id ffacd0b85a97d-32fadd4ad09so3886091f8f.1 for ; Tue, 14 Nov 2023 05:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699969732; x=1700574532; 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=TGGSuc6BnUGX7iB0QidxuNUl3WSz9RgEcMYRvfqAbrI=; b=e7apqyRSaL+tfdS+oVACwA+AYCOUm+qgAEDw3Vwebej5h+pC6BrDneJdt4q9cUsiTr 6rVMG0vKKfMmjJJB/cm2w7Ot47wT1/d1OZ4ldu3mE9EmjPkS53PxKw957vxgnoMabpP1 dRpreE2i5WaPOWZ4eo0Hf+S2NK3TWst0ayKtxl1o6m3BsCHXzfNgXMtgvfSv8pdgjcAi kHJ32ctXZEQAWS8WH61MKjMh0oIyvrTzr8cVM3sfWMwuMDdDiTZkOXaNqZDxC2+P3uVB W/Cq0NYQItRnv6PkrFl6PbFRs9ejEOMoFFXbcIz65Xm4AIUEG+StoAKulyGJSzibndnu NiPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699969732; x=1700574532; 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=TGGSuc6BnUGX7iB0QidxuNUl3WSz9RgEcMYRvfqAbrI=; b=sXStb4tFHhDY76jR8gIA4sjETmoZ7Gz0l1sEbUuN9VM1Yt47FytlAWhvwRRjednpSb QTzD7Fr8YFcpC0LIXuxM6QcWJ7AYttDeDsmQkEBKf6NfvwxpF/cvy4AO41cA2Jj3nT33 AvyvTLP+T+ZjgSNhT5Ibx5uTpl/js9wpvl1Rc1AbrDt+mQcPI4Hia3lyoU8CQ6Jq+F4A nCYJmmcrdTS6Oj/HhYEL5EBxTaJ7vQ8LRfNw6wo6/+12dGPXkocH53/G2Cyv7TxgGSGm SOkdDm74eGSMuKD2hnnvovX5jGXlkKZqLCHRQWmILChiRkWHNB0rl0T1L+WQO+WCvruc xESA== X-Gm-Message-State: AOJu0YzzXPHt0aG/jLwFgBLU6kHJDcEyXNbmLpF+oAGvygqq/lS+OK7E YvpdOUQoBG3yhefCeKeiq0sh/A== X-Received: by 2002:a05:6000:4012:b0:32f:8181:7d39 with SMTP id cp18-20020a056000401200b0032f81817d39mr9841050wrb.9.1699969731522; Tue, 14 Nov 2023 05:48:51 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id w10-20020a5d4b4a000000b003313426f136sm7804220wrs.39.2023.11.14.05.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:48:51 -0800 (PST) From: Caleb Connolly Date: Tue, 14 Nov 2023 13:48:48 +0000 Subject: [PATCH v3 2/5] gpio: qcom_pmic: rework pwrkey driver into a button driver MIME-Version: 1.0 Message-Id: <20231114-b4-qcom-dt-compat-v3-2-88a92f8f00ba@linaro.org> References: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@linaro.org> In-Reply-To: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@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=23423; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=GRJ6lHWFEsVn60z/zeY0P4M1P8hxpZrlbvWzFfqPNp4=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtTgqgNl1Vsvt9Vp/Znj4bQ8/WzCGTHFJ74yyXbP7qWxX Sh7VlLUUcrCIMjBICumyCJ+Ypll09rL9hrbF1yAmcPKBDKEgYtTACayW4SRYfH3uqXavQqsuYct b3dGHM9Q3+3E7njgfHwP9+zncv6dJxkZ2p+1hZpJvF3+UtAzrNRFtLqQ05TLfnvjyuu3uTR5pl9 xBwA= 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 The power and resin keys were implemented as GPIOs here, but their only use would be as buttons. Avoid the additional layer of introspection and rework this driver into a button driver. While we're here, replace the "qcom,pm8998-pwrkey" compatible with "qcom,pm8941-pwrkey" to match upstream (Linux). The dragonboard410c and 820c boards are adjusted to benefit from this change too, simplify their custom board init code. Signed-off-by: Caleb Connolly --- MAINTAINERS | 1 + arch/arm/dts/dragonboard410c-uboot.dtsi | 11 -- arch/arm/dts/dragonboard410c.dts | 22 ++- arch/arm/dts/dragonboard820c-uboot.dtsi | 12 -- arch/arm/dts/dragonboard820c.dts | 23 +++- arch/arm/dts/dragonboard845c-uboot.dtsi | 11 -- arch/arm/dts/dragonboard845c.dts | 4 + arch/arm/dts/sdm845.dtsi | 23 +++- arch/arm/dts/starqltechn-uboot.dtsi | 10 -- arch/arm/dts/starqltechn.dts | 20 +-- arch/arm/mach-snapdragon/Kconfig | 3 + arch/arm/mach-snapdragon/init_sdm845.c | 45 ++----- board/qualcomm/dragonboard410c/dragonboard410c.c | 31 ++--- board/qualcomm/dragonboard820c/dragonboard820c.c | 29 ++-- drivers/button/Kconfig | 9 ++ drivers/button/Makefile | 1 + drivers/button/button-qcom-pmic.c | 165 +++++++++++++++++++++++ drivers/gpio/Kconfig | 3 +- drivers/gpio/qcom_pmic_gpio.c | 104 -------------- 19 files changed, 269 insertions(+), 258 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index f6d63c8ab563..8cd102eaa070 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -572,6 +572,7 @@ M: Neil Armstrong R: Sumit Garg S: Maintained F: arch/arm/mach-snapdragon/ +F: drivers/button/button-qcom-pmic.c F: drivers/clk/qcom/ F: drivers/gpio/msm_gpio.c F: drivers/mmc/msm_sdhci.c diff --git a/arch/arm/dts/dragonboard410c-uboot.dtsi b/arch/arm/dts/dragonboard410c-uboot.dtsi index 3b0bd0ed0a1b..cec64bf80f99 100644 --- a/arch/arm/dts/dragonboard410c-uboot.dtsi +++ b/arch/arm/dts/dragonboard410c-uboot.dtsi @@ -42,14 +42,3 @@ gpios = <&pm8916_gpios 3 0>; }; }; - - -&pm8916_pon { - key_vol_down { - gpios = <&pm8916_pon 1 0>; - }; - - key_power { - gpios = <&pm8916_pon 0 0>; - }; -}; diff --git a/arch/arm/dts/dragonboard410c.dts b/arch/arm/dts/dragonboard410c.dts index 9230dd3fd96c..c41fee977813 100644 --- a/arch/arm/dts/dragonboard410c.dts +++ b/arch/arm/dts/dragonboard410c.dts @@ -147,11 +147,23 @@ #address-cells = <0x1>; #size-cells = <0x1>; - pm8916_pon: pm8916_pon@800 { - compatible = "qcom,pm8916-pwrkey"; - reg = <0x800 0x96>; - #gpio-cells = <2>; - gpio-controller; + pon@800 { + compatible = "qcom,pm8916-pon"; + reg = <0x800 0x100>; + mode-bootloader = <0x2>; + mode-recovery = <0x1>; + + pwrkey { + compatible = "qcom,pm8941-pwrkey"; + debounce = <15625>; + bias-pull-up; + }; + + pm8916_resin: resin { + compatible = "qcom,pm8941-resin"; + debounce = <15625>; + bias-pull-up; + }; }; pm8916_gpios: pm8916_gpios@c000 { diff --git a/arch/arm/dts/dragonboard820c-uboot.dtsi b/arch/arm/dts/dragonboard820c-uboot.dtsi index 457728a43ecb..d93c7c1fbdee 100644 --- a/arch/arm/dts/dragonboard820c-uboot.dtsi +++ b/arch/arm/dts/dragonboard820c-uboot.dtsi @@ -30,15 +30,3 @@ }; }; }; - -&pm8994_pon { - key_vol_down { - gpios = <&pm8994_pon 1 0>; - label = "key_vol_down"; - }; - - key_power { - gpios = <&pm8994_pon 0 0>; - label = "key_power"; - }; -}; diff --git a/arch/arm/dts/dragonboard820c.dts b/arch/arm/dts/dragonboard820c.dts index ad201d48749c..0d9c9f7a4922 100644 --- a/arch/arm/dts/dragonboard820c.dts +++ b/arch/arm/dts/dragonboard820c.dts @@ -109,12 +109,23 @@ #address-cells = <0x1>; #size-cells = <0x1>; - pm8994_pon: pm8994_pon@800 { - compatible = "qcom,pm8994-pwrkey"; - reg = <0x800 0x96>; - #gpio-cells = <2>; - gpio-controller; - gpio-bank-name="pm8994_key."; + pm8994_pon: pon@800 { + compatible = "qcom,pm8916-pon"; + reg = <0x800 0x100>; + mode-bootloader = <0x2>; + mode-recovery = <0x1>; + + pwrkey { + compatible = "qcom,pm8941-pwrkey"; + debounce = <15625>; + bias-pull-up; + }; + + pm8994_resin: resin { + compatible = "qcom,pm8941-resin"; + debounce = <15625>; + bias-pull-up; + }; }; pm8994_gpios: pm8994_gpios@c000 { diff --git a/arch/arm/dts/dragonboard845c-uboot.dtsi b/arch/arm/dts/dragonboard845c-uboot.dtsi index 7728f4f4a3e5..775f45c0149f 100644 --- a/arch/arm/dts/dragonboard845c-uboot.dtsi +++ b/arch/arm/dts/dragonboard845c-uboot.dtsi @@ -24,14 +24,3 @@ }; }; }; - -&pm8998_pon { - key_vol_down { - gpios = <&pm8998_pon 1 0>; - label = "key_vol_down"; - }; - key_power { - gpios = <&pm8998_pon 0 0>; - label = "key_power"; - }; -}; diff --git a/arch/arm/dts/dragonboard845c.dts b/arch/arm/dts/dragonboard845c.dts index b4f057ac6537..054f253eb32a 100644 --- a/arch/arm/dts/dragonboard845c.dts +++ b/arch/arm/dts/dragonboard845c.dts @@ -41,4 +41,8 @@ }; }; +&pm8998_resin { + status = "okay"; +}; + #include "dragonboard845c-uboot.dtsi" diff --git a/arch/arm/dts/sdm845.dtsi b/arch/arm/dts/sdm845.dtsi index 4798ace0ff8b..cd5d890e9a45 100644 --- a/arch/arm/dts/sdm845.dtsi +++ b/arch/arm/dts/sdm845.dtsi @@ -78,12 +78,25 @@ #address-cells = <0x1>; #size-cells = <0x1>; - pm8998_pon: pm8998_pon@800 { - compatible = "qcom,pm8998-pwrkey"; + pm8998_pon: pon@800 { + compatible = "qcom,pm8998-pon"; + reg = <0x800 0x100>; - #gpio-cells = <2>; - gpio-controller; - gpio-bank-name = "pm8998_key."; + mode-bootloader = <0x2>; + mode-recovery = <0x1>; + + pm8998_pwrkey: pwrkey { + compatible = "qcom,pm8941-pwrkey"; + debounce = <15625>; + bias-pull-up; + }; + + pm8998_resin: resin { + compatible = "qcom,pm8941-resin"; + debounce = <15625>; + bias-pull-up; + status = "disabled"; + }; }; pm8998_gpios: pm8998_gpios@c000 { diff --git a/arch/arm/dts/starqltechn-uboot.dtsi b/arch/arm/dts/starqltechn-uboot.dtsi index 034d5c1c07ed..55c6d18412ba 100644 --- a/arch/arm/dts/starqltechn-uboot.dtsi +++ b/arch/arm/dts/starqltechn-uboot.dtsi @@ -25,13 +25,3 @@ }; }; -&pm8998_pon { - key_vol_down { - gpios = <&pm8998_pon 1 0>; - label = "key_vol_down"; - }; - key_power { - gpios = <&pm8998_pon 0 0>; - label = "key_power"; - }; -}; diff --git a/arch/arm/dts/starqltechn.dts b/arch/arm/dts/starqltechn.dts index 5b6372bee79a..0842e19adb60 100644 --- a/arch/arm/dts/starqltechn.dts +++ b/arch/arm/dts/starqltechn.dts @@ -45,22 +45,6 @@ format = "a8r8g8b8"; }; - gpio-keys { - compatible = "gpio-keys"; - - key-pwr { - label = "Power"; - linux,code = ; - gpios = <&pm8998_pon 0 GPIO_ACTIVE_LOW>; - }; - - key-vol-down { - label = "Volume Down"; - linux,code = ; - gpios = <&pm8998_pon 1 GPIO_ACTIVE_LOW>; - }; - }; - soc: soc { serial@a84000 { status = "okay"; @@ -68,6 +52,10 @@ }; }; +&pm8998_resin { + status = "okay"; +}; + &tlmm { muic_i2c: muic-i2c-n { pins = "GPIO_33", "GPIO_34"; diff --git a/arch/arm/mach-snapdragon/Kconfig b/arch/arm/mach-snapdragon/Kconfig index 3c9f3bee3f18..ad6671081910 100644 --- a/arch/arm/mach-snapdragon/Kconfig +++ b/arch/arm/mach-snapdragon/Kconfig @@ -17,6 +17,7 @@ config SDM845 select LINUX_KERNEL_IMAGE_HEADER imply CLK_QCOM_SDM845 imply PINCTRL_QCOM_SDM845 + imply BUTTON_QCOM_PMIC config LNX_KRNL_IMG_TEXT_OFFSET_BASE default 0x80000000 @@ -30,6 +31,7 @@ config TARGET_DRAGONBOARD410C select ENABLE_ARM_SOC_BOOT0_HOOK imply CLK_QCOM_APQ8016 imply PINCTRL_QCOM_APQ8016 + imply BUTTON_QCOM_PMIC help Support for 96Boards Dragonboard 410C. This board complies with 96Board Open Platform Specifications. Features: @@ -45,6 +47,7 @@ config TARGET_DRAGONBOARD820C bool "96Boards Dragonboard 820C" imply CLK_QCOM_APQ8096 imply PINCTRL_QCOM_APQ8096 + imply BUTTON_QCOM_PMIC help Support for 96Boards Dragonboard 820C. This board complies with 96Board Open Platform Specifications. Features: diff --git a/arch/arm/mach-snapdragon/init_sdm845.c b/arch/arm/mach-snapdragon/init_sdm845.c index 1f8850239437..067acc9a6f44 100644 --- a/arch/arm/mach-snapdragon/init_sdm845.c +++ b/arch/arm/mach-snapdragon/init_sdm845.c @@ -5,6 +5,7 @@ * (C) Copyright 2021 Dzmitry Sankouski */ +#include #include #include #include @@ -32,46 +33,18 @@ __weak int board_init(void) /* Check for vol- and power buttons */ __weak int misc_init_r(void) { - struct udevice *pon; - struct gpio_desc resin; - int node, ret; + struct udevice *btn; + int ret; + enum button_state_t state; - ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8998_pon@800", &pon); + ret = button_get_by_label("pwrkey", &btn); if (ret < 0) { - printf("Failed to find PMIC pon node. Check device tree\n"); - return 0; + printf("Couldn't find power button!\n"); + return ret; } - node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon), - "key_vol_down"); - if (node < 0) { - printf("Failed to find key_vol_down node. Check device tree\n"); - return 0; - } - if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0, - &resin, 0)) { - printf("Failed to request key_vol_down button.\n"); - return 0; - } - if (dm_gpio_get_value(&resin)) { - env_set("key_vol_down", "1"); - printf("Volume down button pressed\n"); - } else { - env_set("key_vol_down", "0"); - } - - node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon), - "key_power"); - if (node < 0) { - printf("Failed to find key_power node. Check device tree\n"); - return 0; - } - if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0, - &resin, 0)) { - printf("Failed to request key_power button.\n"); - return 0; - } - if (dm_gpio_get_value(&resin)) { + state = button_get_state(btn); + if (state == BUTTON_ON) { env_set("key_power", "1"); printf("Power button pressed\n"); } else { diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c index 371b3262f8c5..350e0e9e20aa 100644 --- a/board/qualcomm/dragonboard410c/dragonboard410c.c +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c @@ -5,6 +5,7 @@ * (C) Copyright 2015 Mateusz Kulikowski */ +#include #include #include #include @@ -108,32 +109,20 @@ int board_usb_init(int index, enum usb_init_type init) /* Check for vol- button - if pressed - stop autoboot */ int misc_init_r(void) { - struct udevice *pon; - struct gpio_desc resin; - int node, ret; + struct udevice *btn; + int ret; + enum button_state_t state; - ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon); + ret = button_get_by_label("vol_down", &btn); if (ret < 0) { - printf("Failed to find PMIC pon node. Check device tree\n"); - return 0; + printf("Couldn't find power button!\n"); + return ret; } - node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon), - "key_vol_down"); - if (node < 0) { - printf("Failed to find key_vol_down node. Check device tree\n"); - return 0; - } - - if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0, - &resin, 0)) { - printf("Failed to request key_vol_down button.\n"); - return 0; - } - - if (dm_gpio_get_value(&resin)) { + state = button_get_state(btn); + if (state == BUTTON_ON) { env_set("preboot", "setenv preboot; fastboot 0"); - printf("key_vol_down pressed - Starting fastboot.\n"); + printf("vol_down pressed - Starting fastboot.\n"); } return 0; diff --git a/board/qualcomm/dragonboard820c/dragonboard820c.c b/board/qualcomm/dragonboard820c/dragonboard820c.c index 6785bf58e949..2f0db628368b 100644 --- a/board/qualcomm/dragonboard820c/dragonboard820c.c +++ b/board/qualcomm/dragonboard820c/dragonboard820c.c @@ -5,6 +5,7 @@ * (C) Copyright 2017 Jorge Ramirez-Ortiz */ +#include #include #include #include @@ -139,30 +140,18 @@ void reset_cpu(void) /* Check for vol- button - if pressed - stop autoboot */ int misc_init_r(void) { - struct udevice *pon; - struct gpio_desc resin; - int node, ret; + struct udevice *btn; + int ret; + enum button_state_t state; - ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8994_pon@800", &pon); + ret = button_get_by_label("pwrkey", &btn); if (ret < 0) { - printf("Failed to find PMIC pon node. Check device tree\n"); - return 0; + printf("Couldn't find power button!\n"); + return ret; } - node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon), - "key_vol_down"); - if (node < 0) { - printf("Failed to find key_vol_down node. Check device tree\n"); - return 0; - } - - if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0, - &resin, 0)) { - printf("Failed to request key_vol_down button.\n"); - return 0; - } - - if (dm_gpio_get_value(&resin)) { + state = button_get_state(btn); + if (state == BUTTON_ON) { env_set("bootdelay", "-1"); printf("Power button pressed - dropping to console.\n"); } diff --git a/drivers/button/Kconfig b/drivers/button/Kconfig index 8ce2de37d62a..097b05f822e7 100644 --- a/drivers/button/Kconfig +++ b/drivers/button/Kconfig @@ -27,4 +27,13 @@ config BUTTON_GPIO The GPIO driver must used driver model. Buttons are configured using the device tree. +config BUTTON_QCOM_PMIC + bool "Qualcomm power button" + depends on BUTTON + depends on PMIC_QCOM + help + Enable support for the power and "resin" (usually volume down) buttons + on Qualcomm SoCs. These will be configured as the Enter and Down keys + respectively, allowing navigation of bootmenu with buttons on device. + endmenu diff --git a/drivers/button/Makefile b/drivers/button/Makefile index bbd18af14940..68555081a47a 100644 --- a/drivers/button/Makefile +++ b/drivers/button/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_BUTTON) += button-uclass.o obj-$(CONFIG_BUTTON_ADC) += button-adc.o obj-$(CONFIG_BUTTON_GPIO) += button-gpio.o +obj-$(CONFIG_BUTTON_QCOM_PMIC) += button-qcom-pmic.o \ No newline at end of file diff --git a/drivers/button/button-qcom-pmic.c b/drivers/button/button-qcom-pmic.c new file mode 100644 index 000000000000..34a976d1e6c6 --- /dev/null +++ b/drivers/button/button-qcom-pmic.c @@ -0,0 +1,165 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Qualcomm generic pmic gpio driver + * + * (C) Copyright 2015 Mateusz Kulikowski + * (C) Copyright 2023 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define REG_TYPE 0x4 +#define REG_SUBTYPE 0x5 + +struct qcom_pmic_btn_priv { + u32 base; + u32 status_bit; + int code; + struct udevice *pmic; +}; + +#define PON_INT_RT_STS 0x10 +#define KPDPWR_ON_INT_BIT 0 +#define RESIN_ON_INT_BIT 1 + +#define NODE_IS_PWRKEY(node) (!strncmp(ofnode_get_name(node), "pwrkey", strlen("pwrkey"))) +#define NODE_IS_RESIN(node) (!strncmp(ofnode_get_name(node), "resin", strlen("resin"))) + +static enum button_state_t qcom_pwrkey_get_state(struct udevice *dev) +{ + struct qcom_pmic_btn_priv *priv = dev_get_priv(dev); + + int reg = pmic_reg_read(priv->pmic, priv->base + PON_INT_RT_STS); + + if (reg < 0) + return 0; + + return (reg & BIT(priv->status_bit)) != 0; +} + +static int qcom_pwrkey_get_code(struct udevice *dev) +{ + struct qcom_pmic_btn_priv *priv = dev_get_priv(dev); + + return priv->code; +} + +static int qcom_pwrkey_probe(struct udevice *dev) +{ + struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev); + struct qcom_pmic_btn_priv *priv = dev_get_priv(dev); + ofnode node = dev_ofnode(dev); + int ret; + u64 base; + + /* Ignore the top-level pon node */ + if (!uc_plat->label) + return 0; + + /* the pwrkey and resin nodes are children of the "pon" node, get the + * PMIC device to use in pmic_reg_* calls. + */ + priv->pmic = dev->parent->parent; + + /* Get the address of the parent pon node */ + base = dev_read_addr(dev->parent); + if (base == FDT_ADDR_T_NONE) { + printf("%s: Can't find address\n", dev->name); + return -EINVAL; + } + + priv->base = base; + + /* Do a sanity check */ + ret = pmic_reg_read(priv->pmic, priv->base + REG_TYPE); + if (ret != 0x1 && ret != 0xb) { + printf("%s: unexpected PMIC function type %d\n", dev->name, ret); + return -ENXIO; + } + + ret = pmic_reg_read(priv->pmic, priv->base + REG_SUBTYPE); + if ((ret & 0x7) == 0) { + printf("%s: unexpected PMCI function subtype %d\n", dev->name, ret); + return -ENXIO; + } + + if (NODE_IS_PWRKEY(node)) { + priv->status_bit = 0; + priv->code = KEY_ENTER; + } else if (NODE_IS_RESIN(node)) { + priv->status_bit = 1; + priv->code = KEY_DOWN; + } else { + /* Should not get here! */ + printf("Invalid pon node '%s' should be 'pwrkey' or 'resin'\n", + ofnode_get_name(node)); + return -EINVAL; + } + + return 0; +} + +static int button_qcom_pmic_bind(struct udevice *parent) +{ + struct udevice *dev; + ofnode node; + int ret; + + dev_for_each_subnode(node, parent) { + struct button_uc_plat *uc_plat; + const char *label; + + if (!ofnode_is_enabled(node)) + continue; + + ret = device_bind_driver_to_node(parent, "qcom_pwrkey", + ofnode_get_name(node), + node, &dev); + if (ret) { + printf("Failed to bind %s! %d\n", label, ret); + return ret; + } + uc_plat = dev_get_uclass_plat(dev); + if (NODE_IS_PWRKEY(node)) { + uc_plat->label = "pwrkey"; + } else if (NODE_IS_RESIN(node)) { + uc_plat->label = "vol_down"; + } else { + printf("Unknown button node '%s' should be 'pwrkey' or 'resin'\n", + ofnode_get_name(node)); + device_unbind(dev); + } + } + + return 0; +} + +static const struct button_ops button_qcom_pmic_ops = { + .get_state = qcom_pwrkey_get_state, + .get_code = qcom_pwrkey_get_code, +}; + +static const struct udevice_id qcom_pwrkey_ids[] = { + { .compatible = "qcom,pm8916-pon" }, + { .compatible = "qcom,pm8941-pon" }, + { .compatible = "qcom,pm8998-pon" }, + { } +}; + +U_BOOT_DRIVER(qcom_pwrkey) = { + .name = "qcom_pwrkey", + .id = UCLASS_BUTTON, + .of_match = qcom_pwrkey_ids, + .bind = button_qcom_pmic_bind, + .probe = qcom_pwrkey_probe, + .ops = &button_qcom_pmic_ops, + .priv_auto = sizeof(struct qcom_pmic_btn_priv), +}; diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index ba42b0768e12..fbf77673c5e0 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -309,12 +309,13 @@ config CMD_PCA953X config QCOM_PMIC_GPIO bool "Qualcomm generic PMIC GPIO/keypad driver" depends on DM_GPIO && PMIC_QCOM + select BUTTON help Support for GPIO pins and power/reset buttons found on Qualcomm SoCs PMIC. Default name for GPIO bank is "pm8916". Power and reset buttons are placed in "pwkey_qcom" bank and - have gpio numbers 0 and 1 respectively. + have gpio numbers 0 and 1 respectively. config PCF8575_GPIO bool "PCF8575 I2C GPIO Expander driver" diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index e5841f502953..7b83c67fa464 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -275,107 +275,3 @@ U_BOOT_DRIVER(qcom_pmic_gpio) = { .priv_auto = sizeof(struct qcom_gpio_bank), }; - -/* Add pmic buttons as GPIO as well - there is no generic way for now */ -#define PON_INT_RT_STS 0x10 -#define KPDPWR_ON_INT_BIT 0 -#define RESIN_ON_INT_BIT 1 - -static int qcom_pwrkey_get_function(struct udevice *dev, unsigned offset) -{ - return GPIOF_INPUT; -} - -static int qcom_pwrkey_get_value(struct udevice *dev, unsigned offset) -{ - struct qcom_gpio_bank *priv = dev_get_priv(dev); - - int reg = pmic_reg_read(dev->parent, priv->pid + PON_INT_RT_STS); - - if (reg < 0) - return 0; - - switch (offset) { - case 0: /* Power button */ - return (reg & BIT(KPDPWR_ON_INT_BIT)) != 0; - break; - case 1: /* Reset button */ - default: - return (reg & BIT(RESIN_ON_INT_BIT)) != 0; - break; - } -} - -/* - * Since pmic buttons modelled as GPIO, we need empty direction functions - * to trick u-boot button driver - */ -static int qcom_pwrkey_direction_input(struct udevice *dev, unsigned int offset) -{ - return 0; -} - -static int qcom_pwrkey_direction_output(struct udevice *dev, unsigned int offset, int value) -{ - return -EOPNOTSUPP; -} - -static const struct dm_gpio_ops qcom_pwrkey_ops = { - .get_value = qcom_pwrkey_get_value, - .get_function = qcom_pwrkey_get_function, - .direction_input = qcom_pwrkey_direction_input, - .direction_output = qcom_pwrkey_direction_output, -}; - -static int qcom_pwrkey_probe(struct udevice *dev) -{ - struct qcom_gpio_bank *priv = dev_get_priv(dev); - int reg; - u64 pid; - - pid = dev_read_addr(dev); - if (pid == FDT_ADDR_T_NONE) - return log_msg_ret("bad address", -EINVAL); - - priv->pid = pid; - - /* Do a sanity check */ - reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE); - if (reg != 0x1) - return log_msg_ret("bad type", -ENXIO); - - reg = pmic_reg_read(dev->parent, priv->pid + REG_SUBTYPE); - if ((reg & 0x5) == 0) - return log_msg_ret("bad subtype", -ENXIO); - - return 0; -} - -static int qcom_pwrkey_of_to_plat(struct udevice *dev) -{ - struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - - uc_priv->gpio_count = 2; - uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); - if (uc_priv->bank_name == NULL) - uc_priv->bank_name = "pwkey_qcom"; - - return 0; -} - -static const struct udevice_id qcom_pwrkey_ids[] = { - { .compatible = "qcom,pm8916-pwrkey" }, - { .compatible = "qcom,pm8994-pwrkey" }, - { .compatible = "qcom,pm8998-pwrkey" }, - { } -}; - -U_BOOT_DRIVER(pwrkey_qcom) = { - .name = "pwrkey_qcom", - .id = UCLASS_GPIO, - .of_match = qcom_pwrkey_ids, - .of_to_plat = qcom_pwrkey_of_to_plat, - .probe = qcom_pwrkey_probe, - .ops = &qcom_pwrkey_ops, - .priv_auto = sizeof(struct qcom_gpio_bank), -}; From patchwork Tue Nov 14 13:48:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 743776 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2176927wrw; Tue, 14 Nov 2023 05:49:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEg9XZYUwn1PB+i52D+4muph2IPf79gNqrc9F9IMXUJUOqp+E7ssIk4v/jzNSISBO77VSt5 X-Received: by 2002:a17:906:300b:b0:9ba:a38:531e with SMTP id 11-20020a170906300b00b009ba0a38531emr7370046ejz.52.1699969763682; Tue, 14 Nov 2023 05:49:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699969763; cv=none; d=google.com; s=arc-20160816; b=yjLzYmaFt3T6dDyAEu0VaYycqfaCjDgENcR6Jmw8UtLOKymWRCsbvBNcGQAr33RB2K 7zNT+aRap171k0xtVb33Uy11Tty8Uphuxzw+N/hI5SBdZu0ZDglNT1QVPNsBNbIIN9X0 10cJH07gLm/rnyVPaX0Gz52JYF0h1dCZX66MqdDImLoWmXw37hrUpACOY/6i7YpTowOE 3Fza/DM8WmvSYC/qH9RcP52QoMLN1yu4qAxGxY/RTCZ93KKBFD3tzCv8EgPsai7aszUM gjoDD22VBKNFrMJTxfoLBceTkJx7LzskZBzzBq9YqwtNlI2Yx+nimzz+a8GXo7D6eAiT +frA== 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=jI/l4CqgBGDD443rF4TTf/YO0j+k3/gQmH6HyMKvn1E=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=VytuQUd1ZZy0yQ3FXYQpRiR7TSm9gqwaB5dXQ5oMunm9jes1WI4x1uOF3yN5QezP5f 0swY7CvsJnf2xR62UGMXp7b6TQF8s1klIk/jFAlxZVTKiDikx6JuiM3FnxYK3rtBPjdM jMmY4cWuuhF+mcovx377RbHZjyQ4E8nku0bSh9HlunEeIxErAHncqobVnE11bBLdYamy 6aaWHOMU0wiy6FKbDJ69Ns7RpqB3QYSRDabA3k2nsgDpvW9vzbGHtmLwtRETu7HH7sH2 +o9dCGz/6rV8Y0iR2eLQhSK8huJVKVG8isl72+EUjNlltF5HXnkWYaQwk6Hm3cGzisSt KdPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nzxNRuus; 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 mc17-20020a170906eb5100b009942c859e77si4031073ejb.193.2023.11.14.05.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:49:23 -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=nzxNRuus; 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 23C448749A; Tue, 14 Nov 2023 14:48:56 +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="nzxNRuus"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 329218745D; Tue, 14 Nov 2023 14:48:55 +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-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) (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 31F2A871E4 for ; Tue, 14 Nov 2023 14:48:53 +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-x22e.google.com with SMTP id 38308e7fff4ca-2c509f2c46cso79345561fa.1 for ; Tue, 14 Nov 2023 05:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699969732; x=1700574532; 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=jI/l4CqgBGDD443rF4TTf/YO0j+k3/gQmH6HyMKvn1E=; b=nzxNRuusq0cMb91RPGlJBvQMQnS3AaWhzQfj8hJ3ajgw5S+uzIxMWbmdQquG/v8E9e jSF+v/hQeLxN9YEyCeIOW9iBxi8cB+oTsc01AOfiO9fszs73lRb2RHzJAK8U844Lmq+/ PNEKVFRVcLw3J8VaDaCEBGQmZ64VaSuirhMSDXf/1HDZvzmx3jplH/jN0C6JIPXkDA3N T0QXI2lY7lvEM7ZcvX1eHXofh3JVxm/gr3q6Kwqg5Pl7dNG9makX0E4MF7ruiIUe/D01 /rdHp2uwFrnzhHd4oeWkN4/Q+pTiuPiWWBEWso46XDsKxX6cUQpmVNr7b4bJSnriDF5X jiDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699969732; x=1700574532; 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=jI/l4CqgBGDD443rF4TTf/YO0j+k3/gQmH6HyMKvn1E=; b=XZYdu1YOa3zOCSiPvsmHknRkvxaYPGj70LWRZqRPvJnmARddmaorXLBS/yd0gyD6hl yqGgzYLwVsjKjNDtb2eH7QKfxN3AfrHWHdT9ZIVChtERrUcML3DWAfwhXNnmG2DGUhkj eacdFjof6aSCCm9r+JNKi4U2Pshw9aMqtNZJ2OzvXaU6x21p7uNuNshqPxuuA5O3RJRz DYVwwTQ5GQ006spNLgHXxX5A9+PAsP4XebjSGRdcxkkW65G4vMwjQLauIxreyooCMnXl CtV83ocNVVbThSZh65clD77i3xQu2GG2tyOEx/gfEyYioTvXAVU2fGgf2WTKjiabyf7j 5q0Q== X-Gm-Message-State: AOJu0YwcbAkaN+rF9wl5iZxKuHGWfQYYZL49O9FPV3Nv7xOFvgayzKnv gQXNNS2JT7KDc8bHWOHbd0fYbQ== X-Received: by 2002:a2e:3c03:0:b0:2c5:999:de64 with SMTP id j3-20020a2e3c03000000b002c50999de64mr1563819lja.16.1699969732584; Tue, 14 Nov 2023 05:48:52 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id w10-20020a5d4b4a000000b003313426f136sm7804220wrs.39.2023.11.14.05.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:48:52 -0800 (PST) From: Caleb Connolly Date: Tue, 14 Nov 2023 13:48:49 +0000 Subject: [PATCH v3 3/5] gpio: qcom_pmic: fix support for upstream DT MIME-Version: 1.0 Message-Id: <20231114-b4-qcom-dt-compat-v3-3-88a92f8f00ba@linaro.org> References: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@linaro.org> In-Reply-To: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@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=4167; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=biTuo/YGg0zWe6lK+r/M8Dw3vz9xAKbdjHOcAQ8XE/E=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtTgqgP88a/P3SnX/uLQe+Wr0twnB7rrp9+dfc3PplDwg pb2zP0rO0pZGAQ5GGTFFFnETyyzbFp72V5j+4ILMHNYmUCGMHBxCsBEbNcz/BV4ekvga+CDaSU5 7xqOiZ2ftt7265pvvOpdR1Of8piLtM5l+F+QZVAW/lmL+aDM54Yv53N9AyyulGtWLut/2PCQo6o k6hcA 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 --- arch/arm/dts/dragonboard410c.dts | 3 +-- arch/arm/dts/dragonboard820c.dts | 3 +-- arch/arm/dts/qcs404-evb.dts | 2 +- arch/arm/dts/sdm845.dtsi | 3 +-- drivers/gpio/qcom_pmic_gpio.c | 38 ++++++++++++++++++++++++++++++-------- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/arch/arm/dts/dragonboard410c.dts b/arch/arm/dts/dragonboard410c.dts index c41fee977813..6a4e3ccf17b1 100644 --- a/arch/arm/dts/dragonboard410c.dts +++ b/arch/arm/dts/dragonboard410c.dts @@ -170,9 +170,8 @@ compatible = "qcom,pm8916-gpio"; reg = <0xc000 0x400>; gpio-controller; - gpio-count = <4>; + gpio-ranges = <&pm8916_gpios 0 0 4>; #gpio-cells = <2>; - gpio-bank-name="pmic"; }; }; diff --git a/arch/arm/dts/dragonboard820c.dts b/arch/arm/dts/dragonboard820c.dts index 0d9c9f7a4922..146a0af8aafe 100644 --- a/arch/arm/dts/dragonboard820c.dts +++ b/arch/arm/dts/dragonboard820c.dts @@ -132,9 +132,8 @@ compatible = "qcom,pm8994-gpio"; reg = <0xc000 0x400>; gpio-controller; - gpio-count = <24>; + gpio-ranges = <&pm8994_gpios 0 0 22>; #gpio-cells = <2>; - gpio-bank-name="pm8994."; }; }; diff --git a/arch/arm/dts/qcs404-evb.dts b/arch/arm/dts/qcs404-evb.dts index 84224a8a3d39..3bb580ba4e17 100644 --- a/arch/arm/dts/qcs404-evb.dts +++ b/arch/arm/dts/qcs404-evb.dts @@ -378,7 +378,7 @@ compatible = "qcom,pms405-gpio"; reg = <0xc000 0x400>; gpio-controller; - gpio-count = <12>; + gpio-ranges = <&pms405_gpios 0 0 12>; #gpio-cells = <2>; gpio-bank-name="pmic"; }; diff --git a/arch/arm/dts/sdm845.dtsi b/arch/arm/dts/sdm845.dtsi index cd5d890e9a45..a26e9f411ee0 100644 --- a/arch/arm/dts/sdm845.dtsi +++ b/arch/arm/dts/sdm845.dtsi @@ -103,9 +103,8 @@ compatible = "qcom,pm8998-gpio"; reg = <0xc000 0x1a00>; gpio-controller; - gpio-count = <21>; + gpio-ranges = <&pm8998_gpios 0 0 26>; #gpio-cells = <2>; - gpio-bank-name = "pm8998."; }; }; diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 7b83c67fa464..f2424766e5cc 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -245,23 +245,45 @@ 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"; + ret = qcom_gpio_of_parse_ranges(dev); + if (ret > 0) + uc_priv->gpio_count = ret; + else + return ret; + + uc_priv->bank_name = (const char *)dev->driver_data; 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", .data = (ulong)&"pm8916_gpio" }, + { .compatible = "qcom,pm8994-gpio", .data = (ulong)&"pm8994_gpio" }, + { .compatible = "qcom,pm8998-gpio", .data = (ulong)&"pm8998_gpio" }, + { .compatible = "qcom,pms405-gpio", .data = (ulong)&"pms405_gpio" }, { } }; From patchwork Tue Nov 14 13:48: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: 743777 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2177012wrw; Tue, 14 Nov 2023 05:49:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4RA83M97ssefMeUoneGJP+rrRw1he1TteYiRewO4jIq7qMvpG/ThPm+ylmU1rzrHOmwwn X-Received: by 2002:a17:907:7256:b0:9d5:96e7:5ae1 with SMTP id ds22-20020a170907725600b009d596e75ae1mr2588783ejc.12.1699969774362; Tue, 14 Nov 2023 05:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699969774; cv=none; d=google.com; s=arc-20160816; b=wZwKoZZOpqceYeezoVQah18lpWok4lMvMA6NeBiSfQLR2KAjuTVnn2myRmzVIyCwNN MiuQdN0ejklvFrwc6XStC2ILRp1YMb3uhvYPNBykuLNdOOPPPtdlZnqVe+mcIuZxvfaT qDTVG3FN81wrG2kND8PUcOE5I3zwjIjSBeAkVyGf6bTxMyCd0A0+AG3Taw+b3wdRA+34 MqKpC7UOu82YJI+Smv9RARslrJrQ5f5c1NqedKwebJ+isNWELU4SR4UT0IJtxSbO2gvt OdyLHZfQt5TJ344UHdlXf5MpiIU8V7kRYenbmTE5wXZipquo9eaZmGIfS/X9LoZTpDSs P7iA== 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=K4HJn/tQnDoPEBtaMDZXekvN7HN3mdSExqfi0/VY234=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=Mo9g1XiMPC7Qyu/j9xL8rz3nYY4Wc7Bx/iPiitVacZYiPT1UB7xPtBuUcZkm+LYhKq yjmTE9dleIXYEjm9q5WpDEX5qDfOJL2XSUmiNTVogIHeKGCgannsMMMjCAWCduuxcA3J aO690rrh9jDfj/3B2QV4N6RfqzShJAgPivD7z6yd8EsD7Ib3ynlyfsnACTv4ZXsAK3Wr 2Z/ouLbgj7EwyHMAO4mmjqursbzMtuhZ2hZexERi6P1mFEM1ky9QCwZ3tlFQWBi6BqFe AOdz9AFgaxaB+thLbUAzY0a7TBx17zL7gT+omgsYfpToJKQi27oxUCqLJx9kGpwHPiYQ 48cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oH3b6srR; 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 mm28-20020a170906cc5c00b009a472926f77si4016046ejb.219.2023.11.14.05.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:49:34 -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=oH3b6srR; 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 8E4F68749E; Tue, 14 Nov 2023 14:48:58 +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="oH3b6srR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A3E68748F; Tue, 14 Nov 2023 14:48:56 +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-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 F3D1187474 for ; Tue, 14 Nov 2023 14:48:53 +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-x32b.google.com with SMTP id 5b1f17b1804b1-40806e4106dso33196455e9.1 for ; Tue, 14 Nov 2023 05:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699969733; x=1700574533; 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=K4HJn/tQnDoPEBtaMDZXekvN7HN3mdSExqfi0/VY234=; b=oH3b6srRJ8o9FCxtXIx/Q3n/nh48AW6pJqi5iftFjNwvCq/ysCa/j5VITQjm6tf3IX 2QWK4IVcenYwk77ksPcIxAt3kFIObGLFP0PPgqTa/V3dUttbl9xEB2fS20N7QcTciBE6 s3I5bH9nCVJBFVn7eCCcBw2YriEJItB1v41Ef8uocBWhv64siUwMyKWh5ORq8KljZLBY ypXcv1BqMESa29+Y8PgofPQrUqlRpU2ZbsgDMhrTsjDcewg5bIMJHEXoTflJafL3rniS 1vTCfcf+EQTjDjaKYbjh2PKT9nYt8Ki/FHrbgTQLoD/cKVh2Es3ZHR/t4TyDPYan5uWN GrdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699969733; x=1700574533; 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=K4HJn/tQnDoPEBtaMDZXekvN7HN3mdSExqfi0/VY234=; b=Sp6kWBm84vn3jQS4nOzJ56iUlHwEM8qtSl1e2YJl8oNhnUvaqNemEYJq+meT+L0mI+ FmkQ29P7zG0icbMnO6baHlHCXZzdEZxPGfhQSbN7rUIuuTusQt7HW2t+Ds3uDmFVP/PI YBmsPGa6lIZHkA7w3xOdkGnbhOSkUQJJbJa2VeLwC3JR+Duza2HU/UoN0HiIQd562MrD FRgprW03+1+Mhk+6zB6SDOBGoUTM+YgW9FT4s+mU4JQ6ahKRe5wOytHEURv/Syqob+Tn AfzM7JaTsUb5A2Mpir3DBV+q8Jj4PWZq7lC2G5BcNm0dXYuitcDs7L8AGjMW2flV2Kdo PzKg== X-Gm-Message-State: AOJu0YxXULYSaISeW0S3K9b7bD9FguTXPX8WjOwGLeUfMBa3ls7nGWNh dGOJI5fLgwl/Lie13aKFXLp6mQ== X-Received: by 2002:a05:600c:1549:b0:409:6e0e:e95a with SMTP id f9-20020a05600c154900b004096e0ee95amr2211020wmg.19.1699969733524; Tue, 14 Nov 2023 05:48:53 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id w10-20020a5d4b4a000000b003313426f136sm7804220wrs.39.2023.11.14.05.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:48:53 -0800 (PST) From: Caleb Connolly Date: Tue, 14 Nov 2023 13:48:50 +0000 Subject: [PATCH v3 4/5] spmi: msm: fix register range names MIME-Version: 1.0 Message-Id: <20231114-b4-qcom-dt-compat-v3-4-88a92f8f00ba@linaro.org> References: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@linaro.org> In-Reply-To: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@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=4848; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=5Nq6pIXn+6EIZVVsV3wf0ErrywVU36ZaB7JxmmJtnFg=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtTgqgN2+cWyJXz6AasnmnstSNWp+CQs53xo180GGaeZL ir6nhodpSwMghwMsmKKLOInllk2rb1sr7F9wQWYOaxMIEMYuDgFYCIH8hkZ9mxMXCcTeGT1zT12 XzxiFAtPvipZx+Z5cfVy4f5FJY2T6hkZNty/xXgoUX/p7o2CXgeElf/9vx//ZZ2kQkDNnMDS7/+ 5hQE= 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 The core and chnl register ranges were swapped on SDM845. Fix it, and fetch the register ranges by name instead of by index. Drop the cosmetic "version" variable and clean up the debug logging. Signed-off-by: Caleb Connolly --- arch/arm/dts/sdm845.dtsi | 2 +- drivers/spmi/spmi-msm.c | 46 ++++++++++++++++++---------------------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/arch/arm/dts/sdm845.dtsi b/arch/arm/dts/sdm845.dtsi index a26e9f411ee0..96c9749a52c0 100644 --- a/arch/arm/dts/sdm845.dtsi +++ b/arch/arm/dts/sdm845.dtsi @@ -63,7 +63,7 @@ reg = <0xc440000 0x1100>, <0xc600000 0x2000000>, <0xe600000 0x100000>; - reg-names = "cnfg", "core", "obsrvr"; + reg-names = "core", "chnls", "obsrvr"; #address-cells = <0x1>; #size-cells = <0x1>; diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index 27a035c0a595..f8834e60c266 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -70,7 +70,7 @@ enum pmic_arb_channel { struct msm_spmi_priv { phys_addr_t arb_chnl; /* ARB channel mapping base */ - phys_addr_t spmi_core; /* SPMI core */ + phys_addr_t spmi_chnls; /* SPMI core */ phys_addr_t spmi_obs; /* SPMI observer */ /* SPMI channel map */ uint8_t channel_map[SPMI_MAX_SLAVES][SPMI_MAX_PERIPH]; @@ -95,10 +95,10 @@ static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, /* Disable IRQ mode for the current channel*/ writel(0x0, - priv->spmi_core + SPMI_CH_OFFSET(channel) + SPMI_REG_CONFIG); + priv->spmi_chnls + SPMI_CH_OFFSET(channel) + SPMI_REG_CONFIG); /* Write single byte */ - writel(val, priv->spmi_core + SPMI_CH_OFFSET(channel) + SPMI_REG_WDATA); + writel(val, priv->spmi_chnls + SPMI_CH_OFFSET(channel) + SPMI_REG_WDATA); /* Prepare write command */ reg |= SPMI_CMD_EXT_REG_WRITE_LONG << SPMI_CMD_OPCODE_SHIFT; @@ -113,12 +113,12 @@ static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, ch_offset = SPMI_CH_OFFSET(channel); /* Send write command */ - writel(reg, priv->spmi_core + SPMI_CH_OFFSET(channel) + SPMI_REG_CMD0); + writel(reg, priv->spmi_chnls + SPMI_CH_OFFSET(channel) + SPMI_REG_CMD0); /* Wait till CMD DONE status */ reg = 0; while (!reg) { - reg = readl(priv->spmi_core + SPMI_CH_OFFSET(channel) + + reg = readl(priv->spmi_chnls + SPMI_CH_OFFSET(channel) + SPMI_REG_STATUS); } @@ -186,47 +186,37 @@ static struct dm_spmi_ops msm_spmi_ops = { static int msm_spmi_probe(struct udevice *dev) { struct msm_spmi_priv *priv = dev_get_priv(dev); - phys_addr_t config_addr; + phys_addr_t core_addr; u32 hw_ver; - u32 version; int i; - int err; - config_addr = dev_read_addr_index(dev, 0); - priv->spmi_core = dev_read_addr_index(dev, 1); - priv->spmi_obs = dev_read_addr_index(dev, 2); + core_addr = dev_read_addr_name(dev, "core"); + priv->spmi_chnls = dev_read_addr_name(dev, "chnls"); + priv->spmi_obs = dev_read_addr_name(dev, "obsrvr"); - hw_ver = readl(config_addr + PMIC_ARB_VERSION); + hw_ver = readl(core_addr + PMIC_ARB_VERSION); if (hw_ver < PMIC_ARB_VERSION_V3_MIN) { priv->arb_ver = V2; - version = 2; - priv->arb_chnl = config_addr + APID_MAP_OFFSET_V1_V2_V3; + priv->arb_chnl = core_addr + APID_MAP_OFFSET_V1_V2_V3; } else if (hw_ver < PMIC_ARB_VERSION_V5_MIN) { priv->arb_ver = V3; - version = 3; - priv->arb_chnl = config_addr + APID_MAP_OFFSET_V1_V2_V3; + priv->arb_chnl = core_addr + APID_MAP_OFFSET_V1_V2_V3; } else { priv->arb_ver = V5; - version = 5; - priv->arb_chnl = config_addr + APID_MAP_OFFSET_V5; - - if (err) { - dev_err(dev, "could not read APID->PPID mapping table, rc= %d\n", err); - return -1; - } + priv->arb_chnl = core_addr + APID_MAP_OFFSET_V5; } - dev_dbg(dev, "PMIC Arb Version-%d (0x%x)\n", version, hw_ver); + dev_dbg(dev, "PMIC Arb Version-%d (%#x)\n", hw_ver >> 28, hw_ver); if (priv->arb_chnl == FDT_ADDR_T_NONE || - priv->spmi_core == FDT_ADDR_T_NONE || + priv->spmi_chnls == FDT_ADDR_T_NONE || priv->spmi_obs == FDT_ADDR_T_NONE) return -EINVAL; - dev_dbg(dev, "priv->arb_chnl address (%llu)\n", priv->arb_chnl); - dev_dbg(dev, "priv->spmi_core address (%llu)\n", priv->spmi_core); - dev_dbg(dev, "priv->spmi_obs address (%llu)\n", priv->spmi_obs); + dev_dbg(dev, "priv->arb_chnl address (%#08llx)\n", priv->arb_chnl); + dev_dbg(dev, "priv->spmi_chnls address (%#08llx)\n", priv->spmi_chnls); + dev_dbg(dev, "priv->spmi_obs address (%#08llx)\n", priv->spmi_obs); /* Scan peripherals connected to each SPMI channel */ for (i = 0; i < SPMI_MAX_PERIPH; i++) { uint32_t periph = readl(priv->arb_chnl + ARB_CHANNEL_OFFSET(i)); From patchwork Tue Nov 14 13:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 743778 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2177091wrw; Tue, 14 Nov 2023 05:49:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGA/ZzKqOs8YcJoK7bxLKBH2DhE2xgvzUiVuyg0QIbTc3qSwMB9hGhJbgqW5fk8MlRP0mRi X-Received: by 2002:a50:c050:0:b0:540:9d0c:75fc with SMTP id u16-20020a50c050000000b005409d0c75fcmr6628614edd.26.1699969784852; Tue, 14 Nov 2023 05:49:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699969784; cv=none; d=google.com; s=arc-20160816; b=hbdlhHjcijDjYWScssNlJKiepPovK0zujMsncIVCsaADsibf+vPLoWtE2ezis85CUs uKHXVQdJpF70K4P9bweiTfQyWL/2OvHeOsMCKLCuwkd3BmqIh+erKRPNAGyE12ip3+sL Vin6TAfeMKHCyNXC9adQqWxbnfquJ3mS10t7s6AIHpwV2fyADAIEFiJT/nTHWPDSC2hA 8mbM00XGEesYDhllMVIYxRZjWTFLXXdejnPyAjB4mX1lofOXVfVUbZMYqv/Kky3XdUEd i7+nnHzczsPLhB/+Yykzy3NZdHsu1lc5sPboHVlMKtlpzEYaTrHHkgtZgm01HZfquQz9 ERNw== 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=YJfp5QS/eefmKujbF78pe1VSO00cljqoNnqX74yAIow=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=Z91F29nktiwjGh9D6MJ6HQ0zwEfy7JQ8GfgFgsDfDHGZRCb9HodSmVDjs6nx3e+3W9 mJnfmOL3Bh72G/KY6oy6AjRcHuGs9ubmACKNoShBsZclihQ38+B4wWbZiyN4slhVmUUP atGXyhY/D6Y7SUBFiu5n7n5NJQ63nZUtJtK3kIQuSYGId0NHCmzdSgzUfnpK0kDyZCjG USrroneTTkaYGMjHa8ElJN9Wk6wic288H50E1H6G5Nr6LwYa4a36JEeRbCQ4nS1W1feF Uwqh/b4yBrUucOXrSq78Brm59e92tJcc9zifPkFVytGIomac0WKEIWPycfaM0hRFu9gO NZaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xH8iJeTn; 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 p24-20020aa7d318000000b0054340fa19d5si3896535edq.589.2023.11.14.05.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:49:44 -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=xH8iJeTn; 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 09322874B1; Tue, 14 Nov 2023 14:48:59 +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="xH8iJeTn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF54F87499; Tue, 14 Nov 2023 14:48:56 +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-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 DD5318744F for ; Tue, 14 Nov 2023 14:48:54 +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-x32b.google.com with SMTP id 5b1f17b1804b1-40a48775c58so33704925e9.3 for ; Tue, 14 Nov 2023 05:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699969734; x=1700574534; 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=YJfp5QS/eefmKujbF78pe1VSO00cljqoNnqX74yAIow=; b=xH8iJeTna2sICgwfkk9LK7pfAOdpdmlc4VrTq5QuMBqvmGibLD6Gi0noBxE5JrWFOp kVL4y5iD8uJXbX2v+gNRM7o4AQer1a1l58kKeQ+E+Fmogq2EUeBbwjLF88hVTQdepJDn DJ6z4oyMq4QkkFEt1lrIJ6lHBDuqCpKbmkMbTasYP51gClmeeFQ6cBDo/wZOD2gsivYu ImQNJWqd9FDc+W0nMHnA54xw+hEAUKcMa+UMLOl4zS48Yyvt1NNJq/MksvgHcilBbLq4 13bLVOMDo7UVLXbQmF2BjBmFacZzyZd4Hict0rTwTV3uXvM3FPl3DGkw6RLIwppm+URP DwfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699969734; x=1700574534; 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=YJfp5QS/eefmKujbF78pe1VSO00cljqoNnqX74yAIow=; b=VBjffOitM/cFRDLLI/NcGV2vqewOfQZiVLkk4riwWccVgWndddZfhK5PX+y0h9MJag 53bAYZJVls7jJ8HcBczxRY0Aa4Yjqs2wfPEaini9k8uRCoXXN5t+et6UKlSj9Pxv5Ywy LeRVrzN2ZBXpoiu3dzXWqWGIDy+Dr1qwy94mdZ4ORlZin5bHEBJmwsOfNuLuxpcAfzP5 r0xUf1b05S6aUZnGUf+fJ/e6x1WV421hrrDQ01rYCgdXqqQraNrmtETsn1vOexDosaKI EhsiytvxYDMU8PYDsTQiTQbwC/OQX2fts/AXgT/tvMQfK5LayNV7nc/HxS7Dn0F0XHEj W9uQ== X-Gm-Message-State: AOJu0YzS89R4dvhh8y//5XXwNZSzcR57uIvaDl2qzQseCFngjBbxxFL8 w3zDZNS+4EmE90TUEHWEqGXgsg== X-Received: by 2002:a05:600c:231a:b0:40a:3e13:22b0 with SMTP id 26-20020a05600c231a00b0040a3e1322b0mr7425000wmo.41.1699969734438; Tue, 14 Nov 2023 05:48:54 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id w10-20020a5d4b4a000000b003313426f136sm7804220wrs.39.2023.11.14.05.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:48:53 -0800 (PST) From: Caleb Connolly Date: Tue, 14 Nov 2023 13:48:51 +0000 Subject: [PATCH v3 5/5] pmic: qcom: dont use dev_read_addr to get USID MIME-Version: 1.0 Message-Id: <20231114-b4-qcom-dt-compat-v3-5-88a92f8f00ba@linaro.org> References: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@linaro.org> In-Reply-To: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@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=1388; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=pJOwgwuqESk9m96peXOf3uui++e6fZBT/bur0vD18ic=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtTgqgOLdW023unRL97xtvXZ71NVV5fWlZY03W3p3ijfM 1f+evafjlIWBkEOBlkxRRbxE8ssm9ZettfYvuACzBxWJpAhDFycAjCRzZcYGTbcbvUUD3QQ85RY YTdjmmRg0pS13bPN7p65w6Td/eDKaTaG/7lJje9XvJqosXTbokM2K47/t7w2d6Xlk/ld0iKZjnE /TwUBAA== 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 DTs stuff a value indicating if the USID is a USID or a GSID in the reg property, the Linux SPMI driver then reads the two address cells separately. U-boot's dev_read_addr() doesn't know how to handle this, so use ofnode_read_u32_index() to get just the USID. The Qcom pmic driver doesn't have support for GSID handling, so just ignore the second value for now. Signed-off-by: Caleb Connolly --- drivers/power/pmic/pmic_qcom.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/power/pmic/pmic_qcom.c b/drivers/power/pmic/pmic_qcom.c index ad8daf43f06f..f2ac6494811d 100644 --- a/drivers/power/pmic/pmic_qcom.c +++ b/drivers/power/pmic/pmic_qcom.c @@ -66,12 +66,19 @@ static const struct udevice_id pmic_qcom_ids[] = { static int pmic_qcom_probe(struct udevice *dev) { struct pmic_qcom_priv *priv = dev_get_priv(dev); + int ret; - priv->usid = dev_read_addr(dev); - - if (priv->usid == FDT_ADDR_T_NONE) + /* + * dev_read_addr() can't be used here because the reg property actually + * contains two discrete values, not a single 64-bit address. + * The address is the first value. + */ + ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", 0, &priv->usid); + if (ret < 0) return -EINVAL; + debug("usid: %d\n", priv->usid); + return 0; }