linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.vnet.ibm.com>
To: Matt Ranostay <matt.ranostay@konsulko.com>,
	Eddie James <eajames@linux.ibm.com>
Cc: "open list:IIO SUBSYSTEM AND DRIVERS" <linux-iio@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	joel@jms.id.au, Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Jonathan Cameron <jic23@kernel.org>,
	Christopher Bostic <cbostic@linux.vnet.ibm.com>
Subject: Re: [PATCH v2 2/3] iio: dps310: Temperature measurement errata
Date: Thu, 9 May 2019 10:17:14 -0500	[thread overview]
Message-ID: <5217daa3-4f43-0fce-5d1f-438f8c9e47bb@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAJCx=gn0Yv+oP56HQQNm-9JbH2aoZuEQ-73b1grLTVNfbYsDsg@mail.gmail.com>


On 5/8/19 10:09 PM, Matt Ranostay wrote:
> On Thu, May 9, 2019 at 3:36 AM Eddie James <eajames@linux.ibm.com> wrote:
>> From: Christopher Bostic <cbostic@linux.vnet.ibm.com>
>>
>> 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: Christopher Bostic <cbostic@linux.vnet.ibm.com>
>> Signed-off-by: Joel Stanley <joel@jms.id.au>
>> Signed-off-by: Eddie James <eajames@linux.ibm.com>
>> ---
>>   drivers/iio/pressure/dps310.c | 51 ++++++++++++++++++++++++++++++++++++++++++-
>>   1 file changed, 50 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
>> index 7afaa88..c42808e 100644
>> --- a/drivers/iio/pressure/dps310.c
>> +++ b/drivers/iio/pressure/dps310.c
>> @@ -221,6 +221,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:
> What is with the magic values? Are they not documented to what they
> are, and hence not defining enum values for them?
>
> - Matt


Thats correct. These don't show up in the data sheet so I left them as 
raw values. Chris, do you know what the source for these values was?

Thanks,

Eddie


>
>>                  return true;
>>          default:
>>                  return false;
>> @@ -237,6 +240,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;
>> @@ -314,7 +318,7 @@ static int dps310_read_raw(struct iio_dev *iio,
>>          .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 = {
>> @@ -322,6 +326,47 @@ static int dps310_read_raw(struct iio_dev *iio,
>>          .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.
>> + */
>> +static int dps310_temp_workaround(struct dps310_data *data)
>> +{
>> +       int r, reg;
>> +
>> +       r = regmap_read(data->regmap, 0x32, &reg);
>> +       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)
>>   {
>> @@ -383,6 +428,10 @@ static int dps310_probe(struct i2c_client *client,
>>          if (r < 0)
>>                  goto err;
>>
>> +       r = dps310_temp_workaround(data);
>> +       if (r < 0)
>> +               return r;
>> +
>>          r = devm_iio_device_register(&client->dev, iio);
>>          if (r)
>>                  goto err;
>> --
>> 1.8.3.1
>>


  reply	other threads:[~2019-05-09 15:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 19:35 [PATCH v2 0/3] iio: Add driver for Infineon DPS310 Eddie James
2019-05-08 19:35 ` [PATCH v2 1/3] " Eddie James
2019-05-11  9:22   ` Jonathan Cameron
2019-05-15 18:46     ` Eddie James
2019-05-18  8:46       ` Jonathan Cameron
2019-05-08 19:35 ` [PATCH v2 2/3] iio: dps310: Temperature measurement errata Eddie James
2019-05-09  3:09   ` Matt Ranostay
2019-05-09 15:17     ` Eddie James [this message]
2019-05-10  2:21       ` Matt Ranostay
2019-05-08 19:35 ` [PATCH v2 3/3] iio: dps310: Add pressure sensing capability Eddie James
2019-05-11  9:48   ` Jonathan Cameron
2019-05-14 20:25     ` Eddie James
2019-05-18  8:47       ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5217daa3-4f43-0fce-5d1f-438f8c9e47bb@linux.vnet.ibm.com \
    --to=eajames@linux.vnet.ibm.com \
    --cc=cbostic@linux.vnet.ibm.com \
    --cc=eajames@linux.ibm.com \
    --cc=jic23@kernel.org \
    --cc=joel@jms.id.au \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.ranostay@konsulko.com \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).