18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 3-axis accelerometer driver supporting SPI Bosch-Sensortec accelerometer chip 48c2ecf20Sopenharmony_ci * Copyright © 2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/device.h> 88c2ecf20Sopenharmony_ci#include <linux/mod_devicetable.h> 98c2ecf20Sopenharmony_ci#include <linux/module.h> 108c2ecf20Sopenharmony_ci#include <linux/acpi.h> 118c2ecf20Sopenharmony_ci#include <linux/regmap.h> 128c2ecf20Sopenharmony_ci#include <linux/spi/spi.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include "bmc150-accel.h" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_cistatic int bmc150_accel_probe(struct spi_device *spi) 178c2ecf20Sopenharmony_ci{ 188c2ecf20Sopenharmony_ci struct regmap *regmap; 198c2ecf20Sopenharmony_ci const struct spi_device_id *id = spi_get_device_id(spi); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci regmap = devm_regmap_init_spi(spi, &bmc150_regmap_conf); 228c2ecf20Sopenharmony_ci if (IS_ERR(regmap)) { 238c2ecf20Sopenharmony_ci dev_err(&spi->dev, "Failed to initialize spi regmap\n"); 248c2ecf20Sopenharmony_ci return PTR_ERR(regmap); 258c2ecf20Sopenharmony_ci } 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci return bmc150_accel_core_probe(&spi->dev, regmap, spi->irq, id->name, 288c2ecf20Sopenharmony_ci true); 298c2ecf20Sopenharmony_ci} 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistatic int bmc150_accel_remove(struct spi_device *spi) 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci return bmc150_accel_core_remove(&spi->dev); 348c2ecf20Sopenharmony_ci} 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic const struct acpi_device_id bmc150_accel_acpi_match[] = { 378c2ecf20Sopenharmony_ci {"BSBA0150", bmc150}, 388c2ecf20Sopenharmony_ci {"BMC150A", bmc150}, 398c2ecf20Sopenharmony_ci {"BMI055A", bmi055}, 408c2ecf20Sopenharmony_ci {"BMA0255", bma255}, 418c2ecf20Sopenharmony_ci {"BMA250E", bma250e}, 428c2ecf20Sopenharmony_ci {"BMA222E", bma222e}, 438c2ecf20Sopenharmony_ci {"BMA0280", bma280}, 448c2ecf20Sopenharmony_ci { }, 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic const struct spi_device_id bmc150_accel_id[] = { 498c2ecf20Sopenharmony_ci {"bmc150_accel", bmc150}, 508c2ecf20Sopenharmony_ci {"bmi055_accel", bmi055}, 518c2ecf20Sopenharmony_ci {"bma255", bma255}, 528c2ecf20Sopenharmony_ci {"bma250e", bma250e}, 538c2ecf20Sopenharmony_ci {"bma222e", bma222e}, 548c2ecf20Sopenharmony_ci {"bma280", bma280}, 558c2ecf20Sopenharmony_ci {} 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(spi, bmc150_accel_id); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic struct spi_driver bmc150_accel_driver = { 608c2ecf20Sopenharmony_ci .driver = { 618c2ecf20Sopenharmony_ci .name = "bmc150_accel_spi", 628c2ecf20Sopenharmony_ci .acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match), 638c2ecf20Sopenharmony_ci .pm = &bmc150_accel_pm_ops, 648c2ecf20Sopenharmony_ci }, 658c2ecf20Sopenharmony_ci .probe = bmc150_accel_probe, 668c2ecf20Sopenharmony_ci .remove = bmc150_accel_remove, 678c2ecf20Sopenharmony_ci .id_table = bmc150_accel_id, 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_cimodule_spi_driver(bmc150_accel_driver); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciMODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>"); 728c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 738c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("BMC150 SPI accelerometer driver"); 74