diff options
author | Todd Broch <tbroch@chromium.org> | 2014-10-01 18:49:50 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-11 02:22:28 +0000 |
commit | 8a6c72022f1a43fe8288eed2e1a5b94400ca4b1f (patch) | |
tree | 66bb4c18e1bd6fee90b21df243d04585156be134 /board/samus_pd/usb_pd_policy.c | |
parent | 44e4f7cfe7953198091cfd5e39bf339a770138dc (diff) | |
download | chrome-ec-8a6c72022f1a43fe8288eed2e1a5b94400ca4b1f.tar.gz |
pd: Enable alternate mode support for DP.
Change effects:
1. samus_pd: Acts as initiator of SVDM discovery once its reaches source
ready and upon identifying UFP with display port
alternate mode enters that mode.
2. hoho: Acts as responder for SVDM discovery providing its identity,
svids and svid capabilities which are display port only. If
asked to enter display port alternate mode it does.
3. fruitpie: Acts a initiator with mock display port mode.
BRANCH=none
BUG=chrome-os-partner:30645
TEST=manual,
Plug hoho into samus_pd
- see dpout
- from console
> typec 0
Port C0: CC1 451 mV CC2 111 mV (polarity:CC1)
Superspeed DP1
Change-Id: I1a76767353a69baeceffa3e79c37dcea77b8337d
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221354
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/samus_pd/usb_pd_policy.c')
-rw-r--r-- | board/samus_pd/usb_pd_policy.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 7b7237059b..dce1407ec3 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -158,6 +158,12 @@ static void pd_send_host_event(void) } /* ----------------- Vendor Defined Messages ------------------ */ +const struct svdm_response svdm_rsp = { + .identity = NULL, + .svids = NULL, + .modes = NULL, +}; + static int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) { @@ -208,6 +214,41 @@ int pd_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) return pd_custom_vdm(port, cnt, payload, rpayload); } +static void svdm_enter_dp_mode(int port, uint32_t mode_caps) +{ + board_set_usb_mux(port, TYPEC_MUX_DP, pd_get_polarity(port)); +} + +static void svdm_exit_dp_mode(int port) +{ + board_set_usb_mux(port, TYPEC_MUX_NONE, pd_get_polarity(port)); +} + +const struct svdm_amode_fx supported_modes[] = { + { + .svid = USB_SID_DISPLAYPORT, + .enter = &svdm_enter_dp_mode, + .exit = &svdm_exit_dp_mode, + }, +}; + +void pd_dfp_choose_modes(struct pd_policy *pe) +{ + int i, j; + pe->amode_cnt = ARRAY_SIZE(supported_modes); + pe->amodes->fx = supported_modes; + for (i = 0; i < pe->amode_cnt; i++) { + for (j = 0; j < pe->svid_cnt; j++) { + if (pe->svids[j].svid == pe->amodes->fx[i].svid) { + /* TODO(tbroch) need more elaborate mode + resolution */ + pe->amodes[i].mode_caps = pe->svids[j].mode_vdo; + pe->amodes[i].amode = dfp_amode1; + break; + } + } + } +} /****************************************************************************/ /* Console commands */ static int command_ec_int(int argc, char **argv) |