Commit cc8baffe authored by Christopher Bostic's avatar Christopher Bostic Committed by Jonathan Cameron

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.
Signed-off-by: default avatarChristopher Bostic <cbostic@linux.vnet.ibm.com>
Signed-off-by: default avatarJoel Stanley <joel@jms.id.au>
Signed-off-by: default avatarEddie James <eajames@linux.ibm.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent ba6ec48e
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#define DPS310_RESET 0x0c #define DPS310_RESET 0x0c
#define DPS310_RESET_MAGIC 0x09 #define DPS310_RESET_MAGIC 0x09
#define DPS310_COEF_BASE 0x10 #define DPS310_COEF_BASE 0x10
#define DPS310_COEF_SRC 0x28
/* Make sure sleep time is <= 20ms for usleep_range */ /* Make sure sleep time is <= 20ms for usleep_range */
#define DPS310_POLL_SLEEP_US(t) min(20000, (t) / 8) #define DPS310_POLL_SLEEP_US(t) min(20000, (t) / 8)
...@@ -234,6 +233,10 @@ static bool dps310_is_writeable_reg(struct device *dev, unsigned int reg) ...@@ -234,6 +233,10 @@ static bool dps310_is_writeable_reg(struct device *dev, unsigned int reg)
case DPS310_MEAS_CFG: case DPS310_MEAS_CFG:
case DPS310_CFG_REG: case DPS310_CFG_REG:
case DPS310_RESET: case DPS310_RESET:
/* No documentation available on the registers below */
case 0x0e:
case 0x0f:
case 0x62:
return true; return true;
default: default:
return false; return false;
...@@ -250,6 +253,7 @@ static bool dps310_is_volatile_reg(struct device *dev, unsigned int reg) ...@@ -250,6 +253,7 @@ static bool dps310_is_volatile_reg(struct device *dev, unsigned int reg)
case DPS310_TMP_B1: case DPS310_TMP_B1:
case DPS310_TMP_B2: case DPS310_TMP_B2:
case DPS310_MEAS_CFG: case DPS310_MEAS_CFG:
case 0x32: /* No documentation available on this register */
return true; return true;
default: default:
return false; return false;
...@@ -360,7 +364,7 @@ static const struct regmap_config dps310_regmap_config = { ...@@ -360,7 +364,7 @@ static const struct regmap_config dps310_regmap_config = {
.writeable_reg = dps310_is_writeable_reg, .writeable_reg = dps310_is_writeable_reg,
.volatile_reg = dps310_is_volatile_reg, .volatile_reg = dps310_is_volatile_reg,
.cache_type = REGCACHE_RBTREE, .cache_type = REGCACHE_RBTREE,
.max_register = DPS310_COEF_SRC, .max_register = 0x62, /* No documentation available on this register */
}; };
static const struct iio_info dps310_info = { static const struct iio_info dps310_info = {
...@@ -368,6 +372,46 @@ static const struct iio_info dps310_info = { ...@@ -368,6 +372,46 @@ static const struct iio_info dps310_info = {
.write_raw = dps310_write_raw, .write_raw = dps310_write_raw,
}; };
/*
* Some verions of chip will read temperatures in the ~60C range when
* its actually ~20C. This is the manufacturer recommended workaround
* to correct the issue. The registers used below are undocumented.
*/
static int dps310_temp_workaround(struct dps310_data *data)
{
int rc;
int reg;
rc = regmap_read(data->regmap, 0x32, &reg);
if (rc < 0)
return rc;
/*
* 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;
rc = regmap_write(data->regmap, 0x0e, 0xA5);
if (rc < 0)
return rc;
rc = regmap_write(data->regmap, 0x0f, 0x96);
if (rc < 0)
return rc;
rc = regmap_write(data->regmap, 0x62, 0x02);
if (rc < 0)
return rc;
rc = regmap_write(data->regmap, 0x0e, 0x00);
if (rc < 0)
return rc;
return regmap_write(data->regmap, 0x0f, 0x00);
}
static int dps310_probe(struct i2c_client *client, static int dps310_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -439,6 +483,10 @@ static int dps310_probe(struct i2c_client *client, ...@@ -439,6 +483,10 @@ static int dps310_probe(struct i2c_client *client,
if (rc < 0) if (rc < 0)
return rc; return rc;
rc = dps310_temp_workaround(data);
if (rc < 0)
return rc;
rc = devm_iio_device_register(&client->dev, iio); rc = devm_iio_device_register(&client->dev, iio);
if (rc) if (rc)
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment