Linux 6.14-rc1
[linux.git] / drivers / iio / chemical / bme680.h
blob7d86ed8b02e6b54cdda0802fd73bdfdf1d09e43a
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef BME680_H_
3 #define BME680_H_
5 #include <linux/pm.h>
6 #include <linux/regmap.h>
8 #define BME680_REG_CHIP_ID 0xD0
9 #define BME680_CHIP_ID_VAL 0x61
10 #define BME680_REG_SOFT_RESET 0xE0
11 #define BME680_CMD_SOFTRESET 0xB6
12 #define BME680_REG_STATUS 0x73
13 #define BME680_SPI_MEM_PAGE_BIT BIT(4)
14 #define BME680_SPI_MEM_PAGE_1_VAL 1
16 #define BME680_REG_TEMP_MSB 0x22
17 #define BME680_REG_PRESS_MSB 0x1F
18 #define BME680_REG_HUMIDITY_MSB 0x25
19 #define BME680_REG_GAS_MSB 0x2A
20 #define BME680_REG_GAS_R_LSB 0x2B
21 #define BME680_GAS_STAB_BIT BIT(4)
22 #define BME680_GAS_RANGE_MASK GENMASK(3, 0)
24 #define BME680_REG_CTRL_HUMIDITY 0x72
25 #define BME680_OSRS_HUMIDITY_MASK GENMASK(2, 0)
27 #define BME680_REG_CTRL_MEAS 0x74
28 #define BME680_OSRS_TEMP_MASK GENMASK(7, 5)
29 #define BME680_OSRS_PRESS_MASK GENMASK(4, 2)
30 #define BME680_MODE_MASK GENMASK(1, 0)
32 #define BME680_REG_CONFIG 0x75
33 #define BME680_FILTER_MASK GENMASK(4, 2)
34 #define BME680_FILTER_COEFF_VAL BIT(1)
36 /* TEMP/PRESS/HUMID reading skipped */
37 #define BME680_MEAS_SKIPPED 0x8000
39 #define BME680_MAX_OVERFLOW_VAL 0x40000000
40 #define BME680_HUM_REG_SHIFT_VAL 4
41 #define BME680_BIT_H1_DATA_MASK GENMASK(3, 0)
43 #define BME680_RHRANGE_MASK GENMASK(5, 4)
44 #define BME680_REG_RES_HEAT_VAL 0x00
45 #define BME680_RSERROR_MASK GENMASK(7, 4)
46 #define BME680_REG_IDAC_HEAT_0 0x50
47 #define BME680_REG_RES_HEAT_0 0x5A
48 #define BME680_REG_GAS_WAIT_0 0x64
49 #define BME680_ADC_GAS_RES GENMASK(15, 6)
50 #define BME680_AMB_TEMP 25
52 #define BME680_REG_CTRL_GAS_1 0x71
53 #define BME680_RUN_GAS_MASK BIT(4)
54 #define BME680_NB_CONV_MASK GENMASK(3, 0)
56 #define BME680_REG_MEAS_STAT_0 0x1D
57 #define BME680_NEW_DATA_BIT BIT(7)
58 #define BME680_GAS_MEAS_BIT BIT(6)
59 #define BME680_MEAS_BIT BIT(5)
61 #define BME680_TEMP_NUM_BYTES 3
62 #define BME680_PRESS_NUM_BYTES 3
63 #define BME680_HUMID_NUM_BYTES 2
64 #define BME680_GAS_NUM_BYTES 2
66 #define BME680_MEAS_TRIM_MASK GENMASK(24, 4)
68 /* Datasheet Section 1.1, Table 1 */
69 #define BME680_STARTUP_TIME_US 2000
71 #define BME680_NUM_CHANNELS 4
72 #define BME680_NUM_BULK_READ_REGS 15
74 /* Calibration Parameters */
75 #define BME680_T2_LSB_REG 0x8A
76 #define BME680_H2_MSB_REG 0xE1
77 #define BME680_GH3_REG 0xEE
79 #define BME680_CALIB_RANGE_1_LEN 23
80 #define BME680_CALIB_RANGE_2_LEN 14
81 #define BME680_CALIB_RANGE_3_LEN 5
83 extern const struct regmap_config bme680_regmap_config;
84 extern const struct dev_pm_ops bme680_dev_pm_ops;
86 int bme680_core_probe(struct device *dev, struct regmap *regmap,
87 const char *name);
89 #endif /* BME680_H_ */