1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * BME680 - I2C Driver 4 * 5 * Copyright (C) 2018 Himanshu Jha <himanshujha199640@gmail.com> 6 * 7 * 7-Bit I2C slave address is: 8 * - 0x76 if SDO is pulled to GND 9 * - 0x77 if SDO is pulled to VDDIO 10 * 11 * Note: SDO pin cannot be left floating otherwise I2C address 12 * will be undefined. 13 */ 14 #include <linux/acpi.h> 15 #include <linux/i2c.h> 16 #include <linux/module.h> 17 #include <linux/regmap.h> 18 19 #include "bme680.h" 20 21 static int bme680_i2c_probe(struct i2c_client *client, 22 const struct i2c_device_id *id) 23 { 24 struct regmap *regmap; 25 const char *name = NULL; 26 27 regmap = devm_regmap_init_i2c(client, &bme680_regmap_config); 28 if (IS_ERR(regmap)) { 29 dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap)); 30 return PTR_ERR(regmap); 31 } 32 33 if (id) 34 name = id->name; 35 36 return bme680_core_probe(&client->dev, regmap, name); 37 } 38 39 static const struct i2c_device_id bme680_i2c_id[] = { 40 {"bme680", 0}, 41 {}, 42 }; 43 MODULE_DEVICE_TABLE(i2c, bme680_i2c_id); 44 45 static const struct acpi_device_id bme680_acpi_match[] = { 46 {"BME0680", 0}, 47 {}, 48 }; 49 MODULE_DEVICE_TABLE(acpi, bme680_acpi_match); 50 51 static const struct of_device_id bme680_of_i2c_match[] = { 52 { .compatible = "bosch,bme680", }, 53 {}, 54 }; 55 MODULE_DEVICE_TABLE(of, bme680_of_i2c_match); 56 57 static struct i2c_driver bme680_i2c_driver = { 58 .driver = { 59 .name = "bme680_i2c", 60 .acpi_match_table = ACPI_PTR(bme680_acpi_match), 61 .of_match_table = bme680_of_i2c_match, 62 }, 63 .probe = bme680_i2c_probe, 64 .id_table = bme680_i2c_id, 65 }; 66 module_i2c_driver(bme680_i2c_driver); 67 68 MODULE_AUTHOR("Himanshu Jha <himanshujha199640@gmail.com>"); 69 MODULE_DESCRIPTION("BME680 I2C driver"); 70 MODULE_LICENSE("GPL v2"); 71