From nobody Fri Oct 18 08:47:11 2024 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 D1459200CB1; Thu, 17 Oct 2024 23:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729207835; cv=none; b=XcAJ4UZy+yO3OdP4C4yHc7YC/vTjYg09rliWAOk8cRrQrc8A4DMF3fsiPqJDbd+X5cJSniUy/uo0XYQCytnrMekKkpaWyoG1aMBwL7AErmYHC6dDgTRJEikBxtVoCBnp7Y/XZPpZPwysiX/illSGSmQGl+5PP3dwYaGPFpSTYn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729207835; c=relaxed/simple; bh=r2MJjo+AxWykg8h4A+XVsUGUtoSjmKFbCzd2Cldo5Sg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fdKQ93Q+hW5oi4XpBvLuMzgJtho3l3FuyatgtmowYBpLzsRIVzaE1NsBnyvUzUE/q6+i+xHUi4a15hPk5hg5rWp+Xmv8GY0K43PXAUMWssPLGeblFyW8YdF53H5P/rn2WA25K42sbQ2tPM15DgVEYgC2WfU6m4EMz2RYxXue8aQ= 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=YPm11Fhk; arc=none smtp.client-ip=209.85.221.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YPm11Fhk" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-37d538fe5f2so1164778f8f.2; Thu, 17 Oct 2024 16:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729207831; x=1729812631; 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=hu6qYguXyWLLQGgQz5Fyz+bu/mq9sq/0118iAPw8+kw=; b=YPm11FhkTC1cAe3sbYG06b3+6Qwitw1etGTmH5mMjQX7GQV5ih3HMTCnwc24l9G8Kx x46c2cigVgJ1aCTXgcLrmfmMaF07O4qIMDorkOUsK2d6Ui4Yqbd+oYyNoOmnUswDECVo fh+l1vyOT+9+gv8Hl057JTao5uP62tUSI9CsS9pERUUEvTZ5FAD0SBBARYW1xiDGNyve /G5JrxoCYPqQwcfO/0GNS70YLWlb/Wz/xHnw3QqaJ0Ic1Ddc2sa9Z1C2Asej7eIiLIfo pXngYnsxI2xodDJBM5+YrHtFjHaxuNVG7KA+Jgy27typ7yo6Bq/0fvrzty8IGFKMMimf MJ1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729207831; x=1729812631; 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=hu6qYguXyWLLQGgQz5Fyz+bu/mq9sq/0118iAPw8+kw=; b=jjy5GQCVLLAvbUJq1vHcOJVr3GeJpwS5xkVVz4OqBVV9PuQithJM9ZtTe7TGGQufbt 2qIiJR2WIrcgLTASt/SML9KbO4GLM0tXSJv8qNnBh7L+KC4glgLlSDuV2TbybcOh66g/ uZWHNFKGiXL2J598qYtt673Uq3evkcUzzHp6yjIuC2OOItRzDJ5XtsGW643LdzbopUes ZFuUEuAR0gn0lVWdBkA+vi75mJU6sOgI2CTnud65Z9HxiGnZz0dT283Vno5rxcfGF+fa cHTG/39lf/IzgWwwdjPJ7kq8pS1y/24Lus0laG6YbD6ipwDQMBGqgix9kPSsbJfXTe5G 9h1Q== X-Forwarded-Encrypted: i=1; AJvYcCUU4D1Tmper1j+wMYveSC+OoaNDqdGEDDXwLVu6RKcT0q1EJzkixr3HQ4Bkm4gKzKH9avho+hgcZz/i@vger.kernel.org, AJvYcCW4c7fdZk/CzkLERuu6Qz/TANtHXajkO7h/1pK+7zE/hA6jeXMm3jqp0oB8ioQes30/5uhup09SlpfXJlGx@vger.kernel.org, AJvYcCWc9H6rIHASDssC3VvR4OK3NBI9ie2fVKArdcGZXhOfbRTnd1i3o+1cwBaavPVNCFSdefih5dsRq+tC@vger.kernel.org X-Gm-Message-State: AOJu0YyCEc0j2Pqt8gOfbo+4/cpNrHdeG9bN8B0kNQcVrkPvXHf+Yyia Bxf2JbWE0QDk/ALypV2J3ImJVjdIQfjBIkL+ahgpRoZzF1iujvxa X-Google-Smtp-Source: AGHT+IHTtMgwQ5dY6xup2gHjadCgQlbmrSuoKrPH+K9jeFV/iEui1aA61vDELUdrXFy8iHp7L33MOg== X-Received: by 2002:a05:6000:109:b0:35f:d70:6193 with SMTP id ffacd0b85a97d-37eb487b3admr295914f8f.41.1729207830877; Thu, 17 Oct 2024 16:30:30 -0700 (PDT) Received: from vamoirid-laptop.. ([2a04:ee41:82:7577:8661:df0e:b445:43ef]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-37ecf06d3casm306939f8f.48.2024.10.17.16.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 16:30:29 -0700 (PDT) From: Vasileios Amoiridis To: jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andriy.shevchenko@linux.intel.com Cc: vassilisamir@gmail.com, ang.iglesiasg@gmail.com, ajarizzo@gmail.com, biju.das.jz@bp.renesas.com, linus.walleij@linaro.org, semen.protsenko@linaro.org, 579lpy@gmail.com, ak@it-klinger.de, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 1/4] iio: pressure: bmp280: Use sleep and forced mode for oneshot captures Date: Fri, 18 Oct 2024 01:30:19 +0200 Message-ID: <20241017233022.238250-2-vassilisamir@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017233022.238250-1-vassilisamir@gmail.com> References: <20241017233022.238250-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: quoted-printable Content-Type: text/plain; charset="utf-8" Add forced mode support in sensors BMP28x, BME28x, BMP3xx and BMP58x. Sensors BMP18x and BMP085 are old and do not support this feature so their operation is not affected at all. Essentially, up to now, the rest of the sensors were used in normal mode all the time. This means that they are continuously doing measurements even though these measurements are not used. Even though the sensor does provide PM support, to cover all the possible use cases, the sensor needs to go into sleep mode and wake up whenever necessary. The idea is that the sensor is by default in sleep mode, wakes up in forced mode when a oneshot capture is requested, or in normal mode when the buffer is enabled. The difference lays in the fact that in forced mode, the sensor does only one conversion and goes back to sleep while in normal mode, the sensor does continuous measurements with the frequency that was set in the ODR registers. The bmpX_chip_config() functions which are responsible for applying the requested configuration to the sensor, are modified accordingly in order to set the sensor by default in sleep mode. DEEP STANDBY, Low Power NORMAL and CONTINUOUS modes, supported only by the BMP58x version, are not added. Reviewed-by: Andy Shevchenko Signed-off-by: Vasileios Amoiridis --- drivers/iio/pressure/bmp280-core.c | 280 ++++++++++++++++++++++++++--- drivers/iio/pressure/bmp280.h | 21 +++ 2 files changed, 280 insertions(+), 21 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp2= 80-core.c index 682329f81886..70abaff08646 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -16,6 +16,11 @@ * https://www.bosch-sensortec.com/media/boschsensortec/downloads/datashee= ts/bst-bmp390-ds002.pdf * https://www.bosch-sensortec.com/media/boschsensortec/downloads/datashee= ts/bst-bmp581-ds004.pdf * + * Sensor API: + * https://github.com/boschsensortec/BME280_SensorAPI + * https://github.com/boschsensortec/BMP3_SensorAPI + * https://github.com/boschsensortec/BMP5_SensorAPI + * * Notice: * The link to the bmp180 datasheet points to an outdated version missing = these changes: * - Changed document referral from ANP015 to BST-MPS-AN004-00 on page 26 @@ -616,6 +621,14 @@ static int bmp280_read_raw_impl(struct iio_dev *indio_= dev, =20 switch (mask) { case IIO_CHAN_INFO_PROCESSED: + ret =3D data->chip_info->set_mode(data, BMP280_FORCED); + if (ret) + return ret; + + ret =3D data->chip_info->wait_conv(data); + if (ret) + return ret; + switch (chan->type) { case IIO_HUMIDITYRELATIVE: ret =3D data->chip_info->read_humid(data, &chan_value); @@ -645,6 +658,14 @@ static int bmp280_read_raw_impl(struct iio_dev *indio_= dev, return -EINVAL; } case IIO_CHAN_INFO_RAW: + ret =3D data->chip_info->set_mode(data, BMP280_FORCED); + if (ret) + return ret; + + ret =3D data->chip_info->wait_conv(data); + if (ret) + return ret; + switch (chan->type) { case IIO_HUMIDITYRELATIVE: ret =3D data->chip_info->read_humid(data, &chan_value); @@ -991,6 +1012,65 @@ static int bmp280_preinit(struct bmp280_data *data) return 0; } =20 +static const u8 bmp280_operation_mode[] =3D { + [BMP280_SLEEP] =3D BMP280_MODE_SLEEP, + [BMP280_FORCED] =3D BMP280_MODE_FORCED, + [BMP280_NORMAL] =3D BMP280_MODE_NORMAL, +}; + +static int bmp280_set_mode(struct bmp280_data *data, enum bmp280_op_mode m= ode) +{ + int ret; + + ret =3D regmap_write_bits(data->regmap, BMP280_REG_CTRL_MEAS, + BMP280_MODE_MASK, bmp280_operation_mode[mode]); + if (ret) { + dev_err(data->dev, "failed to write ctrl_meas register.\n"); + return ret; + } + + data->op_mode =3D mode; + + return 0; +} + +static int bmp280_wait_conv(struct bmp280_data *data) +{ + unsigned int reg, meas_time_us; + int ret; + + /* Check if we are using a BME280 device */ + if (data->oversampling_humid) + meas_time_us =3D BMP280_PRESS_HUMID_MEAS_OFFSET + + BIT(data->oversampling_humid) * BMP280_MEAS_DUR; + + else + meas_time_us =3D 0; + + /* Pressure measurement time */ + meas_time_us +=3D BMP280_PRESS_HUMID_MEAS_OFFSET + + BIT(data->oversampling_press) * BMP280_MEAS_DUR; + + /* Temperature measurement time */ + meas_time_us +=3D BIT(data->oversampling_temp) * BMP280_MEAS_DUR; + + /* Waiting time according to the BM(P/E)2 Sensor API */ + fsleep(meas_time_us); + + ret =3D regmap_read(data->regmap, BMP280_REG_STATUS, ®); + if (ret) { + dev_err(data->dev, "failed to read status register.\n"); + return ret; + } + + if (reg & BMP280_REG_STATUS_MEAS_BIT) { + dev_err(data->dev, "Measurement cycle didn't complete.\n"); + return -EBUSY; + } + + return 0; +} + static int bmp280_chip_config(struct bmp280_data *data) { u8 osrs =3D FIELD_PREP(BMP280_OSRS_TEMP_MASK, data->oversampling_temp + 1= ) | @@ -1001,7 +1081,7 @@ static int bmp280_chip_config(struct bmp280_data *dat= a) BMP280_OSRS_TEMP_MASK | BMP280_OSRS_PRESS_MASK | BMP280_MODE_MASK, - osrs | BMP280_MODE_NORMAL); + osrs | BMP280_MODE_SLEEP); if (ret) { dev_err(data->dev, "failed to write ctrl_meas register\n"); return ret; @@ -1111,6 +1191,8 @@ const struct bmp280_chip_info bmp280_chip_info =3D { .read_temp =3D bmp280_read_temp, .read_press =3D bmp280_read_press, .read_calib =3D bmp280_read_calib, + .set_mode =3D bmp280_set_mode, + .wait_conv =3D bmp280_wait_conv, .preinit =3D bmp280_preinit, =20 .trigger_handler =3D bmp280_trigger_handler, @@ -1235,6 +1317,8 @@ const struct bmp280_chip_info bme280_chip_info =3D { .read_press =3D bmp280_read_press, .read_humid =3D bme280_read_humid, .read_calib =3D bme280_read_calib, + .set_mode =3D bmp280_set_mode, + .wait_conv =3D bmp280_wait_conv, .preinit =3D bmp280_preinit, =20 .trigger_handler =3D bme280_trigger_handler, @@ -1522,6 +1606,64 @@ static int bmp380_preinit(struct bmp280_data *data) return bmp380_cmd(data, BMP380_CMD_SOFT_RESET); } =20 +static const u8 bmp380_operation_mode[] =3D { + [BMP280_SLEEP] =3D BMP380_MODE_SLEEP, + [BMP280_FORCED] =3D BMP380_MODE_FORCED, + [BMP280_NORMAL] =3D BMP380_MODE_NORMAL, +}; + +static int bmp380_set_mode(struct bmp280_data *data, enum bmp280_op_mode m= ode) +{ + int ret; + + ret =3D regmap_write_bits(data->regmap, BMP380_REG_POWER_CONTROL, + BMP380_MODE_MASK, + FIELD_PREP(BMP380_MODE_MASK, + bmp380_operation_mode[mode])); + if (ret) { + dev_err(data->dev, "failed to write power control register.\n"); + return ret; + } + + data->op_mode =3D mode; + + return 0; +} + +static int bmp380_wait_conv(struct bmp280_data *data) +{ + unsigned int reg; + int ret, meas_time_us; + + /* Offset measurement time */ + meas_time_us =3D BMP380_MEAS_OFFSET; + + /* Pressure measurement time */ + meas_time_us +=3D BMP380_PRESS_MEAS_OFFSET + + BIT(data->oversampling_press) * BMP380_MEAS_DUR; + + /* Temperature measurement time */ + meas_time_us +=3D BMP380_TEMP_MEAS_OFFSET + + BIT(data->oversampling_temp) * BMP380_MEAS_DUR; + + /* Measurement time defined in Datasheet Section 3.9.2 */ + fsleep(meas_time_us); + + ret =3D regmap_read(data->regmap, BMP380_REG_STATUS, ®); + if (ret) { + dev_err(data->dev, "failed to read status register.\n"); + return ret; + } + + if (!((reg & BMP380_STATUS_DRDY_PRESS_MASK) && + (reg & BMP380_STATUS_DRDY_TEMP_MASK))) { + dev_err(data->dev, "Measurement cycle didn't complete.\n"); + return -EBUSY; + } + + return 0; +} + static int bmp380_chip_config(struct bmp280_data *data) { bool change =3D false, aux; @@ -1582,17 +1724,19 @@ static int bmp380_chip_config(struct bmp280_data *d= ata) * Resets sensor measurement loop toggling between sleep and * normal operating modes. */ - ret =3D regmap_write_bits(data->regmap, BMP380_REG_POWER_CONTROL, - BMP380_MODE_MASK, - FIELD_PREP(BMP380_MODE_MASK, BMP380_MODE_SLEEP)); + ret =3D bmp380_set_mode(data, BMP280_SLEEP); if (ret) { dev_err(data->dev, "failed to set sleep mode\n"); return ret; } - usleep_range(2000, 2500); - ret =3D regmap_write_bits(data->regmap, BMP380_REG_POWER_CONTROL, - BMP380_MODE_MASK, - FIELD_PREP(BMP380_MODE_MASK, BMP380_MODE_NORMAL)); + + /* + * According to the BMP3 Sensor API, the sensor needs 5ms + * in order to go to the sleep mode. + */ + fsleep(5 * USEC_PER_MSEC); + + ret =3D bmp380_set_mode(data, BMP280_NORMAL); if (ret) { dev_err(data->dev, "failed to set normal mode\n"); return ret; @@ -1618,7 +1762,16 @@ static int bmp380_chip_config(struct bmp280_data *da= ta) } } =20 - return 0; + /* Dummy read to empty data registers. */ + ret =3D bmp380_read_press(data, &tmp); + if (ret) + return ret; + + ret =3D bmp380_set_mode(data, BMP280_SLEEP); + if (ret) + dev_err(data->dev, "failed to set sleep mode.\n"); + + return ret; } =20 static irqreturn_t bmp380_trigger_handler(int irq, void *p) @@ -1714,6 +1867,8 @@ const struct bmp280_chip_info bmp380_chip_info =3D { .read_temp =3D bmp380_read_temp, .read_press =3D bmp380_read_press, .read_calib =3D bmp380_read_calib, + .set_mode =3D bmp380_set_mode, + .wait_conv =3D bmp380_wait_conv, .preinit =3D bmp380_preinit, =20 .trigger_handler =3D bmp380_trigger_handler, @@ -2101,6 +2256,70 @@ static int bmp580_preinit(struct bmp280_data *data) return PTR_ERR_OR_ZERO(devm_nvmem_register(config.dev, &config)); } =20 +static const u8 bmp580_operation_mode[] =3D { + [BMP280_SLEEP] =3D BMP580_MODE_SLEEP, + [BMP280_FORCED] =3D BMP580_MODE_FORCED, + [BMP280_NORMAL] =3D BMP580_MODE_NORMAL, +}; + +static int bmp580_set_mode(struct bmp280_data *data, enum bmp280_op_mode m= ode) +{ + struct device *dev =3D data->dev; + int ret; + + if (mode =3D=3D BMP280_FORCED) { + ret =3D regmap_set_bits(data->regmap, BMP580_REG_DSP_CONFIG, + BMP580_DSP_IIR_FORCED_FLUSH); + if (ret) { + dev_err(dev, "Could not flush IIR filter constants.\n"); + return ret; + } + } + + ret =3D regmap_write_bits(data->regmap, BMP580_REG_ODR_CONFIG, + BMP580_MODE_MASK, + FIELD_PREP(BMP580_MODE_MASK, + bmp580_operation_mode[mode])); + if (ret) { + dev_err(dev, "failed to write power control register.\n"); + return ret; + } + + data->op_mode =3D mode; + + return 0; +} + +static int bmp580_wait_conv(struct bmp280_data *data) +{ + /* + * Taken from datasheet, Section 2 "Specification, Table 3 "Electrical + * characteristics. + */ + static const int time_conv_press[] =3D { + 0, 1050, 1785, 3045, 5670, 10920, 21420, 42420, + 84420, + }; + static const int time_conv_temp[] =3D { + 0, 1050, 1105, 1575, 2205, 3465, 6090, 11340, + 21840, + }; + int meas_time_us; + + meas_time_us =3D 4 * USEC_PER_MSEC + + time_conv_temp[data->oversampling_temp] + + time_conv_press[data->oversampling_press]; + + /* + * Measurement time mentioned in Chapter 2, Table 4 of the datasheet. + * The extra 4ms is the required mode change to start of measurement + * time. + */ + fsleep(meas_time_us); + + return 0; +} + static int bmp580_chip_config(struct bmp280_data *data) { bool change =3D false, aux; @@ -2171,17 +2390,6 @@ static int bmp580_chip_config(struct bmp280_data *da= ta) return ret; } =20 - /* Restore sensor to normal operation mode */ - ret =3D regmap_write_bits(data->regmap, BMP580_REG_ODR_CONFIG, - BMP580_MODE_MASK, - FIELD_PREP(BMP580_MODE_MASK, BMP580_MODE_NORMAL)); - if (ret) { - dev_err(data->dev, "failed to set normal mode\n"); - return ret; - } - /* From datasheet's table 4: electrical characteristics */ - usleep_range(3000, 3500); - if (change) { /* * Check if ODR and OSR settings are valid or we are @@ -2281,6 +2489,8 @@ const struct bmp280_chip_info bmp580_chip_info =3D { .chip_config =3D bmp580_chip_config, .read_temp =3D bmp580_read_temp, .read_press =3D bmp580_read_press, + .set_mode =3D bmp580_set_mode, + .wait_conv =3D bmp580_wait_conv, .preinit =3D bmp580_preinit, =20 .trigger_handler =3D bmp580_trigger_handler, @@ -2528,6 +2738,19 @@ static int bmp180_read_press(struct bmp280_data *dat= a, u32 *comp_press) return 0; } =20 +/* Keep compatibility with newer generations of the sensor */ +static int bmp180_set_mode(struct bmp280_data *data, enum bmp280_op_mode m= ode) +{ + return 0; +} + +/* Keep compatibility with newer generations of the sensor */ +static int bmp180_wait_conv(struct bmp280_data *data) +{ + return 0; +} + +/* Keep compatibility with newer generations of the sensor */ static int bmp180_chip_config(struct bmp280_data *data) { return 0; @@ -2599,6 +2822,8 @@ const struct bmp280_chip_info bmp180_chip_info =3D { .read_temp =3D bmp180_read_temp, .read_press =3D bmp180_read_press, .read_calib =3D bmp180_read_calib, + .set_mode =3D bmp180_set_mode, + .wait_conv =3D bmp180_wait_conv, =20 .trigger_handler =3D bmp180_trigger_handler, }; @@ -2651,6 +2876,7 @@ static int bmp280_buffer_preenable(struct iio_dev *in= dio_dev) struct bmp280_data *data =3D iio_priv(indio_dev); =20 pm_runtime_get_sync(data->dev); + data->chip_info->set_mode(data, BMP280_NORMAL); =20 return 0; } @@ -2821,6 +3047,10 @@ int bmp280_common_probe(struct device *dev, return ret; } =20 + ret =3D data->chip_info->set_mode(data, BMP280_SLEEP); + if (ret) + return dev_err_probe(dev, ret, "Failed to set sleep mode\n"); + /* Enable runtime PM */ pm_runtime_get_noresume(dev); pm_runtime_set_active(dev); @@ -2846,6 +3076,9 @@ static int bmp280_runtime_suspend(struct device *dev) struct iio_dev *indio_dev =3D dev_get_drvdata(dev); struct bmp280_data *data =3D iio_priv(indio_dev); =20 + data->chip_info->set_mode(data, BMP280_SLEEP); + + fsleep(data->start_up_time); return regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies); } =20 @@ -2860,7 +3093,12 @@ static int bmp280_runtime_resume(struct device *dev) return ret; =20 usleep_range(data->start_up_time, data->start_up_time + 100); - return data->chip_info->chip_config(data); + + ret =3D data->chip_info->chip_config(data); + if (ret) + return ret; + + return data->chip_info->set_mode(data, data->op_mode); } =20 EXPORT_RUNTIME_DEV_PM_OPS(bmp280_dev_pm_ops, bmp280_runtime_suspend, diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index dc1bf04cb0b5..3babf90ce73c 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -170,6 +170,11 @@ #define BMP380_MODE_FORCED 1 #define BMP380_MODE_NORMAL 3 =20 +#define BMP380_MEAS_OFFSET 234 +#define BMP380_MEAS_DUR 2020 +#define BMP380_TEMP_MEAS_OFFSET 163 +#define BMP380_PRESS_MEAS_OFFSET 392 + #define BMP380_MIN_TEMP -4000 #define BMP380_MAX_TEMP 8500 #define BMP380_MIN_PRES 3000000 @@ -206,6 +211,7 @@ #define BMP280_REG_CTRL_MEAS 0xF4 #define BMP280_REG_STATUS 0xF3 #define BMP280_REG_STATUS_IM_UPDATE BIT(0) +#define BMP280_REG_STATUS_MEAS_BIT BIT(3) #define BMP280_REG_RESET 0xE0 #define BMP280_RST_SOFT_CMD 0xB6 =20 @@ -246,6 +252,10 @@ #define BMP280_MODE_FORCED 1 #define BMP280_MODE_NORMAL 3 =20 +#define BMP280_MEAS_OFFSET 1250 +#define BMP280_MEAS_DUR 2300 +#define BMP280_PRESS_HUMID_MEAS_OFFSET 575 + /* BME280 specific registers */ #define BME280_REG_HUMIDITY_LSB 0xFE #define BME280_REG_HUMIDITY_MSB 0xFD @@ -385,6 +395,12 @@ struct bmp380_calib { s8 P11; }; =20 +enum bmp280_op_mode { + BMP280_SLEEP, + BMP280_FORCED, + BMP280_NORMAL, +}; + struct bmp280_data { struct device *dev; struct mutex lock; @@ -423,6 +439,9 @@ struct bmp280_data { u8 sensor_data[ALIGN(sizeof(s32) * BME280_NUM_MAX_CHANNELS, sizeof(s64)) + sizeof(s64)] __aligned(sizeof(s64)); =20 + /* Value to hold the current operation mode of the device */ + enum bmp280_op_mode op_mode; + /* * DMA (thus cache coherency maintenance) may require the * transfer buffers to live in their own cache lines. @@ -487,6 +506,8 @@ struct bmp280_chip_info { int (*read_humid)(struct bmp280_data *data, u32 *adc_humidity); int (*read_calib)(struct bmp280_data *data); int (*preinit)(struct bmp280_data *data); + int (*set_mode)(struct bmp280_data *data, enum bmp280_op_mode mode); + int (*wait_conv)(struct bmp280_data *data); =20 irqreturn_t (*trigger_handler)(int irq, void *p); }; --=20 2.43.0 From nobody Fri Oct 18 08:47:11 2024 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 6A03E1DA116; Thu, 17 Oct 2024 23:30:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729207837; cv=none; b=cZvWhMgVFTDQT8UZtZ0/uGnUkh1dXKPJ8/BZu7cVGr7dU0RKPge6EkvBqwNJeh8fkLi7Eenvu2zviwleZaLUvaPw29ExIwnhO/5hhFzQDReLSFD54v3M/V0/lD5HUXIKNkKPqwN4JEQ0q866jmX9TH73jeOKHC6HYUsLG+w7IrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729207837; c=relaxed/simple; bh=eAY1hTTkc6zB17ODGLsyqWAOg13GMRMk/2LkjykgxHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aUYmdOuYYjissIYByZ9f9STElhGwu7BlH/F9ILD/FJgHukr68zR6yUGuWSfdcs1n3DUYsF37pPGHj4Btd+pUYyrtCwk14ANy/QPf0cGr+K5aNAa9CzOWUtnJzpzo/YNikH7uGeZwIon+zv0BtYdwzB3AgoMt8GTrTvADy4cO02c= 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=DGmnk25X; arc=none smtp.client-ip=209.85.128.46 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DGmnk25X" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-43158625112so13994135e9.3; Thu, 17 Oct 2024 16:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729207834; x=1729812634; 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=WIbli1M7hW/BVRSXeIjtcKMrgS5TeW2fN11YEFKx9CU=; b=DGmnk25XPYi7xANxyP2DCL5WpNKFg5+UQGuHL48BFDrcGcmZN635Hzo2OFKsAeZ5VM 3mIDfuy79zEqGwGKjG9bzHb+XQaKuHvaMo39lah5PSnjJyuBoA9YiSWBdd4vvsN9Tzdm r9jwPn4xGWg0AWzgS98EzrVkyhpRoJJfZAFrxeVQ5m+a8hVHLqIoERX3W1/obT1EnUEO Wi87G/OlizS/9XoZfQlrpS579R42Ci37RzkBs3X+ScUUzWoRtWcFFHkFu/R1/z690yQL 7PsNOH4uP2YDUNRTdef7iaopllRTvZHylpnwvU72mQ98WQFKRP9smDt0MTye9gt3ocw/ GV0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729207834; x=1729812634; 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=WIbli1M7hW/BVRSXeIjtcKMrgS5TeW2fN11YEFKx9CU=; b=iT4HjQDuIfqoL9YzYV1J1QKLOHYeiWhjILFOZtD6jlJhyH35eP5Mdmkt04XDOD/acW H68sN0bbqYD/R51piwu3O8DCvfuZ/XRNUaGztYRmXK2d15UqNY7fJBjoC4+OVE2u+3+3 1ynwSb9h/EK2waXYa4SgEjSfP7Pz2Jvo21P90ZNYI4SlQraljQOroBPgGEhYwabrSk0m 3DvFzN+TK6Whvl0EQvzdn0ObTnQwpTTJ53p6osbaxEsZwIAIczUyaByp1VZec4/FiAQk 56/6+oxLeYoreT+S71g78ZHoADJ4ErEDvVQXCtIZtt426ROBpCHl95fbatEvsU/PVomn uITA== X-Forwarded-Encrypted: i=1; AJvYcCV2+PzJD9pbeCtExs0R3SOduH2PbrTudpp2UmD/JbzkSDrp0d7wwXYWlZbfXLNwzIR1FAhnlvbUUW8f@vger.kernel.org, AJvYcCVV0fg/Cqlxvmu09eKpLnVdmoWs9MPhrbDpvfLECQbJaffGv3k6KanKmzNbhyG9eKvIsbfmTu53iTXrLiUn@vger.kernel.org, AJvYcCWMNmDfPlqlwIq8IAZJUbvZpyA6lDV+Jh2HdJmjW+YBUKChn/RbEbSQOezqU0rDvzrfIN05pumZk6Vo@vger.kernel.org X-Gm-Message-State: AOJu0Yw/4C7VDYwjnbxlZvchsi8sd+w2Ul8uVYWS8wcK/DgMXfkwqBQ6 pl223iX3pkdbls+INYaJoJOmrvzpkRqOw0A8rheq6TEvNvw/pGOR X-Google-Smtp-Source: AGHT+IGJkALxfsFig24l+iTuar/zke82mzQ6JfVgSsJpPuYgS9NtE77hsCnrs0Q4qc2bqH8io58t8w== X-Received: by 2002:adf:f988:0:b0:37d:940c:7394 with SMTP id ffacd0b85a97d-37ea2192b67mr268486f8f.32.1729207833545; Thu, 17 Oct 2024 16:30:33 -0700 (PDT) Received: from vamoirid-laptop.. ([2a04:ee41:82:7577:8661:df0e:b445:43ef]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-37ecf06d3casm306939f8f.48.2024.10.17.16.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 16:30:32 -0700 (PDT) From: Vasileios Amoiridis To: jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andriy.shevchenko@linux.intel.com Cc: vassilisamir@gmail.com, ang.iglesiasg@gmail.com, ajarizzo@gmail.com, biju.das.jz@bp.renesas.com, linus.walleij@linaro.org, semen.protsenko@linaro.org, 579lpy@gmail.com, ak@it-klinger.de, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Conor Dooley Subject: [PATCH v9 2/4] dt-bindings: iio: pressure: bmp085: Add interrupts for BMP3xx and BMP5xx devices Date: Fri, 18 Oct 2024 01:30:20 +0200 Message-ID: <20241017233022.238250-3-vassilisamir@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017233022.238250-1-vassilisamir@gmail.com> References: <20241017233022.238250-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: quoted-printable Content-Type: text/plain; charset="utf-8" Add interrupt options for BMP3xx and BMP5xx devices as well. Acked-by: Conor Dooley Signed-off-by: Vasileios Amoiridis --- .../bindings/iio/pressure/bmp085.yaml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/pressure/bmp085.yaml b/D= ocumentation/devicetree/bindings/iio/pressure/bmp085.yaml index 6fda887ee9d4..cb201cecfa1a 100644 --- a/Documentation/devicetree/bindings/iio/pressure/bmp085.yaml +++ b/Documentation/devicetree/bindings/iio/pressure/bmp085.yaml @@ -47,15 +47,33 @@ properties: maxItems: 1 =20 interrupts: - description: - interrupt mapping for IRQ (BMP085 only) maxItems: 1 =20 + drive-open-drain: + description: + set if the interrupt pin should be configured as open drain. + If not set, defaults to push-pull configuration. + type: boolean + required: - compatible - vddd-supply - vdda-supply =20 +allOf: + - if: + properties: + compatible: + not: + contains: + enum: + - bosch,bmp085 + - bosch,bmp380 + - bosch,bmp580 + then: + properties: + interrupts: false + additionalProperties: false =20 examples: --=20 2.43.0 From nobody Fri Oct 18 08:47:11 2024 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 59600205AA4; Thu, 17 Oct 2024 23:30:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729207840; cv=none; b=uaaP0IK1Oqe1x/HskCgzUn+TdbUsWAqC828Jk5oqgx/1/EM9jgRjCsKhugju2JEWstjw1u//tQP66LnhaMCc4HEdiyqS2qFzVIOYJW4vRSjYX4SxhCQ3/kdIh4MMAAZe4OYRCOwY4KOY2TxVdzCtTGzh72+r7P3bZY2zErvQzrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729207840; c=relaxed/simple; bh=oRb5xpcd/iPuTu6s3Cmyy1HzBwTIfI4MkXZuyr5lwhA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IVo7zDjKRa1VySZJVCYlJOfA+mJ4A9jT7oIZfqMVLFX9RNyIxN7gIpPjWVOq9fFLddHXcMAgQaQAizpcvsNBNmHrewi4sGUt6CqN+raVMZdQO/7S0Cc+7g8Ca6u+FOxGZJYIyPkqhYyoOEHYykTsQP27oZNDq3ht40cdJJZbrRM= 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=Za/KE9Au; arc=none smtp.client-ip=209.85.221.52 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Za/KE9Au" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-37d4c1b1455so1137476f8f.3; Thu, 17 Oct 2024 16:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729207837; x=1729812637; 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=EqC4jhkEzX/0PiAUkSZMMW8RBuoLzgshKD/S/9YVKyw=; b=Za/KE9AuE0TJ0c7fDBJbOfQgpYjmtuhQRB6E83cvFpEb2f3aoFSAGcS7LLWK7+8LER qPTe+CD2Y+uXO6CKawxrg1FBSrMwZFxXmc3YjDppJUDV1Sd51Qja2Vhx1EgW8tlQbs4f OjV4La2X2R8bEaLSeRUwILLBkn0KhN0cpF5Yz4BsZBi5s5zQxlavBHtLVc4nbMZLgf82 6hjSFWIklWiCUjJhugnFkgjbYZpPMwd62Kpj0H93sgBxrZlNnZP0FaSm7LfvO2vef8Ij gIEpxPTEhcfkras6rUhFpP2O9DhqPIZ6zXKI3pMAHKZGCRSCRRn4roO4BN8Fur+buT86 TRdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729207837; x=1729812637; 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=EqC4jhkEzX/0PiAUkSZMMW8RBuoLzgshKD/S/9YVKyw=; b=XwvueOd0lia4EVByH04MWdV4CGjepi8c0qxhICRH4afAArBYmFgT22CN7HO2NkC7lS LrJPMunIUKd9QchXZ9bQcL8euxXbiy3+RiIDO/cMC+2LQBvMDcljZVc8SkQznDOQx4w5 XF31gTa6oALU9RytN9CAy6ZGXjso/AcHjg/ObbeRykSOborBMe1pjL0nJvNawIaAAchy fgT8+nxG65y0tV+KTJr1xdf7vAybxCF1YpS/76cMypK4ibNab+IFd63lOOtGFH4zIdfF tuVOz8tJ6B2gRurhcESR2GGwdctZZsqrZ4DkcS78MHKGFn4h+digtEe0dKwwv225OZCT HGug== X-Forwarded-Encrypted: i=1; AJvYcCW5cd+MGdgVxUtwyg9rtil8gK0u1IJbMMA1GlcGcxGxOKQqwsxrzHbDejRVYuwZFnXygplkdE5/t42S@vger.kernel.org, AJvYcCWzFrLLfiHM4JQYZpotxKeyZd/QHPNgWZoSMNUg09OLLy8AtBHF+Q5wPWzxreBE1gwiAniz79UEZWbt@vger.kernel.org, AJvYcCXr9H+rYTcJPpUNJvtzRTeCtCZisAgu3IjV99ZJnDO6BgSNeuyHaHDPu0rYw9SPD4KoOFd8AXOkKthGChN6@vger.kernel.org X-Gm-Message-State: AOJu0YxaMKUlkQxP8mVZhELdGLdxWDgFY17wwKip6PhDayT1PvZRmj6f 3K9Zqbzr6CL+CvUQ+wHoynRoDZKA7I5MicB8goiyG7/ez3xv6hJo X-Google-Smtp-Source: AGHT+IHnq7HTC7LLEv0jNTGWSFFP+v2JZL2E6bcxQ0PJN5kxEVb+W9VP/96cHavEVQXp2EvYaMY2qQ== X-Received: by 2002:adf:a198:0:b0:374:b6f3:728d with SMTP id ffacd0b85a97d-37eb487a528mr286607f8f.46.1729207836354; Thu, 17 Oct 2024 16:30:36 -0700 (PDT) Received: from vamoirid-laptop.. ([2a04:ee41:82:7577:8661:df0e:b445:43ef]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-37ecf06d3casm306939f8f.48.2024.10.17.16.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 16:30:35 -0700 (PDT) From: Vasileios Amoiridis To: jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andriy.shevchenko@linux.intel.com Cc: vassilisamir@gmail.com, ang.iglesiasg@gmail.com, ajarizzo@gmail.com, biju.das.jz@bp.renesas.com, linus.walleij@linaro.org, semen.protsenko@linaro.org, 579lpy@gmail.com, ak@it-klinger.de, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 3/4] iio: pressure: bmp280: Add data ready trigger support Date: Fri, 18 Oct 2024 01:30:21 +0200 Message-ID: <20241017233022.238250-4-vassilisamir@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017233022.238250-1-vassilisamir@gmail.com> References: <20241017233022.238250-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: quoted-printable Content-Type: text/plain; charset="utf-8" The BMP3xx and BMP5xx sensors have an interrupt pin which can be used as a trigger for when there are data ready in the sensor for pick up. This use case is used along with NORMAL_MODE in the sensor, which allows the sensor to do consecutive measurements depending on the ODR rate value. The trigger pin can be configured to be open-drain or push-pull and either rising or falling edge. No support is added yet for interrupts for FIFO, WATERMARK and out of range values. Reviewed-by: Andy Shevchenko Signed-off-by: Vasileios Amoiridis --- drivers/iio/pressure/bmp280-core.c | 197 ++++++++++++++++++++++++++++- drivers/iio/pressure/bmp280.h | 21 +++ 2 files changed, 216 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp2= 80-core.c index 70abaff08646..a941423a899a 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -42,12 +42,14 @@ #include #include #include +#include #include #include #include =20 #include #include +#include #include #include =20 @@ -1280,6 +1282,63 @@ static irqreturn_t bme280_trigger_handler(int irq, v= oid *p) return IRQ_HANDLED; } =20 +static int __bmp280_trigger_probe(struct iio_dev *indio_dev, + const struct iio_trigger_ops *trigger_ops, + int (*int_pin_config)(struct bmp280_data *data), + irq_handler_t irq_thread_handler) +{ + struct bmp280_data *data =3D iio_priv(indio_dev); + struct device *dev =3D data->dev; + u32 irq_type; + int ret, irq; + + irq =3D fwnode_irq_get(dev_fwnode(dev), 0); + if (irq < 0) + return dev_err_probe(dev, irq, "No interrupt found.\n"); + + irq_type =3D irq_get_trigger_type(irq); + switch (irq_type) { + case IRQF_TRIGGER_RISING: + data->trig_active_high =3D true; + break; + case IRQF_TRIGGER_FALLING: + data->trig_active_high =3D false; + break; + default: + return dev_err_probe(dev, -EINVAL, "Invalid interrupt type specified.\n"= ); + } + + data->trig_open_drain =3D + fwnode_property_read_bool(dev_fwnode(dev), "int-open-drain"); + + ret =3D int_pin_config(data); + if (ret) + return ret; + + data->trig =3D devm_iio_trigger_alloc(data->dev, "%s-dev%d", + indio_dev->name, + iio_device_id(indio_dev)); + if (!data->trig) + return -ENOMEM; + + data->trig->ops =3D trigger_ops; + iio_trigger_set_drvdata(data->trig, data); + + ret =3D devm_request_threaded_irq(data->dev, irq, NULL, + irq_thread_handler, IRQF_ONESHOT, + indio_dev->name, indio_dev); + if (ret) + return dev_err_probe(dev, ret, "request IRQ failed.\n"); + + ret =3D devm_iio_trigger_register(data->dev, data->trig); + if (ret) + return dev_err_probe(dev, ret, "iio trigger register failed.\n"); + + indio_dev->trig =3D iio_trigger_get(data->trig); + + return 0; +} + static const u8 bme280_chip_ids[] =3D { BME280_CHIP_ID }; static const int bme280_humid_coeffs[] =3D { 1000, 1024 }; =20 @@ -1774,6 +1833,67 @@ static int bmp380_chip_config(struct bmp280_data *da= ta) return ret; } =20 +static int bmp380_data_rdy_trigger_set_state(struct iio_trigger *trig, + bool state) +{ + struct bmp280_data *data =3D iio_trigger_get_drvdata(trig); + int ret; + + guard(mutex)(&data->lock); + + ret =3D regmap_update_bits(data->regmap, BMP380_REG_INT_CONTROL, + BMP380_INT_CTRL_DRDY_EN, + FIELD_PREP(BMP380_INT_CTRL_DRDY_EN, !!state)); + if (ret) + dev_err(data->dev, + "Could not %s interrupt.\n", str_enable_disable(state)); + return ret; +} + +static const struct iio_trigger_ops bmp380_trigger_ops =3D { + .set_trigger_state =3D &bmp380_data_rdy_trigger_set_state, +}; + +static int bmp380_int_pin_config(struct bmp280_data *data) +{ + int pin_drive_cfg =3D FIELD_PREP(BMP380_INT_CTRL_OPEN_DRAIN, + data->trig_open_drain); + int pin_level_cfg =3D FIELD_PREP(BMP380_INT_CTRL_LEVEL, + data->trig_active_high); + int ret, int_pin_cfg =3D pin_drive_cfg | pin_level_cfg; + + ret =3D regmap_update_bits(data->regmap, BMP380_REG_INT_CONTROL, + BMP380_INT_CTRL_SETTINGS_MASK, int_pin_cfg); + if (ret) + dev_err(data->dev, "Could not set interrupt settings.\n"); + + return ret; +} + +static irqreturn_t bmp380_irq_thread_handler(int irq, void *p) +{ + struct iio_dev *indio_dev =3D p; + struct bmp280_data *data =3D iio_priv(indio_dev); + unsigned int int_ctrl; + int ret; + + ret =3D regmap_read(data->regmap, BMP380_REG_INT_STATUS, &int_ctrl); + if (ret) + return IRQ_NONE; + + if (FIELD_GET(BMP380_INT_STATUS_DRDY, int_ctrl)) + iio_trigger_poll_nested(data->trig); + + return IRQ_HANDLED; +} + +static int bmp380_trigger_probe(struct iio_dev *indio_dev) +{ + return __bmp280_trigger_probe(indio_dev, &bmp380_trigger_ops, + bmp380_int_pin_config, + bmp380_irq_thread_handler); +} + static irqreturn_t bmp380_trigger_handler(int irq, void *p) { struct iio_poll_func *pf =3D p; @@ -1871,6 +1991,7 @@ const struct bmp280_chip_info bmp380_chip_info =3D { .wait_conv =3D bmp380_wait_conv, .preinit =3D bmp380_preinit, =20 + .trigger_probe =3D bmp380_trigger_probe, .trigger_handler =3D bmp380_trigger_handler, }; EXPORT_SYMBOL_NS(bmp380_chip_info, IIO_BMP280); @@ -2413,6 +2534,74 @@ static int bmp580_chip_config(struct bmp280_data *da= ta) return 0; } =20 +static int bmp580_data_rdy_trigger_set_state(struct iio_trigger *trig, + bool state) +{ + struct bmp280_data *data =3D iio_trigger_get_drvdata(trig); + int ret; + + guard(mutex)(&data->lock); + + ret =3D regmap_update_bits(data->regmap, BMP580_REG_INT_CONFIG, + BMP580_INT_CONFIG_INT_EN, + FIELD_PREP(BMP580_INT_CONFIG_INT_EN, !!state)); + if (ret) + dev_err(data->dev, + "Could not %s interrupt.\n", str_enable_disable(state)); + return ret; +} + +static const struct iio_trigger_ops bmp580_trigger_ops =3D { + .set_trigger_state =3D &bmp580_data_rdy_trigger_set_state, +}; + +static int bmp580_int_pin_config(struct bmp280_data *data) +{ + int pin_drive_cfg =3D FIELD_PREP(BMP580_INT_CONFIG_OPEN_DRAIN, + data->trig_open_drain); + int pin_level_cfg =3D FIELD_PREP(BMP580_INT_CONFIG_LEVEL, + data->trig_active_high); + int ret, int_pin_cfg =3D pin_drive_cfg | pin_level_cfg; + + ret =3D regmap_update_bits(data->regmap, BMP580_REG_INT_CONFIG, + BMP580_INT_CONFIG_MASK, int_pin_cfg); + if (ret) { + dev_err(data->dev, "Could not set interrupt settings.\n"); + return ret; + } + + ret =3D regmap_set_bits(data->regmap, BMP580_REG_INT_SOURCE, + BMP580_INT_SOURCE_DRDY); + if (ret) + dev_err(data->dev, "Could not set interrupt source.\n"); + + return ret; +} + +static irqreturn_t bmp580_irq_thread_handler(int irq, void *p) +{ + struct iio_dev *indio_dev =3D p; + struct bmp280_data *data =3D iio_priv(indio_dev); + unsigned int int_ctrl; + int ret; + + ret =3D regmap_read(data->regmap, BMP580_REG_INT_STATUS, &int_ctrl); + if (ret) + return IRQ_NONE; + + if (FIELD_GET(BMP580_INT_STATUS_DRDY_MASK, int_ctrl)) + iio_trigger_poll_nested(data->trig); + + return IRQ_HANDLED; +} + +static int bmp580_trigger_probe(struct iio_dev *indio_dev) +{ + return __bmp280_trigger_probe(indio_dev, &bmp580_trigger_ops, + bmp580_int_pin_config, + bmp580_irq_thread_handler); +} + static irqreturn_t bmp580_trigger_handler(int irq, void *p) { struct iio_poll_func *pf =3D p; @@ -2493,6 +2682,7 @@ const struct bmp280_chip_info bmp580_chip_info =3D { .wait_conv =3D bmp580_wait_conv, .preinit =3D bmp580_preinit, =20 + .trigger_probe =3D bmp580_trigger_probe, .trigger_handler =3D bmp580_trigger_handler, }; EXPORT_SYMBOL_NS(bmp580_chip_info, IIO_BMP280); @@ -3041,8 +3231,11 @@ int bmp280_common_probe(struct device *dev, * however as it happens, the BMP085 shares the chip ID of BMP180 * so we look for an IRQ if we have that. */ - if (irq > 0 && (chip_id =3D=3D BMP180_CHIP_ID)) { - ret =3D bmp085_fetch_eoc_irq(dev, name, irq, data); + if (irq > 0) { + if (chip_id =3D=3D BMP180_CHIP_ID) + ret =3D bmp085_fetch_eoc_irq(dev, name, irq, data); + if (data->chip_info->trigger_probe) + ret =3D data->chip_info->trigger_probe(indio_dev); if (ret) return ret; } diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index 3babf90ce73c..12f6e90b3728 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -55,8 +55,17 @@ #define BMP580_CMD_NVM_WRITE_SEQ_1 0xA0 #define BMP580_CMD_SOFT_RESET 0xB6 =20 +#define BMP580_INT_STATUS_DRDY_MASK BIT(0) #define BMP580_INT_STATUS_POR_MASK BIT(4) =20 +#define BMP580_INT_SOURCE_DRDY BIT(0) + +#define BMP580_INT_CONFIG_MASK GENMASK(3, 0) +#define BMP580_INT_CONFIG_LATCH BIT(0) +#define BMP580_INT_CONFIG_LEVEL BIT(1) +#define BMP580_INT_CONFIG_OPEN_DRAIN BIT(2) +#define BMP580_INT_CONFIG_INT_EN BIT(3) + #define BMP580_STATUS_CORE_RDY_MASK BIT(0) #define BMP580_STATUS_NVM_RDY_MASK BIT(1) #define BMP580_STATUS_NVM_ERR_MASK BIT(2) @@ -175,6 +184,14 @@ #define BMP380_TEMP_MEAS_OFFSET 163 #define BMP380_PRESS_MEAS_OFFSET 392 =20 +#define BMP380_INT_STATUS_DRDY BIT(3) + +#define BMP380_INT_CTRL_SETTINGS_MASK GENMASK(2, 0) +#define BMP380_INT_CTRL_OPEN_DRAIN BIT(0) +#define BMP380_INT_CTRL_LEVEL BIT(1) +#define BMP380_INT_CTRL_LATCH BIT(2) +#define BMP380_INT_CTRL_DRDY_EN BIT(6) + #define BMP380_MIN_TEMP -4000 #define BMP380_MAX_TEMP 8500 #define BMP380_MIN_PRES 3000000 @@ -407,6 +424,9 @@ struct bmp280_data { struct regmap *regmap; struct completion done; bool use_eoc; + bool trig_open_drain; + bool trig_active_high; + struct iio_trigger *trig; const struct bmp280_chip_info *chip_info; union { struct bmp180_calib bmp180; @@ -509,6 +529,7 @@ struct bmp280_chip_info { int (*set_mode)(struct bmp280_data *data, enum bmp280_op_mode mode); int (*wait_conv)(struct bmp280_data *data); =20 + int (*trigger_probe)(struct iio_dev *indio_dev); irqreturn_t (*trigger_handler)(int irq, void *p); }; =20 --=20 2.43.0 From nobody Fri Oct 18 08:47:11 2024 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 D6F9B205AD5; Thu, 17 Oct 2024 23:30:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729207842; cv=none; b=k9vkoZiqZmrnXxbqXc7cuSvdZPc9+qYEdgXEKh5G1nmN7LrimXrnTjalSBHSELBzP3Hg7AyECjMEOtMWRshWVyrkRCGdi1QlH/mEGWFGYOtUrpcKAFVcztTHZA0byCd/Nl6oub4ybGBo429L41ILNtlc/feOM3tUJHgRybuvSFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729207842; c=relaxed/simple; bh=hKiO/5RQQmD5FWUdZeySdsJxjFc5Ch+XC/c/iVI89+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OatX0q+G4qxLkqvPRc9YerfrjwwQ25aCw4mg42fn9UCdNS4TeZeVZ3b5GXdJcyY8xfTfl30uvXXoX1qWqyFSDjQk3pnmuEAwgLH+eWmZclgYezW2eDWzQ+XkYUGZ40AsQTZYNLHAFw6JN+iwjCFGYnM9nE89dofTaaaPtcD+p1I= 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=V/eAMONq; arc=none smtp.client-ip=209.85.128.41 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V/eAMONq" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4315baec681so11916065e9.2; Thu, 17 Oct 2024 16:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729207839; x=1729812639; 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=4DQoEPUhCbdcxhsElGFNYL61baylOpGR0QKhkPlDj1w=; b=V/eAMONqoGZX6WURL5BIBHzgFVmxB7b7o8NS5lKoWSa2aRxAZ2t3Z+ZTcXlRTEr6V6 AfK9EfhuhYO4W8rzMcwAqE1ygvZdp9k7tNFKGUz9RSWd/+RV1JYlnp8AgwDIynLTUASt fSg4MitnRNZngngZx8EIqZb7FUaA3Vzo6rHqwonVJzJEjjuoeFJf5pgp0MnfwAv+efiV 7f7tdo2T/kzgYMJL9fwufdU8Y/UMohzB/DEPBIwZzNwqWyPIZU4rJ1CM7YnqvgdgudL3 T42qFJ+X2yaFLVC7AZqaEjoEdnL3+wLgQOcMe4K7fI+cfqEd4jdpIqPnnVwSr9IO4UlG d98g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729207839; x=1729812639; 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=4DQoEPUhCbdcxhsElGFNYL61baylOpGR0QKhkPlDj1w=; b=S2QIwc3jJVxYsy3aDSSvLYYmCbnYy1fE6KbYmB7Y0YeVG4wCm0FOoc1zY7BhHyQcEB p99BSk2pwXaqOwgC+2gc0xVLjNMhKa4hbBlxM/hD09yzCNgrjgsfSosjNlu7L1/3cQN6 SKd0OJdl+D9xEsMiFDlXRXhONDZ2u7zZuPVDakO8iOCNve/PsDEk8/5H3R6jwjhLZfjh 0d/1+A51iPBTipmLyjtHscJOu5N7ZoL0tMkvqL6i8AwWeMF9kByQbj20DWPQEuFA3eRT nVE0piZOlWjmqrBksBJK0ifsWT78gY6Hbrkhqyht3GcyuI7+92LiIopCwH6ZMB9PyezS Z5Ww== X-Forwarded-Encrypted: i=1; AJvYcCVTm8NI935yWA8gmiUlk1/9Tj80izakDnAR8bSrfAdHYmEgibrse6rEJ1xx+AneBwCKB+VDxaBgK25m@vger.kernel.org, AJvYcCVls1v1RIX1QLDdVTwEAS5AKo8jZvL6a4SOMmK0t+cTOLV6PiI2BGChbUxvaA9IvpWOFq3pmofrMhq0@vger.kernel.org, AJvYcCXGjV0m83mZv7+TvU4/mPBSuKXwqe1MjSXSqVahi1uEoN5R/5PPJyKasYHVHmEf1T5rYGn3RmUdyck7npIM@vger.kernel.org X-Gm-Message-State: AOJu0YzmESRHwaceK7Zakia0NlD4IfuFPlbe7OyBhklanm20xHLzvvj5 nd2tCT6zV/BhXgFx9T1jqGqH1nDrP8Jityp5I9ERjVBNfXmMoIlf X-Google-Smtp-Source: AGHT+IHkNnBRKNWorLhD9+bPoqfN1N6uj6wLi1HJ8yQMJGus+AMP/brEKSZTZXWQR26gwfV5BCjalA== X-Received: by 2002:a05:600c:1c8d:b0:431:12a8:7f1a with SMTP id 5b1f17b1804b1-4316165d3acmr2705855e9.16.1729207839008; Thu, 17 Oct 2024 16:30:39 -0700 (PDT) Received: from vamoirid-laptop.. ([2a04:ee41:82:7577:8661:df0e:b445:43ef]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-37ecf06d3casm306939f8f.48.2024.10.17.16.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 16:30:37 -0700 (PDT) From: Vasileios Amoiridis To: jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andriy.shevchenko@linux.intel.com Cc: vassilisamir@gmail.com, ang.iglesiasg@gmail.com, ajarizzo@gmail.com, biju.das.jz@bp.renesas.com, linus.walleij@linaro.org, semen.protsenko@linaro.org, 579lpy@gmail.com, ak@it-klinger.de, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 4/4] iio: pressure: bmp280: Move bmp085 interrupt to new configuration Date: Fri, 18 Oct 2024 01:30:22 +0200 Message-ID: <20241017233022.238250-5-vassilisamir@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017233022.238250-1-vassilisamir@gmail.com> References: <20241017233022.238250-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: quoted-printable Content-Type: text/plain; charset="utf-8" This commit intends to add the old BMP085 sensor to the new IRQ interface of the driver for consistence. No functional changes intended. The BMP085 sensor is equivalent with the BMP180 with the only difference of BMP085 having an extra interrupt pin to inform about an End of Conversion. Reviewed-by: Andy Shevchenko Signed-off-by: Vasileios Amoiridis --- drivers/iio/pressure/bmp280-core.c | 63 +++++++++++++++++++++++------- drivers/iio/pressure/bmp280-i2c.c | 4 +- drivers/iio/pressure/bmp280-spi.c | 4 +- drivers/iio/pressure/bmp280.h | 1 + 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp2= 80-core.c index a941423a899a..e5ec8137961f 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -3028,13 +3028,16 @@ static irqreturn_t bmp085_eoc_irq(int irq, void *d) return IRQ_HANDLED; } =20 -static int bmp085_fetch_eoc_irq(struct device *dev, - const char *name, - int irq, - struct bmp280_data *data) +static int bmp085_trigger_probe(struct iio_dev *indio_dev) { + struct bmp280_data *data =3D iio_priv(indio_dev); + struct device *dev =3D data->dev; unsigned long irq_trig; - int ret; + int ret, irq; + + irq =3D fwnode_irq_get(dev_fwnode(dev), 0); + if (irq < 0) + return dev_err_probe(dev, irq, "No interrupt found.\n"); =20 irq_trig =3D irq_get_trigger_type(irq); if (irq_trig !=3D IRQF_TRIGGER_RISING) { @@ -3044,13 +3047,8 @@ static int bmp085_fetch_eoc_irq(struct device *dev, =20 init_completion(&data->done); =20 - ret =3D devm_request_threaded_irq(dev, - irq, - bmp085_eoc_irq, - NULL, - irq_trig, - name, - data); + ret =3D devm_request_irq(dev, irq, bmp085_eoc_irq, irq_trig, + indio_dev->name, data); if (ret) { /* Bail out without IRQ but keep the driver in place */ dev_err(dev, "unable to request DRDY IRQ\n"); @@ -3058,9 +3056,48 @@ static int bmp085_fetch_eoc_irq(struct device *dev, } =20 data->use_eoc =3D true; + return 0; } =20 +/* Identical to bmp180_chip_info + bmp085_trigger_probe */ +const struct bmp280_chip_info bmp085_chip_info =3D { + .id_reg =3D BMP280_REG_ID, + .chip_id =3D bmp180_chip_ids, + .num_chip_id =3D ARRAY_SIZE(bmp180_chip_ids), + .regmap_config =3D &bmp180_regmap_config, + .start_up_time =3D 2000, + .channels =3D bmp280_channels, + .num_channels =3D ARRAY_SIZE(bmp280_channels), + .avail_scan_masks =3D bmp280_avail_scan_masks, + + .oversampling_temp_avail =3D bmp180_oversampling_temp_avail, + .num_oversampling_temp_avail =3D + ARRAY_SIZE(bmp180_oversampling_temp_avail), + .oversampling_temp_default =3D 0, + + .oversampling_press_avail =3D bmp180_oversampling_press_avail, + .num_oversampling_press_avail =3D + ARRAY_SIZE(bmp180_oversampling_press_avail), + .oversampling_press_default =3D BMP180_MEAS_PRESS_8X, + + .temp_coeffs =3D bmp180_temp_coeffs, + .temp_coeffs_type =3D IIO_VAL_FRACTIONAL, + .press_coeffs =3D bmp180_press_coeffs, + .press_coeffs_type =3D IIO_VAL_FRACTIONAL, + + .chip_config =3D bmp180_chip_config, + .read_temp =3D bmp180_read_temp, + .read_press =3D bmp180_read_press, + .read_calib =3D bmp180_read_calib, + .set_mode =3D bmp180_set_mode, + .wait_conv =3D bmp180_wait_conv, + + .trigger_probe =3D bmp085_trigger_probe, + .trigger_handler =3D bmp180_trigger_handler, +}; +EXPORT_SYMBOL_NS(bmp085_chip_info, IIO_BMP280); + static int bmp280_buffer_preenable(struct iio_dev *indio_dev) { struct bmp280_data *data =3D iio_priv(indio_dev); @@ -3232,8 +3269,6 @@ int bmp280_common_probe(struct device *dev, * so we look for an IRQ if we have that. */ if (irq > 0) { - if (chip_id =3D=3D BMP180_CHIP_ID) - ret =3D bmp085_fetch_eoc_irq(dev, name, irq, data); if (data->chip_info->trigger_probe) ret =3D data->chip_info->trigger_probe(indio_dev); if (ret) diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp28= 0-i2c.c index 5c3a63b4327c..2f7b25984c7b 100644 --- a/drivers/iio/pressure/bmp280-i2c.c +++ b/drivers/iio/pressure/bmp280-i2c.c @@ -27,7 +27,7 @@ static int bmp280_i2c_probe(struct i2c_client *client) } =20 static const struct of_device_id bmp280_of_i2c_match[] =3D { - { .compatible =3D "bosch,bmp085", .data =3D &bmp180_chip_info }, + { .compatible =3D "bosch,bmp085", .data =3D &bmp085_chip_info }, { .compatible =3D "bosch,bmp180", .data =3D &bmp180_chip_info }, { .compatible =3D "bosch,bmp280", .data =3D &bmp280_chip_info }, { .compatible =3D "bosch,bme280", .data =3D &bme280_chip_info }, @@ -38,7 +38,7 @@ static const struct of_device_id bmp280_of_i2c_match[] = =3D { MODULE_DEVICE_TABLE(of, bmp280_of_i2c_match); =20 static const struct i2c_device_id bmp280_i2c_id[] =3D { - {"bmp085", (kernel_ulong_t)&bmp180_chip_info }, + {"bmp085", (kernel_ulong_t)&bmp085_chip_info }, {"bmp180", (kernel_ulong_t)&bmp180_chip_info }, {"bmp280", (kernel_ulong_t)&bmp280_chip_info }, {"bme280", (kernel_ulong_t)&bme280_chip_info }, diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp28= 0-spi.c index d18549d9bb64..49aa8c2cd85b 100644 --- a/drivers/iio/pressure/bmp280-spi.c +++ b/drivers/iio/pressure/bmp280-spi.c @@ -114,7 +114,7 @@ static int bmp280_spi_probe(struct spi_device *spi) } =20 static const struct of_device_id bmp280_of_spi_match[] =3D { - { .compatible =3D "bosch,bmp085", .data =3D &bmp180_chip_info }, + { .compatible =3D "bosch,bmp085", .data =3D &bmp085_chip_info }, { .compatible =3D "bosch,bmp180", .data =3D &bmp180_chip_info }, { .compatible =3D "bosch,bmp181", .data =3D &bmp180_chip_info }, { .compatible =3D "bosch,bmp280", .data =3D &bmp280_chip_info }, @@ -126,7 +126,7 @@ static const struct of_device_id bmp280_of_spi_match[] = =3D { MODULE_DEVICE_TABLE(of, bmp280_of_spi_match); =20 static const struct spi_device_id bmp280_spi_id[] =3D { - { "bmp085", (kernel_ulong_t)&bmp180_chip_info }, + { "bmp085", (kernel_ulong_t)&bmp085_chip_info }, { "bmp180", (kernel_ulong_t)&bmp180_chip_info }, { "bmp181", (kernel_ulong_t)&bmp180_chip_info }, { "bmp280", (kernel_ulong_t)&bmp280_chip_info }, diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index 12f6e90b3728..2df1175b6b85 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -534,6 +534,7 @@ struct bmp280_chip_info { }; =20 /* Chip infos for each variant */ +extern const struct bmp280_chip_info bmp085_chip_info; extern const struct bmp280_chip_info bmp180_chip_info; extern const struct bmp280_chip_info bmp280_chip_info; extern const struct bmp280_chip_info bme280_chip_info; --=20 2.43.0