iio: pressure: Fixes in SPI support of BMP280 driver
v2 cover iio: pressure: Fixes in SPI support of BMP280 driver
PATCH 1/2: Fix BME280 SPI driver data structures as it was assigned to the struct for the BMP280 and not the BME280.
PATCH 2/2: Fix identification of BMP3xx devices in order to use different SPI regmap.
[1]: https://lore.kernel.org/linux-iio/[email protected]/
Vasileios Amoiridis (2):
iio: pressure: Fix BME280 SPI driver data
iio: pressure: Fixes SPI support for BMP3xx devices
drivers/iio/pressure/bmp280-core.c | 1 + drivers/iio/pressure/bmp280-spi.c | 13 ++++--------- drivers/iio/pressure/bmp280.h | 1 + 3 files changed, 6 insertions(+), 9 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/2 iio: pressure: Fixes BME280 SPI driver data
Use bme280_chip_info structure instead of bmp280_chip_info in SPI support for the BME280 sensor.
--- drivers/iio/pressure/bmp280-spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/pressure/bmp280-spi.c +2 -2
@@ -127,7 +127,7 @@ static const struct of_device_id bmp280_of_spi_match[] = { { .compatible = "bosch,bmp180", .data = &bmp180_chip_info }, { .compatible = "bosch,bmp181", .data = &bmp180_chip_info }, { .compatible = "bosch,bmp280", .data = &bmp280_chip_info }, - { .compatible = "bosch,bme280", .data = &bmp280_chip_info }, + { .compatible = "bosch,bme280", .data = &bme280_chip_info }, { .compatible = "bosch,bmp380", .data = &bmp380_chip_info }, { .compatible = "bosch,bmp580", .data = &bmp580_chip_info }, { },
@@ -139,7 +139,7 @@ static const struct spi_device_id bmp280_spi_id[] = { { "bmp180", (kernel_ulong_t)&bmp180_chip_info }, { "bmp181", (kernel_ulong_t)&bmp180_chip_info }, { "bmp280", (kernel_ulong_t)&bmp280_chip_info }, - { "bme280", (kernel_ulong_t)&bmp280_chip_info }, + { "bme280", (kernel_ulong_t)&bme280_chip_info }, { "bmp380", (kernel_ulong_t)&bmp380_chip_info }, { "bmp580", (kernel_ulong_t)&bmp580_chip_info }, { }
Signature · 1 line
2.25.1
PATCH v2 2/2 iio: pressure: Fixes SPI support for BMP3xx devices
In reply to Vasileios AmoiridisBosch does not use unique BMPxxx_CHIP_ID for the different versions of the device which leads to misidentification of devices if their ID is used. Use a new value in the chip_info structure instead of the BMPxxx_CHIP_ID, in order to choose the correct regmap_bus to be used.
--- drivers/iio/pressure/bmp280-core.c | 1 + drivers/iio/pressure/bmp280-spi.c | 9 ++------- drivers/iio/pressure/bmp280.h | 1 + 3 files changed, 4 insertions(+), 7 deletions(-)
drivers/iio/pressure/bmp280-core.c +1 -0
@@ -1233,6 +1233,7 @@ const struct bmp280_chip_info bmp380_chip_info = { .chip_id = bmp380_chip_ids, .num_chip_id = ARRAY_SIZE(bmp380_chip_ids), .regmap_config = &bmp380_regmap_config, + .spi_read_extra_byte = true, .start_up_time = 2000, .channels = bmp380_channels, .num_channels = 2,
drivers/iio/pressure/bmp280-spi.c +2 -7
@@ -96,15 +96,10 @@ static int bmp280_spi_probe(struct spi_device *spi) chip_info =spi_get_device_match_data (spi); -switch (chip_info->chip_id[0 ]) { -case BMP380_CHIP_ID : -case BMP390_CHIP_ID : +if (chip_info->spi_read_extra_byte) bmp_regmap_bus = &bmp380_regmap_bus; -break ; -default : +else bmp_regmap_bus = &bmp280_regmap_bus; -break ; - } regmap = devm_regmap_init(&spi->dev, bmp_regmap_bus,
drivers/iio/pressure/bmp280.h +1 -0
@@ -423,6 +423,7 @@ struct bmp280_chip_info {int num_chip_id;const struct regmap_config *regmap_config; +bool spi_read_extra_byte;const struct iio_chan_spec *channels;int num_channels;
Signature · 1 line
2.25.1
Quoted 7 lines · On Sat, 16 Mar 2024 12:07:41 +0100 Vasileios Amoiridis…
PATCH 1/2: Fix BME280 SPI driver data structures as it was assigned to the struct for the BMP280 and not the BME280.
PATCH 2/2: Fix identification of BMP3xx devices in order to use different SPI regmap.
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
Quoted 10 lines
Vasileios Amoiridis (2):
iio: pressure: Fix BME280 SPI driver data
iio: pressure: Fixes SPI support for BMP3xx devicesdrivers/iio/pressure/bmp280-core.c | 1 + drivers/iio/pressure/bmp280-spi.c | 13 ++++--------- drivers/iio/pressure/bmp280.h | 1 + 3 files changed, 6 insertions(+), 9 deletions(-)