bmp280.h (4028B)
1/* SPDX-License-Identifier: GPL-2.0 */ 2#include <linux/bitops.h> 3#include <linux/device.h> 4#include <linux/regmap.h> 5 6/* BMP280 specific registers */ 7#define BMP280_REG_HUMIDITY_LSB 0xFE 8#define BMP280_REG_HUMIDITY_MSB 0xFD 9#define BMP280_REG_TEMP_XLSB 0xFC 10#define BMP280_REG_TEMP_LSB 0xFB 11#define BMP280_REG_TEMP_MSB 0xFA 12#define BMP280_REG_PRESS_XLSB 0xF9 13#define BMP280_REG_PRESS_LSB 0xF8 14#define BMP280_REG_PRESS_MSB 0xF7 15 16#define BMP280_REG_CONFIG 0xF5 17#define BMP280_REG_CTRL_MEAS 0xF4 18#define BMP280_REG_STATUS 0xF3 19#define BMP280_REG_CTRL_HUMIDITY 0xF2 20 21/* Due to non linear mapping, and data sizes we can't do a bulk read */ 22#define BMP280_REG_COMP_H1 0xA1 23#define BMP280_REG_COMP_H2 0xE1 24#define BMP280_REG_COMP_H3 0xE3 25#define BMP280_REG_COMP_H4 0xE4 26#define BMP280_REG_COMP_H5 0xE5 27#define BMP280_REG_COMP_H6 0xE7 28 29#define BMP280_REG_COMP_TEMP_START 0x88 30#define BMP280_COMP_TEMP_REG_COUNT 6 31 32#define BMP280_REG_COMP_PRESS_START 0x8E 33#define BMP280_COMP_PRESS_REG_COUNT 18 34 35#define BMP280_FILTER_MASK (BIT(4) | BIT(3) | BIT(2)) 36#define BMP280_FILTER_OFF 0 37#define BMP280_FILTER_2X BIT(2) 38#define BMP280_FILTER_4X BIT(3) 39#define BMP280_FILTER_8X (BIT(3) | BIT(2)) 40#define BMP280_FILTER_16X BIT(4) 41 42#define BMP280_OSRS_HUMIDITY_MASK (BIT(2) | BIT(1) | BIT(0)) 43#define BMP280_OSRS_HUMIDITIY_X(osrs_h) ((osrs_h) << 0) 44#define BMP280_OSRS_HUMIDITY_SKIP 0 45#define BMP280_OSRS_HUMIDITY_1X BMP280_OSRS_HUMIDITIY_X(1) 46#define BMP280_OSRS_HUMIDITY_2X BMP280_OSRS_HUMIDITIY_X(2) 47#define BMP280_OSRS_HUMIDITY_4X BMP280_OSRS_HUMIDITIY_X(3) 48#define BMP280_OSRS_HUMIDITY_8X BMP280_OSRS_HUMIDITIY_X(4) 49#define BMP280_OSRS_HUMIDITY_16X BMP280_OSRS_HUMIDITIY_X(5) 50 51#define BMP280_OSRS_TEMP_MASK (BIT(7) | BIT(6) | BIT(5)) 52#define BMP280_OSRS_TEMP_SKIP 0 53#define BMP280_OSRS_TEMP_X(osrs_t) ((osrs_t) << 5) 54#define BMP280_OSRS_TEMP_1X BMP280_OSRS_TEMP_X(1) 55#define BMP280_OSRS_TEMP_2X BMP280_OSRS_TEMP_X(2) 56#define BMP280_OSRS_TEMP_4X BMP280_OSRS_TEMP_X(3) 57#define BMP280_OSRS_TEMP_8X BMP280_OSRS_TEMP_X(4) 58#define BMP280_OSRS_TEMP_16X BMP280_OSRS_TEMP_X(5) 59 60#define BMP280_OSRS_PRESS_MASK (BIT(4) | BIT(3) | BIT(2)) 61#define BMP280_OSRS_PRESS_SKIP 0 62#define BMP280_OSRS_PRESS_X(osrs_p) ((osrs_p) << 2) 63#define BMP280_OSRS_PRESS_1X BMP280_OSRS_PRESS_X(1) 64#define BMP280_OSRS_PRESS_2X BMP280_OSRS_PRESS_X(2) 65#define BMP280_OSRS_PRESS_4X BMP280_OSRS_PRESS_X(3) 66#define BMP280_OSRS_PRESS_8X BMP280_OSRS_PRESS_X(4) 67#define BMP280_OSRS_PRESS_16X BMP280_OSRS_PRESS_X(5) 68 69#define BMP280_MODE_MASK (BIT(1) | BIT(0)) 70#define BMP280_MODE_SLEEP 0 71#define BMP280_MODE_FORCED BIT(0) 72#define BMP280_MODE_NORMAL (BIT(1) | BIT(0)) 73 74/* BMP180 specific registers */ 75#define BMP180_REG_OUT_XLSB 0xF8 76#define BMP180_REG_OUT_LSB 0xF7 77#define BMP180_REG_OUT_MSB 0xF6 78 79#define BMP180_REG_CALIB_START 0xAA 80#define BMP180_REG_CALIB_COUNT 22 81 82#define BMP180_MEAS_SCO BIT(5) 83#define BMP180_MEAS_TEMP (0x0E | BMP180_MEAS_SCO) 84#define BMP180_MEAS_PRESS_X(oss) ((oss) << 6 | 0x14 | BMP180_MEAS_SCO) 85#define BMP180_MEAS_PRESS_1X BMP180_MEAS_PRESS_X(0) 86#define BMP180_MEAS_PRESS_2X BMP180_MEAS_PRESS_X(1) 87#define BMP180_MEAS_PRESS_4X BMP180_MEAS_PRESS_X(2) 88#define BMP180_MEAS_PRESS_8X BMP180_MEAS_PRESS_X(3) 89 90/* BMP180 and BMP280 common registers */ 91#define BMP280_REG_CTRL_MEAS 0xF4 92#define BMP280_REG_RESET 0xE0 93#define BMP280_REG_ID 0xD0 94 95#define BMP180_CHIP_ID 0x55 96#define BMP280_CHIP_ID 0x58 97#define BME280_CHIP_ID 0x60 98#define BMP280_SOFT_RESET_VAL 0xB6 99 100/* BMP280 register skipped special values */ 101#define BMP280_TEMP_SKIPPED 0x80000 102#define BMP280_PRESS_SKIPPED 0x80000 103#define BMP280_HUMIDITY_SKIPPED 0x8000 104 105/* Regmap configurations */ 106extern const struct regmap_config bmp180_regmap_config; 107extern const struct regmap_config bmp280_regmap_config; 108 109/* Probe called from different transports */ 110int bmp280_common_probe(struct device *dev, 111 struct regmap *regmap, 112 unsigned int chip, 113 const char *name, 114 int irq); 115 116/* PM ops */ 117extern const struct dev_pm_ops bmp280_dev_pm_ops;