1
2
3
4
5
6
7
8#include <linux/acpi.h>
9#include <linux/module.h>
10#include <linux/of.h>
11#include <linux/regmap.h>
12#include <linux/spi/spi.h>
13
14#include "bmi160.h"
15
16static int bmi160_spi_probe(struct spi_device *spi)
17{
18 struct regmap *regmap;
19 const struct spi_device_id *id = spi_get_device_id(spi);
20
21 regmap = devm_regmap_init_spi(spi, &bmi160_regmap_config);
22 if (IS_ERR(regmap)) {
23 dev_err(&spi->dev, "Failed to register spi regmap: %pe\n",
24 regmap);
25 return PTR_ERR(regmap);
26 }
27 return bmi160_core_probe(&spi->dev, regmap, id->name, true);
28}
29
30static const struct spi_device_id bmi160_spi_id[] = {
31 {"bmi160", 0},
32 {}
33};
34MODULE_DEVICE_TABLE(spi, bmi160_spi_id);
35
36static const struct acpi_device_id bmi160_acpi_match[] = {
37 {"BMI0160", 0},
38 { },
39};
40MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
41
42#ifdef CONFIG_OF
43static const struct of_device_id bmi160_of_match[] = {
44 { .compatible = "bosch,bmi160" },
45 { },
46};
47MODULE_DEVICE_TABLE(of, bmi160_of_match);
48#endif
49
50static struct spi_driver bmi160_spi_driver = {
51 .probe = bmi160_spi_probe,
52 .id_table = bmi160_spi_id,
53 .driver = {
54 .acpi_match_table = ACPI_PTR(bmi160_acpi_match),
55 .of_match_table = of_match_ptr(bmi160_of_match),
56 .name = "bmi160_spi",
57 },
58};
59module_spi_driver(bmi160_spi_driver);
60
61MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
62MODULE_DESCRIPTION("Bosch BMI160 SPI driver");
63MODULE_LICENSE("GPL v2");
64