]> Git Repo - linux.git/blob - drivers/iio/pressure/bmp280.h
Merge tag 'for-linus-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw...
[linux.git] / drivers / iio / pressure / bmp280.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/bitops.h>
3 #include <linux/device.h>
4 #include <linux/regmap.h>
5
6 /* BMP380 specific registers */
7 #define BMP380_REG_CMD                  0x7E
8 #define BMP380_REG_CONFIG               0x1F
9 #define BMP380_REG_ODR                  0x1D
10 #define BMP380_REG_OSR                  0x1C
11 #define BMP380_REG_POWER_CONTROL        0x1B
12 #define BMP380_REG_IF_CONFIG            0x1A
13 #define BMP380_REG_INT_CONTROL          0x19
14 #define BMP380_REG_INT_STATUS           0x11
15 #define BMP380_REG_EVENT                0x10
16 #define BMP380_REG_STATUS               0x03
17 #define BMP380_REG_ERROR                0x02
18 #define BMP380_REG_ID                   0x00
19
20 #define BMP380_REG_FIFO_CONFIG_1        0x18
21 #define BMP380_REG_FIFO_CONFIG_2        0x17
22 #define BMP380_REG_FIFO_WATERMARK_MSB   0x16
23 #define BMP380_REG_FIFO_WATERMARK_LSB   0x15
24 #define BMP380_REG_FIFO_DATA            0x14
25 #define BMP380_REG_FIFO_LENGTH_MSB      0x13
26 #define BMP380_REG_FIFO_LENGTH_LSB      0x12
27
28 #define BMP380_REG_SENSOR_TIME_MSB      0x0E
29 #define BMP380_REG_SENSOR_TIME_LSB      0x0D
30 #define BMP380_REG_SENSOR_TIME_XLSB     0x0C
31
32 #define BMP380_REG_TEMP_MSB             0x09
33 #define BMP380_REG_TEMP_LSB             0x08
34 #define BMP380_REG_TEMP_XLSB            0x07
35
36 #define BMP380_REG_PRESS_MSB            0x06
37 #define BMP380_REG_PRESS_LSB            0x05
38 #define BMP380_REG_PRESS_XLSB           0x04
39
40 #define BMP380_REG_CALIB_TEMP_START     0x31
41 #define BMP380_CALIB_REG_COUNT          21
42
43 #define BMP380_FILTER_MASK              GENMASK(3, 1)
44 #define BMP380_FILTER_OFF               0
45 #define BMP380_FILTER_1X                1
46 #define BMP380_FILTER_3X                2
47 #define BMP380_FILTER_7X                3
48 #define BMP380_FILTER_15X               4
49 #define BMP380_FILTER_31X               5
50 #define BMP380_FILTER_63X               6
51 #define BMP380_FILTER_127X              7
52
53 #define BMP380_OSRS_TEMP_MASK           GENMASK(5, 3)
54 #define BMP380_OSRS_PRESS_MASK          GENMASK(2, 0)
55
56 #define BMP380_ODRS_MASK                GENMASK(4, 0)
57
58 #define BMP380_CTRL_SENSORS_MASK        GENMASK(1, 0)
59 #define BMP380_CTRL_SENSORS_PRESS_EN    BIT(0)
60 #define BMP380_CTRL_SENSORS_TEMP_EN     BIT(1)
61 #define BMP380_MODE_MASK                GENMASK(5, 4)
62 #define BMP380_MODE_SLEEP               0
63 #define BMP380_MODE_FORCED              1
64 #define BMP380_MODE_NORMAL              3
65
66 #define BMP380_MIN_TEMP                 -4000
67 #define BMP380_MAX_TEMP                 8500
68 #define BMP380_MIN_PRES                 3000000
69 #define BMP380_MAX_PRES                 12500000
70
71 #define BMP380_CMD_NOOP                 0x00
72 #define BMP380_CMD_EXTMODE_EN_MID       0x34
73 #define BMP380_CMD_FIFO_FLUSH           0xB0
74 #define BMP380_CMD_SOFT_RESET           0xB6
75
76 #define BMP380_STATUS_CMD_RDY_MASK      BIT(4)
77 #define BMP380_STATUS_DRDY_PRESS_MASK   BIT(5)
78 #define BMP380_STATUS_DRDY_TEMP_MASK    BIT(6)
79
80 #define BMP380_ERR_FATAL_MASK           BIT(0)
81 #define BMP380_ERR_CMD_MASK             BIT(1)
82 #define BMP380_ERR_CONF_MASK            BIT(2)
83
84 #define BMP380_TEMP_SKIPPED             0x800000
85 #define BMP380_PRESS_SKIPPED            0x800000
86
87 /* BMP280 specific registers */
88 #define BMP280_REG_HUMIDITY_LSB         0xFE
89 #define BMP280_REG_HUMIDITY_MSB         0xFD
90 #define BMP280_REG_TEMP_XLSB            0xFC
91 #define BMP280_REG_TEMP_LSB             0xFB
92 #define BMP280_REG_TEMP_MSB             0xFA
93 #define BMP280_REG_PRESS_XLSB           0xF9
94 #define BMP280_REG_PRESS_LSB            0xF8
95 #define BMP280_REG_PRESS_MSB            0xF7
96
97 /* Helper mask to truncate excess 4 bits on pressure and temp readings */
98 #define BMP280_MEAS_TRIM_MASK           GENMASK(24, 4)
99
100 #define BMP280_REG_CONFIG               0xF5
101 #define BMP280_REG_CTRL_MEAS            0xF4
102 #define BMP280_REG_STATUS               0xF3
103 #define BMP280_REG_CTRL_HUMIDITY        0xF2
104
105 /* Due to non linear mapping, and data sizes we can't do a bulk read */
106 #define BMP280_REG_COMP_H1              0xA1
107 #define BMP280_REG_COMP_H2              0xE1
108 #define BMP280_REG_COMP_H3              0xE3
109 #define BMP280_REG_COMP_H4              0xE4
110 #define BMP280_REG_COMP_H5              0xE5
111 #define BMP280_REG_COMP_H6              0xE7
112
113 #define BMP280_REG_COMP_TEMP_START      0x88
114 #define BMP280_COMP_TEMP_REG_COUNT      6
115
116 #define BMP280_REG_COMP_PRESS_START     0x8E
117 #define BMP280_COMP_PRESS_REG_COUNT     18
118
119 #define BMP280_COMP_H5_MASK             GENMASK(15, 4)
120
121 #define BMP280_CONTIGUOUS_CALIB_REGS    (BMP280_COMP_TEMP_REG_COUNT + \
122                                          BMP280_COMP_PRESS_REG_COUNT)
123
124 #define BMP280_FILTER_MASK              GENMASK(4, 2)
125 #define BMP280_FILTER_OFF               0
126 #define BMP280_FILTER_2X                1
127 #define BMP280_FILTER_4X                2
128 #define BMP280_FILTER_8X                3
129 #define BMP280_FILTER_16X               4
130
131 #define BMP280_OSRS_HUMIDITY_MASK       GENMASK(2, 0)
132 #define BMP280_OSRS_HUMIDITY_SKIP       0
133 #define BMP280_OSRS_HUMIDITY_1X         1
134 #define BMP280_OSRS_HUMIDITY_2X         2
135 #define BMP280_OSRS_HUMIDITY_4X         3
136 #define BMP280_OSRS_HUMIDITY_8X         4
137 #define BMP280_OSRS_HUMIDITY_16X        5
138
139 #define BMP280_OSRS_TEMP_MASK           GENMASK(7, 5)
140 #define BMP280_OSRS_TEMP_SKIP           0
141 #define BMP280_OSRS_TEMP_1X             1
142 #define BMP280_OSRS_TEMP_2X             2
143 #define BMP280_OSRS_TEMP_4X             3
144 #define BMP280_OSRS_TEMP_8X             4
145 #define BMP280_OSRS_TEMP_16X            5
146
147 #define BMP280_OSRS_PRESS_MASK          GENMASK(4, 2)
148 #define BMP280_OSRS_PRESS_SKIP          0
149 #define BMP280_OSRS_PRESS_1X            1
150 #define BMP280_OSRS_PRESS_2X            2
151 #define BMP280_OSRS_PRESS_4X            3
152 #define BMP280_OSRS_PRESS_8X            4
153 #define BMP280_OSRS_PRESS_16X           5
154
155 #define BMP280_MODE_MASK                GENMASK(1, 0)
156 #define BMP280_MODE_SLEEP               0
157 #define BMP280_MODE_FORCED              1
158 #define BMP280_MODE_NORMAL              3
159
160 /* BMP180 specific registers */
161 #define BMP180_REG_OUT_XLSB             0xF8
162 #define BMP180_REG_OUT_LSB              0xF7
163 #define BMP180_REG_OUT_MSB              0xF6
164
165 #define BMP180_REG_CALIB_START          0xAA
166 #define BMP180_REG_CALIB_COUNT          22
167
168 #define BMP180_MEAS_CTRL_MASK           GENMASK(4, 0)
169 #define BMP180_MEAS_TEMP                0x0E
170 #define BMP180_MEAS_PRESS               0x14
171 #define BMP180_MEAS_SCO                 BIT(5)
172 #define BMP180_OSRS_PRESS_MASK          GENMASK(7, 6)
173 #define BMP180_MEAS_PRESS_1X            0
174 #define BMP180_MEAS_PRESS_2X            1
175 #define BMP180_MEAS_PRESS_4X            2
176 #define BMP180_MEAS_PRESS_8X            3
177
178 /* BMP180 and BMP280 common registers */
179 #define BMP280_REG_CTRL_MEAS            0xF4
180 #define BMP280_REG_RESET                0xE0
181 #define BMP280_REG_ID                   0xD0
182
183 #define BMP380_CHIP_ID                  0x50
184 #define BMP180_CHIP_ID                  0x55
185 #define BMP280_CHIP_ID                  0x58
186 #define BME280_CHIP_ID                  0x60
187 #define BMP280_SOFT_RESET_VAL           0xB6
188
189 /* BMP280 register skipped special values */
190 #define BMP280_TEMP_SKIPPED             0x80000
191 #define BMP280_PRESS_SKIPPED            0x80000
192 #define BMP280_HUMIDITY_SKIPPED         0x8000
193
194 /* Regmap configurations */
195 extern const struct regmap_config bmp180_regmap_config;
196 extern const struct regmap_config bmp280_regmap_config;
197 extern const struct regmap_config bmp380_regmap_config;
198
199 /* Probe called from different transports */
200 int bmp280_common_probe(struct device *dev,
201                         struct regmap *regmap,
202                         unsigned int chip,
203                         const char *name,
204                         int irq);
205
206 /* PM ops */
207 extern const struct dev_pm_ops bmp280_dev_pm_ops;
This page took 0.044924 seconds and 4 git commands to generate.