zpa2326.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Murata ZPA2326 pressure and temperature sensor IIO driver
  3. *
  4. * Copyright (c) 2016 Parrot S.A.
  5. *
  6. * Author: Gregor Boirie <gregor.boirie@parrot.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published by
  10. * the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. */
  17. #ifndef _ZPA2326_H
  18. #define _ZPA2326_H
  19. /* Register map. */
  20. #define ZPA2326_REF_P_XL_REG (0x8)
  21. #define ZPA2326_REF_P_L_REG (0x9)
  22. #define ZPA2326_REF_P_H_REG (0xa)
  23. #define ZPA2326_DEVICE_ID_REG (0xf)
  24. #define ZPA2326_DEVICE_ID (0xb9)
  25. #define ZPA2326_RES_CONF_REG (0x10)
  26. #define ZPA2326_CTRL_REG0_REG (0x20)
  27. #define ZPA2326_CTRL_REG0_ONE_SHOT BIT(0)
  28. #define ZPA2326_CTRL_REG0_ENABLE BIT(1)
  29. #define ZPA2326_CTRL_REG1_REG (0x21)
  30. #define ZPA2326_CTRL_REG1_MASK_DATA_READY BIT(2)
  31. #define ZPA2326_CTRL_REG2_REG (0x22)
  32. #define ZPA2326_CTRL_REG2_SWRESET BIT(2)
  33. #define ZPA2326_CTRL_REG3_REG (0x23)
  34. #define ZPA2326_CTRL_REG3_ODR_SHIFT (4)
  35. #define ZPA2326_CTRL_REG3_ENABLE_MEAS BIT(7)
  36. #define ZPA2326_INT_SOURCE_REG (0x24)
  37. #define ZPA2326_INT_SOURCE_DATA_READY BIT(2)
  38. #define ZPA2326_THS_P_LOW_REG (0x25)
  39. #define ZPA2326_THS_P_HIGH_REG (0x26)
  40. #define ZPA2326_STATUS_REG (0x27)
  41. #define ZPA2326_STATUS_P_DA BIT(1)
  42. #define ZPA2326_STATUS_FIFO_E BIT(2)
  43. #define ZPA2326_STATUS_P_OR BIT(5)
  44. #define ZPA2326_PRESS_OUT_XL_REG (0x28)
  45. #define ZPA2326_PRESS_OUT_L_REG (0x29)
  46. #define ZPA2326_PRESS_OUT_H_REG (0x2a)
  47. #define ZPA2326_TEMP_OUT_L_REG (0x2b)
  48. #define ZPA2326_TEMP_OUT_H_REG (0x2c)
  49. struct device;
  50. struct regmap;
  51. bool zpa2326_isreg_writeable(struct device *dev, unsigned int reg);
  52. bool zpa2326_isreg_readable(struct device *dev, unsigned int reg);
  53. bool zpa2326_isreg_precious(struct device *dev, unsigned int reg);
  54. /**
  55. * zpa2326_probe() - Instantiate and register core ZPA2326 IIO device
  56. * @parent: Hardware sampling device the created IIO device will be a child of.
  57. * @name: Arbitrary name to identify the device.
  58. * @irq: Interrupt line, negative if none.
  59. * @hwid: Expected device hardware id.
  60. * @regmap: Registers map used to abstract underlying bus accesses.
  61. *
  62. * Return: Zero when successful, a negative error code otherwise.
  63. */
  64. int zpa2326_probe(struct device *parent,
  65. const char *name,
  66. int irq,
  67. unsigned int hwid,
  68. struct regmap *regmap);
  69. /**
  70. * zpa2326_remove() - Unregister and destroy core ZPA2326 IIO device.
  71. * @parent: Hardware sampling device the IIO device to remove is a child of.
  72. */
  73. void zpa2326_remove(const struct device *parent);
  74. #ifdef CONFIG_PM
  75. #include <linux/pm.h>
  76. extern const struct dev_pm_ops zpa2326_pm_ops;
  77. #define ZPA2326_PM_OPS (&zpa2326_pm_ops)
  78. #else
  79. #define ZPA2326_PM_OPS (NULL)
  80. #endif
  81. #endif