iio: pressure: bmp280: support device tree initialization
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 30 Jun 2016 01:48:46 +0000 (03:48 +0200)
committerJonathan Cameron <jic23@kernel.org>
Thu, 30 Jun 2016 19:39:36 +0000 (20:39 +0100)
This adds device tree support to the BMP085, BMP180 and BMP280
pressure sensors. Tested on the Qualcomm APQ8060 Dragonboard:

iio:device1$ cat in_temp_input
26700
iio:device1$ cat in_pressure_input
99.185000000

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/pressure/bmp280.c

index dbbcd6d..a147ce2 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/acpi.h>
+#include <linux/of.h>
 #include <linux/regmap.h>
 #include <linux/delay.h>
 #include <linux/iio/iio.h>
@@ -1094,6 +1095,19 @@ static const struct acpi_device_id bmp280_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, bmp280_acpi_match);
 
+#ifdef CONFIG_OF
+static const struct of_device_id bmp280_of_match[] = {
+       { .compatible = "bosch,bme280", .data = (void *)BME280_CHIP_ID },
+       { .compatible = "bosch,bmp280", .data = (void *)BMP280_CHIP_ID },
+       { .compatible = "bosch,bmp180", .data = (void *)BMP180_CHIP_ID },
+       { .compatible = "bosch,bmp085", .data = (void *)BMP180_CHIP_ID },
+       { },
+};
+MODULE_DEVICE_TABLE(of, bmp280_of_match);
+#else
+#define bmp280_of_match NULL
+#endif
+
 static const struct i2c_device_id bmp280_id[] = {
        {"bmp280", BMP280_CHIP_ID },
        {"bmp180", BMP180_CHIP_ID },
@@ -1107,6 +1121,7 @@ static struct i2c_driver bmp280_driver = {
        .driver = {
                .name   = "bmp280",
                .acpi_match_table = ACPI_PTR(bmp280_acpi_match),
+               .of_match_table = of_match_ptr(bmp280_of_match),
        },
        .probe          = bmp280_probe,
        .id_table       = bmp280_id,