162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef BME680_H_
362306a36Sopenharmony_ci#define BME680_H_
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#define BME680_REG_CHIP_ID			0xD0
662306a36Sopenharmony_ci#define   BME680_CHIP_ID_VAL			0x61
762306a36Sopenharmony_ci#define BME680_REG_SOFT_RESET			0xE0
862306a36Sopenharmony_ci#define   BME680_CMD_SOFTRESET			0xB6
962306a36Sopenharmony_ci#define BME680_REG_STATUS			0x73
1062306a36Sopenharmony_ci#define   BME680_SPI_MEM_PAGE_BIT		BIT(4)
1162306a36Sopenharmony_ci#define     BME680_SPI_MEM_PAGE_1_VAL		1
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define BME680_REG_TEMP_MSB			0x22
1462306a36Sopenharmony_ci#define BME680_REG_PRESS_MSB			0x1F
1562306a36Sopenharmony_ci#define BM6880_REG_HUMIDITY_MSB			0x25
1662306a36Sopenharmony_ci#define BME680_REG_GAS_MSB			0x2A
1762306a36Sopenharmony_ci#define BME680_REG_GAS_R_LSB			0x2B
1862306a36Sopenharmony_ci#define   BME680_GAS_STAB_BIT			BIT(4)
1962306a36Sopenharmony_ci#define   BME680_GAS_RANGE_MASK			GENMASK(3, 0)
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define BME680_REG_CTRL_HUMIDITY		0x72
2262306a36Sopenharmony_ci#define   BME680_OSRS_HUMIDITY_MASK		GENMASK(2, 0)
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define BME680_REG_CTRL_MEAS			0x74
2562306a36Sopenharmony_ci#define   BME680_OSRS_TEMP_MASK			GENMASK(7, 5)
2662306a36Sopenharmony_ci#define   BME680_OSRS_PRESS_MASK		GENMASK(4, 2)
2762306a36Sopenharmony_ci#define   BME680_MODE_MASK			GENMASK(1, 0)
2862306a36Sopenharmony_ci#define     BME680_MODE_FORCED			1
2962306a36Sopenharmony_ci#define     BME680_MODE_SLEEP			0
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define BME680_REG_CONFIG			0x75
3262306a36Sopenharmony_ci#define   BME680_FILTER_MASK			GENMASK(4, 2)
3362306a36Sopenharmony_ci#define     BME680_FILTER_COEFF_VAL		BIT(1)
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/* TEMP/PRESS/HUMID reading skipped */
3662306a36Sopenharmony_ci#define BME680_MEAS_SKIPPED			0x8000
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#define BME680_MAX_OVERFLOW_VAL			0x40000000
3962306a36Sopenharmony_ci#define BME680_HUM_REG_SHIFT_VAL		4
4062306a36Sopenharmony_ci#define BME680_BIT_H1_DATA_MASK			GENMASK(3, 0)
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define BME680_REG_RES_HEAT_RANGE		0x02
4362306a36Sopenharmony_ci#define   BME680_RHRANGE_MASK			GENMASK(5, 4)
4462306a36Sopenharmony_ci#define BME680_REG_RES_HEAT_VAL			0x00
4562306a36Sopenharmony_ci#define BME680_REG_RANGE_SW_ERR			0x04
4662306a36Sopenharmony_ci#define   BME680_RSERROR_MASK			GENMASK(7, 4)
4762306a36Sopenharmony_ci#define BME680_REG_RES_HEAT_0			0x5A
4862306a36Sopenharmony_ci#define BME680_REG_GAS_WAIT_0			0x64
4962306a36Sopenharmony_ci#define BME680_ADC_GAS_RES_SHIFT		6
5062306a36Sopenharmony_ci#define BME680_AMB_TEMP				25
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define BME680_REG_CTRL_GAS_1			0x71
5362306a36Sopenharmony_ci#define   BME680_RUN_GAS_MASK			BIT(4)
5462306a36Sopenharmony_ci#define   BME680_NB_CONV_MASK			GENMASK(3, 0)
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci#define BME680_REG_MEAS_STAT_0			0x1D
5762306a36Sopenharmony_ci#define   BME680_GAS_MEAS_BIT			BIT(6)
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/* Calibration Parameters */
6062306a36Sopenharmony_ci#define BME680_T2_LSB_REG	0x8A
6162306a36Sopenharmony_ci#define BME680_T3_REG		0x8C
6262306a36Sopenharmony_ci#define BME680_P1_LSB_REG	0x8E
6362306a36Sopenharmony_ci#define BME680_P2_LSB_REG	0x90
6462306a36Sopenharmony_ci#define BME680_P3_REG		0x92
6562306a36Sopenharmony_ci#define BME680_P4_LSB_REG	0x94
6662306a36Sopenharmony_ci#define BME680_P5_LSB_REG	0x96
6762306a36Sopenharmony_ci#define BME680_P7_REG		0x98
6862306a36Sopenharmony_ci#define BME680_P6_REG		0x99
6962306a36Sopenharmony_ci#define BME680_P8_LSB_REG	0x9C
7062306a36Sopenharmony_ci#define BME680_P9_LSB_REG	0x9E
7162306a36Sopenharmony_ci#define BME680_P10_REG		0xA0
7262306a36Sopenharmony_ci#define BME680_H2_LSB_REG	0xE2
7362306a36Sopenharmony_ci#define BME680_H2_MSB_REG	0xE1
7462306a36Sopenharmony_ci#define BME680_H1_MSB_REG	0xE3
7562306a36Sopenharmony_ci#define BME680_H1_LSB_REG	0xE2
7662306a36Sopenharmony_ci#define BME680_H3_REG		0xE4
7762306a36Sopenharmony_ci#define BME680_H4_REG		0xE5
7862306a36Sopenharmony_ci#define BME680_H5_REG		0xE6
7962306a36Sopenharmony_ci#define BME680_H6_REG		0xE7
8062306a36Sopenharmony_ci#define BME680_H7_REG		0xE8
8162306a36Sopenharmony_ci#define BME680_T1_LSB_REG	0xE9
8262306a36Sopenharmony_ci#define BME680_GH2_LSB_REG	0xEB
8362306a36Sopenharmony_ci#define BME680_GH1_REG		0xED
8462306a36Sopenharmony_ci#define BME680_GH3_REG		0xEE
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ciextern const struct regmap_config bme680_regmap_config;
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ciint bme680_core_probe(struct device *dev, struct regmap *regmap,
8962306a36Sopenharmony_ci		      const char *name);
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#endif  /* BME680_H_ */
92