mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master v2] regulator: rk808: fix misplaced DCDC_REG5
@ 2022-11-30 17:14 Ahmad Fatoum
  2022-12-01  7:27 ` Michael Riesch
  2022-12-02  8:50 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-11-30 17:14 UTC (permalink / raw)
  To: barebox; +Cc: Michael Riesch, Ahmad Fatoum

Driver was written to mimic existing stpmic1 regulator driver, which had
the implicit assumption of a 1:1 relationship between of_match_data and
regulator configuration with same indices.

Yet DCDC_REG5 was not at the same place it was in the rk_regulator_cfg
due to likely a copy-paste mistake, leading to possibly the wrong
regulators being controlled. Fix this.

Reported-by: Michael Riesch <michael.riesch@wolfvision.net>
Suggested-by: Michael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
move entry in rk809_reg, not rk809_reg_matches to keep same numbering as
enum rk809_reg_id.
---
 drivers/regulator/rk808-regulator.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
index 39eadbd3ebe5..f8bc31f354e2 100644
--- a/ drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -526,19 +526,6 @@ static struct rk_regulator_cfg rk809_reg[] = {
 		.enable_mask = ENABLE_MASK(RK817_ID_DCDC4),
 		.enable_val = ENABLE_MASK(RK817_ID_DCDC4),
 		.disable_val = DISABLE_VAL(RK817_ID_DCDC4),
-	}}, {{
-		/* .name = "DCDC_REG5", */
-		.supply_name = "vcc9",
-		.ops = &rk809_buck5_ops_range,
-		.n_voltages = RK809_BUCK5_SEL_CNT,
-		.linear_ranges = rk809_buck5_voltage_ranges,
-		.n_linear_ranges = ARRAY_SIZE(rk809_buck5_voltage_ranges),
-		.vsel_reg = RK809_BUCK5_CONFIG(0),
-		.vsel_mask = RK809_BUCK5_VSEL_MASK,
-		.enable_reg = RK817_POWER_EN_REG(3),
-		.enable_mask = ENABLE_MASK(1),
-		.enable_val = ENABLE_MASK(1),
-		.disable_val = DISABLE_VAL(1),
 	}},
 	RK817_DESC(/* "LDO_REG1", */ "vcc5", 600, 3400, 25,
 		   RK817_LDO_ON_VSEL_REG(0), RK817_LDO_VSEL_MASK,
@@ -576,6 +563,20 @@ static struct rk_regulator_cfg rk809_reg[] = {
 		   RK817_LDO_ON_VSEL_REG(8), RK817_LDO_VSEL_MASK,
 		   RK817_POWER_EN_REG(3), ENABLE_MASK(0),
 		   DISABLE_VAL(0), 400),
+	{{
+		/* .name = "DCDC_REG5", */
+		.supply_name = "vcc9",
+		.ops = &rk809_buck5_ops_range,
+		.n_voltages = RK809_BUCK5_SEL_CNT,
+		.linear_ranges = rk809_buck5_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk809_buck5_voltage_ranges),
+		.vsel_reg = RK809_BUCK5_CONFIG(0),
+		.vsel_mask = RK809_BUCK5_VSEL_MASK,
+		.enable_reg = RK817_POWER_EN_REG(3),
+		.enable_mask = ENABLE_MASK(1),
+		.enable_val = ENABLE_MASK(1),
+		.disable_val = DISABLE_VAL(1),
+	}},
 	RK817_DESC_SWITCH(/* "SWITCH_REG1", */ "vcc9",
 			  RK817_POWER_EN_REG(3), ENABLE_MASK(2), DISABLE_VAL(2)),
 	RK817_DESC_SWITCH(/* "SWITCH_REG2", */ "vcc8",
-- 
2.30.2




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

* Re: [PATCH master v2] regulator: rk808: fix misplaced DCDC_REG5
  2022-11-30 17:14 [PATCH master v2] regulator: rk808: fix misplaced DCDC_REG5 Ahmad Fatoum
@ 2022-12-01  7:27 ` Michael Riesch
  2022-12-02  8:50 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Riesch @ 2022-12-01  7:27 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox

Hi Ahmad,

