power: charge animation: add rtc alarm check

Under the charging interface,if the rtc alarm is
triggered, boot on the system.

Change-Id: I6a921bd5c6971c45b02b2be84d9d6d79e9b17a36
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
This commit is contained in:
Elaine Zhang 2019-02-05 03:00:55 +08:00 committed by Jianhong Chen
parent 47bc0dad56
commit 8b436ce576
1 changed files with 23 additions and 2 deletions

View File

@ -11,6 +11,7 @@
#include <dm.h>
#include <errno.h>
#include <key.h>
#include <rtc.h>
#include <pwm.h>
#include <asm/arch/rockchip_smccc.h>
#include <asm/suspend.h>
@ -42,6 +43,7 @@ struct charge_image {
struct charge_animation_priv {
struct udevice *pmic;
struct udevice *fg;
struct udevice *rtc;
const struct charge_image *image;
int image_num;
@ -112,7 +114,16 @@ static int check_key_press(struct udevice *dev)
{
struct charge_animation_pdata *pdata = dev_get_platdata(dev);
struct charge_animation_priv *priv = dev_get_priv(dev);
u32 state;
u32 state, rtc_state = 0;
#ifdef CONFIG_DM_RTC
if (priv->rtc)
rtc_state = rtc_alarm_trigger(priv->rtc);
#endif
if (rtc_state) {
printf("rtc alarm trigger...\n");
return KEY_PRESS_LONG_DOWN;
}
state = key_read(KEY_POWER);
if (state < 0)
@ -671,7 +682,7 @@ static const struct dm_charge_display_ops charge_animation_ops = {
static int charge_animation_probe(struct udevice *dev)
{
struct charge_animation_priv *priv = dev_get_priv(dev);
struct udevice *fg, *pmic;
struct udevice *fg, *pmic, *rtc;
int ret, soc;
/* Get PMIC: used for power off system */
@ -696,6 +707,16 @@ static int charge_animation_probe(struct udevice *dev)
}
priv->fg = fg;
/* Get rtc: used for power on */
ret = uclass_get_device(UCLASS_RTC, 0, &rtc);
if (ret) {
if (ret == -ENODEV)
debug("Can't find RTC\n");
else
debug("Get UCLASS RTC failed: %d\n", ret);
}
priv->rtc = rtc;
/* Get PWRKEY: used for wakeup and turn off/on LCD */
if (key_read(KEY_POWER) == KEY_NOT_EXIST) {
debug("Can't find power key\n");