qpnp-power-on.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2015, 2017-2019, 2021 The Linux Foundation.
  4. * All rights reserved.
  5. * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
  6. */
  7. #ifndef QPNP_PON_H
  8. #define QPNP_PON_H
  9. #include <dt-bindings/input/qcom,qpnp-power-on.h>
  10. #include <linux/errno.h>
  11. #include <linux/types.h>
  12. /**
  13. * enum pon_trigger_source: List of PON trigger sources
  14. * %PON_SMPL: PON triggered by Sudden Momentary Power Loss (SMPL)
  15. * %PON_RTC: PON triggered by real-time clock (RTC) alarm
  16. * %PON_DC_CHG: PON triggered by insertion of DC charger
  17. * %PON_USB_CHG: PON triggered by insertion of USB
  18. * %PON_PON1: PON triggered by other PMIC (multi-PMIC option)
  19. * %PON_CBLPWR_N: PON triggered by power-cable insertion
  20. * %PON_KPDPWR_N: PON triggered by long press of the power-key
  21. */
  22. enum pon_trigger_source {
  23. PON_SMPL = 1,
  24. PON_RTC,
  25. PON_DC_CHG,
  26. PON_USB_CHG,
  27. PON_PON1,
  28. PON_CBLPWR_N,
  29. PON_KPDPWR_N,
  30. };
  31. /**
  32. * enum pon_power_off_type: Possible power off actions to perform
  33. * %PON_POWER_OFF_RESERVED: Reserved, not used
  34. * %PON_POWER_OFF_WARM_RESET: Reset the MSM but not all PMIC peripherals
  35. * %PON_POWER_OFF_SHUTDOWN: Shutdown the MSM and PMIC completely
  36. * %PON_POWER_OFF_HARD_RESET: Reset the MSM and all PMIC peripherals
  37. * %PON_POWER_OFF_MAX_TYPE: Reserved, not used
  38. */
  39. enum pon_power_off_type {
  40. PON_POWER_OFF_RESERVED = 0x00,
  41. PON_POWER_OFF_WARM_RESET = PON_POWER_OFF_TYPE_WARM_RESET,
  42. PON_POWER_OFF_SHUTDOWN = PON_POWER_OFF_TYPE_SHUTDOWN,
  43. PON_POWER_OFF_HARD_RESET = PON_POWER_OFF_TYPE_HARD_RESET,
  44. PON_POWER_OFF_MAX_TYPE = 0x10,
  45. };
  46. enum pon_restart_reason {
  47. PON_RESTART_REASON_UNKNOWN = 0x00,
  48. PON_RESTART_REASON_RECOVERY = 0x01,
  49. PON_RESTART_REASON_BOOTLOADER = 0x02,
  50. PON_RESTART_REASON_RTC = 0x03,
  51. PON_RESTART_REASON_DMVERITY_CORRUPTED = 0x04,
  52. PON_RESTART_REASON_DMVERITY_ENFORCE = 0x05,
  53. PON_RESTART_REASON_KEYS_CLEAR = 0x06,
  54. PON_RESTART_REASON_SILENT = 0x0a,
  55. PON_RESTART_REASON_NON_SILENT = 0x0b,
  56. PON_RESTART_REASON_FORCED_SILENT = 0x0c,
  57. PON_RESTART_REASON_FORCED_NON_SILENT = 0x0d,
  58. };
  59. #if IS_ENABLED(CONFIG_INPUT_QPNP_POWER_ON)
  60. int qpnp_pon_system_pwr_off(enum pon_power_off_type type);
  61. int qpnp_pon_is_warm_reset(void);
  62. int qpnp_pon_trigger_config(enum pon_trigger_source pon_src, bool enable);
  63. int qpnp_pon_wd_config(bool enable);
  64. int qpnp_pon_set_restart_reason(enum pon_restart_reason reason);
  65. bool qpnp_pon_check_hard_reset_stored(void);
  66. int qpnp_pon_modem_pwr_off(enum pon_power_off_type type);
  67. #else
  68. static int qpnp_pon_system_pwr_off(enum pon_power_off_type type)
  69. {
  70. return -ENODEV;
  71. }
  72. static inline int qpnp_pon_is_warm_reset(void)
  73. {
  74. return -ENODEV;
  75. }
  76. static inline int qpnp_pon_trigger_config(enum pon_trigger_source pon_src,
  77. bool enable)
  78. {
  79. return -ENODEV;
  80. }
  81. int qpnp_pon_wd_config(bool enable)
  82. {
  83. return -ENODEV;
  84. }
  85. static inline int qpnp_pon_set_restart_reason(enum pon_restart_reason reason)
  86. {
  87. return -ENODEV;
  88. }
  89. static inline bool qpnp_pon_check_hard_reset_stored(void)
  90. {
  91. return false;
  92. }
  93. static inline int qpnp_pon_modem_pwr_off(enum pon_power_off_type type)
  94. {
  95. return -ENODEV;
  96. }
  97. #endif
  98. #endif