Re: [PATCH v7 3/5] regulator: add regulators driver for Marvell 88PM886 PMIC

2024-06-26 Thread Mark Brown
On Fri, May 31, 2024 at 07:34:58PM +0200, Karel Balej wrote:
> Support the LDO and buck regulators of the Marvell 88PM886 PMIC.

Reviewed-by: Mark Brown 


signature.asc
Description: PGP signature


Re: [PATCH v7 3/5] regulator: add regulators driver for Marvell 88PM886 PMIC

2024-06-13 Thread Lee Jones
On Fri, 31 May 2024, Karel Balej wrote:

> Support the LDO and buck regulators of the Marvell 88PM886 PMIC.
> 
> Signed-off-by: Karel Balej 
> ---
> 
> Notes:
> v7:
> - Address Mark's feedback:
>   - Drop get_current_limit op, max_uA values and thus unneeded struct
> pm886_regulator and adapt the code accordingly.
> v6:
> - Remove all definitions (now present in the header).
> v5:
> - Add remaining regulators.
> - Clean up includes.
> - Address Mark's feedback:
>   - Use dedicated regmap config.
> RFC v4:
> - Initialize regulators regmap in the regulators driver.
> - Register all regulators at once.
> - Drop regulator IDs.
> - Add missing '\n' to dev_err_probe message.
> - Fix includes.
> - Add ID table.
> RFC v3:
> - Do not have a variable for each regulator -- define them all in the
>   pm886_regulators array.
> - Use new regulators regmap index name.
> - Use dev_err_probe.
> RFC v2:
> - Drop of_compatible and related code.
> - Drop unused include.
> - Remove some abstraction: use only one regmap for all regulators and
>   only mention 88PM886 in Kconfig description.
> - Reword commit message.
> 
>  drivers/regulator/88pm886-regulator.c | 392 ++
>  drivers/regulator/Kconfig |   6 +
>  drivers/regulator/Makefile|   1 +
>  3 files changed, 399 insertions(+)
>  create mode 100644 drivers/regulator/88pm886-regulator.c

I'm fine with this set - just waiting for Mark to review.

-- 
Lee Jones [李琼斯]



[PATCH v7 3/5] regulator: add regulators driver for Marvell 88PM886 PMIC

2024-05-31 Thread Karel Balej
Support the LDO and buck regulators of the Marvell 88PM886 PMIC.

Signed-off-by: Karel Balej 
---

Notes:
v7:
- Address Mark's feedback:
  - Drop get_current_limit op, max_uA values and thus unneeded struct
pm886_regulator and adapt the code accordingly.
v6:
- Remove all definitions (now present in the header).
v5:
- Add remaining regulators.
- Clean up includes.
- Address Mark's feedback:
  - Use dedicated regmap config.
RFC v4:
- Initialize regulators regmap in the regulators driver.
- Register all regulators at once.
- Drop regulator IDs.
- Add missing '\n' to dev_err_probe message.
- Fix includes.
- Add ID table.
RFC v3:
- Do not have a variable for each regulator -- define them all in the
  pm886_regulators array.
- Use new regulators regmap index name.
- Use dev_err_probe.
RFC v2:
- Drop of_compatible and related code.
- Drop unused include.
- Remove some abstraction: use only one regmap for all regulators and
  only mention 88PM886 in Kconfig description.
- Reword commit message.

 drivers/regulator/88pm886-regulator.c | 392 ++
 drivers/regulator/Kconfig |   6 +
 drivers/regulator/Makefile|   1 +
 3 files changed, 399 insertions(+)
 create mode 100644 drivers/regulator/88pm886-regulator.c

diff --git a/drivers/regulator/88pm886-regulator.c 
b/drivers/regulator/88pm886-regulator.c
new file mode 100644
index ..a38bd4f312b7
--- /dev/null
+++ b/drivers/regulator/88pm886-regulator.c
@@ -0,0 +1,392 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const struct regmap_config pm886_regulator_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = PM886_REG_BUCK5_VOUT,
+};
+
+static const struct regulator_ops pm886_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 struct regulator_ops pm886_buck_ops = {
+   .list_voltage = regulator_list_voltage_linear_range,
+   .map_voltage = regulator_map_voltage_linear_range,
+   .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 pm886_ldo_volt_table1[] = {
+   170, 180, 190, 250, 280, 290, 310, 330,
+};
+
+static const unsigned int pm886_ldo_volt_table2[] = {
+   120, 125, 170, 180, 185, 190, 250, 260,
+   270, 275, 280, 285, 290, 300, 310, 330,
+};
+
+static const unsigned int pm886_ldo_volt_table3[] = {
+   170, 180, 190, 200, 210, 250, 270, 280,
+};
+
+static const struct linear_range pm886_buck_volt_ranges1[] = {
+   REGULATOR_LINEAR_RANGE(60, 0, 79, 12500),
+   REGULATOR_LINEAR_RANGE(160, 80, 84, 5),
+};
+
+static const struct linear_range pm886_buck_volt_ranges2[] = {
+   REGULATOR_LINEAR_RANGE(60, 0, 79, 12500),
+   REGULATOR_LINEAR_RANGE(160, 80, 114, 5),
+};
+
+static struct regulator_desc pm886_regulators[] = {
+   {
+   .name = "LDO1",
+   .regulators_node = "regulators",
+   .of_match = "ldo1",
+   .ops = _ldo_ops,
+   .type = REGULATOR_VOLTAGE,
+   .enable_reg = PM886_REG_LDO_EN1,
+   .enable_mask = BIT(0),
+   .volt_table = pm886_ldo_volt_table1,
+   .n_voltages = ARRAY_SIZE(pm886_ldo_volt_table1),
+   .vsel_reg = PM886_REG_LDO1_VOUT,
+   .vsel_mask = PM886_LDO_VSEL_MASK,
+   },
+   {
+   .name = "LDO2",
+   .regulators_node = "regulators",
+   .of_match = "ldo2",
+   .ops = _ldo_ops,
+   .type = REGULATOR_VOLTAGE,
+   .enable_reg = PM886_REG_LDO_EN1,
+   .enable_mask = BIT(1),
+   .volt_table = pm886_ldo_volt_table1,
+   .n_voltages = ARRAY_SIZE(pm886_ldo_volt_table1),
+   .vsel_reg = PM886_REG_LDO2_VOUT,
+   .vsel_mask = PM886_LDO_VSEL_MASK,
+   },
+   {
+   .name = "LDO3",
+   .regulators_node = "regulators",
+   .of_match = "ldo3",
+   .ops = _ldo_ops,
+   .type = REGULATOR_VOLTAGE,
+   .enable_reg = PM886_REG_LDO_EN1,
+   .enable_mask =