All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@deeprootsystems.com>
To: Thara Gopinath <thara@ti.com>
Cc: linux-omap@vger.kernel.org, paul@pwsan.com, b-cousson@ti.com,
	vishwanath.bs@ti.com, sawant@ti.com
Subject: Re: [PATCHv3 05/22] OMAP3: PM: Remove OPP id dependency from smartreflex driver
Date: Tue, 27 Apr 2010 11:43:23 -0700	[thread overview]
Message-ID: <87sk6gka7o.fsf@deeprootsystems.com> (raw)
In-Reply-To: <1271408597-3066-6-git-send-email-thara@ti.com> (Thara Gopinath's message of "Fri\, 16 Apr 2010 14\:33\:00 +0530")

Thara Gopinath <thara@ti.com> writes:

> This patch removes get_vdd1_opp and get_vdd2_opp API's and replaces
> them with get_curr_vdd1_voltage and get_curr_vdd2_voltage API's.
> N-target values are now linked to voltages and the link bewtween
> voltage and n-target values is managed internally in smartreflex
> driver and sr_devices.c.
>
> get_curr_vdd1_voltage and get_curr_vdd2_voltage are added in
> smartreflex driver in this patch. These API's will be moved to the
> voltage driver in a later patch when voltage specific code is separated
> out of smartreflex. The link between various voltages and n-target
> values will also be separated out later.
>
> Signed-off-by: Thara Gopinath <thara@ti.com>
> ---
>  arch/arm/mach-omap2/smartreflex.c |  201 +++++++++++++++----------------------
>  arch/arm/mach-omap2/smartreflex.h |   21 +++-
>  arch/arm/mach-omap2/sr_device.c   |   39 ++++++-
>  3 files changed, 129 insertions(+), 132 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 2f89d79..669f1bb 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -48,7 +48,6 @@ struct omap_sr {
>  	int			srid;
>  	int			is_sr_reset;
>  	int			is_autocomp_active;
> -	struct clk		*vdd_opp_clk;
>  	u32			clk_length;
>  	unsigned int		irq;
>  	struct platform_device	*pdev;
> @@ -119,64 +118,65 @@ static void sr_clk_disable(struct omap_sr *sr)
>  	sr->is_sr_reset = 1;
>  }
>  
> -static u8 get_vdd1_opp(void)
> +static unsigned long get_curr_vdd1_voltage(void)
>  {
>  	struct omap_opp *opp;
>  	unsigned long freq;
> -	struct omap_sr *sr_info = _sr_lookup(SR1);
> +	struct clk *dpll1_clk;
>  

> -	if (!sr_info) {
> -		pr_warning("omap_sr struct corresponding to SR1 not found\n");
> -		return 0;
> -	}
> -
> -	if (sr_info->vdd_opp_clk == NULL || IS_ERR(sr_info->vdd_opp_clk))
> +	dpll1_clk = clk_get(NULL, "dpll1_ck");
> +	if (IS_ERR(dpll1_clk))
>  		return 0;
>  
> -	freq = sr_info->vdd_opp_clk->rate;
> -	opp = opp_find_freq_ceil(OPP_MPU, &freq);
> +	freq = dpll1_clk->rate;;
> +	opp = opp_find_freq_exact(OPP_MPU, freq, 1);
>  	if (IS_ERR(opp))
>  		return 0;

I mentioned this in an earlier review, but I think it's best to leave
the clock as part of sr_info.  If you also add the OPP enum value
to sr_info, you could have a single, common function to get current
voltage intstead of a separate one per-VDD.  Otherwise, as additional
voltage domains are added, we need to add another function.

What should result is just a single get_curr_voltage() or similar
which takes an sr_info ptr and doesn't need to sr_lookup()

> -	/*
> -	 * Use higher freq voltage even if an exact match is not available
> -	 * we are probably masking a clock framework bug, so warn
> -	 */
> -	if (unlikely(freq != sr_info->vdd_opp_clk->rate))
> -		pr_warning("%s: Available freq %ld != dpll freq %ld.\n",
> -			   __func__, freq, sr_info->vdd_opp_clk->rate);
>  

Removed here, but added back in subsequent patch.  Should be combined.
Another reason to start condensing this series and reworking against
mainline.

> -	return opp_get_opp_id(opp);
> +	return opp_get_voltage(opp);
>  }
>  
> -static u8 get_vdd2_opp(void)
> +static unsigned long get_curr_vdd2_voltage(void)
>  {
>  	struct omap_opp *opp;
>  	unsigned long freq;
> -	struct omap_sr *sr_info = _sr_lookup(SR2);
> +	struct clk *l3_clk;
>  
> -	if (!sr_info) {
> -		pr_warning("omap_sr struct corresponding to SR2 not found\n");
> -		return 0;
> -	}
> -
> -	if (sr_info->vdd_opp_clk == NULL || IS_ERR(sr_info->vdd_opp_clk))
> +	l3_clk = clk_get(NULL, "l3_ick");
> +	if (IS_ERR(l3_clk))
>  		return 0;
>  
> -	freq = sr_info->vdd_opp_clk->rate;
> -	opp = opp_find_freq_ceil(OPP_L3, &freq);
> +	freq = l3_clk->rate;
> +	opp = opp_find_freq_exact(OPP_L3, freq, 1);
>  	if (IS_ERR(opp))
>  		return 0;
>  
> -	/*
> -	 * Use higher freq voltage even if an exact match is not available
> -	 * we are probably masking a clock framework bug, so warn
> -	 */
> -	if (unlikely(freq != sr_info->vdd_opp_clk->rate))
> -		pr_warning("%s: Available freq %ld != dpll freq %ld.\n",
> -			   __func__, freq, sr_info->vdd_opp_clk->rate);
> -	return opp_get_opp_id(opp);
> +	return opp_get_voltage(opp);
>  }
>  
> +static int sr_match_volt(struct omap_sr *sr, unsigned long volt,
> +				struct omap_volt_data *volt_data)
> +{
> +	struct omap_smartreflex_data *pdata = sr->pdev->dev.platform_data;
> +	struct omap_device *odev = to_omap_device(sr->pdev);
> +	struct omap_smartreflex_dev_data *sr_dev_data =
> +					odev->hwmods[0]->dev_attr;
> +	int i;
> +
> +	if (!pdata->sr_volt_data) {
> +		pr_notice("voltage table does not exist for SR %d\n", sr->srid);

dev_notice()

> +		return false;
> +	}
> +	for (i = 0; i < sr_dev_data->volts_supported; i++) {
> +		if (pdata->sr_volt_data[i].voltage == volt) {
> +			*volt_data = pdata->sr_volt_data[i];
> +			return true;
> +		}
> +	}
> +	pr_notice("Unable to match the current voltage with \
> +				the voltage table for SR %d\n", sr->srid);

dev_notice()

> +	return false;
> +}
>  

[...]

> diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h
> index ea0ddd3..b14ba50 100644
> --- a/arch/arm/mach-omap2/smartreflex.h
> +++ b/arch/arm/mach-omap2/smartreflex.h
> @@ -242,6 +242,17 @@ extern u32 current_vdd2_opp;
>  #endif
>  
>  /**
> + * omap_volt_data - Omap voltage specific data.
> + *
> + * @voltage	: The possible voltage value
> + * @sr_nvalue	: Smartreflex N target value at voltage <voltage>
> + */
> +struct omap_volt_data {
> +	unsigned long	voltage;
> +	u32		sr_nvalue;
> +};
> +
> +/**
>   * omap_smartreflex_dev_data - Smartreflex device specific data
>   *
>   * @volts_supported	: Number of distinct voltages possible for the VDD
> @@ -295,10 +306,10 @@ struct omap_smartreflex_dev_data {
>   * @device_idle		: fn pointer to be pouplated with omap_device idle API
>   */
>  struct omap_smartreflex_data {
> -	u32		senp_mod;
> -	u32		senn_mod;
> -	u32		*sr_nvalue;
> -	bool		enable_on_init;
> +	u32				senp_mod;
> +	u32				senn_mod;
> +	struct omap_volt_data		*sr_volt_data;

minor nit: drop the sr_ prefix

> +	bool				enable_on_init;
>  	int (*device_enable)(struct platform_device *pdev);
>  	int (*device_shutdown)(struct platform_device *pdev);
>  	int (*device_idle)(struct platform_device *pdev);
> @@ -307,7 +318,7 @@ struct omap_smartreflex_data {
>  void enable_smartreflex(int srid);
>  void disable_smartreflex(int srid);
>  int sr_voltagescale_vcbypass(u32 t_opp, u32 c_opp, u8 t_vsel, u8 c_vsel);
> -void sr_start_vddautocomap(int srid, u32 target_opp_no);
> +void sr_start_vddautocomap(int srid, unsigned long volt);
>  int sr_stop_vddautocomap(int srid);
>  #else
>  static inline void enable_smartreflex(int srid) {}
> diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
> index a9c1ef0..544d575 100644
> --- a/arch/arm/mach-omap2/sr_device.c
> +++ b/arch/arm/mach-omap2/sr_device.c
> @@ -51,8 +51,9 @@ static void __init sr_read_efuse(
>  			!dev_data->efuse_nvalues_offs))
>  		return;
>  
> -	sr_data->sr_nvalue = kzalloc(sizeof(sr_data->sr_nvalue) *
> -			dev_data->volts_supported , GFP_KERNEL);
> +	if (WARN_ON(!sr_data->sr_volt_data))
> +		return;
> +
>  	sr_data->senn_mod = (omap_ctrl_readl(dev_data->efuse_sr_control) &
>  				(0x3 << dev_data->sennenable_shift) >>
>  				dev_data->sennenable_shift);
> @@ -60,7 +61,7 @@ static void __init sr_read_efuse(
>  				(0x3 << dev_data->senpenable_shift) >>
>  				dev_data->senpenable_shift);
>  	for (i = 0; i < dev_data->volts_supported; i++)
> -		sr_data->sr_nvalue[i] = omap_ctrl_readl(
> +		sr_data->sr_volt_data[i].sr_nvalue = omap_ctrl_readl(
>  				dev_data->efuse_nvalues_offs[i]);
>  }
>  
> @@ -78,12 +79,13 @@ static void __init sr_set_testing_nvalues(
>  			!dev_data->test_nvalues))
>  		return;
>  
> -	sr_data->sr_nvalue = kzalloc(sizeof(sr_data->sr_nvalue) *
> -			dev_data->volts_supported , GFP_KERNEL);
> +	if (WARN_ON(!sr_data->sr_volt_data))
> +		return;
> +
>  	sr_data->senn_mod = dev_data->test_sennenable;
>  	sr_data->senp_mod = dev_data->test_senpenable;
>  	for (i = 0; i < dev_data->volts_supported; i++)
> -		sr_data->sr_nvalue[i] = dev_data->test_nvalues[i];
> +		sr_data->sr_volt_data[i].sr_nvalue = dev_data->test_nvalues[i];
>  }
>  
>  static void __init sr_set_nvalues(struct omap_smartreflex_dev_data *dev_data,
> @@ -97,6 +99,28 @@ static void __init sr_set_nvalues(struct omap_smartreflex_dev_data *dev_data,
>  	}
>  }
>  
> +static void __init omap34xx_sr_volt_details(struct omap_smartreflex_data
> +						*sr_data, int srid,
> +						int volt_count)
> +{
> +	sr_data->sr_volt_data = kzalloc(sizeof(sr_data->sr_volt_data) *
> +				volt_count , GFP_KERNEL);
> +	if (WARN_ON(!sr_data->sr_volt_data))
> +		return;
> +
> +	if (srid == SR1) {
> +		sr_data->sr_volt_data[0].voltage = 975000;
> +		sr_data->sr_volt_data[1].voltage = 1075000;
> +		sr_data->sr_volt_data[2].voltage = 1200000;
> +		sr_data->sr_volt_data[3].voltage = 1270000;
> +		sr_data->sr_volt_data[4].voltage = 1350000;
> +	} else if (srid == SR2) {
> +		sr_data->sr_volt_data[0].voltage = 975000;
> +		sr_data->sr_volt_data[1].voltage = 1050000;
> +		sr_data->sr_volt_data[2].voltage = 1150000;
> +	}
> +}
> +

