[PATCH v4 4/5] regulator: p3h2x4x: Add driver for on-die regulators in NXP P3H2x4x i3c hub
From: Aman Kumar Pandey <hidden>
Date: 2026-01-13 11:46:01
Also in:
linux-i3c, lkml
Subsystem:
the rest, voltage and current regulator framework · Maintainers:
Linus Torvalds, Liam Girdwood, Mark Brown
The NXP P3H2x4x family integrates on-die regulators alongside I3C hub functionality. This driver registers the regulators using the MFD framework and exposes them via the regulator subsystem. Signed-off-by: Aman Kumar Pandey <redacted> Signed-off-by: Vikash Bansal <redacted> --- Changes in v4: - Split the driver into three separate patches (mfd, regulator and I3C hub) - Introduced driver for on-die regulators in NXP P3H2x4x I3C hub --- --- MAINTAINERS | 3 + drivers/regulator/Kconfig | 10 ++ drivers/regulator/Makefile | 1 + drivers/regulator/p3h2840_i3c_hub_regulator.c | 162 ++++++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 drivers/regulator/p3h2840_i3c_hub_regulator.c
diff --git a/MAINTAINERS b/MAINTAINERS
index aa7043499223..4bcd52d65f1a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS@@ -18934,6 +18934,9 @@ F: Documentation/devicetree/bindings/mfd/nxp,p3h2840-i3c-hub.yaml F: drivers/mfd/Kconfig F: drivers/mfd/Makefile F: drivers/mfd/p3h2840.c +F: drivers/regulator/Kconfig +F: drivers/regulator/Makefile +F: drivers/regulator/p3h2840_i3c_hub_regulator.c F: include/linux/mfd/p3h2840.h NXP SGTL5000 DRIVER
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index d2335276cce5..aa8c06c1253a 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig@@ -1085,6 +1085,16 @@ config REGULATOR_PF8X00 on the NXP PF8100/PF8121A/PF8200 PMIC. The module will be named "pf8x00-regulator". +config REGULATOR_P3H2X4X + tristate "P3H2X4X regulator support" + depends on MFD_P3H2X4X + help + This driver provides support for the voltage regulators of the + P3H244x/P3H284x multi-function I3C Hub device. + + Say M here if you want to include support for this regulator as + a module. The module will be named "p3h2840_i3c_hub_regulator". + config REGULATOR_PFUZE100 tristate "Freescale PFUZE100/200/3000/3001 regulator driver" depends on I2C && OF
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 1beba1493241..4cece550b4c1 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile@@ -214,5 +214,6 @@ obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o +obj-$(CONFIG_REGULATOR_P3H2X4X) += p3h2840_i3c_hub_regulator.o ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/p3h2840_i3c_hub_regulator.c b/drivers/regulator/p3h2840_i3c_hub_regulator.c
new file mode 100644
index 000000000000..bf34e5f1f3ba
--- /dev/null
+++ b/drivers/regulator/p3h2840_i3c_hub_regulator.c@@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2025 NXP + * This P3H2x4x driver file contain functions for enable/disable regulator and voltage set/get. + */ +#include <linux/regulator/driver.h> +#include <linux/platform_device.h> +#include <linux/of.h> +#include <linux/mfd/p3h2840.h> + +#define P3H2x4x_LDO_AND_PULLUP_CONF 0x19 +#define P3H2x4x_LDO_ENABLE_DISABLE_MASK GENMASK(3, 0) +#define P3H2x4x_CP0_EN_LDO BIT(0) +#define P3H2x4x_CP1_EN_LDO BIT(1) +#define P3H2x4x_TP0145_EN_LDO BIT(2) +#define P3H2x4x_TP2367_EN_LDO BIT(3) + +#define P3H2x4x_NET_OPER_MODE_CONF 0x15 +#define P3H2x4x_VCCIO_LDO_CONF 0x16 +#define P3H2x4x_CP0_VCCIO_LDO_VOLTAGE_MASK GENMASK(1, 0) +#define P3H2x4x_CP0_VCCIO_LDO_VOLTAGE(x) \ + FIELD_PREP(P3H2x4x_CP0_VCCIO_LDO_VOLTAGE_MASK, x) +#define P3H2x4x_CP1_VCCIO_LDO_VOLTAGE_MASK GENMASK(3, 2) +#define P3H2x4x_CP1_VCCIO_LDO_VOLTAGE(x) \ + FIELD_PREP(P3H2x4x_CP1_VCCIO_LDO_VOLTAGE_MASK, x) +#define P3H2x4x_TP0145_VCCIO_LDO_VOLTAGE_MASK GENMASK(5, 4) +#define P3H2x4x_TP0145_VCCIO_LDO_VOLTAGE(x) \ + FIELD_PREP(P3H2x4x_TP0145_VCCIO_LDO_VOLTAGE_MASK, x) +#define P3H2x4x_TP2367_VCCIO_LDO_VOLTAGE_MASK GENMASK(7, 6) +#define P3H2x4x_TP2367_VCCIO_LDO_VOLTAGE(x) \ + FIELD_PREP(P3H2x4x_TP2367_VCCIO_LDO_VOLTAGE_MASK, x) +#define P3H2x4x_LDO_COUNT 4 + +struct p3h2x4x_regulator_dev { + struct regulator_dev *rp3h2x4x_dev[P3H2x4x_LDO_COUNT]; + struct regmap *regmap; +}; + +static const struct regulator_ops p3h2x4x_ldo_ops = { + .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_iterate, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, +}; + +static const unsigned int p3h2x4x_voltage_table[] = { + 1000000, + 1100000, + 1200000, + 1800000, +}; + +static struct regulator_desc p3h2x4x_regulators[] = { + { + .name = "cp0", + .of_match = of_match_ptr("cp0"), + .regulators_node = of_match_ptr("regulators"), + .volt_table = p3h2x4x_voltage_table, + .n_voltages = ARRAY_SIZE(p3h2x4x_voltage_table), + .ops = &p3h2x4x_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .enable_reg = P3H2x4x_LDO_AND_PULLUP_CONF, + .enable_mask = P3H2x4x_CP0_EN_LDO, + .vsel_reg = P3H2x4x_VCCIO_LDO_CONF, + .vsel_mask = P3H2x4x_CP0_VCCIO_LDO_VOLTAGE_MASK, + }, + { + .name = "cp1", + .of_match = of_match_ptr("cp1"), + .regulators_node = of_match_ptr("regulators"), + .volt_table = p3h2x4x_voltage_table, + .n_voltages = ARRAY_SIZE(p3h2x4x_voltage_table), + .ops = &p3h2x4x_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .enable_reg = P3H2x4x_LDO_AND_PULLUP_CONF, + .enable_mask = P3H2x4x_CP1_EN_LDO, + .vsel_reg = P3H2x4x_VCCIO_LDO_CONF, + .vsel_mask = P3H2x4x_CP1_VCCIO_LDO_VOLTAGE_MASK, + }, + { + .name = "tp0145", + .of_match = of_match_ptr("tp0145"), + .regulators_node = of_match_ptr("regulators"), + .volt_table = p3h2x4x_voltage_table, + .n_voltages = ARRAY_SIZE(p3h2x4x_voltage_table), + .ops = &p3h2x4x_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .enable_reg = P3H2x4x_LDO_AND_PULLUP_CONF, + .enable_mask = P3H2x4x_TP0145_EN_LDO, + .vsel_reg = P3H2x4x_VCCIO_LDO_CONF, + .vsel_mask = P3H2x4x_TP0145_VCCIO_LDO_VOLTAGE_MASK, + }, + { + .name = "tp2367", + .of_match = of_match_ptr("tp2367"), + .regulators_node = of_match_ptr("regulators"), + .volt_table = p3h2x4x_voltage_table, + .n_voltages = ARRAY_SIZE(p3h2x4x_voltage_table), + .ops = &p3h2x4x_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .enable_reg = P3H2x4x_LDO_AND_PULLUP_CONF, + .enable_mask = P3H2x4x_TP2367_EN_LDO, + .vsel_reg = P3H2x4x_VCCIO_LDO_CONF, + .vsel_mask = P3H2x4x_TP2367_VCCIO_LDO_VOLTAGE_MASK, + }, +}; + +static int p3h2x4x_regulator_probe(struct platform_device *pdev) +{ + struct p3h2x4x_dev *p3h2x4x = dev_get_drvdata(pdev->dev.parent); + struct p3h2x4x_regulator_dev *p3h2x4x_regulator; + struct regulator_config rcfg = { }; + struct device *dev = &pdev->dev; + struct regulator_dev *rdev; + int ret, i; + + p3h2x4x_regulator = devm_kzalloc(dev, sizeof(*p3h2x4x_regulator), GFP_KERNEL); + if (!p3h2x4x_regulator) + return -ENOMEM; + + platform_set_drvdata(pdev, p3h2x4x_regulator); + + p3h2x4x_regulator->regmap = p3h2x4x->regmap; + device_set_of_node_from_dev(dev, dev->parent); + + rcfg.dev = dev; + rcfg.dev->of_node = dev->of_node; + rcfg.regmap = p3h2x4x_regulator->regmap; + rcfg.driver_data = p3h2x4x_regulator; + + for (i = 0; i < ARRAY_SIZE(p3h2x4x_regulators); i++) { + rdev = devm_regulator_register(&pdev->dev, &p3h2x4x_regulators[i], &rcfg); + if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); + dev_err(dev, "Failed to register %s\n", p3h2x4x_regulators[i].name); + return ret; + } + p3h2x4x_regulator->rp3h2x4x_dev[i] = rdev; + } + return 0; +} + +static struct platform_driver p3h2x4x_regulator_driver = { + .driver = { + .name = "p3h2x4x-regulator", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .probe = p3h2x4x_regulator_probe, +}; +module_platform_driver(p3h2x4x_regulator_driver); + +MODULE_AUTHOR("Aman Kumar Pandey <aman.kumarpandey@nxp.com>"); +MODULE_AUTHOR("vikash Bansal <vikash.bansal@nxp.com>"); +MODULE_DESCRIPTION("P3H2x4x I3C HUB driver"); +MODULE_LICENSE("GPL");
--
2.25.1