summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/kevin/board.h3
-rw-r--r--power/rk3399.c23
2 files changed, 26 insertions, 0 deletions
diff --git a/board/kevin/board.h b/board/kevin/board.h
index fa41f99c68..4dcca31dbe 100644
--- a/board/kevin/board.h
+++ b/board/kevin/board.h
@@ -56,6 +56,9 @@
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_NARROW_VDC
#define CONFIG_CHARGER_V2
+#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
+#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1
+#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000
#define CONFIG_USB_CHARGER
#define CONFIG_USB_MUX_VIRTUAL
diff --git a/power/rk3399.c b/power/rk3399.c
index 554e5aee3d..8efebaf69a 100644
--- a/power/rk3399.c
+++ b/power/rk3399.c
@@ -5,6 +5,7 @@
/* rk3399 chipset power control module for Chrome EC */
+#include "charge_state.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -43,6 +44,9 @@
/* Long power key press to force shutdown in S0 */
#define FORCED_SHUTDOWN_DELAY (8 * SECOND)
+#define CHARGER_INITIALIZED_DELAY_MS 100
+#define CHARGER_INITIALIZED_TRIES 40
+
static int forcing_shutdown;
void chipset_force_shutdown(void)
@@ -94,6 +98,8 @@ DECLARE_DEFERRED(force_shutdown);
enum power_state power_handle_state(enum power_state state)
{
+ int tries = 0;
+
switch (state) {
case POWER_G3:
break;
@@ -118,6 +124,23 @@ enum power_state power_handle_state(enum power_state state)
case POWER_G3S5:
forcing_shutdown = 0;
+ /*
+ * Allow time for charger to be initialized, in case we're
+ * trying to boot the AP with no battery.
+ */
+ while (charge_prevent_power_on(0) &&
+ tries++ < CHARGER_INITIALIZED_TRIES) {
+ msleep(CHARGER_INITIALIZED_DELAY_MS);
+ }
+
+ /* Return to G3 if battery level is too low. */
+ if (charge_want_shutdown() ||
+ tries > CHARGER_INITIALIZED_TRIES) {
+ CPRINTS("power-up inhibited");
+ chipset_force_shutdown();
+ return POWER_G3;
+ }
+
/* Power up to next state */
return POWER_S5;