diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-10-13 13:51:26 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-10-13 18:44:01 -0700 |
commit | 89067fc458d8533a74e45a1285091dda7a96669e (patch) | |
tree | 7736222d644ef1ae412b4d9cd9c3e91e72834263 | |
parent | 6b498ef31825ae4da01b26644c232726fbcf3a75 (diff) | |
download | chrome-ec-89067fc458d8533a74e45a1285091dda7a96669e.tar.gz |
cleanup: pd: remove duplicate code for checking request msg
Remove duplicate code for checking request message, but keep
a board specific check of the request message for custom checks
needed on zinger and plankton.
BUG=chrome-os-partner:42490
BRANCH=none
TEST=make -j buildall. run on samus and connect a hoho, make
sure we successfully negotiate a contract.
Change-Id: I7398953a158d340e3e113f5a816b55445a857711
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305374
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/dingdong/usb_pd_policy.c | 5 | ||||
-rw-r--r-- | board/glados/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/hoho/usb_pd_policy.c | 5 | ||||
-rw-r--r-- | board/honeybuns/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/host/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/kunimitsu/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/lucid/usb_pd_policy.c | 5 | ||||
-rw-r--r-- | board/oak/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/pdeval-stm32f072/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/plankton/usb_pd_policy.c | 27 | ||||
-rw-r--r-- | board/ryu/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/samus_pd/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/strago/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/twinkie/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/wheatley/usb_pd_policy.c | 26 | ||||
-rw-r--r-- | board/zinger/usb_pd_policy.c | 25 | ||||
-rw-r--r-- | common/usb_pd_policy.c | 39 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 2 | ||||
-rw-r--r-- | include/usb_pd.h | 7 |
19 files changed, 57 insertions, 344 deletions
diff --git a/board/dingdong/usb_pd_policy.c b/board/dingdong/usb_pd_policy.c index 06d2355b4a..69d7f2d811 100644 --- a/board/dingdong/usb_pd_policy.c +++ b/board/dingdong/usb_pd_policy.c @@ -50,11 +50,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - return EC_SUCCESS; -} - void pd_transition_voltage(int idx) { /* No operation: sink only */ diff --git a/board/glados/usb_pd_policy.c b/board/glados/usb_pd_policy.c index dc5153e32e..ae3579f3e3 100644 --- a/board/glados/usb_pd_policy.c +++ b/board/glados/usb_pd_policy.c @@ -42,32 +42,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* No-operation: we are always 5V */ diff --git a/board/hoho/usb_pd_policy.c b/board/hoho/usb_pd_policy.c index 6debdfff9c..175241bf33 100644 --- a/board/hoho/usb_pd_policy.c +++ b/board/hoho/usb_pd_policy.c @@ -50,11 +50,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - return EC_SUCCESS; -} - void pd_transition_voltage(int idx) { /* No operation: sink only */ diff --git a/board/honeybuns/usb_pd_policy.c b/board/honeybuns/usb_pd_policy.c index b1a0990852..ca0ead8dbb 100644 --- a/board/honeybuns/usb_pd_policy.c +++ b/board/honeybuns/usb_pd_policy.c @@ -58,32 +58,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* PDO index are starting from 1 */ diff --git a/board/host/usb_pd_policy.c b/board/host/usb_pd_policy.c index dbc15b1788..e67984742c 100644 --- a/board/host/usb_pd_policy.c +++ b/board/host/usb_pd_policy.c @@ -31,32 +31,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* Not implemented */ diff --git a/board/kunimitsu/usb_pd_policy.c b/board/kunimitsu/usb_pd_policy.c index 3dd9586bf2..66040c3d4f 100644 --- a/board/kunimitsu/usb_pd_policy.c +++ b/board/kunimitsu/usb_pd_policy.c @@ -42,32 +42,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* No-operation: we are always 5V */ diff --git a/board/lucid/usb_pd_policy.c b/board/lucid/usb_pd_policy.c index 380e45454d..5265e5738d 100644 --- a/board/lucid/usb_pd_policy.c +++ b/board/lucid/usb_pd_policy.c @@ -37,11 +37,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - return EC_SUCCESS; -} - void pd_transition_voltage(int idx) { /* No operation: sink only */ diff --git a/board/oak/usb_pd_policy.c b/board/oak/usb_pd_policy.c index 5799d4a765..5f9cea8f31 100644 --- a/board/oak/usb_pd_policy.c +++ b/board/oak/usb_pd_policy.c @@ -42,32 +42,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* No-operation: we are always 5V */ diff --git a/board/pdeval-stm32f072/usb_pd_policy.c b/board/pdeval-stm32f072/usb_pd_policy.c index 35762bde39..b7c069c555 100644 --- a/board/pdeval-stm32f072/usb_pd_policy.c +++ b/board/pdeval-stm32f072/usb_pd_policy.c @@ -39,32 +39,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* No-operation: we are always 5V */ diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c index ab8eb6c978..8a916e65aa 100644 --- a/board/plankton/usb_pd_policy.c +++ b/board/plankton/usb_pd_policy.c @@ -74,30 +74,13 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) +int pd_board_check_request(uint32_t rdo) { - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnts[pd_src_pdo_idx]) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %d V %d mA (for %d/%d mA)\n", - ((pdo >> 10) & 0x3ff) * 50, (pdo & 0x3ff) * 10, - ((rdo >> 10) & 0x3ff) * 10, (rdo & 0x3ff) * 10); + int idx = RDO_POS(rdo); - return EC_SUCCESS; + /* Check for invalid index */ + return (!idx || idx > pd_src_pdo_cnts[pd_src_pdo_idx]) ? + EC_ERROR_INVAL : EC_SUCCESS; } void pd_transition_voltage(int idx) diff --git a/board/ryu/usb_pd_policy.c b/board/ryu/usb_pd_policy.c index 21a26cbd48..b600edb427 100644 --- a/board/ryu/usb_pd_policy.c +++ b/board/ryu/usb_pd_policy.c @@ -68,32 +68,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* No-operation: we are always 5V */ diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 82ddaf6e9a..5c7889c41b 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -55,32 +55,6 @@ int pd_is_valid_input_voltage(int mv) (mv > INPUT_VOLTAGE_DEADBAND_MAX); } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* No-operation: we are always 5V */ diff --git a/board/strago/usb_pd_policy.c b/board/strago/usb_pd_policy.c index 0309d67e09..8c2377aa52 100644 --- a/board/strago/usb_pd_policy.c +++ b/board/strago/usb_pd_policy.c @@ -42,32 +42,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* No-operation: we are always 5V */ diff --git a/board/twinkie/usb_pd_policy.c b/board/twinkie/usb_pd_policy.c index 0553bdad3c..1677a28f4d 100644 --- a/board/twinkie/usb_pd_policy.c +++ b/board/twinkie/usb_pd_policy.c @@ -50,32 +50,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { } diff --git a/board/wheatley/usb_pd_policy.c b/board/wheatley/usb_pd_policy.c index 57154978fa..93600e0dba 100644 --- a/board/wheatley/usb_pd_policy.c +++ b/board/wheatley/usb_pd_policy.c @@ -41,32 +41,6 @@ int pd_is_valid_input_voltage(int mv) return 1; } -int pd_check_requested_voltage(uint32_t rdo) -{ - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; - - if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - CPRINTF("Requested %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; -} - void pd_transition_voltage(int idx) { /* No-operation: we are always 5V */ diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c index 2f5b6c3e99..477060d17d 100644 --- a/board/zinger/usb_pd_policy.c +++ b/board/zinger/usb_pd_policy.c @@ -198,33 +198,18 @@ static int discharge_volt_idx; /* output current measurement */ int vbus_amp; -int pd_check_requested_voltage(uint32_t rdo) +int pd_board_check_request(uint32_t rdo) { - int max_ma = rdo & 0x3FF; - int op_ma = (rdo >> 10) & 0x3FF; - int idx = rdo >> 28; - uint32_t pdo; - uint32_t pdo_ma; + int idx = RDO_POS(rdo); /* fault condition or output disabled: reject transitions */ if (fault != FAULT_OK || !output_is_enabled()) return EC_ERROR_INVAL; + /* Invalid index */ if (!idx || idx > pd_src_pdo_cnt) - return EC_ERROR_INVAL; /* Invalid index */ - - /* check current ... */ - pdo = pd_src_pdo[idx - 1]; - pdo_ma = (pdo & 0x3ff); - if (op_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much op current */ - if (max_ma > pdo_ma) - return EC_ERROR_INVAL; /* too much max current */ - - debug_printf("Requested %d V %d mA (for %d/%d mA)\n", - ((pdo >> 10) & 0x3ff) * 50, (pdo & 0x3ff) * 10, - ((rdo >> 10) & 0x3ff) * 10, (rdo & 0x3ff) * 10); - /* Accept the requested voltage */ + return EC_ERROR_INVAL; + return EC_SUCCESS; } diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 0cd4160614..e20605f9ff 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -32,6 +32,45 @@ static int rw_flash_changed = 1; +int pd_check_requested_voltage(uint32_t rdo) +{ + int max_ma = rdo & 0x3FF; + int op_ma = (rdo >> 10) & 0x3FF; + int idx = RDO_POS(rdo); + uint32_t pdo; + uint32_t pdo_ma; + + /* Board specific check for this request */ + if (pd_board_check_request(rdo)) + return EC_ERROR_INVAL; + + /* check current ... */ + pdo = pd_src_pdo[idx - 1]; + pdo_ma = (pdo & 0x3ff); + if (op_ma > pdo_ma) + return EC_ERROR_INVAL; /* too much op current */ + if (max_ma > pdo_ma) + return EC_ERROR_INVAL; /* too much max current */ + + CPRINTF("Requested %d V %d mA (for %d/%d mA)\n", + ((pdo >> 10) & 0x3ff) * 50, (pdo & 0x3ff) * 10, + op_ma * 10, max_ma * 10); + + /* Accept the requested voltage */ + return EC_SUCCESS; +} + +static int stub_pd_board_check_request(uint32_t rdo) +{ + int idx = RDO_POS(rdo); + + /* Check for invalid index */ + return (!idx || idx > pd_src_pdo_cnt) ? + EC_ERROR_INVAL : EC_SUCCESS; +} +int pd_board_check_request(uint32_t) + __attribute__((weak, alias("stub_pd_board_check_request"))); + #ifdef CONFIG_USB_PD_DUAL_ROLE /* Cap on the max voltage requested as a sink (in millivolts) */ static unsigned max_request_mv = PD_MAX_VOLTAGE_MV; /* no cap */ diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 28389b274f..9ddccb80c4 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -748,7 +748,7 @@ static void handle_data_request(int port, uint16_t head, /* explicit contract is now in place */ pd[port].flags |= PD_FLAGS_EXPLICIT_CONTRACT; - pd[port].requested_idx = payload[0] >> 28; + pd[port].requested_idx = RDO_POS(payload[0]); set_state(port, PD_STATE_SRC_ACCEPTED); return; } diff --git a/include/usb_pd.h b/include/usb_pd.h index ae11f8bc09..3a1d306c86 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -918,6 +918,13 @@ int pd_is_valid_input_voltage(int mv); int pd_check_requested_voltage(uint32_t rdo); /** + * Run board specific checks on request message + * + * @return EC_SUCCESS if request is ok , <0 else. + */ +int pd_board_check_request(uint32_t rdo); + +/** * Select a new output voltage. * * param idx index of the new voltage in the source PDO table. |