On 11/30/22 18:14, Ahmad Fatoum wrote:
> Driver was written to mimic existing stpmic1 regulator driver, which had
> the implicit assumption of a 1:1 relationship between of_match_data and
> regulator configuration with same indices.
> 
> Yet DCDC_REG5 was not at the same place it was in the rk_regulator_cfg
> due to likely a copy-paste mistake, leading to possibly the wrong
> regulators being controlled. Fix this.

Cool, thanks for the fix!

> 
> Reported-by: Michael Riesch <michael.riesch@wolfvision.net>
> Suggested-by: Michael Riesch <michael.riesch@wolfvision.net>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Reviewed-by: Michael Riesch <michael.riesch@wolfvision.net>

> ---
> move entry in rk809_reg, not rk809_reg_matches to keep same numbering as
> enum rk809_reg_id.

Note that I haven't tested your patch, but v2 is identical to the fix I
have applied and tested in my setup. So it should be fine (TM).

Best regards,
Michael

> ---
>  drivers/regulator/rk808-regulator.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
> index 39eadbd3ebe5..f8bc31f354e2 100644
> --- a/ drivers/regulator/rk808-regulator.c
> +++ b/drivers/regulator/rk808-regulator.c
> @@ -526,19 +526,6 @@ static struct rk_regulator_cfg rk809_reg[] = {
>  		.enable_mask = ENABLE_MASK(RK817_ID_DCDC4),
>  		.enable_val = ENABLE_MASK(RK817_ID_DCDC4),
>  		.disable_val = DISABLE_VAL(RK817_ID_DCDC4),
> -	}}, {{
> -		/* .name = "DCDC_REG5", */
> -		.supply_name = "vcc9",
> -		.ops = &rk809_buck5_ops_range,
> -		.n_voltages = RK809_BUCK5_SEL_CNT,
> -		.linear_ranges = rk809_buck5_voltage_ranges,
> -		.n_linear_ranges = ARRAY_SIZE(rk809_buck5_voltage_ranges),
> -		.vsel_reg = RK809_BUCK5_CONFIG(0),
> -		.vsel_mask = RK809_BUCK5_VSEL_MASK,
> -		.enable_reg = RK817_POWER_EN_REG(3),
> -		.enable_mask = ENABLE_MASK(1),
> -		.enable_val = ENABLE_MASK(1),
> -		.disable_val = DISABLE_VAL(1),
>  	}},
>  	RK817_DESC(/* "LDO_REG1", */ "vcc5", 600, 3400, 25,
>  		   RK817_LDO_ON_VSEL_REG(0), RK817_LDO_VSEL_MASK,
> @@ -576,6 +563,20 @@ static struct rk_regulator_cfg rk809_reg[] = {
>  		   RK817_LDO_ON_VSEL_REG(8), RK817_LDO_VSEL_MASK,
>  		   RK817_POWER_EN_REG(3), ENABLE_MASK(0),
>  		   DISABLE_VAL(0), 400),
> +	{{
> +		/* .name = "DCDC_REG5", */
> +		.supply_name = "vcc9",
> +		.ops = &rk809_buck5_ops_range,
> +		.n_voltages = RK809_BUCK5_SEL_CNT,
> +		.linear_ranges = rk809_buck5_voltage_ranges,
> +		.n_linear_ranges = ARRAY_SIZE(rk809_buck5_voltage_ranges),
> +		.vsel_reg = RK809_BUCK5_CONFIG(0),
> +		.vsel_mask = RK809_BUCK5_VSEL_MASK,
> +		.enable_reg = RK817_POWER_EN_REG(3),
> +		.enable_mask = ENABLE_MASK(1),
> +		.enable_val = ENABLE_MASK(1),
> +		.disable_val = DISABLE_VAL(1),
> +	}},
>  	RK817_DESC_SWITCH(/* "SWITCH_REG1", */ "vcc9",
>  			  RK817_POWER_EN_REG(3), ENABLE_MASK(2), DISABLE_VAL(2)),
>  	RK817_DESC_SWITCH(/* "SWITCH_REG2", */ "vcc8",



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

* Re: [PATCH master v2] regulator: rk808: fix misplaced DCDC_REG5
  2022-11-30 17:14 [PATCH master v2] regulator: rk808: fix misplaced DCDC_REG5 Ahmad Fatoum
  2022-12-01  7:27 ` Michael Riesch
@ 2022-12-02  8:50 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2022-12-02  8:50 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Michael Riesch

On Wed, Nov 30, 2022 at 06:14:39PM +0100, Ahmad Fatoum wrote:
> Driver was written to mimic existing stpmic1 regulator driver, which had
> the implicit assumption of a 1:1 relationship between of_match_data and
> regulator configuration with same indices.
> 
> Yet DCDC_REG5 was not at the same place it was in the rk_regulator_cfg
> due to likely a copy-paste mistake, leading to possibly the wrong
> regulators being controlled. Fix this.
> 
> Reported-by: Michael Riesch <michael.riesch@wolfvision.net>
> Suggested-by: Michael Riesch <michael.riesch@wolfvision.net>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> move entry in rk809_reg, not rk809_reg_matches to keep same numbering as
> enum rk809_reg_id.
> ---
>  drivers/regulator/rk808-regulator.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
> index 39eadbd3ebe5..f8bc31f354e2 100644
> --- a/ drivers/regulator/rk808-regulator.c
> +++ b/drivers/regulator/rk808-regulator.c
> @@ -526,19 +526,6 @@ static struct rk_regulator_cfg rk809_reg[] = {
>  		.enable_mask = ENABLE_MASK(RK817_ID_DCDC4),
>  		.enable_val = ENABLE_MASK(RK817_ID_DCDC4),
>  		.disable_val = DISABLE_VAL(RK817_ID_DCDC4),
> -	}}, {{
> -		/* .name = "DCDC_REG5", */
> -		.supply_name = "vcc9",
> -		.ops = &rk809_buck5_ops_range,
> -		.n_voltages = RK809_BUCK5_SEL_CNT,
> -		.linear_ranges = rk809_buck5_voltage_ranges,
> -		.n_linear_ranges = ARRAY_SIZE(rk809_buck5_voltage_ranges),
> -		.vsel_reg = RK809_BUCK5_CONFIG(0),
> -		.vsel_mask = RK809_BUCK5_VSEL_MASK,
> -		.enable_reg = RK817_POWER_EN_REG(3),
> -		.enable_mask = ENABLE_MASK(1),
> -		.enable_val = ENABLE_MASK(1),
> -		.disable_val = DISABLE_VAL(1),
>  	}},
>  	RK817_DESC(/* "LDO_REG1", */ "vcc5", 600, 3400, 25,
>  		   RK817_LDO_ON_VSEL_REG(0), RK817_LDO_VSEL_MASK,
> @@ -576,6 +563,20 @@ static struct rk_regulator_cfg rk809_reg[] = {
>  		   RK817_LDO_ON_VSEL_REG(8), RK817_LDO_VSEL_MASK,
>  		   RK817_POWER_EN_REG(3), ENABLE_MASK(0),
>  		   DISABLE_VAL(0), 400),
> +	{{
> +		/* .name = "DCDC_REG5", */
> +		.supply_name = "vcc9",
> +		.ops = &rk809_buck5_ops_range,
> +		.n_voltages = RK809_BUCK5_SEL_CNT,
> +		.linear_ranges = rk809_buck5_voltage_ranges,
> +		.n_linear_ranges = ARRAY_SIZE(rk809_buck5_voltage_ranges),
> +		.vsel_reg = RK809_BUCK5_CONFIG(0),
> +		.vsel_mask = RK809_BUCK5_VSEL_MASK,
> +		.enable_reg = RK817_POWER_EN_REG(3),
> +		.enable_mask = ENABLE_MASK(1),
> +		.enable_val = ENABLE_MASK(1),
> +		.disable_val = DISABLE_VAL(1),
> +	}},
>  	RK817_DESC_SWITCH(/* "SWITCH_REG1", */ "vcc9",
>  			  RK817_POWER_EN_REG(3), ENABLE_MASK(2), DISABLE_VAL(2)),
>  	RK817_DESC_SWITCH(/* "SWITCH_REG2", */ "vcc8",
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2022-12-02  8:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30 17:14 [PATCH master v2] regulator: rk808: fix misplaced DCDC_REG5 Ahmad Fatoum
2022-12-01  7:27 ` Michael Riesch
2022-12-02  8:50 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox