summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lok <ben.lok@mediatek.com>2015-12-31 20:31:57 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-01-08 05:04:45 -0800
commit863d0b81fd658e1becb5e1cadd4169189ebdc872 (patch)
treeef99c5775c3dc9b4c513dccba031cac5ea2a6974
parent126f48aa3f31065cb0f340a68219fa7894f1b53b (diff)
downloadchrome-ec-863d0b81fd658e1becb5e1cadd4169189ebdc872.tar.gz
oak: pd: move power change notification to function board_set_charge_limit.
if CONFIG_USB_PD_TCPM_VBUS is enabled, a race condition may happen: In function pd_set_input_current_limit() and typec_set_input_current_limit(), EC may notify AP power change event before PD send the up-to-date POWER_STATUS TCPC alert to EC. It will cause the AP get the stale power status. Move the power change event notification to board_set_charge_limit(), it will be called after EC receives POWER_STATUS TCPC alert, and sending power change event notification only if the "charge limit" or "charge port" or supplier is changed. BUG=chrome-os-partner:48801 BRANCH=none TEST=make buildall -j; Tested on Oak by plug/unplug AC adapter to type-C ports and verify the UI battery icon shows the correct status instantly. Change-Id: I52f0e268fdebc45e609d843847540ae48cd0a9eb Signed-off-by: Ben Lok <ben.lok@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/320066 Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r--board/oak/board.c1
-rw-r--r--board/oak/usb_pd_policy.c18
2 files changed, 14 insertions, 5 deletions
diff --git a/board/oak/board.c b/board/oak/board.c
index 1b4141b4f7..065a7f62ea 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -269,6 +269,7 @@ void board_set_charge_limit(int charge_ma)
{
charge_set_input_current_limit(MAX(charge_ma,
CONFIG_CHARGER_INPUT_CURRENT));
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
}
/**
diff --git a/board/oak/usb_pd_policy.c b/board/oak/usb_pd_policy.c
index 9a37c8b205..38db163b58 100644
--- a/board/oak/usb_pd_policy.c
+++ b/board/oak/usb_pd_policy.c
@@ -81,8 +81,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma,
charge.voltage = supply_voltage;
charge_manager_update_charge(CHARGE_SUPPLIER_PD, port, &charge);
#endif
- /* notify host of power info change */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
+ /*
+ * move power info change notification to board_set_charge_limit(),
+ * board_set_charge_limit() will be executed in call stack of
+ * charge_manager_update_charge() if the "charge limit" or "charge port"
+ * or supplier if is changed.
+ */
}
void typec_set_input_current_limit(int port, uint32_t max_ma,
@@ -94,11 +98,15 @@ void typec_set_input_current_limit(int port, uint32_t max_ma,
charge.voltage = supply_voltage;
charge_manager_update_charge(CHARGE_SUPPLIER_TYPEC, port, &charge);
#endif
-
- /* notify host of power info change */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
+ /*
+ * move power info change notification to board_set_charge_limit(),
+ * board_set_charge_limit() will be executed in call stack of
+ * charge_manager_update_charge() if the "charge limit" or "charge port"
+ * or supplier if is changed.
+ */
}
+
int pd_board_checks(void)
{
#if BOARD_REV <= OAK_REV3