1
2
3
4
5
6
7
8
9
10
11#include <linux/acpi.h>
12#include <linux/i2c.h>
13#include <linux/module.h>
14#include <linux/of.h>
15#include <linux/regmap.h>
16
17#include "bmi160.h"
18
19static int bmi160_i2c_probe(struct i2c_client *client,
20 const struct i2c_device_id *id)
21{
22 struct regmap *regmap;
23 const char *name = NULL;
24
25 regmap = devm_regmap_init_i2c(client, &bmi160_regmap_config);
26 if (IS_ERR(regmap)) {
27 dev_err(&client->dev, "Failed to register i2c regmap: %pe\n",
28 regmap);
29 return PTR_ERR(regmap);
30 }
31
32 if (id)
33 name = id->name;
34
35 return bmi160_core_probe(&client->dev, regmap, name, false);
36}
37
38static const struct i2c_device_id bmi160_i2c_id[] = {
39 {"bmi160", 0},
40 {}
41};
42MODULE_DEVICE_TABLE(i2c, bmi160_i2c_id);
43
44static const struct acpi_device_id bmi160_acpi_match[] = {
45 {"BMI0160", 0},
46 { },
47};
48MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
49
50#ifdef CONFIG_OF
51static const struct of_device_id bmi160_of_match[] = {
52 { .compatible = "bosch,bmi160" },
53 { },
54};
55MODULE_DEVICE_TABLE(of, bmi160_of_match);
56#endif
57
58static struct i2c_driver bmi160_i2c_driver = {
59 .driver = {
60 .name = "bmi160_i2c",
61 .acpi_match_table = ACPI_PTR(bmi160_acpi_match),
62 .of_match_table = of_match_ptr(bmi160_of_match),
63 },
64 .probe = bmi160_i2c_probe,
65 .id_table = bmi160_i2c_id,
66};
67module_i2c_driver(bmi160_i2c_driver);
68
69MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
70MODULE_DESCRIPTION("BMI160 I2C driver");
71MODULE_LICENSE("GPL v2");
72