summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2016-08-22 16:15:59 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-24 02:15:09 -0700
commitf322e32a3ec052be3f0c226145448fed63aa7ef9 (patch)
tree0baf8f4e3bb04016413cefbd30a502fd6a2c3874
parent748b5bad9fb17d13c89d3e446bd6ef3a4ec55e59 (diff)
downloadchrome-ec-f322e32a3ec052be3f0c226145448fed63aa7ef9.tar.gz
apollolake: Do not power-on AP till sufficient power is provided
Do not power-on the AP unless battery can provide sufficient power or the charger is negotiated to sufficient power. BUG=chrome-os-partner:56494 BRANCH=none TEST=Manually tested on Reef. Device can boot to OS without the battery & cut-off battery. Change-Id: Ib22bad81a29ccbb2fecc8e835148b627dd722988 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/374023 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--board/reef/battery.c20
-rw-r--r--power/apollolake.c6
2 files changed, 19 insertions, 7 deletions
diff --git a/board/reef/battery.c b/board/reef/battery.c
index 5227a4b556..850fc1a571 100644
--- a/board/reef/battery.c
+++ b/board/reef/battery.c
@@ -34,6 +34,14 @@ static const struct battery_info info = {
.discharging_max_c = 60,
};
+#ifdef CONFIG_BATTERY_PRESENT_CUSTOM
+static inline enum battery_present battery_hw_present(void)
+{
+ /* The GPIO is low when the battery is physically present */
+ return gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES;
+}
+#endif
+
const struct battery_info *battery_get_info(void)
{
return &info;
@@ -105,8 +113,12 @@ enum battery_disconnect_state battery_get_disconnect_state(void)
if (rv || data[2] || data[3] || data[4] || data[5])
return BATTERY_DISCONNECT_ERROR;
- /* No safety fault, battery is disconnected */
- return BATTERY_DISCONNECTED;
+ /*
+ * Battery is present and also the status is initialized and
+ * no safety fault, battery is disconnected.
+ */
+ if (battery_is_present() == BP_YES)
+ return BATTERY_DISCONNECTED;
}
not_disconnected = 1;
return BATTERY_NOT_DISCONNECTED;
@@ -296,8 +308,8 @@ enum battery_present battery_is_present(void)
enum battery_present batt_pres;
int batt_status;
- /* The GPIO is low when the battery is physically present */
- batt_pres = gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES;
+ /* Get the physical hardware status */
+ batt_pres = battery_hw_present();
/*
* Make sure battery status is implemented, I2C transactions are
diff --git a/power/apollolake.c b/power/apollolake.c
index c477064c8d..3710579c3e 100644
--- a/power/apollolake.c
+++ b/power/apollolake.c
@@ -256,9 +256,6 @@ static enum power_state _power_handle_state(enum power_state state)
/* Platform is powering up, clear forcing_coldreset */
forcing_coldreset = 0;
- /* Call hooks to initialize PMIC */
- hook_notify(HOOK_CHIPSET_PRE_INIT);
-
/*
* Allow up to 1s for charger to be initialized, in case
* we're trying to boot the AP with no battery.
@@ -276,6 +273,9 @@ static enum power_state _power_handle_state(enum power_state state)
return POWER_G3;
}
+ /* Call hooks to initialize PMIC */
+ hook_notify(HOOK_CHIPSET_PRE_INIT);
+
/* Wait for RSMRST_L de-assert */
if (power_wait_signals(IN_PGOOD_ALL_CORE)) {
chipset_force_shutdown();