From: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
To: Lee Jones <lee@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Guru Das Srinagesh <linux@gurudas.dev>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, mfd@lists.linux.dev,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
Dhruvin Rajpura <drajpura@qti.qualcomm.com>,
Nihal Kumar Gupta <nihal.gupta@oss.qualcomm.com>,
Kamal Wadhwa <kamal.wadhwa@oss.qualcomm.com>,
Oleg Keri <okerixx@gmail.com>,
Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
Subject: [PATCH 3/6] regulator: qcom-pm8008: Add PM8010 mode support
Date: Fri, 18 Sep 2026 22:12:47 +0530 [thread overview]
Message-ID: <20260918-pm8010_i2c_support-v1-3-de33d78fad9d@oss.qualcomm.com> (raw)
In-Reply-To: <20260918-pm8010_i2c_support-v1-0-de33d78fad9d@oss.qualcomm.com>
From: Dhruvin Rajpura <drajpura@qti.qualcomm.com>
Implement set_mode/get_mode support for PM8010 LDOs using the mode
control and status registers to allow clients to vote for LDO modes.
Mode voting is not supported in the PM8008 LDOs.
Signed-off-by: Dhruvin Rajpura <drajpura@qti.qualcomm.com>
Signed-off-by: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
---
drivers/regulator/qcom-pm8008-regulator.c | 75 ++++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/qcom-pm8008-regulator.c b/drivers/regulator/qcom-pm8008-regulator.c
index b484c0f73eea..9758809a6322 100644
--- a/drivers/regulator/qcom-pm8008-regulator.c
+++ b/drivers/regulator/qcom-pm8008-regulator.c
@@ -8,6 +8,7 @@
#include <linux/array_size.h>
#include <linux/bits.h>
#include <linux/device.h>
+#include <linux/i2c.h>
#include <linux/math.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -24,9 +25,19 @@
#define LDO_VSET_LB_REG 0x40
+#define LDO_MODE_CTL1_REG 0x45
+#define MODE_PRIMARY_MASK GENMASK(2, 0)
+#define LDO_MODE_NPM 7
+#define LDO_MODE_LPM 4
+
#define LDO_ENABLE_REG 0x46
#define ENABLE_BIT BIT(7)
+#define LDO_STATUS1_REG 0x08
+#define MODE_STATE_MASK GENMASK(1, 0)
+#define MODE_STATE_NPM 3
+#define MODE_STATE_LPM 2
+
struct pm8008_regulator {
struct regmap *regmap;
struct regulator_desc desc;
@@ -134,6 +145,51 @@ static int pm8008_regulator_get_voltage_sel(struct regulator_dev *rdev)
return regulator_map_voltage_linear_range(rdev, uV, INT_MAX);
}
+static int pm8010_regulator_set_mode(struct regulator_dev *rdev, unsigned int mode)
+{
+ struct pm8008_regulator *preg = rdev_get_drvdata(rdev);
+ unsigned int val;
+
+ switch (mode) {
+ case REGULATOR_MODE_NORMAL:
+ val = LDO_MODE_NPM;
+ break;
+ case REGULATOR_MODE_IDLE:
+ val = LDO_MODE_LPM;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return regmap_update_bits(preg->regmap, preg->base + LDO_MODE_CTL1_REG,
+ MODE_PRIMARY_MASK, val);
+}
+
+static unsigned int pm8010_regulator_get_mode(struct regulator_dev *rdev)
+{
+ struct pm8008_regulator *preg = rdev_get_drvdata(rdev);
+ unsigned int val;
+ int ret;
+
+ ret = regmap_read(preg->regmap, preg->base + LDO_STATUS1_REG, &val);
+ if (ret < 0)
+ return REGULATOR_MODE_INVALID;
+
+ return (val & MODE_STATE_MASK) == MODE_STATE_NPM ?
+ REGULATOR_MODE_NORMAL : REGULATOR_MODE_IDLE;
+}
+
+static unsigned int pm8010_regulator_of_map_mode(unsigned int mode)
+{
+ switch (mode) {
+ case REGULATOR_MODE_NORMAL:
+ case REGULATOR_MODE_IDLE:
+ return mode;
+ default:
+ return REGULATOR_MODE_INVALID;
+ }
+}
+
static const struct regulator_ops pm8008_regulator_ops = {
.list_voltage = regulator_list_voltage_linear_range,
.set_voltage_sel = pm8008_regulator_set_voltage_sel,
@@ -143,6 +199,17 @@ static const struct regulator_ops pm8008_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap,
};
+static const struct regulator_ops pm8010_regulator_ops = {
+ .list_voltage = regulator_list_voltage_linear_range,
+ .set_voltage_sel = pm8008_regulator_set_voltage_sel,
+ .get_voltage_sel = pm8008_regulator_get_voltage_sel,
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .set_mode = pm8010_regulator_set_mode,
+ .get_mode = pm8010_regulator_get_mode,
+};
+
static int pm8008_regulator_probe(struct platform_device *pdev)
{
const struct pm8008_match_data *match_data;
@@ -155,6 +222,7 @@ static int pm8008_regulator_probe(struct platform_device *pdev)
struct regulator_dev *rdev;
struct regmap *regmap;
unsigned int val;
+ bool is_pm8010;
int ret, i;
id = platform_get_device_id(pdev);
@@ -169,6 +237,9 @@ static int pm8008_regulator_probe(struct platform_device *pdev)
if (!regmap)
return -EINVAL;
+ is_pm8010 = of_device_is_compatible(to_i2c_client(dev->parent)->dev.of_node,
+ "qcom,pm8010-i2c");
+
for (i = 0; i < match_data->num_regulators; i++) {
data = &match_data->regulator_data[i];
@@ -185,7 +256,9 @@ static int pm8008_regulator_probe(struct platform_device *pdev)
desc->supply_name = data->supply_name;
desc->of_match = data->name;
desc->regulators_node = of_match_ptr("regulators");
- desc->ops = &pm8008_regulator_ops;
+ desc->ops = is_pm8010 ? &pm8010_regulator_ops : &pm8008_regulator_ops;
+ if (is_pm8010)
+ desc->of_map_mode = pm8010_regulator_of_map_mode;
desc->type = REGULATOR_VOLTAGE;
desc->owner = THIS_MODULE;
--
2.43.0
next prev parent reply other threads:[~2026-09-18 16:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 16:42 [PATCH 0/6] mfd: qcom-pm8008: Add support for PM8010 over I2C Jishnu Prakash
2026-09-18 16:42 ` [PATCH 1/6] dt-bindings: mfd: pm8008: Add qcom,pm8010-i2c compatible Jishnu Prakash
2026-09-28 19:48 ` Rob Herring (Arm)
2026-09-18 16:42 ` [PATCH 2/6] regulator: pm8008: Add PM8010 support Jishnu Prakash
2026-09-18 16:42 ` Jishnu Prakash [this message]
2026-09-18 16:42 ` [PATCH 4/6] mfd: qcom-pm8008: " Jishnu Prakash
2026-09-21 13:33 ` Konrad Dybcio
2026-09-23 10:18 ` Jishnu Prakash
2026-10-01 8:29 ` Konrad Dybcio
2026-09-18 16:42 ` [PATCH 5/6] dt-bindings: mfd: pm8008: Make interrupts optional Jishnu Prakash
2026-09-28 19:49 ` Rob Herring (Arm)
2026-09-18 16:42 ` [PATCH 6/6] mfd: qcom-pm8008: Tolerate missing interrupt Jishnu Prakash
2026-09-19 13:01 ` [PATCH 0/6] mfd: qcom-pm8008: Add support for PM8010 over I2C Oleg Keri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260918-pm8010_i2c_support-v1-3-de33d78fad9d@oss.qualcomm.com \
--to=jishnu.prakash@oss.qualcomm.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=drajpura@qti.qualcomm.com \
--cc=kamal.wadhwa@oss.qualcomm.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@gurudas.dev \
--cc=mfd@lists.linux.dev \
--cc=nihal.gupta@oss.qualcomm.com \
--cc=okerixx@gmail.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®