public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: OMAP2+: voltage: ensure voltage used is exact voltage from OPP table
Date: Mon, 5 Mar 2012 11:41:27 +0200	[thread overview]
Message-ID: <1330940487.2116.119.camel@sokoban> (raw)
In-Reply-To: <1330728121-26664-1-git-send-email-khilman@ti.com>

On Fri, 2012-03-02 at 14:42 -0800, Kevin Hilman wrote:
> 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

> 
> Cc: Tero Kristo <t-kristo@ti.com>
> Cc: Nishanth Menon <nm@ti.com>
> Signed-off-by: Kevin Hilman <khilman@ti.com>
> ---
> 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(-)
> 
> diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
> index 8a36342..4dc60e8 100644
> --- a/arch/arm/mach-omap2/voltage.c
> +++ b/arch/arm/mach-omap2/voltage.c
> @@ -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;
>  }

  reply	other threads:[~2012-03-05  9:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-02 22:42 [PATCH] ARM: OMAP2+: voltage: ensure voltage used is exact voltage from OPP table Kevin Hilman
2012-03-05  9:41 ` Tero Kristo [this message]
2012-03-05 18:12   ` Kevin Hilman
2012-03-06  6:12     ` Nishanth Menon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330940487.2116.119.camel@sokoban \
    --to=t-kristo@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox