soc_pmu.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (c) 2021 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief Actions LARK family PMU public APIs
  9. */
  10. #ifndef _SOC_PMU_H_
  11. #define _SOC_PMU_H_
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /* Macro of peripheral devices that PMU supervise the devices voltage level change.*/
  16. #define PMU_DETECT_DEV_DC5V (1)
  17. #define PMU_DETECT_DEV_REMOTE (2)
  18. #define PMU_DETECT_DEV_ONOFF (3)
  19. #define PMU_DETECT_DEV_COUNTER8HZ (4)
  20. #define PMU_DETECT_DEV_ALARM8HZ (5)
  21. #define PMU_DETECT_MAX_DEV (5)
  22. /* Max cycles of counter8hz */
  23. #define PMU_COUTNER8HZ_MAX (0x3FFFFFF)
  24. /**
  25. * enum pmu_hotplug_state
  26. * @brief Hotplug devices (e.g. DV5V) state change which detected by PMU.
  27. */
  28. enum pmu_notify_state {
  29. PMU_NOTIFY_STATE_OUT = 0,
  30. PMU_NOTIFY_STATE_IN,
  31. PMU_NOTIFY_STATE_PRESSED,
  32. PMU_NOTIFY_STATE_LONG_PRESSED,
  33. PMU_NOTIFY_STATE_TIME_ON
  34. };
  35. typedef void (*pmu_notify_t)(void *cb_data, int state);
  36. /**
  37. * struct notify_param_t
  38. * @brief Parameters for PMU notify register.
  39. */
  40. struct detect_param_t {
  41. uint8_t detect_dev;
  42. pmu_notify_t notify;
  43. void *cb_data;
  44. };
  45. /* @brief Register the device that PMU start to monitor */
  46. int soc_pmu_register_notify(struct detect_param_t *param);
  47. /* @brief Unregister the device that PMU stop to monitor */
  48. void soc_pmu_unregister_notify(uint8_t detect_dev);
  49. /* @brief Get the wakeup source caused by system power up */
  50. uint32_t soc_pmu_get_wakeup_source(void);
  51. /* @brief return the wakeup setting by system startup */
  52. uint32_t soc_pmu_get_wakeup_setting(void);
  53. /* @brief check if system wakeup by RTC alarm */
  54. bool soc_pmu_is_alarm_wakeup(void);
  55. /* @brief get the current DC5V status of plug in or out and if retval of status is 1 indicates that plug-in*/
  56. bool soc_pmu_get_dc5v_status(void);
  57. /* @brief lock DC5V charging for reading battery voltage */
  58. void soc_pmu_read_bat_lock(void);
  59. /* @brief unlock and restart DC5V charging */
  60. void soc_pmu_read_bat_unlock(void);
  61. /* @brief configure the long press on-off key time */
  62. void soc_pmu_config_onoffkey_function(uint8_t val);
  63. /* @brief configure the long press on-off key time */
  64. void soc_pmu_config_onoffkey_time(uint8_t val);
  65. /* @brief check if the onoff key has been pressed or not */
  66. bool soc_pmu_is_onoff_key_pressed(void);
  67. /* @brief set const voltage value */
  68. void soc_pmu_set_const_voltage(uint8_t cv);
  69. /* @brief set the max constant current */
  70. void soc_pmu_set_max_current(uint16_t cur_ma);
  71. /* @brief get the max constant current */
  72. uint16_t soc_pmu_get_max_current(void);
  73. /* @brief configure the long press on-off key reset/restart time */
  74. void soc_pmu_config_onoffkey_reset_time(uint8_t val);
  75. /* @brief counter 8hz clock enable */
  76. void soc_pmu_counter8hz_enable(void);
  77. /* @brief get counter8hz and the retval is by cycles */
  78. int soc_pmu_get_counter8hz_cycles(bool is_sync);
  79. /* @brief enable PMU alarm 8hz */
  80. int soc_pmu_alarm8hz_enable(uint32_t alarm_msec);
  81. /* @brief disable PMU alarm8hz */
  82. void soc_pmu_alarm8hz_disable(void);
  83. /* @brief get alarm8hz cycles */
  84. int soc_pmu_get_alarm8hz(void);
  85. /* @brief get current rc32k freq by hosc count, cal_cyc is rc32k cycle */
  86. uint32_t acts_clock_rc32k_set_cal_cyc(uint32_t cal_cyc);
  87. /* @brief set S1 VDD voltage */
  88. void soc_pmu_set_vdd_voltage(uint32_t volt_mv);
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif /* _SOC_PMU_H_ */