Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp444745lqj; Sun, 2 Jun 2024 06:01:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9C/a7gwwjQHY54Xa7ubQ/34yDsWbLSH3E9efRrNxaFH8j0jqdc3MjrpPgWoJXyZwmDEf1/CnHCesqXD5d9VPYoNNNjHoLY9EDKax4Rw== X-Google-Smtp-Source: AGHT+IGQFkQryEj+5xYCYHAiX9WUzfBQ/OAOoyHvpsCrkMM+HvTphN0pbPeAUIuC6Y+hjncv6Lu4 X-Received: by 2002:a05:6a20:734e:b0:1b0:812:ab3e with SMTP id adf61e73a8af0-1b26f25d051mr7902680637.38.1717333314680; Sun, 02 Jun 2024 06:01:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717333314; cv=pass; d=google.com; s=arc-20160816; b=dgcp3JFr2fTjBOC6yoDRLWiFugrCD/KRMnfoLa+57sOjLp3gjqOPr4rg/90fdkW0tb 1/2fPzjbNm1OrC9sNxzXFIo+JcHpUZlS2m2obxG8ySq0kzDhUZpuKAWAa++mmuECfwVX bQIaFyj3rHHpr9QGCKekmclN7y9IvPq8UYX3IFOZy/iRLHtIYrumKbOjDdVDu3HRYI4u FrHJWaSjCFlGP7kqfI7zZrfbMxJ4roOM5pmYhVN0iglhle342eVhNxmFoIGU462PIYVN rhcJ4ZNM4+Axs3bjE198HoNvPjGj/yK/aycMcm4F5R7rqw9BWanhlcoVhtTsnm5KsxCj SXcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=WzERVbyrH+JYdP+U4bvfP6SlqHa8I0ajuXChzUvzhMU=; fh=xjsdCYuomEJyS1EkfNUc5fKtF34cXQ1mOBn36d3R9dU=; b=l+RbYP7Wphscsn/DoNImDuUab+C3YfMf2yosDIx1LT9pxjHX0FBztQyM7eM0JxEjDM TWERIlFlYdlmj/QWAB+V6TpitJuzZzPgM4fxoX72ewnn1QhqZdU5d8AJXw4AEhU2t1gZ MsLL0LE0EYUR/O/YroxH8D7LpjaW+VS2W7JrFkSHJW1PsXoMwYbequisxDPmlhyC5e2+ Jqn/hpuwvzAJ3j2gwPST3gByOE4Lljn/UgZgxUJrZppWPcbz6zytwjXEqwyaGYK9dRjv /Tdzu8boExJly2GVKcPX01Ss1FDWCjL9kJMQxA5vfUwBcIdIlpajnpeORRoqLEFikg/K cSiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BzXDecZs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-198246-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c3540fac6esi4842352a12.6.2024.06.02.06.01.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 06:01:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198246-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BzXDecZs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-198246-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 50895282722 for ; Sun, 2 Jun 2024 13:01:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6561E3BBCB; Sun, 2 Jun 2024 13:01:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BzXDecZs" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 844C010795; Sun, 2 Jun 2024 13:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717333294; cv=none; b=T8RV1v7fKndMokXIzRiVvGfEUbQqfN0HKKUm5JTV2sVYF1cEDkwxieGj/SlRwOWeThgjerkGkC5F9MCXvUEeEN5w9j6LZEZhq/Bg4yXpFgTtJPa4t4DCptfrTMze9nP7KTMRcrZn0rxB3d1GmQYPkCoURH2jwGaW31qPZwPU2YE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717333294; c=relaxed/simple; bh=XSk5Excflz8p5LLif+T5zrBQC/2wFaw72fKVckybhpM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=syeyEhB3igGhe/wGagcPdy3OON41oiNbuHO6hU+7LEFLXe9nqIOI2t8xah/ijvWlhkvP5MPE1WioXt7vNIqQvVnODPrk91dPS/nM52oGZcqSFq3tSKP732dWCMcJFtsDAOF+uBKg2qvmZStsFTznX777lvnSGGvnZHwDx1PUMt0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BzXDecZs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9932C2BBFC; Sun, 2 Jun 2024 13:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717333294; bh=XSk5Excflz8p5LLif+T5zrBQC/2wFaw72fKVckybhpM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BzXDecZsK1cm5aKEgDLyZ4crqqOp4n9widhhJp0HX68trdjSjjXLAmn9ruw6+bpkw talZnkfRF7sqstChyWZA+b1uI7OGOUNzAzG1OZ2mbjtY51POHQE+JoA2d1VIZOpLur +hWLuxkPcwiNnJ0tqk2lBDE4t559lMaNcR8PdlTy0DCvV0H86TeYXNDUXFQDhoDELn QaS55ONGsLVrVtyR7qkjsEU5alNBmoxilZq2lvaNplgLui62+0jMmgwUNPATLqEGjC aEeU0SFkVS4JJiHg+vXhl/aVPQdcZJ7JH+s1t4rEqoneAOm8fZOAu4lm1CmBKxendY iHrtPyeP4CRjg== Date: Sun, 2 Jun 2024 14:01:23 +0100 From: Jonathan Cameron To: Vasileios Amoiridis Cc: lars@metafoo.de, himanshujha199640@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 14/17] iio: chemical: bme680: Modify startup procedure Message-ID: <20240602140123.3dd1b793@jic23-huawei> In-Reply-To: <20240527183805.311501-15-vassilisamir@gmail.com> References: <20240527183805.311501-1-vassilisamir@gmail.com> <20240527183805.311501-15-vassilisamir@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 27 May 2024 20:38:02 +0200 Vasileios Amoiridis wrote: > Modify the startup procedure to reflect the procedure of > the Bosch BME68x Sensor API. The initial readings and > configuration of the sensor need to happen in the > following order: > > 1) Read calibration data [1,2] > 2) Chip general configuration [3] > 3) Gas configuration [4] > > After the chip configuration it is necessary to ensure that > the sensor is in sleeping mode, in order to apply the gas > configuration settings [5]. > > Also, after the soft reset, it is advised to wait for 5ms [6]. > > [1]: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/bme68x.c#L162 > [2]: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/examples/forced_mode/forced_mode.c#L44 > [3]: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/examples/forced_mode/forced_mode.c#L53 > [4]: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/examples/forced_mode/forced_mode.c#L60 > [5]: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/bme68x.c#L640 > [6]: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/bme68x.c#L294 > Signed-off-by: Vasileios Amoiridis > --- > drivers/iio/chemical/bme680.h | 2 ++ > drivers/iio/chemical/bme680_core.c | 27 ++++++++++++++++++--------- > 2 files changed, 20 insertions(+), 9 deletions(-) > > diff --git a/drivers/iio/chemical/bme680.h b/drivers/iio/chemical/bme680.h > index 17ea59253923..3be2f76a5bfb 100644 > --- a/drivers/iio/chemical/bme680.h > +++ b/drivers/iio/chemical/bme680.h > @@ -61,6 +61,8 @@ > > #define BME680_MEAS_TRIM_MASK GENMASK(24, 4) > > +#define BME680_STARTUP_TIME_US 5000 > + > /* Calibration Parameters */ > #define BME680_T2_LSB_REG 0x8A > #define BME680_H2_MSB_REG 0xE1 > diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c > index b055eeee8f1c..afaa43ec3241 100644 > --- a/drivers/iio/chemical/bme680_core.c > +++ b/drivers/iio/chemical/bme680_core.c > @@ -505,10 +505,12 @@ static int bme680_chip_config(struct bme680_data *data) > ret = regmap_write_bits(data->regmap, BME680_REG_CTRL_MEAS, > BME680_OSRS_TEMP_MASK | BME680_OSRS_PRESS_MASK, > osrs); > - if (ret < 0) > + if (ret < 0) { > dev_err(dev, "failed to write ctrl_meas register\n"); > + return ret; > + } > > - return ret; > + return 0; > } I think this is an unrelated change so if you want to do this - different patch. > > static int bme680_gas_config(struct bme680_data *data) > @@ -517,6 +519,11 @@ static int bme680_gas_config(struct bme680_data *data) > int ret; > u8 heatr_res, heatr_dur; > > + /* Go to sleep */ > + ret = bme680_set_mode(data, false); > + if (ret < 0) > + return ret; > + > heatr_res = bme680_calc_heater_res(data, data->heater_temp); > > /* set target heater temperature */ > @@ -847,6 +854,8 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap, > return ret; > } > > + usleep_range(BME680_STARTUP_TIME_US, BME680_STARTUP_TIME_US + 1000); > + > ret = regmap_read(regmap, BME680_REG_CHIP_ID, &data->check); > if (ret < 0) { > dev_err(dev, "Error reading chip ID\n"); > @@ -859,22 +868,22 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap, > return -ENODEV; > } > > - ret = bme680_chip_config(data); > + ret = bme680_read_calib(data, &data->bme680); > if (ret < 0) { > - dev_err(dev, "failed to set chip_config data\n"); > + dev_err(dev, > + "failed to read calibration coefficients at probe\n"); > return ret; Maybe you have it in a later patch (it definitely wants to be a different patch from this one as different issue), but feels like a bunch of places where dev_err_probe() would be good. > } > > - ret = bme680_gas_config(data); > + ret = bme680_chip_config(data); > if (ret < 0) { > - dev_err(dev, "failed to set gas config data\n"); > + dev_err(dev, "failed to set chip_config data\n"); > return ret; > } > > - ret = bme680_read_calib(data, &data->bme680); > + ret = bme680_gas_config(data); > if (ret < 0) { > - dev_err(dev, > - "failed to read calibration coefficients at probe\n"); > + dev_err(dev, "failed to set gas config data\n"); > return ret; > } >