You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

451 lines
22 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved.
* Description: Application programming interfaces (APIs) of the PMOC
*/
#ifndef UAPI_PMOC_H
#define UAPI_PMOC_H
#include "td_type.h"
#include "uapi_gpio.h"
#include "uapi_ir.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
#define UAPI_PMOC_WAKEUP_GPIO_MAXNUM 4
#define UAPI_PMOC_WAKEUP_IRKEY_MAXNUM 10
#define UAPI_PMOC_POWEROFF_GPIO_MAXNUM 4
#define UAPI_PMOC_HDMITX_ID_MAXNUM 4
#define UAPI_PMOC_FILTER_COUNT 4
#define UAPI_PMOC_FILTER_VALUE_COUNT 31
#define UAPI_PMOC_LSADC_CHANNEL_MAXNUM 4
/*
* keyled display type
* CNcomment:
*/
typedef enum {
UAPI_PMOC_NO_DISPLAY = 0, /* No display */ /* CNcomment: 前面板不显示 */
UAPI_PMOC_DISPLAY_DIGIT, /* Display digit */ /* CNcomment: 显示数字 */
UAPI_PMOC_DISPLAY_TIME, /* Display time */ /* CNcomment: 显示时间 */
UAPI_PMOC_DISPLAY_TYPE_MAX
} uapi_pmoc_display_type;
/*
* wakeup source
* CNcomment:
*/
typedef enum {
UAPI_PMOC_WAKEUP_IR = 0, /* Woken by the IR module */ /* CNcomment: 被IR唤醒 */
UAPI_PMOC_WAKEUP_KEYLED, /* Woken by the keyled key */ /* CNcomment: 被前面板按键唤醒 */
UAPI_PMOC_WAKEUP_GPIO, /* Woken by the GPIO interrupt */ /* CNcomment: 被GPIO中断唤醒 */
UAPI_PMOC_WAKEUP_LSADC, /* Woken by the LSADC */ /* CNcomment: 被LSADC按键唤醒 */
UAPI_PMOC_WAKEUP_UART, /* Woken by the UART */ /* CNcomment: 被UART唤醒 */
UAPI_PMOC_WAKEUP_ETH, /* Woken by the ethernet interrupt */ /* CNcomment: 被网络中断唤醒 */
UAPI_PMOC_WAKEUP_USB, /* Woken by the USB interrupt */ /* CNcomment: 被USB鼠标键盘唤醒 */
UAPI_PMOC_WAKEUP_VOICE, /* Woken by the VOICE */ /* CNcomment: 被语音唤醒 */
UAPI_PMOC_WAKEUP_VGA = 0x10, /* Woken by the VGA */ /* CNcomment: 被VGA唤醒 */
UAPI_PMOC_WAKEUP_SCART, /* Woken by the SCART */ /* CNcomment: 被SCART唤醒 */
UAPI_PMOC_WAKEUP_HDMIRX_PLUGIN, /* Woken by the HDMI PLUGIN */ /* CNcomment: 被HDMI唤醒 */
UAPI_PMOC_WAKEUP_HDMIRX_CEC, /* Woken by the HDMIRX CEC */ /* CNcomment: 被HDMIRX CEC唤醒 */
UAPI_PMOC_WAKEUP_HDMITX_CEC, /* Woken by the HDMITX CEC */ /* CNcomment: 被HDMITX CEC唤醒 */
UAPI_PMOC_WAKEUP_TIMEOUT = 0x20, /* Woken by the timing interrupt */ /* CNcomment: 被定时中断唤醒 */
UAPI_PMOC_WAKEUP_SOURCE_MAX
} uapi_pmoc_wakeup_src;
/*
* wakeup type
* CNcomment:
*/
typedef enum {
UAPI_PMOC_WAKEUP_TO_DDR = 0, /* wakeup to ddr */ /* CNcomment: 原地唤醒 */
UAPI_PMOC_WAKEUP_RESET, /* system reset when wakeup */ /* CNcomment: 被唤醒后系统重启 */
UAPI_PMOC_WAKEUP_TYPE_MAX
} uapi_pmoc_wakeup_type;
/*
* cec control type
* CNcomment: cec
*/
typedef enum {
UAPI_PMOC_CEC_CONTROL_TYPE_BILATERAL = 0, /* CEC bilateral control */ /* CNcomment: CEC双向控制 */
/* TV suspends or resumes chip by CEC */ /* CNcomment: 电视通过CEC待机或唤醒芯片 */
UAPI_PMOC_CEC_CONTROL_TYPE_TV_TO_CHIP,
/* Chip suspends or resumes TV by CEC */ /* CNcomment: 芯片通过CEC待机或唤醒电视 */
UAPI_PMOC_CEC_CONTROL_TYPE_CHIP_TO_TV,
UAPI_PMOC_CEC_CONTROL_TYPE_MAX
} uapi_pmoc_cec_control_type;
/*
* active standby modle
* CNcomment:
*/
typedef enum {
UAPI_PMOC_ACTIVE_STANDBY_MODLE1,
UAPI_PMOC_ACTIVE_STANDBY_MODLE2, /* reserve */ /* CNcomment: 预留 */
UAPI_PMOC_ACTIVE_STANDBY_MODLE_MAX
} uapi_pmoc_active_standby_modle;
/*
* wakeup frame data
* CNcomment:
*/
typedef struct {
/* bitN to control value[N].0:invalid, 1:valid */ /* CNcomment: 对应value的掩码, bitN对应value[N], 0-无效1-有效 */
td_u32 mask_bytes;
td_u8 offset; /* Filter offset */ /* CNcomment: 过滤器偏移量 */
td_u8 value[UAPI_PMOC_FILTER_VALUE_COUNT]; /* Filter value */ /* CNcomment: 过滤器的值 */
td_bool filter_valid; /* Valid filter, 0:invalid, 1:valid */ /* CNcomment: 过滤器是否有效0-无效1-有效 */
} uapi_pmoc_wakeup_frame;
/*
* suspend param
* CNcomment:
*/
typedef union {
struct {
uapi_ir_code ir_type; /* ir type */ /* CNcomment: 红外遥控类型 */
td_u32 ir_num; /* number of ir key for wakeup */ /* CNcomment: 支持唤醒的键值对个数 */
/* Lower-bit value of the power key on an IR remote control */ /* CNcomment:红外遥控 power 低位键值 */
td_u32 ir_low_val[UAPI_PMOC_WAKEUP_IRKEY_MAXNUM];
/* Upper-bit value of the power key on an IR remote control */ /* CNcomment:红外遥控 power 高位键值 */
td_u32 ir_high_val[UAPI_PMOC_WAKEUP_IRKEY_MAXNUM];
} ir_param;
struct {
td_u32 keyled_type; /* keyled type */ /* CNcomment: 前面板类型 */
td_u32 wakeup_key; /* keyled wakeup key */ /* CNcomment: 前面板唤醒键值 */
} keyled_param;
struct {
td_u32 num; /* number of GPIO for wakeup */ /* CNcomment: 支持唤醒的GPIO个数 */
td_u8 group[UAPI_PMOC_WAKEUP_GPIO_MAXNUM]; /* GPIO group number */ /* CNcomment: GPIO管脚组号 */
td_u8 bit[UAPI_PMOC_WAKEUP_GPIO_MAXNUM]; /* GPIO bit number */ /* CNcomment: GPIO管脚所在组的bit号 */
/* GPIO interrupt type */ /* CNcomment: GPIO中断类型 */
uapi_gpio_interrupt_type interrupt_type[UAPI_PMOC_WAKEUP_GPIO_MAXNUM];
} gpio_param;
struct {
/* channel mask of LSADC */ /* CNcomment: bit0~bit3对应LSADC通道0~3如0x3表示使能通道0和通道1 */
td_u32 channel_mask;
struct {
td_u16 low; /* low key value of LSADC */ /* CNcomment: LSADC唤醒键值的电压下限 */
td_u16 high; /* high key value of LSADC */ /* CNcomment: LSADC唤醒键值的电压上限 */
} key_value_range[UAPI_PMOC_LSADC_CHANNEL_MAXNUM];
} lsadc_param;
struct {
td_u8 wakeup_key; /* uart wakeup key */ /* CNcomment:uart唤醒键值 */
} uart_param;
struct {
td_u32 index; /* eth index:0-eth0, 1-eth1 */ /* CNcomment: 网口号 */
td_bool unicast_packet_enable; /* Unicast packet enable */ /* CNcomment: 单播包使能 */
td_bool magic_packet_enable; /* Magic packet enable */ /* CNcomment: 魔法包使能 */
td_bool wakeup_frame_enable; /* Wakeup Frame enable */ /* CNcomment: 唤醒帧使能 */
uapi_pmoc_wakeup_frame frame[UAPI_PMOC_FILTER_COUNT]; /* Filter frame */ /* CNcomment: 唤醒帧数据 */
/* time to deep standby(unit: s) */ /* CNcomment: 定时切换到真待机的时间(单位: 秒) */
td_u32 time_to_passive_standby;
td_bool mute_wakeup_enable; /* mute wakeup enable */ /* CNcomment: 静默唤醒使能 */
} eth_param;
struct {
/* usb wakeup mask: don't to be set by app */ /* CNcomment: usb 唤醒掩码,用户不需要设置 */
td_u32 usb_wakeup_mask;
} usb_param;
struct {
td_u32 port; /* HDMI port for wakeup */ /* CNcomment: 用于唤醒的hdmi port */
} hdmirx_plugin_param;
struct {
td_bool id[UAPI_PMOC_HDMITX_ID_MAXNUM]; /* HDMITX id */ /* CNcomment: HDMI id */
/* cec control type */ /* CNcomment: cec控制方向 */
uapi_pmoc_cec_control_type cec_control[UAPI_PMOC_HDMITX_ID_MAXNUM];
} hdmitx_cec_param;
struct {
td_u32 suspend_period; /* Preconfigured Wakeup time, in second */ /* CNcomment: 唤醒定时时间 ,单位为秒 */
td_bool pvr_enable; /* After wakeup, start pvr */ /* CNcomment: 定时唤醒后启动pvr标志 */
td_bool mute_wakeup_enable; /* mute wakeup enable */ /* CNcomment: 静默唤醒使能 */
} timeout_param;
} uapi_pmoc_suspend_param;
/*
* param of last wakeup
* CNcomment:
*/
typedef struct {
uapi_pmoc_wakeup_src source; /* Wakeup source for last wakeup */ /* CNcomment: 上一次被唤醒的唤醒源 */
union {
struct {
td_u32 ir_low_val; /* The ir lower-bit of last wakeup */ /* CNcomment: 上一次待机唤醒的遥控器低位键值 */
td_u32 ir_high_val; /* The ir high-bit of last wakeup */ /* CNcomment: 上一次待机唤醒的遥控器高位键值 */
} ir_param;
struct {
td_u8 group; /* GPIO group number of last wakeup */ /* CNcomment: 上一次待机唤醒的GPIO管脚组号 */
td_u8 bit; /* GPIO bit number of last wakeup */ /* CNcomment: 上一次待机唤醒的GPIO管脚所在组的bit号 */
} gpio_param;
struct {
td_u16 channel; /* LSADC channel mask of last wakeup */ /* CNcomment: 上一次待机唤醒的LSADC通道 */
td_u16 key_value; /* LSADC key value of last wakeup */ /* CNcomment: 上一次待机唤醒的LSADC键值 */
} lsadc_param;
} wakeup_param;
} uapi_pmoc_wakeup_attr;
/*
* Configures the time displayed on the front panel in standby mode.
* CNcomment:
*/
typedef struct {
td_u32 hour; /* Hour */ /* CNcomment: 时 */
td_u32 minute; /* Minute */ /* CNcomment: 分 */
td_u32 second; /* Second */ /* CNcomment: 秒 */
} uapi_pmoc_display_time;
/*
* Configures the display mode of the front panel in standby mode.
* CNcomment:
*/
typedef struct {
td_u32 keyled_type; /* Type of the front panel */ /* CNcomment: 前面板类型 */
uapi_pmoc_display_type display_type; /* front panel display type */ /* CNcomment: 前面板显示类型 */
/* display digit,range 0 to 9999, not support hex */ /* CNcomment: 前面板显示的数字范围0到9999不支持16进制数 */
td_u32 display_value;
/* display type is time on the front panel */ /* CNcomment: 前面板显示的时间 */
uapi_pmoc_display_time display_time_info;
} uapi_pmoc_display_param;
/*
* Define of chip temperature
* CNcomment:
*/
typedef struct {
/* The temperature of T-sensor1 in Celsius */ /* CNcomment: 芯片第一个传感器的温度,单位度 */
td_s32 t_sensor1_temperature;
td_s32 t_sensor2_temperature; /* Reserved now */ /* CNcomment: 当前保留 */
td_s32 t_sensor3_temperature; /* Reserved now */ /* CNcomment: 当前保留 */
td_s32 t_sensor4_temperature; /* Reserved now */ /* CNcomment: 当前保留 */
} uapi_pmoc_chip_temperature;
typedef struct {
/* GPIO number to be poweroff when standby */ /* CNcomment: 待机时需要下电的GPIO个数 */
td_u32 num;
/* GPIO group number to be poweroff when standby */ /* CNcomment: 待机时需要下电的GPIO管脚组号 */
td_u8 group[UAPI_PMOC_POWEROFF_GPIO_MAXNUM];
/* GPIO bit number to be poweroff when standby */ /* CNcomment: 待机时需要下电的GPIO管脚所在组的bit号 */
td_u8 bit[UAPI_PMOC_POWEROFF_GPIO_MAXNUM];
/* GPIO level to be set when standby */ /* CNcomment: 待机时GPIO配置的电平 */
td_u8 level[UAPI_PMOC_POWEROFF_GPIO_MAXNUM];
} uapi_pmoc_poweroff_gpio_param;
/*
* brief Starts the power management on chip (PMoC) device.
* CNcomment: brief CNend
* attention \n
* The ARM can be switched to another operating mode and \n
* then to low-power mode only after the PMoC device is started.\n
* CNcomment: ARMCNend
* param N/A CNcomment: CNend
* retval: TD_SUCCESS Success CNcomment: CNend
* retval: SOC_ERR_PMOC_FAILED_INIT The PMOC device fails to open. CNcomment: PMOC CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_init(void);
/*
* brief Stops the PMoC device.
* CNcomment: brief CNend
* attention \n
* N/A CNcomment: CNend
* param N/A CNcomment: CNend
* retval: TD_SUCCESS Success CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMoC device is not started. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_deinit(void);
/*
* brief Set Suspend Param.
* CNcomment: brief CNend
* \attention \n
* N/A CNcomment: CNend
* param[in] source wakeup source to be set CNcomment: CNend
* param[in] enable enable or disable wakeup source CNcomment: 使CNend
* param[in] param param of wakeup source CNcomment: CNend
* retval: SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: TD_SUCCESS set suspend information success. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_set_suspend_param(uapi_pmoc_wakeup_src source, td_bool enable, uapi_pmoc_suspend_param *param);
/*
* brief Get Suspend Param.
* CNcomment: brief CNend
* attention \n
* N/A CNcomment: CNend
* param[in] source wakeup source CNcomment: CNend
* param[out] enable wakeup source enable or not CNcomment: 使CNend
* param[out] param param of wakeup source CNcomment: CNend
* retval: SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: TD_SUCCESS set suspend information success. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_get_suspend_param(uapi_pmoc_wakeup_src source, td_bool *enable, uapi_pmoc_suspend_param *param);
/*
* brief Set Wakeup Type.
* CNcomment: brief CNend
* attention \n
* N/A CNcomment: CNend
* param[in] wakeup_type wakeup to ddr or resume CNcomment: CNend
* retval: SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: TD_SUCCESS set suspend information success. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_set_wakeup_type(uapi_pmoc_wakeup_type wakeup_type);
/*
* brief Enter passive standby or deep active standby and obtains the wakeup source.
* CNcomment: brief passive standbydeep active standby, CNend
* attention \n
* N/A CNcomment: CNend
* param[out] wakeup_src wakeup source CNcomment: CNend
* retval: SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: TD_SUCCESS set suspend information success. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_enter_standby(uapi_pmoc_wakeup_src *wakeup_src);
/*
* brief Get the Parameters of last wake up.
* CNcomment: brief CNend
* attention \n
* N/A CNcomment: CNend
* param[out] attr The Parameters of last waking up. CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: SOC_ERR_PMOC_INVALID_POINT The pointer is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend
* retval: TD_SUCCESS Getting waking up parameters succeeded. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_get_wakeup_attr(uapi_pmoc_wakeup_attr *attr);
/*
* brief Get the period during standby status.
* CNcomment: brief CNend
* attention \n
* N/A CNcomment: CNend
* param[out] standby_period The period of standby. CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: SOC_ERR_PMOC_INVALID_POINT The pointer is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_FAILED_GETPERIOD It fails to get standby period. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_get_standby_period(td_u32 *standby_period);
/*
* brief Switch to active standby status.
* CNcomment: brief active standbyCNend
* attention \n
* N/A CNcomment: CNend
* param[in] model active standby modle to switch. CNcomment: active standby CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: TD_SUCCESS Standby success. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_enter_active_standby(uapi_pmoc_active_standby_modle model);
/*
* brief Quit active standby status.
* CNcomment: brief 退active standbyCNend
* attention \n
* N/A CNcomment: CNend
* param N/A CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: TD_SUCCESS Quit standby success. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_quit_active_standby(td_void);
/*
* brief set display content when wake up.
* CNcomment: brief CNend
* attention \n
* N/A CNcomment: CNend
* content that the panel display when standby
* CNcomment: \n CNend
* param[in] display_param display content: time or channel or no display CNcomment: : or or
* CNend retval: TD_SUCCESS success CNcomment: CNend retval:
* SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend retval:
* SOC_ERR_PMOC_INVALID_POINT The pointer is invalid. CNcomment: CNend retval:
* SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend retval:
* SOC_ERR_PMOC_FAILED_STANDBY It fails to set standby display CNcomment: CNend see \n N/A
* CNcomment: CNend
*/
td_s32 uapi_pmoc_set_standby_display_param(uapi_pmoc_display_param *display_param);
/*
* brief when standby, GPIO pin control 12v and 5v power,relate to hardware.
* CNcomment: brief ,GPIO12V05V0CNend
* attention \n
* N/A CNcomment: CNend
* when standby, the outside power controled by STANDBY_PWROFF pin, the function can be ignored.\n
* when some part of outside power controled by GPIO pin, use this function will decrease standby power.\n
* CNcomment:STANDBY_PWROFF\n
* GPIO,CNend
* param[in] param GPIO param CNcomment: GPIO CNend
* retval: TD_SUCCESS success CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: SOC_ERR_PMOC_INVALID_POINT The pointer is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_FAILED_SETDEV It fails to set standby Gpio. CNcomment: GPIO CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_set_gpio_power_off(uapi_pmoc_poweroff_gpio_param *param);
/* CNcomment: 设置呼吸灯 */
td_s32 uapi_pmoc_set_breath_led(td_u8 group, td_u8 bit, td_u32 led_breath_cycle);
/* CNcomment: 设置待机灯 */
td_s32 uapi_pmoc_set_standby_led(td_u8 group, td_u8 bit, td_u8 level);
/* CNcomment: 客户定制化需求 */
td_s32 uapi_pmoc_set_mcu_msg(td_u32 msg_index, td_u32 value);
td_s32 uapi_pmoc_get_mcu_msg(td_u32 msg_index, td_u32 *value);
/*
* brief Get the temperatures of the chip.
* CNcomment: brief CNend
* attention \n
* N/A CNcomment: CNend
* param[out] chip_temprature The temperatures of the chip sensors. CNcomment: CNend
* retval: SOC_ERR_PMOC_NOT_INIT The PMOC device is not started. CNcomment: PMOC CNend
* retval: SOC_ERR_PMOC_INVALID_POINT The pointer is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_INVALID_PARA The parameter is invalid. CNcomment: CNend
* retval: SOC_ERR_PMOC_FAILED_GETTEMPERATURE It fails to get chip temp. CNcomment: CNend
* see \n
* N/A CNcomment: CNend
*/
td_s32 uapi_pmoc_get_chip_temperature(uapi_pmoc_chip_temperature *chip_temprature);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* UAPI_PMOC_H */