summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usb_pd_dual_role.c18
-rw-r--r--common/usb_pd_policy.c13
-rw-r--r--common/usbc/usb_pe_drp_sm.c19
3 files changed, 20 insertions, 30 deletions
diff --git a/common/usb_pd_dual_role.c b/common/usb_pd_dual_role.c
index f00b5981b9..d94d9f5e21 100644
--- a/common/usb_pd_dual_role.c
+++ b/common/usb_pd_dual_role.c
@@ -7,6 +7,24 @@
#include "usb_pd.h"
+#if defined(PD_MAX_VOLTAGE_MV) && defined(PD_OPERATING_POWER_MW)
+/*
+ * As a sink, this is the max voltage (in millivolts) we can request
+ * before getting source caps
+ */
+static unsigned int max_request_mv = PD_MAX_VOLTAGE_MV;
+
+void pd_set_max_voltage(unsigned int mv)
+{
+ max_request_mv = mv;
+}
+
+unsigned int pd_get_max_voltage(void)
+{
+ return max_request_mv;
+}
+#endif /* defined(PD_MAX_VOLTAGE_MV) && defined(PD_OPERATING_POWER_MW) */
+
int pd_charge_from_device(uint16_t vid, uint16_t pid)
{
/* TODO: rewrite into table if we get more of these */
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index caa008fda6..adce64b65f 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -58,9 +58,6 @@ void pd_notify_dp_alt_mode_entry(void)
static uint32_t pd_src_caps[CONFIG_USB_PD_PORT_MAX_COUNT][PDO_MAX_OBJECTS];
static uint8_t pd_src_cap_cnt[CONFIG_USB_PD_PORT_MAX_COUNT];
-/* Cap on the max voltage requested as a sink (in millivolts) */
-static unsigned max_request_mv = PD_MAX_VOLTAGE_MV; /* no cap */
-
const uint32_t * const pd_get_src_caps(int port)
{
ASSERT(port < CONFIG_USB_PD_PORT_MAX_COUNT);
@@ -97,16 +94,6 @@ void pd_process_source_cap(int port, int cnt, uint32_t *src_caps)
pd_set_input_current_limit(port, ma, mv);
#endif
}
-
-void pd_set_max_voltage(unsigned mv)
-{
- max_request_mv = mv;
-}
-
-unsigned pd_get_max_voltage(void)
-{
- return max_request_mv;
-}
#endif /* CONFIG_USB_PD_DUAL_ROLE */
static struct pd_cable cable[CONFIG_USB_PD_PORT_MAX_COUNT];
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index baaeb48ba4..bfd459fd21 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -480,12 +480,6 @@ static struct policy_engine {
} pe[CONFIG_USB_PD_PORT_MAX_COUNT];
-/*
- * As a sink, this is the max voltage (in millivolts) we can request
- * before getting source caps
- */
-static unsigned int max_request_mv = PD_MAX_VOLTAGE_MV;
-
test_export_static enum usb_pe_state get_state_pe(const int port);
test_export_static void set_state_pe(const int port,
const enum usb_pe_state new_state);
@@ -862,7 +856,8 @@ static void pe_send_request_msg(int port)
pd_build_request(pe[port].src_cap_cnt, pe[port].src_caps,
pe[port].vpd_vdo, &rdo, &curr_limit,
&supply_voltage, charging && max_request_allowed ?
- PD_REQUEST_MAX : PD_REQUEST_VSAFE5V, max_request_mv, port);
+ PD_REQUEST_MAX : PD_REQUEST_VSAFE5V,
+ pd_get_max_voltage(), port);
CPRINTF("C%d Req [%d] %dmV %dmA", port, RDO_POS(rdo),
supply_voltage, curr_limit);
@@ -4457,16 +4452,6 @@ void pd_process_source_cap(int port, int cnt, uint32_t *src_caps)
#endif
}
-void pd_set_max_voltage(unsigned int mv)
-{
- max_request_mv = mv;
-}
-
-unsigned int pd_get_max_voltage(void)
-{
- return max_request_mv;
-}
-
void pd_dfp_pe_init(int port)
{
memset(&pe[port].am_policy, 0, sizeof(struct pd_policy));