hmc5843.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Header file for hmc5843 driver
  4. *
  5. * Split from hmc5843.c
  6. * Copyright (C) Josef Gajdusek <atx@atx.name>
  7. */
  8. #ifndef HMC5843_CORE_H
  9. #define HMC5843_CORE_H
  10. #include <linux/regmap.h>
  11. #include <linux/iio/iio.h>
  12. #define HMC5843_CONFIG_REG_A 0x00
  13. #define HMC5843_CONFIG_REG_B 0x01
  14. #define HMC5843_MODE_REG 0x02
  15. #define HMC5843_DATA_OUT_MSB_REGS 0x03
  16. #define HMC5843_STATUS_REG 0x09
  17. #define HMC5843_ID_REG 0x0a
  18. #define HMC5843_ID_END 0x0c
  19. enum hmc5843_ids {
  20. HMC5843_ID,
  21. HMC5883_ID,
  22. HMC5883L_ID,
  23. HMC5983_ID,
  24. };
  25. /**
  26. * struct hmc5843_data - device specific data
  27. * @dev: actual device
  28. * @lock: update and read regmap data
  29. * @regmap: hardware access register maps
  30. * @variant: describe chip variants
  31. * @scan: buffer to pack data for passing to
  32. * iio_push_to_buffers_with_timestamp()
  33. */
  34. struct hmc5843_data {
  35. struct device *dev;
  36. struct mutex lock;
  37. struct regmap *regmap;
  38. const struct hmc5843_chip_info *variant;
  39. struct iio_mount_matrix orientation;
  40. struct {
  41. __be16 chans[3];
  42. s64 timestamp __aligned(8);
  43. } scan;
  44. };
  45. int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
  46. enum hmc5843_ids id, const char *name);
  47. int hmc5843_common_remove(struct device *dev);
  48. int hmc5843_common_suspend(struct device *dev);
  49. int hmc5843_common_resume(struct device *dev);
  50. #ifdef CONFIG_PM_SLEEP
  51. static __maybe_unused SIMPLE_DEV_PM_OPS(hmc5843_pm_ops,
  52. hmc5843_common_suspend,
  53. hmc5843_common_resume);
  54. #define HMC5843_PM_OPS (&hmc5843_pm_ops)
  55. #else
  56. #define HMC5843_PM_OPS NULL
  57. #endif
  58. #endif /* HMC5843_CORE_H */