bmi160_spi.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/module.h>
  11. #include <linux/spi/spi.h>
  12. #include <linux/regmap.h>
  13. #include <linux/acpi.h>
  14. #include "bmi160.h"
  15. static int bmi160_spi_probe(struct spi_device *spi)
  16. {
  17. struct regmap *regmap;
  18. const struct spi_device_id *id = spi_get_device_id(spi);
  19. regmap = devm_regmap_init_spi(spi, &bmi160_regmap_config);
  20. if (IS_ERR(regmap)) {
  21. dev_err(&spi->dev, "Failed to register spi regmap %d\n",
  22. (int)PTR_ERR(regmap));
  23. return PTR_ERR(regmap);
  24. }
  25. return bmi160_core_probe(&spi->dev, regmap, id->name, true);
  26. }
  27. static int bmi160_spi_remove(struct spi_device *spi)
  28. {
  29. bmi160_core_remove(&spi->dev);
  30. return 0;
  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. static const struct acpi_device_id bmi160_acpi_match[] = {
  38. {"BMI0160", 0},
  39. { },
  40. };
  41. MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
  42. static struct spi_driver bmi160_spi_driver = {
  43. .probe = bmi160_spi_probe,
  44. .remove = bmi160_spi_remove,
  45. .id_table = bmi160_spi_id,
  46. .driver = {
  47. .acpi_match_table = ACPI_PTR(bmi160_acpi_match),
  48. .name = "bmi160_spi",
  49. },
  50. };
  51. module_spi_driver(bmi160_spi_driver);
  52. MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
  53. MODULE_DESCRIPTION("Bosch BMI160 SPI driver");
  54. MODULE_LICENSE("GPL v2");