1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * 3-axis accelerometer driver supporting following Bosch-Sensortec chips: 4 * - BMI088 5 * - BMI085 6 * - BMI090L 7 * 8 * Copyright 2023 Jun Yan <jerrysteve1101@gmail.com> 9 */ 10 11 #include <linux/i2c.h> 12 #include <linux/mod_devicetable.h> 13 #include <linux/module.h> 14 #include <linux/regmap.h> 15 #include <linux/slab.h> 16 17 #include "bmi088-accel.h" 18 19 static int bmi088_accel_probe(struct i2c_client *i2c) 20 { 21 struct regmap *regmap; 22 const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 23 24 regmap = devm_regmap_init_i2c(i2c, &bmi088_regmap_conf); 25 if (IS_ERR(regmap)) { 26 dev_err(&i2c->dev, "Failed to initialize i2c regmap\n"); 27 return PTR_ERR(regmap); 28 } 29 30 return bmi088_accel_core_probe(&i2c->dev, regmap, i2c->irq, 31 id->driver_data); 32 } 33 34 static void bmi088_accel_remove(struct i2c_client *i2c) 35 { 36 bmi088_accel_core_remove(&i2c->dev); 37 } 38 39 static const struct of_device_id bmi088_of_match[] = { 40 { .compatible = "bosch,bmi085-accel" }, 41 { .compatible = "bosch,bmi088-accel" }, 42 { .compatible = "bosch,bmi090l-accel" }, 43 {} 44 }; 45 MODULE_DEVICE_TABLE(of, bmi088_of_match); 46 47 static const struct i2c_device_id bmi088_accel_id[] = { 48 { "bmi085-accel", BOSCH_BMI085 }, 49 { "bmi088-accel", BOSCH_BMI088 }, 50 { "bmi090l-accel", BOSCH_BMI090L }, 51 {} 52 }; 53 MODULE_DEVICE_TABLE(i2c, bmi088_accel_id); 54 55 static struct i2c_driver bmi088_accel_driver = { 56 .driver = { 57 .name = "bmi088_accel_i2c", 58 .pm = pm_ptr(&bmi088_accel_pm_ops), 59 .of_match_table = bmi088_of_match, 60 }, 61 .probe = bmi088_accel_probe, 62 .remove = bmi088_accel_remove, 63 .id_table = bmi088_accel_id, 64 }; 65 module_i2c_driver(bmi088_accel_driver); 66 67 MODULE_AUTHOR("Jun Yan <jerrysteve1101@gmail.com>"); 68 MODULE_LICENSE("GPL"); 69 MODULE_DESCRIPTION("BMI088 accelerometer driver (I2C)"); 70 MODULE_IMPORT_NS(IIO_BMI088); 71