说明
该补丁需要修改 cmd_charge.c 文件的代码, 该文件位置在 uboot 文件夹下,
修改源码
diff --git a/include/configs/rk30plat.h b/include/configs/rk30plat.h
index 3a25fc7..d768832 100755
--- a/include/configs/rk30plat.h
+++ b/include/configs/rk30plat.h
@@ -215,7 +215,8 @@
#define CONFIG_RK32_DSI
#endif /* CONFIG_RKCHIP_RK3126 */
-#undef CONFIG_UBOOT_CHARGE
+/* #undef CONFIG_UBOOT_CHARGE */
+#define CONFIG_UBOOT_CHARGE
#else
diff --git a/common/cmd_charge.c b/common/cmd_charge.c
index f9ce5bd..6fb7980 100755
--- a/common/cmd_charge.c
+++ b/common/cmd_charge.c
@@ -22,7 +22,7 @@
#include <resource.h>
#include <asm/arch/rkplat.h>
-/*#define DEBUG*/
+//#define DEBUG
#define LOGE(fmt, args...) printf(fmt "\n", ##args)
#ifdef DEBUG
#define LOGD(fmt, args...) printf(fmt "\n", ##args)
@@ -50,6 +50,7 @@
#define NOT_EXIT 0
#define EXIT_BOOT 1
#define EXIT_SHUTDOWN 2
+#define EXIT_WITHOUT_BAT 3
#define DEF_CHARGE_DESC_PATH "charge_anim_desc.txt"
#define DEFAULT_ANIM_DELAY 80000 //us
@@ -78,6 +79,11 @@ u8 g_increment = 0;
int timer_interrupt_wakeup = 0;
+static inline unsigned int diff_fix_duration(unsigned int base) {
+ unsigned int max = 0xFFFFFFFF / 24000;
+ return max - base;
+}
+
//return duration(ms).
static inline unsigned int get_fix_duration(unsigned int base) {
unsigned int max = 0xFFFFFFFF / 24000;
@@ -149,7 +155,7 @@ int power_key_pressed(void) {
if (power_pressed) {
//still pressing
#define LONG_PRESSED_TIME 2000 //2s
- if (get_fix_duration(power_pressed_time) >= LONG_PRESSED_TIME) {
+ if (diff_fix_duration(get_fix_duration(power_pressed_time)) >= LONG_PRESSED_TIME) {
//long pressed.
power_pressed_state = KEY_LONG_PRESSED;
}
@@ -216,23 +222,25 @@ int check_charging(void) {
get_power_bat_status(&batt_status);
// if no exist bat but charging
- if((batt_status.state_of_chrg)&&(!batt_status.isexistbat))
- {
- printf("charging but no exist batterry!.");
- return EXIT_BOOT;
+ /* Modity Tower 20180127 */
+ if((batt_status.state_of_chrg) && (!batt_status.isexistbat)) {
+ printf("ERROR: charging but no exist batterry!. \n");
+ return EXIT_WITHOUT_BAT;
+ //return EXIT_BOOT;
}
-
- if(!batt_status.state_of_chrg)
- {
- printf("pmic not charging.");
+
+ if(!batt_status.state_of_chrg) {
+ printf("INFO: pmic not charging. \n");
pmic_charger_setting(0);
return EXIT_SHUTDOWN;
}
+
/*
- if (check cap enough)
- return EXIT_BOOT;
- */
- return 0;
+ if (check cap enough)
+ return EXIT_BOOT;
+ */
+
+ return NOT_EXIT;
}
/**
@@ -265,11 +273,13 @@ static anim_level_conf* level_confs = NULL;
static int level_conf_num = 0;
static int only_current_level = false;
static char bat_err_path[MAX_INDEX_ENTRY_PATH_LEN];
+static char bat_without_path[MAX_INDEX_ENTRY_PATH_LEN];
#define OPT_CHARGE_ANIM_DELAY "delay="
#define OPT_CHARGE_ANIM_LOOP_CUR "only_current_level="
#define OPT_CHARGE_ANIM_LEVELS "levels="
#define OPT_CHARGE_ANIM_BAT_ERROR "bat_error="
+#define OPT_CHARGE_ANIM_BAT_WITHOUT "bat_without="
#define OPT_CHARGE_ANIM_LEVEL_CONF "min_level="
#define OPT_CHARGE_ANIM_LEVEL_NUM "num="
#define OPT_CHARGE_ANIM_LEVEL_PFX "prefix="
@@ -421,6 +431,12 @@ static bool load_anim_desc(const char* desc_path, bool dump) {
snprintf(bat_err_path, sizeof(bat_err_path), "%s",
arg + strlen(OPT_CHARGE_ANIM_BAT_ERROR));
LOGD("Found battery error image:%s", bat_err_path);
+
+ } else if (!memcmp(arg, OPT_CHARGE_ANIM_BAT_WITHOUT,
+ strlen(OPT_CHARGE_ANIM_BAT_WITHOUT))) {
+ snprintf(bat_without_path, sizeof(bat_without_path), "%s",
+ arg + strlen(OPT_CHARGE_ANIM_BAT_WITHOUT));
+ LOGD("Found battery without image:%s", bat_without_path);
} else {
LOGE("Unknown arg:%s", arg);
continue;
@@ -702,13 +718,14 @@ int do_charge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#endif
//step 2: handle timeouts.
if (IS_BRIGHT(g_state.brightness)) {
- unsigned int idle_time = get_fix_duration(g_state.screen_on_time);
+ unsigned int idle_time = diff_fix_duration(get_fix_duration(g_state.screen_on_time));
//printf("idle_time:%ld\n", idle_time);
+#if 1
if (idle_time > SCREEN_OFF_TIMEOUT) {
LOGD("screen off");
brightness = SCREEN_OFF;
}
- #if 0
+#else
if (idle_time > SCREEN_OFF_TIMEOUT) {
LOGD("screen off");
brightness = SCREEN_OFF;
@@ -716,7 +733,7 @@ int do_charge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
LOGD("screen dim");
brightness = SCREEN_DIM;
}
- #endif
+#endif
}
//step 3: check power key pressed state.
@@ -761,7 +778,7 @@ int do_charge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#ifdef CONFIG_CHARGE_TIMER_WAKEUP
timer1_irq_deinit();
#endif
- //close some ldo
+ //on some ldo
power_on_pmic();
mdelay(10);
@@ -774,7 +791,7 @@ int do_charge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
//step 5:step anim when screen is on.
if (IS_BRIGHT(brightness)) {
//do anim when screen is on.
- unsigned int duration = get_fix_duration(anim_time) * 1000;
+ unsigned int duration = diff_fix_duration(get_fix_duration(anim_time));
if (!IS_BRIGHT(g_state.brightness)
|| duration >= get_delay(&g_state)) {
anim_time = get_timer(0);
@@ -788,9 +805,19 @@ int do_charge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
//udelay(100);// 50ms.
}
exit:
+ /* If there is no battery */
+ if (exit_type == EXIT_WITHOUT_BAT) {
+ set_brightness(SCREEN_BRIGHT, &g_state);
+ //TODO:show warning logo.
+ show_resource_image("images/battery_without.bmp");
+ udelay(3000000); //3 sec.
+ exit_type = EXIT_BOOT;
+ }
+
/* disable fb buffer flip */
lcd_enable_flip(false);
set_brightness(SCREEN_OFF, &g_state);
+
if (exit_type == EXIT_BOOT) {
#ifdef CONFIG_POWER_FG_ADC
if(fg_adc_storage_flag_load()==0)
diff --git a/drivers/power/fuel_gauge/fg_rk816.c b/drivers/power/fuel_gauge/fg_rk816.c
index eaa8da2..270c1c9 100755
--- a/drivers/power/fuel_gauge/fg_rk816.c
+++ b/drivers/power/fuel_gauge/fg_rk816.c
@@ -1317,8 +1317,10 @@ static int rk816_bat_update(struct pmic *p, struct pmic *bat)
}
battery->state_of_chrg = rk816_fg.di.state_of_chrg;
- battery->isexistbat = 1;
-
+ // Modify Tower 20191112
+ //battery->isexistbat = 1;
+ battery->isexistbat = !rk816_fg.di.virtual_power;
+
return 0;
}
diff --git a/tools/resource_tool/resources/charge_anim_desc.txt b/tools/resource_tool/resources/charge_anim_desc.txt
old mode 100644
new mode 100755
index 40faf88..cf2d07d
--- a/tools/resource_tool/resources/charge_anim_desc.txt
+++ b/tools/resource_tool/resources/charge_anim_desc.txt
@@ -1,5 +1,5 @@
#default anim delay.
-delay=900
+delay=1
#only show current level's pics.
only_current_level=false
@@ -7,6 +7,9 @@ only_current_level=false
#reserve.
bat_error=images/battery_fail.bmp
+#without battery
+bat_without=images/battery_fail.bmp
+
#num of level configs.
levels=6
diff --git a/tools/resource_tool/resources/images/battery_without.bmp b/tools/resource_tool/resources/images/battery_without.bmp
new file mode 100755
index 0000000..2ec45b3
Binary files /dev/null and b/tools/resource_tool/resources/images/battery_without.bmp differ