Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at master 64 lines 1.6 kB view raw
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/i2c.h> 15#include <linux/module.h> 16#include <linux/regmap.h> 17 18#include "bme680.h" 19 20static int bme680_i2c_probe(struct i2c_client *client) 21{ 22 const struct i2c_device_id *id = i2c_client_get_device_id(client); 23 struct regmap *regmap; 24 const char *name = NULL; 25 26 regmap = devm_regmap_init_i2c(client, &bme680_regmap_config); 27 if (IS_ERR(regmap)) { 28 dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap)); 29 return PTR_ERR(regmap); 30 } 31 32 if (id) 33 name = id->name; 34 35 return bme680_core_probe(&client->dev, regmap, name); 36} 37 38static const struct i2c_device_id bme680_i2c_id[] = { 39 { "bme680" }, 40 { } 41}; 42MODULE_DEVICE_TABLE(i2c, bme680_i2c_id); 43 44static const struct of_device_id bme680_of_i2c_match[] = { 45 { .compatible = "bosch,bme680", }, 46 { } 47}; 48MODULE_DEVICE_TABLE(of, bme680_of_i2c_match); 49 50static struct i2c_driver bme680_i2c_driver = { 51 .driver = { 52 .name = "bme680_i2c", 53 .of_match_table = bme680_of_i2c_match, 54 .pm = pm_ptr(&bme680_dev_pm_ops), 55 }, 56 .probe = bme680_i2c_probe, 57 .id_table = bme680_i2c_id, 58}; 59module_i2c_driver(bme680_i2c_driver); 60 61MODULE_AUTHOR("Himanshu Jha <himanshujha199640@gmail.com>"); 62MODULE_DESCRIPTION("BME680 I2C driver"); 63MODULE_LICENSE("GPL v2"); 64MODULE_IMPORT_NS("IIO_BME680");