162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci#include <linux/device.h> 362306a36Sopenharmony_ci#include <linux/module.h> 462306a36Sopenharmony_ci#include <linux/regmap.h> 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include "bmp280.h" 762306a36Sopenharmony_ci 862306a36Sopenharmony_cistatic bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg) 962306a36Sopenharmony_ci{ 1062306a36Sopenharmony_ci switch (reg) { 1162306a36Sopenharmony_ci case BMP280_REG_CTRL_MEAS: 1262306a36Sopenharmony_ci case BMP280_REG_RESET: 1362306a36Sopenharmony_ci return true; 1462306a36Sopenharmony_ci default: 1562306a36Sopenharmony_ci return false; 1662306a36Sopenharmony_ci } 1762306a36Sopenharmony_ci} 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_cistatic bool bmp180_is_volatile_reg(struct device *dev, unsigned int reg) 2062306a36Sopenharmony_ci{ 2162306a36Sopenharmony_ci switch (reg) { 2262306a36Sopenharmony_ci case BMP180_REG_OUT_XLSB: 2362306a36Sopenharmony_ci case BMP180_REG_OUT_LSB: 2462306a36Sopenharmony_ci case BMP180_REG_OUT_MSB: 2562306a36Sopenharmony_ci case BMP280_REG_CTRL_MEAS: 2662306a36Sopenharmony_ci return true; 2762306a36Sopenharmony_ci default: 2862306a36Sopenharmony_ci return false; 2962306a36Sopenharmony_ci } 3062306a36Sopenharmony_ci} 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciconst struct regmap_config bmp180_regmap_config = { 3362306a36Sopenharmony_ci .reg_bits = 8, 3462306a36Sopenharmony_ci .val_bits = 8, 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci .max_register = BMP180_REG_OUT_XLSB, 3762306a36Sopenharmony_ci .cache_type = REGCACHE_RBTREE, 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci .writeable_reg = bmp180_is_writeable_reg, 4062306a36Sopenharmony_ci .volatile_reg = bmp180_is_volatile_reg, 4162306a36Sopenharmony_ci}; 4262306a36Sopenharmony_ciEXPORT_SYMBOL_NS(bmp180_regmap_config, IIO_BMP280); 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_cistatic bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg) 4562306a36Sopenharmony_ci{ 4662306a36Sopenharmony_ci switch (reg) { 4762306a36Sopenharmony_ci case BMP280_REG_CONFIG: 4862306a36Sopenharmony_ci case BMP280_REG_CTRL_HUMIDITY: 4962306a36Sopenharmony_ci case BMP280_REG_CTRL_MEAS: 5062306a36Sopenharmony_ci case BMP280_REG_RESET: 5162306a36Sopenharmony_ci return true; 5262306a36Sopenharmony_ci default: 5362306a36Sopenharmony_ci return false; 5462306a36Sopenharmony_ci } 5562306a36Sopenharmony_ci} 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistatic bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg) 5862306a36Sopenharmony_ci{ 5962306a36Sopenharmony_ci switch (reg) { 6062306a36Sopenharmony_ci case BMP280_REG_HUMIDITY_LSB: 6162306a36Sopenharmony_ci case BMP280_REG_HUMIDITY_MSB: 6262306a36Sopenharmony_ci case BMP280_REG_TEMP_XLSB: 6362306a36Sopenharmony_ci case BMP280_REG_TEMP_LSB: 6462306a36Sopenharmony_ci case BMP280_REG_TEMP_MSB: 6562306a36Sopenharmony_ci case BMP280_REG_PRESS_XLSB: 6662306a36Sopenharmony_ci case BMP280_REG_PRESS_LSB: 6762306a36Sopenharmony_ci case BMP280_REG_PRESS_MSB: 6862306a36Sopenharmony_ci case BMP280_REG_STATUS: 6962306a36Sopenharmony_ci return true; 7062306a36Sopenharmony_ci default: 7162306a36Sopenharmony_ci return false; 7262306a36Sopenharmony_ci } 7362306a36Sopenharmony_ci} 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_cistatic bool bmp380_is_writeable_reg(struct device *dev, unsigned int reg) 7662306a36Sopenharmony_ci{ 7762306a36Sopenharmony_ci switch (reg) { 7862306a36Sopenharmony_ci case BMP380_REG_CMD: 7962306a36Sopenharmony_ci case BMP380_REG_CONFIG: 8062306a36Sopenharmony_ci case BMP380_REG_FIFO_CONFIG_1: 8162306a36Sopenharmony_ci case BMP380_REG_FIFO_CONFIG_2: 8262306a36Sopenharmony_ci case BMP380_REG_FIFO_WATERMARK_LSB: 8362306a36Sopenharmony_ci case BMP380_REG_FIFO_WATERMARK_MSB: 8462306a36Sopenharmony_ci case BMP380_REG_POWER_CONTROL: 8562306a36Sopenharmony_ci case BMP380_REG_INT_CONTROL: 8662306a36Sopenharmony_ci case BMP380_REG_IF_CONFIG: 8762306a36Sopenharmony_ci case BMP380_REG_ODR: 8862306a36Sopenharmony_ci case BMP380_REG_OSR: 8962306a36Sopenharmony_ci return true; 9062306a36Sopenharmony_ci default: 9162306a36Sopenharmony_ci return false; 9262306a36Sopenharmony_ci } 9362306a36Sopenharmony_ci} 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_cistatic bool bmp380_is_volatile_reg(struct device *dev, unsigned int reg) 9662306a36Sopenharmony_ci{ 9762306a36Sopenharmony_ci switch (reg) { 9862306a36Sopenharmony_ci case BMP380_REG_TEMP_XLSB: 9962306a36Sopenharmony_ci case BMP380_REG_TEMP_LSB: 10062306a36Sopenharmony_ci case BMP380_REG_TEMP_MSB: 10162306a36Sopenharmony_ci case BMP380_REG_PRESS_XLSB: 10262306a36Sopenharmony_ci case BMP380_REG_PRESS_LSB: 10362306a36Sopenharmony_ci case BMP380_REG_PRESS_MSB: 10462306a36Sopenharmony_ci case BMP380_REG_SENSOR_TIME_XLSB: 10562306a36Sopenharmony_ci case BMP380_REG_SENSOR_TIME_LSB: 10662306a36Sopenharmony_ci case BMP380_REG_SENSOR_TIME_MSB: 10762306a36Sopenharmony_ci case BMP380_REG_INT_STATUS: 10862306a36Sopenharmony_ci case BMP380_REG_FIFO_DATA: 10962306a36Sopenharmony_ci case BMP380_REG_STATUS: 11062306a36Sopenharmony_ci case BMP380_REG_ERROR: 11162306a36Sopenharmony_ci case BMP380_REG_EVENT: 11262306a36Sopenharmony_ci return true; 11362306a36Sopenharmony_ci default: 11462306a36Sopenharmony_ci return false; 11562306a36Sopenharmony_ci } 11662306a36Sopenharmony_ci} 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_cistatic bool bmp580_is_writeable_reg(struct device *dev, unsigned int reg) 11962306a36Sopenharmony_ci{ 12062306a36Sopenharmony_ci switch (reg) { 12162306a36Sopenharmony_ci case BMP580_REG_NVM_DATA_MSB: 12262306a36Sopenharmony_ci case BMP580_REG_NVM_DATA_LSB: 12362306a36Sopenharmony_ci case BMP580_REG_NVM_ADDR: 12462306a36Sopenharmony_ci case BMP580_REG_ODR_CONFIG: 12562306a36Sopenharmony_ci case BMP580_REG_OSR_CONFIG: 12662306a36Sopenharmony_ci case BMP580_REG_INT_SOURCE: 12762306a36Sopenharmony_ci case BMP580_REG_INT_CONFIG: 12862306a36Sopenharmony_ci case BMP580_REG_OOR_THR_MSB: 12962306a36Sopenharmony_ci case BMP580_REG_OOR_THR_LSB: 13062306a36Sopenharmony_ci case BMP580_REG_OOR_CONFIG: 13162306a36Sopenharmony_ci case BMP580_REG_OOR_RANGE: 13262306a36Sopenharmony_ci case BMP580_REG_IF_CONFIG: 13362306a36Sopenharmony_ci case BMP580_REG_FIFO_CONFIG: 13462306a36Sopenharmony_ci case BMP580_REG_FIFO_SEL: 13562306a36Sopenharmony_ci case BMP580_REG_DSP_CONFIG: 13662306a36Sopenharmony_ci case BMP580_REG_DSP_IIR: 13762306a36Sopenharmony_ci case BMP580_REG_CMD: 13862306a36Sopenharmony_ci return true; 13962306a36Sopenharmony_ci default: 14062306a36Sopenharmony_ci return false; 14162306a36Sopenharmony_ci } 14262306a36Sopenharmony_ci} 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_cistatic bool bmp580_is_volatile_reg(struct device *dev, unsigned int reg) 14562306a36Sopenharmony_ci{ 14662306a36Sopenharmony_ci switch (reg) { 14762306a36Sopenharmony_ci case BMP580_REG_NVM_DATA_MSB: 14862306a36Sopenharmony_ci case BMP580_REG_NVM_DATA_LSB: 14962306a36Sopenharmony_ci case BMP580_REG_FIFO_COUNT: 15062306a36Sopenharmony_ci case BMP580_REG_INT_STATUS: 15162306a36Sopenharmony_ci case BMP580_REG_PRESS_XLSB: 15262306a36Sopenharmony_ci case BMP580_REG_PRESS_LSB: 15362306a36Sopenharmony_ci case BMP580_REG_PRESS_MSB: 15462306a36Sopenharmony_ci case BMP580_REG_FIFO_DATA: 15562306a36Sopenharmony_ci case BMP580_REG_TEMP_XLSB: 15662306a36Sopenharmony_ci case BMP580_REG_TEMP_LSB: 15762306a36Sopenharmony_ci case BMP580_REG_TEMP_MSB: 15862306a36Sopenharmony_ci case BMP580_REG_EFF_OSR: 15962306a36Sopenharmony_ci case BMP580_REG_STATUS: 16062306a36Sopenharmony_ci return true; 16162306a36Sopenharmony_ci default: 16262306a36Sopenharmony_ci return false; 16362306a36Sopenharmony_ci } 16462306a36Sopenharmony_ci} 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ciconst struct regmap_config bmp280_regmap_config = { 16762306a36Sopenharmony_ci .reg_bits = 8, 16862306a36Sopenharmony_ci .val_bits = 8, 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci .max_register = BMP280_REG_HUMIDITY_LSB, 17162306a36Sopenharmony_ci .cache_type = REGCACHE_RBTREE, 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci .writeable_reg = bmp280_is_writeable_reg, 17462306a36Sopenharmony_ci .volatile_reg = bmp280_is_volatile_reg, 17562306a36Sopenharmony_ci}; 17662306a36Sopenharmony_ciEXPORT_SYMBOL_NS(bmp280_regmap_config, IIO_BMP280); 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ciconst struct regmap_config bmp380_regmap_config = { 17962306a36Sopenharmony_ci .reg_bits = 8, 18062306a36Sopenharmony_ci .val_bits = 8, 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ci .max_register = BMP380_REG_CMD, 18362306a36Sopenharmony_ci .cache_type = REGCACHE_RBTREE, 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci .writeable_reg = bmp380_is_writeable_reg, 18662306a36Sopenharmony_ci .volatile_reg = bmp380_is_volatile_reg, 18762306a36Sopenharmony_ci}; 18862306a36Sopenharmony_ciEXPORT_SYMBOL_NS(bmp380_regmap_config, IIO_BMP280); 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ciconst struct regmap_config bmp580_regmap_config = { 19162306a36Sopenharmony_ci .reg_bits = 8, 19262306a36Sopenharmony_ci .val_bits = 8, 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci .max_register = BMP580_REG_CMD, 19562306a36Sopenharmony_ci .cache_type = REGCACHE_RBTREE, 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci .writeable_reg = bmp580_is_writeable_reg, 19862306a36Sopenharmony_ci .volatile_reg = bmp580_is_volatile_reg, 19962306a36Sopenharmony_ci}; 20062306a36Sopenharmony_ciEXPORT_SYMBOL_NS(bmp580_regmap_config, IIO_BMP280); 201