diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-11-11 15:39:40 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-14 04:24:29 +0000 |
commit | 8e024350d3c81c7b1b76eac7ce0b419d6039dbb5 (patch) | |
tree | e3af8ce46ef928f5733a2198266af5143f1e4036 /board | |
parent | aad897775a77319e458be15a4d1d5a80a01359a1 (diff) | |
download | chrome-ec-8e024350d3c81c7b1b76eac7ce0b419d6039dbb5.tar.gz |
pd: add data role swap
Add support for DR_swap, data role swap command.
BUG=chrome-os-partner:33686, chrome-os-partner:28343
BRANCH=samus
TEST=test with samus and zinger. use "pd 1 swap data" command
and verify data role swaps by using twinkie and "pd 1 state".
Change-Id: I410309199cdeecb26847a6bf217523fdfe688cba
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/229192
Diffstat (limited to 'board')
-rw-r--r-- | board/dingdong/usb_pd_policy.c | 15 | ||||
-rw-r--r-- | board/firefly/usb_pd_policy.c | 21 | ||||
-rw-r--r-- | board/fruitpie/usb_pd_policy.c | 22 | ||||
-rw-r--r-- | board/hoho/usb_pd_policy.c | 15 | ||||
-rw-r--r-- | board/host/usb_pd_policy.c | 17 | ||||
-rw-r--r-- | board/plankton/usb_pd_policy.c | 25 | ||||
-rw-r--r-- | board/ryu/usb_pd_policy.c | 17 | ||||
-rw-r--r-- | board/ryu_p1/usb_pd_policy.c | 18 | ||||
-rw-r--r-- | board/samus_pd/usb_pd_policy.c | 17 | ||||
-rw-r--r-- | board/twinkie/usb_pd_policy.c | 21 | ||||
-rw-r--r-- | board/zinger/usb_pd_policy.c | 19 |
11 files changed, 176 insertions, 31 deletions
diff --git a/board/dingdong/usb_pd_policy.c b/board/dingdong/usb_pd_policy.c index 181bc5a17f..82386a0c96 100644 --- a/board/dingdong/usb_pd_policy.c +++ b/board/dingdong/usb_pd_policy.c @@ -21,6 +21,8 @@ #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) +#define PDO_FIXED_FLAGS 0 + /* Source PDOs */ const uint32_t pd_src_pdo[] = {}; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); @@ -32,7 +34,7 @@ const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); /* Fake PDOs : we just want our pre-defined voltages */ const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, 0), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); @@ -119,6 +121,17 @@ int pd_power_swap(int port) /* Always refuse power swap */ return 0; } + +int pd_data_swap(int port, int data_role) +{ + /* Always refuse data swap */ + return 0; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} /* ----------------- Vendor Defined Messages ------------------ */ const uint32_t vdo_idh = VDO_IDH(0, /* data caps as USB host */ 0, /* data caps as USB device */ diff --git a/board/firefly/usb_pd_policy.c b/board/firefly/usb_pd_policy.c index 68768856d5..8fe1add0b0 100644 --- a/board/firefly/usb_pd_policy.c +++ b/board/firefly/usb_pd_policy.c @@ -26,17 +26,19 @@ #define MAX_POWER_MW 1500 #define MAX_CURRENT_MA 300 +#define PDO_FIXED_FLAGS (PDO_FIXED_EXTERNAL) + /* we are not acting as a source */ const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_EXTERNAL), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), }; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); /* Fake PDOs : we just want our pre-defined voltages */ const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, 0), - PDO_FIXED(12000, 500, 0), - PDO_FIXED(20000, 500, 0), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), + PDO_FIXED(12000, 500, PDO_FIXED_FLAGS), + PDO_FIXED(20000, 500, PDO_FIXED_FLAGS), }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); @@ -157,3 +159,14 @@ int pd_power_swap(int port) /* Always refuse power swap */ return 0; } + +int pd_data_swap(int port, int data_role) +{ + /* Always refuse data swap */ + return 0; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} diff --git a/board/fruitpie/usb_pd_policy.c b/board/fruitpie/usb_pd_policy.c index 422a371266..3344872a43 100644 --- a/board/fruitpie/usb_pd_policy.c +++ b/board/fruitpie/usb_pd_policy.c @@ -17,15 +17,18 @@ #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) +#define PDO_FIXED_FLAGS (PDO_FIXED_EXTERNAL | PDO_FIXED_DUAL_ROLE | \ + PDO_FIXED_DATA_SWAP) + const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), - PDO_FIXED(12000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), - PDO_FIXED(20000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS), + PDO_FIXED(12000, 3000, PDO_FIXED_FLAGS), + PDO_FIXED(20000, 3000, PDO_FIXED_FLAGS), }; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), PDO_BATT(5000, 20000, 15000), PDO_VAR(5000, 20000, 3000), }; @@ -145,6 +148,17 @@ int pd_power_swap(int port) /* Always allow power swap */ return 1; } + +int pd_data_swap(int port, int data_role) +{ + /* Always allow data swap */ + return 1; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} /* ----------------- Vendor Defined Messages ------------------ */ const struct svdm_response svdm_rsp = { .identity = NULL, diff --git a/board/hoho/usb_pd_policy.c b/board/hoho/usb_pd_policy.c index a5c333ef10..2164918a7a 100644 --- a/board/hoho/usb_pd_policy.c +++ b/board/hoho/usb_pd_policy.c @@ -21,6 +21,8 @@ #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) +#define PDO_FIXED_FLAGS 0 + /* Source PDOs */ const uint32_t pd_src_pdo[] = {}; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); @@ -32,7 +34,7 @@ const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); /* Fake PDOs : we just want our pre-defined voltages */ const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, 0), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); @@ -119,6 +121,17 @@ int pd_power_swap(int port) /* Always refuse power swap */ return 0; } + +int pd_data_swap(int port, int data_role) +{ + /* Always refuse data swap */ + return 0; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} /* ----------------- Vendor Defined Messages ------------------ */ const uint32_t vdo_idh = VDO_IDH(0, /* data caps as USB host */ 0, /* data caps as USB device */ diff --git a/board/host/usb_pd_policy.c b/board/host/usb_pd_policy.c index b61b0a4349..8d927d0cb4 100644 --- a/board/host/usb_pd_policy.c +++ b/board/host/usb_pd_policy.c @@ -16,13 +16,15 @@ #define MAX_POWER_MW 60000 #define MAX_CURRENT_MA 3000 +#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP) + const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 900, PDO_FIXED_EXTERNAL), + PDO_FIXED(5000, 900, PDO_FIXED_FLAGS), }; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), PDO_BATT(5000, 20000, 15000), PDO_VAR(5000, 20000, 3000), }; @@ -149,6 +151,17 @@ int pd_power_swap(int port) return 1; } +int pd_data_swap(int port, int data_role) +{ + /* Always allow data swap */ + return 1; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} + int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) { return 0; diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c index 6ae87f4850..ea240107c2 100644 --- a/board/plankton/usb_pd_policy.c +++ b/board/plankton/usb_pd_policy.c @@ -26,11 +26,14 @@ #define MAX_POWER_MW 60000 #define MAX_CURRENT_MA 3000 +#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP | \ + PDO_FIXED_EXTERNAL) + /* Source PDOs */ const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), - PDO_FIXED(12000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), - PDO_FIXED(20000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS), + PDO_FIXED(12000, 3000, PDO_FIXED_FLAGS), + PDO_FIXED(20000, 3000, PDO_FIXED_FLAGS), }; static const int pd_src_pdo_cnts[3] = { [SRC_CAP_5V] = 1, @@ -42,9 +45,9 @@ static int pd_src_pdo_idx; /* Fake PDOs : we just want our pre-defined voltages */ const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE), - PDO_FIXED(12000, 500, PDO_FIXED_DUAL_ROLE), - PDO_FIXED(20000, 500, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), + PDO_FIXED(12000, 500, PDO_FIXED_FLAGS), + PDO_FIXED(20000, 500, PDO_FIXED_FLAGS), }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); @@ -173,3 +176,13 @@ int pd_power_swap(int port) return 1; } +int pd_data_swap(int port, int data_role) +{ + /* Always allow data swap */ + return 1; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} diff --git a/board/ryu/usb_pd_policy.c b/board/ryu/usb_pd_policy.c index fc55246837..8026a413df 100644 --- a/board/ryu/usb_pd_policy.c +++ b/board/ryu/usb_pd_policy.c @@ -23,13 +23,15 @@ #define MAX_POWER_MW 60000 #define MAX_CURRENT_MA 3000 +#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP) + const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 900, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 900, PDO_FIXED_FLAGS), }; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), PDO_BATT(5000, 20000, 10000), PDO_VAR(5000, 20000, 3000), }; @@ -162,3 +164,14 @@ int pd_power_swap(int port) /* Always allow power swap */ return 1; } + +int pd_data_swap(int port, int data_role) +{ + /* Always allow data swap */ + return 1; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* TODO: what do we need to do to change host controller data role? */ +} diff --git a/board/ryu_p1/usb_pd_policy.c b/board/ryu_p1/usb_pd_policy.c index 23400e7a8b..8c58452a6e 100644 --- a/board/ryu_p1/usb_pd_policy.c +++ b/board/ryu_p1/usb_pd_policy.c @@ -23,13 +23,15 @@ #define MAX_POWER_MW 60000 #define MAX_CURRENT_MA 3000 +#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP) + const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 900, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 900, PDO_FIXED_FLAGS), }; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), PDO_BATT(5000, 20000, 10000), PDO_VAR(5000, 20000, 3000), }; @@ -162,6 +164,18 @@ int pd_power_swap(int port) /* Always allow power swap */ return 1; } + +int pd_data_swap(int port, int data_role) +{ + /* Always allow data swap */ + return 1; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* TODO: what do we need to do to change host controller data role? */ +} + /* ----------------- Vendor Defined Messages ------------------ */ static int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 1678a005f8..c63debcf16 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -24,13 +24,15 @@ #define MAX_POWER_MW 60000 #define MAX_CURRENT_MA 3000 +#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP) + const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 900, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 900, PDO_FIXED_FLAGS), }; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), PDO_BATT(5000, 20000, 15000), PDO_VAR(5000, 20000, 3000), }; @@ -210,6 +212,17 @@ int pd_power_swap(int port) /* Always allow power swap */ return 1; } + +int pd_data_swap(int port, int data_role) +{ + /* Allow data swap if we are a UFP, otherwise don't allow */ + return (data_role == PD_ROLE_UFP) ? 1 : 0; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* TODO: when switching to UFP need to open D+/D- switches */ +} /* ----------------- Vendor Defined Messages ------------------ */ const struct svdm_response svdm_rsp = { .identity = NULL, diff --git a/board/twinkie/usb_pd_policy.c b/board/twinkie/usb_pd_policy.c index f980527056..f38f522698 100644 --- a/board/twinkie/usb_pd_policy.c +++ b/board/twinkie/usb_pd_policy.c @@ -22,15 +22,17 @@ #define MAX_POWER_MW 60000 #define MAX_CURRENT_MA 3000 +#define PDO_FIXED_FLAGS (PDO_FIXED_EXTERNAL | PDO_FIXED_DATA_SWAP) + const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), - PDO_FIXED(12000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), - PDO_FIXED(20000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS), + PDO_FIXED(12000, 3000, PDO_FIXED_FLAGS), + PDO_FIXED(20000, 3000, PDO_FIXED_FLAGS), }; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE), + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), PDO_BATT(5000, 20000, 15000), PDO_VAR(5000, 20000, 3000), }; @@ -159,3 +161,14 @@ int pd_power_swap(int port) /* Always refuse power swap */ return 0; } + +int pd_data_swap(int port, int data_role) +{ + /* Always allow data swap */ + return 1; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c index c520a10d5b..be86f26271 100644 --- a/board/zinger/usb_pd_policy.c +++ b/board/zinger/usb_pd_policy.c @@ -146,11 +146,13 @@ static void discharge_voltage(int target_volt) /* ----------------------- USB Power delivery policy ---------------------- */ +#define PDO_FIXED_FLAGS (PDO_FIXED_EXTERNAL | PDO_FIXED_DATA_SWAP) + /* Power Delivery Objects */ const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, RATED_CURRENT, PDO_FIXED_EXTERNAL), - PDO_FIXED(12000, RATED_CURRENT, PDO_FIXED_EXTERNAL), - PDO_FIXED(20000, RATED_CURRENT, PDO_FIXED_EXTERNAL), + PDO_FIXED(5000, RATED_CURRENT, PDO_FIXED_FLAGS), + PDO_FIXED(12000, RATED_CURRENT, PDO_FIXED_FLAGS), + PDO_FIXED(20000, RATED_CURRENT, PDO_FIXED_FLAGS), }; const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); @@ -251,6 +253,17 @@ void pd_power_supply_reset(int port) discharge_voltage(voltages[0].ovp); } +int pd_data_swap(int port, int data_role) +{ + /* Allow data swap if we are a DFP, otherwise don't allow */ + return (data_role == PD_ROLE_DFP) ? 1 : 0; +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} + int pd_board_checks(void) { #ifdef CONFIG_HIBERNATE |