diff options
| author | Christopher Bostic <cbostic@linux.vnet.ibm.com> | 2017-07-24 16:25:08 -0500 |
|---|---|---|
| committer | Joel Stanley <joel@jms.id.au> | 2019-03-20 15:13:32 +1030 |
| commit | c2f4437371745cae6d427373c620b81b5ec55dab (patch) | |
| tree | 40c8dbf3da93dae3998c134d209ec5bff661fdb8 | |
| parent | 3a84e8f859e59f4e65f203320b954dae45a23587 (diff) | |
| download | talos-obmc-linux-c2f4437371745cae6d427373c620b81b5ec55dab.tar.gz talos-obmc-linux-c2f4437371745cae6d427373c620b81b5ec55dab.zip | |
iio: dps310: Temperature measurement errata
Add a manufacturer's suggested workaround to deal with early revisions
of chip that don't indicate correct temperature. Readings can be in the
~60C range when they should be in the ~20's.
OpenBMC-Staging-Count: 6
Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
| -rw-r--r-- | drivers/iio/pressure/dps310.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c index 6e0445552bf3..beb8b118b666 100644 --- a/drivers/iio/pressure/dps310.c +++ b/drivers/iio/pressure/dps310.c @@ -219,6 +219,9 @@ static bool dps310_is_writeable_reg(struct device *dev, unsigned int reg) case DPS310_MEAS_CFG: case DPS310_CFG_REG: case DPS310_RESET: + case 0x0e: + case 0x0f: + case 0x62: return true; default: return false; @@ -235,6 +238,7 @@ static bool dps310_is_volatile_reg(struct device *dev, unsigned int reg) case DPS310_TMP_B1: case DPS310_TMP_B2: case DPS310_MEAS_CFG: + case 0x32: return true; default: return false; @@ -308,7 +312,7 @@ static const struct regmap_config dps310_regmap_config = { .writeable_reg = dps310_is_writeable_reg, .volatile_reg = dps310_is_volatile_reg, .cache_type = REGCACHE_RBTREE, - .max_register = 0x29, + .max_register = 0x62, }; static const struct iio_info dps310_info = { @@ -316,6 +320,45 @@ static const struct iio_info dps310_info = { .write_raw = dps310_write_raw, }; +/* + * Some verions of chip will read temperatures in the ~60C range when + * its acutally ~20C. This is the manufacturer recommended workaround + * to correct the issue. + */ +static int dps310_temp_workaround(struct dps310_data *data) +{ + int r, reg; + + r = regmap_read(data->regmap, 0x32, ®); + if (r < 0) + return r; + + /* If bit 1 is set then the device is okay, and the workaround does not + * need to be applied */ + if (reg & BIT(1)) + return 0; + + r = regmap_write(data->regmap, 0x0e, 0xA5); + if (r < 0) + return r; + + r = regmap_write(data->regmap, 0x0f, 0x96); + if (r < 0) + return r; + + r = regmap_write(data->regmap, 0x62, 0x02); + if (r < 0) + return r; + + r = regmap_write(data->regmap, 0x0e, 0x00); + if (r < 0) + return r; + + r = regmap_write(data->regmap, 0x0f, 0x00); + + return r; +} + static int dps310_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -378,6 +421,10 @@ static int dps310_probe(struct i2c_client *client, if (r < 0) return r; + r = dps310_temp_workaround(data); + if (r < 0) + return r; + r = devm_iio_device_register(&client->dev, iio); if (r) return r; |

