linux/drivers/iio/pressure/bmp280.h

/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/iio/iio.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>


/* BMP580 specific registers */
#define BMP580_REG_CMD
#define BMP580_REG_EFF_OSR
#define BMP580_REG_ODR_CONFIG
#define BMP580_REG_OSR_CONFIG
#define BMP580_REG_IF_CONFIG
#define BMP580_REG_REV_ID
#define BMP580_REG_CHIP_ID
/* OOR allows to configure a pressure alarm */
#define BMP580_REG_OOR_CONFIG
#define BMP580_REG_OOR_RANGE
#define BMP580_REG_OOR_THR_MSB
#define BMP580_REG_OOR_THR_LSB
/* DSP registers (IIR filters) */
#define BMP580_REG_DSP_IIR
#define BMP580_REG_DSP_CONFIG
/* NVM access registers */
#define BMP580_REG_NVM_DATA_MSB
#define BMP580_REG_NVM_DATA_LSB
#define BMP580_REG_NVM_ADDR
/* Status registers */
#define BMP580_REG_STATUS
#define BMP580_REG_INT_STATUS
#define BMP580_REG_CHIP_STATUS
/* Data registers */
#define BMP580_REG_FIFO_DATA
#define BMP580_REG_PRESS_MSB
#define BMP580_REG_PRESS_LSB
#define BMP580_REG_PRESS_XLSB
#define BMP580_REG_TEMP_MSB
#define BMP580_REG_TEMP_LSB
#define BMP580_REG_TEMP_XLSB
/* FIFO config registers */
#define BMP580_REG_FIFO_SEL
#define BMP580_REG_FIFO_COUNT
#define BMP580_REG_FIFO_CONFIG
/* Interruptions config registers */
#define BMP580_REG_INT_SOURCE
#define BMP580_REG_INT_CONFIG

#define BMP580_CMD_NOOP
#define BMP580_CMD_EXTMODE_SEQ_0
#define BMP580_CMD_EXTMODE_SEQ_1
#define BMP580_CMD_EXTMODE_SEQ_2
#define BMP580_CMD_NVM_OP_SEQ_0
#define BMP580_CMD_NVM_READ_SEQ_1
#define BMP580_CMD_NVM_WRITE_SEQ_1
#define BMP580_CMD_SOFT_RESET

#define BMP580_INT_STATUS_POR_MASK

#define BMP580_STATUS_CORE_RDY_MASK
#define BMP580_STATUS_NVM_RDY_MASK
#define BMP580_STATUS_NVM_ERR_MASK
#define BMP580_STATUS_NVM_CMD_ERR_MASK

#define BMP580_OSR_PRESS_MASK
#define BMP580_OSR_TEMP_MASK
#define BMP580_OSR_PRESS_EN
#define BMP580_EFF_OSR_PRESS_MASK
#define BMP580_EFF_OSR_TEMP_MASK
#define BMP580_EFF_OSR_VALID_ODR

#define BMP580_ODR_MASK
#define BMP580_MODE_MASK
#define BMP580_MODE_SLEEP
#define BMP580_MODE_NORMAL
#define BMP580_MODE_FORCED
#define BMP580_MODE_CONTINOUS
#define BMP580_ODR_DEEPSLEEP_DIS

#define BMP580_DSP_COMP_MASK
#define BMP580_DSP_COMP_DIS
#define BMP580_DSP_TEMP_COMP_EN
/*
 * In section 7.27 of datasheet, modes 2 and 3 are technically the same.
 * Pressure compensation means also enabling temperature compensation
 */
#define BMP580_DSP_PRESS_COMP_EN
#define BMP580_DSP_PRESS_TEMP_COMP_EN
#define BMP580_DSP_IIR_FORCED_FLUSH
#define BMP580_DSP_SHDW_IIR_TEMP_EN
#define BMP580_DSP_FIFO_IIR_TEMP_EN
#define BMP580_DSP_SHDW_IIR_PRESS_EN
#define BMP580_DSP_FIFO_IIR_PRESS_EN
#define BMP580_DSP_OOR_IIR_PRESS_EN

#define BMP580_DSP_IIR_PRESS_MASK
#define BMP580_DSP_IIR_TEMP_MASK
#define BMP580_FILTER_OFF
#define BMP580_FILTER_1X
#define BMP580_FILTER_3X
#define BMP580_FILTER_7X
#define BMP580_FILTER_15X
#define BMP580_FILTER_31X
#define BMP580_FILTER_63X
#define BMP580_FILTER_127X

