linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805
@ 2019-01-29 19:54 Otavio Salvador
  2019-01-29 19:54 ` [PATCH 2/4] ARM: dts: rockchip: rv1108-elgin: Fix vcc5/6-supply representation Otavio Salvador
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Otavio Salvador @ 2019-01-29 19:54 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Jason Zhu, Vicent Chi, Andy Yan, Philipp Tomsic, Tony Xie,
	Otavio Salvador, Liam Girdwood, linux-kernel, Mark Brown

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 <otavio@ossystems.com.br>
---

 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] ARM: dts: rockchip: rv1108-elgin: Fix vcc5/6-supply representation
  2019-01-29 19:54 [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Otavio Salvador
@ 2019-01-29 19:54 ` Otavio Salvador
  2019-01-29 19:54 ` [PATCH 3/4] ARM: dts: rockchip: rv1108-elgin: Use the correct regulator properties Otavio Salvador
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2019-01-29 19:54 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Jason Zhu, Vicent Chi, Andy Yan, Philipp Tomsic, Tony Xie,
	Otavio Salvador, devicetree, Heiko Stuebner, linux-kernel,
	linux-rockchip, Rob Herring, Mark Rutland

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 <otavio@ossystems.com.br>
---

 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] ARM: dts: rockchip: rv1108-elgin: Use the correct regulator properties
  2019-01-29 19:54 [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Otavio Salvador
  2019-01-29 19:54 ` [PATCH 2/4] ARM: dts: rockchip: rv1108-elgin: Fix vcc5/6-supply representation Otavio Salvador
@ 2019-01-29 19:54 ` Otavio Salvador
  2019-01-29 19:54 ` [PATCH 4/4] ARM: dts: rockchip: rv1108-evb: " Otavio Salvador
  2019-01-30 15:39 ` [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2019-01-29 19:54 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Jason Zhu, Vicent Chi, Andy Yan, Philipp Tomsic, Tony Xie,
	Otavio Salvador, devicetree, Heiko Stuebner, linux-kernel,
	linux-rockchip, Rob Herring, Mark Rutland

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 <otavio@ossystems.com.br>
---

 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] ARM: dts: rockchip: rv1108-evb: Use the correct regulator properties
  2019-01-29 19:54 [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Otavio Salvador
  2019-01-29 19:54 ` [PATCH 2/4] ARM: dts: rockchip: rv1108-elgin: Fix vcc5/6-supply representation Otavio Salvador
  2019-01-29 19:54 ` [PATCH 3/4] ARM: dts: rockchip: rv1108-elgin: Use the correct regulator properties Otavio Salvador
@ 2019-01-29 19:54 ` Otavio Salvador
  2019-01-30 15:39 ` [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2019-01-29 19:54 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Jason Zhu, Vicent Chi, Andy Yan, Philipp Tomsic, Tony Xie,
	Otavio Salvador, devicetree, Heiko Stuebner, linux-kernel,
	linux-rockchip, Rob Herring, Mark Rutland

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 <otavio@ossystems.com.br>
---

 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805
  2019-01-29 19:54 [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Otavio Salvador
                   ` (2 preceding siblings ...)
  2019-01-29 19:54 ` [PATCH 4/4] ARM: dts: rockchip: rv1108-evb: " Otavio Salvador
@ 2019-01-30 15:39 ` Mark Brown
  2019-01-31 12:45   ` Otavio Salvador
  3 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2019-01-30 15:39 UTC (permalink / raw)
  To: Otavio Salvador
  Cc: linux-arm-kernel, Jason Zhu, Vicent Chi, Andy Yan,
	Philipp Tomsic, Tony Xie, Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

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?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805
  2019-01-30 15:39 ` [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Mark Brown
@ 2019-01-31 12:45   ` Otavio Salvador
  0 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2019-01-31 12:45 UTC (permalink / raw)
  To: Mark Brown
  Cc: Otavio Salvador, Jason Zhu, Liam Girdwood,
	Kernel development list, Tony Xie, Vicent Chi, Andy Yan,
	Philipp Tomsic, linux-arm-kernel

Hello Mark,

On Wed, Jan 30, 2019 at 1:40 PM Mark Brown <broonie@kernel.org> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-01-31 12:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 19:54 [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Otavio Salvador
2019-01-29 19:54 ` [PATCH 2/4] ARM: dts: rockchip: rv1108-elgin: Fix vcc5/6-supply representation Otavio Salvador
2019-01-29 19:54 ` [PATCH 3/4] ARM: dts: rockchip: rv1108-elgin: Use the correct regulator properties Otavio Salvador
2019-01-29 19:54 ` [PATCH 4/4] ARM: dts: rockchip: rv1108-evb: " Otavio Salvador
2019-01-30 15:39 ` [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Mark Brown
2019-01-31 12:45   ` Otavio Salvador

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).