Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / iio / imu / bmi270 / bmi270_i2c.c
blob44699ab589097eaa0eec5f2172245496ed031185
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
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>
9 #include "bmi270.h"
11 static const struct regmap_config bmi270_i2c_regmap_config = {
12 .reg_bits = 8,
13 .val_bits = 8,
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);
23 if (!chip_info)
24 return -ENODEV;
26 regmap = devm_regmap_init_i2c(client, &bmi270_i2c_regmap_config);
27 if (IS_ERR(regmap))
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 },
37 { }
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 },
43 { }
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 },
49 { }
52 static struct i2c_driver bmi270_i2c_driver = {
53 .driver = {
54 .name = "bmi270_i2c",
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");