diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-02-16 11:27:58 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-02-18 04:53:12 +0000 |
commit | ac5f11bf84d8186a899454e50da3fd634bc9b35e (patch) | |
tree | 66417af5efebda9451631de3d7be64e482dc9247 /common | |
parent | f41d33b1d7432f159d3a24c8c31c064852620618 (diff) | |
download | chrome-ec-ac5f11bf84d8186a899454e50da3fd634bc9b35e.tar.gz |
pd: charge_manager: make new VBUS charge supplier
Make new VBUS charge supplier for Samus and Ryu which allows
default 500mA charging when VBUS is present. Before this was
accomplished via the type-C supplier, but type-C supplier should
only be used for 1.5A and 3A pull-up. VBUS supplier is lowest
priority so that any other supplier will take precedence over
the default charging rate.
This work is done in preparation for charge_ramp module where
we don't want to ramp for typeC supplier.
BUG=chrome-os-partner:34946
BRANCH=samus
TEST=make sure we can boot without battery on samus, and test
other chargers including legacy chargers, zinger, and donette.
Change-Id: I89f1e9520e4bf9e5debbaf8dd2de1262154eecf8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250312
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/usb_pd_protocol.c | 51 |
1 files changed, 8 insertions, 43 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 40126aa8fe..d1f92efd08 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -228,7 +228,6 @@ static int pd_src_cap_cnt[PD_PORT_COUNT]; #define PD_FLAGS_PREVIOUS_PD_CONN (1 << 8) /* previously PD connected */ #define PD_FLAGS_CHECK_PR_ROLE (1 << 9) /* check power role in READY */ #define PD_FLAGS_CHECK_DR_ROLE (1 << 10)/* check data role in READY */ -#define PD_FLAGS_VBUS_PRESENT (1 << 11)/* vbus present in sink disconn. */ /* Flags to clear on a disconnect */ #define PD_FLAGS_RESET_ON_DISCONNECT_MASK (PD_FLAGS_PARTNER_DR_POWER | \ PD_FLAGS_PARTNER_DR_DATA | \ @@ -238,8 +237,7 @@ static int pd_src_cap_cnt[PD_PORT_COUNT]; PD_FLAGS_EXPLICIT_CONTRACT | \ PD_FLAGS_PREVIOUS_PD_CONN | \ PD_FLAGS_CHECK_PR_ROLE | \ - PD_FLAGS_CHECK_DR_ROLE | \ - PD_FLAGS_VBUS_PRESENT) + PD_FLAGS_CHECK_DR_ROLE) static struct pd_protocol { /* current port power role (SOURCE or SINK) */ @@ -387,14 +385,12 @@ static inline void set_state(int port, enum pd_states next_state) #ifdef CONFIG_USB_PD_DUAL_ROLE if (next_state == PD_STATE_SRC_DISCONNECTED || next_state == PD_STATE_SNK_DISCONNECTED) { - if (pd[port].flags & PD_FLAGS_VBUS_PRESENT) { - /* Clear the input current limit */ - pd_set_input_current_limit(port, 0, 0); + /* Clear the input current limit */ + pd_set_input_current_limit(port, 0, 0); #ifdef CONFIG_CHARGE_MANAGER - typec_set_input_current_limit(port, 0, 0); - charge_manager_set_ceil(port, CHARGE_CEIL_NONE); + typec_set_input_current_limit(port, 0, 0); + charge_manager_set_ceil(port, CHARGE_CEIL_NONE); #endif - } #else /* CONFIG_USB_PD_DUAL_ROLE */ if (next_state == PD_STATE_SRC_DISCONNECTED) { #endif @@ -1134,7 +1130,6 @@ static void handle_ctrl_request(int port, uint16_t head, /* reset message ID and swap roles */ pd[port].msg_id = 0; pd[port].power_role = PD_ROLE_SINK; - pd[port].flags |= PD_FLAGS_VBUS_PRESENT; set_state(port, PD_STATE_SNK_DISCOVERY); } else if (pd[port].task_state == PD_STATE_SNK_DISCOVERY) { /* Don't know what power source is ready. Reset. */ @@ -1714,8 +1709,6 @@ static inline int get_typec_current_limit(int cc_voltage) charge = 3000; else if (cc_voltage > TYPE_C_SRC_1500_THRESHOLD) charge = 1500; - else if (cc_voltage > PD_SNK_VA) - charge = 500; else charge = 0; @@ -1798,19 +1791,10 @@ void pd_task(void) #endif #ifdef CONFIG_CHARGE_MANAGER - /* Initialize PD supplier current limit to 0 */ + /* Initialize PD and type-C supplier current limits to 0 */ pd_set_input_current_limit(port, 0, 0); + typec_set_input_current_limit(port, 0, 0); charge_manager_update_dualrole(port, CAP_UNKNOWN); -#ifdef CONFIG_USB_PD_DUAL_ROLE - /* If sink, set initial type-C current limit based on vbus */ - if (pd_snk_is_vbus_provided(port)) { - typec_set_input_current_limit(port, 500, TYPE_C_VOLTAGE); - pd[port].flags |= PD_FLAGS_VBUS_PRESENT; - } else { - typec_set_input_current_limit(port, 0, 0); - pd[port].flags &= ~PD_FLAGS_VBUS_PRESENT; - } -#endif #endif while (1) { @@ -2303,24 +2287,6 @@ void pd_task(void) case PD_STATE_SNK_DISCONNECTED: timeout = 10*MSEC; -#ifdef CONFIG_CHARGE_MANAGER - /* - * If VBUS, use default 500mA limit, otherwise - * set current limit to 0. This is necessary for - * an accessory that provides power with no Rp. - */ - if (pd_snk_is_vbus_provided(port) && - !(pd[port].flags & PD_FLAGS_VBUS_PRESENT)) { - typec_set_input_current_limit(port, 500, - TYPE_C_VOLTAGE); - pd[port].flags |= PD_FLAGS_VBUS_PRESENT; - } else if (!pd_snk_is_vbus_provided(port) && - (pd[port].flags & PD_FLAGS_VBUS_PRESENT)) { - typec_set_input_current_limit(port, 0, 0); - pd[port].flags &= ~PD_FLAGS_VBUS_PRESENT; - } -#endif - /* Source connection monitoring */ cc1_volt = pd_adc_read(port, 0); cc2_volt = pd_adc_read(port, 1); @@ -2385,8 +2351,7 @@ void pd_task(void) port, typec_curr, TYPE_C_VOLTAGE); #endif pd[port].flags |= PD_FLAGS_CHECK_PR_ROLE | - PD_FLAGS_CHECK_DR_ROLE | - PD_FLAGS_VBUS_PRESENT; + PD_FLAGS_CHECK_DR_ROLE; set_state(port, PD_STATE_SNK_DISCOVERY); timeout = 10*MSEC; hook_call_deferred( |