Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2162518lqa; Tue, 30 Apr 2024 09:37:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXqdOGCcZBPEr0XRM0JjfIapkQQXTTLTH4hjh5tXK1Nrjb2dU2uwPYo9jLVsN+gdDxRjDT6RzwbpPxkELt+K917zzGRoNaMQVz/ayla1g== X-Google-Smtp-Source: AGHT+IEcBUqybR4cbJCKSgY9ReSk3Tcu+HlFrZ0qresqN9CBzDN/IYgudkIHjPEwA/LHf/GXxXNI X-Received: by 2002:a50:cd55:0:b0:572:7926:a0f9 with SMTP id d21-20020a50cd55000000b005727926a0f9mr181326edj.41.1714495061603; Tue, 30 Apr 2024 09:37:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714495061; cv=pass; d=google.com; s=arc-20160816; b=EKJwILlpZs2ygxq4qk6JpyjvG6NaST6o6HwVEEwDdkjeHXUHkVKRqVVrhZhzZt7WgW xuZHg6ErXV5e8pHnpiI3+S03U8GwZicPh43fs6C88raDXZ+FWfvDWqbCatnaRgp6YXny PMS4p1Q/EzG7zU48wWHXjGz6gglcCaimwP0q37F9CH4y8Ep+Af0EDb6iSoiPM4TUK3om IkVYFcKK01ZuG+14+926U9MQ0v7sa/4qKF7eBPYDUEFXnSK9kg/5UfIGH3BB8cj1BA/J qQeAWLvHTAHuDMQbbPKWEXonKYckpYYYAoNoXwh4TY4eEDrGF+i//uO6VOiekbt0P1aF v0ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=I5E0v/QISH42i6i609xh1CUUPrjI1rIw7BU/HQqBZW0=; fh=xXOF1hX1WC9Il7BzxfOdi7PDnssZuy8pCFHdHZeQ0R4=; b=EDzzrHkrHKTfsskbkgjU2KF2JC3rBXppinpyL6fLJcaM3hEs+68NeTYawhUdycPtny DeDOwzYzwb6DJ+mMh2joOEaLypmb3OPbsi+Hy2YN2JmMOLYZs/AIXnyqXrTNfjVwAGYN pVXkzEMdz0uamE1c1Yi0qhhlIMmyFsZUX43noGiSrlMYiEf2JIPVL0YiUervAlTc2Mp5 cRpDYKqAGE722DyMYJ0YFZtLaXDClEGQ8Jvpo+XuL+qT7SLoP14rYPFS9ITAkMlzaem/ v4QtK55OwrGno8P+uS29AXUpTTAROzTkzRzeuj1AhUg6m7nvBDiFFJmEoB9LRine/5DH 8cQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ltts.com header.s=i3fe3efcd4pbz7ipgssfqjhzqx347xbc header.b=IQYPxotd; dkim=pass header.i=@amazonses.com header.s=zpkik46mrueu52d3326ufxxchortqmoc header.b=boCETMet; arc=pass (i=1 spf=pass spfdomain=ap-south-1.amazonses.com dkim=pass dkdomain=ltts.com dkim=pass dkdomain=amazonses.com dmarc=pass fromdomain=ltts.com); spf=pass (google.com: domain of linux-kernel+bounces-164399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ltts.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m27-20020a50d7db000000b00572727642fasi3609204edj.338.2024.04.30.09.37.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 09:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ltts.com header.s=i3fe3efcd4pbz7ipgssfqjhzqx347xbc header.b=IQYPxotd; dkim=pass header.i=@amazonses.com header.s=zpkik46mrueu52d3326ufxxchortqmoc header.b=boCETMet; arc=pass (i=1 spf=pass spfdomain=ap-south-1.amazonses.com dkim=pass dkdomain=ltts.com dkim=pass dkdomain=amazonses.com dmarc=pass fromdomain=ltts.com); spf=pass (google.com: domain of linux-kernel+bounces-164399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ltts.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2D01C1F224A5 for ; Tue, 30 Apr 2024 16:37:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E5B118131F; Tue, 30 Apr 2024 16:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ltts.com header.i=@ltts.com header.b="IQYPxotd"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="boCETMet" Received: from c180-38.smtp-out.ap-south-1.amazonses.com (c180-38.smtp-out.ap-south-1.amazonses.com [76.223.180.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1285D180A77; Tue, 30 Apr 2024 16:35:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=76.223.180.38 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714494943; cv=none; b=rUCMP8ctBh7a0U3uzBEqR85aJRnr5onoAx7L1x/NJgNX7S+kxDuA9T+wTk6qjJSoo8BCVfIkwHTE5C/u+RO+62tbAHt59lDFtgCXy9BRnNF/vc0tYuMKBNQ8iXDz+5XYEl0baJP/lHuUJUkB4vPX57pCI7yakAvvgW6adQ6AlK0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714494943; c=relaxed/simple; bh=iFYczu1Wr+uRIXgLgGIxVu11RyoBjz1N8NcMbmiHQVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GkgKU6DPSdAQDiwF+1PI0ATnHvgqga6lQzGsAXwiSUJcN8I8Bnyn71u+uI2bwVuh33ms4hFSgDClMHtJwD+t7xn4yCvoJDcIQLyUaxwwfycwbmjyGYDc4MXE/WWIUKEcmJ3wVua+EBzVFnlYlY9QfzMbGLSoNw1ppbENEF1yxjs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ltts.com; spf=pass smtp.mailfrom=ap-south-1.amazonses.com; dkim=pass (2048-bit key) header.d=ltts.com header.i=@ltts.com header.b=IQYPxotd; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b=boCETMet; arc=none smtp.client-ip=76.223.180.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ltts.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ap-south-1.amazonses.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=i3fe3efcd4pbz7ipgssfqjhzqx347xbc; d=ltts.com; t=1714494938; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=iFYczu1Wr+uRIXgLgGIxVu11RyoBjz1N8NcMbmiHQVA=; b=IQYPxotdOCxYZj34HZVx7bB8IQotIgTeOmj750D8/zW16SZegV886ouEYpzcjx8W EsJD25MFi2/ZltcxQWwKb1B78X6u/jRkdivXbjA8pB9i84vWE20vJmFzGftrVIlRu9q TE84a4vsFFeSP6YsZ2sDN/BTXLVyXNTMjVG4AcWTGpSFPCVn1iGQRNUQ+vm5YGIR+l9 9fRvo779QJcmh9VHv2jmBjlIes6TmleGEAhsrFHgvaFgPhzjtm5D8+aDV18KvlWaFfX nP7GE1W9i+3f/eMb7zyW3M9ig2iEik53GeUHN0u7bux0CNp7WlfSM7vVksWHVcG5df8 KWOXUfBrjg== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zpkik46mrueu52d3326ufxxchortqmoc; d=amazonses.com; t=1714494938; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Feedback-ID; bh=iFYczu1Wr+uRIXgLgGIxVu11RyoBjz1N8NcMbmiHQVA=; b=boCETMetFV10EJTUkHnfRaqrc2dCGIkG4dE8U8BetNLh9Di73zoR5/Wceq9c0vuG 3UcENHzPO3bt3LGCaTwXdgSCzB2i+dIxz/Z+HlNop8+9UoEuHclxKU2GTT189uUtJUW h1M2o+vWE4xKeGVgRNX0QnkPMnq2RWdmj7tO5MB0= From: Bhargav Raviprakash To: linux-kernel@vger.kernel.org Cc: bhargav.r@ltts.com, arnd@arndb.de, broonie@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, eblanc@baylibre.com, gregkh@linuxfoundation.org, jpanis@baylibre.com, kristo@kernel.org, krzysztof.kozlowski+dt@linaro.org, lee@kernel.org, lgirdwood@gmail.com, linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, m.nirmaladevi@ltts.com, nm@ti.com, robh+dt@kernel.org, vigneshr@ti.com Subject: [PATCH v8 07/10] misc: tps6594-pfsm: Add TI TPS65224 PMIC PFSM Date: Tue, 30 Apr 2024 16:35:38 +0000 Message-ID: <0109018f2fdc9dc4-db5a45c0-0148-48cc-8462-d1c5b577a4bd-000000@ap-south-1.amazonses.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <0109018f2f24c15e-c50bfc29-5f1d-4368-a4b8-2c9f1d398abb-000000@ap-south-1.amazonses.com> References: <0109018f2f24c15e-c50bfc29-5f1d-4368-a4b8-2c9f1d398abb-000000@ap-south-1.amazonses.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Feedback-ID: 1.ap-south-1./RC/PI2M8xOxQmTMPi0M1Q8h2FX69egpT62QKSaMPIA=:AmazonSES X-SES-Outgoing: 2024.04.30-76.223.180.38 Add support for TPS65224 PFSM in the TPS6594 PFSM driver as they share significant functionality. Signed-off-by: Bhargav Raviprakash Acked-by: Julien Panis Acked-by: Greg Kroah-Hartman --- drivers/misc/tps6594-pfsm.c | 48 +++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c index 88dcac814..9bcca1856 100644 --- a/drivers/misc/tps6594-pfsm.c +++ b/drivers/misc/tps6594-pfsm.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * PFSM (Pre-configurable Finite State Machine) driver for TI TPS6594/TPS6593/LP8764 PMICs + * PFSM (Pre-configurable Finite State Machine) driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs * * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ */ @@ -39,10 +39,12 @@ * * @miscdev: misc device infos * @regmap: regmap for accessing the device registers + * @chip_id: chip identifier of the device */ struct tps6594_pfsm { struct miscdevice miscdev; struct regmap *regmap; + unsigned long chip_id; }; static ssize_t tps6594_pfsm_read(struct file *f, char __user *buf, @@ -133,21 +135,29 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(f); struct pmic_state_opt state_opt; void __user *argp = (void __user *)arg; + unsigned int regmap_reg, mask; int ret = -ENOIOCTLCMD; switch (cmd) { case PMIC_GOTO_STANDBY: - /* Disable LP mode */ - ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, - TPS6594_BIT_LP_STANDBY_SEL); - if (ret) - return ret; + /* Disable LP mode on TPS6594 Family PMIC */ + if (pfsm->chip_id != TPS65224) { + ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, + TPS6594_BIT_LP_STANDBY_SEL); + + if (ret) + return ret; + } /* Force trigger */ ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_FSM_I2C_TRIGGERS, TPS6594_BIT_TRIGGER_I2C(0), TPS6594_BIT_TRIGGER_I2C(0)); break; case PMIC_GOTO_LP_STANDBY: + /* TPS65224 does not support LP STANDBY */ + if (pfsm->chip_id == TPS65224) + return ret; + /* Enable LP mode */ ret = regmap_set_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, TPS6594_BIT_LP_STANDBY_SEL); @@ -169,6 +179,10 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a TPS6594_BIT_NSLEEP1B | TPS6594_BIT_NSLEEP2B); break; case PMIC_SET_MCU_ONLY_STATE: + /* TPS65224 does not support MCU_ONLY_STATE */ + if (pfsm->chip_id == TPS65224) + return ret; + if (copy_from_user(&state_opt, argp, sizeof(state_opt))) return -EFAULT; @@ -192,14 +206,20 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a return -EFAULT; /* Configure wake-up destination */ + if (pfsm->chip_id == TPS65224) { + regmap_reg = TPS65224_REG_STARTUP_CTRL; + mask = TPS65224_MASK_STARTUP_DEST; + } else { + regmap_reg = TPS6594_REG_RTC_CTRL_2; + mask = TPS6594_MASK_STARTUP_DEST; + } + if (state_opt.mcu_only_startup_dest) - ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, - TPS6594_MASK_STARTUP_DEST, - TPS6594_STARTUP_DEST_MCU_ONLY); + ret = regmap_write_bits(pfsm->regmap, regmap_reg, + mask, TPS6594_STARTUP_DEST_MCU_ONLY); else - ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, - TPS6594_MASK_STARTUP_DEST, - TPS6594_STARTUP_DEST_ACTIVE); + ret = regmap_write_bits(pfsm->regmap, regmap_reg, + mask, TPS6594_STARTUP_DEST_ACTIVE); if (ret) return ret; @@ -211,7 +231,8 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a /* Modify NSLEEP1-2 bits */ ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, - TPS6594_BIT_NSLEEP2B); + pfsm->chip_id == TPS65224 ? + TPS6594_BIT_NSLEEP1B : TPS6594_BIT_NSLEEP2B); break; } @@ -262,6 +283,7 @@ static int tps6594_pfsm_probe(struct platform_device *pdev) tps->chip_id, tps->reg); pfsm->miscdev.fops = &tps6594_pfsm_fops; pfsm->miscdev.parent = dev->parent; + pfsm->chip_id = tps->chip_id; for (i = 0 ; i < pdev->num_resources ; i++) { irq = platform_get_irq_byname(pdev, pdev->resource[i].name); -- 2.25.1