1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <linux/device.h>
20#include <linux/mod_devicetable.h>
21#include <linux/module.h>
22#include <linux/acpi.h>
23#include <linux/regmap.h>
24#include <linux/spi/spi.h>
25
26#include "bmc150-accel.h"
27
28static int bmc150_accel_probe(struct spi_device *spi)
29{
30 struct regmap *regmap;
31 const struct spi_device_id *id = spi_get_device_id(spi);
32
33 regmap = devm_regmap_init_spi(spi, &bmc150_regmap_conf);
34 if (IS_ERR(regmap)) {
35 dev_err(&spi->dev, "Failed to initialize spi regmap\n");
36 return PTR_ERR(regmap);
37 }
38
39 return bmc150_accel_core_probe(&spi->dev, regmap, spi->irq, id->name,
40 true);
41}
42
43static int bmc150_accel_remove(struct spi_device *spi)
44{
45 return bmc150_accel_core_remove(&spi->dev);
46}
47
48static const struct acpi_device_id bmc150_accel_acpi_match[] = {
49 {"BSBA0150", bmc150},
50 {"BMC150A", bmc150},
51 {"BMI055A", bmi055},
52 {"BMA0255", bma255},
53 {"BMA250E", bma250e},
54 {"BMA222E", bma222e},
55 {"BMA0280", bma280},
56 { },
57};
58MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match);
59
60static const struct spi_device_id bmc150_accel_id[] = {
61 {"bmc150_accel", bmc150},
62 {"bmi055_accel", bmi055},
63 {"bma255", bma255},
64 {"bma250e", bma250e},
65 {"bma222e", bma222e},
66 {"bma280", bma280},
67 {}
68};
69MODULE_DEVICE_TABLE(spi, bmc150_accel_id);
70
71static struct spi_driver bmc150_accel_driver = {
72 .driver = {
73 .name = "bmc150_accel_spi",
74 .acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match),
75 .pm = &bmc150_accel_pm_ops,
76 },
77 .probe = bmc150_accel_probe,
78 .remove = bmc150_accel_remove,
79 .id_table = bmc150_accel_id,
80};
81module_spi_driver(bmc150_accel_driver);
82
83MODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>");
84MODULE_LICENSE("GPL v2");
85MODULE_DESCRIPTION("BMC150 SPI accelerometer driver");
86