1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
4 #include <linux/iio/iio.h>
5 #include <linux/module.h>
6 #include <linux/mod_devicetable.h>
7 #include <linux/regmap.h>
11 static const struct regmap_config bmi270_i2c_regmap_config
= {
16 static int bmi270_i2c_probe(struct i2c_client
*client
)
18 struct regmap
*regmap
;
19 struct device
*dev
= &client
->dev
;
20 const struct bmi270_chip_info
*chip_info
;
22 chip_info
= i2c_get_match_data(client
);
26 regmap
= devm_regmap_init_i2c(client
, &bmi270_i2c_regmap_config
);
28 return dev_err_probe(dev
, PTR_ERR(regmap
),
29 "Failed to init i2c regmap");
31 return bmi270_core_probe(dev
, regmap
, chip_info
);
34 static const struct i2c_device_id bmi270_i2c_id
[] = {
35 { "bmi260", (kernel_ulong_t
)&bmi260_chip_info
},
36 { "bmi270", (kernel_ulong_t
)&bmi270_chip_info
},
40 static const struct acpi_device_id bmi270_acpi_match
[] = {
41 /* GPD Win Mini, Aya Neo AIR Pro, OXP Mini Pro, etc. */
42 { "BMI0160", (kernel_ulong_t
)&bmi260_chip_info
},
46 static const struct of_device_id bmi270_of_match
[] = {
47 { .compatible
= "bosch,bmi260", .data
= &bmi260_chip_info
},
48 { .compatible
= "bosch,bmi270", .data
= &bmi270_chip_info
},
52 static struct i2c_driver bmi270_i2c_driver
= {
55 .acpi_match_table
= bmi270_acpi_match
,
56 .of_match_table
= bmi270_of_match
,
58 .probe
= bmi270_i2c_probe
,
59 .id_table
= bmi270_i2c_id
,
61 module_i2c_driver(bmi270_i2c_driver
);
63 MODULE_AUTHOR("Alex Lanzano");
64 MODULE_DESCRIPTION("BMI270 driver");
65 MODULE_LICENSE("GPL");
66 MODULE_IMPORT_NS("IIO_BMI270");