109c434b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 214e8015fSLinus Walleij #include <linux/module.h> 314e8015fSLinus Walleij #include <linux/i2c.h> 414e8015fSLinus Walleij #include <linux/regmap.h> 514e8015fSLinus Walleij 614e8015fSLinus Walleij #include "bmp280.h" 714e8015fSLinus Walleij 812491d35SAngel Iglesias static int bmp280_i2c_probe(struct i2c_client *client) 914e8015fSLinus Walleij { 1014e8015fSLinus Walleij struct regmap *regmap; 11*0b0b7726SAngel Iglesias const struct bmp280_chip_info *chip_info; 1212491d35SAngel Iglesias const struct i2c_device_id *id = i2c_client_get_device_id(client); 1314e8015fSLinus Walleij 14*0b0b7726SAngel Iglesias chip_info = device_get_match_data(&client->dev); 15*0b0b7726SAngel Iglesias if (!chip_info) 16*0b0b7726SAngel Iglesias chip_info = (const struct bmp280_chip_info *) id->driver_data; 1714e8015fSLinus Walleij 18*0b0b7726SAngel Iglesias regmap = devm_regmap_init_i2c(client, chip_info->regmap_config); 1914e8015fSLinus Walleij if (IS_ERR(regmap)) { 2014e8015fSLinus Walleij dev_err(&client->dev, "failed to allocate register map\n"); 2114e8015fSLinus Walleij return PTR_ERR(regmap); 2214e8015fSLinus Walleij } 2314e8015fSLinus Walleij 2414e8015fSLinus Walleij return bmp280_common_probe(&client->dev, 2514e8015fSLinus Walleij regmap, 26*0b0b7726SAngel Iglesias chip_info, 27aae95394SLinus Walleij id->name, 28aae95394SLinus Walleij client->irq); 2914e8015fSLinus Walleij } 3014e8015fSLinus Walleij 3114e8015fSLinus Walleij static const struct of_device_id bmp280_of_i2c_match[] = { 32*0b0b7726SAngel Iglesias { .compatible = "bosch,bmp085", .data = &bmp180_chip_info }, 33*0b0b7726SAngel Iglesias { .compatible = "bosch,bmp180", .data = &bmp180_chip_info }, 34*0b0b7726SAngel Iglesias { .compatible = "bosch,bmp280", .data = &bmp280_chip_info }, 35*0b0b7726SAngel Iglesias { .compatible = "bosch,bme280", .data = &bme280_chip_info }, 36*0b0b7726SAngel Iglesias { .compatible = "bosch,bmp380", .data = &bmp380_chip_info }, 3714e8015fSLinus Walleij { }, 3814e8015fSLinus Walleij }; 3914e8015fSLinus Walleij MODULE_DEVICE_TABLE(of, bmp280_of_i2c_match); 4014e8015fSLinus Walleij 4114e8015fSLinus Walleij static const struct i2c_device_id bmp280_i2c_id[] = { 42*0b0b7726SAngel Iglesias {"bmp085", (kernel_ulong_t)&bmp180_chip_info }, 43*0b0b7726SAngel Iglesias {"bmp180", (kernel_ulong_t)&bmp180_chip_info }, 44*0b0b7726SAngel Iglesias {"bmp280", (kernel_ulong_t)&bmp280_chip_info }, 45*0b0b7726SAngel Iglesias {"bme280", (kernel_ulong_t)&bme280_chip_info }, 46*0b0b7726SAngel Iglesias {"bmp380", (kernel_ulong_t)&bmp380_chip_info }, 4714e8015fSLinus Walleij { }, 4814e8015fSLinus Walleij }; 4914e8015fSLinus Walleij MODULE_DEVICE_TABLE(i2c, bmp280_i2c_id); 5014e8015fSLinus Walleij 5114e8015fSLinus Walleij static struct i2c_driver bmp280_i2c_driver = { 5214e8015fSLinus Walleij .driver = { 5314e8015fSLinus Walleij .name = "bmp280", 54ae968599SAndy Shevchenko .of_match_table = bmp280_of_i2c_match, 555865918fSPaul Cercueil .pm = pm_ptr(&bmp280_dev_pm_ops), 5614e8015fSLinus Walleij }, 5712491d35SAngel Iglesias .probe_new = bmp280_i2c_probe, 5814e8015fSLinus Walleij .id_table = bmp280_i2c_id, 5914e8015fSLinus Walleij }; 6014e8015fSLinus Walleij module_i2c_driver(bmp280_i2c_driver); 6114e8015fSLinus Walleij 6214e8015fSLinus Walleij MODULE_AUTHOR("Vlad Dogaru <vlad.dogaru@intel.com>"); 6314e8015fSLinus Walleij MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor"); 6414e8015fSLinus Walleij MODULE_LICENSE("GPL v2"); 650f26b9dbSJonathan Cameron MODULE_IMPORT_NS(IIO_BMP280); 66