/*
 * @file hv_pm51_app_PM.h
 * @brief Header file of power manager module.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-03-01
 */
 
#ifndef __HV_PM51_APP_PM_H__
#define __HV_PM51_APP_PM_H__

#include "hv_pm51_Base.h"
#include "hv_pm51_app_Key.h"

typedef enum _WakeUpIndex
{
    WAKEUP_DP_CABLE_0 = 0,
    WAKEUP_AUX_0,
    WAKEUP_AUX_1,
    WAKEUP_HDMI_CABLE_0,
    WAKEUP_ADC0,
    WAKEUP_ADC1,
    WAKEUP_RX_PHY_0,
    WAKEUP_RX_PHY_1,
    WAKEUP_RX_PHY_2,
    WAKEUP_RX_PHY_3,
    WAKEUP_DP_CABLE_1,
    WAKEUP_HDMI_CABLE_1,
    WAKEUP_HDMI_CEC_0,
    WAKEUP_HDMI_CEC_1,
    WAKEUP_TYPE_C_0,
    WAKEUP_TYPE_C_1,
    WAKEUP_SEL_NUM,
}WakeUpIndex;

typedef enum  _PowerState
{
    POWER_STATE_POWER_ON    = 0x1,
    POWER_STATE_NORMAL      = 0x2,
    POWER_STATE_STANDBY     = 0x4,
    POWER_STATE_OFF         = 0x8,
    POWER_STATE_ANY_STATE   = 0xFFFF,
}PowerState;

typedef enum  _CurChannel
{
    CUR_CHANNEL_HDMI0       = 0x0,
    CUR_CHANNEL_HDMI1       = 0x1,
    CUR_CHANNEL_DP0         = 0x2,
    CUR_CHANNEL_DP1         = 0x3,
}CurChannel;

/**
 * @brief Power off main domain. 
 * @return None.
 */
void Hv_PM51_PM_PowerOffMainDomain(void);
    
/**
 * @brief Bootup MIPS and send wakeup reason to MIPS. 
 * @param[in] ucType: wakeup reason sending to MIPS.
 * @param[in] ucVal: the value sending to MIPS, such as key value.
 * @return None.
 */
void Hv_PM51_PM_BootUpSequense(UCHAR8 ucType, UCHAR8 ucVal);

/**
 * @brief PM51 enter idle low power mode. 
 * @return None.
 */
void Hv_PM51_PM_EnterIdle(void);

/**
 * @brief Enable DPMS: include HDMI cable, HDMI TMDS, DP cable and DP AUX ect. 
 * @return None.
 */
void Hv_PM51_PM_DpmsEnable(void);

/**
 * @brief Set HPD Low when in PMU mode.
 * @return None.
 */
void Hv_PM51_PM_SetHpdLow(void);

/**
 * @brief PMU enter standby low power mode. 
 * @return None.
 */
void Hv_PM51_PM_EnterStandBy(void);

/**
 * @brief PMU enter power off mode. 
 * @return None.
 */
void Hv_PM51_PM_EnterPowerOff(void);

/**
 * @brief Check PMU status in E2PROM when system booting,
 *          and decide which PMU state the system ultimately enters.
 * @return None.
 */
void Hv_PM51_PM_PowerOnReadE2P(void);

/**
 * @brief Save PMU status in E2PROM,
 * @return 1: save successfully  0: save failed..
 */
xUCHAR8 Hv_PM51_PM_SaveCurStatusToE2P(xUCHAR8 ucStatus);

/**
 * @brief Check PMU status when system booting,
 *          read from flash or e2prom according to project setting.
 * @return None.
 */
void Hv_PM51_PM_PowerOnCheckPmu(void);

#endif 
