Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/device.h>
0003 #include <linux/module.h>
0004 #include <linux/regmap.h>
0005 
0006 #include "bmp280.h"
0007 
0008 static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg)
0009 {
0010     switch (reg) {
0011     case BMP280_REG_CTRL_MEAS:
0012     case BMP280_REG_RESET:
0013         return true;
0014     default:
0015         return false;
0016     }
0017 }
0018 
0019 static bool bmp180_is_volatile_reg(struct device *dev, unsigned int reg)
0020 {
0021     switch (reg) {
0022     case BMP180_REG_OUT_XLSB:
0023     case BMP180_REG_OUT_LSB:
0024     case BMP180_REG_OUT_MSB:
0025     case BMP280_REG_CTRL_MEAS:
0026         return true;
0027     default:
0028         return false;
0029     }
0030 }
0031 
0032 const struct regmap_config bmp180_regmap_config = {
0033     .reg_bits = 8,
0034     .val_bits = 8,
0035 
0036     .max_register = BMP180_REG_OUT_XLSB,
0037     .cache_type = REGCACHE_RBTREE,
0038 
0039     .writeable_reg = bmp180_is_writeable_reg,
0040     .volatile_reg = bmp180_is_volatile_reg,
0041 };
0042 EXPORT_SYMBOL_NS(bmp180_regmap_config, IIO_BMP280);
0043 
0044 static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg)
0045 {
0046     switch (reg) {
0047     case BMP280_REG_CONFIG:
0048     case BMP280_REG_CTRL_HUMIDITY:
0049     case BMP280_REG_CTRL_MEAS:
0050     case BMP280_REG_RESET:
0051         return true;
0052     default:
0053         return false;
0054     }
0055 }
0056 
0057 static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg)
0058 {
0059     switch (reg) {
0060     case BMP280_REG_HUMIDITY_LSB:
0061     case BMP280_REG_HUMIDITY_MSB:
0062     case BMP280_REG_TEMP_XLSB:
0063     case BMP280_REG_TEMP_LSB:
0064     case BMP280_REG_TEMP_MSB:
0065     case BMP280_REG_PRESS_XLSB:
0066     case BMP280_REG_PRESS_LSB:
0067     case BMP280_REG_PRESS_MSB:
0068     case BMP280_REG_STATUS:
0069         return true;
0070     default:
0071         return false;
0072     }
0073 }
0074 
0075 const struct regmap_config bmp280_regmap_config = {
0076     .reg_bits = 8,
0077     .val_bits = 8,
0078 
0079     .max_register = BMP280_REG_HUMIDITY_LSB,
0080     .cache_type = REGCACHE_RBTREE,
0081 
0082     .writeable_reg = bmp280_is_writeable_reg,
0083     .volatile_reg = bmp280_is_volatile_reg,
0084 };
0085 EXPORT_SYMBOL_NS(bmp280_regmap_config, IIO_BMP280);