fxos8700_spi.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * FXOS8700 - NXP IMU, SPI bits
  4. */
  5. #include <linux/acpi.h>
  6. #include <linux/module.h>
  7. #include <linux/mod_devicetable.h>
  8. #include <linux/regmap.h>
  9. #include <linux/spi/spi.h>
  10. #include "fxos8700.h"
  11. static int fxos8700_spi_probe(struct spi_device *spi)
  12. {
  13. struct regmap *regmap;
  14. const struct spi_device_id *id = spi_get_device_id(spi);
  15. regmap = devm_regmap_init_spi(spi, &fxos8700_regmap_config);
  16. if (IS_ERR(regmap)) {
  17. dev_err(&spi->dev, "Failed to register spi regmap %ld\n", PTR_ERR(regmap));
  18. return PTR_ERR(regmap);
  19. }
  20. return fxos8700_core_probe(&spi->dev, regmap, id->name, true);
  21. }
  22. static const struct spi_device_id fxos8700_spi_id[] = {
  23. {"fxos8700", 0},
  24. { }
  25. };
  26. MODULE_DEVICE_TABLE(spi, fxos8700_spi_id);
  27. static const struct acpi_device_id fxos8700_acpi_match[] = {
  28. {"FXOS8700", 0},
  29. { }
  30. };
  31. MODULE_DEVICE_TABLE(acpi, fxos8700_acpi_match);
  32. static const struct of_device_id fxos8700_of_match[] = {
  33. { .compatible = "nxp,fxos8700" },
  34. { }
  35. };
  36. MODULE_DEVICE_TABLE(of, fxos8700_of_match);
  37. static struct spi_driver fxos8700_spi_driver = {
  38. .probe = fxos8700_spi_probe,
  39. .id_table = fxos8700_spi_id,
  40. .driver = {
  41. .acpi_match_table = ACPI_PTR(fxos8700_acpi_match),
  42. .of_match_table = fxos8700_of_match,
  43. .name = "fxos8700_spi",
  44. },
  45. };
  46. module_spi_driver(fxos8700_spi_driver);
  47. MODULE_AUTHOR("Robert Jones <[email protected]>");
  48. MODULE_DESCRIPTION("FXOS8700 SPI driver");
  49. MODULE_LICENSE("GPL v2");