mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-23 11:04:44 +08:00
52ae7c708d
BMC156 is another accelerometer that works just fine with the bmc150-accel
driver. It's very similar to BMC150 (also a accelerometer + magnetometer
combo) but with only one accelerometer interrupt pin. It would make sense
if only INT1 was exposed but someone at Bosch decided to only have an
INT2 pin.
Try to deal with this by making use of the INT2 support introduced
in the previous commit and force using INT2 for BMC156. To detect
that we need to bring up a simplified version of the previous type IDs.
Note that unlike the type IDs removed in commit c06a6aba68
("iio: accel: bmc150: Drop misleading/duplicate chip identifiers")
here I only add one for the special case of BMC156. Everything else
still happens by reading the CHIP_ID register since the chip type
information often is not accurate in ACPI tables.
Tested-by: Nikita Travkin <nikita@trvn.ru> # BMC156
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20210802155657.102766-5-stephan@gerhold.net
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
85 lines
1.9 KiB
C
85 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* 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/acpi.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;
|
|
const char *name = NULL;
|
|
enum bmc150_type type = BOSCH_UNKNOWN;
|
|
const struct spi_device_id *id = spi_get_device_id(spi);
|
|
|
|
regmap = devm_regmap_init_spi(spi, &bmc150_regmap_conf);
|
|
if (IS_ERR(regmap)) {
|
|
dev_err(&spi->dev, "Failed to initialize spi regmap\n");
|
|
return PTR_ERR(regmap);
|
|
}
|
|
|
|
if (id) {
|
|
name = id->name;
|
|
type = id->driver_data;
|
|
}
|
|
|
|
return bmc150_accel_core_probe(&spi->dev, regmap, spi->irq, type, name,
|
|
true);
|
|
}
|
|
|
|
static int bmc150_accel_remove(struct spi_device *spi)
|
|
{
|
|
return bmc150_accel_core_remove(&spi->dev);
|
|
}
|
|
|
|
static const struct acpi_device_id bmc150_accel_acpi_match[] = {
|
|
{"BMA0255"},
|
|
{"BMA0280"},
|
|
{"BMA222"},
|
|
{"BMA222E"},
|
|
{"BMA250E"},
|
|
{"BMC150A"},
|
|
{"BMI055A"},
|
|
{"BSBA0150"},
|
|
{ },
|
|
};
|
|
MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match);
|
|
|
|
static const struct spi_device_id bmc150_accel_id[] = {
|
|
{"bma222"},
|
|
{"bma222e"},
|
|
{"bma250e"},
|
|
{"bma253"},
|
|
{"bma255"},
|
|
{"bma280"},
|
|
{"bmc150_accel"},
|
|
{"bmc156_accel", BOSCH_BMC156},
|
|
{"bmi055_accel"},
|
|
{}
|
|
};
|
|
MODULE_DEVICE_TABLE(spi, bmc150_accel_id);
|
|
|
|
static struct spi_driver bmc150_accel_driver = {
|
|
.driver = {
|
|
.name = "bmc150_accel_spi",
|
|
.acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match),
|
|
.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");
|