2019-01-29 19:55:06

by Otavio Salvador

[permalink] [raw]
Subject: [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805

RK805 has the following voltage range for the BUCK1 and BUCK2 regulators:

From 0.7125V to 1.45V in 12.5mV steps, 1.8V, 2V, 2.2V and 2.3V

, which corresponds to the following values as per the RK805
datasheet:

000 000: 0.7125V
000 001: 0.725V
……
111 011: 1.45V
111 100: 1.8V
111 101: 2.0V
111 110: 2.2V
111 111: 2.3V

This means that the voltage range is not linear and so RK805 can not
reuse the same regulator_ops structure from RK808.

Fix it by creating a list with the correct supported voltage values
for RK805 BUCK1 and BUCK2 regulators.

Tested on a rv1108-elgin-r1 board that now correctly reports a BUCK2
voltage of 2.2V instead of the unsupported value of 1.4875V.

Signed-off-by: Otavio Salvador <[email protected]>
---

drivers/regulator/rk808-regulator.c | 53 ++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
index 213b68743cc8..1463c65c85db 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -289,6 +289,21 @@ static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
RK808_RAMP_RATE_MASK, ramp_value);
}

+static int rk805_set_suspend_voltage(struct regulator_dev *rdev, int uv)
+{
+ unsigned int reg;
+ int sel = regulator_map_voltage_ascend(rdev, uv, uv);
+
+ if (sel < 0)
+ return -EINVAL;
+
+ reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET;
+
+ return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->vsel_mask,
+ sel);
+}
+
static int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv)
{
unsigned int reg;
@@ -376,6 +391,19 @@ static struct regulator_ops rk805_reg_ops = {
.set_suspend_disable = rk805_set_suspend_disable,
};

+static struct regulator_ops rk805_buck1_2_ops = {
+ .list_voltage = regulator_list_voltage_table,
+ .map_voltage = regulator_map_voltage_ascend,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .set_suspend_voltage = rk805_set_suspend_voltage,
+ .set_suspend_enable = rk805_set_suspend_enable,
+ .set_suspend_disable = rk805_set_suspend_disable,
+};
+
static struct regulator_ops rk805_switch_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
@@ -433,6 +461,17 @@ static struct regulator_ops rk808_switch_ops = {
.set_suspend_disable = rk808_set_suspend_disable,
};

+static const int rk805_buck_1_2_voltages[] = {
+ 712500, 725000, 737500, 750000, 762500, 775000, 787500, 800000,
+ 812500, 825000, 837500, 850000, 862500, 875000, 887500, 900000,
+ 912500, 925000, 937500, 950000, 962500, 975000, 987500, 1000000,
+ 1012500, 1025000, 1037500, 1050000, 1062500, 1075000, 1087500, 1100000,
+ 1112500, 1125000, 1137500, 1150000, 1162500, 1175000, 1187500, 1200000,
+ 1212500, 1225000, 1237500, 1250000, 1262500, 1275000, 1287500, 1300000,
+ 1312500, 1325000, 1337500, 1350000, 1362500, 1375000, 1387500, 1400000,
+ 1412500, 1425000, 1437500, 1450000, 1800000, 2000000, 2200000, 2300000,
+};
+
static const struct regulator_desc rk805_reg[] = {
{
.name = "DCDC_REG1",
@@ -440,11 +479,10 @@ static const struct regulator_desc rk805_reg[] = {
.of_match = of_match_ptr("DCDC_REG1"),
.regulators_node = of_match_ptr("regulators"),
.id = RK805_ID_DCDC1,
- .ops = &rk805_reg_ops,
+ .ops = &rk805_buck1_2_ops,
.type = REGULATOR_VOLTAGE,
- .min_uV = 712500,
- .uV_step = 12500,
- .n_voltages = 64,
+ .n_voltages = ARRAY_SIZE(rk805_buck_1_2_voltages),
+ .volt_table = rk805_buck_1_2_voltages,
.vsel_reg = RK805_BUCK1_ON_VSEL_REG,
.vsel_mask = RK818_BUCK_VSEL_MASK,
.enable_reg = RK805_DCDC_EN_REG,
@@ -456,11 +494,10 @@ static const struct regulator_desc rk805_reg[] = {
.of_match = of_match_ptr("DCDC_REG2"),
.regulators_node = of_match_ptr("regulators"),
.id = RK805_ID_DCDC2,
- .ops = &rk805_reg_ops,
+ .ops = &rk805_buck1_2_ops,
.type = REGULATOR_VOLTAGE,
- .min_uV = 712500,
- .uV_step = 12500,
- .n_voltages = 64,
+ .n_voltages = ARRAY_SIZE(rk805_buck_1_2_voltages),
+ .volt_table = rk805_buck_1_2_voltages,
.vsel_reg = RK805_BUCK2_ON_VSEL_REG,
.vsel_mask = RK818_BUCK_VSEL_MASK,
.enable_reg = RK805_DCDC_EN_REG,
--
2.20.1



2019-01-29 19:55:18

by Otavio Salvador

[permalink] [raw]
Subject: [PATCH 2/4] ARM: dts: rockchip: rv1108-elgin: Fix vcc5/6-supply representation

On rv1108-elgin-r1 board the RK805 VCC5 and VCC6 supplies come from
the BUCK2 regulator at 2.2V, so fix the representation in the
device tree.

While at it, rename it from vdd_cam to vdd_buck2, which is a better
name for the regulator label.

Signed-off-by: Otavio Salvador <[email protected]>
---

arch/arm/boot/dts/rv1108-elgin-r1.dts | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/rv1108-elgin-r1.dts b/arch/arm/boot/dts/rv1108-elgin-r1.dts
index 7b24558f13e0..dc2ae1731ae2 100644
--- a/arch/arm/boot/dts/rv1108-elgin-r1.dts
+++ b/arch/arm/boot/dts/rv1108-elgin-r1.dts
@@ -74,8 +74,8 @@
vcc2-supply = <&vcc_sys>;
vcc3-supply = <&vcc_sys>;
vcc4-supply = <&vcc_sys>;
- vcc5-supply = <&vcc_sys>;
- vcc6-supply = <&vcc_sys>;
+ vcc5-supply = <&vdd_buck2>;
+ vcc6-supply = <&vdd_buck2>;

regulators {
vdd_core: DCDC_REG1 {
@@ -90,10 +90,12 @@
};
};

- vdd_cam: DCDC_REG2 {
- regulator-name= "vdd_cam";
- regulator-min-microvolt = <700000>;
- regulator-max-microvolt = <2000000>;
+ vdd_buck2: DCDC_REG2 {
+ regulator-name= "vdd_buck2";
+ regulator-min-microvolt = <2200000>;
+ regulator-max-microvolt = <2200000>;
+ regulator-always-on;
+ regulator-boot-on;
regulator-state-mem {
regulator-state-disabled;
};
--
2.20.1


2019-01-29 19:56:08

by Otavio Salvador

[permalink] [raw]
Subject: [PATCH 3/4] ARM: dts: rockchip: rv1108-elgin: Use the correct regulator properties

The following properties:

- regulator-state-enabled
- regulator-state-disabled
- regulator-state-uv

are not valid ones as per
Documentation/devicetree/bindings/regulator/regulator.txt

Fix it by using the correct properties as per the dt bindings.

Signed-off-by: Otavio Salvador <[email protected]>
---

arch/arm/boot/dts/rv1108-elgin-r1.dts | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/rv1108-elgin-r1.dts b/arch/arm/boot/dts/rv1108-elgin-r1.dts
index dc2ae1731ae2..ef31fee8acec 100644
--- a/arch/arm/boot/dts/rv1108-elgin-r1.dts
+++ b/arch/arm/boot/dts/rv1108-elgin-r1.dts
@@ -85,8 +85,8 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-enabled;
- regulator-state-uv = <900000>;
+ regulator-on-in-suspend;
+ regulator-suspend-microvolt = <900000>;
};
};

@@ -97,7 +97,7 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-disabled;
+ regulator-off-in-suspend;
};
};

@@ -106,7 +106,7 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-enabled;
+ regulator-on-in-suspend;
};
};

@@ -117,8 +117,8 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-enabled;
- regulator-state-uv = <3300000>;
+ regulator-on-in-suspend;
+ regulator-suspend-microvolt = <3300000>;
};
};

