1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * BMA220 Digital triaxial acceleration sensor driver
4 *
5 * Copyright (c) 2016,2020 Intel Corporation.
6 */
7
8 #include <linux/mod_devicetable.h>
9 #include <linux/module.h>
10 #include <linux/regmap.h>
11 #include <linux/types.h>
12 #include <linux/spi/spi.h>
13
14 #include "bma220.h"
15
bma220_spi_probe(struct spi_device * spi)16 static int bma220_spi_probe(struct spi_device *spi)
17 {
18 struct regmap *regmap;
19
20 regmap = devm_regmap_init_spi(spi, &bma220_spi_regmap_config);
21 if (IS_ERR(regmap))
22 return dev_err_probe(&spi->dev, PTR_ERR(regmap),
23 "failed to create regmap\n");
24
25 return bma220_common_probe(&spi->dev, regmap, spi->irq);
26 }
27
28 static const struct spi_device_id bma220_spi_id[] = {
29 { "bma220", 0 },
30 { }
31 };
32
33 static const struct acpi_device_id bma220_acpi_id[] = {
34 { "BMA0220", 0 },
35 { }
36 };
37 MODULE_DEVICE_TABLE(spi, bma220_spi_id);
38
39 static const struct of_device_id bma220_of_spi_match[] = {
40 { .compatible = "bosch,bma220" },
41 { }
42 };
43 MODULE_DEVICE_TABLE(of, bma220_of_spi_match);
44
45 static struct spi_driver bma220_spi_driver = {
46 .driver = {
47 .name = "bma220_spi",
48 .pm = pm_sleep_ptr(&bma220_pm_ops),
49 .of_match_table = bma220_of_spi_match,
50 .acpi_match_table = bma220_acpi_id,
51 },
52 .probe = bma220_spi_probe,
53 .id_table = bma220_spi_id,
54 };
55 module_spi_driver(bma220_spi_driver);
56
57 MODULE_AUTHOR("Tiberiu Breana <tiberiu.a.breana@intel.com>");
58 MODULE_DESCRIPTION("BMA220 triaxial acceleration sensor spi driver");
59 MODULE_LICENSE("GPL");
60 MODULE_IMPORT_NS("IIO_BOSCH_BMA220");
61