From: Eduardo Valentin <edubezval@gmail.com>
To: Bai Ping <ping.bai@nxp.com>
Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org
Subject: Re: [PATCH] thermal: imx: update the temperature calibration data for imx6 soc
Date: Thu, 31 Dec 2015 09:50:57 -0800 [thread overview]
Message-ID: <20151231175048.GA13409@localhost.localdomain> (raw)
In-Reply-To: <1450682876-26725-1-git-send-email-ping.bai@nxp.com>
On Mon, Dec 21, 2015 at 03:27:56PM +0800, Bai Ping wrote:
> According to the design team:
>
> After a thorough accuracy study of the Temp sense circuit,we found that
> with our current equation, an average part can read 7 degrees lower than
> a known forced temperature. We also found out that the standard variance
> was around 2C; which is the tightest distribution that we could create.
> We need to change the temp sense equation to center the average
> part around the target temperature.
>
> Old Equation:
>
> Temp = Troom,cal - slope*(Count measured - Count room fuse)
> Where Troom,cal = 25C and Slope = 0.4297157 - (0.0015974 * Count room fuse)
>
> New Equation:
>
> Temp = Troom,cal - slope*(Count measured - Count room fuse) +offset
> Where Troom,cal = 25C and Slope = 0.4148468 - (0.0015423 * Count room fuse)
> Offset = 3.580661
>
> Signed-off-by: Bai Ping <ping.bai@nxp.com>
> ---
> drivers/thermal/imx_thermal.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index c5547bd..9fb613e 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -69,8 +69,9 @@ enum imx_thermal_trip {
> #define IMX_PASSIVE_DELAY 1000
>
> #define FACTOR0 10000000
> -#define FACTOR1 15976
> -#define FACTOR2 4297157
> +#define FACTOR1 15423
> +#define FACTOR2 4148468
> +#define OFFSET 3580661
>
> #define TEMPMON_IMX6Q 1
> #define TEMPMON_IMX6SX 2
> @@ -385,23 +386,26 @@ static int imx_get_sensor_data(struct platform_device *pdev)
> * Derived from linear interpolation:
> * slope = 0.4297157 - (0.0015976 * 25C fuse)
> * slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0
> + * offset = OFFSET / 1000000
> * (Nmeas - n1) / (Tmeas - t1) = slope
> * We want to reduce this down to the minimum computation necessary
> * for each temperature read. Also, we want Tmeas in millicelsius
> * and we don't want to lose precision from integer division. So...
> - * Tmeas = (Nmeas - n1) / slope + t1
> - * milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1
> - * milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1
> + * Tmeas = (Nmeas - n1) / slope + t1 + offset
> + * milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1 + OFFSET / 1000
> + * milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1 + OFFSET / 1000
> * Let constant c1 = (-1000 / slope)
> - * milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1
> - * Let constant c2 = n1 *c1 + 1000 * t1
> + * milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1 + OFFSET / 1000
> + * Let constant c2 = n1 *c1 + 1000 * t1 + OFFSET / 1000
> * milli_Tmeas = c2 - Nmeas * c1
> */
> temp64 = FACTOR0;
> temp64 *= 1000;
> do_div(temp64, FACTOR1 * n1 - FACTOR2);
> data->c1 = temp64;
> - data->c2 = n1 * data->c1 + 1000 * t1;
> + temp64 = OFFSET;
> + do_div(temp64, 1000);
> + data->c2 = n1 * data->c1 + 1000 * t1 + temp64;
Dear Bai Ping. Can you please get at least on Tested-by response in the
mailing list for this patch from one of your co-workers, for example?
Meanwhile, a couple of questions:
Does this offset work well on all chip distribution?
Do we need a different offset for different soc revision ? Is the same
offset applicable to IMX6Q and to IMX6SX?
I strong recommend you to translate this driver to add of-thermal
support. This is more than desirable, specially considering the type of
changes you are in a need, such as the one above. This is better
described in DT, not in the driver code.
>
> /* use OTP for thermal grade */
> ret = regmap_read(map, OCOTP_MEM0, &val);
> --
> 1.9.1
>
next prev parent reply other threads:[~2015-12-31 17:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-21 7:27 [PATCH] thermal: imx: update the temperature calibration data for imx6 soc Bai Ping
2015-12-31 17:50 ` Eduardo Valentin [this message]
2016-01-04 7:32 ` Ping Bai
2016-01-04 7:37 ` Fuchuan Liu
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=20151231175048.GA13409@localhost.localdomain \
--to=edubezval@gmail.com \
--cc=linux-pm@vger.kernel.org \
--cc=ping.bai@nxp.com \
--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