Commit 80cd23f4 authored by Vasileios Amoiridis's avatar Vasileios Amoiridis Committed by Jonathan Cameron

iio: pressure: bmp280: Add triggered buffer support

BMP2xx, BME280, BMP3xx, and BMP5xx use continuous buffers for their
temperature, pressure and humidity readings. This facilitates the
use of burst/bulk reads in order to acquire data faster. The
approach is different from the one used in oneshot captures.

BMP085 & BMP1xx devices use a completely different measurement
process that is well defined and is used in their buffer_handler().
Suggested-by: default avatarAngel Iglesias <ang.iglesiasg@gmail.com>
Signed-off-by: default avatarVasileios Amoiridis <vassilisamir@gmail.com>
Link: https://lore.kernel.org/r/20240512230524.53990-6-vassilisamir@gmail.com
Link: https://patch.msgid.link/20240628171726.124852-4-vassilisamir@gmail.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 479e67ac
......@@ -31,6 +31,8 @@ config BMP280
select REGMAP
select BMP280_I2C if (I2C)
select BMP280_SPI if (SPI_MASTER)
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Bosch Sensortec BMP180, BMP280, BMP380
and BMP580 pressure and temperature sensors. Also supports the BME280 with
......
This diff is collapsed.
......@@ -40,14 +40,10 @@ static int bmp380_regmap_spi_read(void *context, const void *reg,
size_t reg_size, void *val, size_t val_size)
{
struct spi_device *spi = to_spi_device(context);
u8 rx_buf[4];
u8 rx_buf[BME280_BURST_READ_BYTES + 1];
ssize_t status;
/*
* Maximum number of consecutive bytes read for a temperature or
* pressure measurement is 3.
*/
if (val_size > 3)
if (val_size > BME280_BURST_READ_BYTES)
return -EINVAL;
/*
......
......@@ -304,6 +304,16 @@
#define BMP280_PRESS_SKIPPED 0x80000
#define BMP280_HUMIDITY_SKIPPED 0x8000
/* Number of bytes for each value */
#define BMP280_NUM_PRESS_BYTES 3
#define BMP280_NUM_TEMP_BYTES 3
#define BME280_NUM_HUMIDITY_BYTES 2
#define BMP280_BURST_READ_BYTES (BMP280_NUM_PRESS_BYTES + \
BMP280_NUM_TEMP_BYTES)
#define BME280_BURST_READ_BYTES (BMP280_NUM_PRESS_BYTES + \
BMP280_NUM_TEMP_BYTES + \
BME280_NUM_HUMIDITY_BYTES)
/* Core exported structs */
static const char *const bmp280_supply_names[] = {
......@@ -397,13 +407,19 @@ struct bmp280_data {
*/
int sampling_freq;
/*
* Data to push to userspace triggered buffer. Up to 3 channels and
* s64 timestamp, aligned.
*/
s32 sensor_data[6] __aligned(8);
/*
* DMA (thus cache coherency maintenance) may require the
* transfer buffers to live in their own cache lines.
*/
union {
/* Sensor data buffer */
u8 buf[3];
u8 buf[BME280_BURST_READ_BYTES];
/* Calibration data buffers */
__le16 bmp280_cal_buf[BMP280_CONTIGUOUS_CALIB_REGS / 2];
__be16 bmp180_cal_buf[BMP180_REG_CALIB_COUNT / 2];
......@@ -425,6 +441,7 @@ struct bmp280_chip_info {
const struct iio_chan_spec *channels;
int num_channels;
unsigned int start_up_time;
const unsigned long *avail_scan_masks;
const int *oversampling_temp_avail;
int num_oversampling_temp_avail;
......@@ -459,6 +476,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);
irqreturn_t (*trigger_handler)(int irq, void *p);
};
/* Chip infos for each variant */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment