aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkshay Bhat <akshay.bhat@timesys.com>2016-04-18 15:47:53 -0400
committerGuenter Roeck <linux@roeck-us.net>2016-04-19 09:30:28 -0400
commit7a18afe8097731b8ffb6cb5b2b3b418ded77c105 (patch)
treea6b39b60800292c14a9732f0cd6b0837d5e5c951
parent9735a22799b9214d17d3c231fe377fc852f042e9 (diff)
hwmon: (ads7828) Enable internal reference
On ads7828 the internal reference defaults to off upon power up. When using internal reference, it needs to be turned on and the voltage needs to settle before normal conversion cycle can be started. Hence perform a dummy read in the probe to enable the internal reference allowing the voltage to settle before performing a normal read. Without this fix, the first read from the ADC when using internal reference always returns incorrect data. Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com> Cc: stable@vger.kernel.org # v4.1+ Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/ads7828.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
index 6c99ee7bafa3..ee396ff167d9 100644
--- a/drivers/hwmon/ads7828.c
+++ b/drivers/hwmon/ads7828.c
@@ -120,6 +120,7 @@ static int ads7828_probe(struct i2c_client *client,
120 unsigned int vref_mv = ADS7828_INT_VREF_MV; 120 unsigned int vref_mv = ADS7828_INT_VREF_MV;
121 bool diff_input = false; 121 bool diff_input = false;
122 bool ext_vref = false; 122 bool ext_vref = false;
123 unsigned int regval;
123 124
124 data = devm_kzalloc(dev, sizeof(struct ads7828_data), GFP_KERNEL); 125 data = devm_kzalloc(dev, sizeof(struct ads7828_data), GFP_KERNEL);
125 if (!data) 126 if (!data)
@@ -154,6 +155,15 @@ static int ads7828_probe(struct i2c_client *client,
154 if (!diff_input) 155 if (!diff_input)
155 data->cmd_byte |= ADS7828_CMD_SD_SE; 156 data->cmd_byte |= ADS7828_CMD_SD_SE;
156 157
158 /*
159 * Datasheet specifies internal reference voltage is disabled by
160 * default. The internal reference voltage needs to be enabled and
161 * voltage needs to settle before getting valid ADC data. So perform a
162 * dummy read to enable the internal reference voltage.
163 */
164 if (!ext_vref)
165 regmap_read(data->regmap, data->cmd_byte, &regval);
166
157 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, 167 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
158 data, 168 data,
159 ads7828_groups); 169 ads7828_groups);