Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / iio / pressure / bmp280-regmap.c
blobb6a7b417c8cf737535e8f36cd6d8df03eeb555fd
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/device.h>
3 #include <linux/module.h>
4 #include <linux/regmap.h>
6 #include "bmp280.h"
8 static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg)
10 switch (reg) {
11 case BMP280_REG_CTRL_MEAS:
12 case BMP280_REG_RESET:
13 return true;
14 default:
15 return false;
19 static bool bmp180_is_volatile_reg(struct device *dev, unsigned int reg)
21 switch (reg) {
22 case BMP180_REG_OUT_XLSB:
23 case BMP180_REG_OUT_LSB:
24 case BMP180_REG_OUT_MSB:
25 case BMP280_REG_CTRL_MEAS:
26 return true;
27 default:
28 return false;
32 const struct regmap_config bmp180_regmap_config = {
33 .reg_bits = 8,
34 .val_bits = 8,
36 .max_register = BMP180_REG_OUT_XLSB,
37 .cache_type = REGCACHE_RBTREE,
39 .writeable_reg = bmp180_is_writeable_reg,
40 .volatile_reg = bmp180_is_volatile_reg,
42 EXPORT_SYMBOL_NS(bmp180_regmap_config, "IIO_BMP280");
44 static bool bme280_is_writeable_reg(struct device *dev, unsigned int reg)
46 switch (reg) {
47 case BMP280_REG_CONFIG:
48 case BME280_REG_CTRL_HUMIDITY:
49 case BMP280_REG_CTRL_MEAS:
50 case BMP280_REG_RESET:
51 return true;
52 default:
53 return false;
57 static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg)
59 switch (reg) {
60 case BMP280_REG_CONFIG:
61 case BMP280_REG_CTRL_MEAS:
62 case BMP280_REG_RESET:
63 return true;
64 default:
65 return false;
69 static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg)
71 switch (reg) {
72 case BMP280_REG_TEMP_XLSB:
73 case BMP280_REG_TEMP_LSB:
74 case BMP280_REG_TEMP_MSB:
75 case BMP280_REG_PRESS_XLSB:
76 case BMP280_REG_PRESS_LSB:
77 case BMP280_REG_PRESS_MSB:
78 case BMP280_REG_STATUS:
79 return true;
80 default:
81 return false;
85 static bool bme280_is_volatile_reg(struct device *dev, unsigned int reg)
87 switch (reg) {
88 case BME280_REG_HUMIDITY_LSB:
89 case BME280_REG_HUMIDITY_MSB:
90 case BMP280_REG_TEMP_XLSB:
91 case BMP280_REG_TEMP_LSB:
92 case BMP280_REG_TEMP_MSB:
93 case BMP280_REG_PRESS_XLSB:
94 case BMP280_REG_PRESS_LSB:
95 case BMP280_REG_PRESS_MSB:
96 case BMP280_REG_STATUS:
97 return true;
98 default:
99 return false;
102 static bool bmp380_is_writeable_reg(struct device *dev, unsigned int reg)
104 switch (reg) {
105 case BMP380_REG_CMD:
106 case BMP380_REG_CONFIG:
107 case BMP380_REG_FIFO_CONFIG_1:
108 case BMP380_REG_FIFO_CONFIG_2:
109 case BMP380_REG_FIFO_WATERMARK_LSB:
110 case BMP380_REG_FIFO_WATERMARK_MSB:
111 case BMP380_REG_POWER_CONTROL:
112 case BMP380_REG_INT_CONTROL:
113 case BMP380_REG_IF_CONFIG:
114 case BMP380_REG_ODR:
115 case BMP380_REG_OSR:
116 return true;
117 default:
118 return false;
122 static bool bmp380_is_volatile_reg(struct device *dev, unsigned int reg)
124 switch (reg) {
125 case BMP380_REG_TEMP_XLSB:
126 case BMP380_REG_TEMP_LSB:
127 case BMP380_REG_TEMP_MSB:
128 case BMP380_REG_PRESS_XLSB:
129 case BMP380_REG_PRESS_LSB:
130 case BMP380_REG_PRESS_MSB:
131 case BMP380_REG_SENSOR_TIME_XLSB:
132 case BMP380_REG_SENSOR_TIME_LSB:
133 case BMP380_REG_SENSOR_TIME_MSB:
134 case BMP380_REG_INT_STATUS:
135 case BMP380_REG_FIFO_DATA:
136 case BMP380_REG_STATUS:
137 case BMP380_REG_ERROR:
138 case BMP380_REG_EVENT:
139 return true;
140 default:
141 return false;
145 static bool bmp580_is_writeable_reg(struct device *dev, unsigned int reg)
147 switch (reg) {
148 case BMP580_REG_NVM_DATA_MSB:
149 case BMP580_REG_NVM_DATA_LSB:
150 case BMP580_REG_NVM_ADDR:
151 case BMP580_REG_ODR_CONFIG:
152 case BMP580_REG_OSR_CONFIG:
153 case BMP580_REG_INT_SOURCE:
154 case BMP580_REG_INT_CONFIG:
155 case BMP580_REG_OOR_THR_MSB:
156 case BMP580_REG_OOR_THR_LSB:
157 case BMP580_REG_OOR_CONFIG:
158 case BMP580_REG_OOR_RANGE:
159 case BMP580_REG_IF_CONFIG:
160 case BMP580_REG_FIFO_CONFIG:
161 case BMP580_REG_FIFO_SEL:
162 case BMP580_REG_DSP_CONFIG:
163 case BMP580_REG_DSP_IIR:
164 case BMP580_REG_CMD:
165 return true;
166 default:
167 return false;
171 static bool bmp580_is_volatile_reg(struct device *dev, unsigned int reg)
173 switch (reg) {
174 case BMP580_REG_NVM_DATA_MSB:
175 case BMP580_REG_NVM_DATA_LSB:
176 case BMP580_REG_FIFO_COUNT:
177 case BMP580_REG_INT_STATUS:
178 case BMP580_REG_PRESS_XLSB:
179 case BMP580_REG_PRESS_LSB:
180 case BMP580_REG_PRESS_MSB:
181 case BMP580_REG_FIFO_DATA:
182 case BMP580_REG_TEMP_XLSB:
183 case BMP580_REG_TEMP_LSB:
184 case BMP580_REG_TEMP_MSB:
185 case BMP580_REG_EFF_OSR:
186 case BMP580_REG_STATUS:
187 return true;
188 default:
189 return false;
193 const struct regmap_config bmp280_regmap_config = {
194 .reg_bits = 8,
195 .val_bits = 8,
197 .max_register = BMP280_REG_TEMP_XLSB,
198 .cache_type = REGCACHE_RBTREE,
200 .writeable_reg = bmp280_is_writeable_reg,
201 .volatile_reg = bmp280_is_volatile_reg,
203 EXPORT_SYMBOL_NS(bmp280_regmap_config, "IIO_BMP280");
205 const struct regmap_config bme280_regmap_config = {
206 .reg_bits = 8,
207 .val_bits = 8,
209 .max_register = BME280_REG_HUMIDITY_LSB,
210 .cache_type = REGCACHE_RBTREE,
212 .writeable_reg = bme280_is_writeable_reg,
213 .volatile_reg = bme280_is_volatile_reg,
215 EXPORT_SYMBOL_NS(bme280_regmap_config, "IIO_BMP280");
217 const struct regmap_config bmp380_regmap_config = {
218 .reg_bits = 8,
219 .val_bits = 8,
221 .max_register = BMP380_REG_CMD,
222 .cache_type = REGCACHE_RBTREE,
224 .writeable_reg = bmp380_is_writeable_reg,
225 .volatile_reg = bmp380_is_volatile_reg,
227 EXPORT_SYMBOL_NS(bmp380_regmap_config, "IIO_BMP280");
229 const struct regmap_config bmp580_regmap_config = {
230 .reg_bits = 8,
231 .val_bits = 8,
233 .max_register = BMP580_REG_CMD,
234 .cache_type = REGCACHE_RBTREE,
236 .writeable_reg = bmp580_is_writeable_reg,
237 .volatile_reg = bmp580_is_volatile_reg,
239 EXPORT_SYMBOL_NS(bmp580_regmap_config, "IIO_BMP280");