2019-05-19 15:51:43 +02:00
// SPDX-License-Identifier: GPL-2.0-or-later
2015-09-21 12:55:16 +02: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/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 ;
2021-08-02 17:56:57 +02:00
const char * name = NULL ;
enum bmc150_type type = BOSCH_UNKNOWN ;
2015-09-21 12:55:16 +02:00
const struct spi_device_id * id = spi_get_device_id ( spi ) ;
2016-03-29 15:21:21 +03:00
regmap = devm_regmap_init_spi ( spi , & bmc150_regmap_conf ) ;
2015-09-21 12:55:16 +02:00
if ( IS_ERR ( regmap ) ) {
dev_err ( & spi - > dev , " Failed to initialize spi regmap \n " ) ;
return PTR_ERR ( regmap ) ;
}
2021-08-02 17:56:57 +02: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 12:55:16 +02:00
true ) ;
}
2022-01-23 18:52:01 +01:00
static void bmc150_accel_remove ( struct spi_device * spi )
2015-09-21 12:55:16 +02:00
{
2021-10-13 22:32:10 +02:00
bmc150_accel_core_remove ( & spi - > dev ) ;
2015-09-21 12:55:16 +02:00
}
static const struct acpi_device_id bmc150_accel_acpi_match [ ] = {
2021-06-11 10:08:56 +02:00
{ " BMA0255 " } ,
2021-06-11 10:08:58 +02:00
{ " BMA0280 " } ,
2021-06-11 10:08:56 +02:00
{ " BMA222 " } ,
{ " BMA222E " } ,
2021-06-11 10:08:58 +02:00
{ " BMA250E " } ,
{ " BMC150A " } ,
{ " BMI055A " } ,
{ " BSBA0150 " } ,
2015-09-21 12:55:16 +02:00
{ } ,
} ;
MODULE_DEVICE_TABLE ( acpi , bmc150_accel_acpi_match ) ;
static const struct spi_device_id bmc150_accel_id [ ] = {
2021-06-11 10:08:56 +02:00
{ " bma222 " } ,
{ " bma222e " } ,
2021-06-11 10:08:58 +02:00
{ " bma250e " } ,
2021-06-11 10:09:00 +02:00
{ " bma253 " } ,
2021-06-11 10:08:58 +02:00
{ " bma255 " } ,
2021-06-11 10:08:56 +02:00
{ " bma280 " } ,
2021-06-11 10:08:58 +02:00
{ " bmc150_accel " } ,
2021-08-02 17:56:57 +02:00
{ " bmc156_accel " , BOSCH_BMC156 } ,
2021-06-11 10:08:58 +02:00
{ " bmi055_accel " } ,
2015-09-21 12:55:16 +02:00
{ }
} ;
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 " ) ;
2022-01-16 18:05:31 +00:00
MODULE_IMPORT_NS ( IIO_BMC150 ) ;