91 lines
3.2 KiB
C
91 lines
3.2 KiB
C
/*================================================================
|
|
Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
|
|
Quectel Wireless Solutions Proprietary and Confidential.
|
|
=================================================================*/
|
|
#ifndef _QL_POWER_H_
|
|
#define _QL_POWER_H_
|
|
#include "pmic.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
typedef enum QL_POWERUP_REASON_ENUM
|
|
{
|
|
QL_POWERUP_NO_REASON = 0,
|
|
QL_POWERUP_PWRKEY,
|
|
QL_POWERUP_RESET,
|
|
QL_POWERUP_VBAT,
|
|
QL_POWERUP_RTC,
|
|
QL_POWERUP_FAULT,
|
|
QL_POWERUP_VBUS,
|
|
}QL_POWERUP_REASON_E;
|
|
|
|
typedef enum QL_POWERDOWN_REASON_ENUM
|
|
{
|
|
QL_POWERDOWN_NO_REASON = 0,
|
|
QL_POWERDOWN_PWRKEY,
|
|
QL_POWERDOWN_VINLDO_HIGH,
|
|
QL_POWERDOWN_VINLDO_LOW,
|
|
QL_POWERDOWN_OVERTEMP,
|
|
QL_POWERDOWN_WDT,
|
|
QL_POWERDOWN_VRTC_LOW,
|
|
}QL_POWERDOWN_REASON_E;
|
|
|
|
typedef enum QL_SW_RESTART_REASON_ENUM
|
|
{
|
|
QL_RSTREASON_POWEROFF_CHARGE = 'C', //Charging in "powering off" mode
|
|
QL_RSTREASON_RD_PRODUCTION = 'R', //Rd production mode
|
|
QL_RSTREASON_RTC_ALARM = 'A', //rtc Alarm
|
|
QL_RSTREASON_NORMAL_POWERON = 'N', //Normal powering on
|
|
QL_RSTREASON_ERROR_CONDITION = 'E', //Error reset, eg. watchdog reset triggered by system hang or silent reset
|
|
QL_RSTREASON_ENTER_DOWNLOAD = 'D', //image Download mode
|
|
} QL_SW_RESTART_REASON_E;
|
|
|
|
typedef void* ql_sleep_flags_ref ;
|
|
|
|
typedef enum QL_SLEEP_FLAG_ENUM
|
|
{
|
|
QL_NOT_ALLOW_SLEEP = 0,
|
|
QL_ALLOW_SLEEP,
|
|
}QL_SLEEP_FLAG_E;
|
|
|
|
void ql_sleep_flags_init(void);
|
|
unsigned int ql_sleep_flags_create(ql_sleep_flags_ref *group_ref , char *name_ptr);
|
|
unsigned int ql_sleep_flags_set(ql_sleep_flags_ref group_ref,unsigned int flags_to_set,unsigned int set_option);
|
|
unsigned int ql_sleep_flags_group_delete(ql_sleep_flags_ref group_ref);
|
|
unsigned int ql_get_current_sleep_flags(ql_sleep_flags_ref group_ref,unsigned int *current_flag_ptr);
|
|
void ql_autosleep_enable(QL_SLEEP_FLAG_E sleep_flag);
|
|
void ql_set_cam_vdd_output(unsigned char on_off);
|
|
void ql_power_down(unsigned char normal_flag);
|
|
void ql_power_reset(void);
|
|
void ql_power_reset_fast(void);
|
|
int ql_get_powerup_reason(void);
|
|
int ql_get_powerdown_reason(void);
|
|
unsigned short ql_get_battery_vol(void);
|
|
typedef void (*ql_pwrkey_cb)(void);
|
|
unsigned char ql_get_pwrkey_status(void);
|
|
void ql_pwrkey_register_irq(ql_pwrkey_cb callback);
|
|
void ql_pwrkey_intc_enable(unsigned char onoff);
|
|
unsigned char ql_get_vbus_state(void);
|
|
void ql_create_a_fake_wake_source(QL_SW_RESTART_REASON_E reason);
|
|
QL_SW_RESTART_REASON_E ql_get_the_fake_wake_source(void);
|
|
void ql_power_watchdog_reset(void);
|
|
int ql_lpm_wakelock_create(char *lock_name, int name_size);
|
|
void ql_lpm_wakelock_delete(int wakelock_fd);
|
|
int ql_lpm_wakelock_lock(int wakelock_fd);
|
|
int ql_lpm_wakelock_unlock(int wakelock_fd);
|
|
int ql_lpm_get_wakelock_num(void);
|
|
void ql_create_a_fake_wake_source(QL_SW_RESTART_REASON_E reason);
|
|
QL_SW_RESTART_REASON_E ql_get_the_fake_wake_source(void);
|
|
int ql_powerdown_rtc_in_work(int flag);
|
|
void ql_autosleep_enable_ex(QL_SLEEP_FLAG_E sleep_flag,unsigned short no_data_time,unsigned short punish_time);
|
|
int ql_set_powerdown_threshold(int level);
|
|
|
|
void ql_watchdogReset(void);
|
|
#ifdef __cplusplus
|
|
} /*"C" */
|
|
#endif
|
|
|
|
#endif /* _QL_POWER_H_ */
|
|
|
|
|