blob: da136dbadc8f7e8c7f8af4d91b48903cac86cd67 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Walleij14e80152016-06-30 03:48:49 +02002#include <linux/device.h>
Linus Walleij17118842016-06-30 03:48:50 +02003#include <linux/module.h>
Linus Walleij14e80152016-06-30 03:48:49 +02004#include <linux/regmap.h>
5
6#include "bmp280.h"
7
8static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg)
9{
10 switch (reg) {
11 case BMP280_REG_CTRL_MEAS:
12 case BMP280_REG_RESET:
13 return true;
14 default:
15 return false;
Tom Rix3516ebc2020-10-31 06:45:06 -070016 }
Linus Walleij14e80152016-06-30 03:48:49 +020017}
18
19static bool bmp180_is_volatile_reg(struct device *dev, unsigned int reg)
20{
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;
29 }
30}
31
32const struct regmap_config bmp180_regmap_config = {
33 .reg_bits = 8,
34 .val_bits = 8,
35
36 .max_register = BMP180_REG_OUT_XLSB,
37 .cache_type = REGCACHE_RBTREE,
38
39 .writeable_reg = bmp180_is_writeable_reg,
40 .volatile_reg = bmp180_is_volatile_reg,
41};
Linus Walleij17118842016-06-30 03:48:50 +020042EXPORT_SYMBOL(bmp180_regmap_config);
Linus Walleij14e80152016-06-30 03:48:49 +020043
44static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg)
45{
46 switch (reg) {
47 case BMP280_REG_CONFIG:
48 case BMP280_REG_CTRL_HUMIDITY:
49 case BMP280_REG_CTRL_MEAS:
50 case BMP280_REG_RESET:
51 return true;
52 default:
53 return false;
Tom Rix3516ebc2020-10-31 06:45:06 -070054 }
Linus Walleij14e80152016-06-30 03:48:49 +020055}
56
57static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg)
58{
59 switch (reg) {
60 case BMP280_REG_HUMIDITY_LSB:
61 case BMP280_REG_HUMIDITY_MSB:
62 case BMP280_REG_TEMP_XLSB:
63 case BMP280_REG_TEMP_LSB:
64 case BMP280_REG_TEMP_MSB:
65 case BMP280_REG_PRESS_XLSB:
66 case BMP280_REG_PRESS_LSB:
67 case BMP280_REG_PRESS_MSB:
68 case BMP280_REG_STATUS:
69 return true;
70 default:
71 return false;
72 }
73}
74
75const struct regmap_config bmp280_regmap_config = {
76 .reg_bits = 8,
77 .val_bits = 8,
78
79 .max_register = BMP280_REG_HUMIDITY_LSB,
80 .cache_type = REGCACHE_RBTREE,
81
82 .writeable_reg = bmp280_is_writeable_reg,
83 .volatile_reg = bmp280_is_volatile_reg,
84};
Linus Walleij17118842016-06-30 03:48:50 +020085EXPORT_SYMBOL(bmp280_regmap_config);