summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajagopala V <rajagopala.v@stericsson.com>2011-11-10 17:50:52 +0530
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-05-22 11:01:11 +0200
commit886b10019c98b81720052babff9080a66caba721 (patch)
tree37d28bf09bd837bfb43ee1504946ccf48727b964
parent1fa4ffa3bd74c841979a4f05cf6dd9a64e9769e7 (diff)
u5500:gpadc: Fix ab5500 internal temp conversion formula
Fix AB5500 internal die temperature conversion formula and provide 8bit min/max lavel to auto trigger. ST-Ericsson Linux next: NA ST-Ericsson ID: 372448 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I6bb2d0afb657582709f95f1f88466e6c061c1117 Signed-off-by: Rajagopala V <rajagopala.v@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/37296 Reviewed-by: QABUILD Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com> Reviewed-by: Vijaya Kumar K-1 <vijay.kilari@stericsson.com> Reviewed-by: Arun MURTHY <arun.murthy@stericsson.com>
-rw-r--r--drivers/mfd/ab5500-gpadc.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/mfd/ab5500-gpadc.c b/drivers/mfd/ab5500-gpadc.c
index 51d1fa9049a..d099f1b9d73 100644
--- a/drivers/mfd/ab5500-gpadc.c
+++ b/drivers/mfd/ab5500-gpadc.c
@@ -295,10 +295,10 @@ static int ab5500_gpadc_ad_to_voltage(struct ab5500_gpadc *gpadc,
/*
* From the AB5500 product specification
* T(deg cel) = 27 - ((ADCode - 709)/2.4213)
- * 27 + 709/2.4213 - ADCode/2.4123
- * (320 - ADCode)/2.4213
+ * 27 + 709/2.4213 - ADCode/2.4213
+ * 320 - (ADCode/2.4213)
*/
- res = 320 - (((unsigned long)ad_val * 1000000) / 242130) / 10;
+ res = 320 - (((unsigned long)ad_val * 10000) / 24213);
break;
default:
dev_err(gpadc->dev,
@@ -747,13 +747,16 @@ int ab5500_gpadc_convert_auto(struct ab5500_gpadc *gpadc,
case DIE_TEMP:
/*
* From the AB5500 product specification
- * T(deg_cel) = 27 -(ADCode - 709)/2.4123)
- * adc min and max values are based on the above formula.
+ * T(deg_cel) = 27 - (ADCode - 709)/2.4213)
+ * ADCode = 709 + (2.4213 * (27 - T))
+ * Auto trigger min/max level is of 8bit precision.
+ * Hence use AB5500_GPADC_MANDATAH_REG value
+ * obtained by 2 bit right shift of ADCode.
*/
gpadc->adc_trig[trig].trig_min =
- 709 - (22413 * (in->min - 27))/10000;
+ (709 + ((24213 * (27 - in->min))/10000))>>2;
gpadc->adc_trig[trig].trig_max =
- 709 - (22413 * (in->max - 27))/10000;
+ (709 + ((24213 * (27 - in->max))/10000))>>2;
gpadc->adc_trig[trig].adout =
adc_tab[in->mux].adout;
break;