blob: 11559567cb398dcfaee86e05ff6a1f0eba2c4218 [file] [log] [blame]
Thomas Gleixner1ccea772019-05-19 15:51:43 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Markus Pargmannf9ab96e2015-09-21 12:55:16 +02002/*
3 * 3-axis accelerometer driver supporting SPI Bosch-Sensortec accelerometer chip
4 * Copyright © 2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de>
Markus Pargmannf9ab96e2015-09-21 12:55:16 +02005 */
6
7#include <linux/device.h>
8#include <linux/mod_devicetable.h>
9#include <linux/module.h>
10#include <linux/acpi.h>
11#include <linux/regmap.h>
12#include <linux/spi/spi.h>
13
14#include "bmc150-accel.h"
15
Markus Pargmannf9ab96e2015-09-21 12:55:16 +020016static int bmc150_accel_probe(struct spi_device *spi)
17{
18 struct regmap *regmap;
Stephan Gerhold52ae7c72021-08-02 17:56:57 +020019 const char *name = NULL;
20 enum bmc150_type type = BOSCH_UNKNOWN;
Markus Pargmannf9ab96e2015-09-21 12:55:16 +020021 const struct spi_device_id *id = spi_get_device_id(spi);
22
Irina Tirdea486294f2016-03-29 15:21:21 +030023 regmap = devm_regmap_init_spi(spi, &bmc150_regmap_conf);
Markus Pargmannf9ab96e2015-09-21 12:55:16 +020024 if (IS_ERR(regmap)) {
25 dev_err(&spi->dev, "Failed to initialize spi regmap\n");
26 return PTR_ERR(regmap);
27 }
28
Stephan Gerhold52ae7c72021-08-02 17:56:57 +020029 if (id) {
30 name = id->name;
31 type = id->driver_data;
32 }
33
34 return bmc150_accel_core_probe(&spi->dev, regmap, spi->irq, type, name,
Markus Pargmannf9ab96e2015-09-21 12:55:16 +020035 true);
36}
37
38static int bmc150_accel_remove(struct spi_device *spi)
39{
Uwe Kleine-König97139642021-10-13 22:32:10 +020040 bmc150_accel_core_remove(&spi->dev);
41
42 return 0;
Markus Pargmannf9ab96e2015-09-21 12:55:16 +020043}
44
45static const struct acpi_device_id bmc150_accel_acpi_match[] = {
Stephan Gerholdc06a6ab2021-06-11 10:08:56 +020046 {"BMA0255"},
Stephan Gerhold88e63ce2021-06-11 10:08:58 +020047 {"BMA0280"},
Stephan Gerholdc06a6ab2021-06-11 10:08:56 +020048 {"BMA222"},
49 {"BMA222E"},
Stephan Gerhold88e63ce2021-06-11 10:08:58 +020050 {"BMA250E"},
51 {"BMC150A"},
52 {"BMI055A"},
53 {"BSBA0150"},
Markus Pargmannf9ab96e2015-09-21 12:55:16 +020054 { },
55};
56MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match);
57
58static const struct spi_device_id bmc150_accel_id[] = {
Stephan Gerholdc06a6ab2021-06-11 10:08:56 +020059 {"bma222"},
60 {"bma222e"},
Stephan Gerhold88e63ce2021-06-11 10:08:58 +020061 {"bma250e"},
Stephan Gerhold49e95c62021-06-11 10:09:00 +020062 {"bma253"},
Stephan Gerhold88e63ce2021-06-11 10:08:58 +020063 {"bma255"},
Stephan Gerholdc06a6ab2021-06-11 10:08:56 +020064 {"bma280"},
Stephan Gerhold88e63ce2021-06-11 10:08:58 +020065 {"bmc150_accel"},
Stephan Gerhold52ae7c72021-08-02 17:56:57 +020066 {"bmc156_accel", BOSCH_BMC156},
Stephan Gerhold88e63ce2021-06-11 10:08:58 +020067 {"bmi055_accel"},
Markus Pargmannf9ab96e2015-09-21 12:55:16 +020068 {}
69};
70MODULE_DEVICE_TABLE(spi, bmc150_accel_id);
71
72static struct spi_driver bmc150_accel_driver = {
73 .driver = {
74 .name = "bmc150_accel_spi",
75 .acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match),
76 .pm = &bmc150_accel_pm_ops,
77 },
78 .probe = bmc150_accel_probe,
79 .remove = bmc150_accel_remove,
80 .id_table = bmc150_accel_id,
81};
82module_spi_driver(bmc150_accel_driver);
83
84MODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>");
85MODULE_LICENSE("GPL v2");
86MODULE_DESCRIPTION("BMC150 SPI accelerometer driver");