diff options
-rw-r--r-- | board/dingdong/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | board/firefly/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | board/fruitpie/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | board/hoho/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | board/host/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | board/plankton/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | board/ryu/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | board/ryu_p1/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | board/samus_pd/usb_pd_policy.c | 14 | ||||
-rw-r--r-- | board/twinkie/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | common/usb_pd_policy.c | 4 | ||||
-rw-r--r-- | include/usb_pd.h | 8 |
12 files changed, 80 insertions, 0 deletions
diff --git a/board/dingdong/usb_pd_policy.c b/board/dingdong/usb_pd_policy.c index 520732cd26..7122bfab3d 100644 --- a/board/dingdong/usb_pd_policy.c +++ b/board/dingdong/usb_pd_policy.c @@ -45,6 +45,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, return; } +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { return EC_SUCCESS; diff --git a/board/firefly/usb_pd_policy.c b/board/firefly/usb_pd_policy.c index 5917e1a7ef..44ccfe418b 100644 --- a/board/firefly/usb_pd_policy.c +++ b/board/firefly/usb_pd_policy.c @@ -44,6 +44,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, return; } +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { /* Never acting as a source */ diff --git a/board/fruitpie/usb_pd_policy.c b/board/fruitpie/usb_pd_policy.c index ed7e1386fb..96668ff015 100644 --- a/board/fruitpie/usb_pd_policy.c +++ b/board/fruitpie/usb_pd_policy.c @@ -44,6 +44,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, CPRINTS("Failed to set input current limit for PD"); } +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { int max_ma = rdo & 0x3FF; diff --git a/board/hoho/usb_pd_policy.c b/board/hoho/usb_pd_policy.c index efd1bbc243..0c0dd41908 100644 --- a/board/hoho/usb_pd_policy.c +++ b/board/hoho/usb_pd_policy.c @@ -45,6 +45,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, return; } +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { return EC_SUCCESS; diff --git a/board/host/usb_pd_policy.c b/board/host/usb_pd_policy.c index d77731a8ff..9d108bf2cc 100644 --- a/board/host/usb_pd_policy.c +++ b/board/host/usb_pd_policy.c @@ -25,6 +25,12 @@ const uint32_t pd_snk_pdo[] = { }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { int max_ma = rdo & 0x3FF; diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c index 4e56ba8b36..628e244500 100644 --- a/board/plankton/usb_pd_policy.c +++ b/board/plankton/usb_pd_policy.c @@ -63,6 +63,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, return; } +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { int max_ma = rdo & 0x3FF; diff --git a/board/ryu/usb_pd_policy.c b/board/ryu/usb_pd_policy.c index d6bd8c5598..7556c86ba6 100644 --- a/board/ryu/usb_pd_policy.c +++ b/board/ryu/usb_pd_policy.c @@ -50,6 +50,12 @@ void typec_set_input_current_limit(int port, uint32_t max_ma, charge_manager_update(CHARGE_SUPPLIER_TYPEC, port, &charge); } +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { int max_ma = rdo & 0x3FF; diff --git a/board/ryu_p1/usb_pd_policy.c b/board/ryu_p1/usb_pd_policy.c index 99e06e39c1..e48bd348e1 100644 --- a/board/ryu_p1/usb_pd_policy.c +++ b/board/ryu_p1/usb_pd_policy.c @@ -42,6 +42,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, CPRINTS("Failed to set input current limit for PD"); } +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { int max_ma = rdo & 0x3FF; diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 2142a0b9bb..91d19bf7f8 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -26,6 +26,13 @@ #define MAX_POWER_MW 60000 #define MAX_CURRENT_MA 3000 +/* + * Do not request any voltage within this deadband region, where + * we're not sure whether or not the boost or the bypass will be on. + */ +#define INPUT_VOLTAGE_DEADBAND_MIN 9700 +#define INPUT_VOLTAGE_DEADBAND_MAX 11999 + #define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP) const uint32_t pd_src_pdo[] = { @@ -40,6 +47,13 @@ const uint32_t pd_snk_pdo[] = { }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); +int pd_is_valid_input_voltage(int mv) +{ + /* Allow any voltage not in the boost bypass deadband */ + return (mv < INPUT_VOLTAGE_DEADBAND_MIN) || + (mv > INPUT_VOLTAGE_DEADBAND_MAX); +} + int pd_check_requested_voltage(uint32_t rdo) { int max_ma = rdo & 0x3FF; diff --git a/board/twinkie/usb_pd_policy.c b/board/twinkie/usb_pd_policy.c index e52f2f0057..b1e4c064da 100644 --- a/board/twinkie/usb_pd_policy.c +++ b/board/twinkie/usb_pd_policy.c @@ -44,6 +44,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, gpio_set_level(GPIO_LED_B_L, !blue); } +int pd_is_valid_input_voltage(int mv) +{ + /* Any voltage less than the max is allowed */ + return 1; +} + int pd_check_requested_voltage(uint32_t rdo) { int max_ma = rdo & 0x3FF; diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index b95ef726d0..e67f08caa1 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -61,6 +61,10 @@ static int pd_find_pdo_index(int cnt, uint32_t *src_caps, int max_mv) /* Get max power that is under our max voltage input */ for (i = 0; i < cnt; i++) { mv = ((src_caps[i] >> 10) & 0x3FF) * 50; + /* Skip any voltage not supported by this board */ + if (!pd_is_valid_input_voltage(mv)) + continue; + if ((src_caps[i] & PDO_TYPE_MASK) == PDO_TYPE_BATTERY) { uw = 250000 * (src_caps[i] & 0x3FF); } else { diff --git a/include/usb_pd.h b/include/usb_pd.h index 32ff118b0f..b6b8d9dbf1 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -768,6 +768,14 @@ void pd_set_max_voltage(unsigned mv); unsigned pd_get_max_voltage(void); /** + * Check if this board supports the given input voltage. + * + * @mv input voltage + * @return 1 if voltage supported, 0 if not + */ +int pd_is_valid_input_voltage(int mv); + +/** * Request a new operating voltage. * * @param rdo Request Data Object with the selected operating point. |