From patchwork Wed Nov 8 16:20:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 742235 Delivered-To: patch@linaro.org Received: by 2002:ab3:760f:0:b0:23f:8cfb:5ad7 with SMTP id q15csp479161lte; Wed, 8 Nov 2023 08:21:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRU3HWyK4e/m2zJtyYFys/UsybSMUhssYX6KTXOQkWPX2iBwd0NJpEBmIg8UbY+fep3QVJ X-Received: by 2002:a50:9f6e:0:b0:53e:7781:2279 with SMTP id b101-20020a509f6e000000b0053e77812279mr2004451edf.36.1699460484794; Wed, 08 Nov 2023 08:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699460484; cv=none; d=google.com; s=arc-20160816; b=u0eN6BgyAOJqnL2uMxnAhEW4+R2ku+P/HWYBf+1NccZAlvgXKQp9o/Vc5ngytUrZ1p 15oQIq3LL56KX6IrDVGmCWIWs+noWKfy0vzc65JyKt1BNe4WN4v7+0q1K2o5T8l9RgwM 6rrPctXzHvR787e1r74aDj5hSTBAY5ezGaoiSGAxHRZ2bl+Q4NupqwHqv4OAcQRxs+4G VaGJ1/Qh/Un2Ae9HQfsGhnQa/ljWO0eJaVKVgNKEUV7h9HUgDtoBxytHpdtZ2+88GICY z/zL7BRAnMzOZ9kk/Lq1FlQRhEDx2I94YrwRMjgF1jzoBSmXSRJRTPqDNrj2mZDN4wYL 14Cw== 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=VCAIZbVxHMpTnsm7TVx+XTK2iDbZ6+ydra9nYJxmJOo=; fh=i7Y9asrausL8i9nH7n7DTaWvEmliXkHtoWPkbew9DMg=; b=rupuEW3g8wsJUo4BS780oQIU6x9gnjZUu4PGcPkGgMLp0yJkZj4pcMpwwfbyL6Rs9B jDD2v7serPBbwKivTQBW+MX5WHeko1e/cb+XrZ22U/pqjHkTGD/RnR813vnCYasCte14 oT2ViJy/aYWC3OBud+2s6nRZh315wozglznyWszHTdoPQeLIW1Tdrrp6SZCBemhpiacN Q3ksIEaaY23zXfwIuAiYl02HhquBcK2NmQ/zG6xhJlMr1eO4qKIRhKDJ5SVpxuSJdRre LNNmZRBdl4KhHuMbP44plWocClu9bCXnNsEossKpWsKwuDQe4sw9q7OwvmoKeEix5wco wHrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w46tInyt; 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 n24-20020a5099d8000000b0053e8d0d8a40si6567680edb.222.2023.11.08.08.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:21:24 -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=w46tInyt; 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 7317F87572; 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="w46tInyt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 54948875A7; 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-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 96CD78754A for ; Wed, 8 Nov 2023 17:21:03 +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-x435.google.com with SMTP id ffacd0b85a97d-32d834ec222so3643682f8f.0 for ; Wed, 08 Nov 2023 08:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699460462; x=1700065262; 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=VCAIZbVxHMpTnsm7TVx+XTK2iDbZ6+ydra9nYJxmJOo=; b=w46tInytVUc9WtTT+aUWo2kjvgNBH37oyLYWsoH6kJPrT76PheEiNbYIiHRj9aqDlw eYYFy05VOFagmZrZvt9Fkp7XKr03QPzw9WiFYWWyN7g0S75SBSTy5h3ALnZMW46QT4BT PeTfm5Lnqcm5QwX3Qq7LAikTM5S02sjnDJwJ6+2kkcAbQmp43O2Bt7EZcC3jctTCte/n rS8MAewg1TFLN9t/7C85htD/ACNzTSItLYsQ1ONphtTDrPFWeCG++CLOEQvRB4SLdReP GAnPWpdNwskw5qOls9dAd2CmXppNw9U2ZHkvYoNf5Wx5Z2MA2bYMKvwoXbXln0FnRzzl e5bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699460462; x=1700065262; 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=VCAIZbVxHMpTnsm7TVx+XTK2iDbZ6+ydra9nYJxmJOo=; b=lCw15zKEfLo+uRMgrklRTgWuczjGxlB25KcrLgxkcn0kwMAXQWJ8+tLXRnBgEEsAnM dp4EuMNnmj+6I4XxPDrys2lvRT3dqL/0fNrysnWjV4NrzukqCl1AmelnnvjEF+m3D67J iIplVAkzozrJHV5xCir/a+PP0eUiQeKi+BQe2Ti5/ir+KDJLOrbfHdxQars9y5L8eRaf ld1IxEBbQtdPgQ4YtdY9VMomh63Rd3iXUt3IGD2aIpdRvQLpg3oh/WLK0wvELQbxiO4R f6N8ukSOfIwszqZQIRGYm7XaQCFd1h33Rilf7gdFdgdS1ls4ZSQ1KURdu5B8/DL5qkLY 3Oag== X-Gm-Message-State: AOJu0YzLJ0Pu+Ir/Mj9whWjY6yEZb9BBpfuXYJY95W6TTySWwrt/7R+x sojaAfxHOYT0uaDbsAnNR5qFliwFAUgfbSqs8GhJIA== X-Received: by 2002:a5d:4f0c:0:b0:32f:7967:aa4d with SMTP id c12-20020a5d4f0c000000b0032f7967aa4dmr1857855wru.68.1699460462552; Wed, 08 Nov 2023 08:21:02 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:21:01 -0800 (PST) From: Caleb Connolly Date: Wed, 08 Nov 2023 16:20:53 +0000 Subject: [PATCH v2 1/5] gpio: qcom_pmic: fix silent dev_read_addr downcast MIME-Version: 1.0 Message-Id: <20231108-b4-qcom-dt-compat-v2-1-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=1527; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=yUdSWNMLnPJpyCscd/Vnde7MMn7arQIEoSvg1f014Lw=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhlTvrTnTW+ezZog8njT/hVqVhm4gm9mPTTfme7H9mZPxf 8KZKT21HaUsDIIcDLJiiiziJ5ZZNq29bK+xfcEFmDmsTCBDGLg4BWAingkM/3Teb5qdc/7zl7p/ KauzVtWnOYqYLuJaZ9308rfgFqOdzf8ZGRbf+r97uypv2rqoMqOFlfOZA46LKGU8mrQwteFN26P N/lEA 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 --- 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 Wed Nov 8 16:20:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 742238 Delivered-To: patch@linaro.org Received: by 2002:ab3:760f:0:b0:23f:8cfb:5ad7 with SMTP id q15csp479505lte; Wed, 8 Nov 2023 08:21:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHeVaC6qiPIVUANB+st1uS+2Bs6Da+L2+UybLsdBSrCJUDX78kwWFmjz9fR+wAELgBULgi X-Received: by 2002:a50:8d52:0:b0:544:7c9b:6227 with SMTP id t18-20020a508d52000000b005447c9b6227mr1874805edt.4.1699460512757; Wed, 08 Nov 2023 08:21:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699460512; cv=none; d=google.com; s=arc-20160816; b=U/sPMjqV1Ihw9lOU4lY/RTW4AIo6A2tzYNYE2LLdTtftNoNnrRvJMbfXAyQAq7Q5Nz wiZAtqYGyqE7wNMWD9CI3PxLuketX3zF5fpiJre/tkDfLEKrSH9AhJ+dCNT+XVaLxS// CdKg1BARLK/RI+qltZ0F3crEfsQwtgHUSe2H/MwTeYzjMyQImyGy9E0lqu+je+HMIpIi 1qOHck1B/I4I9drrVD48B4mSZzu60DouABsMFB/yXB2x5yC4Jb998JnpBjIPljuVO/yn N0k6Pc92TCkVKwOoWWAyOxQzyWCxBvBxa5Xfj3koUVnbE2HxtCOXysCT7L6IBsVDGZM5 2lrQ== 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=9Kyd6lwk3VaOzuXFDsQrHX0cudy1TRXN/ZFytlLhHXM=; fh=i7Y9asrausL8i9nH7n7DTaWvEmliXkHtoWPkbew9DMg=; b=YTervDUwLu6MpYgjPA1FljO69ezMwiFgca63hvONVqeWM1eli+raI1Mpiect66BitL oCTS8PnGXqMLA3Y1bOAPACVsFkP48cKbsLIVSObK5tWPQGFHXiURuyusMduNQA7yNJfm 7efOEN57TmPkJ0SOHMSwu2EAG5CG3d/0rR/51QcAVLgAEWUxp4Pj6UVbJIhjbDU+ATZ8 Ugcwq279UX8eJJYT4feJaG21jTg30IN4iFQ2DtzGXSwVkbH3rbpL63XsBHtCoQEJul9c 1zcEs66qG6YgTt+UBi1WlufwyLJbTSKhFXfRS0LE0FM07Z6fUXi8JKJni7tV14ZUh9Mb AuFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lW3JGclR; 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 u23-20020a50c057000000b00542fb42362bsi7255047edd.552.2023.11.08.08.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:21:52 -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=lW3JGclR; 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 719A4876F4; Wed, 8 Nov 2023 17:21:12 +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="lW3JGclR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 29F248766C; Wed, 8 Nov 2023 17:21:10 +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-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 58A418755C for ; Wed, 8 Nov 2023 17:21: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-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-407c3adef8eso59905395e9.2 for ; Wed, 08 Nov 2023 08:21:04 -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=9Kyd6lwk3VaOzuXFDsQrHX0cudy1TRXN/ZFytlLhHXM=; b=lW3JGclRgRNBcgMHAg8Fyyw9O2+FZzj/AMbREzprs1UZr83Grfg/BJ/3WqBzNA/JPC rExvJAwnhN7pqh37BPbRol6oUmoYuqaH2l+HxrVSIGmDJnPsAXdgqmKpnzen+uV1LPqs +6CB4PovdTYPm+y0nTLYGlWqC7On+5vsBl6+EgPwSZ/uPPeRa86hz+c09/+aXkuviIbe +IUzC2wJ2BpTZFyJcg57cZDHYSN/O9z9ctsoyTHt8WaOFKvC20kMiNtbnfZjMT0GM0US PxWdrowEVBLklC5YpDm1+mJKo48TbV5IwSEZMcQQp1v0EIvWC4jG03ngsaHLzCoNnliH tuJQ== 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=9Kyd6lwk3VaOzuXFDsQrHX0cudy1TRXN/ZFytlLhHXM=; b=oV0t0CzU7klcL1OWGs4zlAdPJNXsRy/hmj6/WeIp4hPvFfF5pki8bYoUn2GYfuz+oE QU/s1ZATcTcm3dro5ISU/Z/6a2SjbMDDV4bnDu6p7uwDk7Cb6lUymSJho3DbAXLDmxWL Xcei4uOgeSkGozLIoJdcL/LOPTr9830S0WkT2toxgjasP5x97zGeOJdGBP3QleOqmLhL DiziBQpGUrH2in/OneNz8GexXjYl568Xdra7eax2T1SRYHgKICCIE1bHKIiFL8dBklad e4QrhTVVXd8TFJ7CPzDzB2/nu2wSVxxJWoWankU9O6Heb8ado0hCwP9WB5wZA4MmI4BO olmg== X-Gm-Message-State: AOJu0Yx+tcrydvLo34tBn4rtWoyyy3ncnycBoMJvfUbDDSDygXZjWFLp EfiypXHclQAUEcx2xfrMVdEGLw== X-Received: by 2002:a5d:6488:0:b0:32f:7a44:76df with SMTP id o8-20020a5d6488000000b0032f7a4476dfmr2244134wri.49.1699460463631; Wed, 08 Nov 2023 08:21:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:21:03 -0800 (PST) From: Caleb Connolly Date: Wed, 08 Nov 2023 16:20:54 +0000 Subject: [PATCH v2 2/5] gpio: qcom_pmic: rework pwrkey driver into a button driver MIME-Version: 1.0 Message-Id: <20231108-b4-qcom-dt-compat-v2-2-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=23400; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=DgkA7g/3lQjAgOCPv6AbHSj0NPzxqbSZ/R8qW1zKYMA=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhlTvrTmzz5xfl9uoXeUwtVwlMLhD9xtrZPgsXQWFVa3Tf 6bIsH3vKGVhEORgkBVTZBE/scyyae1le43tCy7AzGFlAhnCwMUpABP5MZmRYe/mnbzbs78vdKqf x/y0r2fvJiPGKVsbloZ9X5rBk/ZuwmWGf3oiOvvKbzXEfpG6ZpnvW5xk6XPUvuztrKj6L7xM/RU uVwE= 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 | 14 +- arch/arm/dts/dragonboard410c.dts | 22 ++- arch/arm/dts/dragonboard820c-uboot.dtsi | 15 +-- 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.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 -------------- 18 files changed, 275 insertions(+), 248 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..39b03a30702c 100644 --- a/arch/arm/dts/dragonboard410c-uboot.dtsi +++ b/arch/arm/dts/dragonboard410c-uboot.dtsi @@ -5,6 +5,9 @@ * (C) Copyright 2015 Mateusz Kulikowski */ +#include +#include + / { smem { @@ -42,14 +45,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..693c0e5efcc4 100644 --- a/arch/arm/dts/dragonboard820c-uboot.dtsi +++ b/arch/arm/dts/dragonboard820c-uboot.dtsi @@ -5,6 +5,9 @@ * (C) Copyright 2017 Jorge Ramirez-Ortiz */ +#include +#include + / { smem { bootph-all; @@ -30,15 +33,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.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 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"; From patchwork Wed Nov 8 16:20:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 742239 Delivered-To: patch@linaro.org Received: by 2002:ab3:760f:0:b0:23f:8cfb:5ad7 with SMTP id q15csp479723lte; Wed, 8 Nov 2023 08:22:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeIQKtLhOWMfzZN7wQyXM59NEbKWhw1OlHWtrvJbMDBzPpkFckXSv+zI0ltIE+k+YYnoNF X-Received: by 2002:a05:6402:1e8e:b0:540:c989:fcdd with SMTP id f14-20020a0564021e8e00b00540c989fcddmr2156087edf.11.1699460529775; Wed, 08 Nov 2023 08:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699460529; cv=none; d=google.com; s=arc-20160816; b=MLWNe7Fa7M860fxtq4qnHX5DHfeFVK+gPFTiyxP1imQHfLA4PZDrGkomAApALxnULl g8jj/+pAShoVJjIN1Im38AytpHrlD/RK1C1XUlkMDFtCdGug0YHSF3ncSHW8ilYQJEOi /9lojxb7y8/C9CzOlNko3qGo6MRyYgmOmfYexzR4lVP+LgFMGZDJFtyVy+PvUDHt52sD vI2e/OEM2ZnBLtTb2X6i9ipkhvkKtNXnK4yZcDIyoKD4h2Q82dPXGrL8sXI53fBlHoIY 7tP3SAqj/4rmKHKMhIMf1o5VGFmUabf80KuznePLhuVbCBQ0gBvroRAA41iRr1EwgSip MmpQ== 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=fwxL8YeGurbYpusfu29GmdyWIfsaMFjKpG1zHju8o5Q=; fh=i7Y9asrausL8i9nH7n7DTaWvEmliXkHtoWPkbew9DMg=; b=jhfVoCnO0IZXGxylKxsTx/45dzpJvHE547jq+kGd0PHILFGUwWqE2Sr+s/ApMI/znp XcFt2LkfhjbAJolkX2o0M1MsxaY7SmjBbAjV35hTXw9XpOr3dxDpnFhbM5pomRzxgja3 27OKUHO1nFmtJVw7le/cgg3dd6i8HW+VLHbCa8wrczscQaJwWddtkhBn91/5AAfeh9te uFbnTYap5fqBPF4dd86/jT9o2pnTEawGpNrh2Oa09mm8RWH4zgEn2FQxptWPCg4bnyLY l9kTiWnvzxyic+Ta1JZFklpVSyx28dLgyq4z3o5RyYNRUNm80D8yBrl3ZDGKMxxoN71a Rjuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nnZ8moLR; 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 c26-20020a50f61a000000b0054340960069si6265152edn.500.2023.11.08.08.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:22:09 -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=nnZ8moLR; 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 1E6FD8716E; Wed, 8 Nov 2023 17:21:14 +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="nnZ8moLR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8041D87677; Wed, 8 Nov 2023 17:21:11 +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 672BD8716E for ; Wed, 8 Nov 2023 17:21:06 +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-2c50906f941so101754701fa.2 for ; Wed, 08 Nov 2023 08:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699460466; x=1700065266; 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=fwxL8YeGurbYpusfu29GmdyWIfsaMFjKpG1zHju8o5Q=; b=nnZ8moLRqDKdprvp8lSAWB3dgv2cS0JTi0Jg8+WtGEb+GFQdRyPZ3dG0wB8fvZHtRO lPIaBhe3KXCCbB7kcHVqCXiXoZIZ9tl6ZE0uVgtX8GHjl50Syv/gxiMoylo7S0IOGs7S qImb3jdtPGNWnkabdQSno71v+mRpcpqaZ1qVd7kM7solSIaZTDjLzoh95ySsLn5XeeLi kAoLkGQ6wj0wJtY939QDNLwpTuMV74o5i8TwnKQJ+9Rd8l5QfRATIwLHEigvk9QWyoES VWCFXccp81A5wOyGvVa2dfVG51YoKwDRG9JAf4ND/cQvdEXYJYkVA4wouohXkRgQT0vE 3ubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699460466; x=1700065266; 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=fwxL8YeGurbYpusfu29GmdyWIfsaMFjKpG1zHju8o5Q=; b=fvgWrmq0mzjXPUUcP/g+4OV9DrlKyTF24RYYJ4/U9bHr+BaVOxAC7Urehu0mIrsNmg vYkVIIUBKFPAt9+uNC16eOlFD+ViQyY2ITI5367uwFkdyEFnx7cgauSQBnb8JDQxgY7C GgeyjAzVnum6CmiF2mobRtQFX5AA/hnc4GuQ+C9lXSqCeCzHlYcz7+zcl/r5bgp03vwk se2PQtpErRAOABJWqjLNjT3GXFCUrdd1V9jrVWnTE/6RhEHIxyCQExNnqUpkFjqWDQm7 C9+KphoU5fiO5N71a02Ki8uZpwUGKk+nt6okpElcs4//5DWLeRKPBsESDvkpPp+9yqvX ZQrQ== X-Gm-Message-State: AOJu0Yxw9GpipMKpMrhOUGLI7PtwtVj8gevxY7sr+L/qCd9/C+MtcwMS 2kIJ0tRVj73bxand97XhApvSAg== X-Received: by 2002:a05:6512:1325:b0:507:cb04:59d4 with SMTP id x37-20020a056512132500b00507cb0459d4mr1786914lfu.8.1699460465662; Wed, 08 Nov 2023 08:21:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:21:05 -0800 (PST) From: Caleb Connolly Date: Wed, 08 Nov 2023 16:20:56 +0000 Subject: [PATCH v2 4/5] spmi: msm: fix register range names MIME-Version: 1.0 Message-Id: <20231108-b4-qcom-dt-compat-v2-4-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=4848; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=q6xTsMEPs6plLVOY9RnmsZVWcCm+LITA36IHatLfYW0=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhlTvrTlx3n37HXecrlozgdfR+TN3BUvirWumCoEGGzdlX H7M+vhfRykLgyAHg6yYIov4iWWWTWsv22tsX3ABZg4rE8gQBi5OAZiIkA3DPwOehTGnRORevjry vff4Pu5KjhWT7OcULSlYcoNDQnCfoB7DL+agl56Cm8+33Z/ecF2Qq3K7RdrqFYxvXFhaDn/V2vJ jnRwA 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 cd5d890e9a45..9aa3b99d8660 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 Wed Nov 8 16:20:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 742240 Delivered-To: patch@linaro.org Received: by 2002:ab3:760f:0:b0:23f:8cfb:5ad7 with SMTP id q15csp479900lte; Wed, 8 Nov 2023 08:22:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHS8I+8L5xOHQ2wSuuJYgVgQNhfXtrCvg+RVeE6GUAXp82RCNABhBIRIGeZl69LEGfp3SPQ X-Received: by 2002:a50:9e49:0:b0:543:4fdb:de84 with SMTP id z67-20020a509e49000000b005434fdbde84mr1944650ede.7.1699460542899; Wed, 08 Nov 2023 08:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699460542; cv=none; d=google.com; s=arc-20160816; b=K/NX/Mpgo59rf14X/B0tMmEZz9bIb7vut0WIMKTIfQ+5ncUs+iYTaBGpB78Dk6ZvFS x+uSI7rIMWC+GvRCLqiGmWRSPhCoP546lHMRBaJe/jgS041tpe7hDOVAD5rgXWkoEudf JhtBfAguIBW2ZcOBBwa8yOnaK/C4YbUSYt3bN0fMZ0RMat0+2oTHBvY15Q5HktLnHBmX ly7+FVCDKN4kNJd0of71Fp3LWdArN3nXIiULKB+d05aG1BfkFSEIQnBu7iOxRZ4+WBAh g7pxSGWrMVSSjz3qAEXUSrYx7mXd8dE1XGBogdBSjRnI5xxkGH90B9MfiQZsoNZWps4X +c1A== 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=018DhIg4oU2avzPOOIk9IL8QILD9VZBX7XSKEIBDpeg=; fh=i7Y9asrausL8i9nH7n7DTaWvEmliXkHtoWPkbew9DMg=; b=vUYvIZZIVcyeJUf6LTZx9ptfqGv7Le57Ch58MC2+nSeZernfRiQW/6CcECN2N180y3 wF1rAp2DsRoiSwaTGIrB8uJHG2XwdKpA9ZVH+6F/S2gVG5By1hNUrvoXVj+Bi66+Lbv1 4QNtWAarQsEh5cl8uVNo6RI9+H9Dh55ef+fgmCmzIiT2dJSpNPUzkOK6JHrOVGYjh28w F4/Q/zu9uuhyrKmFxWAom4NT9sg4vdQkLRuyc+hT15MMQqzZF8teiJuxH1Ld6VCqeM0g oTy5J6IdPyrlns9b4qwW1VmHnTNbTEcKAc0Ab26jm4vNt/ISp8RH584JRs17lp/7x5VF 6YCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PeplDznr; 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 r17-20020a05640251d100b0053dbb8a0740si6518326edd.417.2023.11.08.08.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:22:22 -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=PeplDznr; 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 4F45C87677; Wed, 8 Nov 2023 17:21:15 +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="PeplDznr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B7BE887702; Wed, 8 Nov 2023 17:21:12 +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-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) (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 621B78755B for ; Wed, 8 Nov 2023 17:21: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=caleb.connolly@linaro.org Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-507a62d4788so9670691e87.0 for ; Wed, 08 Nov 2023 08:21:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699460466; x=1700065266; 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=018DhIg4oU2avzPOOIk9IL8QILD9VZBX7XSKEIBDpeg=; b=PeplDznr4B8dqmYjOppuCIlSwv3SZLYaTWq6xAyAJgERRTvWyIcbXmBCPBgVeQIjDU 56YTXt4UPDUek5qXif31IwaUnZjPTrHfclaaU6mAa1bD6h72R0V3oCFeub7QSKPGGGHY S+yN6UzoPYZIZWHD5jsAWpbtB7PfKM0N9PXAfKJGw8oi+bfGjlrtoPUXc9mzRzkdjhSi G9IlMsvxuDD85fkr6gcDgg3OvRlEETBQoZtr2w7IG+W/rQuQQ1rxg31xv81g3MS//PTS Q+bLM+UUlrWgCU+t8QdP3cnYZLQtG07WXb6aMV3bx5r3tHTvRez+SnkkFYv93V81YLUZ t7SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699460466; x=1700065266; 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=018DhIg4oU2avzPOOIk9IL8QILD9VZBX7XSKEIBDpeg=; b=a4ZXQDbUBajL7QCWYsWEmiltMov3qAGpVvQyB81XAdBInmTvsw1UZbZv+uQcVUYFjY m/ALxmdhSPS1gTzVnrjPYECFg26R2W/O2yWmHUYGVQ13KB2aqeq/IQAQsejjE397ceGK 4qV8vy9ZvakAZ7hhbIeflYCP41gVp8ZubhvFQgapejBtfgY+m9mZ/WtCmvw2UWv6zAr5 4C5qdzmeT4JaOR2MQN5OBj1dcfmQNnrZCTiRiwqI/39jvbN3NSPrzU446Tlbhl1PxhVy 0Vvo9e3KAUWIOYjvzqqzg4MtslN0TskFNE/9StETKW5RVWcC7zTeoDnT7sckqdfklz0W ZXiw== X-Gm-Message-State: AOJu0YxdYAGQvUBhdybpSy8IolhPz4BcExsXuiDHgLjjsiMogfP/EWi4 qYkfplCbv+v0LHcEKTQtPFNVuQ== X-Received: by 2002:ac2:4a81:0:b0:507:a33f:135d with SMTP id l1-20020ac24a81000000b00507a33f135dmr1786038lfp.4.1699460466635; Wed, 08 Nov 2023 08:21:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:21:06 -0800 (PST) From: Caleb Connolly Date: Wed, 08 Nov 2023 16:20:57 +0000 Subject: [PATCH v2 5/5] pmic: qcom: dont use dev_read_addr to get USID MIME-Version: 1.0 Message-Id: <20231108-b4-qcom-dt-compat-v2-5-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=1388; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=5K5TojjS22iKoGc3mT5WWQT3H8v2KeEZTGL2lkHxY9A=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhlTvrTktc8Q/+927cYjNynlZ9cRJRdJCVybyb9r5onLuy sVbzV4kdZSyMAhyMMiKKbKIn1hm2bT2sr3G9gUXYOawMoEMYeDiFICJdG5hZJj3fEfPgnm6JyNa i75Ii86SVvxiqn6patIrtQbnO1k2M7kY/icbHd6S98L5fpUYf9+eOea2d9dknN5Tc2bC0rBGjQK tJA4A 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; }