diff options
-rw-r--r-- | board/ryu_p2/usb_pd_policy.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/board/ryu_p2/usb_pd_policy.c b/board/ryu_p2/usb_pd_policy.c index 10ceb1c30a..73688b218d 100644 --- a/board/ryu_p2/usb_pd_policy.c +++ b/board/ryu_p2/usb_pd_policy.c @@ -15,6 +15,7 @@ #include "util.h" #include "usb_pd.h" +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) /* TODO(crosbug.com/p/28869): update source and sink tables to spec. */ @@ -34,7 +35,8 @@ const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); /* Cap on the max voltage requested as a sink (in millivolts) */ static unsigned max_mv = -1; /* no cap */ -int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo) +int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo, + uint32_t *curr_limit, uint32_t *supply_voltage) { int i; int sel_mv; @@ -66,19 +68,22 @@ int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo) int uw = 250000 * (src_caps[max_i] & 0x3FF); max_ma = uw / sel_mv; *rdo = RDO_BATT(max_i + 1, uw/2, uw, 0); - ccprintf("Request [%d] %dV %dmW\n", - max_i, sel_mv/1000, uw/1000); + CPRINTF("Request [%d] %dV %dmW\n", + max_i, sel_mv/1000, uw/1000); } else { int ma = 10 * (src_caps[max_i] & 0x3FF); max_ma = ma; *rdo = RDO_FIXED(max_i + 1, ma / 2, ma, 0); - ccprintf("Request [%d] %dV %dmA\n", - max_i, sel_mv/1000, ma); + CPRINTF("Request [%d] %dV %dmA\n", + max_i, sel_mv/1000, ma); } - return max_ma; + *curr_limit = max_ma; + *supply_voltage = sel_mv; + return EC_SUCCESS; } -void pd_set_input_current_limit(int port, uint32_t max_ma) +void pd_set_input_current_limit(int port, uint32_t max_ma, + uint32_t supply_voltage) { int rv = charge_set_input_current_limit(MAX(max_ma, CONFIG_CHARGER_INPUT_CURRENT)); @@ -110,9 +115,9 @@ int pd_request_voltage(uint32_t rdo) if (max_ma > pdo_ma) return EC_ERROR_INVAL; /* too much max current */ - ccprintf("Switch to %d V %d mA (for %d/%d mA)\n", - ((pdo >> 10) & 0x3ff) * 50, (pdo & 0x3ff) * 10, - ((rdo >> 10) & 0x3ff) * 10, (rdo & 0x3ff) * 10); + CPRINTF("Switch to %d V %d mA (for %d/%d mA)\n", + ((pdo >> 10) & 0x3ff) * 50, (pdo & 0x3ff) * 10, + ((rdo >> 10) & 0x3ff) * 10, (rdo & 0x3ff) * 10); return EC_SUCCESS; } @@ -135,4 +140,3 @@ int pd_board_checks(void) { return EC_SUCCESS; } - |