summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-03-22 20:07:39 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-04-10 19:13:32 -0700
commit46ca9738f23d91148519fdaf31e8791be49855e3 (patch)
tree44c57af9f4710e84ef6735888386b4582cf2719f
parentdccaf9d9fce04a1e2fd1eb51fb85627ef2976146 (diff)
downloadchrome-ec-46ca9738f23d91148519fdaf31e8791be49855e3.tar.gz
chgstv2: Check charger power in prevent_power_on.
charge_prevent_power_on() had sections which were gated on the following CONFIG_* option: CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT However, the block of code that this gated didn't even take the battery percentage into account and made it very confusing as to why. This commit simply changes the CONFIG_* option used to gate to be the following: CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON This better reflects the checks that were actually being made. Additionally, this CONFIG_* option is defined by default for boards that have a chipset task and is initialized to 15W, which is the power that indicates that the charger is likely to speak USB PD. BUG=b:76174140 BRANCH=None TEST=make -j buildall Change-Id: Ic9158dd7109ce6082c6d00157ff266842363b295 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/977431 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r--board/fizz/board.c2
-rw-r--r--board/fizz/board.h4
-rw-r--r--common/charge_state_v2.c39
-rw-r--r--common/system.c9
-rw-r--r--include/config.h21
5 files changed, 46 insertions, 29 deletions
diff --git a/board/fizz/board.c b/board/fizz/board.c
index 24d31a99c8..98f5f36c68 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -511,7 +511,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
* is called.
*/
led_alert(charge_ma * charge_mv <
- CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW * 1000);
+ CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000);
/*
* In terms of timing, this should always work because
diff --git a/board/fizz/board.h b/board/fizz/board.h
index 439870eb66..464b517db8 100644
--- a/board/fizz/board.h
+++ b/board/fizz/board.h
@@ -69,7 +69,7 @@
/* Charger */
#define CONFIG_CHARGE_MANAGER
-#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 50000
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 50000
#define CONFIG_CMD_PD_CONTROL
#define CONFIG_EXTPOWER_GPIO
@@ -233,7 +233,7 @@ enum mft_channel {
/* Define typical operating power. Since Fizz doesn't have a battery to charge,
* we're not interested in any power lower than the AP power-on threshold. */
-#define PD_OPERATING_POWER_MW CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW
+#define PD_OPERATING_POWER_MW CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
#define PD_MAX_POWER_MW 100000
#define PD_MAX_CURRENT_MA 5000
#define PD_MAX_VOLTAGE_MV 20000
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 3c8a0d80a6..884daef387 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -41,9 +41,6 @@
#define PRECHARGE_TIMEOUT_US (PRECHARGE_TIMEOUT * SECOND)
#define LFCC_EVENT_THRESH 5 /* Full-capacity change reqd for host event */
-/* Prior to negotiating PD, most PD chargers advertise 15W */
-#define LIKELY_PD_USBC_POWER_MW 15000
-
static int charge_request(int voltage, int current);
/*
@@ -1821,24 +1818,22 @@ int charge_prevent_power_on(int power_button_pressed)
battery_get_params(&params);
current_batt_params = &params;
}
+
/* Require a minimum battery level to power on */
if (current_batt_params->is_present != BP_YES ||
current_batt_params->state_of_charge <
CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
prevent_power_on = 1;
-#ifdef CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT
- /*
- * Allow power-on if our charger advertises more than
- * LIKELY_PD_USBC_POWER_MW since it may speak PD and provide
- * sufficient power once we enable PD communication.
- */
+#ifdef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+#ifdef CONFIG_CHARGE_MANAGER
+ /* However, we can power on if a sufficient charger is present. */
if (prevent_power_on)
if (charge_manager_get_power_limit_uw() >=
- MIN(LIKELY_PD_USBC_POWER_MW * 1000,
- CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW * 1000))
+ CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000)
prevent_power_on = 0;
-#endif
+#endif /* defined(CONFIG_CHARGE_MANAGER) */
+#endif /* defined(CONFIG_CHARGER_MIN_POWER_FOR_POWER_ON) */
/*
* Factory override: Always allow power on if WP is disabled,
@@ -1861,19 +1856,17 @@ int charge_prevent_power_on(int power_button_pressed)
#ifdef CONFIG_BATTERY_HW_PRESENT_CUSTOM
/*
* If battery is NOT physically present then prevent power on until
- * charge manager provides at least LIKELY_PD_USBC_POWER_MW.
+ * a sufficient charger is present.
*/
- if (extpower_is_present() && battery_hw_present() == BP_NO &&
- charge_manager_get_power_limit_uw() <
-#ifdef CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT
- MIN(LIKELY_PD_USBC_POWER_MW * 1000,
- CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW * 1000))
-#else
- (LIKELY_PD_USBC_POWER_MW * 1000))
-#endif
+ if (extpower_is_present() && battery_hw_present() == BP_NO
+#ifdef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+ && charge_manager_get_power_limit_uw() <
+ CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000
+#endif /* CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON */
+ )
prevent_power_on = 1;
-#endif
-#endif
+#endif /* CONFIG_BATTERY_HW_PRESENT_CUSTOM */
+#endif /* CONFIG_CHARGE_MANAGER */
return prevent_power_on;
}
diff --git a/common/system.c b/common/system.c
index 48c26776b9..1699b5b3fa 100644
--- a/common/system.c
+++ b/common/system.c
@@ -1491,13 +1491,16 @@ int system_can_boot_ap(void)
power_good = 1;
#endif
-#ifdef CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW
+#ifdef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+#ifdef CONFIG_CHARGE_MANAGER
if (!power_good) {
pow = charge_manager_get_power_limit_uw() / 1000;
- if (pow >= CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW)
+ if (pow >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON)
power_good = 1;
}
-#endif
+#endif /* CONFIG_CHARGE_MANAGER */
+#endif /* CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON */
+
if (!power_good)
CPRINTS("Not enough power to boot: chg=%d pwr=%d", soc, pow);
diff --git a/include/config.h b/include/config.h
index 76cc1646ca..ca44183ef1 100644
--- a/include/config.h
+++ b/include/config.h
@@ -626,6 +626,9 @@
/* Minimum battery percentage for power on */
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
+/* Minimum charger power (in mW) required for powering on. */
+#undef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+
/* Set this option when using a Narrow VDC (NVDC) charger, such as ISL9237/8. */
#undef CONFIG_CHARGER_NARROW_VDC
@@ -3452,6 +3455,24 @@
#undef CONFIG_POWER_TRACK_HOST_SLEEP_STATE
#endif
+/*
+ * If a board has a chipset task, set the minimum charger power required for
+ * powering on to 15W. This is also the highest power discovered over Type-C.
+ * The EC normally does not communicate using USB PD when the system is locked
+ * and in RO, so it would not be able to tell if higher power is available.
+ * However, if a 15W charger is discovered, it's likely that the charger does
+ * speak USB PD and we would be able to negotiate more power after booting the
+ * AP and jumping to EC RW.
+ *
+ * If a board needs more or less power to power on, they can re-define this
+ * value in their board.h file.
+ */
+#ifdef HAS_TASK_CHIPSET
+#ifndef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15000
+#endif /* !defined(CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON) */
+#endif /* defined(HAS_TASK_CHIPSET) */
+
#ifndef HAS_TASK_KEYPROTO
#undef CONFIG_KEYBOARD_PROTOCOL_8042
/*