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