fxos8700_i2c.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * FXOS8700 - NXP IMU, I2C bits
  4. *
  5. * 7-bit I2C slave address determined by SA1 and SA0 logic level
  6. * inputs represented in the following table:
  7. * SA1 | SA0 | Slave Address
  8. * 0 | 0 | 0x1E
  9. * 0 | 1 | 0x1D
  10. * 1 | 0 | 0x1C
  11. * 1 | 1 | 0x1F
  12. */
  13. #include <linux/acpi.h>
  14. #include <linux/i2c.h>
  15. #include <linux/module.h>
  16. #include <linux/mod_devicetable.h>
  17. #include <linux/regmap.h>
  18. #include "fxos8700.h"
  19. static int fxos8700_i2c_probe(struct i2c_client *client,
  20. const struct i2c_device_id *id)
  21. {
  22. struct regmap *regmap;
  23. const char *name = NULL;
  24. regmap = devm_regmap_init_i2c(client, &fxos8700_regmap_config);
  25. if (IS_ERR(regmap)) {
  26. dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap));
  27. return PTR_ERR(regmap);
  28. }
  29. if (id)
  30. name = id->name;
  31. return fxos8700_core_probe(&client->dev, regmap, name, false);
  32. }
  33. static const struct i2c_device_id fxos8700_i2c_id[] = {
  34. {"fxos8700", 0},
  35. { }
  36. };
  37. MODULE_DEVICE_TABLE(i2c, fxos8700_i2c_id);
  38. static const struct acpi_device_id fxos8700_acpi_match[] = {
  39. {"FXOS8700", 0},
  40. { }
  41. };
  42. MODULE_DEVICE_TABLE(acpi, fxos8700_acpi_match);
  43. static const struct of_device_id fxos8700_of_match[] = {
  44. { .compatible = "nxp,fxos8700" },
  45. { }
  46. };
  47. MODULE_DEVICE_TABLE(of, fxos8700_of_match);
  48. static struct i2c_driver fxos8700_i2c_driver = {
  49. .driver = {
  50. .name = "fxos8700_i2c",
  51. .acpi_match_table = ACPI_PTR(fxos8700_acpi_match),
  52. .of_match_table = fxos8700_of_match,
  53. },
  54. .probe = fxos8700_i2c_probe,
  55. .id_table = fxos8700_i2c_id,
  56. };
  57. module_i2c_driver(fxos8700_i2c_driver);
  58. MODULE_AUTHOR("Robert Jones <[email protected]>");
  59. MODULE_DESCRIPTION("FXOS8700 I2C driver");
  60. MODULE_LICENSE("GPL v2");