summaryrefslogtreecommitdiff
path: root/board/kukui
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2019-08-02 20:29:30 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-06 10:42:25 +0000
commit8e6cbfe9da81862da48c250737cb9e77d175b2b3 (patch)
tree084b7d20f2ad4866b97ffa63235f804dad581db9 /board/kukui
parent2cfd12facff02ead45addb10c4dd363402eb8898 (diff)
downloadchrome-ec-8e6cbfe9da81862da48c250737cb9e77d175b2b3.tar.gz
kukui: fix tcpc_init failed on kukui
Calling board_pogo_charge_init() when DEDICATED_CHARGE_PORT disabled causes buffer overflow inside charge manager, move the function to a suitable place to fix the issue. BUG=b:138741956 TEST=flash and verify that kukui is bootable BRANCH=master Change-Id: I43d8aabf8fd21ed62a37671ba7cd471c8c188b9f Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1731212 Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Yilun Lin <yllin@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org>
Diffstat (limited to 'board/kukui')
-rw-r--r--board/kukui/base_detect_krane.c11
-rw-r--r--board/kukui/board.c13
-rw-r--r--board/kukui/board.h2
3 files changed, 15 insertions, 11 deletions
diff --git a/board/kukui/base_detect_krane.c b/board/kukui/base_detect_krane.c
index 2ec9fa7d2e..13f0fc6744 100644
--- a/board/kukui/base_detect_krane.c
+++ b/board/kukui/base_detect_krane.c
@@ -159,3 +159,14 @@ static void base_init(void)
hook_call_deferred(&base_detect_deferred_data, 0);
}
DECLARE_HOOK(HOOK_INIT, base_init, HOOK_PRIO_INIT_ADC + 1);
+
+static void board_pogo_charge_init(void)
+{
+ int i;
+
+ /* Initialize all charge suppliers to 0 */
+ for (i = 0; i < CHARGE_SUPPLIER_COUNT; i++)
+ charge_manager_update_charge(i, CHARGE_PORT_POGO, NULL);
+}
+DECLARE_HOOK(HOOK_INIT, board_pogo_charge_init,
+ HOOK_PRIO_CHARGE_MANAGER_INIT + 1);
diff --git a/board/kukui/board.c b/board/kukui/board.c
index 3f6fa326a4..2f6315426b 100644
--- a/board/kukui/board.c
+++ b/board/kukui/board.c
@@ -117,17 +117,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-static void board_pogo_charge_init(void)
-{
- int i;
-
- /* Initialize all charge suppliers to 0 */
- for (i = 0; i < CHARGE_SUPPLIER_COUNT; i++)
- charge_manager_update_charge(i, CHARGE_PORT_POGO, NULL);
-}
-DECLARE_HOOK(HOOK_INIT, board_pogo_charge_init,
- HOOK_PRIO_CHARGE_MANAGER_INIT + 1);
-
static int force_discharge;
int board_set_active_charge_port(int charge_port)
@@ -146,10 +135,12 @@ int board_set_active_charge_port(int charge_port)
gpio_set_level(GPIO_EN_POGO_CHARGE_L, 1);
gpio_set_level(GPIO_EN_USBC_CHARGE_L, 0);
break;
+#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
case CHARGE_PORT_POGO:
gpio_set_level(GPIO_EN_USBC_CHARGE_L, 1);
gpio_set_level(GPIO_EN_POGO_CHARGE_L, 0);
break;
+#endif
case CHARGE_PORT_NONE:
/*
* To ensure the fuel gauge (max17055) is always powered
diff --git a/board/kukui/board.h b/board/kukui/board.h
index 2b03844cb2..b6561b13f1 100644
--- a/board/kukui/board.h
+++ b/board/kukui/board.h
@@ -114,7 +114,9 @@ enum sensor_id {
enum charge_port {
CHARGE_PORT_USB_C,
+#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
CHARGE_PORT_POGO,
+#endif
};
#include "ec_commands.h"