regulator.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Regulator uapi header
  4. *
  5. * Author: Naresh Solanki <Naresh.Solanki@9elements.com>
  6. */
  7. #ifndef _UAPI_REGULATOR_H
  8. #define _UAPI_REGULATOR_H
  9. #ifdef __KERNEL__
  10. #include <linux/types.h>
  11. #else
  12. #include <stdint.h>
  13. #endif
  14. /*
  15. * Regulator notifier events.
  16. *
  17. * UNDER_VOLTAGE Regulator output is under voltage.
  18. * OVER_CURRENT Regulator output current is too high.
  19. * REGULATION_OUT Regulator output is out of regulation.
  20. * FAIL Regulator output has failed.
  21. * OVER_TEMP Regulator over temp.
  22. * FORCE_DISABLE Regulator forcibly shut down by software.
  23. * VOLTAGE_CHANGE Regulator voltage changed.
  24. * Data passed is old voltage cast to (void *).
  25. * DISABLE Regulator was disabled.
  26. * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed.
  27. * Data passed is "struct pre_voltage_change_data"
  28. * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
  29. * Data passed is old voltage cast to (void *).
  30. * PRE_DISABLE Regulator is about to be disabled
  31. * ABORT_DISABLE Regulator disable failed for some reason
  32. *
  33. * NOTE: These events can be OR'ed together when passed into handler.
  34. */
  35. #define REGULATOR_EVENT_UNDER_VOLTAGE 0x01
  36. #define REGULATOR_EVENT_OVER_CURRENT 0x02
  37. #define REGULATOR_EVENT_REGULATION_OUT 0x04
  38. #define REGULATOR_EVENT_FAIL 0x08
  39. #define REGULATOR_EVENT_OVER_TEMP 0x10
  40. #define REGULATOR_EVENT_FORCE_DISABLE 0x20
  41. #define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40
  42. #define REGULATOR_EVENT_DISABLE 0x80
  43. #define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
  44. #define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
  45. #define REGULATOR_EVENT_PRE_DISABLE 0x400
  46. #define REGULATOR_EVENT_ABORT_DISABLE 0x800
  47. #define REGULATOR_EVENT_ENABLE 0x1000
  48. /*
  49. * Following notifications should be emitted only if detected condition
  50. * is such that the HW is likely to still be working but consumers should
  51. * take a recovery action to prevent problems escalating into errors.
  52. */
  53. #define REGULATOR_EVENT_UNDER_VOLTAGE_WARN 0x2000
  54. #define REGULATOR_EVENT_OVER_CURRENT_WARN 0x4000
  55. #define REGULATOR_EVENT_OVER_VOLTAGE_WARN 0x8000
  56. #define REGULATOR_EVENT_OVER_TEMP_WARN 0x10000
  57. #define REGULATOR_EVENT_WARN_MASK 0x1E000
  58. struct reg_genl_event {
  59. char reg_name[32];
  60. uint64_t event;
  61. };
  62. /* attributes of reg_genl_family */
  63. enum {
  64. REG_GENL_ATTR_UNSPEC,
  65. REG_GENL_ATTR_EVENT, /* reg event info needed by user space */
  66. __REG_GENL_ATTR_MAX,
  67. };
  68. #define REG_GENL_ATTR_MAX (__REG_GENL_ATTR_MAX - 1)
  69. /* commands supported by the reg_genl_family */
  70. enum {
  71. REG_GENL_CMD_UNSPEC,
  72. REG_GENL_CMD_EVENT, /* kernel->user notifications for reg events */
  73. __REG_GENL_CMD_MAX,
  74. };
  75. #define REG_GENL_CMD_MAX (__REG_GENL_CMD_MAX - 1)
  76. #define REG_GENL_FAMILY_NAME "reg_event"
  77. #define REG_GENL_VERSION 0x01
  78. #define REG_GENL_MCAST_GROUP_NAME "reg_mc_group"
  79. #endif /* _UAPI_REGULATOR_H */