bmp280.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <linux/bitops.h>
  3. #include <linux/device.h>
  4. #include <linux/regmap.h>
  5. #include <linux/regulator/consumer.h>
  6. #include <linux/iio/iio.h>
  7. /* BMP580 specific registers */
  8. #define BMP580_REG_CMD 0x7E
  9. #define BMP580_REG_EFF_OSR 0x38
  10. #define BMP580_REG_ODR_CONFIG 0x37
  11. #define BMP580_REG_OSR_CONFIG 0x36
  12. #define BMP580_REG_IF_CONFIG 0x13
  13. #define BMP580_REG_REV_ID 0x02
  14. #define BMP580_REG_CHIP_ID 0x01
  15. /* OOR allows to configure a pressure alarm */
  16. #define BMP580_REG_OOR_CONFIG 0x35
  17. #define BMP580_REG_OOR_RANGE 0x34
  18. #define BMP580_REG_OOR_THR_MSB 0x33
  19. #define BMP580_REG_OOR_THR_LSB 0x32
  20. /* DSP registers (IIR filters) */
  21. #define BMP580_REG_DSP_IIR 0x31
  22. #define BMP580_REG_DSP_CONFIG 0x30
  23. /* NVM access registers */
  24. #define BMP580_REG_NVM_DATA_MSB 0x2D
  25. #define BMP580_REG_NVM_DATA_LSB 0x2C
  26. #define BMP580_REG_NVM_ADDR 0x2B
  27. /* Status registers */
  28. #define BMP580_REG_STATUS 0x28
  29. #define BMP580_REG_INT_STATUS 0x27
  30. #define BMP580_REG_CHIP_STATUS 0x11
  31. /* Data registers */
  32. #define BMP580_REG_FIFO_DATA 0x29
  33. #define BMP580_REG_PRESS_MSB 0x22
  34. #define BMP580_REG_PRESS_LSB 0x21
  35. #define BMP580_REG_PRESS_XLSB 0x20
  36. #define BMP580_REG_TEMP_MSB 0x1F
  37. #define BMP580_REG_TEMP_LSB 0x1E
  38. #define BMP580_REG_TEMP_XLSB 0x1D
  39. /* FIFO config registers */
  40. #define BMP580_REG_FIFO_SEL 0x18
  41. #define BMP580_REG_FIFO_COUNT 0x17
  42. #define BMP580_REG_FIFO_CONFIG 0x16
  43. /* Interruptions config registers */
  44. #define BMP580_REG_INT_SOURCE 0x15
  45. #define BMP580_REG_INT_CONFIG 0x14
  46. #define BMP580_CMD_NOOP 0x00
  47. #define BMP580_CMD_EXTMODE_SEQ_0 0x73
  48. #define BMP580_CMD_EXTMODE_SEQ_1 0xB4
  49. #define BMP580_CMD_EXTMODE_SEQ_2 0x69
  50. #define BMP580_CMD_NVM_OP_SEQ_0 0x5D
  51. #define BMP580_CMD_NVM_READ_SEQ_1 0xA5
  52. #define BMP580_CMD_NVM_WRITE_SEQ_1 0xA0
  53. #define BMP580_CMD_SOFT_RESET 0xB6
  54. #define BMP580_INT_STATUS_DRDY_MASK BIT(0)
  55. #define BMP580_INT_STATUS_POR_MASK BIT(4)
  56. #define BMP580_INT_SOURCE_DRDY BIT(0)
  57. #define BMP580_INT_CONFIG_MASK GENMASK(3, 0)
  58. #define BMP580_INT_CONFIG_LATCH BIT(0)
  59. #define BMP580_INT_CONFIG_LEVEL BIT(1)
  60. #define BMP580_INT_CONFIG_OPEN_DRAIN BIT(2)
  61. #define BMP580_INT_CONFIG_INT_EN BIT(3)
  62. #define BMP580_STATUS_CORE_RDY_MASK BIT(0)
  63. #define BMP580_STATUS_NVM_RDY_MASK BIT(1)
  64. #define BMP580_STATUS_NVM_ERR_MASK BIT(2)
  65. #define BMP580_STATUS_NVM_CMD_ERR_MASK BIT(3)
  66. #define BMP580_OSR_PRESS_MASK GENMASK(5, 3)
  67. #define BMP580_OSR_TEMP_MASK GENMASK(2, 0)
  68. #define BMP580_OSR_PRESS_EN BIT(6)
  69. #define BMP580_EFF_OSR_PRESS_MASK GENMASK(5, 3)
  70. #define BMP580_EFF_OSR_TEMP_MASK GENMASK(2, 0)
  71. #define BMP580_EFF_OSR_VALID_ODR BIT(7)
  72. #define BMP580_ODR_MASK GENMASK(6, 2)
  73. #define BMP580_MODE_MASK GENMASK(1, 0)
  74. #define BMP580_MODE_SLEEP 0
  75. #define BMP580_MODE_NORMAL 1
  76. #define BMP580_MODE_FORCED 2
  77. #define BMP580_MODE_CONTINOUS 3
  78. #define BMP580_ODR_DEEPSLEEP_DIS BIT(7)
  79. #define BMP580_DSP_COMP_MASK GENMASK(1, 0)
  80. #define BMP580_DSP_COMP_DIS 0
  81. #define BMP580_DSP_TEMP_COMP_EN 1
  82. /*
  83. * In section 7.27 of datasheet, modes 2 and 3 are technically the same.
  84. * Pressure compensation means also enabling temperature compensation
  85. */
  86. #define BMP580_DSP_PRESS_COMP_EN 2
  87. #define BMP580_DSP_PRESS_TEMP_COMP_EN 3
  88. #define BMP580_DSP_IIR_FORCED_FLUSH BIT(2)
  89. #define BMP580_DSP_SHDW_IIR_TEMP_EN BIT(3)
  90. #define BMP580_DSP_FIFO_IIR_TEMP_EN BIT(4)
  91. #define BMP580_DSP_SHDW_IIR_PRESS_EN BIT(5)
  92. #define BMP580_DSP_FIFO_IIR_PRESS_EN BIT(6)
  93. #define BMP580_DSP_OOR_IIR_PRESS_EN BIT(7)
  94. #define BMP580_DSP_IIR_PRESS_MASK GENMASK(5, 3)
  95. #define BMP580_DSP_IIR_TEMP_MASK GENMASK(2, 0)
  96. #define BMP580_FILTER_OFF 0
  97. #define BMP580_FILTER_1X 1
  98. #define BMP580_FILTER_3X 2
  99. #define BMP580_FILTER_7X 3
  100. #define BMP580_FILTER_15X 4
  101. #define BMP580_FILTER_31X 5
  102. #define BMP580_FILTER_63X 6
  103. #define BMP580_FILTER_127X 7
  104. #define BMP580_NVM_ROW_ADDR_MASK GENMASK(5, 0)
  105. #define BMP580_NVM_PROG_EN BIT(6)
  106. #define BMP580_TEMP_SKIPPED 0x7f7f7f
  107. #define BMP580_PRESS_SKIPPED 0x7f7f7f
  108. /* BMP380 specific registers */
  109. #define BMP380_REG_CMD 0x7E
  110. #define BMP380_REG_CONFIG 0x1F
  111. #define BMP380_REG_ODR 0x1D
  112. #define BMP380_REG_OSR 0x1C
  113. #define BMP380_REG_POWER_CONTROL 0x1B
  114. #define BMP380_REG_IF_CONFIG 0x1A
  115. #define BMP380_REG_INT_CONTROL 0x19
  116. #define BMP380_REG_INT_STATUS 0x11
  117. #define BMP380_REG_EVENT 0x10
  118. #define BMP380_REG_STATUS 0x03
  119. #define BMP380_REG_ERROR 0x02
  120. #define BMP380_REG_ID 0x00
  121. #define BMP380_REG_FIFO_CONFIG_1 0x18
  122. #define BMP380_REG_FIFO_CONFIG_2 0x17
  123. #define BMP380_REG_FIFO_WATERMARK_MSB 0x16
  124. #define BMP380_REG_FIFO_WATERMARK_LSB 0x15
  125. #define BMP380_REG_FIFO_DATA 0x14
  126. #define BMP380_REG_FIFO_LENGTH_MSB 0x13
  127. #define BMP380_REG_FIFO_LENGTH_LSB 0x12
  128. #define BMP380_REG_SENSOR_TIME_MSB 0x0E
  129. #define BMP380_REG_SENSOR_TIME_LSB 0x0D
  130. #define BMP380_REG_SENSOR_TIME_XLSB 0x0C
  131. #define BMP380_REG_TEMP_MSB 0x09
  132. #define BMP380_REG_TEMP_LSB 0x08
  133. #define BMP380_REG_TEMP_XLSB 0x07
  134. #define BMP380_REG_PRESS_MSB 0x06
  135. #define BMP380_REG_PRESS_LSB 0x05
  136. #define BMP380_REG_PRESS_XLSB 0x04
  137. #define BMP380_REG_CALIB_TEMP_START 0x31
  138. #define BMP380_CALIB_REG_COUNT 21
  139. #define BMP380_FILTER_MASK GENMASK(3, 1)
  140. #define BMP380_FILTER_OFF 0
  141. #define BMP380_FILTER_1X 1
  142. #define BMP380_FILTER_3X 2
  143. #define BMP380_FILTER_7X 3
  144. #define BMP380_FILTER_15X 4
  145. #define BMP380_FILTER_31X 5
  146. #define BMP380_FILTER_63X 6
  147. #define BMP380_FILTER_127X 7
  148. #define BMP380_OSRS_TEMP_MASK GENMASK(5, 3)
  149. #define BMP380_OSRS_PRESS_MASK GENMASK(2, 0)
  150. #define BMP380_ODRS_MASK GENMASK(4, 0)
  151. #define BMP380_CTRL_SENSORS_MASK GENMASK(1, 0)
  152. #define BMP380_CTRL_SENSORS_PRESS_EN BIT(0)
  153. #define BMP380_CTRL_SENSORS_TEMP_EN BIT(1)
  154. #define BMP380_MODE_MASK GENMASK(5, 4)
  155. #define BMP380_MODE_SLEEP 0
  156. #define BMP380_MODE_FORCED 1
  157. #define BMP380_MODE_NORMAL 3
  158. #define BMP380_MEAS_OFFSET 234
  159. #define BMP380_MEAS_DUR 2020
  160. #define BMP380_TEMP_MEAS_OFFSET 163
  161. #define BMP380_PRESS_MEAS_OFFSET 392
  162. #define BMP380_INT_STATUS_DRDY BIT(3)
  163. #define BMP380_INT_CTRL_SETTINGS_MASK GENMASK(2, 0)
  164. #define BMP380_INT_CTRL_OPEN_DRAIN BIT(0)
  165. #define BMP380_INT_CTRL_LEVEL BIT(1)
  166. #define BMP380_INT_CTRL_LATCH BIT(2)
  167. #define BMP380_INT_CTRL_DRDY_EN BIT(6)
  168. #define BMP380_MIN_TEMP -4000
  169. #define BMP380_MAX_TEMP 8500
  170. #define BMP380_MIN_PRES 3000000
  171. #define BMP380_MAX_PRES 12500000
  172. #define BMP380_CMD_NOOP 0x00
  173. #define BMP380_CMD_EXTMODE_EN_MID 0x34
  174. #define BMP380_CMD_FIFO_FLUSH 0xB0
  175. #define BMP380_CMD_SOFT_RESET 0xB6
  176. #define BMP380_STATUS_CMD_RDY_MASK BIT(4)
  177. #define BMP380_STATUS_DRDY_PRESS_MASK BIT(5)
  178. #define BMP380_STATUS_DRDY_TEMP_MASK BIT(6)
  179. #define BMP380_ERR_FATAL_MASK BIT(0)
  180. #define BMP380_ERR_CMD_MASK BIT(1)
  181. #define BMP380_ERR_CONF_MASK BIT(2)
  182. #define BMP380_TEMP_SKIPPED 0x800000
  183. #define BMP380_PRESS_SKIPPED 0x800000
  184. /* BMP280 specific registers */
  185. #define BMP280_REG_TEMP_XLSB 0xFC
  186. #define BMP280_REG_TEMP_LSB 0xFB
  187. #define BMP280_REG_TEMP_MSB 0xFA
  188. #define BMP280_REG_PRESS_XLSB 0xF9
  189. #define BMP280_REG_PRESS_LSB 0xF8
  190. #define BMP280_REG_PRESS_MSB 0xF7
  191. /* Helper mask to truncate excess 4 bits on pressure and temp readings */
  192. #define BMP280_MEAS_TRIM_MASK GENMASK(24, 4)
  193. #define BMP280_REG_CONFIG 0xF5
  194. #define BMP280_REG_CTRL_MEAS 0xF4
  195. #define BMP280_REG_STATUS 0xF3
  196. #define BMP280_REG_STATUS_IM_UPDATE BIT(0)
  197. #define BMP280_REG_STATUS_MEAS_BIT BIT(3)
  198. #define BMP280_REG_RESET 0xE0
  199. #define BMP280_RST_SOFT_CMD 0xB6
  200. #define BMP280_REG_COMP_TEMP_START 0x88
  201. #define BMP280_COMP_TEMP_REG_COUNT 6
  202. #define BMP280_REG_COMP_PRESS_START 0x8E
  203. #define BMP280_COMP_PRESS_REG_COUNT 18
  204. #define BMP280_CONTIGUOUS_CALIB_REGS (BMP280_COMP_TEMP_REG_COUNT + \
  205. BMP280_COMP_PRESS_REG_COUNT)
  206. #define BMP280_FILTER_MASK GENMASK(4, 2)
  207. #define BMP280_FILTER_OFF 0
  208. #define BMP280_FILTER_2X 1
  209. #define BMP280_FILTER_4X 2
  210. #define BMP280_FILTER_8X 3
  211. #define BMP280_FILTER_16X 4
  212. #define BMP280_OSRS_TEMP_MASK GENMASK(7, 5)
  213. #define BMP280_OSRS_TEMP_SKIP 0
  214. #define BMP280_OSRS_TEMP_1X 1
  215. #define BMP280_OSRS_TEMP_2X 2
  216. #define BMP280_OSRS_TEMP_4X 3
  217. #define BMP280_OSRS_TEMP_8X 4
  218. #define BMP280_OSRS_TEMP_16X 5
  219. #define BMP280_OSRS_PRESS_MASK GENMASK(4, 2)
  220. #define BMP280_OSRS_PRESS_SKIP 0
  221. #define BMP280_OSRS_PRESS_1X 1
  222. #define BMP280_OSRS_PRESS_2X 2
  223. #define BMP280_OSRS_PRESS_4X 3
  224. #define BMP280_OSRS_PRESS_8X 4
  225. #define BMP280_OSRS_PRESS_16X 5
  226. #define BMP280_MODE_MASK GENMASK(1, 0)
  227. #define BMP280_MODE_SLEEP 0
  228. #define BMP280_MODE_FORCED 1
  229. #define BMP280_MODE_NORMAL 3
  230. #define BMP280_MEAS_OFFSET 1250
  231. #define BMP280_MEAS_DUR 2300
  232. #define BMP280_PRESS_HUMID_MEAS_OFFSET 575
  233. /* BME280 specific registers */
  234. #define BME280_REG_HUMIDITY_LSB 0xFE
  235. #define BME280_REG_HUMIDITY_MSB 0xFD
  236. #define BME280_REG_CTRL_HUMIDITY 0xF2
  237. /* Due to non linear mapping, and data sizes we can't do a bulk read */
  238. #define BME280_REG_COMP_H1 0xA1
  239. #define BME280_REG_COMP_H2 0xE1
  240. #define BME280_REG_COMP_H3 0xE3
  241. #define BME280_REG_COMP_H4 0xE4
  242. #define BME280_REG_COMP_H5 0xE5
  243. #define BME280_REG_COMP_H6 0xE7
  244. #define BME280_COMP_H4_GET_MASK_UP GENMASK(15, 8)
  245. #define BME280_COMP_H4_PREP_MASK_UP GENMASK(11, 4)
  246. #define BME280_COMP_H4_MASK_LOW GENMASK(3, 0)
  247. #define BME280_COMP_H5_MASK GENMASK(15, 4)
  248. #define BME280_CONTIGUOUS_CALIB_REGS 7
  249. #define BME280_OSRS_HUMIDITY_MASK GENMASK(2, 0)
  250. #define BME280_OSRS_HUMIDITY_SKIP 0
  251. #define BME280_OSRS_HUMIDITY_1X 1
  252. #define BME280_OSRS_HUMIDITY_2X 2
  253. #define BME280_OSRS_HUMIDITY_4X 3
  254. #define BME280_OSRS_HUMIDITY_8X 4
  255. #define BME280_OSRS_HUMIDITY_16X 5
  256. /* BMP180 specific registers */
  257. #define BMP180_REG_OUT_XLSB 0xF8
  258. #define BMP180_REG_OUT_LSB 0xF7
  259. #define BMP180_REG_OUT_MSB 0xF6
  260. #define BMP180_REG_CALIB_START 0xAA
  261. #define BMP180_REG_CALIB_COUNT 22
  262. #define BMP180_MEAS_CTRL_MASK GENMASK(4, 0)
  263. #define BMP180_MEAS_TEMP 0x0E
  264. #define BMP180_MEAS_PRESS 0x14
  265. #define BMP180_MEAS_SCO BIT(5)
  266. #define BMP180_OSRS_PRESS_MASK GENMASK(7, 6)
  267. #define BMP180_MEAS_PRESS_1X 0
  268. #define BMP180_MEAS_PRESS_2X 1
  269. #define BMP180_MEAS_PRESS_4X 2
  270. #define BMP180_MEAS_PRESS_8X 3
  271. /* BMP180 and BMP280 common registers */
  272. #define BMP280_REG_CTRL_MEAS 0xF4
  273. #define BMP280_REG_RESET 0xE0
  274. #define BMP280_REG_ID 0xD0
  275. #define BMP380_CHIP_ID 0x50
  276. #define BMP580_CHIP_ID 0x50
  277. #define BMP580_CHIP_ID_ALT 0x51
  278. #define BMP180_CHIP_ID 0x55
  279. #define BMP280_CHIP_ID 0x58
  280. #define BMP390_CHIP_ID 0x60
  281. #define BME280_CHIP_ID 0x60
  282. #define BMP280_SOFT_RESET_VAL 0xB6
  283. /* BMP280 register skipped special values */
  284. #define BMP280_TEMP_SKIPPED 0x80000
  285. #define BMP280_PRESS_SKIPPED 0x80000
  286. #define BMP280_HUMIDITY_SKIPPED 0x8000
  287. /* Number of bytes for each value */
  288. #define BMP280_NUM_PRESS_BYTES 3
  289. #define BMP280_NUM_TEMP_BYTES 3
  290. #define BME280_NUM_HUMIDITY_BYTES 2
  291. #define BMP280_BURST_READ_BYTES (BMP280_NUM_PRESS_BYTES + \
  292. BMP280_NUM_TEMP_BYTES)
  293. #define BME280_BURST_READ_BYTES (BMP280_NUM_PRESS_BYTES + \
  294. BMP280_NUM_TEMP_BYTES + \
  295. BME280_NUM_HUMIDITY_BYTES)
  296. /* Core exported structs */
  297. static const char *const bmp280_supply_names[] = {
  298. "vddd", "vdda"
  299. };
  300. #define BMP280_NUM_SUPPLIES ARRAY_SIZE(bmp280_supply_names)
  301. struct bmp180_calib {
  302. s16 AC1;
  303. s16 AC2;
  304. s16 AC3;
  305. u16 AC4;
  306. u16 AC5;
  307. u16 AC6;
  308. s16 B1;
  309. s16 B2;
  310. s16 MB;
  311. s16 MC;
  312. s16 MD;
  313. };
  314. /* See datasheet Section 4.2.2. */
  315. struct bmp280_calib {
  316. u16 T1;
  317. s16 T2;
  318. s16 T3;
  319. u16 P1;
  320. s16 P2;
  321. s16 P3;
  322. s16 P4;
  323. s16 P5;
  324. s16 P6;
  325. s16 P7;
  326. s16 P8;
  327. s16 P9;
  328. u8 H1;
  329. s16 H2;
  330. u8 H3;
  331. s16 H4;
  332. s16 H5;
  333. s8 H6;
  334. };
  335. /* See datasheet Section 3.11.1. */
  336. struct bmp380_calib {
  337. u16 T1;
  338. u16 T2;
  339. s8 T3;
  340. s16 P1;
  341. s16 P2;
  342. s8 P3;
  343. s8 P4;
  344. u16 P5;
  345. u16 P6;
  346. s8 P7;
  347. s8 P8;
  348. s16 P9;
  349. s8 P10;
  350. s8 P11;
  351. };
  352. enum bmp280_op_mode {
  353. BMP280_SLEEP,
  354. BMP280_FORCED,
  355. BMP280_NORMAL,
  356. };
  357. struct bmp280_data {
  358. struct device *dev;
  359. struct mutex lock;
  360. struct regmap *regmap;
  361. struct completion done;
  362. bool use_eoc;
  363. bool trig_open_drain;
  364. bool trig_active_high;
  365. struct iio_trigger *trig;
  366. const struct bmp280_chip_info *chip_info;
  367. union {
  368. struct bmp180_calib bmp180;
  369. struct bmp280_calib bmp280;
  370. struct bmp380_calib bmp380;
  371. } calib;
  372. struct regulator_bulk_data supplies[BMP280_NUM_SUPPLIES];
  373. unsigned int start_up_time_us;
  374. /* log of base 2 of oversampling rate */
  375. u8 oversampling_press;
  376. u8 oversampling_temp;
  377. u8 oversampling_humid;
  378. u8 iir_filter_coeff;
  379. /*
  380. * BMP380 devices introduce sampling frequency configuration. See
  381. * datasheet sections 3.3.3. and 4.3.19 for more details.
  382. *
  383. * BMx280 devices allowed indirect configuration of sampling frequency
  384. * changing the t_standby duration between measurements, as detailed on
  385. * section 3.6.3 of the datasheet.
  386. */
  387. int sampling_freq;
  388. /* Value to hold the current operation mode of the device */
  389. enum bmp280_op_mode op_mode;
  390. /*
  391. * DMA (thus cache coherency maintenance) may require the
  392. * transfer buffers to live in their own cache lines.
  393. */
  394. union {
  395. /* Sensor data buffer */
  396. u8 buf[BME280_BURST_READ_BYTES];
  397. /* Calibration data buffers */
  398. __le16 bmp280_cal_buf[BMP280_CONTIGUOUS_CALIB_REGS / sizeof(__le16)];
  399. __be16 bmp180_cal_buf[BMP180_REG_CALIB_COUNT / sizeof(__be16)];
  400. u8 bme280_humid_cal_buf[BME280_CONTIGUOUS_CALIB_REGS];
  401. u8 bmp380_cal_buf[BMP380_CALIB_REG_COUNT];
  402. /* Miscellaneous, endianness-aware data buffers */
  403. __le16 le16;
  404. __be16 be16;
  405. } __aligned(IIO_DMA_MINALIGN);
  406. };
  407. struct bmp280_chip_info {
  408. unsigned int id_reg;
  409. const u8 *chip_id;
  410. int num_chip_id;
  411. const struct regmap_config *regmap_config;
  412. bool spi_read_extra_byte;
  413. const struct iio_chan_spec *channels;
  414. int num_channels;
  415. unsigned int start_up_time_us;
  416. const unsigned long *avail_scan_masks;
  417. const int *oversampling_temp_avail;
  418. int num_oversampling_temp_avail;
  419. int oversampling_temp_default;
  420. const int *oversampling_press_avail;
  421. int num_oversampling_press_avail;
  422. int oversampling_press_default;
  423. const int *oversampling_humid_avail;
  424. int num_oversampling_humid_avail;
  425. int oversampling_humid_default;
  426. const int *iir_filter_coeffs_avail;
  427. int num_iir_filter_coeffs_avail;
  428. int iir_filter_coeff_default;
  429. const int (*sampling_freq_avail)[2];
  430. int num_sampling_freq_avail;
  431. int sampling_freq_default;
  432. const int *temp_coeffs;
  433. const int temp_coeffs_type;
  434. const int *press_coeffs;
  435. const int press_coeffs_type;
  436. const int *humid_coeffs;
  437. const int humid_coeffs_type;
  438. int (*chip_config)(struct bmp280_data *data);
  439. int (*read_temp)(struct bmp280_data *data, s32 *adc_temp);
  440. int (*read_press)(struct bmp280_data *data, u32 *adc_press);
  441. int (*read_humid)(struct bmp280_data *data, u32 *adc_humidity);
  442. int (*read_calib)(struct bmp280_data *data);
  443. int (*preinit)(struct bmp280_data *data);
  444. int (*set_mode)(struct bmp280_data *data, enum bmp280_op_mode mode);
  445. int (*wait_conv)(struct bmp280_data *data);
  446. int (*trigger_probe)(struct iio_dev *indio_dev);
  447. irqreturn_t (*trigger_handler)(int irq, void *p);
  448. };
  449. /* Chip infos for each variant */
  450. extern const struct bmp280_chip_info bmp085_chip_info;
  451. extern const struct bmp280_chip_info bmp180_chip_info;
  452. extern const struct bmp280_chip_info bmp280_chip_info;
  453. extern const struct bmp280_chip_info bme280_chip_info;
  454. extern const struct bmp280_chip_info bmp380_chip_info;
  455. extern const struct bmp280_chip_info bmp580_chip_info;
  456. /* Regmap configurations */
  457. extern const struct regmap_config bmp180_regmap_config;
  458. extern const struct regmap_config bmp280_regmap_config;
  459. extern const struct regmap_config bme280_regmap_config;
  460. extern const struct regmap_config bmp380_regmap_config;
  461. extern const struct regmap_config bmp580_regmap_config;
  462. /* Probe called from different transports */
  463. int bmp280_common_probe(struct device *dev,
  464. struct regmap *regmap,
  465. const struct bmp280_chip_info *chip_info,
  466. const char *name,
  467. int irq);
  468. /* PM ops */
  469. extern const struct dev_pm_ops bmp280_dev_pm_ops;