#define BMP580_NVM_ROW_ADDR_MASK
#define BMP580_NVM_PROG_EN

#define BMP580_TEMP_SKIPPED
#define BMP580_PRESS_SKIPPED

/* BMP380 specific registers */
#define BMP380_REG_CMD
#define BMP380_REG_CONFIG
#define BMP380_REG_ODR
#define BMP380_REG_OSR
#define BMP380_REG_POWER_CONTROL
#define BMP380_REG_IF_CONFIG
#define BMP380_REG_INT_CONTROL
#define BMP380_REG_INT_STATUS
#define BMP380_REG_EVENT
#define BMP380_REG_STATUS
#define BMP380_REG_ERROR
#define BMP380_REG_ID

#define BMP380_REG_FIFO_CONFIG_1
#define BMP380_REG_FIFO_CONFIG_2
#define BMP380_REG_FIFO_WATERMARK_MSB
#define BMP380_REG_FIFO_WATERMARK_LSB
#define BMP380_REG_FIFO_DATA
#define BMP380_REG_FIFO_LENGTH_MSB
#define BMP380_REG_FIFO_LENGTH_LSB

#define BMP380_REG_SENSOR_TIME_MSB
#define BMP380_REG_SENSOR_TIME_LSB
#define BMP380_REG_SENSOR_TIME_XLSB

#define BMP380_REG_TEMP_MSB
#define BMP380_REG_TEMP_LSB
#define BMP380_REG_TEMP_XLSB

#define BMP380_REG_PRESS_MSB
#define BMP380_REG_PRESS_LSB
#define BMP380_REG_PRESS_XLSB

#define BMP380_REG_CALIB_TEMP_START
#define BMP380_CALIB_REG_COUNT

#define BMP380_FILTER_MASK
#define BMP380_FILTER_OFF
#define BMP380_FILTER_1X
#define BMP380_FILTER_3X
#define BMP380_FILTER_7X
#define BMP380_FILTER_15X
#define BMP380_FILTER_31X
#define BMP380_FILTER_63X
#define BMP380_FILTER_127X

#define BMP380_OSRS_TEMP_MASK
#define BMP380_OSRS_PRESS_MASK

#define BMP380_ODRS_MASK

#define BMP380_CTRL_SENSORS_MASK
#define BMP380_CTRL_SENSORS_PRESS_EN
#define BMP380_CTRL_SENSORS_TEMP_EN
#define BMP380_MODE_MASK
#define BMP380_MODE_SLEEP
#define BMP380_MODE_FORCED
#define BMP380_MODE_NORMAL

#define BMP380_MIN_TEMP
#define BMP380_MAX_TEMP
#define BMP380_MIN_PRES
#define BMP380_MAX_PRES

#define BMP380_CMD_NOOP
#define BMP380_CMD_EXTMODE_EN_MID
#define BMP380_CMD_FIFO_FLUSH
#define BMP380_CMD_SOFT_RESET

#define BMP380_STATUS_CMD_RDY_MASK
#define BMP380_STATUS_DRDY_PRESS_MASK
#define BMP380_STATUS_DRDY_TEMP_MASK

#define BMP380_ERR_FATAL_MASK
#define BMP380_ERR_CMD_MASK
#define BMP380_ERR_CONF_MASK

#define BMP380_TEMP_SKIPPED
#define BMP380_PRESS_SKIPPED

/* BMP280 specific registers */
#define BMP280_REG_TEMP_XLSB
#define BMP280_REG_TEMP_LSB
#define BMP280_REG_TEMP_MSB
#define BMP280_REG_PRESS_XLSB
#define BMP280_REG_PRESS_LSB
#define BMP280_REG_PRESS_MSB

/* Helper mask to truncate excess 4 bits on pressure and temp readings */
#define BMP280_MEAS_TRIM_MASK

#define BMP280_REG_CONFIG
#define BMP280_REG_CTRL_MEAS
#define BMP280_REG_STATUS

#define BMP280_REG_COMP_TEMP_START
#define BMP280_COMP_TEMP_REG_COUNT

#define BMP280_REG_COMP_PRESS_START
#define BMP280_COMP_PRESS_REG_COUNT

#define BMP280_CONTIGUOUS_CALIB_REGS

