From 9ea7ca8d87a5d6d9a8ff8e95230d7f38ee2f1eda Mon Sep 17 00:00:00 2001 From: Ben Lok Date: Tue, 24 Nov 2015 14:34:34 +0800 Subject: [PATCH] pd: send power change event to AP whenever input power is changed Send power change event to AP whenever input power is changed, ensure that AP gets the latest power charging info. BUG=chrome-os-partner:47677 BRANCH=none TEST=tested on Oak by plug/unplug AC adapter to type-C ports and verifying the UI battery icon shows the correct status instantly. Change-Id: I7465afcd8bc9b1c56ecf70fc74446866a8ab1b9a Signed-off-by: Ben Lok Reviewed-on: https://chromium-review.googlesource.com/313926 Reviewed-by: Alec Berg --- board/chell/usb_pd_policy.c | 5 +++++ board/glados/usb_pd_policy.c | 5 +++++ board/kunimitsu/usb_pd_policy.c | 5 +++++ board/lars/usb_pd_policy.c | 5 +++++ board/oak/usb_pd_policy.c | 6 ++++++ 5 files changed, 26 insertions(+) diff --git a/board/chell/usb_pd_policy.c b/board/chell/usb_pd_policy.c index b1a65b73bf..cc2c87d239 100644 --- a/board/chell/usb_pd_policy.c +++ b/board/chell/usb_pd_policy.c @@ -56,6 +56,9 @@ int pd_set_power_supply_ready(int port) gpio_set_level(port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN, 1); + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + return EC_SUCCESS; /* we are ready */ } @@ -80,6 +83,7 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, charge_manager_update_charge(CHARGE_SUPPLIER_PD, port, &charge); #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } void typec_set_input_current_limit(int port, uint32_t max_ma, @@ -94,6 +98,7 @@ void typec_set_input_current_limit(int port, uint32_t max_ma, #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } int pd_snk_is_vbus_provided(int port) diff --git a/board/glados/usb_pd_policy.c b/board/glados/usb_pd_policy.c index ff88ede3bc..e07454e887 100644 --- a/board/glados/usb_pd_policy.c +++ b/board/glados/usb_pd_policy.c @@ -56,6 +56,9 @@ int pd_set_power_supply_ready(int port) gpio_set_level(port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN, 1); + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + return EC_SUCCESS; /* we are ready */ } @@ -79,6 +82,7 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, charge_manager_update_charge(CHARGE_SUPPLIER_PD, port, &charge); #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } void typec_set_input_current_limit(int port, uint32_t max_ma, @@ -92,6 +96,7 @@ void typec_set_input_current_limit(int port, uint32_t max_ma, #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } int pd_snk_is_vbus_provided(int port) diff --git a/board/kunimitsu/usb_pd_policy.c b/board/kunimitsu/usb_pd_policy.c index 6489d0e391..b8a9ad3c67 100644 --- a/board/kunimitsu/usb_pd_policy.c +++ b/board/kunimitsu/usb_pd_policy.c @@ -56,6 +56,9 @@ int pd_set_power_supply_ready(int port) gpio_set_level(port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN, 1); + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + return EC_SUCCESS; /* we are ready */ } @@ -79,6 +82,7 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, charge_manager_update_charge(CHARGE_SUPPLIER_PD, port, &charge); #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } void typec_set_input_current_limit(int port, uint32_t max_ma, @@ -92,6 +96,7 @@ void typec_set_input_current_limit(int port, uint32_t max_ma, #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } int pd_snk_is_vbus_provided(int port) diff --git a/board/lars/usb_pd_policy.c b/board/lars/usb_pd_policy.c index f3877a0241..419a805a22 100644 --- a/board/lars/usb_pd_policy.c +++ b/board/lars/usb_pd_policy.c @@ -59,6 +59,9 @@ int pd_set_power_supply_ready(int port) /* Provide VBUS */ gpio_set_level(GPIO_USB_C0_5V_EN, 1); + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + return EC_SUCCESS; /* we are ready */ } @@ -82,6 +85,7 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, charge_manager_update_charge(CHARGE_SUPPLIER_PD, port, &charge); #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } void typec_set_input_current_limit(int port, uint32_t max_ma, @@ -96,6 +100,7 @@ void typec_set_input_current_limit(int port, uint32_t max_ma, #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } int pd_snk_is_vbus_provided(int port) diff --git a/board/oak/usb_pd_policy.c b/board/oak/usb_pd_policy.c index 33009e763e..9a37c8b205 100644 --- a/board/oak/usb_pd_policy.c +++ b/board/oak/usb_pd_policy.c @@ -56,6 +56,9 @@ int pd_set_power_supply_ready(int port) gpio_set_level(port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN, 1); + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + return EC_SUCCESS; /* we are ready */ } @@ -65,6 +68,7 @@ void pd_power_supply_reset(int port) gpio_set_level(port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN, 0); + /* notify host of power info change */ pd_send_host_event(PD_EVENT_POWER_CHANGE); } @@ -78,6 +82,7 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, charge_manager_update_charge(CHARGE_SUPPLIER_PD, port, &charge); #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } void typec_set_input_current_limit(int port, uint32_t max_ma, @@ -91,6 +96,7 @@ void typec_set_input_current_limit(int port, uint32_t max_ma, #endif /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); } int pd_board_checks(void)