again, more stuff added that is removed later.  Time to start condensing
as it's getting hard to keep track of.

[...]

Kevin


  parent reply	other threads:[~2010-04-27 18:43 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16  9:02 [PATCHv3 00/22] OMAP3: PM: Smartreflex and voltage revamp Thara Gopinath
2010-04-16  9:02 ` [PATCHv3 01/22] OMAP3: PM: Adding hwmod data for Smartreflex Thara Gopinath
2010-04-16  9:02   ` [PATCHv3 02/22] OMAP3: PM: Create list to keep track of various smartreflex instances Thara Gopinath
2010-04-16  9:02     ` [PATCHv3 03/22] OMAP3: PM: Convert smartreflex driver into a platform driver using hwmods and omap-device layer Thara Gopinath
2010-04-16  9:02       ` [PATCHv3 04/22] OMAP3: PM: Move smartreflex autocompensation enable disable hooks to PM debugfs Thara Gopinath
2010-04-16  9:03         ` [PATCHv3 05/22] OMAP3: PM: Remove OPP id dependency from smartreflex driver Thara Gopinath
2010-04-16  9:03           ` [PATCHv3 06/22] OMAP3: PM: Correcting API names in samrtreflex driver Thara Gopinath
2010-04-16  9:03             ` [PATCHv3 07/22] OMAP3: PM: Smartreflex class related changes for smartreflex.c Thara Gopinath
2010-04-16  9:03               ` [PATCHv3 08/22] OMAP3: PM: Adding smartreflex class 3 driver Thara Gopinath
2010-04-16  9:03                 ` [PATCHv3 09/22] OMAP3: PM: Creating separate files for handling OMAP3 voltage related operations Thara Gopinath
2010-04-16  9:03                   ` [PATCHv3 10/22] OMAP3: PM: Adding voltage table support in voltage driver Thara Gopinath
2010-04-16  9:03                     ` [PATCHv3 11/22] OMAP3: PM: Removing VP1, VP2, SR1 and SR2 defintions Thara Gopinath
2010-04-16  9:03                       ` [PATCHv3 12/22] OMAP3: PM: Minimizing the passing around of sr id in smartreflex.c Thara Gopinath
2010-04-16  9:03                         ` [PATCHv3 13/22] OMAP3: PM: Cleaning up of smartreflex header file Thara Gopinath
2010-04-16  9:03                           ` [PATCHv3 14/22] OMAP3: PM: Configurations for Smartreflex Class 2 and Smartreflex Class 3 Thara Gopinath
2010-04-16  9:03                             ` [PATCHv3 15/22] OMAP3: PM: Support for enabling smartreflex autocompensation by default Thara Gopinath
2010-04-16  9:03                               ` [PATCHv3 16/22] OMAP3: PM: Correcting accessing of ERRCONFIG register in smartreflex.c Thara Gopinath
2010-04-16  9:03                                 ` [PATCHv3 17/22] OMAP3: PM: Implement latest h/w recommendations for SR and VP registers and SR VP enable disable sequence Thara Gopinath
2010-04-16  9:03                                   ` [PATCHv3 18/22] OMAP3: PM: Optional reset of voltage during Smartreflex disable Thara Gopinath
2010-04-16  9:03                                     ` [PATCHv3 19/22] OMAP3: PM: Disabling Smartreflex across both frequency and voltage scaling during DVFS Thara Gopinath
2010-04-16  9:03                                       ` [PATCHv3 20/22] OMAP3: PM: VP force update method of voltage scaling Thara Gopinath
2010-04-16  9:03                                         ` [PATCHv3 21/22] OMAP3: PM: Enabling Smartreflex Class 3 driver by default in pm defconfig Thara Gopinath
2010-04-16  9:03                                           ` [PATCHv3 22/22] OMAP3: PM: Fix crash when enabling SmartReflex on non-supported OMAPs Thara Gopinath
2010-04-27 16:23                                         ` [PATCHv3 20/22] OMAP3: PM: VP force update method of voltage scaling Kevin Hilman
2010-04-27 19:16                                         ` Kevin Hilman
2010-04-27 19:14                                     ` [PATCHv3 18/22] OMAP3: PM: Optional reset of voltage during Smartreflex disable Kevin Hilman
2010-05-05 11:03                                       ` Gopinath, Thara
2010-05-05 21:39                                         ` Kevin Hilman
2010-04-27 19:12                                   ` [PATCHv3 17/22] OMAP3: PM: Implement latest h/w recommendations for SR and VP registers and SR VP enable disable sequence Kevin Hilman
2010-04-27 19:10                               ` [PATCHv3 15/22] OMAP3: PM: Support for enabling smartreflex autocompensation by default Kevin Hilman
2010-04-27 19:06                             ` [PATCHv3 14/22] OMAP3: PM: Configurations for Smartreflex Class 2 and Smartreflex Class 3 Kevin Hilman
2010-04-27 19:02                         ` [PATCHv3 12/22] OMAP3: PM: Minimizing the passing around of sr id in smartreflex.c Kevin Hilman
2010-05-13  7:13                           ` Gopinath, Thara
2010-05-14 17:14                             ` Kevin Hilman
2010-04-27 18:58                     ` [PATCHv3 10/22] OMAP3: PM: Adding voltage table support in voltage driver Kevin Hilman
2010-04-27 18:43           ` Kevin Hilman [this message]
2010-04-27 17:57         ` [PATCHv3 04/22] OMAP3: PM: Move smartreflex autocompensation enable disable hooks to PM debugfs Kevin Hilman
2010-04-27 17:47       ` [PATCHv3 03/22] OMAP3: PM: Convert smartreflex driver into a platform driver using hwmods and omap-device layer Kevin Hilman
2010-04-27 17:34   ` [PATCHv3 01/22] OMAP3: PM: Adding hwmod data for Smartreflex Kevin Hilman
2010-04-20 23:49 ` [PATCHv3 00/22] OMAP3: PM: Smartreflex and voltage revamp Kevin Hilman
2010-04-27 19:18 ` Kevin Hilman
2010-04-30  6:09   ` Gopinath, Thara
2010-04-30 14:22     ` Kevin Hilman

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=87sk6gka7o.fsf@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=b-cousson@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    --cc=sawant@ti.com \
    --cc=thara@ti.com \
    --cc=vishwanath.bs@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.