summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/usbc/usb_pe_drp_sm.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index e3c3ee4627..e8610f3c75 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -1213,7 +1213,7 @@ void pe_got_soft_reset(int port)
set_state_pe(port, PE_SOFT_RESET);
}
-static bool pd_can_source_from_device(int port, const int pdo_cnt,
+__overridable bool pd_can_source_from_device(int port, const int pdo_cnt,
const uint32_t *pdos)
{
/*
@@ -1748,6 +1748,13 @@ static void pe_update_src_pdo_flags(int port, int pdo_cnt, uint32_t *pdos)
charge_manager_update_dualrole(port, CAP_DUALROLE);
}
}
+
+ /*
+ * If port policy preference is to be a power role source, then request
+ * a power role swap.
+ */
+ if (!pd_can_source_from_device(port, pdo_cnt, pdos))
+ pd_request_power_swap(port);
}
void pd_request_power_swap(int port)
@@ -3078,9 +3085,12 @@ static void pe_snk_evaluate_capability_entry(int port)
set_cable_rev(port);
- pd_set_src_caps(port, num, pdo);
+ /* Parse source caps if they have changed */
+ if (pe[port].src_cap_cnt != num ||
+ memcmp(pdo, pe[port].src_caps, num << 2))
+ pe_update_src_pdo_flags(port, num, pdo);
- pe_update_src_pdo_flags(port, num, pdo);
+ pd_set_src_caps(port, num, pdo);
/* Evaluate the options based on supplied capabilities */
pd_process_source_cap(port, pe[port].src_cap_cnt, pe[port].src_caps);