hmc5843.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Header file for hmc5843 driver
  3. *
  4. * Split from hmc5843.c
  5. * Copyright (C) Josef Gajdusek <atx@atx.name>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef HMC5843_CORE_H
  12. #define HMC5843_CORE_H
  13. #include <linux/regmap.h>
  14. #include <linux/iio/iio.h>
  15. #define HMC5843_CONFIG_REG_A 0x00
  16. #define HMC5843_CONFIG_REG_B 0x01
  17. #define HMC5843_MODE_REG 0x02
  18. #define HMC5843_DATA_OUT_MSB_REGS 0x03
  19. #define HMC5843_STATUS_REG 0x09
  20. #define HMC5843_ID_REG 0x0a
  21. #define HMC5843_ID_END 0x0c
  22. enum hmc5843_ids {
  23. HMC5843_ID,
  24. HMC5883_ID,
  25. HMC5883L_ID,
  26. HMC5983_ID,
  27. };
  28. /**
  29. * struct hcm5843_data - device specific data
  30. * @dev: actual device
  31. * @lock: update and read regmap data
  32. * @regmap: hardware access register maps
  33. * @variant: describe chip variants
  34. * @buffer: 3x 16-bit channels + padding + 64-bit timestamp
  35. */
  36. struct hmc5843_data {
  37. struct device *dev;
  38. struct mutex lock;
  39. struct regmap *regmap;
  40. const struct hmc5843_chip_info *variant;
  41. __be16 buffer[8];
  42. };
  43. int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
  44. enum hmc5843_ids id, const char *name);
  45. int hmc5843_common_remove(struct device *dev);
  46. int hmc5843_common_suspend(struct device *dev);
  47. int hmc5843_common_resume(struct device *dev);
  48. #ifdef CONFIG_PM_SLEEP
  49. static SIMPLE_DEV_PM_OPS(hmc5843_pm_ops,
  50. hmc5843_common_suspend,
  51. hmc5843_common_resume);
  52. #define HMC5843_PM_OPS (&hmc5843_pm_ops)
  53. #else
  54. #define HMC5843_PM_OPS NULL
  55. #endif
  56. #endif /* HMC5843_CORE_H */