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; 110b0b7726SAngel Iglesias const struct bmp280_chip_info *chip_info; 1212491d35SAngel Iglesias const struct i2c_device_id *id = i2c_client_get_device_id(client); 1314e8015fSLinus Walleij 140b0b7726SAngel Iglesias chip_info = device_get_match_data(&client->dev); 150b0b7726SAngel Iglesias if (!chip_info) 160b0b7726SAngel Iglesias chip_info = (const struct bmp280_chip_info *) id->driver_data; 1714e8015fSLinus Walleij 180b0b7726SAngel 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, 260b0b7726SAngel 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[] = { 320b0b7726SAngel Iglesias { .compatible = "bosch,bmp085", .data = &bmp180_chip_info }, 330b0b7726SAngel Iglesias { .compatible = "bosch,bmp180", .data = &bmp180_chip_info }, 340b0b7726SAngel Iglesias { .compatible = "bosch,bmp280", .data = &bmp280_chip_info }, 350b0b7726SAngel Iglesias { .compatible = "bosch,bme280", .data = &bme280_chip_info }, 360b0b7726SAngel Iglesias { .compatible = "bosch,bmp380", .data = &bmp380_chip_info }, 37*597dfb2aSAngel Iglesias { .compatible = "bosch,bmp580", .data = &bmp580_chip_info }, 3814e8015fSLinus Walleij { }, 3914e8015fSLinus Walleij }; 4014e8015fSLinus Walleij MODULE_DEVICE_TABLE(of, bmp280_of_i2c_match); 4114e8015fSLinus Walleij 4214e8015fSLinus Walleij static const struct i2c_device_id bmp280_i2c_id[] = { 430b0b7726SAngel Iglesias {"bmp085", (kernel_ulong_t)&bmp180_chip_info }, 440b0b7726SAngel Iglesias {"bmp180", (kernel_ulong_t)&bmp180_chip_info }, 450b0b7726SAngel Iglesias {"bmp280", (kernel_ulong_t)&bmp280_chip_info }, 460b0b7726SAngel Iglesias {"bme280", (kernel_ulong_t)&bme280_chip_info }, 470b0b7726SAngel Iglesias {"bmp380", (kernel_ulong_t)&bmp380_chip_info }, 48*597dfb2aSAngel Iglesias {"bmp580", (kernel_ulong_t)&bmp580_chip_info }, 4914e8015fSLinus Walleij { }, 5014e8015fSLinus Walleij }; 5114e8015fSLinus Walleij MODULE_DEVICE_TABLE(i2c, bmp280_i2c_id); 5214e8015fSLinus Walleij 5314e8015fSLinus Walleij static struct i2c_driver bmp280_i2c_driver = { 5414e8015fSLinus Walleij .driver = { 5514e8015fSLinus Walleij .name = "bmp280", 56ae968599SAndy Shevchenko .of_match_table = bmp280_of_i2c_match, 575865918fSPaul Cercueil .pm = pm_ptr(&bmp280_dev_pm_ops), 5814e8015fSLinus Walleij }, 5912491d35SAngel Iglesias .probe_new = bmp280_i2c_probe, 6014e8015fSLinus Walleij .id_table = bmp280_i2c_id, 6114e8015fSLinus Walleij }; 6214e8015fSLinus Walleij module_i2c_driver(bmp280_i2c_driver); 6314e8015fSLinus Walleij 6414e8015fSLinus Walleij MODULE_AUTHOR("Vlad Dogaru <vlad.dogaru@intel.com>"); 6514e8015fSLinus Walleij MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor"); 6614e8015fSLinus Walleij MODULE_LICENSE("GPL v2"); 670f26b9dbSJonathan Cameron MODULE_IMPORT_NS(IIO_BMP280); 68