1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * 3-axis accelerometer driver supporting SPI Bosch-Sensortec accelerometer chip 4 * Copyright © 2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de> 5 */ 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 16 static int bmc150_accel_probe(struct spi_device *spi) 17 { 18 struct regmap *regmap; 19 const struct spi_device_id *id = spi_get_device_id(spi); 20 21 regmap = devm_regmap_init_spi(spi, &bmc150_regmap_conf); 22 if (IS_ERR(regmap)) { 23 dev_err(&spi->dev, "Failed to initialize spi regmap\n"); 24 return PTR_ERR(regmap); 25 } 26 27 return bmc150_accel_core_probe(&spi->dev, regmap, spi->irq, id->name, 28 true); 29 } 30 31 static int bmc150_accel_remove(struct spi_device *spi) 32 { 33 return bmc150_accel_core_remove(&spi->dev); 34 } 35 36 static const struct acpi_device_id bmc150_accel_acpi_match[] = { 37 {"BSBA0150", bmc150}, 38 {"BMC150A", bmc150}, 39 {"BMI055A", bmi055}, 40 {"BMA0255", bma255}, 41 {"BMA250E", bma250e}, 42 {"BMA222", bma222}, 43 {"BMA222E", bma222e}, 44 {"BMA0280", bma280}, 45 { }, 46 }; 47 MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match); 48 49 static const struct spi_device_id bmc150_accel_id[] = { 50 {"bmc150_accel", bmc150}, 51 {"bmi055_accel", bmi055}, 52 {"bma255", bma255}, 53 {"bma250e", bma250e}, 54 {"bma222", bma222}, 55 {"bma222e", bma222e}, 56 {"bma280", bma280}, 57 {} 58 }; 59 MODULE_DEVICE_TABLE(spi, bmc150_accel_id); 60 61 static struct spi_driver bmc150_accel_driver = { 62 .driver = { 63 .name = "bmc150_accel_spi", 64 .acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match), 65 .pm = &bmc150_accel_pm_ops, 66 }, 67 .probe = bmc150_accel_probe, 68 .remove = bmc150_accel_remove, 69 .id_table = bmc150_accel_id, 70 }; 71 module_spi_driver(bmc150_accel_driver); 72 73 MODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>"); 74 MODULE_LICENSE("GPL v2"); 75 MODULE_DESCRIPTION("BMC150 SPI accelerometer driver"); 76