linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <edubezval@gmail.com>
To: Rui Zhang <rui.zhang@intel.com>,
	hongtao.jia@freescale.com, kong.kongxinwei@hisilicon.com,
	nrajan@codeaurora.org
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux ACPI <linux-acpi@vger.kernel.org>
Subject: Re: [PATCH 2/2] thermal: of-thermal: add support for reading coefficients property  33 O   May 11 Antoine Tenart  ( 15K) [PATCH v4 1/3] iio: adc: add support for Berlin
Date: Mon, 11 May 2015 20:27:52 -0700	[thread overview]
Message-ID: <20150512032751.GJ4810@localhost.localdomain> (raw)
In-Reply-To: <1431399857-13943-3-git-send-email-edubezval@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3664 bytes --]

Copying Narendran.

On Mon, May 11, 2015 at 08:04:17PM -0700, Eduardo Valentin wrote:
> In order to avoid having each driver adding their own
> specific DT property to specify slope and offset,
> this patch adds a basic coefficient reading from
> DT thermal zone node. Right now, as the thermal
> framework does not support multiple sensors,
> the current coefficients apply only to the only
> sensor in the thermal zone.
> 
> The supported equation is a simple linear model:
> 	slope * <sensor reading> + offset.
> 
> slope and offset are read from the coefficients
> DT property. In the same way as it is described in
> the DT thermal binding.
> 
> So, as of today, the thermal framework will support
> only cases like:
>                 /* hotspot = 1 * adc + 6000 */
> 		coefficients =          <1      6000>;
> 
> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>  drivers/thermal/of-thermal.c | 26 ++++++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 9e8c614..b295b2b 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -58,6 +58,8 @@ struct __thermal_bind_params {
>   * @mode: current thermal zone device mode (enabled/disabled)
>   * @passive_delay: polling interval while passive cooling is activated
>   * @polling_delay: zone polling interval
> + * @slope: slope of the temperature adjustment curve
> + * @offset: offset of the temperature adjustment curve
>   * @ntrips: number of trip points
>   * @trips: an array of trip points (0..ntrips - 1)
>   * @num_tbps: number of thermal bind params
> @@ -70,6 +72,8 @@ struct __thermal_zone {
>  	enum thermal_device_mode mode;
>  	int passive_delay;
>  	int polling_delay;
> +	int slope;
> +	int offset;
>  
>  	/* trip data */
>  	int ntrips;
> @@ -716,7 +720,7 @@ static int thermal_of_populate_trip(struct device_node *np,
>   * @np parameter and fills the read data into a __thermal_zone data structure
>   * and return this pointer.
>   *
> - * TODO: Missing properties to parse: thermal-sensor-names and coefficients
> + * TODO: Missing properties to parse: thermal-sensor-names
>   *
>   * Return: On success returns a valid struct __thermal_zone,
>   * otherwise, it returns a corresponding ERR_PTR(). Caller must
> @@ -728,7 +732,7 @@ thermal_of_build_thermal_zone(struct device_node *np)
>  	struct device_node *child = NULL, *gchild;
>  	struct __thermal_zone *tz;
>  	int ret, i;
> -	u32 prop;
> +	u32 prop, coef[2];
>  
>  	if (!np) {
>  		pr_err("no thermal zone np\n");
> @@ -753,6 +757,20 @@ thermal_of_build_thermal_zone(struct device_node *np)
>  	}
>  	tz->polling_delay = prop;
>  
> +	/*
> +	 * REVIST: for now, the thermal framework supports only
> +	 * one sensor per thermal zone. Thus, we are considering
> +	 * only the first two values as slope and offset.
> +	 */
> +	ret = of_property_read_u32_array(np, "coefficients", coef, 2);
> +	if (ret == 0) {
> +		tz->slope = coef[0];
> +		tz->offset = coef[1];
> +	} else {
> +		tz->slope = 1;
> +		tz->offset = 0;
> +	}
> +
>  	/* trips */
>  	child = of_get_child_by_name(np, "trips");
>  
> @@ -900,6 +918,10 @@ int __init of_parse_thermal_zones(void)
>  		for (i = 0; i < tz->ntrips; i++)
>  			mask |= 1 << i;
>  
> +		/* these two are left for temperature drivers to use */
> +		tzp->slope = tz->slope;
> +		tzp->offset = tz->offset;
> +
>  		zone = thermal_zone_device_register(child->name, tz->ntrips,
>  						    mask, tz,
>  						    ops, tzp,
> -- 
> 2.3.4
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

  reply	other threads:[~2015-05-12  3:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12  3:04 [PATCH 0/2] thermal: add support to slope and offset Eduardo Valentin
2015-05-12  3:04 ` [PATCH 1/2] thermal: support slope and offset coefficients Eduardo Valentin
2015-05-12  3:25   ` Eduardo Valentin
2015-05-12  3:04 ` [PATCH 2/2] thermal: of-thermal: add support for reading coefficients property Eduardo Valentin
2015-05-12  3:27   ` Eduardo Valentin [this message]
2015-05-12  3:24 ` [PATCH 0/2] thermal: add support to slope and offset Eduardo Valentin

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=20150512032751.GJ4810@localhost.localdomain \
    --to=edubezval@gmail.com \
    --cc=hongtao.jia@freescale.com \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nrajan@codeaurora.org \
    --cc=rui.zhang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).