Commit 21304e17 authored by Anson Huang's avatar Anson Huang Committed by Jason Liu

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: 's avatarAnson Huang <b20788@freescale.com>
parent 64eb436e
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment