WIP FPC-III support
[linux/fpc-iii.git] / drivers / iio / pressure / bmp280-i2c.c
blob8b03ea15c0d08c3602f97db80616bd228ba1a97c
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/module.h>
3 #include <linux/i2c.h>
4 #include <linux/regmap.h>
6 #include "bmp280.h"
8 static int bmp280_i2c_probe(struct i2c_client *client,
9 const struct i2c_device_id *id)
11 struct regmap *regmap;
12 const struct regmap_config *regmap_config;
14 switch (id->driver_data) {
15 case BMP180_CHIP_ID:
16 regmap_config = &bmp180_regmap_config;
17 break;
18 case BMP280_CHIP_ID:
19 case BME280_CHIP_ID:
20 regmap_config = &bmp280_regmap_config;
21 break;
22 default:
23 return -EINVAL;
26 regmap = devm_regmap_init_i2c(client, regmap_config);
27 if (IS_ERR(regmap)) {
28 dev_err(&client->dev, "failed to allocate register map\n");
29 return PTR_ERR(regmap);
32 return bmp280_common_probe(&client->dev,
33 regmap,
34 id->driver_data,
35 id->name,
36 client->irq);
39 static const struct of_device_id bmp280_of_i2c_match[] = {
40 { .compatible = "bosch,bme280", .data = (void *)BME280_CHIP_ID },
41 { .compatible = "bosch,bmp280", .data = (void *)BMP280_CHIP_ID },
42 { .compatible = "bosch,bmp180", .data = (void *)BMP180_CHIP_ID },
43 { .compatible = "bosch,bmp085", .data = (void *)BMP180_CHIP_ID },
44 { },
46 MODULE_DEVICE_TABLE(of, bmp280_of_i2c_match);
48 static const struct i2c_device_id bmp280_i2c_id[] = {
49 {"bmp280", BMP280_CHIP_ID },
50 {"bmp180", BMP180_CHIP_ID },
51 {"bmp085", BMP180_CHIP_ID },
52 {"bme280", BME280_CHIP_ID },
53 { },
55 MODULE_DEVICE_TABLE(i2c, bmp280_i2c_id);
57 static struct i2c_driver bmp280_i2c_driver = {
58 .driver = {
59 .name = "bmp280",
60 .of_match_table = bmp280_of_i2c_match,
61 .pm = &bmp280_dev_pm_ops,
63 .probe = bmp280_i2c_probe,
64 .id_table = bmp280_i2c_id,
66 module_i2c_driver(bmp280_i2c_driver);
68 MODULE_AUTHOR("Vlad Dogaru <vlad.dogaru@intel.com>");
69 MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor");
70 MODULE_LICENSE("GPL v2");