From patchwork Tue Nov 28 16:30:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 747827 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp3934591wru; Tue, 28 Nov 2023 08:31:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUaJR4E8yGrrG+qWeWw8j151C5Wo538FhSSWFiXmusdKcwlQCgvsxDpfEVp4KCeNX+Sdbw X-Received: by 2002:a17:90a:1944:b0:27d:c95:b0ad with SMTP id 4-20020a17090a194400b0027d0c95b0admr14806613pjh.21.1701189072914; Tue, 28 Nov 2023 08:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701189072; cv=none; d=google.com; s=arc-20160816; b=jrX46/AHTFEGq/NJIk0OxSZJ8mipSi6WKwpFKdNhzwq83La/0TLwsxo9EP2OE2xmha w9aXfugOR1mP/FVfKYLba8VB7lkqst25UR1unly6B/3M9ls7LxcAcgBvBodfOXWerJEk 63qHQdTVBVy3IZAW3Cc46rfBh2HY1YwYRkgOBI5bSoSaXHwhh8AiLJcZx13FwLi6hHGX ER+JEYgxvs78aRyDVRbRuC0cV3bIVpkQH1zGUjtW7XzyqItOo0W4OTQR7fSlm0r9Ghqw xRvA9GTJBivXszmpQ9RxI4sntgv/T/ttBecQkmSjadvZ2Q/h+sRhl4yzGnmyz+M95TCK 8Kfw== 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=ZD3xWJFTddk3OTmdBUhNqHlWq/BUIyH8Xi/jMrAbFW8=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=z/JtRaLdItjTBKT7KA+kkVyWnReMKOG8BrZfcBjZgYSUxVwXoLvtvsUvhNytrD42xH xB7zELDN0EzbJhBj85U/fgcgysqEzG7qvX3LsmZETXnlHyXEF8OXyoRYRyV7XPj6DZCb C7HT7enI65mgjrpmcQL02WdTIQc2jI3CmDV2lrWdoUgccoHqeEKDa57sexARheyW4eX2 egiC4EYwiE19sMfRFyiyHs4aPrKcykiWM9uU8Us1bKqJlnfOB1k1uP2LQRKq8t8hXYSG GHF19KNKBMV62ej55RR0HysG7tUNp2wewnUlzHb6SYPmuvXl0CdaaUSrKhc2UzL62pQF H1dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yRQZ1AMM; 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 k2-20020a170902ce0200b001bdc10170casi13140354plg.36.2023.11.28.08.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:31:12 -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=yRQZ1AMM; 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 449A387759; Tue, 28 Nov 2023 17:30: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="yRQZ1AMM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B42B8776E; Tue, 28 Nov 2023 17:30:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 9504D87741 for ; Tue, 28 Nov 2023 17:30: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-x329.google.com with SMTP id 5b1f17b1804b1-40b27b498c3so45367695e9.0 for ; Tue, 28 Nov 2023 08:30:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701189051; x=1701793851; 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=ZD3xWJFTddk3OTmdBUhNqHlWq/BUIyH8Xi/jMrAbFW8=; b=yRQZ1AMM7I/Z/dVIMxE7IF4yi28FuyJhSSu0nWjfd2wFu6S/5a5BlnfXQAXf6m7tK8 n9Mm3eQC5LB0+PFm6boL/McHf0QV3gqQGdoYKVmwT3t5jwgfa9sAOYARTU3DWQNOEPw6 xRp1Kprqkun5yFukC8+PG9JxKzY+LndKZfN9+nK4MbLi6Eo9wKnxQE2BEtw4H3W5O20N wF7CAKbNLifHbmoZxUjtXy+pyxWLku9m/ZGUFxYc8cALVy4eC/M12Crse+gQxdykh4L/ ndkrLHuFn+GT3Yi79T/2jdFseYE+jLLcrNm0M/BzUOaLwClztN1/iIyU4ke/mX6pLD56 qfpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701189051; x=1701793851; 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=ZD3xWJFTddk3OTmdBUhNqHlWq/BUIyH8Xi/jMrAbFW8=; b=j6+9JW/AZ5J+TsXE8YT5w7tc6QPCaDfOV5W6oKya7buHtsDTOZmYlma8co2zi2ZQQA PY2lBFRgRl+8qC0GP6jt4eQsWilWd+Kug6xkLLzJ/PoKLKwp5z0Gb2h3hHJ5AivEq81u PUCHdZUMSFfdJAD9raIMpi+VL0oAhE+ESEfwIn5eJBLi+583tFZZMqntLZN3AUqBeFAl yeTP7Z6GCHEQSh65SY143DF762bsXK/srPhzy1izMbU88nlcZxHnB26Qo7WXnBUR1vfA J2H73ixnp821pgOXUCp66pujniT4lxgaEkAuBkMWqhB0eQ/Ku8zi7AO9+/OPyImPz3BI j2CA== X-Gm-Message-State: AOJu0YzXG+t8Pm/08Y8I4JGc+DEsE6Ec72+oB7UNa2yEoHH4iRQejyNJ xT0D1hb7NYfBP9494qmDKmcwKNWx/zjWhx5X/XLJww== X-Received: by 2002:a05:600c:1c11:b0:405:3dbc:8823 with SMTP id j17-20020a05600c1c1100b004053dbc8823mr13277768wms.12.1701189050693; Tue, 28 Nov 2023 08:30:50 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id d21-20020adf9b95000000b003316debbde4sm15530041wrc.48.2023.11.28.08.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:30:50 -0800 (PST) From: Caleb Connolly Date: Tue, 28 Nov 2023 16:30:25 +0000 Subject: [PATCH v4 1/5] gpio: qcom_pmic: fix silent dev_read_addr downcast MIME-Version: 1.0 Message-Id: <20231128-b4-qcom-dt-compat-v4-1-949d0982d1de@linaro.org> References: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@linaro.org> In-Reply-To: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@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=1576; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=Ow6e+BYI9LfPmrbAV1SHSrFbCMy8//JMJxsRN55OU2Q=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ00e3Gp84Y+ddkG9n5r14XdlcxY3LGbFYpp5TGfZ9uT xNgyDbtKGVhEORgkBVTZBE/scyyae1le43tCy7AzGFlAhnCwMUpABOZM4XhN+sC0ec278qjONWy FHx+/RBY8+qyHOM65pc707dfZ1+q+5iRYWuC3twz+85GRgs0akltCI/g/7bZ6YuM97ItuYylF9l 4AwE= 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. Reviewed-by: Sumit Garg 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 Tue Nov 28 16:30:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 747828 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp3934772wru; Tue, 28 Nov 2023 08:31:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFl6O+jqFNhHjYqkbg22J8pUsAYBo/pfU9xv7CnM1D5AREOYgL/Uq2HxqZoZ+3G555QdfeK X-Received: by 2002:a05:6a20:4427:b0:18b:5100:4aac with SMTP id ce39-20020a056a20442700b0018b51004aacmr18031132pzb.13.1701189086343; Tue, 28 Nov 2023 08:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701189086; cv=none; d=google.com; s=arc-20160816; b=hy3YCxXZVRvSIJrI0ai3euMwxYn86XmzAzKLBfZ9ughYFw7TWhHN03/cp2G08fdi3Y AeFJ/vsHzDLWsxJYxkyItsUnbDl13qQ6Wz+VAOF+s6e3jOPErDSW5T20xW+RWREP062Y p+lqezbHTNHAiJJ14hxW4NaPdySccH+dR0NSdgDHpQIVJt1fnEabUlpuDEN7mBsRBb8N 7iJwTAD7KQhMEWbKNlS20X3rBxfAK+GdEm8XuMXYEV9oJbGgM1+88JUrTkEH7x+wWaoV 1OC/++X53uLNKLjM4z7NmgDf0mjgUlUnKsvY0UzhLk0HhxGekIV19Qksrjh3yJWdLYL5 T4TQ== 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=uTX5VdfvFUR6RZAYqZZFAoVUM6WUycNK4i3pDc8PUrU=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=W3acc2XDZvm2t59eaRsbSKYkPQPbdVrn9zTiBcw190nbBLu6uZVlxbVervRtUQ35L6 QaQDK2pPYmjUO9X2UP1kkVqiIQNx9gdDC3KcN6BKI/ph18dRfXOO/0MJzfcg6puDl39T 7HoAPAm/LgEQVA1V+AqivoNNkO3jbkpQZsYkfiKWzBjFU0lz43IDgRCToAFPzOxlfZyQ t9lEeIiybG8C95epCI+grBgoApVRgXn1lMFw269oBbypxK8tuch1r3dvxVCv56OqEaln LqiM3A5ibrutxEH9Sxkdmi4g5gQEsLr+HHuzW/+q+oABlr5j6cj6FoNSJtyd3pXdxlUp iajw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DvHi2jZC; 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 p4-20020a056a000b4400b006cd94e0c112si3978262pfo.285.2023.11.28.08.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:31:26 -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=DvHi2jZC; 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 C2948876DE; Tue, 28 Nov 2023 17:30: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="DvHi2jZC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 717148776E; Tue, 28 Nov 2023 17:30: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-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 AACDB876DE for ; Tue, 28 Nov 2023 17:30:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4079ed65582so41185355e9.1 for ; Tue, 28 Nov 2023 08:30:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701189052; x=1701793852; 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=uTX5VdfvFUR6RZAYqZZFAoVUM6WUycNK4i3pDc8PUrU=; b=DvHi2jZCUvYwCuZ4dncTB2KSkoXtFIIA3+hbHTMcHy7OdsByMd+BZG0EmVsx32WWNJ Tvwxbl+/WuAuXy4R8k8UJqqxoQI63+3twItedvx00aODuiLtDhryzwnIzjy1AoxwVSCe H5NSZE/096zuF2V2lW9/M6wwktm3ulOlJo5IN+Xia/3ubb4kkxJMUZV58FB5ddbzFaSD X25GICA1eJc3eV2Ag71Gonh/0fotlP9VAFzBNNHVvdweh9ov88uUDlwcGL7j+DD2pEuO s+fNboWQFXu9/3OEHoVaCFdRwKwgp85bY3044Avzkp/HsdLARrEXahkqD/Iq8a2kHK8F Wy8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701189052; x=1701793852; 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=uTX5VdfvFUR6RZAYqZZFAoVUM6WUycNK4i3pDc8PUrU=; b=udIbcd71GuZ6BmMWC7GVUz80QzYEMr/UtbnNbyPDOV7IlrCzVqe077nvmPTnVOrO4W 0mmhSDJ5xXIUzSUz7ylRCsRG4k22yV/X6sA6p74fgpNNHqhpD938nFjLoDCWjCVw+CHv j+zQQ2ak8Ok0QPnGJiO0TCKPAhhPcs613xUmEyuVv6sGuZiBZSE9FVpFk+mhO5KtA57H oPEiVHgX2/UxLWgEdsPaZry95NDE7nZ4utfvWW4fxQZk5ldBBTTUfFB9BFe5gRkQ35vP 9qkrDm6Twdtr1IM6qy+yV3jPQZvcEVI2dtA5CFSKZTWyMjopOR9yrVUIUdQzNwO2d8s+ ZfEw== X-Gm-Message-State: AOJu0YzXHnWZt+zMJbSHq9KQVhbN3+2eviMrEBk8+HDB4IrQFQ3vieHT eMRB8sCKu74LKZODxXuhMGtv/grgF+Dt5HzKusATjQ== X-Received: by 2002:adf:fd48:0:b0:332:e9f7:9a99 with SMTP id h8-20020adffd48000000b00332e9f79a99mr10212034wrs.43.1701189051641; Tue, 28 Nov 2023 08:30:51 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id d21-20020adf9b95000000b003316debbde4sm15530041wrc.48.2023.11.28.08.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:30:51 -0800 (PST) From: Caleb Connolly Date: Tue, 28 Nov 2023 16:30:26 +0000 Subject: [PATCH v4 2/5] gpio: qcom_pmic: rework pwrkey driver into a button driver MIME-Version: 1.0 Message-Id: <20231128-b4-qcom-dt-compat-v4-2-949d0982d1de@linaro.org> References: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@linaro.org> In-Reply-To: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@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=24763; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=7gudyc4fFNRsyG5AngzUuRd0UnpNiz987zmcnOuJ5tU=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ00e0iR88tUJkdcKVpXaKGdLfKqtMT72pc27iwYBpfB ++6+Ye+dpSyMAhyMMiKKbKIn1hm2bT2sr3G9gUXYOawMoEMYeDiFICJvDjN8L/O2Emt+v+ap10n ixKOR7JUCz/ktW7clLR21m/WL+fWCPUyMsxYJXf7tm/qncbTHQ93/Zof97/rkwCLVfShnLw0ful +pzIA 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 ++-- doc/device-tree-bindings/gpio/pm8916_gpio.txt | 48 ------- 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 -------------- 20 files changed, 269 insertions(+), 306 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/doc/device-tree-bindings/gpio/pm8916_gpio.txt b/doc/device-tree-bindings/gpio/pm8916_gpio.txt deleted file mode 100644 index 58185b833524..000000000000 --- a/doc/device-tree-bindings/gpio/pm8916_gpio.txt +++ /dev/null @@ -1,48 +0,0 @@ -Driver for part of pm8916 PMIC - gpio and power/reset keys - -This device should be child of SPMI pmic. - -1) GPIO driver - -Required properties: -- compatible: "qcom,pm8916-gpio" -- reg: peripheral ID, size of register block -- gpio-controller -- gpio-count: number of GPIOs -- #gpio-cells: 2 - -Optional properties: -- gpio-bank-name: name of bank (as default "pm8916" is used) - -Example: - -pmic_gpios: gpios@c000 { - compatible = "qcom,pm8916-gpio"; - reg = <0xc000 0x400>; - gpio-controller; - gpio-count = <4>; - #gpio-cells = <2>; - gpio-bank-name="pmic"; -}; - - -2) Power/Reset key driver - -Required properties: -- compatible: "qcom,pm8916-pwrkey" -- reg: peripheral ID, size of register block -- gpio-controller -- #gpio-cells: 2 - -Optional properties: -- gpio-bank-name: name of bank (as default "pm8916_key" is used) - - -Example: - -pmic_pon: pon@800 { - compatible = "qcom,pm8916-pwrkey"; - reg = <0x800 0x96>; - #gpio-cells = <2>; - gpio-controller; -}; 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 28 16:30:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 747829 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp3934949wru; Tue, 28 Nov 2023 08:31:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCKuPxnT3C2DtRpTGtmZHPqD0Env4ZYD84npie/CkSj/lVaXIyMEJHfxKp4AKAWOFFiTap X-Received: by 2002:a17:90b:3b90:b0:285:cc9c:74e7 with SMTP id pc16-20020a17090b3b9000b00285cc9c74e7mr7143026pjb.8.1701189105556; Tue, 28 Nov 2023 08:31:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701189105; cv=none; d=google.com; s=arc-20160816; b=osYdVKkzygtSXl9XSiiP1QwdoSEaO8aqhoskOrmfdOHlE8KVTWckWRKfdhtQ1jrHH/ jf7aHijCqCknjLAyORQBwZob1J3gKYXkvyYv2pVpLVQaiQOmiynrQszfUkngHAZPhezT DU+H6uV7MZqeksDE+AHIAtbgfhBQa0+EHY4hk4AFmeJ8WE0+XwdvkZFsHxHxz2ZuEROs Rh1/1bPr5J81vJzWIj4W4SaGAXC4Mp9Yt/2YLg62XO5blGvllpqnKfKQf7TcBeAbmLio nF0XL3F1KFoeogApHVtpzoyaQSqw5+rIonLxpb5oAlOSGQq6mFMXtlLu9DFt41/pM+Up MyJA== 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=4jQx3qy4oEoXbaaicwhgrHVKD/HjDDuA+Ik7RdHhjic=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=F0I9Y4o9DD9kRSx9fwPo4IlECZSQNMxWaAY+h+7+P7ocUhF8VaQaAETqA93DkRMefW 58E+UU3kCFySGJ2NExuKK4t13SKi7KDdCj62ccHN2BiIZGVRiXY8AUaPfLadsUCz2vw8 OedWIpUnGgx5k8zGX+OxrvIxH0mL/sWanZxKl8vgCW1UtCh8qlULutni6aFvliy1S5vY 46HfHeanj7pOmSpSdiy5/K+u84omXOHWNIrgO5lTxk+IBuu3dq0tWQ8NqAJMyRgPN4rk dX4NjNKWoKR/X1iUeX9ogsLkVjQMFlPVS+dQc8BgygxF47SKNlQZY7caLP71mnXEP9NX pluA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lhsLa1x9; 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 z17-20020a17090ab11100b0028511e48364si12215213pjq.176.2023.11.28.08.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:31:45 -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=lhsLa1x9; 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 3AD5887771; Tue, 28 Nov 2023 17:30: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="lhsLa1x9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8F9178776F; Tue, 28 Nov 2023 17:30: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-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 6627D87753 for ; Tue, 28 Nov 2023 17:30: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-x329.google.com with SMTP id 5b1f17b1804b1-40b4a8db331so10020455e9.3 for ; Tue, 28 Nov 2023 08:30:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701189052; x=1701793852; 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=4jQx3qy4oEoXbaaicwhgrHVKD/HjDDuA+Ik7RdHhjic=; b=lhsLa1x9C7Z/Ju6K95iRgnkYi6+GNb+wicYZXpU36jZy6lNhtpDs18PlYRTwJ2Tn7v PAdC0O+WzQN729pqke17Dd5+Pw8zHoAeZ/+3jY4xiwzPhKg49w91zQXoM1fb9CAwZjPx CQBGMcokH+Z9DDnMaoW+EYuTwJmKda5e5VPpCG4LppLQCtitcWMY/Kwn1YAFs+rwyqIi SG5TekXWyPfaRm2HhamsOnyMLwBv0hGt8UWLnL5RiNiRfGh80tBqhl3RAZIRel5Ev9sx IzLeA9PgC0i5kwK+nOLoN5Zw7VjZoffV2mS6eCOi66X9TzsHwWk1b0K/cMDcT91+dGwv 1alg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701189052; x=1701793852; 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=4jQx3qy4oEoXbaaicwhgrHVKD/HjDDuA+Ik7RdHhjic=; b=xEU/c10w1FHRO3OlKiUH8oJTb7GExBHqYEeYZDQExthD0OAeacE+yh1K1SwB7sy6eM H7Nlfdi5qm0ajp37M1lMOTTBSHTD/THX04QvoWxffJqJM5pCoEEAVoKLCqdQBzzdgEER 9jNqePg1yaGODHEz+MzUjjQDy1uYEmwzw/V9j8L58d7HpmHglbmqXUbcpVMkgKphSP7k DePd4kHpGHns0j8Iuz6HQvEc413wWlpeMxUxGDO1QzMagIunDzonyHa//yza5OTLSn46 j7N2llwKNyAuTurSDcBc6ToB8b9xfA5aqvK/cEAanT6mfELunCZbh0bkrFsP+pl/cO7C +ung== X-Gm-Message-State: AOJu0YzmRztDLGRJHrk9kRFx0eFbf15zimDSpGJWKxPAwTwliXULWbuA WAbCNXLliz7RcfyQKp2Mw2Et8SgNukQGk2eTO3a/Ow== X-Received: by 2002:adf:e352:0:b0:333:db9:47d2 with SMTP id n18-20020adfe352000000b003330db947d2mr1707911wrj.66.1701189052727; Tue, 28 Nov 2023 08:30:52 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id d21-20020adf9b95000000b003316debbde4sm15530041wrc.48.2023.11.28.08.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:30:52 -0800 (PST) From: Caleb Connolly Date: Tue, 28 Nov 2023 16:30:27 +0000 Subject: [PATCH v4 3/5] gpio: qcom_pmic: fix support for upstream DT MIME-Version: 1.0 Message-Id: <20231128-b4-qcom-dt-compat-v4-3-949d0982d1de@linaro.org> References: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@linaro.org> In-Reply-To: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@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=4023; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=RkiyMNLxdULm4u53lAkdye3P6jXX+KjMEsZQXapXVyA=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ00e1qKu3/z8ydzBrbwrVHTaPp3f7cG9GaMc+Wf19VE Cil4v2+o5SFQZCDQVZMkUX8xDLLprWX7TW2L7gAM4eVCWQIAxenAEykdh/DX3HX6ZEb7bsZG+P1 JTYZPbjPu0n2ssXMk2zrnwSnbtx1dCYjw8qMJ43lB/UeFU9QEL2zVMans/nPP81/WW/2LdyZd1n 0yH0A 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..1adc6566a36d 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 = "pmic"; return 0; } static const struct udevice_id qcom_gpio_ids[] = { - { .compatible = "qcom,pm8916-gpio" }, - { .compatible = "qcom,pm8994-gpio" }, /* 22 GPIO's */ - { .compatible = "qcom,pm8998-gpio" }, - { .compatible = "qcom,pms405-gpio" }, + { .compatible = "qcom,pm8916-gpio", }, + { .compatible = "qcom,pm8994-gpio", }, + { .compatible = "qcom,pm8998-gpio", }, + { .compatible = "qcom,pms405-gpio", }, { } }; From patchwork Tue Nov 28 16:30:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 747830 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp3935139wru; Tue, 28 Nov 2023 08:32:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfRQdwPJVMXpJqJIO/Z1bUvNLtKGE0K6hUGwvtCORyM+O/D12YX+Gy3gKWcqeoc9gL6xyU X-Received: by 2002:a05:6a20:8403:b0:18a:d7a8:5e5a with SMTP id c3-20020a056a20840300b0018ad7a85e5amr25472587pzd.58.1701189124375; Tue, 28 Nov 2023 08:32:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701189124; cv=none; d=google.com; s=arc-20160816; b=Q8g/dfENPnkYyQuA9Pg9Nqn3n7Fa6KaVvU7ztmagamfcYpuPflqBqGq85+ztFWg0Ox /6WZzIoB32ktrLGM5fs++GiWidYw5NVNAo8ebkHgKI8rrsUk4uhzIbIvZkzWHV+oJTt5 BNp9voNyfPul0SOCJxw4tIDsK8YjfiGIgoKz5m6BgjHFmws+TppSSDujxx1eGTo4HVk1 llGnceLRxJxHm8A93VREnTIbzqQyesOmgzFz2h/+EC1H4oKnIOVc78RKYRzUThwh9iZx HNZQuHtk8z11og5uWtdIe3ClOsz28RZRVFHfM7e9O+h1utEhXMq1XSOhWeZaFfJccJ5m EZ5g== 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=FdtUBSDF6w50SH691fL4oUvk9mLbWDRKwBTBsQpRvM8=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=RTgVE45Zaw7WjsU2mTxfIuBrfdxq2BW1ZQIVgMqaiGS1Ugicy8xcc5UkZETC+kQbvU 3amYLWabsW14v99VJ9lrGqEjJFz41HxA9JNfei3b7qOgQ/BCV1veuzQUAkEoKU7r6DYe AByyYsr7TvRkF2FZE5oXfhjlQ8GQBlFHjGVIPumDzYkAUds3zzq7IxwwKBAX7i98Pj/L MbjhHRT+0/8HSikzEBVCQhWk5m5wNSNKG7I9N6LeoiNrkCyzWN6w8aS0qKdhIT/Petjj AolDpTKn0unbaiFa7ZehWDB0z1iKNvj3/oSKABBKBbtqVyr+J3CM7xn1f04CroU3OhRa Kq5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B8dvHOZR; 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 y24-20020a056a001c9800b006cbfe3c5c60si8923387pfw.404.2023.11.28.08.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:32:04 -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=B8dvHOZR; 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 9FB2587779; Tue, 28 Nov 2023 17:30: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="B8dvHOZR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 96CDB87762; Tue, 28 Nov 2023 17:30:57 +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-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 0650A86F02 for ; Tue, 28 Nov 2023 17:30: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=caleb.connolly@linaro.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4079ed65471so45194065e9.1 for ; Tue, 28 Nov 2023 08:30:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701189054; x=1701793854; 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=FdtUBSDF6w50SH691fL4oUvk9mLbWDRKwBTBsQpRvM8=; b=B8dvHOZR7bE7vBQqB9Cnf9CeQ/ym0QHsk4gr4VV/6FTYGLG3JSweZr9C4v0IiFJFdt Qz1m9Qae/69nttRQ53DOtPhBA8catINxKtbHCuC1LNtgNnjUDyWrhi9CCLKJyYFpycbx 5ZeR+0Zkps43s0Sf2hFLe/jXcmYyXsIBVIn0epQBAYls91xTlJGCq7MtJsrG4O0bNPph n6LMImHwrmYAo3P5b+TecAA2Oenp/mn9w0xqjXNnvVQ7u1IKzdnltEXhprHvJ2tYYsBw eGHqbegbcCGGL+WwqFjlWlo71Z6jlMVfEeCESlR8bUEEhOgYsr7nG25rjU0srmCJPXCC MQRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701189054; x=1701793854; 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=FdtUBSDF6w50SH691fL4oUvk9mLbWDRKwBTBsQpRvM8=; b=vImBSaf6wrW2jfWTH7naKbnDVPTvXZFN0GO+2fSQKN3KV64u4NYu1zybeRGC1/YfXe 1/h1YzDsYHn+Eyr5HZi2/wLxjGlyO1Dkah2+h87Rr5iFTP0mQHUf4U27zQHG13RZxA54 zqrVVTAI+epp4Bs7d8xHpqdCih2UggizQOT3Q/d69bbn72MBeYlfPDo4cVJEanPEha3/ htSamC1v2Q7x9IKdICvO+Tu51idlQcD4T/vP8aIZannLG4mNpFFC/z1yWhuFDRO4znZ9 iJjTq/MVFLIolaV6wwFR1/xqzdwak1DPL3WhNKFvmXDg2ObDwrRh8rsONDwbKHEmjco7 i3NQ== X-Gm-Message-State: AOJu0YzS51sKNTFoN6Ipmb+rpNF+5JBNhiz+mr81YD3foxsf1tsMxEyV PGvge6Bgygx4CFZ9hz2ogNBmMmT5z8uO94LBStNJ5w== X-Received: by 2002:a05:6000:11c5:b0:32f:dca6:534d with SMTP id i5-20020a05600011c500b0032fdca6534dmr12868898wrx.47.1701189054304; Tue, 28 Nov 2023 08:30:54 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id d21-20020adf9b95000000b003316debbde4sm15530041wrc.48.2023.11.28.08.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:30:53 -0800 (PST) From: Caleb Connolly Date: Tue, 28 Nov 2023 16:30:28 +0000 Subject: [PATCH v4 4/5] spmi: msm: fix register range names MIME-Version: 1.0 Message-Id: <20231128-b4-qcom-dt-compat-v4-4-949d0982d1de@linaro.org> References: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@linaro.org> In-Reply-To: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@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=6713; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=ngCQCcWA79jZqTpSLCdIzQaxdPsoQIWp6rrKFzavTy8=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ00e3HzjFZNix8Oi1tbc9jqRtTJ038McHge7i3467ze /bmRUls6ShlYRDkYJAVU2QRP7HMsmntZXuN7QsuwMxhZQIZwsDFKQAT4bzP8D+yXmL7hvz8033s X3mbOx+vrxKKsucTiY5mWvxw37lTv2UY/gocVtt8v0n0XXVI653Qvivr/W/2MeTvfsGmdjLzwbF Og38A 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/qcs404-evb.dts | 7 +++-- arch/arm/dts/sdm845.dtsi | 2 +- doc/device-tree-bindings/spmi/spmi-msm.txt | 26 ----------------- drivers/spmi/spmi-msm.c | 46 ++++++++++++------------------ 4 files changed, 23 insertions(+), 58 deletions(-) diff --git a/arch/arm/dts/qcs404-evb.dts b/arch/arm/dts/qcs404-evb.dts index 3bb580ba4e17..cf41e5a33dbe 100644 --- a/arch/arm/dts/qcs404-evb.dts +++ b/arch/arm/dts/qcs404-evb.dts @@ -362,9 +362,10 @@ spmi@200f000 { compatible = "qcom,spmi-pmic-arb"; - reg = <0x200f000 0x1000 - 0x2400000 0x400000 - 0x2c00000 0x400000>; + reg = <0x200f000 0x001000>, + <0x2400000 0x800000>, + <0x2c00000 0x800000>; + reg-names = "core", "chnls", "obsrvr"; #address-cells = <0x1>; #size-cells = <0x1>; 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/doc/device-tree-bindings/spmi/spmi-msm.txt b/doc/device-tree-bindings/spmi/spmi-msm.txt deleted file mode 100644 index ae47673b768b..000000000000 --- a/doc/device-tree-bindings/spmi/spmi-msm.txt +++ /dev/null @@ -1,26 +0,0 @@ -Qualcomm SPMI arbiter/bus driver - -This is bus driver for Qualcomm chips that use SPMI to communicate with PMICs. - -Required properties: -- compatible: "qcom,spmi-pmic-arb" -- reg: Register block adresses and sizes for various parts of device: - 1) PMIC arbiter channel mapping base (PMIC_ARB_REG_CHNLn) - 2) SPMI write command (master) registers (PMIC_ARB_CORE_SW_DEC_CHANNELS) - 3) SPMI read command (observer) registers (PMIC_ARB_CORE_REGISTERS_OBS) - -Optional properties (if not set by parent): -- #address-cells: 0x1 - childs slave ID address -- #size-cells: 0x1 - -All PMICs should be placed as a child nodes of bus arbiter. -Automatic detection of childs is currently not supported. - -Example: - -spmi@200f000 { - compatible = "qcom,spmi-pmic-arb"; - reg = <0x200f800 0x200 0x2400000 0x400000 0x2c00000 0x400000>; - #address-cells = <0x1>; - #size-cells = <0x1>; -}; diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index 27a035c0a595..5fe8a70abca7 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 channels */ 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 28 16:30:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 747831 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp3935307wru; Tue, 28 Nov 2023 08:32:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdzvBAKryeB00QtQhm9CZHaZO4q3M1mjptPQVNL8lGtG3hx48yi8mvUn6eW8d1PO4PiWd9 X-Received: by 2002:a17:90a:f184:b0:285:55ae:8f9f with SMTP id bv4-20020a17090af18400b0028555ae8f9fmr14091546pjb.42.1701189139441; Tue, 28 Nov 2023 08:32:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701189139; cv=none; d=google.com; s=arc-20160816; b=gimz4aFmO4D9tLilY3Vgz6eaf5RqLlQ/fzpB7UJC/flqlSQB2dHI208uGtuH1s7uTl x/qCUv5bslgl8wlp59FIemZhhWvOAGR7yWqYVE3tBowtB0+vR6oY4sHKVnBOIijVOASl wHkv11vKEG4GF9GrXJie0AGCZuRrVf5P3G9GOEEHrtoZFw9QL5p7EW2Fj+4uzr9lBCGk jgsTB0xsGZbNrskrl/3vufnK5AQ1bOKRi2qvOhwGZJB9dnbIZ6LMEGvVnMJKDPm7qORJ oHo4zKjCaa74tmPnyTPShn+y97kb99orzB35xpeTiiQajTYlxBJsVf7oGSWEjo9Woa5g JkkQ== 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=gXQphteMBD3U0pnY+yrATKZ588HOaJO4A0kylMV0sOA=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=yniwnOaPyCfuRrJjqqSuncjPE6Ua0/YwNt+Qf0o/BffrObLheU8GQUXCLImfECXPVo oBSAK64jpcaoZswwhPC+Q+j11h7AEFY+w8WckxoVIu5zBeZwPFwb23GJ+QPDKk6B1gKR ZqvdGz7oZo1Yf0bKlTyOf+yd5zVRHXdDGHWSIhN9kv23e/byIjM9GIEQ6R/8bKPBY5LZ iLtpc45ljAtKdTDXPQvec0Jmt1Or0Yql/9Ju+jvB/xSQ2XVTjT4e4XJnsrul8BteqaDI cKF2ge736Q4C5M00iwALJKVL5mT4vmul701qq49GwUXLjtBInvLriKWG+7X2XBt2gUBf dgww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jt0u7OK3; 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 w9-20020a170902e88900b001cfb4caefa8si7967741plg.644.2023.11.28.08.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:32:19 -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=jt0u7OK3; 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 29BE887782; Tue, 28 Nov 2023 17:31:00 +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="jt0u7OK3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 595EF86F02; Tue, 28 Nov 2023 17:30:58 +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-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 2E8F7876DE for ; Tue, 28 Nov 2023 17:30: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=caleb.connolly@linaro.org Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-332e3ad436cso3630577f8f.3 for ; Tue, 28 Nov 2023 08:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701189055; x=1701793855; 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=gXQphteMBD3U0pnY+yrATKZ588HOaJO4A0kylMV0sOA=; b=jt0u7OK36Pg0dZFuIn9T/j9r6kJidoBeqz2F+aWBf4btKGzK5SxAwJazB4Vc+zSAo+ XIETXn3ablv7i9cTvm0vgin345o04kEhCg6SlJ7yJF1BQwRay6FQ1Nj6mQQklnb6LI7I eFLjJOSAteS6R0e7Yk4V1WrXQ9XELySIw+lKBvNMWP90Yt1w/IJQkP4Ku0MOyhnOBZkU rtulO/TcU4cjpLWd9ojAWDOiMMe4V3p2Ac96QAWvaMrUl0hOwlT9ymmbhmPDBp5aod2J 5LC0kFHmiYQlCsrzDko+ij33RblXPZrtoDPV46YC2qIs6e7bqFUKheXuEwS7GZwDHEqO Ot+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701189055; x=1701793855; 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=gXQphteMBD3U0pnY+yrATKZ588HOaJO4A0kylMV0sOA=; b=SoWeG6zG0EE3O5HiYvGE1KTYpc8YwPcNX1MOVdVppd3nOtSg6SFVitJAma2YBOy7PL pTy1qiy9UzSSK7+siIvvkvHlrB/gDdDKSRhld2JKYpwyHuQwf2y3L3lMZ5UUN6BPqsnv +6mUiihSc8g2HLOiY1UR7RQkW/FJXyEa12GoHQwiSyripNPVn8YwKVVzGbc31ZgKeNlM 9s/QCaShwInJy4i7eTcQXx2fzS4pR+SE7NWs88/SFO/YvahRt/Kx62jbmTlwmLOuPYHL /73C6HjMZCBG5nOl0AKAIiedY85Y3BgThbQFLY4S7Wv6zSvnjgh8RALzVjwB4ZcebokN USHA== X-Gm-Message-State: AOJu0YznSqonKH1G8L30/VZdpRYkY7kSOsc9ymqCyRaotEACoafKis2m oogOa5WKd6vA/yX/7nqTWfvoGQcOR+YeRCsqtsAqbQ== X-Received: by 2002:adf:fcd1:0:b0:333:129f:58a4 with SMTP id f17-20020adffcd1000000b00333129f58a4mr1038501wrs.59.1701189055406; Tue, 28 Nov 2023 08:30:55 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id d21-20020adf9b95000000b003316debbde4sm15530041wrc.48.2023.11.28.08.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:30:54 -0800 (PST) From: Caleb Connolly Date: Tue, 28 Nov 2023 16:30:29 +0000 Subject: [PATCH v4 5/5] pmic: qcom: dont use dev_read_addr to get USID MIME-Version: 1.0 Message-Id: <20231128-b4-qcom-dt-compat-v4-5-949d0982d1de@linaro.org> References: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@linaro.org> In-Reply-To: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@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=5331; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=GoC7TMy12LCcUreseBruRwwooFPfjXYG46ZgiFDMnn4=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ00R2X11Re+XU9hFNiguGXqo6agMrczXWtT+e3K0VdX e37OjC0o5SFQZCDQVZMkUX8xDLLprWX7TW2L7gAM4eVCWQIAxenAEwkUI7hv4fzzurJO62Ubzzb /ztv6Xd7HY63L5niT2jaCMy2CfpvMoPhD+97jbk33nF/3nR10+r8mrD4h9NcWC/niTxMOVj3dMI tTQEA 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 --- doc/device-tree-bindings/pmic/qcom,spmi-pmic.txt | 94 ------------------------ drivers/power/pmic/pmic_qcom.c | 13 +++- 2 files changed, 10 insertions(+), 97 deletions(-) diff --git a/doc/device-tree-bindings/pmic/qcom,spmi-pmic.txt b/doc/device-tree-bindings/pmic/qcom,spmi-pmic.txt deleted file mode 100644 index eb78e3ae7703..000000000000 --- a/doc/device-tree-bindings/pmic/qcom,spmi-pmic.txt +++ /dev/null @@ -1,94 +0,0 @@ - Qualcomm SPMI PMICs multi-function device bindings - -The Qualcomm SPMI series presently includes PM8941, PM8841 and PMA8084 -PMICs. These PMICs use a QPNP scheme through SPMI interface. -QPNP is effectively a partitioning scheme for dividing the SPMI extended -register space up into logical pieces, and set of fixed register -locations/definitions within these regions, with some of these regions -specifically used for interrupt handling. - -The QPNP PMICs are used with the Qualcomm Snapdragon series SoCs, and are -interfaced to the chip via the SPMI (System Power Management Interface) bus. -Support for multiple independent functions are implemented by splitting the -16-bit SPMI slave address space into 256 smaller fixed-size regions, 256 bytes -each. A function can consume one or more of these fixed-size register regions. - -Required properties: -- compatible: Should contain one of: - "qcom,pm660", - "qcom,pm660l", - "qcom,pm7325", - "qcom,pm8004", - "qcom,pm8005", - "qcom,pm8019", - "qcom,pm8028", - "qcom,pm8110", - "qcom,pm8150", - "qcom,pm8150b", - "qcom,pm8150c", - "qcom,pm8150l", - "qcom,pm8226", - "qcom,pm8350c", - "qcom,pm8841", - "qcom,pm8901", - "qcom,pm8909", - "qcom,pm8916", - "qcom,pm8941", - "qcom,pm8950", - "qcom,pm8953", - "qcom,pm8994", - "qcom,pm8998", - "qcom,pma8084", - "qcom,pmd9635", - "qcom,pmi8950", - "qcom,pmi8962", - "qcom,pmi8994", - "qcom,pmi8998", - "qcom,pmk8002", - "qcom,pmk8350", - "qcom,pmr735a", - "qcom,smb2351", - or generalized "qcom,spmi-pmic". -- reg: Specifies the SPMI USID slave address for this device. - For more information see: - Documentation/devicetree/bindings/spmi/spmi.yaml - -Required properties for peripheral child nodes: -- compatible: Should contain "qcom,xxx", where "xxx" is a peripheral name. - -Optional properties for peripheral child nodes: -- interrupts: Interrupts are specified as a 4-tuple. For more information - see: - Documentation/devicetree/bindings/spmi/qcom,spmi-pmic-arb.yaml -- interrupt-names: Corresponding interrupt name to the interrupts property - -Each child node of SPMI slave id represents a function of the PMIC. In the -example below the rtc device node represents a peripheral of pm8941 -SID = 0. The regulator device node represents a peripheral of pm8941 SID = 1. - -Example: - - spmi { - compatible = "qcom,spmi-pmic-arb"; - - pm8941@0 { - compatible = "qcom,pm8941", "qcom,spmi-pmic"; - reg = <0x0 SPMI_USID>; - - rtc { - compatible = "qcom,rtc"; - interrupts = <0x0 0x61 0x1 IRQ_TYPE_EDGE_RISING>; - interrupt-names = "alarm"; - }; - }; - - pm8941@1 { - compatible = "qcom,pm8941", "qcom,spmi-pmic"; - reg = <0x1 SPMI_USID>; - - regulator { - compatible = "qcom,regulator"; - regulator-name = "8941_boost"; - }; - }; - }; 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; }