public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Nikolay Dimitrov <picmaster@mail.bg>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/4] thermal: imx_thermal: use CPU temperature grade for trip points
Date: Mon, 18 May 2015 01:34:31 +0300	[thread overview]
Message-ID: <55591777.7040300@mail.bg> (raw)
In-Reply-To: <1431580312-24880-5-git-send-email-tharvey@gateworks.com>


On 05/14/2015 08:11 AM, Tim Harvey wrote:
> Replace the hard-coded values for min/max/passive with values derived from
> the CPU temperature grade.
>
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> ---
>   drivers/thermal/imx_thermal.c | 29 +++++++++++++++++++----------
>   1 file changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 0bd9cfd..b5dab63 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -12,15 +12,13 @@
>   #include <fuse.h>
>   #include <asm/io.h>
>   #include <asm/arch/clock.h>
> +#include <asm/arch/sys_proto.h>
>   #include <dm.h>
>   #include <errno.h>
>   #include <malloc.h>
>   #include <thermal.h>
>   #include <imx_thermal.h>
>
> -#define TEMPERATURE_MIN		-40
> -#define TEMPERATURE_HOT		80
> -#define TEMPERATURE_MAX		125
>   #define FACTOR0			10000000
>   #define FACTOR1			15976
>   #define FACTOR2			4297157
> @@ -34,14 +32,21 @@
>   #define MISC0_REFTOP_SELBIASOFF		(1 << 3)
>   #define TEMPSENSE1_MEASURE_FREQ		0xffff
>
> +struct thermal_data {
> +	unsigned int fuse;
> +	int passive;
> +	int minc;
> +	int maxc;
> +};
> +
>   static int read_cpu_temperature(struct udevice *dev)
>   {
>   	int temperature;
>   	unsigned int reg, n_meas;
>   	const struct imx_thermal_plat *pdata = dev_get_platdata(dev);
>   	struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs;
> -	unsigned int *priv = dev_get_priv(dev);
> -	u32 fuse = *priv;
> +	struct thermal_data *priv = dev_get_priv(dev);
> +	u32 fuse = priv->fuse;
>   	int t1, n1;
>   	u32 c1, c2;
>   	u64 temp64;
> @@ -119,11 +124,12 @@ static int read_cpu_temperature(struct udevice *dev)
>
>   int imx_thermal_get_temp(struct udevice *dev, int *temp)
>   {
> +	struct thermal_data *priv = dev_get_priv(dev);
>   	int cpu_tmp = 0;
>
>   	cpu_tmp = read_cpu_temperature(dev);
> -	while (cpu_tmp > TEMPERATURE_MIN && cpu_tmp < TEMPERATURE_MAX) {
> -		if (cpu_tmp >= TEMPERATURE_HOT) {
> +	while (cpu_tmp > priv->minc && cpu_tmp < priv->maxc) {
> +		if (cpu_tmp >= priv->passive) {
>   			printf("CPU Temperature is %d C, too hot to boot, waiting...\n",
>   			       cpu_tmp);
>   			udelay(5000000);
> @@ -147,7 +153,7 @@ static int imx_thermal_probe(struct udevice *dev)
>   	unsigned int fuse = ~0;
>
>   	const struct imx_thermal_plat *pdata = dev_get_platdata(dev);
> -	unsigned int *priv = dev_get_priv(dev);
> +	struct thermal_data *priv = dev_get_priv(dev);
>
>   	/* Read Temperature calibration data fuse */
>   	fuse_read(pdata->fuse_bank, pdata->fuse_word, &fuse);
> @@ -158,7 +164,10 @@ static int imx_thermal_probe(struct udevice *dev)
>   		return -EPERM;
>   	}
>
> -	*priv = fuse;
> +	/* set passive cooling temp to max - 20C */
> +	get_cpu_temp_grade(&priv->minc, &priv->maxc);
> +	priv->passive = priv->maxc - 20;
> +	priv->fuse = fuse;
>
>   	enable_thermal_clk();
>
> @@ -170,6 +179,6 @@ U_BOOT_DRIVER(imx_thermal) = {
>   	.id	= UCLASS_THERMAL,
>   	.ops	= &imx_thermal_ops,
>   	.probe	= imx_thermal_probe,
> -	.priv_auto_alloc_size = sizeof(unsigned int),
> +	.priv_auto_alloc_size = sizeof(struct thermal_data),
>   	.flags  = DM_FLAG_PRE_RELOC,
>   };
>

Tested-by: Nikolay Dimitrov <picmaster@mail.bg>

Regards,
Nikolay

      reply	other threads:[~2015-05-17 22:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14  5:11 [U-Boot] [PATCH v2 0/4]: imx: mx6: use OTP for temperature grade info Tim Harvey
2015-05-14  5:11 ` [U-Boot] [PATCH v2 1/4] mx6: add OTP bank1 registers Tim Harvey
2015-05-15  8:08   ` Christian Gmeiner
2015-05-17 22:32   ` Nikolay Dimitrov
2015-05-14  5:11 ` [U-Boot] [PATCH v2 2/4] imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP Tim Harvey
2015-05-15  8:17   ` Christian Gmeiner
2015-05-17 22:33   ` Nikolay Dimitrov
2015-05-14  5:11 ` [U-Boot] [PATCH v2 3/4] imx: mx6: add display of CPU temperature grade in print_cpuinfo() Tim Harvey
2015-05-15  8:14   ` Christian Gmeiner
2015-05-15 13:16     ` Tim Harvey
2015-05-15 13:24       ` Stefano Babic
2015-05-15 13:31         ` Tim Harvey
2015-05-15 13:36           ` Fabio Estevam
2015-05-18  0:11             ` Peng Fan
2015-05-18 13:30               ` Tim Harvey
2015-05-15 13:44           ` Stefano Babic
2015-05-17 22:33   ` Nikolay Dimitrov
2015-05-14  5:11 ` [U-Boot] [PATCH v2 4/4] thermal: imx_thermal: use CPU temperature grade for trip points Tim Harvey
2015-05-17 22:34   ` Nikolay Dimitrov [this message]

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=55591777.7040300@mail.bg \
    --to=picmaster@mail.bg \
    --cc=u-boot@lists.denx.de \
    /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