From patchwork Thu Nov 30 20:22: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: 748511 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1103297wrn; Thu, 30 Nov 2023 12:22:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEiydxgR/5tBFG5ADbRlGUYPGHxWExUrDthjISCD5n5JfdW8+n+EMax5MxhSPTVldW68xd X-Received: by 2002:a05:6a20:548e:b0:18c:8d0f:a794 with SMTP id i14-20020a056a20548e00b0018c8d0fa794mr16801036pzk.19.1701375776680; Thu, 30 Nov 2023 12:22:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375776; cv=none; d=google.com; s=arc-20160816; b=I/jVWCk8Sh85j18qDqbyFzJ5YDWvosShfR5J8lxMnCp7hoDp4cFAXva2kk+Lo2lVLf yfE/TSchoCaafyoLnOVAinNhpYPLGFftai8x1YMdT/747W5KVlfvYOG8wLUoi/ElVMbr w1pYML2Vu6K1R8hCrN5WeOk5Hnn3HIWTmYFKSyKu5/51kG+iXxDZq4V9q9MqOIMcvBA1 2wDirvaIJcPCo/ED2LCuV5EdkHAo89tpOZpiM0WHavkdBCKbLW28WsZz7Mpawvi4ADIC 16FFeC+SsJXENP08uuzyZLo7Ff2FcI1t5Utk8T6hONPcrWJaoUhyT7/TrG/9aqjW6wQA 2GcQ== 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=h5xrnR+voR0lzTU912ok/GgXW3KeYZlPIjqgluxKI2NhHT6Bs66KZSHZhGhfF3kuN4 YxiHgKphxF2aEPGWrOG4IFykyKBKopy8azyy4UpMDWEG8re2cLR2YyC0khBhOn1UzTFT ReKosSYkDAvy5qzshN644rv4qG+XGOvLQSMHhPIw5o+hYSr+f5Q5IsT1KByHAka24E/N l17YM9nra6N/Stavsjgm6ytElUsukxqDGlK/5Cxx1FYQ52VOhzM9cirhW5ydjDyRBA/O v0r2QKwZGmre9VIUdZW/qGw7qrW6TVXpef3LK4XKvGE8tTuy8AB6nfXzPUyo+jjIT6Cz TzYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AWicY+bQ; 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 fi5-20020a056a00398500b006cddefd2031si1976208pfb.37.2023.11.30.12.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:56 -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=AWicY+bQ; 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 4E4F4876F1; Thu, 30 Nov 2023 21:22:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="AWicY+bQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF4E6876F1; Thu, 30 Nov 2023 21:22:50 +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-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 C6C2A876B0 for ; Thu, 30 Nov 2023 21:22:48 +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-x32a.google.com with SMTP id 5b1f17b1804b1-40838915cecso13046095e9.2 for ; Thu, 30 Nov 2023 12:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375768; x=1701980568; 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=AWicY+bQHNxxzWPUF8jZ8gALpupdVkUYIsWz82zEbuj0ZFEjY9W+APvhc/X+6E6tY2 oI+BO+cE/J66DJoofUaDOZZze739uoE7KN79rZ99NNR2KptYBxX/5jvZOan25WDg0rya amSl9mUrOd1dRhRB1O/ITVrDEm9HkPEQBbKSSt6pzheMGipgnJySMi2d1CZ7JrC3lt3F JbeKPqHDOb2xQujEPtzAaokk3a/ZUzuwrrUbJsQRWMZpFKNJBTldubVrLt51OU3HYRrd cVz0NUz//LZ+i+pcVEJaWbXoE0+7zwBOU5yQLARX6+ftySPWO98wZzWUCLObZHOtQK58 zPjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375768; x=1701980568; 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=pnkRs6LLI6j90G+bgRSti1X0cykhXnapOxH/ocPRRQa97Nf9CzLjSVvw0RRZPof/x1 d6IUkFf0VWrG1PyKtwJW+2YCq8ByW/+PbsKMpNWXOablWGBVEBBE0+p/6ek25qjiGbO2 Kj7rtXH6ENetra77bGpYxAZhUT3ztVu4tXxhFZ+z0ezJpoiiluzUFJvwfQnBmfjUSQ/g 9itAOzaSsnL2h34qFqhsB1wEwVuIfyEXbUpuqg57e+cTzKZqLaaepTKiKc9XPSU4Eldl NCeds4um7PGutxO7EXClUn5XZmYM6aAWNlujDNDFeN1R6EzTXJl6z+6Cr5X2teyRB/e0 gBZw== X-Gm-Message-State: AOJu0YzrKngqZgTEmtT4on6RSIlHQAY0gHOM930VoPjLtmgjs8HAHWSZ eEHz3EpIJXJAIITEvWA2UdiduQ== X-Received: by 2002:a7b:ce90:0:b0:40b:5e59:da7e with SMTP id q16-20020a7bce90000000b0040b5e59da7emr32233wmj.145.1701375768312; Thu, 30 Nov 2023 12:22:48 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:47 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:25 +0000 Subject: [PATCH v5 1/9] gpio: qcom_pmic: fix silent dev_read_addr downcast MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-1-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=1576; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=Ow6e+BYI9LfPmrbAV1SHSrFbCMy8//JMJxsRN55OU2Q=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM96I7Il6oJIRYW8yyjbxm571qqdiKlym9+V/33T2tH zDJcKl7RykLgyAHg6yYIov4iWWWTWsv22tsX3ABZg4rE8gQBi5OAZhIWjIjw9Rf688+miActOxT 7tejDUejriw/PnGb8NntCTzlmiZVX2Yx/K+9c79zrsdpuVmKLE4bQ0LlHhbFy35/+16Mf+OLnMQ SjSAA 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 Reviewed-by: Neil Armstrong --- 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 Thu Nov 30 20:22: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: 748513 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1103483wrn; Thu, 30 Nov 2023 12:23:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZdCUjE2j4zyxGECxkPHd/XEa0AO890/cIAlMGuW/gayVraZ4g9FtxXYWHyyViDp5wKtil X-Received: by 2002:a17:903:1d2:b0:1d0:231f:5e38 with SMTP id e18-20020a17090301d200b001d0231f5e38mr6079347plh.38.1701375804421; Thu, 30 Nov 2023 12:23:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375804; cv=none; d=google.com; s=arc-20160816; b=oKnuHO78qouJxoVqx9k8I0rG1hprZAzIFQKSRtlhEkROfr+uDlQAUkLgO+J2N0rA2j NWjugHJZNAStsw+ZQkDGYE8mnQj/YT3b3JLNWxMe41J3Dpbj0eHPOeB4CqfNC36OCIPM +1Zbr/xGaDux5ugiOLlrORK3jEcysv9dOSkmKk+daAuEpgOWJa4ISHEpXsO7P1d+79P5 7UISaJliXHNs19CAZmb91BtUPE68+YDfctY/7cxp61Ex8Z5pyZmrNSYdLI8KdAwAl64G uuLIsof7N9cBUAOy/XYzai2TuQs+GhtZ9s3Oy7II/cypy7Hdh3t0nafRU5nwZDODsCbM zw+Q== 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=zgcoUT+Zc4QgmXmNW9cHlA6q8iu1ITaaahJMciZTmO0=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=U/xQk4kgXBcNrOaRGYrw/IMU+rWrPIde8i/ddCmmeQACFC0bNzqMPLRS8Vn5r3RzOP +JnVN0HN+A/fl5p7pE0Bvftbnw+NfW7h5N+4QO1rQFHlnCUhXFZqtxbcxxdFRlxVrXBG GsqEKC6ya0+rVY7gdx/jaQzqbT/7WCbIIJHhaa+71pWgNb+qvw8WHzBHe4wuh1FS/mD9 24OTISEdvMDXhz/E0OR5geRZbuJRG9vQrU/wr6RZq9nxLYQ2eXOiAl4QoSdESaHYgeuw m6d+BQiaViFclYYNfQG4jHhqksdiDX+4ySVyPSrVleZcpwnrXDR+lI6ZzlSe5G1RUMqM +q3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FKCZ6/Lu"; 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 k5-20020a170902760500b001d04391825dsi1110482pll.611.2023.11.30.12.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:23: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="FKCZ6/Lu"; 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 4B9778770A; Thu, 30 Nov 2023 21:22: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="FKCZ6/Lu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE26B87707; Thu, 30 Nov 2023 21:22:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) (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 0CD60876C2 for ; Thu, 30 Nov 2023 21:22:50 +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-x129.google.com with SMTP id 2adb3069b0e04-50bc36725bbso1978822e87.2 for ; Thu, 30 Nov 2023 12:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375769; x=1701980569; 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=zgcoUT+Zc4QgmXmNW9cHlA6q8iu1ITaaahJMciZTmO0=; b=FKCZ6/Lu8ZIAjdE6dmMISinzm+A12zIqqovaHJqb7/dXMLuyiWuUqs5IkAh45yAEwd GTuX4rXo+HedkiHKx06W48bVLhTaAiINTyDBclFnjYGqELoInsn6grDG/lgWAOVQuO4y 1NMg4WpHVJ5x/u1Se1nEbiAhR711B4oWqIO+hmW2z49GbsCr/rEtF7joUzMqchTxBUMR X9NgVrReO2hw14buyo7WCDVcWrSzfDTmYBdrIp5se+0/x0z+76xenHRWIvZ2za+wH0/Q TvcqGlqJUVOT5J6muEn35nOl11LCjcDLp2Jik6gKVb8SYHP83+7j/TKvuD0V6ccxEWoG 7Sgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375769; x=1701980569; 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=zgcoUT+Zc4QgmXmNW9cHlA6q8iu1ITaaahJMciZTmO0=; b=INkFLnYHDzk5upvl6tHxWHr2Uljlj2uhGm+E/AX1/H9xob8T1JiZqqdUd5yR+Z4WSP GMLDWaEPg9T9DPpukuNBuoX77mv8dof1rbtZI6p1WwPWnxYsu6jHBchXKR8Zobchyyk2 sRWgDN+Zw0Fpud/u+o8ryIIHqdvXKUVy/Bi8N7O98n7SX3xNn7ISQevwvkwkr8taNN0z O7t8MIGmpbvKNjJHNIkeTbbr81N+5TYhAAfTnPyBOHOpcSe/2qLhttdjzmofbZ9PLpoF iXukdaChy2NxC1SQIcU9lLtkCI/+GdISVgVzbocNN3OseBN+zOtCTJEC0DTo5Wtc9NqX SUIg== X-Gm-Message-State: AOJu0Yzvq2EQpriccvWyLCrHWQBz3HaZBVhFIJAAKTUqqjtjlkEpsPRn BLa21AKSfO8nPbF8Zmnkg1/PVg== X-Received: by 2002:ac2:54a7:0:b0:50b:d763:fe50 with SMTP id w7-20020ac254a7000000b0050bd763fe50mr76406lfk.107.1701375769251; Thu, 30 Nov 2023 12:22:49 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:48 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:26 +0000 Subject: [PATCH v5 2/9] button: qcom-pmic: introduce Qualcomm PMIC button driver MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-2-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=6578; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=MBLaL/Ij2NF87CUXfrcUkkQ4TJVPsOTTWwizWJlKvX4=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM96KTp6w/NmWZ78xHc/fP987ouBDtFuTlLnK181SF7 slCw4/LO0pZGAQ5GGTFFFnETyyzbFp72V5j+4ILMHNYmUCGMHBxCsBEZu1n+MP568qdjecSrn/a fnDrpeW7Jy+65fLH+Yb7t63L/Otkjml3Mvwv8rm39tavBiGbaYsvsk0o1fup6Tj5n6J19QnzgOs 8O00KAA== 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 Qualcomm PMICs include a "pon" function which handles two buttons, the power button and "resin" button (usually volume down). Introduce a new driver following upstream Linux DT to enable these and map them to Enter and Down respectively to enable use in boot menus. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- MAINTAINERS | 1 + drivers/button/Kconfig | 9 +++ drivers/button/Makefile | 1 + drivers/button/button-qcom-pmic.c | 165 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 176 insertions(+) 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/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), +}; From patchwork Thu Nov 30 20:22: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: 748514 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1103607wrn; Thu, 30 Nov 2023 12:23:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFU1D7Jo4MuwmTEI66TbbQSVxNtax00q5eVssBQ2LUjnWu4lAWtvXbOF0Agzgp5ZGXV7aRJ X-Received: by 2002:a05:6a20:9385:b0:18c:19ab:d2e5 with SMTP id x5-20020a056a20938500b0018c19abd2e5mr23053658pzh.33.1701375819047; Thu, 30 Nov 2023 12:23:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375819; cv=none; d=google.com; s=arc-20160816; b=QIqy3TUfdCfXovI3uGHx0Z0lJDgjsg1F+cEzn4EBf56PKu/W4riJxRQ5dy24M96nlK UungGq5AXUQ8vuZ/esqwn3ZXDUBbUCLBRPCItJuBJqq8kIENHnvS8nhk9FnTKauuXqxY uT9ralVKK9Jo1U+I8NcT7v2xuvdMAodwMZt14LUfQLoVId+ep+Arl+Acy2nvRr8Tcnqo xKc03kEzjaC1upE5UMniGDjRTiJYS9OUlnhmdn8w+oAapPiFMN74zH68xhfCH402ZTkZ 9FFklV8LJEmZMMe19eV7cRgCjEPLwJSikYHOAmUTwnndN3kXs7yH/kLBzhvxT5T/3h5B yFEw== 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=0w+DCrtEuIUYJ2fnE/WrbX3JeH1Hp7bKSGISGtzF7mY=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=TIm7iyBhHIlT9UK7Gx3vqVDy1L0NqOZyfa0JF8KNG/u9Wc46O3Iq8ZJcAKbMnPG9TP NimtpRLiS5HXXwH1D5f+lmWqCJj/Fk479YusFKutxaYqA7m6/z5oLkM7kpUaqIrdV6Lc Lb/Hq9aGy9pSojPV3Th3OndxvpdUOjYY53aXLs5O7T86S4/0ckU6D7LeBL88z5DHpVNX pA5nVvhPDgFefYig+lKTwl29d3y5DEu1rcZK/O2CyjbzBDIN3MjRGsk/Vw7aY3k/6gq5 hqPCMWlO5svDELXdhxkq0cMwvxMsFfZTmTYxnb+sPKErzErh0k1UuDxawC3cmvrgHVi8 QgYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZVcU7TJS; 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 o21-20020a056a0015d500b006cde1cef718si1958497pfu.322.2023.11.30.12.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:23:39 -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=ZVcU7TJS; 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 B52A987712; Thu, 30 Nov 2023 21:22: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="ZVcU7TJS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E808F8770A; Thu, 30 Nov 2023 21:22:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 B16D8876B0 for ; Thu, 30 Nov 2023 21:22:50 +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-x331.google.com with SMTP id 5b1f17b1804b1-40b57fa7a85so8407395e9.1 for ; Thu, 30 Nov 2023 12:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375770; x=1701980570; 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=0w+DCrtEuIUYJ2fnE/WrbX3JeH1Hp7bKSGISGtzF7mY=; b=ZVcU7TJSfNhwXMR4Mrhl2asraPJqrNva2HtVpv+3XGysC9+ZkHkmQvdF5XRYc6B6aP D+UkJnaZ0HrrLWij4ANBDIlCfNDC/nnJWLeHfBz99MwGSywVNhxAmgGEVDg1QL2CyFGn Iku/uDOmSNWD78qG3yRvZuDVhVTXTvgL4J++eUc5r4gdIfCt1qq2oJziWlmnPTGyC3j5 ZpMhPTL5YChq1MWaIzer9Sfj3JtDD3jmDe/bOShDN0nMX2IofsXJ2PLV03kh2Qz73mgj NxEaYZ0AuzZC2UtO1sphIIMmoDwxh9pbnylAw/8xODUN6vhyuNWXLFSAKOak0DVIYq+8 e2/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375770; x=1701980570; 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=0w+DCrtEuIUYJ2fnE/WrbX3JeH1Hp7bKSGISGtzF7mY=; b=aNXVCSeA2SFnvaQyMIVtO6C3DWSjTVH0JNMtcD5g79hMWlQuuSCi6qaENpQNoBYWQe vtihg53LA+81ljSBnQFbTFi0shRW0jiY121va9nvfRnt3/avE+Glh1j/IM9ZuQ8QLieG to5816dIKS7c9mD9iToRa46aRC6Z69F3+0l04P97CI0Yrkn7N4GQ56ElxD55b+sWHfI5 i9AQV+kTnClBKsVrIFPmyidbLAuWC0pDtGjPQzM0/Pb7wD/uXahoZCRca0VwLANg/e9X LUYIBNkDlEcJedlahvU6ZKZR9IqKCQt5g11xAsXK8/ek4k3CBec+8s9SYcUGTvFwG56s vsDA== X-Gm-Message-State: AOJu0Yxm1i2CsTRUKzphUw2npJ2h9utbrTKvvA16rO8nHLn9ObVp/H1z nytuDFyUY/OYsLzIDCh1i8BMcQ== X-Received: by 2002:a05:600c:3511:b0:40b:5e1f:c382 with SMTP id h17-20020a05600c351100b0040b5e1fc382mr33475wmq.24.1701375770195; Thu, 30 Nov 2023 12:22:50 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:49 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:27 +0000 Subject: [PATCH v5 3/9] mach-snapdragon: switch to PMIC button driver MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-3-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=13165; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=3vVA5fWR/xqYPXh1LCy36OWhPSOyrFDMxssL+OxQe3w=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM96KzTkd+6DSskWz+oulcmnGPa69U4t81H5aqWhksC /3gtpe7o5SFQZCDQVZMkUX8xDLLprWX7TW2L7gAM4eVCWQIAxenAEykOIeRYZNeDIOV162PfSsO 5/P8Yvtl3BOVu0SwXSVoX2eS+lTlXQz/g+auct/+hif7a++8+L+PE1x73r657FBtnSnNU7H6seW HNgA= 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 PMIC button driver is a much better representation of the hardware here, adjust the boards to use upstream DT and the PMIC button driver instead of exposing the buttons as GPIOs and relying on the GPIO-button driver. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- 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 +++++---------- 13 files changed, 91 insertions(+), 153 deletions(-) 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"); } From patchwork Thu Nov 30 20:22: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: 748515 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1103729wrn; Thu, 30 Nov 2023 12:23:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IH803epspxiaAEyq7tCg3DflG1gAmV9qilL6HNVaWQW6cqmA+3re28R93Tcj2xdb5SvH343 X-Received: by 2002:a17:903:11d1:b0:1b8:90bd:d157 with SMTP id q17-20020a17090311d100b001b890bdd157mr28452224plh.26.1701375832070; Thu, 30 Nov 2023 12:23:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375832; cv=none; d=google.com; s=arc-20160816; b=N7HRzVxig6SHOe33khVxi9RbJoKxFdGGUDqaVaVFtSeMItbEuNkDQ1yb4t7w5+vJrc B2cUG/ukkxFoE+KKeNRXsybDK4FcNrbZ/zg49n6i9KTNQEuBYNh0bWN2Zv8+H8LLQkRB vcdtUatKCo1Q4FkqEvR1BYbto5SwOVryrNxb5LtAwNDVcVhbkSxgdbVyuC1P8rYTz5Ye 2RnoI22FcrDp+M24ISCl9NhqoFRudX+45QULShfkdxjQ7R7Lx7J0aDk9q4t4IQDuJmih uMyI7VbWT8Spx9AtOWS5BjYbOPc9ORL8VVI54HFQPfkNqmNTWt3g8AIPp0xjCdAuh/pv RO6A== 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=gNQvmCLiBayJJsb5GwMY9zHRvD0ru7zzWcRupzkcjp4=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=cOugw2/Im6F+vJzK5Jh3x7vzOpr4abzGeXejiRQ0irkPf7CPPcCAE+yw63FwQSGkAX CKUVidSeyZvp1fshELSC+UJkt+ooH0dNUo8/ZGxKB4Nh1NO5xuNy/kXaRUvhfO4IaUWu gXltnbHXBFmss0ujl3lpxcAey4zodTb2010487v7/JpNCHeQ544EewyiTdnhxrUBJwuj Mg7IM356F7gx2yjHbohzwb0srA1QYeAFbv95ZfvUk08OEZ9au3TmAl6kjf7Rci/PKFSI FFg/0EzlVgiBvdqiwyukrMCogte5PGZolOF61ho50DswfgMrSFmDO39wNrGyS3DwdVpk i53Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PWkmmt3P; 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 p1-20020a1709028a8100b001cfbf5c0466si1787895plo.22.2023.11.30.12.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:23:52 -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=PWkmmt3P; 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 385ED87718; Thu, 30 Nov 2023 21:22:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PWkmmt3P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 65C4A87709; Thu, 30 Nov 2023 21:22:53 +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-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 6CA3087675 for ; Thu, 30 Nov 2023 21:22: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-x331.google.com with SMTP id 5b1f17b1804b1-40b2ddab817so13055555e9.3 for ; Thu, 30 Nov 2023 12:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375771; x=1701980571; 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=gNQvmCLiBayJJsb5GwMY9zHRvD0ru7zzWcRupzkcjp4=; b=PWkmmt3PveuHvzcQ9cXkXBRv1MfC3zlZ0JuwwRn49fBhMEOIIm62CgmqWHet9GJTz2 Px9o9PlpVEgLIGRVkB15/KXBzrw53khTssRLR2l1Euj+Hzxcwoi+4qWeagVc98LlDbPV p5D/6XhirT0vslyT4NI0RtN7UT1V2y1H/YW/izE+WIfLg2t756S3oAQmu4K4JZlNEcw0 PKnlSRbD5Mmr9pLuBJQ+S2D/CK/0d0E/dgLN9qljXn79Czh/9vjWdJdoC6nMQqfDdXLr nkhvMIX6Y/tpFv6SoCnfl/sWPdCMn2kw+siDaHCszuGU3eYoqdyOHsWwhv4CddFYg/bh P4mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375771; x=1701980571; 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=gNQvmCLiBayJJsb5GwMY9zHRvD0ru7zzWcRupzkcjp4=; b=M63AGHMMAVwD+w7y2Cjxynyg+/nzL7oFgJjsi9M/0LvV/dFYbnBn0FSRShigSmLOHm 3q7jMRLT1QFcFS27p/KXNSPc6W+piIajhCF6JVFMU+SL2UoFvDcfUaBpW0k1pLs6qEWv Pf1yoL+wCRMzPqs8g6XyjtDn0Rjxip8T9OA2zGaPtWjQmJUGhXjiJjjDO1FKUX6mn3qY PLY2gx4bqllT163edO5yCGDpOD6GXtD2A47g//aJuIi8uGpt59qwSypHeoMHKApb49bP vaCs8NISuxSzQfexg/8eK0Rcomtk8xET+L0EuZDM/QWKjlCJwUF2i54yfhPGqwiTXCXu PtAw== X-Gm-Message-State: AOJu0YzbTCXO3hzlw2NUFtqbT3nsARTE2SQaKkPoBIE+3k4WM1Tfq6bz TJEmBwn/km1o2mf42hnJedTzJA== X-Received: by 2002:a05:600c:16d4:b0:40b:5e59:daa5 with SMTP id l20-20020a05600c16d400b0040b5e59daa5mr40933wmn.184.1701375771011; Thu, 30 Nov 2023 12:22:51 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:50 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:28 +0000 Subject: [PATCH v5 4/9] gpio: qcom_pmic: drop pon GPIO driver MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-4-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=4105; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=zSKOl9ga1DLlbd+RdN4jSUxH38m8oKW4T7JK6ets4DM=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM92Lvy2W5N1Z2Fni3bP1gL/Rg2ZRUp8/fLdOiLrC8u q827Wx1RykLgyAHg6yYIov4iWWWTWsv22tsX3ABZg4rE8gQBi5OAZiIWCIjw97s+uafx04vmnPo 9Q7f+Z+4JzQEzEordnkdXvrZqePflHJGhk1zeNa0Hz/w+uOBD+kaJf6Pt7Q5Vn3xYwwpT00OM4g +9QQA 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 Remove the (now unused) GPIO driver for the power and resin buttons on the PMIC. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- drivers/gpio/Kconfig | 3 +- drivers/gpio/qcom_pmic_gpio.c | 104 ------------------------------------------ 2 files changed, 2 insertions(+), 105 deletions(-) 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 Thu Nov 30 20:22:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 748516 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1103842wrn; Thu, 30 Nov 2023 12:24:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkwG+ljiBrRhAyFFJuUmRnhnhlLKKUje0HCXF6amguibz/XgmXIQpNWekEO/h+eafot0VG X-Received: by 2002:a05:6a20:c189:b0:187:ce5a:2a87 with SMTP id bg9-20020a056a20c18900b00187ce5a2a87mr25247953pzb.12.1701375845713; Thu, 30 Nov 2023 12:24:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375845; cv=none; d=google.com; s=arc-20160816; b=TyiUNcVEuzFn7Mf9cPgP/KpRqbxnjkJPt7J6O+8B8bUUY1RVjckiqjJHFb1UfRgVZv riBLgl6hucXk9Kn16HENC4jVBmVbznyi7BVWevoaUXgyPNo6crgTBgNh5z2y7ZNI6SIY b0+DxDoDU18pVVI/MYlUcyce0M78lbHafKZjxaAVOk2nAgGLXMOdAPCxe+3Bo2XQl5G7 lLpPstqzqf8qKGzZquqaNTFFcWwKE87d9GBllQt6jCLMCz2c4WN29vdD2ODAMjsCw/U9 YzWvdTJ8QZom3t05jB8qUeh3leBbwpolAsa1zr7T1Xe1cY2eMSVq9zIwiuj5TfJQ8D/v TeDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=+LJakeFglSK5HTWJWr8yiQtiZQ8ZDLzW8xWntxzGnv4=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=kpnPF4NnqeI/+i7RHmblcnNOnmGjfb3y30EPLD/Goa/R+f6m6zH1/nKi+5U19ytsX1 t/9IkUT76JD62kMamNkfFlKsAZuOxv+cddnOgXGL+nbsy2J5KytFn3HEUyeb1OBcBIXE uGh/JWhrkemTE+uKuYs6uP99D2TYIFrSyTODlOCYvcr0OO03NaQahBOdzprIYbhJojfV R9xynFcTRFQGSeDZ/J4eWdF0hMFxiCavs7wf11wKPylKh0vgNHzFd4EZ4cdxYkVXq5ti r3/N6M6WvwnZrsBaSYnrCSsMrXoPAVdUDegN6Xa4LChhJzkHK1QfEcjy6Mnis+G5PaAS GF8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ga986KJw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id b21-20020a6567d5000000b005b96cbfacdesi1980494pgs.196.2023.11.30.12.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:24:05 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ga986KJw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAC118771E; Thu, 30 Nov 2023 21:22:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Ga986KJw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 99E188770B; Thu, 30 Nov 2023 21:22:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 564A9876F6 for ; Thu, 30 Nov 2023 21:22:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40b399a6529so16460185e9.1 for ; Thu, 30 Nov 2023 12:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375772; x=1701980572; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+LJakeFglSK5HTWJWr8yiQtiZQ8ZDLzW8xWntxzGnv4=; b=Ga986KJwMUmxPQBijFu0ekmu1KvLPTJ6a/n/WnLVB7WZXzwtX0Hh0X+ho1QtDz37bC GI8BmhBZflDt5g7T0hnmZpS3sVs3KMVLOSQ1nIBVGrMG3d9oU80csbpH9tGaM9O2rr8T 7T/ERF78zbnzc2s+qfpVNpzbvfbTozK0M18ADrmnGpjO5hXFBRfT2+iftLMVfx/HmqZI haNNt3oOR9kiv7ewiyPke4GwMqVOCqjQSEOpfm9OjozakVYWgzNx5MmqhuDoG3tZ89iF shf3dZxHZtcGpyw8wMPkbBF97STe//ZHPCK30g/cuxlCmJFSJW1aNKgteK2rRNknvkUb G+qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375772; x=1701980572; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+LJakeFglSK5HTWJWr8yiQtiZQ8ZDLzW8xWntxzGnv4=; b=mKbj6r5Qj78C7S3jZgPLSqRP1qBlXxvGphiFEoqnBBXwNGEKEmb5Ov+31OaU5+WWiQ yaAD1t5rIwY7OTII6LCFkwJbfnE35kHuxLVZeNsC1MU0m9VML3if2fKJvLdRBJrGX1Ng lmd5xo8L5i0Nt4xl3Y8cV7ANvnIdcof4vxGtLAZdAVoOWJK1vaKRc1WFoIhKPASizhdz 5eulA0CL4eQxUL7bqRKcLcgbXRoC/8B5ml++NLfO9gyAGqMD2sxczb2iP1OEQLOofkwr hFztyd4THmkAqEu2SAhJQKxE/pGVUgj3o/UlI8Rk40q1KLrCYwlxqHVg3HBo2qa3Zl8+ 1bow== X-Gm-Message-State: AOJu0YwbupqTpsG4kau8x5V7c+pRVNLjmFevPiBO84z/FIR+/zQWopBf 3eLcHu3fMu5KU37aTuWJKXip+w== X-Received: by 2002:a05:600c:5248:b0:40b:5e4a:234d with SMTP id fc8-20020a05600c524800b0040b5e4a234dmr43587wmb.79.1701375771871; Thu, 30 Nov 2023 12:22:51 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:51 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:29 +0000 Subject: [PATCH v5 5/9] gpio: qcom_pmic: support upstream DT MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-5-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=2187; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=ZRJaS/vffm1bIpnsc4l89aGGwKuzPhD3ry9Iqf7YtrE=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM92JNk+a8PrVSYaP3F0+2lgnqHP75FzgZFd2Yj+XFB NXWrDLrKGVhEORgkBVTZBE/scyyae1le43tCy7AzGFlAhnCwMUpABNRZGNk6Oz1yBS50JARarVv 05oCTe3328wuek22VPkb+iKzUUx+AcN/n4mbFs7/+tLw9p6DXyJ23zwu56yz9ka+6xQvFg6z8DM s4QA= X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Upstream uses the gpio-ranges property to define the number of GPIOs, support for parsing this when gpio-count is unspecified Additionally, drop the bank-name property as it isn't used in upstream, and we can just hardcode the bank name instead. Signed-off-by: Caleb Connolly --- drivers/gpio/qcom_pmic_gpio.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 7b83c67fa464..54f4dbd2b84e 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -245,23 +245,48 @@ static int qcom_gpio_probe(struct udevice *dev) return 0; } +/* + * Parse basic GPIO count specified via the gpio-ranges property + * as specified in Linux devicetrees + * Returns < 0 on error, otherwise gpio count + */ +static int qcom_gpio_of_parse_ranges(struct udevice *dev) +{ + int ret; + struct ofnode_phandle_args args; + + ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), "gpio-ranges", + NULL, 3, 0, &args); + if (ret) + return log_msg_ret("gpio-ranges", ret); + + return args.args[2]; +} + static int qcom_gpio_of_to_plat(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + int ret; uc_priv->gpio_count = dev_read_u32_default(dev, "gpio-count", 0); - uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); - if (uc_priv->bank_name == NULL) - uc_priv->bank_name = "qcom_pmic"; + if (!uc_priv->gpio_count) { + ret = qcom_gpio_of_parse_ranges(dev); + if (ret > 0) + uc_priv->gpio_count = ret; + else + return ret; + } + + uc_priv->bank_name = "pmic"; return 0; } static const struct udevice_id qcom_gpio_ids[] = { - { .compatible = "qcom,pm8916-gpio" }, - { .compatible = "qcom,pm8994-gpio" }, /* 22 GPIO's */ - { .compatible = "qcom,pm8998-gpio" }, - { .compatible = "qcom,pms405-gpio" }, + { .compatible = "qcom,pm8916-gpio", }, + { .compatible = "qcom,pm8994-gpio", }, + { .compatible = "qcom,pm8998-gpio", }, + { .compatible = "qcom,pms405-gpio", }, { } }; From patchwork Thu Nov 30 20:22:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 748518 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1104039wrn; Thu, 30 Nov 2023 12:24:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwTGggjaKSDsGp8yQuwHn+kqVtN2JeIoE1jfVID0oDYaHz3DkFKUDrm8ffhMvZnI99WQbU X-Received: by 2002:a92:c6ce:0:b0:35d:3dfc:3126 with SMTP id v14-20020a92c6ce000000b0035d3dfc3126mr3407818ilm.4.1701375874074; Thu, 30 Nov 2023 12:24:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375874; cv=none; d=google.com; s=arc-20160816; b=WUMhrzmw2E3VED/KlNwgOT+1AtbaKV7jBN1dpyLWDZT5VVVhkJsayzq21z2ZXqjPK8 LIrSUyceln/U8XD43nv6qfLn4cyZ0Q1hQAZqYpfX9YlATItgzKSUk3iPjP7klbcQ5t7t bjGpMngHvdlDhLafVeaGI9zAcHyPYTl3FxusFfPYE1mcc+abVkAcuWFR55x5R/e2O8q0 EagvKFIeDczPj8sfybfkTNd+u1Y/swV/5tFNGat+7VEqnpEYla2RL2pc9vyhYwi8YaPB z5rG2JaGfYbF1yWpl8OqjMAVcmmas4MmiKjOfNJUWyXvXqbiXdxL0ekjbkNgQwMtKa6L /hpg== 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=gf3cBmQyShJKbFA3Uv5FmlKa86lloNAaQHHFpz16qfM=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=qNKTZAiaM0KX5wIQvQ+eBg1E1ve7M9dQCGkFFmDHJJgbB0fIxFIo+frBYH/s/YDZ0I RoXIKX0ufT07LsEWb78U0dlblCyopI46i23ygVrkzu8jyMGNt2QFB1ibxUlvcQ24AMrV /LvQWOG5usE1xj/V0t3En5dedGURslvjSJSQfBC+rNaKMxkFSBzXz+kRavyrtJjH9DmI vSKWyB0u7FQwRUHPywk4oYJyFi9nZGn5bKChbc1ckrCK24yuRZTFc6dBIck0sdqmRXj7 0ZvvaUPnLwZFSG7yTFk4N/ll0RFlLxWQVERD/S1l0UctHdnj20rWmMW0Qf+Uw+51namq QwTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fMLI57S6; 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 126-20020a630084000000b005b106cd44d1si1879431pga.486.2023.11.30.12.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:24:34 -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=fMLI57S6; 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 A9A9987724; Thu, 30 Nov 2023 21:23:01 +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="fMLI57S6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F77587675; Thu, 30 Nov 2023 21:22: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-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 73C3587675 for ; Thu, 30 Nov 2023 21:22: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-x32f.google.com with SMTP id 5b1f17b1804b1-40b552deba0so14163795e9.1 for ; Thu, 30 Nov 2023 12:22:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375773; x=1701980573; 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=gf3cBmQyShJKbFA3Uv5FmlKa86lloNAaQHHFpz16qfM=; b=fMLI57S6ciXYH68c5Atrw1InU2h0daHsqLa5fsij6PbmCMKFcTkdvLDFvLrOjBBt8m Y/b9Yuw4efsbFQf2R6++mxD6DuC+df28yb1506kPotveOVNU5eeJLu/lA8oo41Fes3SP pKjUuFCCn9IELIMToOIh2uOH6vlBF40lajdghK18Fs/EaCJUDu651Q/i+HADat+PewFl M1FjuwwiXepGUZz1IkCM9Xmbj5PEAiHdkJ7I3F9mtwnH3PaFnmvi/YxgoZfrdtSYc5// ayIjSgk6UO6ZbWTpobUsbwdu431LCJLcPIAkJxSQUJnyd2Xvo+5z8frNaoIhlIygV4r2 bChQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375773; x=1701980573; 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=gf3cBmQyShJKbFA3Uv5FmlKa86lloNAaQHHFpz16qfM=; b=Qx2Wr3cfsB+i6Dau+NAfSoCZLpSLt0L7F2YF/Hq6iiklkMWCIc3q0i3OllZmt8lZ5I bbcWBtRVnrYAWRd8TACqQjqrFFYoRO0kz2DGMdC0GDzeXkunFpFgSy8RJ+OvdO6coysm uxZzq8mOuGLPvIQC8SeDWCfXS5M1LJY06OiCRMfaBFAu3YaYYRLFv2QJTQuNQnh1QfB9 U1gI+Dt3GXi4lhhhqYaNGtBFZSDRaR2ympiMkI7zz9lNxceEiQqY3DPmFl7qCEXpGtpY DYJ7haeCbhqnopx3avIcFq5ZGUUvEvf4j/5lhNTG25RG0yOS9qDj6Nosj2BXOFpcnzKc 6O4Q== X-Gm-Message-State: AOJu0Ywn+KiEn3IjH4dgdeEqOKwcMASXBSwa0mS/2AHdhBDbhmUg36K3 k7R8VpmmUwJGt7XOnGXYsVx7oA== X-Received: by 2002:a05:600c:a47:b0:40a:44c0:fd43 with SMTP id c7-20020a05600c0a4700b0040a44c0fd43mr43223wmq.17.1701375772924; Thu, 30 Nov 2023 12:22:52 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:52 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:30 +0000 Subject: [PATCH v5 6/9] dts: qcom: adjust pmic gpio to use upstream bindings MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-6-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=2221; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=nlJ/OYxMggVn4W/O03HUdzyvt07GEFCWbK6QOyRtWM4=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM92J/k5p8mjIbNv5QNZt7Z9eyrWs9NT+efa5i5rq2R oDz+IfPHaUsDIIcDLJiiiziJ5ZZNq29bK+xfcEFmDmsTCBDGLg4BWAiK1oYGbYw9sveif7BvunS 9wzDnZqru18fT7PP9A2ujNjg9J5rfhwjwzb/4/azldfdCZjwUWa2zErNKSqrD007WP1xbr+m9FG DoK8A 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 Use the upstream gpio-ranges property instead of gpio-count, and drop the bank-name property for Qualcomm boards. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- 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 +-- 4 files changed, 4 insertions(+), 7 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."; }; }; From patchwork Thu Nov 30 20:22:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 748517 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1103956wrn; Thu, 30 Nov 2023 12:24:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnnuCJYqLaK6eZ2bOotcpkTlUDNq2BDyAxOJjqwlA8Q7YRikQcfiwnZm4NBtrWQAtczBfa X-Received: by 2002:a17:902:be12:b0:1cf:9c44:62e with SMTP id r18-20020a170902be1200b001cf9c44062emr27269076pls.34.1701375860226; Thu, 30 Nov 2023 12:24:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375860; cv=none; d=google.com; s=arc-20160816; b=cmDolmulethRjc/0UeZxsE5dUUQqPy/i2lufh+dB5iG6Pob9TU9741ONrDOPVISE6N GlQlbFQKqthypCkZF0yz538Esg1UQF16IcF+htORb71AQOmICLly7VjMb9stKL1Nah9k 0/i5gNozXI+tgfEEywlmkg5LH6X8K1pFXyy6P0us6tgL2XbGG1LMluuk4ms8VLgl4Fo1 tvkYGHw6zicLyHTP+zfBZtnQewg/CEL7rkUDTyTrSSpZz0p/i3YO9rMaKuCvoU6sgRWh wWyPHNwMg7WjFQQZJ4IKz+vdwy3gu+wFQU2ilwZYxjSXBnaU3DBw9u1a0ZUcZ67rm+QV rhhA== 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=3hXZHxuecfif5wU/f4nXhH4eCzZfa91dmy97EKVy4RQ=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=z48K7LLJpkOOCPYRo8Icf2oj3bYw3V7TB20YW19lN3Ak+W2AK9e2NrEUUcBg1yFa8k S6ij1/5LaKtCyRiV8QR1TSo7sF9i3nmp8xDHCT84Y5xKCKFBTlRSjoeCRfQV44hhC8YT sUBi5WHhSFIXS3MfJ1uLCKMK5hf5/trXyP+KqiZ8DJPdQBuP9PHdIrHKRlfX2qfbi9ax SQzogzGoIOEVpx9OdZdwZr+dLlOQ4ld8L+pkqljFOLP3Nyv58WqTD1xafDMPzuIOt+D9 A+yNzB6I7DBn9goCcQBxuRQNDzv4nMUBcTG6IFb+honc7A1InbGc1VHCdjAUWRSPAE5f LnXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N81aTcTi; 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 u7-20020a170902bf4700b001cfa7f91403si1821351pls.183.2023.11.30.12.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:24:20 -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=N81aTcTi; 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 2FC74876FE; Thu, 30 Nov 2023 21:23:01 +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="N81aTcTi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 213438770B; Thu, 30 Nov 2023 21:22: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-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (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 33DA987709 for ; Thu, 30 Nov 2023 21:22:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-332e58d4219so866545f8f.0 for ; Thu, 30 Nov 2023 12:22:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375773; x=1701980573; 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=3hXZHxuecfif5wU/f4nXhH4eCzZfa91dmy97EKVy4RQ=; b=N81aTcTiY141CsFm4fQhi5E+RcFzTOJFv9hi4g7L4HchQ+zs2wPCuAqJddcX4u+OTe /SuLXM2pM5zRjm4OjzA/w0E4F5+dnQs9xBWHOZ9cG5hmzA9cKoWZj72ZZUPXpqSA15Dd JlHybAhIqRBp4QB85HO4KwgRwL2HBMz3HdqS8xYk0HgseYhTqN93zzhgfDyHkLtQFHwc hF+k1VmUHOKcO7VsHc5hq4jlcr7A8wtC42N4POweYmaPptBeTwcptXW66vWszPGs6k5r tPY3wicczM3x1AGUvEmTRzl+DnAvSs+fy86q2PieoA/7tSKMCokiSSvj4XlSj/TIc38h vkNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375773; x=1701980573; 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=3hXZHxuecfif5wU/f4nXhH4eCzZfa91dmy97EKVy4RQ=; b=CUvRdMy8mqNkyWq6lfUidX9B+9aV3uW38/vuWxGMah05D8QEg6wDKJhPEzYAum/sQA gwrxgF+j5IK7aHi1vAYsDQEGzAIqd03W2IKxZL7zCbvM+Nehsy5tySusJXOloxM1VD0b BQIVReqOE1oZfHgvUdaiwb9OAxP1oSpicLljeqO5h0iu8d3HcG+w0rC3LWLyYF6A6kCI YrrkIpozuvXfdKFmpB3Abinn44GiyaP7TLuDbKnCkuMxWrqXTrvYu/Qod961Rek2S6r8 S3l6TM4n+PP46Hox1hu6etj4FlMDRG5/pSWC62A+a3RL6UXu3FmfYmlANYyReoLQvEWh IMPQ== X-Gm-Message-State: AOJu0Yy9WvQZxuigmwYHs6nbRWzDzgnLEh/ni7f3R6l/CCG0eDWRmcrB wIIv181yZG4XXjiQHBrx1uJJGQ== X-Received: by 2002:adf:a4cf:0:b0:332:f3c9:1c8f with SMTP id h15-20020adfa4cf000000b00332f3c91c8fmr74990wrb.16.1701375773758; Thu, 30 Nov 2023 12:22:53 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:53 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:31 +0000 Subject: [PATCH v5 7/9] gpio: qcom_pmic: drop gpio-count property MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-7-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=2395; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=n4wzavWlWHVsZCehd+UmTwVOMCnMK4Qqs6PAhPleRjQ=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM92IXY/aVvZyzXW2Wn6fOtdJj35Zc72bPtCtqmGO05 vCk5/NtOkpZGAQ5GGTFFFnETyyzbFp72V5j+4ILMHNYmUCGMHBxCsBErrcy/DOPbNJeKD9h5rvd J/6Lz7m973Wu9N2XAvEVs6qnsru0+S1j+Kfg7djf/H9xYOWEjBwTG5Oj2mEX2P7/vSF2wSq3o/q z7hsA 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 This property is not part of the dt bindings and all boards use the new gpio-ranges property instead. Drop support for this. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- doc/device-tree-bindings/gpio/pm8916_gpio.txt | 48 --------------------------- drivers/gpio/qcom_pmic_gpio.c | 13 +++----- 2 files changed, 5 insertions(+), 56 deletions(-) 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/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 54f4dbd2b84e..1adc6566a36d 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -268,14 +268,11 @@ 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 - return ret; - } + ret = qcom_gpio_of_parse_ranges(dev); + if (ret > 0) + uc_priv->gpio_count = ret; + else + return ret; uc_priv->bank_name = "pmic"; From patchwork Thu Nov 30 20:22:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 748519 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1104160wrn; Thu, 30 Nov 2023 12:24:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbwXHheJYt2Ms/b9W4uUfzQkTd+2BKGJZUZAZtTtwzbTewp04QKDwL7kED3uYSoLyAFId5 X-Received: by 2002:a05:6a00:1251:b0:6cd:d67f:7cb with SMTP id u17-20020a056a00125100b006cdd67f07cbmr9237576pfi.16.1701375887875; Thu, 30 Nov 2023 12:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375887; cv=none; d=google.com; s=arc-20160816; b=FIWgwabYyHb3Ilz4SS18b0Kym59YExMquIFafIawG4b/dedaCDnbzasKVd77A20bDR o/J2oKSbZqgkfeukHp0EJw6QD9RumCeS2EwcvPiVNC9Voiwu0jGRH6/VuHPqlOhNjBkR 3U+McAp/E7SbSfP6NXk+rVPPZmj108pl1iRRizaondejZIWk7u2fT9gu/UnSRXFt1TC2 hHUHjOloMTD2retXcneZr1+003hsbUYAAkTdIkNeXWINyQYXwAqhZhTkrkIPgzCZ7I9L kylNvxyIKqTOSEwjMv/1rlWZJQLmW/GMNvaRnTxoSjFYDkHMDwai8PDspvNVPDTj/Kpo VTPQ== 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=OXFNl5nrOAyaQXFEJzGP6SfCWjL5HIsVLC3OhU4dgK+DsdJJD2wfoKz12NO+BQuhkO mjZggUfm6jL2Ej097MDlB9EQEPGvL9CacNXteR/nqsPul75u4qghQkWsNPFyjvLcv3oU jjCJ8n48gQDB2UPE1inW0fqLBrTv/9H1+TvHeR0zhkYhNbYTflwnNc1pfJuThEyIEyar lMj0Y7LEiumh0rp3g5Vy5zGlrVs0Vd4PgfkNtbZP6mMkiMnFOK8pJkU+1mBJSYbUn07n W7Ae5nP85+QE7pfHhvJVr3dOLOcTwqSmDVjOQUr8YW7GmywXva6Of159ze80XVXIQ5mG zxSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YA+pcJAw; 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 fb37-20020a056a002da500b006bdaa24308fsi1920603pfb.105.2023.11.30.12.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:24:47 -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=YA+pcJAw; 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 432638772D; Thu, 30 Nov 2023 21:23:02 +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="YA+pcJAw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2815087723; Thu, 30 Nov 2023 21:22: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-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 1C708876F6 for ; Thu, 30 Nov 2023 21:22: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-x330.google.com with SMTP id 5b1f17b1804b1-40b3e7f2fd9so12823655e9.0 for ; Thu, 30 Nov 2023 12:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375774; x=1701980574; 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=YA+pcJAws3vAjETFISKyNUGg0jvsGCzY360wC9auPMb6BG2CdhNY6+1hQ9DnrkvtAv 1cuy9K6wQ7WNwoiX+OKzg2gXyqx8lmje8eXMm8Lx7on+khzVPlzUN4OpUffmkyWtDunU wLdJ2ctndFmWamBVs0Fe4b6T5nyX6S5v+d7r9Y+D2dOZdPr0hDWP0B0bAxHLjggRRxqP aw5Sd2DgufhWQmFUXzlQ00SrrS4/ZHEfvrrMGe7K8M4Vu4tiXgVnnskvnu4+Xg7ejX+T BtJqYPoWHzidHmDpXdbBnWI0a9+/0rnWFfkIKbygwju7XPE/3izvYgaOSKhcD7Jm8dY7 u7cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375774; x=1701980574; 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=dDBFWGy2s6PDJT6nPK2SbOSE09WN9kHPl5hdSU9/soJoQXsJkJi2Ib78jWH4KnWZZT Uwr/JLDvAxER4av1hQKquJY8cVtnpHtbeoaBUQCoOITu8miDCwhfRD9594O5c676tTWw lnenXyQpDDiJA4dS3kWXBBDVKBvuf/GVsb/rQInjlwXlYoHqRREOMPpx1gf5DAnJG3DC XbpP3U3VBk6NpG6pPrVuQN2FPUdvZOwEyJz0qRbvjNsV8cDYE7jfnryWtLF/K4gMIgAd DNHZPInPxEV3ZW246jSnSA6L26uuP85yNaO2UMrt1Q/qty/+2tv4cE5f6Td8Pcp3xYw4 Yxiw== X-Gm-Message-State: AOJu0YyrPdWkTB8u2CTlnJSwdL7eANUNBEGC6sANj6MHN0inOcE17WTf S32AtRmz4M5/a897Oq2/2SqPmA== X-Received: by 2002:a05:600c:228c:b0:40b:5e21:c599 with SMTP id 12-20020a05600c228c00b0040b5e21c599mr27948wmf.103.1701375774592; Thu, 30 Nov 2023 12:22:54 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:54 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:32 +0000 Subject: [PATCH v5 8/9] spmi: msm: fix register range names MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-8-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=6713; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=ngCQCcWA79jZqTpSLCdIzQaxdPsoQIWp6rrKFzavTy8=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM92Jq7TMDy6weF68+lBe00vpYHrvCzxqmm99CDFceq Oy4k/2to5SFQZCDQVZMkUX8xDLLprWX7TW2L7gAM4eVCWQIAxenAEzEToGRoXFzLsvvDjeL90sf BHCcUVe/ttHRIlZmX8LhR/Jlk/bIb2D4714S591i/1N19eydnX/12Xk7Tu3vb/z18K75B8Gdri8 nJwEA 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 Reviewed-by: Neil Armstrong --- 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 Thu Nov 30 20:22:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 748520 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1104265wrn; Thu, 30 Nov 2023 12:25:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFS5TUs3HLPWH8jhiTS5vZa3A8cPfjX+mpbpHEOGT+Qt7T3f3cK3YI4Rd2dZRFBgnbTVQ2G X-Received: by 2002:a05:6a20:7350:b0:18d:4821:f754 with SMTP id v16-20020a056a20735000b0018d4821f754mr2410429pzc.55.1701375902264; Thu, 30 Nov 2023 12:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375902; cv=none; d=google.com; s=arc-20160816; b=wypBvOkKdZ9PbVVMBgx76UU1u7CBVECb2SbX5NiuoMMx0O1wReNS5cwPFGJkBzqOia LnmNy91s5wphZVJlfgJwS2vQKAHzQ9WUgp/TlQEzzYeMYExOlQM9tQLtRhJ4w8ohbBGQ eRgvWcGKd0givw0GZUPqZzeMRxppzBjjY2tDm+vxG3qg/rwRhJMOEWin6UpBCogK5bcm opuHGQ8Sttb4xZCE7+C1+ITthAnLOPU6dA3NjT7Kn8x6VlycvMsYxUsYADhWVSCQayvw pFKF3MpTCwU8+G3HT6BuiomagMj1897yS78LQb8gm7pMRU2WLBagmt9HwxI0efRpPTJX SbQA== 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=ltF9n5LWx5cCkWzuJp1SLLfO6b6VAmFvztXFh0EgQt12LfdiVEM/NkEV51VkeCGbTS +ZduGWNUV9CiN3OZpmYf/YrhBs/N3f4sFw9lxuYQjL7snHojcVNY6uJvUOW+yhtXxVWt T6MS80LiXGlBjZfv+XLDOT+hW5N7L/DrQOTeGtEltRkhDhDUTXUwR/hetJ8ogZI2UmiT nlL32fzdNtMTuBK7ES2fZE6jUyUReCEb38nraUM22iRA9ZIYCd9IT7bTjM6Ljd936SdG /YMJeZHdkpmxvH/bPq0l2q3zYYyUsEexbbX05nM+1N0v9irABMo35yQX9aI3k//sOvnm /T3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uIq/d9MN"; 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 d24-20020a630e18000000b005c2783b71cfsi1963533pgl.810.2023.11.30.12.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:25:02 -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="uIq/d9MN"; 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 6D9FD87732; Thu, 30 Nov 2023 21:23: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=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="uIq/d9MN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2F01E876F6; Thu, 30 Nov 2023 21:22:59 +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 2D14B87714 for ; Thu, 30 Nov 2023 21:22:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40b27b498c3so14287665e9.0 for ; Thu, 30 Nov 2023 12:22:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375776; x=1701980576; 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=uIq/d9MN42iWm0kGzN8QiwzaOiQ5aQf61OKbRuZQegZ+wh2SAjx/8u02IEihvJ2piG KY+LM/yxk/Wrg32D9Et6fL03eiNAGEP1rj0oIVIdcaS3mce46gLyUXVBJCk5IG44H/by 344eTRE5hLdOzWYUiKMYryAb+r6DwG+7bbEEOabyjMW+mH9gQd/VPtNCghJcGxuEXUhf OzLNwV9ktiBQR2F4XBaJJNxnpJZm7AJr6cmkH/ynCrgVkUJQBfOQhtenmhzyGOJ8NXHO uF17naBq6WSiBKab+FphHQGE9wfsPPwPJ7UOP8ooDf/3btliiZbzICSP1Y+LMkXd+iaG 6jMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375776; x=1701980576; 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=ZKOm8MF67IUSDZuUxs8e2mAsYF8N5BYqKEVM6vtH+aMWgR03N9z5ZiuMDJG/9tbT5u /uSIf2u5QTaZortdnGsmBlsTPJ8O3rYnlt3whYzSnHiMtUBspgeWwl1ikD0VnTDMQyCe pzqk+xgd2Ge5EtQlM0pf15+DL0ftBYDA0aPOg+7TTx5mCpp1xNk/VR1mXy1oVnAwyWwG XBR4tOhkWW2h0kPl00ckjpGY4COFBz/ZILlgOEfnZzKcgL0xdy+smsY89nJX6o1yodl8 2arggPWuxSoayV5fPVhEhJnImBEXoq8U7g4Lyhmqw8kupvvsYfzjp2wnpg5lcD2DJnOW 5W4w== X-Gm-Message-State: AOJu0YwUJYtroJ9gLhTkaT0KFlwlbde0mApXCOSg1jBN+296sScLOL14 k3KOgVgbT/jCq9iGkVkCJWGxwg== X-Received: by 2002:a05:600c:26d3:b0:40b:5e21:dd44 with SMTP id 19-20020a05600c26d300b0040b5e21dd44mr41270wmv.114.1701375776750; Thu, 30 Nov 2023 12:22:56 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:56 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:33 +0000 Subject: [PATCH v5 9/9] pmic: qcom: dont use dev_read_addr to get USID MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-9-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=5331; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=GoC7TMy12LCcUreseBruRwwooFPfjXYG46ZgiFDMnn4=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM92LHY2+2Kay1XMPo0rz288aKhFcms4oeMh/Ys8RAM /7tzjmiHaUsDIIcDLJiiiziJ5ZZNq29bK+xfcEFmDmsTCBDGLg4BWAiZy8y/Pf6eUo1r2zWvus+ x+Ykb9WQyHojrKJ1pqm44TFL1ulqo0CG/7HTNJ+s3bO+ehmL3c+T7//FKZouK9V+ZsQzs36O8BS fX5wA 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 Reviewed-by: Neil Armstrong --- 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; }