@@ -129,7 +129,7 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-disabled;
+ regulator-off-in-suspend;
};
};

@@ -140,7 +140,7 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-disabled;
+ regulator-off-in-suspend;
};
};

@@ -151,8 +151,8 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-enabled;
- regulator-state-uv = <1000000>;
+ regulator-on-in-suspend;
+ regulator-suspend-microvolt = <1000000>;
};
};
};
--
2.20.1


2019-01-29 19:56:13

by Otavio Salvador

[permalink] [raw]
Subject: [PATCH 4/4] ARM: dts: rockchip: rv1108-evb: Use the correct regulator properties

The following properties:

- regulator-state-enabled
- regulator-state-disabled
- regulator-state-uv

are not valid ones as per
Documentation/devicetree/bindings/regulator/regulator.txt

Fix it by using the correct properties as per the dt bindings.

Signed-off-by: Otavio Salvador <[email protected]>
---

arch/arm/boot/dts/rv1108-evb.dts | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/rv1108-evb.dts b/arch/arm/boot/dts/rv1108-evb.dts
index 203d83e3bbf5..30f3d0470ad9 100644
--- a/arch/arm/boot/dts/rv1108-evb.dts
+++ b/arch/arm/boot/dts/rv1108-evb.dts
@@ -97,8 +97,8 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-enabled;
- regulator-state-uv = <900000>;
+ regulator-on-in-suspend;
+ regulator-suspend-microvolt = <900000>;
};
};

