bmc150_magn_spi.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * 3-axis magnetometer driver support following SPI Bosch-Sensortec chips:
  4. * - BMC150
  5. * - BMC156
  6. * - BMM150
  7. *
  8. * Copyright (c) 2016, Intel Corporation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/mod_devicetable.h>
  12. #include <linux/spi/spi.h>
  13. #include <linux/acpi.h>
  14. #include <linux/regmap.h>
  15. #include "bmc150_magn.h"
  16. static int bmc150_magn_spi_probe(struct spi_device *spi)
  17. {
  18. struct regmap *regmap;
  19. const struct spi_device_id *id = spi_get_device_id(spi);
  20. regmap = devm_regmap_init_spi(spi, &bmc150_magn_regmap_config);
  21. if (IS_ERR(regmap)) {
  22. dev_err(&spi->dev, "Failed to register spi regmap: %pe\n",
  23. regmap);
  24. return PTR_ERR(regmap);
  25. }
  26. return bmc150_magn_probe(&spi->dev, regmap, spi->irq, id->name);
  27. }
  28. static void bmc150_magn_spi_remove(struct spi_device *spi)
  29. {
  30. bmc150_magn_remove(&spi->dev);
  31. }
  32. static const struct spi_device_id bmc150_magn_spi_id[] = {
  33. {"bmc150_magn", 0},
  34. {"bmc156_magn", 0},
  35. {"bmm150_magn", 0},
  36. {}
  37. };
  38. MODULE_DEVICE_TABLE(spi, bmc150_magn_spi_id);
  39. static const struct acpi_device_id bmc150_magn_acpi_match[] = {
  40. {"BMC150B", 0},
  41. {"BMC156B", 0},
  42. {"BMM150B", 0},
  43. {},
  44. };
  45. MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match);
  46. static struct spi_driver bmc150_magn_spi_driver = {
  47. .probe = bmc150_magn_spi_probe,
  48. .remove = bmc150_magn_spi_remove,
  49. .id_table = bmc150_magn_spi_id,
  50. .driver = {
  51. .acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match),
  52. .name = "bmc150_magn_spi",
  53. },
  54. };
  55. module_spi_driver(bmc150_magn_spi_driver);
  56. MODULE_AUTHOR("Daniel Baluta <[email protected]");
  57. MODULE_DESCRIPTION("BMC150 magnetometer SPI driver");
  58. MODULE_LICENSE("GPL v2");
  59. MODULE_IMPORT_NS(IIO_BMC150_MAGN);