Skip to contentSkip to conversation

ARM: OMAP2+: voltage: ensure voltage used is exact voltage from OPP table

PATCH New Kevin Hilman 3 participants 4 messages Mar 2, 2012 – Mar 6, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: OMAP2+: voltage: ensure voltage used is exact voltage from OPP table

When using the SMPS regulators to scale voltages, the regulator framework may pass a minimum voltage that is not an exact OPP voltage. For the VC/VP controlled voltage domains, we must ensure that the voltage requested is the exact voltage from the OPP table. This is especially critical when using SR.

To fix, voltdm_scale() uses the target voltage passed to walk through the OPP voltages until it finds a voltage that is >= one of the OPP voltages.

Cc Tero Kristo <[email protected]>
Cc Nishanth Menon <[email protected]>

---
Unless there are any objections, this will be queued along with the rest of the SMPS regulator series from Tero. Currently availble in my for_3.4/pm/smps-regulator branch at
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git

 arch/arm/mach-omap2/voltage.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
arch/arm/mach-omap2/voltage.c +18 -3
index 8a36342..4dc60e8 100644
@@ -73,7 +73,8 @@ unsigned long voltdm_get_voltage(struct voltagedomain *voltdm)
 int voltdm_scale(struct voltagedomain *voltdm,
 		 unsigned long target_volt)
 {
-	int ret;
+	int ret, i;
+	unsigned long volt = 0;
 
 	if (!voltdm || IS_ERR(voltdm)) {
 		pr_warning("%s: VDD specified does not exist!\n", __func__);
@@ -86,9 +87,23 @@ int voltdm_scale(struct voltagedomain *voltdm,
 		return -ENODATA;
 	}
 
-	ret = voltdm->scale(voltdm, target_volt);
+	/* Adjust voltage to the exact voltage from the OPP table */
+	for (i = 0; voltdm->volt_data[i].volt_nominal != 0; i++) {
+		if (voltdm->volt_data[i].volt_nominal >= target_volt) {
+			volt = voltdm->volt_data[i].volt_nominal;
+			break;
+		}
+	}
+
+	if (!volt) {
+		pr_warning("%s: not scaling. OPP voltage for %lu, not found.\n",
+			   __func__, target_volt);
+		return -EINVAL;
+	}
+
+	ret = voltdm->scale(voltdm, volt);
 	if (!ret)
-		voltdm->nominal_volt = target_volt;
+		voltdm->nominal_volt = volt;
 
 	return ret;
 }
Signature · 1 line
1.7.9.2
#1 lore raw

PATCH 1/1 ARM: OMAP2+: voltage: ensure voltage used is exact voltage from OPP table

Quoted 9 lines · Kevin Hilman

When using the SMPS regulators to scale voltages, the regulator framework may pass a minimum voltage that is not an exact OPP voltage. For the VC/VP controlled voltage domains, we must ensure that the voltage requested is the exact voltage from the OPP table. This is especially critical when using SR.

To fix, voltdm_scale() uses the target voltage passed to walk through the OPP voltages until it finds a voltage that is >= one of the OPP voltages.

I have just one question to this, how about smartreflex class1p5? Do we have any plans for that one? The old implementation at least was using voltdm_scale, so if we modify this function, smartreflex class1p5 doesn't work anymore.

Otherwise this patch looks good to me.

-Tero

Quoted 53 lines
Cc Tero Kristo <[email protected]>
Cc Nishanth Menon <[email protected]>

---
Unless there are any objections, this will be queued along with the rest of the SMPS regulator series from Tero. Currently availble in my for_3.4/pm/smps-regulator branch at
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git

 arch/arm/mach-omap2/voltage.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
arch/arm/mach-omap2/voltage.c +18 -3
index 8a36342..4dc60e8 100644
@@ -73,7 +73,8 @@ unsigned long voltdm_get_voltage(struct voltagedomain *voltdm)
 int voltdm_scale(struct voltagedomain *voltdm,
 		 unsigned long target_volt)
 {
-	int ret;
+	int ret, i;
+	unsigned long volt = 0;
 
 	if (!voltdm || IS_ERR(voltdm)) {
 		pr_warning("%s: VDD specified does not exist!\n", __func__);
@@ -86,9 +87,23 @@ int voltdm_scale(struct voltagedomain *voltdm,
 		return -ENODATA;
 	}
 
-	ret = voltdm->scale(voltdm, target_volt);
+	/* Adjust voltage to the exact voltage from the OPP table */
+	for (i = 0; voltdm->volt_data[i].volt_nominal != 0; i++) {
+		if (voltdm->volt_data[i].volt_nominal >= target_volt) {
+			volt = voltdm->volt_data[i].volt_nominal;
+			break;
+		}
+	}
+
+	if (!volt) {
+		pr_warning("%s: not scaling. OPP voltage for %lu, not found.\n",
+			   __func__, target_volt);
+		return -EINVAL;
+	}
+
+	ret = voltdm->scale(voltdm, volt);
 	if (!ret)
-		voltdm->nominal_volt = target_volt;
+		voltdm->nominal_volt = volt;
 
 	return ret;
 }
#2 lore raw

PATCH 1/1 ARM: OMAP2+: voltage: ensure voltage used is exact voltage from OPP table

Quoted 7 lines · Tero Kristo
Quoted 6 lines · Kevin Hilman

When using the SMPS regulators to scale voltages, the regulator framework may pass a minimum voltage that is not an exact OPP voltage. For the VC/VP controlled voltage domains, we must ensure that the voltage requested is the exact voltage from the OPP table. This is especially critical when using SR.

Quoted 8 lines
Quoted 3 lines

To fix, voltdm_scale() uses the target voltage passed to walk through the OPP voltages until it finds a voltage that is >= one of the OPP voltages.

I have just one question to this, how about smartreflex class1p5? Do we have any plans for that one? The old implementation at least was using voltdm_scale, so if we modify this function, smartreflex class1p5 doesn't work anymore.

Since it's not in mainline, that is not my concern at the moment. We can worry about SR1.5 when I someone is motivated to push it upstream.

Quoted 1 line

Otherwise this patch looks good to me.

Thanks for looking.

Kevin

#3 lore raw

PATCH 1/1 ARM: OMAP2+: voltage: ensure voltage used is exact voltage from OPP table

Quoted 13 lines · Kevin Hilman
Quoted 11 lines · Tero Kristo
Quoted 9 lines · Kevin Hilman

When using the SMPS regulators to scale voltages, the regulator framework may pass a minimum voltage that is not an exact OPP voltage. For the VC/VP controlled voltage domains, we must ensure that the voltage requested is the exact voltage from the OPP table. This is especially critical when using SR.

To fix, voltdm_scale() uses the target voltage passed to walk through the OPP voltages until it finds a voltage that is >= one of the OPP voltages.

Quoted 9 lines
Quoted 4 lines

I have just one question to this, how about smartreflex class1p5? Do we have any plans for that one? The old implementation at least was using voltdm_scale, so if we modify this function, smartreflex class1p5 doesn't work anymore.

Since it's not in mainline, that is not my concern at the moment. We can worry about SR1.5 when I someone is motivated to push it upstream.

Quoted 1 line

Otherwise this patch looks good to me.

Other than the minor misgiving of having to re-verify the voltage on every scale, I am OK with it as well.

That said, I don't see why this should break class 1.5/3.5 support.

Signature · 2 lines
Regards,
Nishanth Menon