Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp655185lqt; Thu, 6 Jun 2024 14:28:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbd9tlz1MTPWbFsg5XhWnF7Bcv8Q+pd9l6M2yBCLfNE9qld9Dv4Cz2BW05hxaK9K6Xjf4+eZkzgiz9YIlel3FT5L7hj0lZJvZr8nlXQg== X-Google-Smtp-Source: AGHT+IGEMH3QHctUUXKHyolZYsAKmNOx6n8v1So7djCbbxPhQHuaZth+VOVHVeww/aXZGGm/CJ28 X-Received: by 2002:a17:906:19ce:b0:a68:31a9:6003 with SMTP id a640c23a62f3a-a6c7650a30amr286779066b.23.1717709330898; Thu, 06 Jun 2024 14:28:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717709330; cv=pass; d=google.com; s=arc-20160816; b=tZ+JcnliPD2IPIkvbdwYjKtu1xyfDbJSYfeLVxReQV0DU9WZemUmfWyGxrEDajvtis EK/7By/H4TR3KhMwgLgrLlV22gUr2zQPv8otZG6mtriIys7dHxKA1XaiuWuJwsFvmrba g+vV6sKDTxn6XbCvav8YtEmIR9VibN40op3SVoZcSPwFjKM3a1d/FswS82DW++gSJ2Y0 Lpp5AiHKhVN5RRpTEAPbw/FHbEq5brJeBqB5oY3IoMLNtkcFxYFOb23N5w5V2sgAPcT4 fYwiw52WVIOPDhqk/kdwRNrWd6QjdFX7PA5HghcrSpwoVRuxjpO4i9nn2U60g8bu8FUU IiDg== 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 :date:subject:cc:to:from:dkim-signature; bh=pG8ZX4YUUuDYrxuB6YPc+RSBqPz2gypGLp3b2Zlmu98=; fh=XcCgd335C9MHHGOFutK/CO+ZBblOAZxDxYiCB5+0Mwc=; b=rJGTjr/H6r8F6rPHkle3Rxo9jyzI16e24IdH5poFNCq5BYR3cpZVZcsNNvOfzOQZPV VX8tdP9USl7hVkJiwImO5buW+YWFqhblwXk9fQE9Q2Pv6ZvmIFZFIYS5A1fvYh1O7h9I AIaVPj2cLVpofsksaqWtVwk0fMlv0dSZcuQvNFnqUcbrmRc1GOI8HQGvNxW5qBs0+5F1 8OfyQQ4ftjIytMMNQuzCHsxR3Ga17rctNX5FtgbPPpdPl49P20yz0YNJ6U+YmGib0m56 eZFxGrJ5q+2Nok1EqvcG5Vi8HI5rN0P9Dgx91urK5njJrPIiSm+CLNhMpAEkk49UgJfP X4aw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Pt9B9M45; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-205074-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205074-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c806daa60si109698966b.456.2024.06.06.14.28.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 14:28:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205074-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Pt9B9M45; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-205074-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205074-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6CA9C1F2201E for ; Thu, 6 Jun 2024 21:28:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A62CC19EEC8; Thu, 6 Jun 2024 21:24:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pt9B9M45" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF73219E7CC; Thu, 6 Jun 2024 21:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717709054; cv=none; b=R3FDaE33LhG+WYetqF85wh/zGUKmbKGb1I2M/EPEwWP2xIMBRsi0ylHeOL2wbPfRe+DzbkHLnyfUIsB9RDmhtkh2xDtVTZu4WmmSnI9V2fd628nNepHH5t2tnapu9punPrtAk7Wa1Dt2QtChqCSsXf5s4p+Von4TkVWCxUtTM64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717709054; c=relaxed/simple; bh=kzbAH1/qm6sKoaFLom2XqF1d9lKnuwIKy3IanCKqJkM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pXC37xIX9BVk0MxTbyzFi8NYw5T3y6NAO7xuuQ6X8EjzY9q+AXv2bRkX5xgnm1/rTnKUrEJYQ70moAo1HnUsc+jjuydP16XDQ90rMQxWJ6E9iz85Y2ejG3M5HY44anF3U+ExFfYb3aF66woc87EhjoYipahyDeCcHD91OTwLFpU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Pt9B9M45; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-57a677d3d79so4867838a12.1; Thu, 06 Jun 2024 14:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717709051; x=1718313851; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pG8ZX4YUUuDYrxuB6YPc+RSBqPz2gypGLp3b2Zlmu98=; b=Pt9B9M45ipWvfkRQwJ3YrAX8K+FObWg5Om7w5Qr3RQNEp4GX//DdG2FD3uhXQ760vp w693tJtkDEu/RgtON9Ar2pEugCuaR1EHFcOoyazR6pwgDfYlrKYhpD/kpP1T8hUQyVE1 UL1fROxGUD1Oo9lnOpDroMIFJZ0kV+bDuoIjWnjSPFR8WVaXiJbNRn15A0lmr9rA2/ou 8RGA9zgjl7r0hyQXB18JOeMhNMk8YIWnpnLXifkP0MSZtfkF28vCy0FGsQAHw+gg7dMk OLatRqAoox8eqCWwX0F/B1UyKmj/0JzXJj8kIQ+rd3uWfWvhOkAEI/J+L2Xfy+XBZidm 9kpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717709051; x=1718313851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pG8ZX4YUUuDYrxuB6YPc+RSBqPz2gypGLp3b2Zlmu98=; b=dSe9tZA0i8IRrMfoi6mK1/oBBbF9EIsIwhLNLlT8Chd2AVKADOcbJSsRiH+E40jMYz D+cMJOElSXeJZxSgNOGtdwEq04/oqZ9kFFnoznIohPC/B+8Ov7nrTESYjak/0XytuhAO FgkI8y5sQOjJ/tf6THqDJ/5fklOuyzsq9cEgTsEKTxXVXbdedQ3c1JadlMnFWebkM6cC Eob2rN8+hcxZfMEfBxHAieabPQ6T6jCkfvFmtMuMazciADkYgFa0naczd/ghT3CAdDpY Sa4ziQW2cSpoI1s2xAI8MRolmU3RKmKLHqx/fXem41et6fWRR7AFImtEqxhqbASKz9TV 99Qw== X-Forwarded-Encrypted: i=1; AJvYcCVNipTXzz0hHkNt5iwsN3iFlh6xNTGtjXzK3EYTTxRWvsvhm6a4usN5IFnCPTA+u8qtbKdS0ZNWiaOpwZJ89l/lLXLwTQNlcJFqiZkKrGY7XwkpfdwazQjbRJk+/aZGjdbEd7uxAHBG X-Gm-Message-State: AOJu0YwLVsroOiTBt6ksK9jVOWH//g3nVeZW36XDNGpDdqpETiK65RNB PGutFqKJYDGAXx3MhG5nYbBPy7BMVQR3wNjB693gP2gXBJFfhvjB X-Received: by 2002:a17:906:7749:b0:a61:7f85:e31c with SMTP id a640c23a62f3a-a6cba5962damr67000466b.12.1717709051335; Thu, 06 Jun 2024 14:24:11 -0700 (PDT) Received: from localhost.localdomain ([2a04:ee41:82:7577:28a0:434b:ab8b:94ca]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8058272bsm146690566b.18.2024.06.06.14.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 14:24:10 -0700 (PDT) From: Vasileios Amoiridis To: jic23@kernel.org Cc: dpfrey@gmail.com, himanshujha199640@gmail.com, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, mike.looijmans@topic.nl, vassilisamir@gmail.com Subject: [PATCH v2 15/19] iio: chemical: bme680: Modify startup procedure Date: Thu, 6 Jun 2024 23:23:09 +0200 Message-Id: <20240606212313.207550-18-vassilisamir@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240606212313.207550-1-vassilisamir@gmail.com> References: <20240606212313.207550-1-vassilisamir@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/iio/chemical/bme680.h b/drivers/iio/chemical/bme680.h index 7d0ff294725a..b2c547ac8d34 100644 --- a/drivers/iio/chemical/bme680.h +++ b/drivers/iio/chemical/bme680.h @@ -63,6 +63,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 25d128e1ddcf..e354eaa34d59 100644 --- a/drivers/iio/chemical/bme680_core.c +++ b/drivers/iio/chemical/bme680_core.c @@ -531,6 +531,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 */ @@ -866,6 +871,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"); @@ -878,22 +885,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; } - 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; } -- 2.25.1