public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] OMAP3: SR: Fix SR driver to check for omap-pm return values
@ 2009-04-29  6:58 Rajendra Nayak
  2009-04-29  7:49 ` Roger Quadros
  2009-05-13 14:52 ` Kevin Hilman
  0 siblings, 2 replies; 4+ messages in thread
From: Rajendra Nayak @ 2009-04-29  6:58 UTC (permalink / raw)
  To: linux-omap; +Cc: Rajendra Nayak

This patch checks for the return values of omap_pm_vddx_get_opp()
in SR driver and acts accordingly. With no SRF layer enabled the OMAP-PM layer
api is unable to return the current OPP.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/smartreflex.c |   42 +++++++++++++++++++++++++++++++++---
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index ae5c336..04baa8e 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -247,13 +247,19 @@ static void sr_set_nvalues(struct omap_sr *sr)
 static void sr_configure_vp(int srid)
 {
 	u32 vpconfig;
+	u32 vsel;
 
 	if (srid == SR1) {
+		if (!omap_pm_vdd1_get_opp())
+			/* Assume Nominal OPP as current OPP unknown */
+			vsel = mpu_opps[VDD1_OPP3].vsel;
+		else
+			vsel = mpu_opps[omap_pm_vdd1_get_opp()].vsel;
+
 		vpconfig = PRM_VP1_CONFIG_ERROROFFSET |
 			PRM_VP1_CONFIG_ERRORGAIN |
 			PRM_VP1_CONFIG_TIMEOUTEN |
-			mpu_opps[omap_pm_vdd1_get_opp()].vsel <<
-			OMAP3430_INITVOLTAGE_SHIFT;
+			vsel << OMAP3430_INITVOLTAGE_SHIFT;
 
 		prm_write_mod_reg(vpconfig, OMAP3430_GR_MOD,
 					OMAP3_PRM_VP1_CONFIG_OFFSET);
@@ -289,11 +295,16 @@ static void sr_configure_vp(int srid)
 				       OMAP3_PRM_VP1_CONFIG_OFFSET);
 
 	} else if (srid == SR2) {
+		if (!omap_pm_vdd2_get_opp())
+			/* Assume Nominal OPP */
+			vsel = l3_opps[VDD2_OPP3].vsel;
+		else
+			vsel = l3_opps[omap_pm_vdd2_get_opp()].vsel;
+
 		vpconfig = PRM_VP2_CONFIG_ERROROFFSET |
 			PRM_VP2_CONFIG_ERRORGAIN |
 			PRM_VP2_CONFIG_TIMEOUTEN |
-			l3_opps[omap_pm_vdd2_get_opp()].vsel <<
-			OMAP3430_INITVOLTAGE_SHIFT;
+			vsel << OMAP3430_INITVOLTAGE_SHIFT;
 
 		prm_write_mod_reg(vpconfig, OMAP3430_GR_MOD,
 					OMAP3_PRM_VP2_CONFIG_OFFSET);
@@ -387,10 +398,18 @@ static int sr_reset_voltage(int srid)
 
 	if (srid == SR1) {
 		target_opp_no = omap_pm_vdd1_get_opp();
+		if (!target_opp_no) {
+			pr_info("Current OPP unknown: Cannot reset voltage\n");
+			return 1;
+		}
 		vsel = mpu_opps[target_opp_no].vsel;
 		reg_addr = R_VDD1_SR_CONTROL;
 	} else if (srid == SR2) {
 		target_opp_no = omap_pm_vdd2_get_opp();
+		if (!target_opp_no) {
+			pr_info("Current OPP unknown: Cannot reset voltage\n");
+			return 1;
+		}
 		vsel = l3_opps[target_opp_no].vsel;
 		reg_addr = R_VDD2_SR_CONTROL;
 	}
@@ -620,6 +639,11 @@ void enable_smartreflex(int srid)
 			else if (srid == SR2)
 				target_opp_no = omap_pm_vdd2_get_opp();
 
+			if (!target_opp_no) {
+				pr_info("Current OPP unknown \
+						 Cannot configure SR\n");
+			}
+
 			sr_configure(sr);
 
 			if (!sr_enable(sr, target_opp_no))
@@ -754,6 +778,11 @@ static ssize_t omap_sr_vdd1_autocomp_store(struct kobject *kobj,
 
 	current_vdd1opp_no = omap_pm_vdd1_get_opp();
 
+	if (!current_vdd1opp_no) {
+		pr_err("sr_vdd1_autocomp: Current VDD1 opp unknown\n");
+		return -EINVAL;
+	}
+
 	if (value == 0)
 		sr_stop_vddautocomap(SR1);
 	else
@@ -792,6 +821,11 @@ static ssize_t omap_sr_vdd2_autocomp_store(struct kobject *kobj,
 
 	current_vdd2opp_no = omap_pm_vdd2_get_opp();
 
+	if (!current_vdd2opp_no) {
+		pr_err("sr_vdd2_autocomp: Current VDD2 opp unknown\n");
+		return -EINVAL;
+	}
+
 	if (value == 0)
 		sr_stop_vddautocomap(SR2);
 	else
-- 
1.5.4.7


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

* Re: [PATCH] OMAP3: SR: Fix SR driver to check for omap-pm return values
  2009-04-29  6:58 [PATCH] OMAP3: SR: Fix SR driver to check for omap-pm return values Rajendra Nayak
@ 2009-04-29  7:49 ` Roger Quadros
  2009-04-29 11:45   ` Nayak, Rajendra
  2009-05-13 14:52 ` Kevin Hilman
  1 sibling, 1 reply; 4+ messages in thread
From: Roger Quadros @ 2009-04-29  7:49 UTC (permalink / raw)
  To: ext Rajendra Nayak; +Cc: linux-omap

ext Rajendra Nayak wrote:
> This patch checks for the return values of omap_pm_vddx_get_opp()
> in SR driver and acts accordingly. With no SRF layer enabled the OMAP-PM layer
> api is unable to return the current OPP.
> 
> Signed-off-by: Rajendra Nayak <rnayak@ti.com>
> ---
>  arch/arm/mach-omap2/smartreflex.c |   42 +++++++++++++++++++++++++++++++++---
>  1 files changed, 38 insertions(+), 4 deletions(-)
> 

> +		if (!omap_pm_vdd1_get_opp())
> +			/* Assume Nominal OPP as current OPP unknown */
> +			vsel = mpu_opps[VDD1_OPP3].vsel;
> +		else
> +			vsel = mpu_opps[omap_pm_vdd1_get_opp()].vsel;
> +

Hi Rajendra,

   By this approach, what will be the implications if the bootloader had set the 
OPP to something different than your assumption?
   I think the best approach would be to modify the PM layer to at least return 
correct OPP and Frequency values. What do you think?
   We should not expect every driver using X_get_opp to assume the OPP if it 
returns error.

Please see this thread to see the alternative solution.
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg12021.html

I know it uses resource framework even if we set PM_NONE or PM_NOOP, but only 
for getting the correct OPP/frequency values.

regards,
-roger

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

* RE: [PATCH] OMAP3: SR: Fix SR driver to check for omap-pm return values
  2009-04-29  7:49 ` Roger Quadros
@ 2009-04-29 11:45   ` Nayak, Rajendra
  0 siblings, 0 replies; 4+ messages in thread
From: Nayak, Rajendra @ 2009-04-29 11:45 UTC (permalink / raw)
  To: Roger Quadros; +Cc: linux-omap@vger.kernel.org



> -----Original Message-----
> From: Roger Quadros [mailto:ext-roger.quadros@nokia.com] 
> Sent: Wednesday, April 29, 2009 1:20 PM
> To: Nayak, Rajendra
> Cc: linux-omap@vger.kernel.org
> Subject: Re: [PATCH] OMAP3: SR: Fix SR driver to check for 
> omap-pm return values
> 
> ext Rajendra Nayak wrote:
> > This patch checks for the return values of omap_pm_vddx_get_opp()
> > in SR driver and acts accordingly. With no SRF layer 
> enabled the OMAP-PM layer
> > api is unable to return the current OPP.
> > 
> > Signed-off-by: Rajendra Nayak <rnayak@ti.com>
> > ---
> >  arch/arm/mach-omap2/smartreflex.c |   42 
> +++++++++++++++++++++++++++++++++---
> >  1 files changed, 38 insertions(+), 4 deletions(-)
> > 
> 
> > +		if (!omap_pm_vdd1_get_opp())
> > +			/* Assume Nominal OPP as current OPP unknown */
> > +			vsel = mpu_opps[VDD1_OPP3].vsel;
> > +		else
> > +			vsel = mpu_opps[omap_pm_vdd1_get_opp()].vsel;
> > +
> 
> Hi Rajendra,
> 
>    By this approach, what will be the implications if the 
> bootloader had set the 
> OPP to something different than your assumption?
>    I think the best approach would be to modify the PM layer 
> to at least return 
> correct OPP and Frequency values. What do you think?

The PM layer was designed to be just a thin wrapper layer, which
on its own does not have any way to return the right OPP.
It relies on SRF or something else below to provide the right info.

The assumption of OPP comes in only with SRF disabled and nothing
else present to replace the functionality. 
Any reason why SRF is disabled in Nokia builds?

>    We should not expect every driver using X_get_opp to 
> assume the OPP if it 
> returns error.
> 
> Please see this thread to see the alternative solution.
> http://www.mail-archive.com/linux-omap@vger.kernel.org/msg12021.html
> 
> I know it uses resource framework even if we set PM_NONE or 
> PM_NOOP, but only 
> for getting the correct OPP/frequency values.
> 
> regards,
> -roger
> 
> 

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

* Re: [PATCH] OMAP3: SR: Fix SR driver to check for omap-pm return values
  2009-04-29  6:58 [PATCH] OMAP3: SR: Fix SR driver to check for omap-pm return values Rajendra Nayak
  2009-04-29  7:49 ` Roger Quadros
@ 2009-05-13 14:52 ` Kevin Hilman
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2009-05-13 14:52 UTC (permalink / raw)
  To: Rajendra Nayak; +Cc: linux-omap

Rajendra Nayak <rnayak@ti.com> writes:

> This patch checks for the return values of omap_pm_vddx_get_opp()
> in SR driver and acts accordingly. With no SRF layer enabled the OMAP-PM layer
> api is unable to return the current OPP.
>
> Signed-off-by: Rajendra Nayak <rnayak@ti.com>

Thanks, pushing to the PM branch.

I preferred this approach to Roger's approach as I don't currently
like the idea of making PM_NONE and PM_NOOP dependent on SRF, even for
just OPPs.

Kevin


> ---
>  arch/arm/mach-omap2/smartreflex.c |   42 +++++++++++++++++++++++++++++++++---
>  1 files changed, 38 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index ae5c336..04baa8e 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -247,13 +247,19 @@ static void sr_set_nvalues(struct omap_sr *sr)
>  static void sr_configure_vp(int srid)
>  {
>  	u32 vpconfig;
> +	u32 vsel;
>  
>  	if (srid == SR1) {
> +		if (!omap_pm_vdd1_get_opp())
> +			/* Assume Nominal OPP as current OPP unknown */
> +			vsel = mpu_opps[VDD1_OPP3].vsel;
> +		else
> +			vsel = mpu_opps[omap_pm_vdd1_get_opp()].vsel;
> +
>  		vpconfig = PRM_VP1_CONFIG_ERROROFFSET |
>  			PRM_VP1_CONFIG_ERRORGAIN |
>  			PRM_VP1_CONFIG_TIMEOUTEN |
> -			mpu_opps[omap_pm_vdd1_get_opp()].vsel <<
> -			OMAP3430_INITVOLTAGE_SHIFT;
> +			vsel << OMAP3430_INITVOLTAGE_SHIFT;
>  
>  		prm_write_mod_reg(vpconfig, OMAP3430_GR_MOD,
>  					OMAP3_PRM_VP1_CONFIG_OFFSET);
> @@ -289,11 +295,16 @@ static void sr_configure_vp(int srid)
>  				       OMAP3_PRM_VP1_CONFIG_OFFSET);
>  
>  	} else if (srid == SR2) {
> +		if (!omap_pm_vdd2_get_opp())
> +			/* Assume Nominal OPP */
> +			vsel = l3_opps[VDD2_OPP3].vsel;
> +		else
> +			vsel = l3_opps[omap_pm_vdd2_get_opp()].vsel;
> +
>  		vpconfig = PRM_VP2_CONFIG_ERROROFFSET |
>  			PRM_VP2_CONFIG_ERRORGAIN |
>  			PRM_VP2_CONFIG_TIMEOUTEN |
> -			l3_opps[omap_pm_vdd2_get_opp()].vsel <<
> -			OMAP3430_INITVOLTAGE_SHIFT;
> +			vsel << OMAP3430_INITVOLTAGE_SHIFT;
>  
>  		prm_write_mod_reg(vpconfig, OMAP3430_GR_MOD,
>  					OMAP3_PRM_VP2_CONFIG_OFFSET);
> @@ -387,10 +398,18 @@ static int sr_reset_voltage(int srid)
>  
>  	if (srid == SR1) {
>  		target_opp_no = omap_pm_vdd1_get_opp();
> +		if (!target_opp_no) {
> +			pr_info("Current OPP unknown: Cannot reset voltage\n");
> +			return 1;
> +		}
>  		vsel = mpu_opps[target_opp_no].vsel;
>  		reg_addr = R_VDD1_SR_CONTROL;
>  	} else if (srid == SR2) {
>  		target_opp_no = omap_pm_vdd2_get_opp();
> +		if (!target_opp_no) {
> +			pr_info("Current OPP unknown: Cannot reset voltage\n");
> +			return 1;
> +		}
>  		vsel = l3_opps[target_opp_no].vsel;
>  		reg_addr = R_VDD2_SR_CONTROL;
>  	}
> @@ -620,6 +639,11 @@ void enable_smartreflex(int srid)
>  			else if (srid == SR2)
>  				target_opp_no = omap_pm_vdd2_get_opp();
>  
> +			if (!target_opp_no) {
> +				pr_info("Current OPP unknown \
> +						 Cannot configure SR\n");
> +			}
> +
>  			sr_configure(sr);
>  
>  			if (!sr_enable(sr, target_opp_no))
> @@ -754,6 +778,11 @@ static ssize_t omap_sr_vdd1_autocomp_store(struct kobject *kobj,
>  
>  	current_vdd1opp_no = omap_pm_vdd1_get_opp();
>  
> +	if (!current_vdd1opp_no) {
> +		pr_err("sr_vdd1_autocomp: Current VDD1 opp unknown\n");
> +		return -EINVAL;
> +	}
> +
>  	if (value == 0)
>  		sr_stop_vddautocomap(SR1);
>  	else
> @@ -792,6 +821,11 @@ static ssize_t omap_sr_vdd2_autocomp_store(struct kobject *kobj,
>  
>  	current_vdd2opp_no = omap_pm_vdd2_get_opp();
>  
> +	if (!current_vdd2opp_no) {
> +		pr_err("sr_vdd2_autocomp: Current VDD2 opp unknown\n");
> +		return -EINVAL;
> +	}
> +
>  	if (value == 0)
>  		sr_stop_vddautocomap(SR2);
>  	else
> -- 
> 1.5.4.7
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2009-05-13 14:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-29  6:58 [PATCH] OMAP3: SR: Fix SR driver to check for omap-pm return values Rajendra Nayak
2009-04-29  7:49 ` Roger Quadros
2009-04-29 11:45   ` Nayak, Rajendra
2009-05-13 14:52 ` Kevin Hilman

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