diff options
Diffstat (limited to 'board/hoho')
-rw-r--r-- | board/hoho/usb_pd_config.h | 7 | ||||
-rw-r--r-- | board/hoho/usb_pd_policy.c | 53 |
2 files changed, 7 insertions, 53 deletions
diff --git a/board/hoho/usb_pd_config.h b/board/hoho/usb_pd_config.h index 3af9e0a189..ba6e545a3f 100644 --- a/board/hoho/usb_pd_config.h +++ b/board/hoho/usb_pd_config.h @@ -139,4 +139,11 @@ static inline int pd_snk_is_vbus_provided(int port) /* we are never a source : don't care about power supply */ #define PD_POWER_SUPPLY_TRANSITION_DELAY 0 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 1000 +#define PD_MAX_POWER_MW 1500 +#define PD_MAX_CURRENT_MA 300 +#define PD_MAX_VOLTAGE_MV 5000 + #endif /* __USB_PD_CONFIG_H */ diff --git a/board/hoho/usb_pd_policy.c b/board/hoho/usb_pd_policy.c index c9525f2ebe..195aaacb25 100644 --- a/board/hoho/usb_pd_policy.c +++ b/board/hoho/usb_pd_policy.c @@ -27,65 +27,17 @@ const uint32_t pd_src_pdo[] = {}; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); -/* Define typical operating power and max power */ -#define OPERATING_POWER_MW 1000 -#define MAX_POWER_MW 1500 -#define MAX_CURRENT_MA 300 - /* Fake PDOs : we just want our pre-defined voltages */ const uint32_t pd_snk_pdo[] = { PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); -/* Desired voltage requested as a sink (in millivolts) */ -static unsigned select_mv = 5000; - /* Whether alternate mode has been entered or not */ static int alt_mode; /* When set true, we are in GFU mode */ static int gfu_mode; -int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo, - uint32_t *curr_limit, uint32_t *supply_voltage) -{ - int i; - int ma; - int set_mv = select_mv; - int max; - uint32_t flags; - - /* Default to 5V */ - if (set_mv <= 0) - set_mv = 5000; - - /* Get the selected voltage */ - for (i = cnt; i >= 0; i--) { - int mv = ((src_caps[i] >> 10) & 0x3FF) * 50; - int type = src_caps[i] & PDO_TYPE_MASK; - if ((mv == set_mv) && (type == PDO_TYPE_FIXED)) - break; - } - if (i < 0) - return -EC_ERROR_UNKNOWN; - - /* build rdo for desired power */ - ma = 10 * (src_caps[i] & 0x3FF); - max = MIN(ma, MAX_CURRENT_MA); - flags = (max * set_mv) < (1000 * OPERATING_POWER_MW) ? - RDO_CAP_MISMATCH : 0; - *rdo = RDO_FIXED(i + 1, max, max, 0); - CPRINTF("Request [%d] %dV %dmA", i, set_mv/1000, max); - /* Mismatch bit set if less power offered than the operating power */ - if (flags & RDO_CAP_MISMATCH) - CPRINTF(" Mismatch"); - CPRINTF("\n"); - - *curr_limit = max; - *supply_voltage = set_mv; - return EC_SUCCESS; -} - void pd_set_input_current_limit(int port, uint32_t max_ma, uint32_t supply_voltage) { @@ -93,11 +45,6 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, return; } -void pd_set_max_voltage(unsigned mv) -{ - select_mv = mv; -} - int pd_check_requested_voltage(uint32_t rdo) { return EC_SUCCESS; |