diff options
author | Anson Huang <b20788@freescale.com> | 2013-03-13 14:01:01 +0800 |
---|---|---|
committer | Richard Liu <r66033@freescale.com> | 2013-04-08 10:49:27 +0800 |
commit | 2e2ec276df83834ebe8e1f891a3d38ee5b302080 (patch) | |
tree | 2e8cdab14d3dd4e6dad55528d66bb6f88c896d06 | |
parent | 3efd27d2a6b897dc45eeac4574f86c0ba8772428 (diff) |
ENGR00255481 mx6: Update equation for thermal sensor
Use universal equation and 25C's calibration data to
get thermal sensor's ratio.
If want to use old calibration method, please add
"use_calibration" into kernel command line.
Signed-off-by: Anson Huang <b20788@freescale.com>
-rw-r--r-- | drivers/mxc/thermal/thermal.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/drivers/mxc/thermal/thermal.c b/drivers/mxc/thermal/thermal.c index 0982a7b781bd..21ff18fb14fd 100644 --- a/drivers/mxc/thermal/thermal.c +++ b/drivers/mxc/thermal/thermal.c @@ -3,7 +3,7 @@ * * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> - * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. + * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * This program is free software; you can redistribute it and/or modify @@ -43,6 +43,7 @@ #include <linux/cpufreq.h> #include <linux/clk.h> #include "anatop_driver.h" +#include <mach/hardware.h> /* register define of anatop */ #define HW_ANADIG_ANA_MISC0 (0x00000150) @@ -137,6 +138,9 @@ #define ANATOP_DEBUG false #define THERMAL_FUSE_NAME "/sys/fsl_otp/HW_OCOTP_ANA1" +#define FACTOR1 15976 +#define FACTOR2 4297157 + /* variables */ unsigned long anatop_base; unsigned int ratio; @@ -147,6 +151,7 @@ static bool suspend_flag; static unsigned int thermal_irq; bool cooling_cpuhotplug; bool cooling_device_disable; +static bool calibration_valid; unsigned long temperature_cooling; static const struct anatop_device_id thermal_device_ids[] = { {ANATOP_THERMAL_HID}, @@ -824,12 +829,22 @@ static int __init anatop_thermal_cooling_device_disable(char *str) } __setup("no_cooling_device", anatop_thermal_cooling_device_disable); +static int __init anatop_thermal_use_calibration(char *str) +{ + calibration_valid = true; + pr_info("%s: use calibration data for thermal sensor!\n", __func__); + + return 1; +} +__setup("use_calibration", anatop_thermal_use_calibration); + static int anatop_thermal_counting_ratio(unsigned int fuse_data) { int ret = -EINVAL; pr_info("Thermal calibration data is 0x%x\n", fuse_data); - if (fuse_data == 0 || fuse_data == 0xffffffff || (fuse_data & 0xff) == 0) { + if (fuse_data == 0 || fuse_data == 0xffffffff || + (fuse_data & 0xfff00000) == 0) { pr_info("%s: invalid calibration data, disable cooling!!!\n", __func__); cooling_device_disable = true; ratio = DEFAULT_RATIO; @@ -846,7 +861,19 @@ static int anatop_thermal_counting_ratio(unsigned int fuse_data) raw_hot = (fuse_data & 0xfff00) >> 8; hot_temp = fuse_data & 0xff; - ratio = ((raw_25c - raw_hot) * 100) / (hot_temp - 25); + if (!calibration_valid && cpu_is_mx6q()) + /* + * The universal equation for thermal sensor + * is slope = 0.4297157 - (0.0015976 * 25C fuse), + * here we convert them to integer to make them + * easy for counting, FACTOR1 is 15976, + * FACTORs is 4297157. Our ratio = -100 * slope. + */ + ratio = ((FACTOR1 * raw_25c - FACTOR2) + 50000) / 100000; + else + ratio = ((raw_25c - raw_hot) * 100) / (hot_temp - 25); + + pr_info("Thermal sensor with ratio = %d\n", ratio); raw_n40c = raw_25c + (13 * ratio) / 20; raw_125c = raw_25c - ratio; /* Init default critical temp to set alarm */ |