Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: pressure: bmp280: Add support for bmp280 soft reset

The BM(P/E)28x devices have an option for soft reset which is also
recommended by the Bosch Sensortech BME2 Sensor API to be used before the
initial configuration of the device.

Link: https://github.com/boschsensortec/BME280_SensorAPI/blob/bme280_v3.5.1/bme280.c#L429
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240902184222.24874-3-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Vasileios Amoiridis and committed by
Jonathan Cameron
1a8a8787 61809f18

+32
+29
drivers/iio/pressure/bmp280-core.c
··· 964 964 0 965 965 }; 966 966 967 + static int bmp280_preinit(struct bmp280_data *data) 968 + { 969 + struct device *dev = data->dev; 970 + unsigned int reg; 971 + int ret; 972 + 973 + ret = regmap_write(data->regmap, BMP280_REG_RESET, BMP280_RST_SOFT_CMD); 974 + if (ret) 975 + return dev_err_probe(dev, ret, "Failed to reset device.\n"); 976 + 977 + /* 978 + * According to the datasheet in Chapter 1: Specification, Table 2, 979 + * after resetting, the device uses the complete power-on sequence so 980 + * it needs to wait for the defined start-up time. 981 + */ 982 + fsleep(data->start_up_time); 983 + 984 + ret = regmap_read(data->regmap, BMP280_REG_STATUS, &reg); 985 + if (ret) 986 + return dev_err_probe(dev, ret, "Failed to read status register.\n"); 987 + 988 + if (reg & BMP280_REG_STATUS_IM_UPDATE) 989 + return dev_err_probe(dev, -EIO, "Failed to copy NVM contents.\n"); 990 + 991 + return 0; 992 + } 993 + 967 994 static int bmp280_chip_config(struct bmp280_data *data) 968 995 { 969 996 u8 osrs = FIELD_PREP(BMP280_OSRS_TEMP_MASK, data->oversampling_temp + 1) | ··· 1107 1080 .read_temp = bmp280_read_temp, 1108 1081 .read_press = bmp280_read_press, 1109 1082 .read_calib = bmp280_read_calib, 1083 + .preinit = bmp280_preinit, 1110 1084 1111 1085 .trigger_handler = bmp280_trigger_handler, 1112 1086 }; ··· 1225 1197 .read_press = bmp280_read_press, 1226 1198 .read_humid = bme280_read_humid, 1227 1199 .read_calib = bme280_read_calib, 1200 + .preinit = bmp280_preinit, 1228 1201 1229 1202 .trigger_handler = bme280_trigger_handler, 1230 1203 };
+3
drivers/iio/pressure/bmp280.h
··· 205 205 #define BMP280_REG_CONFIG 0xF5 206 206 #define BMP280_REG_CTRL_MEAS 0xF4 207 207 #define BMP280_REG_STATUS 0xF3 208 + #define BMP280_REG_STATUS_IM_UPDATE BIT(0) 209 + #define BMP280_REG_RESET 0xE0 210 + #define BMP280_RST_SOFT_CMD 0xB6 208 211 209 212 #define BMP280_REG_COMP_TEMP_START 0x88 210 213 #define BMP280_COMP_TEMP_REG_COUNT 6