[4.2.y-ckt stable] Patch "vf610_adc: Fix internal temperature calculation" has been added to staging queue
Kamal Mostafa
kamal at canonical.com
Thu Jan 14 22:26:51 UTC 2016
This is a note to let you know that I have just added a patch titled
vf610_adc: Fix internal temperature calculation
to the linux-4.2.y-queue branch of the 4.2.y-ckt extended stable tree
which can be found at:
http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-4.2.y-queue
This patch is scheduled to be released in version 4.2.8-ckt2.
If you, or anyone else, feels it should not be added to this tree, please
reply to this email.
For more information about the 4.2.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
Thanks.
-Kamal
---8<------------------------------------------------------------
>From 348e722d40506e7a166ea5e132710f8335ab7ca0 Mon Sep 17 00:00:00 2001
From: Bhuvanchandra DV <bhuvanchandra.dv at toradex.com>
Date: Mon, 19 Oct 2015 21:24:36 +0530
Subject: vf610_adc: Fix internal temperature calculation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
commit 6219f432ec037317a77c40910da12a626c34af1c upstream.
Calculate ADCR_VTEMP25 using VTEMP25 at VREFH_ADC 3V3. Existing
calculations consider the typical values provided in datasheet.
Those typical values are valid for VREFH_ADC at 3.0V. VTEMP25
is different for different VREFH_ADC voltages. With VREFH_ADC
at 3.3V, voltage at 25°C is 0.699V. Hence update the VTEMP25
to 0.699V which gives ADCR at Temp25 as 867.
Formula for finding ADCR at Temp25:
ADCR at Temp25 = (ADCR at Vdd * V at TEMP25 * 10) / VDDconv
ADCR at Vdd for 12-Bit ADC = 4095
VDDconv = VREFH_ADC * 10
VREFH_ADC at 3.3V
ADCR at Temp25 = (4095 * .699 * 10) / 33
ADCR at Temp25 ~= 867
| VREFH_ADC | V at TEMP25 | VDDconv | ADCR at Temp25 |
| 3.0V | 0.696mV | 30 | 950 |
| 3.3V | 0.699mV | 33 | 867 |
Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv at toradex.com>
Acked-by: Fugang Duan <B38611 at freescale.com>
Signed-off-by: Jonathan Cameron <jic23 at kernel.org>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
drivers/iio/adc/vf610_adc.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 819632b..fe8cf11 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -98,6 +98,13 @@
#define VF610_ADC_CALF 0x2
#define VF610_ADC_TIMEOUT msecs_to_jiffies(100)
+/* V at 25°C of 696 mV */
+#define VF610_VTEMP25_3V0 950
+/* V at 25°C of 699 mV */
+#define VF610_VTEMP25_3V3 867
+/* Typical sensor slope coefficient at all temperatures */
+#define VF610_TEMP_SLOPE_COEFF 1840
+
enum clk_sel {
VF610_ADCIOC_BUSCLK_SET,
VF610_ADCIOC_ALTCLK_SET,
@@ -569,11 +576,13 @@ static int vf610_read_raw(struct iio_dev *indio_dev,
break;
case IIO_TEMP:
/*
- * Calculate in degree Celsius times 1000
- * Using sensor slope of 1.84 mV/°C and
- * V at 25°C of 696 mV
- */
- *val = 25000 - ((int)info->value - 864) * 1000000 / 1840;
+ * Calculate in degree Celsius times 1000
+ * Using the typical sensor slope of 1.84 mV/°C
+ * and VREFH_ADC at 3.3V, V at 25°C of 699 mV
+ */
+ *val = 25000 - ((int)info->value - VF610_VTEMP25_3V3) *
+ 1000000 / VF610_TEMP_SLOPE_COEFF;
+
break;
default:
mutex_unlock(&indio_dev->mlock);
--
1.9.1
More information about the kernel-team
mailing list