18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * BMI160 - Bosch IMU, SPI bits 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2016, Intel Corporation. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#include <linux/acpi.h> 98c2ecf20Sopenharmony_ci#include <linux/module.h> 108c2ecf20Sopenharmony_ci#include <linux/of.h> 118c2ecf20Sopenharmony_ci#include <linux/regmap.h> 128c2ecf20Sopenharmony_ci#include <linux/spi/spi.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include "bmi160.h" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_cistatic int bmi160_spi_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, &bmi160_regmap_config); 228c2ecf20Sopenharmony_ci if (IS_ERR(regmap)) { 238c2ecf20Sopenharmony_ci dev_err(&spi->dev, "Failed to register spi regmap: %pe\n", 248c2ecf20Sopenharmony_ci regmap); 258c2ecf20Sopenharmony_ci return PTR_ERR(regmap); 268c2ecf20Sopenharmony_ci } 278c2ecf20Sopenharmony_ci return bmi160_core_probe(&spi->dev, regmap, id->name, true); 288c2ecf20Sopenharmony_ci} 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic const struct spi_device_id bmi160_spi_id[] = { 318c2ecf20Sopenharmony_ci {"bmi160", 0}, 328c2ecf20Sopenharmony_ci {} 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(spi, bmi160_spi_id); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic const struct acpi_device_id bmi160_acpi_match[] = { 378c2ecf20Sopenharmony_ci {"BMI0160", 0}, 388c2ecf20Sopenharmony_ci { }, 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(acpi, bmi160_acpi_match); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#ifdef CONFIG_OF 438c2ecf20Sopenharmony_cistatic const struct of_device_id bmi160_of_match[] = { 448c2ecf20Sopenharmony_ci { .compatible = "bosch,bmi160" }, 458c2ecf20Sopenharmony_ci { }, 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, bmi160_of_match); 488c2ecf20Sopenharmony_ci#endif 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistatic struct spi_driver bmi160_spi_driver = { 518c2ecf20Sopenharmony_ci .probe = bmi160_spi_probe, 528c2ecf20Sopenharmony_ci .id_table = bmi160_spi_id, 538c2ecf20Sopenharmony_ci .driver = { 548c2ecf20Sopenharmony_ci .acpi_match_table = ACPI_PTR(bmi160_acpi_match), 558c2ecf20Sopenharmony_ci .of_match_table = of_match_ptr(bmi160_of_match), 568c2ecf20Sopenharmony_ci .name = "bmi160_spi", 578c2ecf20Sopenharmony_ci }, 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_cimodule_spi_driver(bmi160_spi_driver); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciMODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com"); 628c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Bosch BMI160 SPI driver"); 638c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 64