]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.13/hwmon-ads7828-enable-internal-reference.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.13 / hwmon-ads7828-enable-internal-reference.patch
1 From 7a18afe8097731b8ffb6cb5b2b3b418ded77c105 Mon Sep 17 00:00:00 2001
2 From: Akshay Bhat <akshay.bhat@timesys.com>
3 Date: Mon, 18 Apr 2016 15:47:53 -0400
4 Subject: hwmon: (ads7828) Enable internal reference
5
6 From: Akshay Bhat <akshay.bhat@timesys.com>
7
8 commit 7a18afe8097731b8ffb6cb5b2b3b418ded77c105 upstream.
9
10 On ads7828 the internal reference defaults to off upon power up. When
11 using internal reference, it needs to be turned on and the voltage needs
12 to settle before normal conversion cycle can be started. Hence perform a
13 dummy read in the probe to enable the internal reference allowing the
14 voltage to settle before performing a normal read.
15
16 Without this fix, the first read from the ADC when using internal
17 reference always returns incorrect data.
18
19 Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com>
20 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 drivers/hwmon/ads7828.c | 10 ++++++++++
25 1 file changed, 10 insertions(+)
26
27 --- a/drivers/hwmon/ads7828.c
28 +++ b/drivers/hwmon/ads7828.c
29 @@ -120,6 +120,7 @@ static int ads7828_probe(struct i2c_clie
30 unsigned int vref_mv = ADS7828_INT_VREF_MV;
31 bool diff_input = false;
32 bool ext_vref = false;
33 + unsigned int regval;
34
35 data = devm_kzalloc(dev, sizeof(struct ads7828_data), GFP_KERNEL);
36 if (!data)
37 @@ -154,6 +155,15 @@ static int ads7828_probe(struct i2c_clie
38 if (!diff_input)
39 data->cmd_byte |= ADS7828_CMD_SD_SE;
40
41 + /*
42 + * Datasheet specifies internal reference voltage is disabled by
43 + * default. The internal reference voltage needs to be enabled and
44 + * voltage needs to settle before getting valid ADC data. So perform a
45 + * dummy read to enable the internal reference voltage.
46 + */
47 + if (!ext_vref)
48 + regmap_read(data->regmap, data->cmd_byte, &regval);
49 +
50 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
51 data,
52 ads7828_groups);