1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/module.h>
4 #include <linux/regmap.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
) {
16 regmap_config
= &bmp180_regmap_config
;
20 regmap_config
= &bmp280_regmap_config
;
26 regmap
= devm_regmap_init_i2c(client
, regmap_config
);
28 dev_err(&client
->dev
, "failed to allocate register map\n");
29 return PTR_ERR(regmap
);
32 return bmp280_common_probe(&client
->dev
,
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
},
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
},
55 MODULE_DEVICE_TABLE(i2c
, bmp280_i2c_id
);
57 static struct i2c_driver bmp280_i2c_driver
= {
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");