2019-05-19 06:51:43 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-09-21 03:55:16 -07:00
|
|
|
/*
|
|
|
|
* 3-axis accelerometer driver supporting SPI Bosch-Sensortec accelerometer chip
|
|
|
|
* Copyright © 2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
#include <linux/spi/spi.h>
|
|
|
|
|
|
|
|
#include "bmc150-accel.h"
|
|
|
|
|
|
|
|
static int bmc150_accel_probe(struct spi_device *spi)
|
|
|
|
{
|
|
|
|
struct regmap *regmap;
|
2021-08-02 08:56:57 -07:00
|
|
|
const char *name = NULL;
|
|
|
|
enum bmc150_type type = BOSCH_UNKNOWN;
|
2015-09-21 03:55:16 -07:00
|
|
|
const struct spi_device_id *id = spi_get_device_id(spi);
|
|
|
|
|
2016-03-29 05:21:21 -07:00
|
|
|
regmap = devm_regmap_init_spi(spi, &bmc150_regmap_conf);
|
2015-09-21 03:55:16 -07:00
|
|
|
if (IS_ERR(regmap)) {
|
|
|
|
dev_err(&spi->dev, "Failed to initialize spi regmap\n");
|
|
|
|
return PTR_ERR(regmap);
|
|
|
|
}
|
|
|
|
|
2021-08-02 08:56:57 -07:00
|
|
|
if (id) {
|
|
|
|
name = id->name;
|
|
|
|
type = id->driver_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bmc150_accel_core_probe(&spi->dev, regmap, spi->irq, type, name,
|
2015-09-21 03:55:16 -07:00
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
2022-01-23 10:52:01 -07:00
|
|
|
static void bmc150_accel_remove(struct spi_device *spi)
|
2015-09-21 03:55:16 -07:00
|
|
|
{
|
2021-10-13 13:32:10 -07:00
|
|
|
bmc150_accel_core_remove(&spi->dev);
|
2015-09-21 03:55:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct acpi_device_id bmc150_accel_acpi_match[] = {
|
2021-06-11 01:08:56 -07:00
|
|
|
{"BMA0255"},
|
2021-06-11 01:08:58 -07:00
|
|
|
{"BMA0280"},
|
2021-06-11 01:08:56 -07:00
|
|
|
{"BMA222"},
|
|
|
|
{"BMA222E"},
|
2021-06-11 01:08:58 -07:00
|
|
|
{"BMA250E"},
|
|
|
|
{"BMC150A"},
|
|
|
|
{"BMI055A"},
|
|
|
|
{"BSBA0150"},
|
2015-09-21 03:55:16 -07:00
|
|
|
{ },
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match);
|
|
|
|
|
|
|
|
static const struct spi_device_id bmc150_accel_id[] = {
|
2021-06-11 01:08:56 -07:00
|
|
|
{"bma222"},
|
|
|
|
{"bma222e"},
|
2021-06-11 01:08:58 -07:00
|
|
|
{"bma250e"},
|
2021-06-11 01:09:00 -07:00
|
|
|
{"bma253"},
|
2021-06-11 01:08:58 -07:00
|
|
|
{"bma255"},
|
2021-06-11 01:08:56 -07:00
|
|
|
{"bma280"},
|
2021-06-11 01:08:58 -07:00
|
|
|
{"bmc150_accel"},
|
2021-08-02 08:56:57 -07:00
|
|
|
{"bmc156_accel", BOSCH_BMC156},
|
2021-06-11 01:08:58 -07:00
|
|
|
{"bmi055_accel"},
|
2015-09-21 03:55:16 -07:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(spi, bmc150_accel_id);
|
|
|
|
|
|
|
|
static struct spi_driver bmc150_accel_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "bmc150_accel_spi",
|
2023-12-31 11:34:58 -07:00
|
|
|
.acpi_match_table = bmc150_accel_acpi_match,
|
2015-09-21 03:55:16 -07:00
|
|
|
.pm = &bmc150_accel_pm_ops,
|
|
|
|
},
|
|
|
|
.probe = bmc150_accel_probe,
|
|
|
|
.remove = bmc150_accel_remove,
|
|
|
|
.id_table = bmc150_accel_id,
|
|
|
|
};
|
|
|
|
module_spi_driver(bmc150_accel_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>");
|
|
|
|
MODULE_LICENSE("GPL v2");
|
|
|
|
MODULE_DESCRIPTION("BMC150 SPI accelerometer driver");
|
2022-01-16 11:05:31 -07:00
|
|
|
MODULE_IMPORT_NS(IIO_BMC150);
|