1 /* 2 * BMI160 - Bosch IMU, SPI bits 3 * 4 * Copyright (c) 2016, Intel Corporation. 5 * 6 * This file is subject to the terms and conditions of version 2 of 7 * the GNU General Public License. See the file COPYING in the main 8 * directory of this archive for more details. 9 */ 10 #include <linux/acpi.h> 11 #include <linux/module.h> 12 #include <linux/of.h> 13 #include <linux/regmap.h> 14 #include <linux/spi/spi.h> 15 16 #include "bmi160.h" 17 18 static int bmi160_spi_probe(struct spi_device *spi) 19 { 20 struct regmap *regmap; 21 const struct spi_device_id *id = spi_get_device_id(spi); 22 23 regmap = devm_regmap_init_spi(spi, &bmi160_regmap_config); 24 if (IS_ERR(regmap)) { 25 dev_err(&spi->dev, "Failed to register spi regmap %d\n", 26 (int)PTR_ERR(regmap)); 27 return PTR_ERR(regmap); 28 } 29 return bmi160_core_probe(&spi->dev, regmap, id->name, true); 30 } 31 32 static const struct spi_device_id bmi160_spi_id[] = { 33 {"bmi160", 0}, 34 {} 35 }; 36 MODULE_DEVICE_TABLE(spi, bmi160_spi_id); 37 38 static const struct acpi_device_id bmi160_acpi_match[] = { 39 {"BMI0160", 0}, 40 { }, 41 }; 42 MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match); 43 44 #ifdef CONFIG_OF 45 static const struct of_device_id bmi160_of_match[] = { 46 { .compatible = "bosch,bmi160" }, 47 { }, 48 }; 49 MODULE_DEVICE_TABLE(of, bmi160_of_match); 50 #endif 51 52 static struct spi_driver bmi160_spi_driver = { 53 .probe = bmi160_spi_probe, 54 .id_table = bmi160_spi_id, 55 .driver = { 56 .acpi_match_table = ACPI_PTR(bmi160_acpi_match), 57 .of_match_table = of_match_ptr(bmi160_of_match), 58 .name = "bmi160_spi", 59 }, 60 }; 61 module_spi_driver(bmi160_spi_driver); 62 63 MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com"); 64 MODULE_DESCRIPTION("Bosch BMI160 SPI driver"); 65 MODULE_LICENSE("GPL v2"); 66