aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBhuvanchandra DV <bhuvanchandra.dv@toradex.com>2015-10-19 11:54:36 -0400
committerJonathan Cameron <jic23@kernel.org>2015-10-25 08:12:29 -0400
commit6219f432ec037317a77c40910da12a626c34af1c (patch)
tree82e046705eabcaae564989f3e7cae6381be73575
parentb94e22805a2224061bb263a82b72e09544a5fbb3 (diff)
vf610_adc: Fix internal temperature calculation
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@Temp25 as 867. Formula for finding ADCR@Temp25: ADCR@Temp25 = (ADCR@Vdd * V@TEMP25 * 10) / VDDconv ADCR@Vdd for 12-Bit ADC = 4095 VDDconv = VREFH_ADC * 10 VREFH_ADC@3.3V ADCR@Temp25 = (4095 * .699 * 10) / 33 ADCR@Temp25 ~= 867 | VREFH_ADC | V@TEMP25 | VDDconv | ADCR@Temp25 | | 3.0V | 0.696mV | 30 | 950 | | 3.3V | 0.699mV | 33 | 867 | Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Acked-by: Fugang Duan <B38611@freescale.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/adc/vf610_adc.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 6bf4c20eb231..42d7c87ea5be 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -103,6 +103,13 @@
103 103
104#define DEFAULT_SAMPLE_TIME 1000 104#define DEFAULT_SAMPLE_TIME 1000
105 105
106/* V at 25°C of 696 mV */
107#define VF610_VTEMP25_3V0 950
108/* V at 25°C of 699 mV */
109#define VF610_VTEMP25_3V3 867
110/* Typical sensor slope coefficient at all temperatures */
111#define VF610_TEMP_SLOPE_COEFF 1840
112
106enum clk_sel { 113enum clk_sel {
107 VF610_ADCIOC_BUSCLK_SET, 114 VF610_ADCIOC_BUSCLK_SET,
108 VF610_ADCIOC_ALTCLK_SET, 115 VF610_ADCIOC_ALTCLK_SET,
@@ -635,11 +642,13 @@ static int vf610_read_raw(struct iio_dev *indio_dev,
635 break; 642 break;
636 case IIO_TEMP: 643 case IIO_TEMP:
637 /* 644 /*
638 * Calculate in degree Celsius times 1000 645 * Calculate in degree Celsius times 1000
639 * Using sensor slope of 1.84 mV/°C and 646 * Using the typical sensor slope of 1.84 mV/°C
640 * V at 25°C of 696 mV 647 * and VREFH_ADC at 3.3V, V at 25°C of 699 mV
641 */ 648 */
642 *val = 25000 - ((int)info->value - 864) * 1000000 / 1840; 649 *val = 25000 - ((int)info->value - VF610_VTEMP25_3V3) *
650 1000000 / VF610_TEMP_SLOPE_COEFF;
651
643 break; 652 break;
644 default: 653 default:
645 mutex_unlock(&indio_dev->mlock); 654 mutex_unlock(&indio_dev->mlock);