summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoy Cho <joy.cho@hardkernel.com>2020-10-15 10:24:47 +0300
committerJoy Cho <joy.cho@hardkernel.com>2020-12-02 10:33:56 +0300
commitb7bd78044cdaeffa3ac4ab48d58c99945dca078e (patch)
tree762b48a15c403f88a8c06fca671f01297d23e3d3
parenta8c5836212bbf39db1bc2dee76fc9cf646fce653 (diff)
downloadu-boot-b7bd78044cdaeffa3ac4ab48d58c99945dca078e.tar.xz
ODROID-GO3: Support battery & charge monitoring
Change-Id: I9d291d75bf5db2719c1bb02e992b578f675b26bc
-rw-r--r--board/rockchip/odroidgo3/odroidgo3.c11
-rwxr-xr-xbuild_recovery.sh9
-rw-r--r--drivers/power/charge_animation.c42
-rw-r--r--drivers/video/drm/rockchip_panel.c9
-rw-r--r--tools/images/hardkernel/battery_0_b.bmpbin0 -> 1229814 bytes
-rw-r--r--tools/images/hardkernel/battery_1_b.bmpbin0 -> 1229814 bytes
-rw-r--r--tools/images/hardkernel/battery_2_b.bmpbin0 -> 1229814 bytes
-rw-r--r--tools/images/hardkernel/battery_3_b.bmpbin0 -> 1229814 bytes
-rw-r--r--tools/images/hardkernel/battery_fail_b.bmpbin0 -> 1229814 bytes
9 files changed, 48 insertions, 23 deletions
diff --git a/board/rockchip/odroidgo3/odroidgo3.c b/board/rockchip/odroidgo3/odroidgo3.c
index 5df3caeea3..ad3840f550 100644
--- a/board/rockchip/odroidgo3/odroidgo3.c
+++ b/board/rockchip/odroidgo3/odroidgo3.c
@@ -13,7 +13,9 @@
#include <key.h>
#include <fs.h>
#include <version.h>
-
+#ifdef CONFIG_DM_CHARGE_DISPLAY
+#include <power/charge_display.h>
+#endif
#include <rockchip_display_cmds.h>
#include "odroidgo3_status.h"
@@ -22,6 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;
extern int board_check_recovery(void);
extern void board_odroid_recovery(void);
extern int board_check_power(void);
+extern int odroid_check_dcjack(void);
#define ALIVE_LED_GPIO 17 /* GPIO0_C1 */
#define WIFI_EN_GPIO 110 /* GPIO3_B6 */
@@ -160,6 +163,12 @@ int rk_board_late_init(void)
/* never get here */
}
+#ifdef CONFIG_DM_CHARGE_DISPLAY
+ if (odroid_check_dcjack() &&
+ (CMD_RET_SUCCESS != run_command("fatload mmc 1:1 $loadaddr manufacture", 0)))
+ charge_display();
+#endif
+
/* show boot logo and version */
lcd_show_logo();
lcd_setfg_color("white");
diff --git a/build_recovery.sh b/build_recovery.sh
index fd4825a832..8fb3abfde5 100755
--- a/build_recovery.sh
+++ b/build_recovery.sh
@@ -36,18 +36,25 @@ if [ ${BOARD} = "odroidgo3" ]; then
dd if=${IMAGES}/recovery_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9192 conv=fsync,notrunc
dd if=${IMAGES}/system_error_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9592 conv=fsync,notrunc
dd if=${IMAGES}/no_sdcard_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9992 conv=fsync,notrunc
+
+ dd if=${IMAGES}/battery_0_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=10392 conv=fsync,notrunc
+ dd if=${IMAGES}/battery_1_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=10792 conv=fsync,notrunc
+ dd if=${IMAGES}/battery_2_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11192 conv=fsync,notrunc
+ dd if=${IMAGES}/battery_3_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11592 conv=fsync,notrunc
+ dd if=${IMAGES}/battery_fail_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11992 conv=fsync,notrunc
else
dd if=${IMAGES}/logo_hardkernel.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=8392 conv=fsync,notrunc
dd if=${IMAGES}/low_battery.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=8792 conv=fsync,notrunc
dd if=${IMAGES}/recovery.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9192 conv=fsync,notrunc
dd if=${IMAGES}/system_error.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9592 conv=fsync,notrunc
dd if=${IMAGES}/no_sdcard.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9992 conv=fsync,notrunc
-fi
+
dd if=${IMAGES}/battery_0.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=10392 conv=fsync,notrunc
dd if=${IMAGES}/battery_1.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=10792 conv=fsync,notrunc
dd if=${IMAGES}/battery_2.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11192 conv=fsync,notrunc
dd if=${IMAGES}/battery_3.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11592 conv=fsync,notrunc
dd if=${IMAGES}/battery_fail.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11992 conv=fsync,notrunc
+fi
rm ${IMAGES}/*.bmp.gz
md5sum ${OUT}/spi_recovery.img > ${OUT}/spi_recovery.img.md5sum
diff --git a/drivers/power/charge_animation.c b/drivers/power/charge_animation.c
index 37c579fe05..2451f54427 100644
--- a/drivers/power/charge_animation.c
+++ b/drivers/power/charge_animation.c
@@ -29,7 +29,7 @@
#include <irq-generic.h>
#include <rk_timer_irq.h>
#endif
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
#include <rockchip_display_cmds.h>
#include <blk.h>
#endif
@@ -74,7 +74,7 @@ struct charge_animation_priv {
* 1. Update the following 'image[]' to point to your own images;
* 2. You must set the failed image as last one and soc = -1 !!!
*/
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
static const struct charge_image image[] = {
{ .name = "battery_0.bmp", .soc = 5, .period = 800 },
{ .name = "battery_1.bmp", .soc = 60, .period = 800 },
@@ -301,17 +301,21 @@ static void autowakeup_timer_uninit(void)
#endif
#ifdef CONFIG_DRM_ROCKCHIP
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
static int bmp_dev;
static void charge_show_bmp(int idx, struct udevice *fg)
{
unsigned long bmp_mem, bmp_copy;
int ret;
- int battery = 0;
+ int battery;
+ int current_avg;
char cmd[64];
- if (fg)
- battery = fuel_gauge_get_voltage(fg);
+ if (!fg)
+ return;
+
+ battery = fuel_gauge_get_voltage(fg);
+ current_avg = fuel_gauge_get_current(fg);
debug("charge_show_bmp idx %d, name %s, battery %d\n", idx, image[idx].name, battery);
@@ -343,9 +347,15 @@ static void charge_show_bmp(int idx, struct udevice *fg)
printf("[%s] show_bmp fail\n", __func__);
/* show battery voltage level */
- sprintf(cmd, "%d.%dV", (battery / 1000), ((battery % 1000) / 100));
+ sprintf(cmd, "battery : %d.%d V", (battery / 1000), ((battery % 1000) / 100));
lcd_setfg_color("white");
- lcd_printf(0, 18, 1, "%s", cmd);
+ lcd_printf(0, 24, 1, "%s", cmd);
+
+ sprintf(cmd, "current %d mA", current_avg);
+ lcd_printf(0, 26, 1, "%s", cmd);
+
+
+ printf("charge_show_bmp end!\n");
}
#else
static void charge_show_bmp(const char *name)
@@ -570,7 +580,7 @@ static int charge_animation_show(struct udevice *dev)
return -EINVAL;
}
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
/* lcd initialization */
lcd_init();
#endif
@@ -579,7 +589,7 @@ static int charge_animation_show(struct udevice *dev)
if (voltage <= pdata->screen_on_voltage + 50) {
screen_on = false;
ever_lowpower_screen_off = true;
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
lcd_onoff(false);
#else
charge_show_bmp(NULL);
@@ -740,7 +750,7 @@ show_images:
if (old_show_idx != show_idx) {
old_show_idx = show_idx;
debug("SHOW: %s\n", image[show_idx].name);
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
charge_show_bmp(show_idx, fg);
#else
charge_show_bmp(image[show_idx].name);
@@ -792,7 +802,7 @@ show_images:
* event turn off the screen and we never show images.
*/
if (screen_on) {
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
lcd_onoff(false);
#else
charge_show_bmp(NULL); /* Turn off screen */
@@ -801,7 +811,7 @@ show_images:
priv->suspend_delay_timeout = get_timer(0);
} else {
screen_on = true;
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
lcd_onoff(true);
#endif
}
@@ -811,7 +821,7 @@ show_images:
/* Set screen_on=true anyway when key long pressed */
if (!screen_on) {
screen_on = true;
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
lcd_onoff(true);
#endif
}
@@ -908,7 +918,7 @@ static int charge_animation_probe(struct udevice *dev)
{
struct charge_animation_priv *priv = dev_get_priv(dev);
int ret, soc;
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
int battery;
#endif
/* Get PMIC: used for power off system */
@@ -948,7 +958,7 @@ static int charge_animation_probe(struct udevice *dev)
return -EINVAL;
}
-#ifdef CONFIG_TARGET_ODROIDGO2
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
/* Check battery existence */
battery = fuel_gauge_get_voltage(priv->fg);
if (battery < 1000) {
diff --git a/drivers/video/drm/rockchip_panel.c b/drivers/video/drm/rockchip_panel.c
index 19719141ba..e26bd83b25 100644
--- a/drivers/video/drm/rockchip_panel.c
+++ b/drivers/video/drm/rockchip_panel.c
@@ -66,10 +66,9 @@ struct rockchip_panel_priv {
struct udevice *backlight;
struct gpio_desc enable_gpio;
struct gpio_desc reset_gpio;
-#if defined(CONFIG_TARGET_ODROIDGO2)
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
struct udevice *backlight_supply;
#endif
-
int cmd_type;
struct gpio_desc spi_sdi_gpio;
struct gpio_desc spi_scl_gpio;
@@ -294,7 +293,7 @@ static void panel_simple_prepare(struct rockchip_panel *panel)
regulator_set_enable(priv->power_supply, !plat->power_invert);
}
-#if defined(CONFIG_TARGET_ODROIDGO2)
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
if (priv->backlight_supply) {
struct dm_regulator_uclass_platdata *uc_pdata;
@@ -376,7 +375,7 @@ static void panel_simple_unprepare(struct rockchip_panel *panel)
if (priv->power_supply)
regulator_set_enable(priv->power_supply, plat->power_invert);
-#if defined(CONFIG_TARGET_ODROIDGO2)
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
if (priv->backlight_supply) {
ret = regulator_set_enable(priv->backlight_supply, 0);
if (ret)
@@ -534,7 +533,7 @@ static int rockchip_panel_probe(struct udevice *dev)
return ret;
}
-#if defined(CONFIG_TARGET_ODROIDGO2)
+#if defined(CONFIG_PLATFORM_ODROID_GOADV)
ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
"backlight-supply", &priv->backlight_supply);
if (ret && ret != -ENOENT) {
diff --git a/tools/images/hardkernel/battery_0_b.bmp b/tools/images/hardkernel/battery_0_b.bmp
new file mode 100644
index 0000000000..b5beb2be45
--- /dev/null
+++ b/tools/images/hardkernel/battery_0_b.bmp
Binary files differ
diff --git a/tools/images/hardkernel/battery_1_b.bmp b/tools/images/hardkernel/battery_1_b.bmp
new file mode 100644
index 0000000000..a6132681ad
--- /dev/null
+++ b/tools/images/hardkernel/battery_1_b.bmp
Binary files differ
diff --git a/tools/images/hardkernel/battery_2_b.bmp b/tools/images/hardkernel/battery_2_b.bmp
new file mode 100644
index 0000000000..50b90d733e
--- /dev/null
+++ b/tools/images/hardkernel/battery_2_b.bmp
Binary files differ
diff --git a/tools/images/hardkernel/battery_3_b.bmp b/tools/images/hardkernel/battery_3_b.bmp
new file mode 100644
index 0000000000..bf56198b6e
--- /dev/null
+++ b/tools/images/hardkernel/battery_3_b.bmp
Binary files differ
diff --git a/tools/images/hardkernel/battery_fail_b.bmp b/tools/images/hardkernel/battery_fail_b.bmp
new file mode 100644
index 0000000000..5d95311c10
--- /dev/null
+++ b/tools/images/hardkernel/battery_fail_b.bmp
Binary files differ