fxls8962af-i2c.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. { "fxls8967af", fxls8967af },
  28. { "fxls8974cf", fxls8974cf },
  29. { }
  30. };
  31. MODULE_DEVICE_TABLE(i2c, fxls8962af_id);
  32. static const struct of_device_id fxls8962af_of_match[] = {
  33. { .compatible = "nxp,fxls8962af" },
  34. { .compatible = "nxp,fxls8964af" },
  35. { }
  36. };
  37. MODULE_DEVICE_TABLE(of, fxls8962af_of_match);
  38. static struct i2c_driver fxls8962af_driver = {
  39. .driver = {
  40. .name = "fxls8962af_i2c",
  41. .of_match_table = fxls8962af_of_match,
  42. .pm = pm_ptr(&fxls8962af_pm_ops),
  43. },
  44. .probe = fxls8962af_probe,
  45. .id_table = fxls8962af_id,
  46. };
  47. module_i2c_driver(fxls8962af_driver);
  48. MODULE_AUTHOR("Sean Nyekjaer <sean@geanix.com>");
  49. MODULE_DESCRIPTION("NXP FXLS8962AF/FXLS8964AF accelerometer i2c driver");
  50. MODULE_LICENSE("GPL v2");
  51. MODULE_IMPORT_NS("IIO_FXLS8962AF");