fxls8962af-i2c.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * NXP FXLS8962AF/FXLS8964AF Accelerometer I2C Driver
  4. *
  5. * Copyright 2021 Connected Cars A/S
  6. */
  7. #include <linux/dev_printk.h>
  8. #include <linux/err.h>
  9. #include <linux/i2c.h>
  10. #include <linux/mod_devicetable.h>
  11. #include <linux/module.h>
  12. #include <linux/regmap.h>
  13. #include "fxls8962af.h"
  14. static int fxls8962af_probe(struct i2c_client *client)
  15. {
  16. struct regmap *regmap;
  17. regmap = devm_regmap_init_i2c(client, &fxls8962af_i2c_regmap_conf);
  18. if (IS_ERR(regmap)) {
  19. dev_err(&client->dev, "Failed to initialize i2c regmap\n");
  20. return PTR_ERR(regmap);
  21. }
  22. return fxls8962af_core_probe(&client->dev, regmap, client->irq);
  23. }
  24. static const struct i2c_device_id fxls8962af_id[] = {
  25. { "fxls8962af", fxls8962af },
  26. { "fxls8964af", fxls8964af },
  27. {}
  28. };
  29. MODULE_DEVICE_TABLE(i2c, fxls8962af_id);
  30. static const struct of_device_id fxls8962af_of_match[] = {
  31. { .compatible = "nxp,fxls8962af" },
  32. { .compatible = "nxp,fxls8964af" },
  33. {}
  34. };
  35. MODULE_DEVICE_TABLE(of, fxls8962af_of_match);
  36. static struct i2c_driver fxls8962af_driver = {
  37. .driver = {
  38. .name = "fxls8962af_i2c",
  39. .of_match_table = fxls8962af_of_match,
  40. .pm = &fxls8962af_pm_ops,
  41. },
  42. .probe_new = fxls8962af_probe,
  43. .id_table = fxls8962af_id,
  44. };
  45. module_i2c_driver(fxls8962af_driver);
  46. MODULE_AUTHOR("Sean Nyekjaer <[email protected]>");
  47. MODULE_DESCRIPTION("NXP FXLS8962AF/FXLS8964AF accelerometer i2c driver");
  48. MODULE_LICENSE("GPL v2");
  49. MODULE_IMPORT_NS(IIO_FXLS8962AF);