1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 3 #include <linux/i2c.h> 4 #include <linux/iio/iio.h> 5 #include <linux/module.h> 6 #include <linux/mod_devicetable.h> 7 #include <linux/regmap.h> 8 9 #include "bmi270.h" 10 11 static const struct regmap_config bmi270_i2c_regmap_config = { 12 .reg_bits = 8, 13 .val_bits = 8, 14 }; 15 16 static int bmi270_i2c_probe(struct i2c_client *client) 17 { 18 struct regmap *regmap; 19 struct device *dev = &client->dev; 20 21 regmap = devm_regmap_init_i2c(client, &bmi270_i2c_regmap_config); 22 if (IS_ERR(regmap)) 23 return dev_err_probe(dev, PTR_ERR(regmap), 24 "Failed to init i2c regmap"); 25 26 return bmi270_core_probe(dev, regmap); 27 } 28 29 static const struct i2c_device_id bmi270_i2c_id[] = { 30 { "bmi270", 0 }, 31 { } 32 }; 33 34 static const struct of_device_id bmi270_of_match[] = { 35 { .compatible = "bosch,bmi270" }, 36 { } 37 }; 38 39 static struct i2c_driver bmi270_i2c_driver = { 40 .driver = { 41 .name = "bmi270_i2c", 42 .of_match_table = bmi270_of_match, 43 }, 44 .probe = bmi270_i2c_probe, 45 .id_table = bmi270_i2c_id, 46 }; 47 module_i2c_driver(bmi270_i2c_driver); 48 49 MODULE_AUTHOR("Alex Lanzano"); 50 MODULE_DESCRIPTION("BMI270 driver"); 51 MODULE_LICENSE("GPL"); 52 MODULE_IMPORT_NS(IIO_BMI270); 53