diff options
author | Joy Cho <joy.cho@hardkernel.com> | 2021-01-06 11:57:10 +0900 |
---|---|---|
committer | Joy Cho <joy.cho@hardkernel.com> | 2021-01-08 09:07:17 +0900 |
commit | 4038ab6d6840e56177405c14129a1f19d21e7f10 (patch) | |
tree | 457dfa66000155fb09a7e4cbd23113070ba0daa5 | |
parent | c75d9e995e93955ec4bd806067bbfe7c8ef69a1d (diff) | |
download | u-boot-odroid-c1-4038ab6d6840e56177405c14129a1f19d21e7f10.tar.gz |
ODROID-GOA: charge: Add user indication in case of extreme low voltage
Change-Id: Ibc50d956d7dcbb1b0f27213b7aeab39f41b9841a
-rw-r--r-- | drivers/power/charge_animation.c | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/drivers/power/charge_animation.c b/drivers/power/charge_animation.c index 662a8f751e..5ed7bd8e34 100644 --- a/drivers/power/charge_animation.c +++ b/drivers/power/charge_animation.c @@ -119,9 +119,14 @@ static int charge_animation_ofdata_to_platdata(struct udevice *dev) pdata->low_power_voltage = dev_read_u32_default(dev, "rockchip,uboot-low-power-voltage", 0); - +#if defined(CONFIG_PLATFORM_ODROID_GOADV) + /* show charge animation if battery voltage is over low-power-voltage */ + pdata->screen_on_voltage = + dev_read_u32_default(dev, "rockchip,uboot-low-power-voltage", 0); +#else pdata->screen_on_voltage = dev_read_u32_default(dev, "rockchip,screen-on-voltage", 0); +#endif pdata->system_suspend = dev_read_u32_default(dev, "rockchip,system-suspend", 0); @@ -329,7 +334,9 @@ static void charge_show_bmp(int idx, struct udevice *fg) ret = run_command(cmd, 0); if (ret != CMD_RET_SUCCESS) bmp_dev = 0xff; - } else { + } + + if (bmp_dev == 0xff) { ulong n, cnt, blk; blk = env_get_hex(image_sf[idx], 0); cnt = env_get_hex("sz_logo", 0); @@ -435,6 +442,8 @@ static int charge_extrem_low_power(struct udevice *dev) int voltage, soc, charging = 1; static int timer_initialized; int ret; + bool screen_on = true; /* screen is activated from lcd_init */ + ulong disp_start = 0; voltage = fuel_gauge_get_voltage(fg); if (voltage < 0) @@ -476,6 +485,21 @@ static int charge_extrem_low_power(struct udevice *dev) if (ret) printf("update led failed: %d\n", ret); + if (!disp_start) { + disp_start = get_timer(0); + + /* display low voltage status */ + charge_show_bmp(4, fg); /* battery fail */ + + lcd_printf(0, 15 + disp_offs, 1, "Extreme Low Battery, please wait until changed to 5%"); + lcd_printf(0, 16 + disp_offs, 1, " LCD will be off soon."); + } + + if ((get_timer(disp_start) > 5000) && screen_on) { + lcd_onoff(false); + screen_on = false; /* never turn on again here */ + } + printf("Extrem low power, force charging... threshold=%dmv, now=%dmv\n", pdata->low_power_voltage, voltage); @@ -493,8 +517,14 @@ static int charge_extrem_low_power(struct udevice *dev) printf("Extrem low charge: exit by ctrl+c\n"); break; } + + mdelay(500); + } + if (!screen_on) + lcd_onoff(true); + autowakeup_timer_uninit(); return 0; @@ -538,6 +568,11 @@ static int charge_animation_show(struct udevice *dev) return 0; } +#if defined(CONFIG_PLATFORM_ODROID_GOADV) + /* lcd initialization */ + lcd_init(); +#endif + /* Extrem low power charge */ ret = charge_extrem_low_power(dev); if (ret < 0) { @@ -587,11 +622,6 @@ static int charge_animation_show(struct udevice *dev) return -EINVAL; } -#if defined(CONFIG_PLATFORM_ODROID_GOADV) - /* lcd initialization */ - lcd_init(); -#endif - /* If low power, turn off screen */ if (voltage <= pdata->screen_on_voltage + 50) { screen_on = false; |