summaryrefslogtreecommitdiff
path: root/common/charge_manager.c
diff options
context:
space:
mode:
authorMadhu M <madhu.m@intel.corp-partner.google.com>2020-06-23 14:28:46 +0530
committerCommit Bot <commit-bot@chromium.org>2020-07-06 13:45:50 +0000
commit18da4156ede6570c3ad3cf7c4039b4a9528e3020 (patch)
treef6d5bd5107fde70ad3b730b388dedc5fef67a272 /common/charge_manager.c
parentb98b77be5abb67aec1d94222741de8f9ada3c489 (diff)
downloadchrome-ec-18da4156ede6570c3ad3cf7c4039b4a9528e3020.tar.gz
charge_manager: Port power swap based on presence of battery
Port power swap has to be done only when there is a battery and no battery cutoff BUG=b:149460624 BRANCH=none TEST=1.Remove battery, connect charger on typec port boot the DUT and after boot the DUT connect docking station on another typec port. expected result is no reboot observed 2.Connect battery, connect charger on typec port boot the DUT and after boot the DUT connect docking station on another typec port. expected result is no reboot observed. Signed-off-by: Madhu M <madhu.m@intel.corp-partner.google.com> Change-Id: Iacfae4ecc2e30c6bee5a19aaed030d59efc61e36 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2259522 Reviewed-by: Madhusudanarao Amara <madhusudanarao.amara@intel.com> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'common/charge_manager.c')
-rw-r--r--common/charge_manager.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 22ef0e9532..d0660a3031 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -650,6 +650,21 @@ static void charge_manager_get_best_charge_port(int *new_port,
}
+#ifdef CONFIG_BATTERY
+ /*
+ * if no battery present then retain same charge port
+ * and charge supplier to avoid the port switching
+ */
+ if (charge_port != CHARGE_SUPPLIER_NONE &&
+ charge_port != port &&
+ (battery_is_present() == BP_NO ||
+ (battery_is_present() == BP_YES &&
+ battery_is_cut_off() != BATTERY_CUTOFF_STATE_NORMAL))) {
+ port = charge_port;
+ supplier = charge_supplier;
+ }
+#endif
+
*new_port = port;
*new_supplier = supplier;
}