aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml6
-rw-r--r--Documentation/devicetree/bindings/regulator/richtek,rt4831-regulator.yaml35
-rw-r--r--drivers/regulator/Kconfig19
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/atc260x-regulator.c539
-rw-r--r--drivers/regulator/bd718x7-regulator.c57
-rw-r--r--drivers/regulator/core.c6
-rw-r--r--drivers/regulator/pf8x00-regulator.c8
-rw-r--r--drivers/regulator/rt4831-regulator.c198
-rw-r--r--lib/linear_ranges.c8
10 files changed, 867 insertions, 11 deletions
diff --git a/Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml b/Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
index a6c259ce9785..956156fe52a3 100644
--- a/Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
+++ b/Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
@@ -19,7 +19,9 @@ description: |
properties:
compatible:
enum:
- - nxp,pf8x00
+ - nxp,pf8100
+ - nxp,pf8121a
+ - nxp,pf8200
reg:
maxItems: 1
@@ -118,7 +120,7 @@ examples:
#size-cells = <0>;
pmic@8 {
- compatible = "nxp,pf8x00";
+ compatible = "nxp,pf8100";
reg = <0x08>;
regulators {
diff --git a/Documentation/devicetree/bindings/regulator/richtek,rt4831-regulator.yaml b/Documentation/devicetree/bindings/regulator/richtek,rt4831-regulator.yaml
new file mode 100644
index 000000000000..d9c23333e157
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/richtek,rt4831-regulator.yaml
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/richtek,rt4831-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT4831 Display Bias Voltage Regulator
+
+maintainers:
+ - ChiYuan Huang <cy_huang@richtek.com>
+
+description: |
+ RT4831 is a multifunctional device that can provide power to the LCD display
+ and LCD backlight.
+
+ For Display Bias Voltage DSVP and DSVN, the output range is about 4V to 6.5V.
+ It is sufficient to meet the current LCD power requirement.
+
+ DSVLCM is a boost regulator in IC internal as DSVP and DSVN input power.
+ Its voltage should be configured above 0.15V to 0.2V gap larger than the
+ voltage needed for DSVP and DSVN. Too much voltage gap could improve the
+ voltage drop from the heavy loading scenario. But it also make the power
+ efficiency worse. It's a trade-off.
+
+ Datasheet is available at
+ https://www.richtek.com/assets/product_file/RT4831A/DS4831A-05.pdf
+
+patternProperties:
+ "^DSV(LCM|P|N)$":
+ type: object
+ $ref: regulator.yaml#
+ description:
+ Properties for single Display Bias Voltage regulator.
+
+additionalProperties: false
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 53fa84f4d1e1..a7fbb9a87413 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -179,6 +179,14 @@ config REGULATOR_AS3722
AS3722 PMIC. This will enable support for all the software
controllable DCDC/LDO regulators.
+config REGULATOR_ATC260X
+ tristate "Actions Semi ATC260x PMIC Regulators"
+ depends on MFD_ATC260X
+ help
+ This driver provides support for the voltage regulators on the
+ ATC260x PMICs. This will enable support for all the software
+ controllable DCDC/LDO regulators.
+
config REGULATOR_AXP20X
tristate "X-POWERS AXP20X PMIC Regulators"
depends on MFD_AXP20X
@@ -881,6 +889,7 @@ config REGULATOR_QCOM_RPM
config REGULATOR_QCOM_RPMH
tristate "Qualcomm Technologies, Inc. RPMh regulator driver"
depends on QCOM_RPMH || (QCOM_RPMH=n && COMPILE_TEST)
+ depends on QCOM_COMMAND_DB || !QCOM_COMMAND_DB
help
This driver supports control of PMIC regulators via the RPMh hardware
block found on Qualcomm Technologies Inc. SoCs. RPMh regulator
@@ -968,6 +977,16 @@ config REGULATOR_RT4801
This adds support for voltage regulators in Richtek RT4801 Display Bias IC.
The device supports two regulators (DSVP/DSVN).
+config REGULATOR_RT4831
+ tristate "Richtek RT4831 DSV Regulators"
+ depends on MFD_RT4831
+ help
+ This adds support for voltage regulators in Richtek RT4831.
+ There are three regulators (VLCM/DSVP/DSVN).
+ VLCM is a virtual voltage input for DSVP/DSVN inside IC.
+ And DSVP/DSVN is the real Vout range from 4V to 6.5V.
+ It's common used to provide the power for the display panel.
+
config REGULATOR_RT5033
tristate "Richtek RT5033 Regulators"
depends on MFD_RT5033
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 680e539f6579..dec23fa5c5f2 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_REGULATOR_ARIZONA_MICSUPP) += arizona-micsupp.o
obj-$(CONFIG_REGULATOR_ARM_SCMI) += scmi-regulator.o
obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
+obj-$(CONFIG_REGULATOR_ATC260X) += atc260x-regulator.o
obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o
obj-$(CONFIG_REGULATOR_BD70528) += bd70528-regulator.o
@@ -118,6 +119,7 @@ obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o
obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o
obj-$(CONFIG_REGULATOR_ROHM) += rohm-regulator.o
obj-$(CONFIG_REGULATOR_RT4801) += rt4801-regulator.o
+obj-$(CONFIG_REGULATOR_RT4831) += rt4831-regulator.o
obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o
obj-$(CONFIG_REGULATOR_RTMV20) += rtmv20-regulator.o
obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
diff --git a/drivers/regulator/atc260x-regulator.c b/drivers/regulator/atc260x-regulator.c
new file mode 100644
index 000000000000..d8b429955d33
--- /dev/null
+++ b/drivers/regulator/atc260x-regulator.c
@@ -0,0 +1,539 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Regulator driver for ATC260x PMICs
+//
+// Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+// Copyright (C) 2020 Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
+
+#include <linux/mfd/atc260x/core.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+#include <linux/regulator/driver.h>
+
+struct atc260x_regulator_data {
+ int voltage_time_dcdc;
+ int voltage_time_ldo;
+};
+
+static const struct linear_range atc2603c_dcdc_voltage_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1300000, 0, 13, 50000),
+ REGULATOR_LINEAR_RANGE(1950000, 14, 15, 100000),
+};
+
+static const struct linear_range atc2609a_dcdc_voltage_ranges[] = {
+ REGULATOR_LINEAR_RANGE(600000, 0, 127, 6250),
+ REGULATOR_LINEAR_RANGE(1400000, 128, 232, 25000),
+};
+
+static const struct linear_range atc2609a_ldo_voltage_ranges0[] = {
+ REGULATOR_LINEAR_RANGE(700000, 0, 15, 100000),
+ REGULATOR_LINEAR_RANGE(2100000, 16, 28, 100000),
+};
+
+static const struct linear_range atc2609a_ldo_voltage_ranges1[] = {
+ REGULATOR_LINEAR_RANGE(850000, 0, 15, 100000),
+ REGULATOR_LINEAR_RANGE(2100000, 16, 27, 100000),
+};
+
+static const unsigned int atc260x_ldo_voltage_range_sel[] = {
+ 0x0, 0x1,
+};
+
+static int atc260x_dcdc_set_voltage_time_sel(struct regulator_dev *rdev,
+ unsigned int old_selector,
+ unsigned int new_selector)
+{
+ struct atc260x_regulator_data *data = rdev_get_drvdata(rdev);
+
+ if (new_selector > old_selector)
+ return data->voltage_time_dcdc;
+
+ return 0;
+}
+
+static int atc260x_ldo_set_voltage_time_sel(struct regulator_dev *rdev,
+ unsigned int old_selector,
+ unsigned int new_selector)
+{
+ struct atc260x_regulator_data *data = rdev_get_drvdata(rdev);
+
+ if (new_selector > old_selector)
+ return data->voltage_time_ldo;
+
+ return 0;
+}
+
+static const struct regulator_ops atc260x_dcdc_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_time_sel = atc260x_dcdc_set_voltage_time_sel,
+};
+
+static const struct regulator_ops atc260x_ldo_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
+};
+
+static const struct regulator_ops atc260x_ldo_bypass_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
+ .set_bypass = regulator_set_bypass_regmap,
+ .get_bypass = regulator_get_bypass_regmap,
+};
+
+static const struct regulator_ops atc260x_ldo_bypass_discharge_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
+ .set_bypass = regulator_set_bypass_regmap,
+ .get_bypass = regulator_get_bypass_regmap,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+};
+
+static const struct regulator_ops atc260x_dcdc_range_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear_range,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_time_sel = atc260x_dcdc_set_voltage_time_sel,
+};
+
+static const struct regulator_ops atc260x_ldo_range_pick_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_pickable_linear_range,
+ .set_voltage_sel = regulator_set_voltage_sel_pickable_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
+ .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
+};
+
+static const struct regulator_ops atc260x_dcdc_fixed_ops = {
+ .list_voltage = regulator_list_voltage_linear,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_time_sel = atc260x_dcdc_set_voltage_time_sel,
+};
+
+static const struct regulator_ops atc260x_ldo_fixed_ops = {
+ .list_voltage = regulator_list_voltage_linear,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
+};
+
+static const struct regulator_ops atc260x_no_ops = {
+};
+
+/*
+ * Note LDO8 is not documented in datasheet (v2.4), but supported
+ * in the vendor's driver implementation (xapp-le-kernel).
+ */
+enum atc2603c_reg_ids {
+ ATC2603C_ID_DCDC1,
+ ATC2603C_ID_DCDC2,
+ ATC2603C_ID_DCDC3,
+ ATC2603C_ID_LDO1,
+ ATC2603C_ID_LDO2,
+ ATC2603C_ID_LDO3,
+ ATC2603C_ID_LDO5,
+ ATC2603C_ID_LDO6,
+ ATC2603C_ID_LDO7,
+ ATC2603C_ID_LDO8,
+ ATC2603C_ID_LDO11,
+ ATC2603C_ID_LDO12,
+ ATC2603C_ID_SWITCHLDO1,
+ ATC2603C_ID_MAX,
+};
+
+#define atc2603c_reg_desc_dcdc(num, min, step, n_volt, vsel_h, vsel_l) { \
+ .name = "DCDC"#num, \
+ .supply_name = "dcdc"#num, \
+ .of_match = of_match_ptr("dcdc"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2603C_ID_DCDC##num, \
+ .ops = &atc260x_dcdc_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = min, \
+ .uV_step = step, \
+ .n_voltages = n_volt, \
+ .vsel_reg = ATC2603C_PMU_DC##num##_CTL0, \
+ .vsel_mask = GENMASK(vsel_h, vsel_l), \
+ .enable_reg = ATC2603C_PMU_DC##num##_CTL0, \
+ .enable_mask = BIT(15), \
+ .enable_time = 800, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2603c_reg_desc_dcdc_range(num, vsel_h, vsel_l) { \
+ .name = "DCDC"#num, \
+ .supply_name = "dcdc"#num, \
+ .of_match = of_match_ptr("dcdc"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2603C_ID_DCDC##num, \
+ .ops = &atc260x_dcdc_range_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .n_voltages = 16, \
+ .linear_ranges = atc2603c_dcdc_voltage_ranges, \
+ .n_linear_ranges = ARRAY_SIZE(atc2603c_dcdc_voltage_ranges), \
+ .vsel_reg = ATC2603C_PMU_DC##num##_CTL0, \
+ .vsel_mask = GENMASK(vsel_h, vsel_l), \
+ .enable_reg = ATC2603C_PMU_DC##num##_CTL0, \
+ .enable_mask = BIT(15), \
+ .enable_time = 800, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2603c_reg_desc_dcdc_fixed(num, min, step, n_volt, vsel_h, vsel_l) { \
+ .name = "DCDC"#num, \
+ .supply_name = "dcdc"#num, \
+ .of_match = of_match_ptr("dcdc"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2603C_ID_DCDC##num, \
+ .ops = &atc260x_dcdc_fixed_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = min, \
+ .uV_step = step, \
+ .n_voltages = n_volt, \
+ .vsel_reg = ATC2603C_PMU_DC##num##_CTL0, \
+ .vsel_mask = GENMASK(vsel_h, vsel_l), \
+ .enable_time = 800, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2603c_reg_desc_ldo(num, min, step, n_volt, vsel_h, vsel_l) { \
+ .name = "LDO"#num, \
+ .supply_name = "ldo"#num, \
+ .of_match = of_match_ptr("ldo"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2603C_ID_LDO##num, \
+ .ops = &atc260x_ldo_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = min, \
+ .uV_step = step, \
+ .n_voltages = n_volt, \
+ .vsel_reg = ATC2603C_PMU_LDO##num##_CTL, \
+ .vsel_mask = GENMASK(vsel_h, vsel_l), \
+ .enable_reg = ATC2603C_PMU_LDO##num##_CTL, \
+ .enable_mask = BIT(0), \
+ .enable_time = 2000, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2603c_reg_desc_ldo_fixed(num, min, step, n_volt, vsel_h, vsel_l) { \
+ .name = "LDO"#num, \
+ .supply_name = "ldo"#num, \
+ .of_match = of_match_ptr("ldo"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2603C_ID_LDO##num, \
+ .ops = &atc260x_ldo_fixed_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = min, \
+ .uV_step = step, \
+ .n_voltages = n_volt, \
+ .vsel_reg = ATC2603C_PMU_LDO##num##_CTL, \
+ .vsel_mask = GENMASK(vsel_h, vsel_l), \
+ .enable_time = 2000, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2603c_reg_desc_ldo_noops(num, vfixed) { \
+ .name = "LDO"#num, \
+ .supply_name = "ldo"#num, \
+ .of_match = of_match_ptr("ldo"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2603C_ID_LDO##num, \
+ .ops = &atc260x_no_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .fixed_uV = vfixed, \
+ .n_voltages = 1, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2603c_reg_desc_ldo_switch(num, min, step, n_volt, vsel_h, vsel_l) { \
+ .name = "SWITCHLDO"#num, \
+ .supply_name = "switchldo"#num, \
+ .of_match = of_match_ptr("switchldo"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2603C_ID_SWITCHLDO##num, \
+ .ops = &atc260x_ldo_bypass_discharge_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = min, \
+ .uV_step = step, \
+ .n_voltages = n_volt, \
+ .vsel_reg = ATC2603C_PMU_SWITCH_CTL, \
+ .vsel_mask = GENMASK(vsel_h, vsel_l), \
+ .enable_reg = ATC2603C_PMU_SWITCH_CTL, \
+ .enable_mask = BIT(15), \
+ .enable_is_inverted = true, \
+ .enable_time = 2000, \
+ .bypass_reg = ATC2603C_PMU_SWITCH_CTL, \
+ .bypass_mask = BIT(5), \
+ .active_discharge_reg = ATC2603C_PMU_SWITCH_CTL, \
+ .active_discharge_mask = BIT(1), \
+ .owner = THIS_MODULE, \
+}
+
+static const struct regulator_desc atc2603c_reg[] = {
+ atc2603c_reg_desc_dcdc_fixed(1, 700000, 25000, 29, 11, 7),
+ atc2603c_reg_desc_dcdc_range(2, 12, 8),
+ atc2603c_reg_desc_dcdc_fixed(3, 2600000, 100000, 8, 11, 9),
+ atc2603c_reg_desc_ldo_fixed(1, 2600000, 100000, 8, 15, 13),
+ atc2603c_reg_desc_ldo_fixed(2, 2600000, 100000, 8, 15, 13),
+ atc2603c_reg_desc_ldo_fixed(3, 1500000, 100000, 6, 15, 13),
+ atc2603c_reg_desc_ldo(5, 2600000, 100000, 8, 15, 13),
+ atc2603c_reg_desc_ldo_fixed(6, 700000, 25000, 29, 15, 11),
+ atc2603c_reg_desc_ldo(7, 1500000, 100000, 6, 15, 13),
+ atc2603c_reg_desc_ldo(8, 2300000, 100000, 11, 15, 12),
+ atc2603c_reg_desc_ldo_fixed(11, 2600000, 100000, 8, 15, 13),
+ atc2603c_reg_desc_ldo_noops(12, 1800000),
+ atc2603c_reg_desc_ldo_switch(1, 3000000, 100000, 4, 4, 3),
+};
+
+static const struct regulator_desc atc2603c_reg_dcdc2_ver_b =
+ atc2603c_reg_desc_dcdc(2, 1000000, 50000, 18, 12, 8);
+
+enum atc2609a_reg_ids {
+ ATC2609A_ID_DCDC0,
+ ATC2609A_ID_DCDC1,
+ ATC2609A_ID_DCDC2,
+ ATC2609A_ID_DCDC3,
+ ATC2609A_ID_DCDC4,
+ ATC2609A_ID_LDO0,
+ ATC2609A_ID_LDO1,
+ ATC2609A_ID_LDO2,
+ ATC2609A_ID_LDO3,
+ ATC2609A_ID_LDO4,
+ ATC2609A_ID_LDO5,
+ ATC2609A_ID_LDO6,
+ ATC2609A_ID_LDO7,
+ ATC2609A_ID_LDO8,
+ ATC2609A_ID_LDO9,
+ ATC2609A_ID_MAX,
+};
+
+#define atc2609a_reg_desc_dcdc(num, en_bit) { \
+ .name = "DCDC"#num, \
+ .supply_name = "dcdc"#num, \
+ .of_match = of_match_ptr("dcdc"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2609A_ID_DCDC##num, \
+ .ops = &atc260x_dcdc_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = 600000, \
+ .uV_step = 6250, \
+ .n_voltages = 256, \
+ .vsel_reg = ATC2609A_PMU_DC##num##_CTL0, \
+ .vsel_mask = GENMASK(15, 8), \
+ .enable_reg = ATC2609A_PMU_DC_OSC, \
+ .enable_mask = BIT(en_bit), \
+ .enable_time = 800, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2609a_reg_desc_dcdc_range(num, en_bit) { \
+ .name = "DCDC"#num, \
+ .supply_name = "dcdc"#num, \
+ .of_match = of_match_ptr("dcdc"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2609A_ID_DCDC##num, \
+ .ops = &atc260x_dcdc_range_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .n_voltages = 233, \
+ .linear_ranges = atc2609a_dcdc_voltage_ranges, \
+ .n_linear_ranges = ARRAY_SIZE(atc2609a_dcdc_voltage_ranges), \
+ .vsel_reg = ATC2609A_PMU_DC##num##_CTL0, \
+ .vsel_mask = GENMASK(15, 8), \
+ .enable_reg = ATC2609A_PMU_DC_OSC, \
+ .enable_mask = BIT(en_bit), \
+ .enable_time = 800, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2609a_reg_desc_ldo(num) { \
+ .name = "LDO"#num, \
+ .supply_name = "ldo"#num, \
+ .of_match = of_match_ptr("ldo"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2609A_ID_LDO##num, \
+ .ops = &atc260x_ldo_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = 700000, \
+ .uV_step = 100000, \
+ .n_voltages = 16, \
+ .vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \
+ .vsel_mask = GENMASK(4, 1), \
+ .enable_reg = ATC2609A_PMU_LDO##num##_CTL0, \
+ .enable_mask = BIT(0), \
+ .enable_time = 2000, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2609a_reg_desc_ldo_bypass(num) { \
+ .name = "LDO"#num, \
+ .supply_name = "ldo"#num, \
+ .of_match = of_match_ptr("ldo"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2609A_ID_LDO##num, \
+ .ops = &atc260x_ldo_bypass_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = 2300000, \
+ .uV_step = 100000, \
+ .n_voltages = 12, \
+ .vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \
+ .vsel_mask = GENMASK(5, 2), \
+ .enable_reg = ATC2609A_PMU_LDO##num##_CTL0, \
+ .enable_mask = BIT(0), \
+ .enable_time = 2000, \
+ .bypass_reg = ATC2609A_PMU_LDO##num##_CTL0, \
+ .bypass_mask = BIT(1), \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2609a_reg_desc_ldo_range_pick(num, n_range) { \
+ .name = "LDO"#num, \
+ .supply_name = "ldo"#num, \
+ .of_match = of_match_ptr("ldo"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2609A_ID_LDO##num, \
+ .ops = &atc260x_ldo_range_pick_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .linear_ranges = atc2609a_ldo_voltage_ranges##n_range, \
+ .n_linear_ranges = ARRAY_SIZE(atc2609a_ldo_voltage_ranges##n_range), \
+ .vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \
+ .vsel_mask = GENMASK(4, 1), \
+ .vsel_range_reg = ATC2609A_PMU_LDO##num##_CTL0, \
+ .vsel_range_mask = BIT(5), \
+ .linear_range_selectors = atc260x_ldo_voltage_range_sel, \
+ .enable_reg = ATC2609A_PMU_LDO##num##_CTL0, \
+ .enable_mask = BIT(0), \
+ .enable_time = 2000, \
+ .owner = THIS_MODULE, \
+}
+
+#define atc2609a_reg_desc_ldo_fixed(num) { \
+ .name = "LDO"#num, \
+ .supply_name = "ldo"#num, \
+ .of_match = of_match_ptr("ldo"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .id = ATC2609A_ID_LDO##num, \
+ .ops = &atc260x_ldo_fixed_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .min_uV = 2600000, \
+ .uV_step = 100000, \
+ .n_voltages = 8, \
+ .vsel_reg = ATC2609A_PMU_LDO##num##_CTL, \
+ .vsel_mask = GENMASK(15, 13), \
+ .enable_time = 2000, \
+ .owner = THIS_MODULE, \
+}
+
+static const struct regulator_desc atc2609a_reg[] = {
+ atc2609a_reg_desc_dcdc(0, 4),
+ atc2609a_reg_desc_dcdc(1, 5),
+ atc2609a_reg_desc_dcdc(2, 6),
+ atc2609a_reg_desc_dcdc_range(3, 7),
+ atc2609a_reg_desc_dcdc(4, 8),
+ atc2609a_reg_desc_ldo_bypass(0),
+ atc2609a_reg_desc_ldo_bypass(1),
+ atc2609a_reg_desc_ldo_bypass(2),
+ atc2609a_reg_desc_ldo_range_pick(3, 0),
+ atc2609a_reg_desc_ldo_range_pick(4, 0),
+ atc2609a_reg_desc_ldo(5),
+ atc2609a_reg_desc_ldo_range_pick(6, 1),
+ atc2609a_reg_desc_ldo_range_pick(7, 0),
+ atc2609a_reg_desc_ldo_range_pick(8, 0),
+ atc2609a_reg_desc_ldo_fixed(9),
+};
+
+static int atc260x_regulator_probe(struct platform_device *pdev)
+{
+ struct atc260x *atc260x = dev_get_drvdata(pdev->dev.parent);
+ struct device *dev = atc260x->dev;
+ struct atc260x_regulator_data *atc260x_data;
+ struct regulator_config config = {};
+ struct regulator_dev *atc260x_rdev;
+ const struct regulator_desc *regulators;
+ bool atc2603c_ver_b = false;
+ int i, nregulators;
+
+ atc260x_data = devm_kzalloc(&pdev->dev, sizeof(*atc260x_data), GFP_KERNEL);
+ if (!atc260x_data)
+ return -ENOMEM;
+
+ atc260x_data->voltage_time_dcdc = 350;
+ atc260x_data->voltage_time_ldo = 800;
+
+ switch (atc260x->ic_type) {
+ case ATC2603C:
+ regulators = atc2603c_reg;
+ nregulators = ATC2603C_ID_MAX;
+ atc2603c_ver_b = atc260x->ic_ver == ATC260X_B;
+ break;
+ case ATC2609A:
+ atc260x_data->voltage_time_dcdc = 250;
+ regulators = atc2609a_reg;
+ nregulators = ATC2609A_ID_MAX;
+ break;
+ default:
+ dev_err(dev, "unsupported ATC260X ID %d\n", atc260x->ic_type);
+ return -EINVAL;
+ }
+
+ config.dev = dev;
+ config.regmap = atc260x->regmap;
+ config.driver_data = atc260x_data;
+
+ /* Instantiate the regulators */
+ for (i = 0; i < nregulators; i++) {
+ if (atc2603c_ver_b && regulators[i].id == ATC2603C_ID_DCDC2)
+ atc260x_rdev = devm_regulator_register(&pdev->dev,
+ &atc2603c_reg_dcdc2_ver_b,
+ &config);
+ else
+ atc260x_rdev = devm_regulator_register(&pdev->dev,
+ &regulators[i],
+ &config);
+ if (IS_ERR(atc260x_rdev)) {
+ dev_err(dev, "failed to register regulator: %d\n", i);
+ return PTR_ERR(atc260x_rdev);
+ }
+ }
+
+ return 0;
+}
+
+static struct platform_driver atc260x_regulator_driver = {
+ .probe = atc260x_regulator_probe,
+ .driver = {
+ .name = "atc260x-regulator",
+ },
+};
+
+module_platform_driver(atc260x_regulator_driver);
+
+MODULE_DESCRIPTION("Regulator driver for ATC260x PMICs");
+MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>");
+MODULE_AUTHOR("Cristian Ciocaltea <cristian.ciocaltea@gmail.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c
index e6d5d98c3cea..9309765d0450 100644
--- a/drivers/regulator/bd718x7-regulator.c
+++ b/drivers/regulator/bd718x7-regulator.c
@@ -15,6 +15,36 @@
#include <linux/regulator/of_regulator.h>
#include <linux/slab.h>
+/* Typical regulator startup times as per data sheet in uS */
+#define BD71847_BUCK1_STARTUP_TIME 144
+#define BD71847_BUCK2_STARTUP_TIME 162
+#define BD71847_BUCK3_STARTUP_TIME 162
+#define BD71847_BUCK4_STARTUP_TIME 240
+#define BD71847_BUCK5_STARTUP_TIME 270
+#define BD71847_BUCK6_STARTUP_TIME 200
+#define BD71847_LDO1_STARTUP_TIME 440
+#define BD71847_LDO2_STARTUP_TIME 370
+#define BD71847_LDO3_STARTUP_TIME 310
+#define BD71847_LDO4_STARTUP_TIME 400
+#define BD71847_LDO5_STARTUP_TIME 530
+#define BD71847_LDO6_STARTUP_TIME 400
+
+#define BD71837_BUCK1_STARTUP_TIME 160
+#define BD71837_BUCK2_STARTUP_TIME 180
+#define BD71837_BUCK3_STARTUP_TIME 180
+#define BD71837_BUCK4_STARTUP_TIME 180
+#define BD71837_BUCK5_STARTUP_TIME 160
+#define BD71837_BUCK6_STARTUP_TIME 240
+#define BD71837_BUCK7_STARTUP_TIME 220
+#define BD71837_BUCK8_STARTUP_TIME 200
+#define BD71837_LDO1_STARTUP_TIME 440
+#define BD71837_LDO2_STARTUP_TIME 370
+#define BD71837_LDO3_STARTUP_TIME 310
+#define BD71837_LDO4_STARTUP_TIME 400
+#define BD71837_LDO5_STARTUP_TIME 310
+#define BD71837_LDO6_STARTUP_TIME 400
+#define BD71837_LDO7_STARTUP_TIME 530
+
/*
* BD718(37/47/50) have two "enable control modes". ON/OFF can either be
* controlled by software - or by PMIC internal HW state machine. Whether
@@ -613,6 +643,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD718XX_REG_BUCK1_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71847_BUCK1_STARTUP_TIME,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -646,6 +677,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD718XX_REG_BUCK2_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71847_BUCK2_STARTUP_TIME,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -680,6 +712,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.linear_range_selectors = bd71847_buck3_volt_range_sel,
.enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71847_BUCK3_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -706,6 +739,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.vsel_range_mask = BD71847_BUCK4_RANGE_MASK,
.linear_range_selectors = bd71847_buck4_volt_range_sel,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71847_BUCK4_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -727,6 +761,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
.enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71847_BUCK5_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -750,6 +785,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
.enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71847_BUCK6_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -775,6 +811,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.linear_range_selectors = bd718xx_ldo1_volt_range_sel,
.enable_reg = BD718XX_REG_LDO1_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71847_LDO1_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -796,6 +833,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.n_voltages = ARRAY_SIZE(ldo_2_volts),
.enable_reg = BD718XX_REG_LDO2_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71847_LDO2_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -818,6 +856,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.vsel_mask = BD718XX_LDO3_MASK,
.enable_reg = BD718XX_REG_LDO3_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71847_LDO3_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -840,6 +879,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.vsel_mask = BD718XX_LDO4_MASK,
.enable_reg = BD718XX_REG_LDO4_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71847_LDO4_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -865,6 +905,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.linear_range_selectors = bd71847_ldo5_volt_range_sel,
.enable_reg = BD718XX_REG_LDO5_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71847_LDO5_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -889,6 +930,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = {
.vsel_mask = BD718XX_LDO6_MASK,
.enable_reg = BD718XX_REG_LDO6_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71847_LDO6_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -942,6 +984,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD718XX_REG_BUCK1_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71837_BUCK1_STARTUP_TIME,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -975,6 +1018,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD718XX_REG_BUCK2_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71837_BUCK2_STARTUP_TIME,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -1005,6 +1049,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD71837_REG_BUCK3_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71837_BUCK3_STARTUP_TIME,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -1033,6 +1078,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD71837_REG_BUCK4_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71837_BUCK4_STARTUP_TIME,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -1065,6 +1111,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.linear_range_selectors = bd71837_buck5_volt_range_sel,
.enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71837_BUCK5_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1088,6 +1135,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = BD71837_BUCK6_MASK,
.enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71837_BUCK6_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1109,6 +1157,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
.enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71837_BUCK7_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1132,6 +1181,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
.enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+ .enable_time = BD71837_BUCK8_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1157,6 +1207,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.linear_range_selectors = bd718xx_ldo1_volt_range_sel,
.enable_reg = BD718XX_REG_LDO1_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71837_LDO1_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1178,6 +1229,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.n_voltages = ARRAY_SIZE(ldo_2_volts),
.enable_reg = BD718XX_REG_LDO2_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71837_LDO2_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1200,6 +1252,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = BD718XX_LDO3_MASK,
.enable_reg = BD718XX_REG_LDO3_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71837_LDO3_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1222,6 +1275,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = BD718XX_LDO4_MASK,
.enable_reg = BD718XX_REG_LDO4_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71837_LDO4_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1246,6 +1300,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = BD71837_LDO5_MASK,
.enable_reg = BD718XX_REG_LDO5_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71837_LDO5_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1272,6 +1327,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = BD718XX_LDO6_MASK,
.enable_reg = BD718XX_REG_LDO6_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71837_LDO6_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -1296,6 +1352,7 @@ static struct bd718xx_regulator_data bd71837_regulators[] = {
.vsel_mask = BD71837_LDO7_MASK,
.enable_reg = BD71837_REG_LDO7_VOLT,
.enable_mask = BD718XX_LDO_EN,
+ .enable_time = BD71837_LDO7_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ca03d8e70bd1..fee924158091 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2020,7 +2020,7 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
* Returns a struct regulator corresponding to the regulator producer,
* or IS_ERR() condition containing errno.
*
- * Use of supply names configured via regulator_set_device_supply() is
+ * Use of supply names configured via set_consumer_device_supply() is
* strongly encouraged. It is recommended that the supply name used
* should match the name used for the supply and/or the relevant
* device pins in the datasheet.
@@ -2047,7 +2047,7 @@ EXPORT_SYMBOL_GPL(regulator_get);
* regulator off for correct operation of the hardware they are
* controlling.
*
- * Use of supply names configured via regulator_set_device_supply() is
+ * Use of supply names configured via set_consumer_device_supply() is
* strongly encouraged. It is recommended that the supply name used
* should match the name used for the supply and/or the relevant
* device pins in the datasheet.
@@ -2073,7 +2073,7 @@ EXPORT_SYMBOL_GPL(regulator_get_exclusive);
* disrupting the operation of drivers that can handle absent
* supplies.
*
- * Use of supply names configured via regulator_set_device_supply() is
+ * Use of supply names configured via set_consumer_device_supply() is
* strongly encouraged. It is recommended that the supply name used
* should match the name used for the supply and/or the relevant
* device pins in the datasheet.
diff --git a/drivers/regulator/pf8x00-regulator.c b/drivers/regulator/pf8x00-regulator.c
index 308c27fa6ea8..af9918cd27aa 100644
--- a/drivers/regulator/pf8x00-regulator.c
+++ b/drivers/regulator/pf8x00-regulator.c
@@ -469,13 +469,17 @@ static int pf8x00_i2c_probe(struct i2c_client *client)
}
static const struct of_device_id pf8x00_dt_ids[] = {
- { .compatible = "nxp,pf8x00",},
+ { .compatible = "nxp,pf8100",},
+ { .compatible = "nxp,pf8121a",},
+ { .compatible = "nxp,pf8200",},
{ }
};
MODULE_DEVICE_TABLE(of, pf8x00_dt_ids);
static const struct i2c_device_id pf8x00_i2c_id[] = {
- { "pf8x00", 0 },
+ { "pf8100", 0 },
+ { "pf8121a", 0 },
+ { "pf8200", 0 },
{},
};
MODULE_DEVICE_TABLE(i2c, pf8x00_i2c_id);
diff --git a/drivers/regulator/rt4831-regulator.c b/drivers/regulator/rt4831-regulator.c
new file mode 100644
index 000000000000..3d4695ded629
--- /dev/null
+++ b/drivers/regulator/rt4831-regulator.c
@@ -0,0 +1,198 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/bitops.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/regulator/driver.h>
+
+enum {
+ DSV_OUT_VLCM = 0,
+ DSV_OUT_VPOS,
+ DSV_OUT_VNEG,
+ DSV_OUT_MAX
+};
+
+#define RT4831_REG_DSVEN 0x09
+#define RT4831_REG_VLCM 0x0c
+#define RT4831_REG_VPOS 0x0d
+#define RT4831_REG_VNEG 0x0e
+#define RT4831_REG_FLAGS 0x0f
+
+#define RT4831_VOLT_MASK GENMASK(5, 0)
+#define RT4831_DSVMODE_SHIFT 5
+#define RT4831_DSVMODE_MASK GENMASK(7, 5)
+#define RT4831_POSADEN_MASK BIT(4)
+#define RT4831_NEGADEN_MASK BIT(3)
+#define RT4831_POSEN_MASK BIT(2)
+#define RT4831_NEGEN_MASK BIT(1)
+
+#define RT4831_OTP_MASK BIT(6)
+#define RT4831_LCMOVP_MASK BIT(5)
+#define RT4831_VPOSSCP_MASK BIT(3)
+#define RT4831_VNEGSCP_MASK BIT(2)
+
+#define DSV_MODE_NORMAL (0x4 << RT4831_DSVMODE_SHIFT)
+#define DSV_MODE_BYPASS (0x6 << RT4831_DSVMODE_SHIFT)
+#define STEP_UV 50000
+#define VLCM_MIN_UV 4000000
+#define VLCM_MAX_UV 7150000
+#define VLCM_N_VOLTAGES ((VLCM_MAX_UV - VLCM_MIN_UV) / STEP_UV + 1)
+#define VPN_MIN_UV 4000000
+#define VPN_MAX_UV 6500000
+#define VPN_N_VOLTAGES ((VPN_MAX_UV - VPN_MIN_UV) / STEP_UV + 1)
+
+static int rt4831_get_error_flags(struct regulator_dev *rdev, unsigned int *flags)
+{
+ struct regmap *regmap = rdev_get_regmap(rdev);
+ int rid = rdev_get_id(rdev);
+ unsigned int val, events = 0;
+ int ret;
+
+ ret = regmap_read(regmap, RT4831_REG_FLAGS, &val);
+ if (ret)
+ return ret;
+
+ if (val & RT4831_OTP_MASK)
+ events |= REGULATOR_ERROR_OVER_TEMP;
+
+ if (rid == DSV_OUT_VLCM && (val & RT4831_LCMOVP_MASK))
+ events |= REGULATOR_ERROR_OVER_CURRENT;
+
+ if (rid == DSV_OUT_VPOS && (val & RT4831_VPOSSCP_MASK))
+ events |= REGULATOR_ERROR_OVER_CURRENT;
+
+ if (rid == DSV_OUT_VNEG && (val & RT4831_VNEGSCP_MASK))
+ events |= REGULATOR_ERROR_OVER_CURRENT;
+
+ *flags = events;
+ return 0;
+}
+
+static const struct regulator_ops rt4831_dsvlcm_ops = {
+ .list_voltage = regulator_list_voltage_linear,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_bypass = regulator_set_bypass_regmap,
+ .get_bypass = regulator_get_bypass_regmap,
+ .get_error_flags = rt4831_get_error_flags,
+};
+
+static const struct regulator_ops rt4831_dsvpn_ops = {
+ .list_voltage = regulator_list_voltage_linear,
+ .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,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+ .get_error_flags = rt4831_get_error_flags,
+};
+
+static const struct regulator_desc rt4831_regulator_descs[] = {
+ {
+ .name = "DSVLCM",
+ .ops = &rt4831_dsvlcm_ops,
+ .of_match = of_match_ptr("DSVLCM"),
+ .regulators_node = of_match_ptr("regulators"),
+ .type = REGULATOR_VOLTAGE,
+ .id = DSV_OUT_VLCM,
+ .n_voltages = VLCM_N_VOLTAGES,
+ .min_uV = VLCM_MIN_UV,
+ .uV_step = STEP_UV,
+ .vsel_reg = RT4831_REG_VLCM,
+ .vsel_mask = RT4831_VOLT_MASK,
+ .bypass_reg = RT4831_REG_DSVEN,
+ .bypass_val_on = DSV_MODE_BYPASS,
+ .bypass_val_off = DSV_MODE_NORMAL,
+ },
+ {
+ .name = "DSVP",
+ .ops = &rt4831_dsvpn_ops,
+ .of_match = of_match_ptr("DSVP"),
+ .regulators_node = of_match_ptr("regulators"),
+ .type = REGULATOR_VOLTAGE,
+ .id = DSV_OUT_VPOS,
+ .n_voltages = VPN_N_VOLTAGES,
+ .min_uV = VPN_MIN_UV,
+ .uV_step = STEP_UV,
+ .vsel_reg = RT4831_REG_VPOS,
+ .vsel_mask = RT4831_VOLT_MASK,
+ .enable_reg = RT4831_REG_DSVEN,
+ .enable_mask = RT4831_POSEN_MASK,
+ .active_discharge_reg = RT4831_REG_DSVEN,
+ .active_discharge_mask = RT4831_POSADEN_MASK,
+ },
+ {
+ .name = "DSVN",
+ .ops = &rt4831_dsvpn_ops,
+ .of_match = of_match_ptr("DSVN"),
+ .regulators_node = of_match_ptr("regulators"),
+ .type = REGULATOR_VOLTAGE,
+ .id = DSV_OUT_VNEG,
+ .n_voltages = VPN_N_VOLTAGES,
+ .min_uV = VPN_MIN_UV,
+ .uV_step = STEP_UV,
+ .vsel_reg = RT4831_REG_VNEG,
+ .vsel_mask = RT4831_VOLT_MASK,
+ .enable_reg = RT4831_REG_DSVEN,
+ .enable_mask = RT4831_NEGEN_MASK,
+ .active_discharge_reg = RT4831_REG_DSVEN,
+ .active_discharge_mask = RT4831_NEGADEN_MASK,
+ }
+};
+
+static int rt4831_regulator_probe(struct platform_device *pdev)
+{
+ struct regmap *regmap;
+ struct regulator_dev *rdev;
+ struct regulator_config config = {};
+ int i, ret;
+
+ regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ if (IS_ERR(regmap)) {
+ dev_err(&pdev->dev, "Failed to init regmap\n");
+ return PTR_ERR(regmap);
+ }
+
+ /* Configure DSV mode to normal by default */
+ ret = regmap_update_bits(regmap, RT4831_REG_DSVEN, RT4831_DSVMODE_MASK, DSV_MODE_NORMAL);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to configure dsv mode to normal\n");
+ return ret;
+ }
+
+ config.dev = pdev->dev.parent;
+ config.regmap = regmap;
+
+ for (i = 0; i < DSV_OUT_MAX; i++) {
+ rdev = devm_regulator_register(&pdev->dev, rt4831_regulator_descs + i, &config);
+ if (IS_ERR(rdev)) {
+ dev_err(&pdev->dev, "Failed to register %d regulator\n", i);
+ return PTR_ERR(rdev);
+ }
+ }
+
+ return 0;
+}
+
+static const struct platform_device_id rt4831_regulator_match[] = {
+ { "rt4831-regulator", 0 },
+ {}
+};
+MODULE_DEVICE_TABLE(platform, rt4831_regulator_match);
+
+static struct platform_driver rt4831_regulator_driver = {
+ .driver = {
+ .name = "rt4831-regulator",
+ },
+ .id_table = rt4831_regulator_match,
+ .probe = rt4831_regulator_probe,
+};
+module_platform_driver(rt4831_regulator_driver);
+
+MODULE_AUTHOR("ChiYuan Huang <cy_huang@richtek.com>");
+MODULE_LICENSE("GPL v2");
diff --git a/lib/linear_ranges.c b/lib/linear_ranges.c
index 9495ef3572b7..ced5c15d3f04 100644
--- a/lib/linear_ranges.c
+++ b/lib/linear_ranges.c
@@ -128,7 +128,7 @@ EXPORT_SYMBOL_GPL(linear_range_get_value_array);
* @selector: address where found selector value is updated
* @found: flag to indicate that given value was in the range
*
- * Return selector which which range value is closest match for given
+ * Return selector for which range value is closest match for given
* input value. Value is matching if it is equal or smaller than given
* value. If given value is in the range, then @found is set true.
*
@@ -168,11 +168,11 @@ EXPORT_SYMBOL_GPL(linear_range_get_selector_low);
* @selector: address where found selector value is updated
* @found: flag to indicate that given value was in the range
*
- * Scan array of ranges for selector which which range value matches given
+ * Scan array of ranges for selector for which range value matches given
* input value. Value is matching if it is equal or smaller than given
* value. If given value is found to be in a range scanning is stopped and
* @found is set true. If a range with values smaller than given value is found
- * but the range max is being smaller than given value, then the ranges
+ * but the range max is being smaller than given value, then the range's
* biggest selector is updated to @selector but scanning ranges is continued
* and @found is set to false.
*
@@ -209,7 +209,7 @@ EXPORT_SYMBOL_GPL(linear_range_get_selector_low_array);
* @selector: address where found selector value is updated
* @found: flag to indicate that given value was in the range
*
- * Return selector which which range value is closest match for given
+ * Return selector for which range value is closest match for given
* input value. Value is matching if it is equal or higher than given
* value. If given value is in the range, then @found is set true.
*