#define BMP280_FILTER_MASK
#define BMP280_FILTER_OFF
#define BMP280_FILTER_2X
#define BMP280_FILTER_4X
#define BMP280_FILTER_8X
#define BMP280_FILTER_16X

#define BMP280_OSRS_TEMP_MASK
#define BMP280_OSRS_TEMP_SKIP
#define BMP280_OSRS_TEMP_1X
#define BMP280_OSRS_TEMP_2X
#define BMP280_OSRS_TEMP_4X
#define BMP280_OSRS_TEMP_8X
#define BMP280_OSRS_TEMP_16X

#define BMP280_OSRS_PRESS_MASK
#define BMP280_OSRS_PRESS_SKIP
#define BMP280_OSRS_PRESS_1X
#define BMP280_OSRS_PRESS_2X
#define BMP280_OSRS_PRESS_4X
#define BMP280_OSRS_PRESS_8X
#define BMP280_OSRS_PRESS_16X

#define BMP280_MODE_MASK
#define BMP280_MODE_SLEEP
#define BMP280_MODE_FORCED
#define BMP280_MODE_NORMAL

/* BME280 specific registers */
#define BME280_REG_HUMIDITY_LSB
#define BME280_REG_HUMIDITY_MSB

#define BME280_REG_CTRL_HUMIDITY

/* Due to non linear mapping, and data sizes we can't do a bulk read */
#define BME280_REG_COMP_H1
#define BME280_REG_COMP_H2
#define BME280_REG_COMP_H3
#define BME280_REG_COMP_H4
#define BME280_REG_COMP_H5
#define BME280_REG_COMP_H6

#define BME280_COMP_H5_MASK

#define BME280_OSRS_HUMIDITY_MASK
#define BME280_OSRS_HUMIDITY_SKIP
#define BME280_OSRS_HUMIDITY_1X
#define BME280_OSRS_HUMIDITY_2X
#define BME280_OSRS_HUMIDITY_4X
#define BME280_OSRS_HUMIDITY_8X
#define BME280_OSRS_HUMIDITY_16X

/* BMP180 specific registers */
#define BMP180_REG_OUT_XLSB
#define BMP180_REG_OUT_LSB
#define BMP180_REG_OUT_MSB

#define BMP180_REG_CALIB_START
#define BMP180_REG_CALIB_COUNT

#define BMP180_MEAS_CTRL_MASK
#define BMP180_MEAS_TEMP
#define BMP180_MEAS_PRESS
#define BMP180_MEAS_SCO
#define BMP180_OSRS_PRESS_MASK
#define BMP180_MEAS_PRESS_1X
#define BMP180_MEAS_PRESS_2X
#define BMP180_MEAS_PRESS_4X
#define BMP180_MEAS_PRESS_8X

/* BMP180 and BMP280 common registers */
#define BMP280_REG_CTRL_MEAS
#define BMP280_REG_RESET
#define BMP280_REG_ID

#define BMP380_CHIP_ID
#define BMP580_CHIP_ID
#define BMP580_CHIP_ID_ALT
#define BMP180_CHIP_ID
#define BMP280_CHIP_ID
#define BMP390_CHIP_ID
#define BME280_CHIP_ID
#define BMP280_SOFT_RESET_VAL

/* BMP280 register skipped special values */
#define BMP280_TEMP_SKIPPED
#define BMP280_PRESS_SKIPPED
#define BMP280_HUMIDITY_SKIPPED

/* Core exported structs */

static const char *const bmp280_supply_names[] =;

#define BMP280_NUM_SUPPLIES

struct bmp180_calib {};

/* See datasheet Section 4.2.2. */
struct bmp280_calib {};

/* See datasheet Section 3.11.1. */
struct bmp380_calib {};

struct bmp280_data {};

struct bmp280_chip_info {};

/* Chip infos for each variant */
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;
extern const struct bmp280_chip_info bmp380_chip_info;
extern const struct bmp280_chip_info bmp580_chip_info;

/* Regmap configurations */
extern const struct regmap_config bmp180_regmap_config;
extern const struct regmap_config bmp280_regmap_config;
extern const struct regmap_config bmp380_regmap_config;
extern const struct regmap_config bmp580_regmap_config;

/* Probe called from different transports */
int bmp280_common_probe(struct device *dev,
			struct regmap *regmap,
			const struct bmp280_chip_info *chip_info,
			const char *name,
			int irq);

/* PM ops */
extern const struct dev_pm_ops bmp280_dev_pm_ops;