Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp262216yba; Wed, 8 May 2019 20:11:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZhByAtsSHLFJLzQYokMedEXDxQSqZpEWpdoCKOJpXO/0nrAQ+nNGrsqQcJGbOTeZEomG2 X-Received: by 2002:a63:fc55:: with SMTP id r21mr2392457pgk.441.1557371474107; Wed, 08 May 2019 20:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557371474; cv=none; d=google.com; s=arc-20160816; b=OEkx8WspI/VjwrefR2QOqyo+XYJ9tX2ItA2xyTPeNyJHtSm1apCnfJK4zGmMZacwPh lVJjh1DwGbWVR4ACMtozdyV/4tYX78zAXlUaRJmUuA66EQzSaue6eXPbUpg5DjP+0elV myVyRIjfGmbUokpl9YwZ3wrLi4WvGjOJhtxJ2ZLgLiTihlBOB0+mOouXEpwhY7s/c0fi FI5iSvtJYByI9XRXcBkq1lgdhNUGAED0hKpBpglVd27Mihi3oD73ERwki8Ht9ez/8oAQ X8skB9Qh8VhSuU3sFwx/934E1uv8gp1K5y3b5tO1lf+4L6SzqdOXiTn41OjED2mRAyeT y3/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=tzFejlNEzzPWI2r7iGHhXKbUYOinWB90ZjCR6lplpJM=; b=OjP5NWUIZlG/XdPqkVQh7OaO1b/IUVG8bwqx71ZkRC51+rPriS4ZEAUBZ3cq7Gi9S+ 99bD9NO9Y4qqjfHOEC0iSJq+E40gR8Lw2dY9L9wDcPNY+iVBgZIyI20TcO6fearUOEV/ seYSzb1kbPkFjtW31XsmH9ZOrP7F9ZVTiwwdIU+meFbqhh0G0SVOjkOH7oljrmkUzXmS 5p+bfbtKIyWxKDqr+Y6frru3vyzJYuZP4lB72cD2LLjxQYum4NzOMeW478gHtBybRVdD QMM8n6ErHGSy5QoZNKpAShAg7MO/VHEFDzuSjOLU3x3gH6f3g7hG3V3LGEZNyK4GzIj6 TFGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@konsulko.com header.s=google header.b=MLZ+PiNh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15si1060055plo.310.2019.05.08.20.10.57; Wed, 08 May 2019 20:11:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@konsulko.com header.s=google header.b=MLZ+PiNh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726503AbfEIDKI (ORCPT + 99 others); Wed, 8 May 2019 23:10:08 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:38429 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726100AbfEIDKI (ORCPT ); Wed, 8 May 2019 23:10:08 -0400 Received: by mail-it1-f194.google.com with SMTP id i63so444897ita.3 for ; Wed, 08 May 2019 20:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tzFejlNEzzPWI2r7iGHhXKbUYOinWB90ZjCR6lplpJM=; b=MLZ+PiNhFL5hha/66D5ODFUNYQ/skp7nsqd36wDgUuqDzaQcdCDnVSKy7otHyCgg7G /NskfxkW9Ea4pf7FxQozEFB7iQjQLi+UFdUQCmrsgke5a6AqmoyJcHH5M6DuOItu9Qym T68sJkaE1MQp9UqhHSJ+lEkmbqbBI4A4vIVvk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tzFejlNEzzPWI2r7iGHhXKbUYOinWB90ZjCR6lplpJM=; b=YewAFpl+gNBWw3OWf4wVtsj6BD/MixMWCaPR9fdiMr1g9lTqU7xSw8lerWBjmWGgt0 8W4BviFitSw1yBJk9YgqWUDQYA8PUgdDZWzqRcjbdHy5zQJI0RUBwigSBf11E0tN3hIs 6kuPGNCC38gmvqD9e/UZytjcHaiz7zmpS4paooRJWlXD8F6nesummTV8bePzfa/9uDmJ gtd0wbvtgoPTChG8b3OxkgFLspNIg7YFWtKMJMAbW5aT98ChSwCRLvEsp4dXWQbYeyVS 4XPXcjjCNY4KstfHZ/weTq/JIMo4UO7SDMa9rlOmJ/MaCSOsLulFWgZfzyQeJb1/AxeG 59qg== X-Gm-Message-State: APjAAAXkzdQXASZ1x58CbG/Y6Bv53UoF8ztWIXmhlU+ozajcHBmCup+D LhmbPUENGNEltX7YbO1cmQBtfMr7XizfigXwqRHuGw== X-Received: by 2002:a02:3b24:: with SMTP id c36mr1346624jaa.52.1557371407664; Wed, 08 May 2019 20:10:07 -0700 (PDT) MIME-Version: 1.0 References: <1557344128-690-1-git-send-email-eajames@linux.ibm.com> <1557344128-690-3-git-send-email-eajames@linux.ibm.com> In-Reply-To: <1557344128-690-3-git-send-email-eajames@linux.ibm.com> From: Matt Ranostay Date: Thu, 9 May 2019 11:09:56 +0800 Message-ID: Subject: Re: [PATCH v2 2/3] iio: dps310: Temperature measurement errata To: Eddie James Cc: "open list:IIO SUBSYSTEM AND DRIVERS" , open list , joel@jms.id.au, Peter Meerwald-Stadler , Lars-Peter Clausen , Hartmut Knaack , Jonathan Cameron , Christopher Bostic Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 9, 2019 at 3:36 AM Eddie James wrote: > > From: Christopher Bostic > > 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 > Signed-off-by: Joel Stanley > Signed-off-by: Eddie James > --- > 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 > 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, ®); > + 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 >