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