blob: 3341189d097584f54b2d23dbca4e84da7fe10091 [file] [log] [blame]
Linus Walleij14e80152016-06-30 03:48:49 +02001#include <linux/device.h>
2#include <linux/regmap.h>
3
4#include "bmp280.h"
5
6static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg)
7{
8 switch (reg) {
9 case BMP280_REG_CTRL_MEAS:
10 case BMP280_REG_RESET:
11 return true;
12 default:
13 return false;
14 };
15}
16
17static bool bmp180_is_volatile_reg(struct device *dev, unsigned int reg)
18{
19 switch (reg) {
20 case BMP180_REG_OUT_XLSB:
21 case BMP180_REG_OUT_LSB:
22 case BMP180_REG_OUT_MSB:
23 case BMP280_REG_CTRL_MEAS:
24 return true;
25 default:
26 return false;
27 }
28}
29
30const struct regmap_config bmp180_regmap_config = {
31 .reg_bits = 8,
32 .val_bits = 8,
33
34 .max_register = BMP180_REG_OUT_XLSB,
35 .cache_type = REGCACHE_RBTREE,
36
37 .writeable_reg = bmp180_is_writeable_reg,
38 .volatile_reg = bmp180_is_volatile_reg,
39};
40
41static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg)
42{
43 switch (reg) {
44 case BMP280_REG_CONFIG:
45 case BMP280_REG_CTRL_HUMIDITY:
46 case BMP280_REG_CTRL_MEAS:
47 case BMP280_REG_RESET:
48 return true;
49 default:
50 return false;
51 };
52}
53
54static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg)
55{
56 switch (reg) {
57 case BMP280_REG_HUMIDITY_LSB:
58 case BMP280_REG_HUMIDITY_MSB:
59 case BMP280_REG_TEMP_XLSB:
60 case BMP280_REG_TEMP_LSB:
61 case BMP280_REG_TEMP_MSB:
62 case BMP280_REG_PRESS_XLSB:
63 case BMP280_REG_PRESS_LSB:
64 case BMP280_REG_PRESS_MSB:
65 case BMP280_REG_STATUS:
66 return true;
67 default:
68 return false;
69 }
70}
71
72const struct regmap_config bmp280_regmap_config = {
73 .reg_bits = 8,
74 .val_bits = 8,
75
76 .max_register = BMP280_REG_HUMIDITY_LSB,
77 .cache_type = REGCACHE_RBTREE,
78
79 .writeable_reg = bmp280_is_writeable_reg,
80 .volatile_reg = bmp280_is_volatile_reg,
81};