* [PATCH v1 0/2] regulator: max77838: add max77838 regulator driver
@ 2025-09-14 13:02 Ivaylo Ivanov
2025-09-14 13:02 ` [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic Ivaylo Ivanov
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Ivaylo Ivanov @ 2025-09-14 13:02 UTC (permalink / raw)
To: Krzysztof Kozlowski, Rob Herring, Liam Girdwood, Mark Brown
Cc: linux-samsung-soc, devicetree, linux-kernel
Hey folks,
This patchset adds support for the max77838 PMIC. It's used on the Galaxy
S7 lineup of phones, and provides regulators for the display.
Best regards,
Ivaylo
Ivaylo Ivanov (2):
dt-bindings: regulator: document max77838 pmic
regulator: max77838: add max77838 regulator driver
.../bindings/regulator/maxim,max77838.yaml | 68 ++++++
MAINTAINERS | 7 +
drivers/regulator/Kconfig | 8 +
drivers/regulator/Makefile | 1 +
drivers/regulator/max77838-regulator.c | 221 ++++++++++++++++++
5 files changed, 305 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max77838.yaml
create mode 100644 drivers/regulator/max77838-regulator.c
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic
2025-09-14 13:02 [PATCH v1 0/2] regulator: max77838: add max77838 regulator driver Ivaylo Ivanov
@ 2025-09-14 13:02 ` Ivaylo Ivanov
2025-09-14 15:10 ` Igor Belwon
2025-09-15 17:43 ` Conor Dooley
2025-09-14 13:02 ` [PATCH v1 2/2] regulator: max77838: add max77838 regulator driver Ivaylo Ivanov
2025-09-16 14:03 ` [PATCH v1 0/2] " Mark Brown
2 siblings, 2 replies; 7+ messages in thread
From: Ivaylo Ivanov @ 2025-09-14 13:02 UTC (permalink / raw)
To: Krzysztof Kozlowski, Rob Herring, Liam Girdwood, Mark Brown
Cc: linux-samsung-soc, devicetree, linux-kernel
The max77838 is a pmic, containing a BUCK regulator and 4 LDOs. It's
primarily used in the Samsung Galaxy S7 lineup and is accessed over I2C.
Document it.
Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
---
.../bindings/regulator/maxim,max77838.yaml | 68 +++++++++++++++++++
MAINTAINERS | 6 ++
2 files changed, 74 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max77838.yaml
diff --git a/Documentation/devicetree/bindings/regulator/maxim,max77838.yaml b/Documentation/devicetree/bindings/regulator/maxim,max77838.yaml
new file mode 100644
index 000000000..bed36af54
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/maxim,max77838.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/maxim,max77838.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim Integrated MAX77838 PMIC
+
+maintainers:
+ - Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
+
+properties:
+ $nodename:
+ pattern: "pmic@[0-9a-f]{1,2}"
+ compatible:
+ enum:
+ - maxim,max77838
+
+ reg:
+ maxItems: 1
+
+ regulators:
+ type: object
+ $ref: regulator.yaml#
+ description: |
+ list of regulators provided by this controller, must be named
+ after their hardware counterparts ldo[1-4] and buck
+
+ properties:
+ buck:
+ type: object
+ $ref: regulator.yaml#
+ unevaluatedProperties: false
+
+ patternProperties:
+ "^ldo([1-4])$":
+ type: object
+ $ref: regulator.yaml#
+ unevaluatedProperties: false
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - regulators
+
+additionalProperties: false
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pmic@60 {
+ compatible = "maxim,max77838";
+ reg = <0x60>;
+
+ regulators {
+ ldo2 {
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ };
+ };
+ };
+ };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index fed6cd812..a4916a178 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15061,6 +15061,12 @@ F: Documentation/devicetree/bindings/*/*max77802.yaml
F: drivers/regulator/max77802-regulator.c
F: include/dt-bindings/*/*max77802.h
+MAXIM MAX77838 PMIC REGULATOR DEVICE DRIVER
+M: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
+L: linux-kernel@vger.kernel.org
+S: Maintained
+F: Documentation/devicetree/bindings/regulator/maxim,max77838.yaml
+
MAXIM MAX77976 BATTERY CHARGER
M: Luca Ceresoli <luca@lucaceresoli.net>
S: Supported
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 2/2] regulator: max77838: add max77838 regulator driver
2025-09-14 13:02 [PATCH v1 0/2] regulator: max77838: add max77838 regulator driver Ivaylo Ivanov
2025-09-14 13:02 ` [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic Ivaylo Ivanov
@ 2025-09-14 13:02 ` Ivaylo Ivanov
2025-09-14 15:25 ` Igor Belwon
2025-09-16 14:03 ` [PATCH v1 0/2] " Mark Brown
2 siblings, 1 reply; 7+ messages in thread
From: Ivaylo Ivanov @ 2025-09-14 13:02 UTC (permalink / raw)
To: Krzysztof Kozlowski, Rob Herring, Liam Girdwood, Mark Brown
Cc: linux-samsung-soc, devicetree, linux-kernel
The max77838 PMIC contains a BUCK regulator and 4 LDOs. It's primarily
used in the Samsung Galaxy S7 lineup and is accessed over I2C.
Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
---
MAINTAINERS | 1 +
drivers/regulator/Kconfig | 8 +
drivers/regulator/Makefile | 1 +
drivers/regulator/max77838-regulator.c | 221 +++++++++++++++++++++++++
4 files changed, 231 insertions(+)
create mode 100644 drivers/regulator/max77838-regulator.c
diff --git a/MAINTAINERS b/MAINTAINERS
index a4916a178..276374ba7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15066,6 +15066,7 @@ M: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
L: linux-kernel@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/regulator/maxim,max77838.yaml
+F: drivers/regulator/max77838-regulator.c
MAXIM MAX77976 BATTERY CHARGER
M: Luca Ceresoli <luca@lucaceresoli.net>
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 41b56b647..18601bdc0 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -777,6 +777,14 @@ config REGULATOR_MAX77826
It includes support for control of output voltage. This
regulator is found on the Samsung Galaxy S5 (klte) smartphone.
+config REGULATOR_MAX77838
+ tristate "Maxim 77838 regulator"
+ depends on REGMAP_I2C
+ help
+ This driver controls a Maxim 77838 regulator via I2C bus.
+ The regulator include 4 LDOs and a BUCK regulator. It's
+ present on the Samsung Galaxy S7 lineup of smartphones.
+
config REGULATOR_MC13XXX_CORE
tristate
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index be98b29d6..0622e9de6 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -92,6 +92,7 @@ obj-$(CONFIG_REGULATOR_MAX77686) += max77686-regulator.o
obj-$(CONFIG_REGULATOR_MAX77693) += max77693-regulator.o
obj-$(CONFIG_REGULATOR_MAX77802) += max77802-regulator.o
obj-$(CONFIG_REGULATOR_MAX77826) += max77826-regulator.o
+obj-$(CONFIG_REGULATOR_MAX77838) += max77838-regulator.o
obj-$(CONFIG_REGULATOR_MAX77857) += max77857-regulator.o
obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
diff --git a/drivers/regulator/max77838-regulator.c b/drivers/regulator/max77838-regulator.c
new file mode 100644
index 000000000..9faddbfd2
--- /dev/null
+++ b/drivers/regulator/max77838-regulator.c
@@ -0,0 +1,221 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+//
+// regulator driver for Maxim MAX77838
+//
+// based on max77826-regulator.c
+//
+// Copyright (c) 2025, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+
+enum max77838_registers {
+ MAX77838_REG_DEVICE_ID = 0x00,
+ MAX77838_REG_TOPSYS_STAT,
+ MAX77838_REG_STAT,
+ MAX77838_REG_EN,
+ MAX77838_REG_GPIO_PD_CTRL,
+ MAX77838_REG_UVLO_CFG1,
+ /* 0x06 - 0x0B: reserved */
+ MAX77838_REG_I2C_CFG = 0x0C,
+ /* 0x0D - 0x0F: reserved */
+ MAX77838_REG_LDO1_CFG = 0x10,
+ MAX77838_REG_LDO2_CFG,
+ MAX77838_REG_LDO3_CFG,
+ MAX77838_REG_LDO4_CFG,
+ /* 0x14 - 0x1F: reserved */
+ MAX77838_REG_BUCK_CFG1 = 0x20,
+ MAX77838_REG_BUCK_VOUT,
+};
+
+enum max77838_regulators {
+ MAX77838_LDO1 = 0,
+ MAX77838_LDO2,
+ MAX77838_LDO3,
+ MAX77838_LDO4,
+ MAX77838_BUCK,
+ MAX77838_MAX_REGULATORS,
+};
+
+#define MAX77838_MASK_LDO 0x7f
+#define MAX77838_MASK_BUCK 0xff
+
+#define MAX77838_LDO1_EN BIT(0)
+#define MAX77838_LDO2_EN BIT(1)
+#define MAX77838_LDO3_EN BIT(2)
+#define MAX77838_LDO4_EN BIT(3)
+#define MAX77838_BUCK_EN BIT(4)
+
+#define MAX77838_BUCK_AD BIT(3)
+#define MAX77838_LDO_AD BIT(7)
+
+#define MAX77838_LDO_VOLT_MIN 600000
+#define MAX77838_LDO_VOLT_MAX 3775000
+#define MAX77838_LDO_VOLT_STEP 25000
+
+#define MAX77838_BUCK_VOLT_MIN 500000
+#define MAX77838_BUCK_VOLT_MAX 2093750
+#define MAX77838_BUCK_VOLT_STEP 6250
+
+#define MAX77838_VOLT_RANGE(_type) \
+ ((MAX77838_ ## _type ## _VOLT_MAX - \
+ MAX77838_ ## _type ## _VOLT_MIN) / \
+ MAX77838_ ## _type ## _VOLT_STEP + 1)
+
+#define MAX77838_LDO(_id) \
+ [MAX77838_LDO ## _id] = { \
+ .id = MAX77838_LDO ## _id, \
+ .name = "ldo"#_id, \
+ .of_match = of_match_ptr("ldo"#_id), \
+ .regulators_node = "regulators", \
+ .ops = &max77838_regulator_ops, \
+ .min_uV = MAX77838_LDO_VOLT_MIN, \
+ .uV_step = MAX77838_LDO_VOLT_STEP, \
+ .n_voltages = MAX77838_VOLT_RANGE(LDO), \
+ .enable_reg = MAX77838_REG_EN, \
+ .enable_mask = MAX77838_LDO ## _id ## _EN, \
+ .vsel_reg = MAX77838_REG_LDO ## _id ## _CFG, \
+ .vsel_mask = MAX77838_MASK_LDO, \
+ .active_discharge_off = 0, \
+ .active_discharge_on = MAX77838_LDO_AD, \
+ .active_discharge_mask = MAX77838_LDO_AD, \
+ .active_discharge_reg = MAX77838_REG_LDO ## _id ## _CFG, \
+ .owner = THIS_MODULE, \
+ }
+
+#define MAX77838_BUCK_DESC \
+ [MAX77838_BUCK] = { \
+ .id = MAX77838_BUCK, \
+ .name = "buck", \
+ .of_match = of_match_ptr("buck"), \
+ .regulators_node = "regulators", \
+ .ops = &max77838_regulator_ops, \
+ .min_uV = MAX77838_BUCK_VOLT_MIN, \
+ .uV_step = MAX77838_BUCK_VOLT_STEP, \
+ .n_voltages = MAX77838_VOLT_RANGE(BUCK), \
+ .enable_reg = MAX77838_REG_EN, \
+ .enable_mask = MAX77838_BUCK_EN, \
+ .vsel_reg = MAX77838_REG_BUCK_VOUT, \
+ .vsel_mask = MAX77838_MASK_BUCK, \
+ .active_discharge_off = 0, \
+ .active_discharge_on = MAX77838_BUCK_AD, \
+ .active_discharge_mask = MAX77838_BUCK_AD, \
+ .active_discharge_reg = MAX77838_REG_BUCK_CFG1, \
+ .owner = THIS_MODULE, \
+ }
+
+struct max77838_regulator_info {
+ struct regmap *regmap;
+};
+
+static const struct regmap_config max77838_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = MAX77838_REG_BUCK_VOUT,
+};
+
+static const struct regulator_ops max77838_regulator_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+};
+
+static const struct regulator_desc max77838_regulators_desc[] = {
+ MAX77838_LDO(1),
+ MAX77838_LDO(2),
+ MAX77838_LDO(3),
+ MAX77838_LDO(4),
+ MAX77838_BUCK_DESC,
+};
+
+static int max77838_read_device_id(struct regmap *regmap, struct device *dev)
+{
+ unsigned int device_id;
+ int ret;
+
+ ret = regmap_read(regmap, MAX77838_REG_DEVICE_ID, &device_id);
+ if (!ret)
+ dev_dbg(dev, "DEVICE_ID: 0x%x\n", device_id);
+
+ return ret;
+}
+
+static int max77838_i2c_probe(struct i2c_client *client)
+{
+ struct device *dev = &client->dev;
+ struct max77838_regulator_info *info;
+ struct regulator_config config = {};
+ struct regulator_dev *rdev;
+ struct regmap *regmap;
+ int i;
+
+ info = devm_kzalloc(dev, sizeof(struct max77838_regulator_info),
+ GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ regmap = devm_regmap_init_i2c(client, &max77838_regmap_config);
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "Failed to allocate regmap!\n");
+ return PTR_ERR(regmap);
+ }
+
+ info->regmap = regmap;
+ i2c_set_clientdata(client, info);
+
+ config.dev = dev;
+ config.regmap = regmap;
+ config.driver_data = info;
+
+ for (i = 0; i < MAX77838_MAX_REGULATORS; i++) {
+ rdev = devm_regulator_register(dev,
+ &max77838_regulators_desc[i],
+ &config);
+ if (IS_ERR(rdev)) {
+ dev_err(dev, "Failed to register regulator!\n");
+ return PTR_ERR(rdev);
+ }
+ }
+
+ return max77838_read_device_id(regmap, dev);
+}
+
+static const struct of_device_id __maybe_unused max77838_of_match[] = {
+ { .compatible = "maxim,max77838" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, max77838_of_match);
+
+static const struct i2c_device_id max77838_id[] = {
+ { "max77838-regulator" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(i2c, max77838_id);
+
+static struct i2c_driver max77838_regulator_driver = {
+ .driver = {
+ .name = "max77838",
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ .of_match_table = of_match_ptr(max77838_of_match),
+ },
+ .probe = max77838_i2c_probe,
+ .id_table = max77838_id,
+};
+module_i2c_driver(max77838_regulator_driver);
+
+MODULE_AUTHOR("Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>");
+MODULE_DESCRIPTION("MAX77838 PMIC regulator driver");
+MODULE_LICENSE("GPL");
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic
2025-09-14 13:02 ` [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic Ivaylo Ivanov
@ 2025-09-14 15:10 ` Igor Belwon
2025-09-15 17:43 ` Conor Dooley
1 sibling, 0 replies; 7+ messages in thread
From: Igor Belwon @ 2025-09-14 15:10 UTC (permalink / raw)
To: Ivaylo Ivanov, Krzysztof Kozlowski, Rob Herring, Liam Girdwood,
Mark Brown
Cc: linux-samsung-soc, devicetree, linux-kernel
On Sun Sep 14, 2025 at 3:02 PM CEST, Ivaylo Ivanov wrote:
> The max77838 is a pmic, containing a BUCK regulator and 4 LDOs. It's
> primarily used in the Samsung Galaxy S7 lineup and is accessed over I2C.
> Document it.
>
> Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
> ---
Hi Ivaylo,
Reviewed-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
Kind regards,
Igor
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 2/2] regulator: max77838: add max77838 regulator driver
2025-09-14 13:02 ` [PATCH v1 2/2] regulator: max77838: add max77838 regulator driver Ivaylo Ivanov
@ 2025-09-14 15:25 ` Igor Belwon
0 siblings, 0 replies; 7+ messages in thread
From: Igor Belwon @ 2025-09-14 15:25 UTC (permalink / raw)
To: Ivaylo Ivanov, Krzysztof Kozlowski, Rob Herring, Liam Girdwood,
Mark Brown
Cc: linux-samsung-soc, devicetree, linux-kernel
Hi Ivaylo,
On Sun Sep 14, 2025 at 3:02 PM CEST, Ivaylo Ivanov wrote:
> The max77838 PMIC contains a BUCK regulator and 4 LDOs. It's primarily
> used in the Samsung Galaxy S7 lineup and is accessed over I2C.
>
> Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
> ---
> MAINTAINERS | 1 +
> drivers/regulator/Kconfig | 8 +
> drivers/regulator/Makefile | 1 +
> drivers/regulator/max77838-regulator.c | 221 +++++++++++++++++++++++++
> 4 files changed, 231 insertions(+)
> create mode 100644 drivers/regulator/max77838-regulator.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a4916a178..276374ba7 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -15066,6 +15066,7 @@ M: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
> L: linux-kernel@vger.kernel.org
> S: Maintained
> F: Documentation/devicetree/bindings/regulator/maxim,max77838.yaml
> +F: drivers/regulator/max77838-regulator.c
>
> MAXIM MAX77976 BATTERY CHARGER
> M: Luca Ceresoli <luca@lucaceresoli.net>
> diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
> index 41b56b647..18601bdc0 100644
> --- a/drivers/regulator/Kconfig
> +++ b/drivers/regulator/Kconfig
> @@ -777,6 +777,14 @@ config REGULATOR_MAX77826
> It includes support for control of output voltage. This
> regulator is found on the Samsung Galaxy S5 (klte) smartphone.
>
> +config REGULATOR_MAX77838
> + tristate "Maxim 77838 regulator"
> + depends on REGMAP_I2C
REGMAP_I2C should be selected by the driver.
The driver should depend on I2C.
> + help
> + This driver controls a Maxim 77838 regulator via I2C bus.
> + The regulator include 4 LDOs and a BUCK regulator. It's
> + present on the Samsung Galaxy S7 lineup of smartphones.
> +
> config REGULATOR_MC13XXX_CORE
> tristate
>
> diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
> index be98b29d6..0622e9de6 100644
> --- a/drivers/regulator/Makefile
> +++ b/drivers/regulator/Makefile
> @@ -92,6 +92,7 @@ obj-$(CONFIG_REGULATOR_MAX77686) += max77686-regulator.o
> obj-$(CONFIG_REGULATOR_MAX77693) += max77693-regulator.o
> obj-$(CONFIG_REGULATOR_MAX77802) += max77802-regulator.o
> obj-$(CONFIG_REGULATOR_MAX77826) += max77826-regulator.o
> +obj-$(CONFIG_REGULATOR_MAX77838) += max77838-regulator.o
> obj-$(CONFIG_REGULATOR_MAX77857) += max77857-regulator.o
> obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
> obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
> diff --git a/drivers/regulator/max77838-regulator.c b/drivers/regulator/max77838-regulator.c
> new file mode 100644
> index 000000000..9faddbfd2
> --- /dev/null
> +++ b/drivers/regulator/max77838-regulator.c
> @@ -0,0 +1,221 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +//
> +// regulator driver for Maxim MAX77838
> +//
> +// based on max77826-regulator.c
> +//
> +// Copyright (c) 2025, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/err.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/regulator/driver.h>
> +#include <linux/regulator/of_regulator.h>
> +#include <linux/i2c.h>
> +#include <linux/regmap.h>
> +
> +enum max77838_registers {
> + MAX77838_REG_DEVICE_ID = 0x00,
> + MAX77838_REG_TOPSYS_STAT,
> + MAX77838_REG_STAT,
> + MAX77838_REG_EN,
> + MAX77838_REG_GPIO_PD_CTRL,
> + MAX77838_REG_UVLO_CFG1,
> + /* 0x06 - 0x0B: reserved */
> + MAX77838_REG_I2C_CFG = 0x0C,
> + /* 0x0D - 0x0F: reserved */
> + MAX77838_REG_LDO1_CFG = 0x10,
> + MAX77838_REG_LDO2_CFG,
> + MAX77838_REG_LDO3_CFG,
> + MAX77838_REG_LDO4_CFG,
> + /* 0x14 - 0x1F: reserved */
> + MAX77838_REG_BUCK_CFG1 = 0x20,
> + MAX77838_REG_BUCK_VOUT,
> +};
> +
> +enum max77838_regulators {
> + MAX77838_LDO1 = 0,
> + MAX77838_LDO2,
> + MAX77838_LDO3,
> + MAX77838_LDO4,
> + MAX77838_BUCK,
> + MAX77838_MAX_REGULATORS,
> +};
> +
> +#define MAX77838_MASK_LDO 0x7f
> +#define MAX77838_MASK_BUCK 0xff
> +
> +#define MAX77838_LDO1_EN BIT(0)
> +#define MAX77838_LDO2_EN BIT(1)
> +#define MAX77838_LDO3_EN BIT(2)
> +#define MAX77838_LDO4_EN BIT(3)
> +#define MAX77838_BUCK_EN BIT(4)
> +
> +#define MAX77838_BUCK_AD BIT(3)
> +#define MAX77838_LDO_AD BIT(7)
> +
> +#define MAX77838_LDO_VOLT_MIN 600000
> +#define MAX77838_LDO_VOLT_MAX 3775000
> +#define MAX77838_LDO_VOLT_STEP 25000
> +
> +#define MAX77838_BUCK_VOLT_MIN 500000
> +#define MAX77838_BUCK_VOLT_MAX 2093750
> +#define MAX77838_BUCK_VOLT_STEP 6250
> +
> +#define MAX77838_VOLT_RANGE(_type) \
> + ((MAX77838_ ## _type ## _VOLT_MAX - \
> + MAX77838_ ## _type ## _VOLT_MIN) / \
> + MAX77838_ ## _type ## _VOLT_STEP + 1)
> +
> +#define MAX77838_LDO(_id) \
> + [MAX77838_LDO ## _id] = { \
> + .id = MAX77838_LDO ## _id, \
> + .name = "ldo"#_id, \
> + .of_match = of_match_ptr("ldo"#_id), \
> + .regulators_node = "regulators", \
> + .ops = &max77838_regulator_ops, \
> + .min_uV = MAX77838_LDO_VOLT_MIN, \
> + .uV_step = MAX77838_LDO_VOLT_STEP, \
> + .n_voltages = MAX77838_VOLT_RANGE(LDO), \
> + .enable_reg = MAX77838_REG_EN, \
> + .enable_mask = MAX77838_LDO ## _id ## _EN, \
> + .vsel_reg = MAX77838_REG_LDO ## _id ## _CFG, \
> + .vsel_mask = MAX77838_MASK_LDO, \
> + .active_discharge_off = 0, \
> + .active_discharge_on = MAX77838_LDO_AD, \
> + .active_discharge_mask = MAX77838_LDO_AD, \
> + .active_discharge_reg = MAX77838_REG_LDO ## _id ## _CFG, \
> + .owner = THIS_MODULE, \
> + }
> +
> +#define MAX77838_BUCK_DESC \
> + [MAX77838_BUCK] = { \
> + .id = MAX77838_BUCK, \
> + .name = "buck", \
> + .of_match = of_match_ptr("buck"), \
> + .regulators_node = "regulators", \
> + .ops = &max77838_regulator_ops, \
> + .min_uV = MAX77838_BUCK_VOLT_MIN, \
> + .uV_step = MAX77838_BUCK_VOLT_STEP, \
> + .n_voltages = MAX77838_VOLT_RANGE(BUCK), \
> + .enable_reg = MAX77838_REG_EN, \
> + .enable_mask = MAX77838_BUCK_EN, \
> + .vsel_reg = MAX77838_REG_BUCK_VOUT, \
> + .vsel_mask = MAX77838_MASK_BUCK, \
> + .active_discharge_off = 0, \
> + .active_discharge_on = MAX77838_BUCK_AD, \
> + .active_discharge_mask = MAX77838_BUCK_AD, \
> + .active_discharge_reg = MAX77838_REG_BUCK_CFG1, \
> + .owner = THIS_MODULE, \
> + }
> +
nit: Could you make the indentation between VOLT_RANGE, LDO and
BUCK_DESC consistent?
> +struct max77838_regulator_info {
> + struct regmap *regmap;
> +};
> +
> +static const struct regmap_config max77838_regmap_config = {
> + .reg_bits = 8,
> + .val_bits = 8,
> + .max_register = MAX77838_REG_BUCK_VOUT,
> +};
> +
> +static const struct regulator_ops max77838_regulator_ops = {
> + .enable = regulator_enable_regmap,
> + .disable = regulator_disable_regmap,
> + .is_enabled = regulator_is_enabled_regmap,
> + .list_voltage = regulator_list_voltage_linear,
> + .map_voltage = regulator_map_voltage_linear,
> + .get_voltage_sel = regulator_get_voltage_sel_regmap,
> + .set_voltage_sel = regulator_set_voltage_sel_regmap,
> + .set_active_discharge = regulator_set_active_discharge_regmap,
> +};
> +
> +static const struct regulator_desc max77838_regulators_desc[] = {
> + MAX77838_LDO(1),
> + MAX77838_LDO(2),
> + MAX77838_LDO(3),
> + MAX77838_LDO(4),
> + MAX77838_BUCK_DESC,
> +};
> +
> +static int max77838_read_device_id(struct regmap *regmap, struct device *dev)
> +{
> + unsigned int device_id;
> + int ret;
> +
> + ret = regmap_read(regmap, MAX77838_REG_DEVICE_ID, &device_id);
> + if (!ret)
> + dev_dbg(dev, "DEVICE_ID: 0x%x\n", device_id);
> +
> + return ret;
> +}
> +
> +static int max77838_i2c_probe(struct i2c_client *client)
> +{
> + struct device *dev = &client->dev;
> + struct max77838_regulator_info *info;
> + struct regulator_config config = {};
> + struct regulator_dev *rdev;
> + struct regmap *regmap;
> + int i;
> +
> + info = devm_kzalloc(dev, sizeof(struct max77838_regulator_info),
> + GFP_KERNEL);
> + if (!info)
> + return -ENOMEM;
> +
> + regmap = devm_regmap_init_i2c(client, &max77838_regmap_config);
> + if (IS_ERR(regmap)) {
> + dev_err(dev, "Failed to allocate regmap!\n");
> + return PTR_ERR(regmap);
> + }
> +
> + info->regmap = regmap;
> + i2c_set_clientdata(client, info);
> +
> + config.dev = dev;
> + config.regmap = regmap;
> + config.driver_data = info;
> +
> + for (i = 0; i < MAX77838_MAX_REGULATORS; i++) {
> + rdev = devm_regulator_register(dev,
> + &max77838_regulators_desc[i],
> + &config);
> + if (IS_ERR(rdev)) {
> + dev_err(dev, "Failed to register regulator!\n");
> + return PTR_ERR(rdev);
> + }
> + }
> +
> + return max77838_read_device_id(regmap, dev);
> +}
> +
> +static const struct of_device_id __maybe_unused max77838_of_match[] = {
> + { .compatible = "maxim,max77838" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, max77838_of_match);
> +
> +static const struct i2c_device_id max77838_id[] = {
> + { "max77838-regulator" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(i2c, max77838_id);
> +
> +static struct i2c_driver max77838_regulator_driver = {
> + .driver = {
> + .name = "max77838",
> + .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> + .of_match_table = of_match_ptr(max77838_of_match),
> + },
> + .probe = max77838_i2c_probe,
> + .id_table = max77838_id,
> +};
> +module_i2c_driver(max77838_regulator_driver);
> +
> +MODULE_AUTHOR("Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>");
> +MODULE_DESCRIPTION("MAX77838 PMIC regulator driver");
> +MODULE_LICENSE("GPL");
Kind regards,
Igor
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic
2025-09-14 13:02 ` [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic Ivaylo Ivanov
2025-09-14 15:10 ` Igor Belwon
@ 2025-09-15 17:43 ` Conor Dooley
1 sibling, 0 replies; 7+ messages in thread
From: Conor Dooley @ 2025-09-15 17:43 UTC (permalink / raw)
To: Ivaylo Ivanov
Cc: Krzysztof Kozlowski, Rob Herring, Liam Girdwood, Mark Brown,
linux-samsung-soc, devicetree, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 52 bytes --]
Acked-by: Conor Dooley <conor.dooley@microchip.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 0/2] regulator: max77838: add max77838 regulator driver
2025-09-14 13:02 [PATCH v1 0/2] regulator: max77838: add max77838 regulator driver Ivaylo Ivanov
2025-09-14 13:02 ` [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic Ivaylo Ivanov
2025-09-14 13:02 ` [PATCH v1 2/2] regulator: max77838: add max77838 regulator driver Ivaylo Ivanov
@ 2025-09-16 14:03 ` Mark Brown
2 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2025-09-16 14:03 UTC (permalink / raw)
To: Krzysztof Kozlowski, Rob Herring, Liam Girdwood, Ivaylo Ivanov
Cc: linux-samsung-soc, devicetree, linux-kernel
On Sun, 14 Sep 2025 16:02:28 +0300, Ivaylo Ivanov wrote:
> Hey folks,
>
> This patchset adds support for the max77838 PMIC. It's used on the Galaxy
> S7 lineup of phones, and provides regulators for the display.
>
> Best regards,
> Ivaylo
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/2] dt-bindings: regulator: document max77838 pmic
commit: 0f101028407605c7b7cea53946ee4d25f82cfb6c
[2/2] regulator: max77838: add max77838 regulator driver
commit: 41b5c85ba94057c955f0f6348c551093917da06d
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-09-16 14:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-14 13:02 [PATCH v1 0/2] regulator: max77838: add max77838 regulator driver Ivaylo Ivanov
2025-09-14 13:02 ` [PATCH v1 1/2] dt-bindings: regulator: document max77838 pmic Ivaylo Ivanov
2025-09-14 15:10 ` Igor Belwon
2025-09-15 17:43 ` Conor Dooley
2025-09-14 13:02 ` [PATCH v1 2/2] regulator: max77838: add max77838 regulator driver Ivaylo Ivanov
2025-09-14 15:25 ` Igor Belwon
2025-09-16 14:03 ` [PATCH v1 0/2] " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox