1 /* 2 * Copyright (C) 2017-2019 Alibaba Group Holding Limited 3 */ 4 5 /****************************************************************************** 6 * @file drv_pmu.h 7 * @brief header file for pmu driver 8 * @version V1.0 9 * @date 02. June 2017 10 * @model pmu 11 ******************************************************************************/ 12 13 #ifndef _DRV_PMU_H_ 14 #define _DRV_PMU_H_ 15 16 17 #include <drv/common.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 /// definition for pmu handle. 23 typedef void *pmu_handle_t; 24 25 /****** PMU specific error codes *****/ 26 typedef enum { 27 EDRV_PMU_MODE = (1), ///< Specified Mode not supported 28 } pmu_error_e; 29 30 /*----- PMU Control Codes: Mode -----*/ 31 typedef enum { 32 PMU_MODE_RUN = 0, ///< Running mode 33 PMU_MODE_SLEEP, ///< Sleep mode 34 PMU_MODE_DOZE, ///< Doze mode 35 PMU_MODE_DORMANT, ///< Dormant mode 36 PMU_MODE_STANDBY, ///< Standby mode 37 PMU_MODE_SHUTDOWN ///< Shutdown mode 38 } pmu_mode_e; 39 40 /*----- PMU Control Codes: Wakeup type -----*/ 41 typedef enum { 42 PMU_WAKEUP_TYPE_PULSE = 0, ///< Pulse interrupt 43 PMU_WAKEUP_TYPE_LEVEL ///< Level interrupt 44 } pmu_wakeup_type_e; 45 46 /*----- PMU Control Codes: Wakeup polarity -----*/ 47 typedef enum { 48 PMU_WAKEUP_POL_LOW = 0, ///< Low or negedge 49 PMU_WAKEUP_POL_HIGH ///< High or posedge 50 } pmu_wakeup_pol_e; 51 52 /****** PMU Event *****/ 53 typedef enum { 54 PMU_EVENT_SLEEP_DONE = 0, ///< Send completed; however PMU may still transmit data 55 PMU_EVENT_PREPARE_SLEEP = 1 56 } pmu_event_e; 57 58 typedef void (*pmu_event_cb_t)(int32_t idx, pmu_event_e event, pmu_mode_e mode); ///< Pointer to \ref pmu_event_cb_t : PMU Event call back. 59 60 /** 61 \brief Initialize PMU Interface. 1. Initializes the resources needed for the PMU interface 2.registers event callback function 62 \param[in] idx the id of the pmu 63 \param[in] cb_event Pointer to \ref pmu_event_cb_t 64 \return return pmu handle if success 65 */ 66 pmu_handle_t csi_pmu_initialize(int32_t idx, pmu_event_cb_t cb_event); 67 68 /** 69 \brief De-initialize PMU Interface. stops operation and releases the software resources used by the interface 70 \param[in] handle pmu handle to operate. 71 \return error code 72 */ 73 int32_t csi_pmu_uninitialize(pmu_handle_t handle); 74 75 /** 76 \brief choose the pmu mode to enter 77 \param[in] handle pmu handle to operate. 78 \param[in] mode \ref pmu_mode_e 79 \return error code 80 */ 81 int32_t csi_pmu_enter_sleep(pmu_handle_t handle, pmu_mode_e mode); 82 83 /** 84 \brief control pmu power. 85 \param[in] handle pmu handle to operate. 86 \param[in] state power state.\ref csi_power_stat_e. 87 \return error code 88 */ 89 /** 90 \brief Config the wakeup source. 91 \param[in] handle pmu handle to operate 92 \param[in] wakeup_num wakeup source num 93 \param[in] type \ref pmu_wakeup_type 94 \param[in] pol \ref pmu_wakeup_pol 95 \param[in] enable flag control the wakeup source is enable or not 96 \return error code 97 */ 98 int32_t csi_pmu_config_wakeup_source(pmu_handle_t handle, uint32_t wakeup_num, pmu_wakeup_type_e type, pmu_wakeup_pol_e pol, uint8_t enable); 99 100 #ifdef __cplusplus 101 } 102 #endif 103 104 #endif /* _CSI_PMU_H_ */ 105