@@ -107,7 +107,7 @@
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <2000000>;
regulator-state-mem {
- regulator-state-disabled;
+ regulator-off-in-suspend;
};
};

@@ -116,7 +116,7 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-enabled;
+ regulator-on-in-suspend;
};
};

@@ -127,8 +127,8 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-enabled;
- regulator-state-uv = <3300000>;
+ regulator-on-in-suspend;
+ regulator-suspend-microvolt = <3300000>;
};
};

@@ -139,7 +139,7 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-disabled;
+ regulator-off-in-suspend;
};
};

@@ -150,7 +150,7 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-disabled;
+ regulator-off-in-suspend;
};
};

@@ -161,8 +161,8 @@
regulator-always-on;
regulator-boot-on;
regulator-state-mem {
- regulator-state-enabled;
- regulator-state-uv = <1000000>;
+ regulator-on-in-suspend;
+ regulator-suspend-microvolt = <1000000>;
};
};
};
--
2.20.1


2019-01-30 15:41:08

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805

On Tue, Jan 29, 2019 at 05:54:21PM -0200, Otavio Salvador wrote:
> RK805 has the following voltage range for the BUCK1 and BUCK2 regulators:

I'm missing the other patches in this series and don't see a cover
letter - what's the story with dependencies?


Attachments:
(No filename) (259.00 B)
signature.asc (499.00 B)
Download all attachments

2019-01-31 12:47:31

by Otavio Salvador

[permalink] [raw]
Subject: Re: [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805

Hello Mark,

On Wed, Jan 30, 2019 at 1:40 PM Mark Brown <[email protected]> wrote:
> On Tue, Jan 29, 2019 at 05:54:21PM -0200, Otavio Salvador wrote:
> > RK805 has the following voltage range for the BUCK1 and BUCK2 regulators:
>
> I'm missing the other patches in this series and don't see a cover
> letter - what's the story with dependencies?

Those are just adjustments on dts files fixing the regulator handle. I
am preparing the v2 without those as they are independent.

--
Otavio Salvador O.S. Systems
http://www.ossystems.com.br http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854 Mobile: +1 (347) 903-9750