diff options
author | Todd Broch <tbroch@chromium.org> | 2015-01-16 12:40:15 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-28 11:13:58 +0000 |
commit | 17f68998fbac95976c271e7403ffffc6f9f1aeaf (patch) | |
tree | 37c7132aced900be55868b5df1ef4b0dd2c13242 /board/dingdong | |
parent | 89479d1fc22d17721f0ab7b9547f20054c870da3 (diff) | |
download | chrome-ec-17f68998fbac95976c271e7403ffffc6f9f1aeaf.tar.gz |
pd: Allow multiple mode entry.
Current simplified implementation allows single mode entry. Specification
allows multiple mode entry and its advantageous for things like flashing RW
while staying in DisplayPort mode on video dongles.
CL adds capability on DFP to track as many alternate modes as supported by the
DFP. Initial mode entered is still the default supported mode ( 1st entry, 1st
opos). Policy manager can then use host command, EC_CMD_USB_PD_SET_AMODE, to
enter additional supported modes.
On the UFP (hoho, dingdong) a small modification to track multiple svid mode
entries was made.
Signed-off-by: Todd Broch <tbroch@chromium.org>
BRANCH=samus
BUG=chrome-os-partner:33946
TEST=manual, On hoho
1. Still successfully enter default mode DP
2. Using ectool's pdsetmode can successfully enter/exit multiple modes.
For example,
# port:1 svid:18d1 opos:1 cmd:1==enter
ectool --name cros_pd pdsetmode 1 0x18d1 1 1
Checking with pdgetmode shows both modes entered.
3. Works across hard & soft resets
4. Can flash via ectool --name cros_pd flashpd 4 <port> <RW image>
5. Still drives external display. With bootarg drm.debug=0x6 and following
command: 'tail -f /var/log/messages | grep "Received HPD" &'
I see HPD assert & deassert when switching between GFU and DP mode.
If both modes entered screen stays lit (after reboot) during write.
Change-Id: I7a21ebea377402eb1b0a0cf1d29df59694e301b1
Reviewed-on: https://chromium-review.googlesource.com/241790
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Diffstat (limited to 'board/dingdong')
-rw-r--r-- | board/dingdong/usb_pd_policy.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/board/dingdong/usb_pd_policy.c b/board/dingdong/usb_pd_policy.c index 5ac32bb7e0..2537a9a658 100644 --- a/board/dingdong/usb_pd_policy.c +++ b/board/dingdong/usb_pd_policy.c @@ -33,10 +33,8 @@ const uint32_t pd_snk_pdo[] = { }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); -/* Whether alternate mode has been entered or not */ -static int alt_mode; -/* When set true, we are in GFU mode */ -static int gfu_mode; +/* Holds valid object position (opos) for entered mode */ +static int alt_mode[PD_AMODE_COUNT]; void pd_set_input_current_limit(int port, uint32_t max_ma, uint32_t supply_voltage) @@ -195,12 +193,11 @@ static int svdm_enter_mode(int port, uint32_t *payload) /* SID & mode request is valid */ if ((PD_VDO_VID(payload[0]) == USB_SID_DISPLAYPORT) && (PD_VDO_OPOS(payload[0]) == OPOS_DP)) { - alt_mode = OPOS_DP; + alt_mode[PD_AMODE_DISPLAYPORT] = OPOS_DP; rv = 1; } else if ((PD_VDO_VID(payload[0]) == USB_VID_GOOGLE) && (PD_VDO_OPOS(payload[0]) == OPOS_GFU)) { - alt_mode = OPOS_GFU; - gfu_mode = 1; + alt_mode[PD_AMODE_GOOGLE] = OPOS_GFU; rv = 1; } @@ -214,20 +211,25 @@ static int svdm_enter_mode(int port, uint32_t *payload) return rv; } -int pd_alt_mode(int port) +int pd_alt_mode(int port, uint16_t svid) { - return alt_mode; + if (svid == USB_SID_DISPLAYPORT) + return alt_mode[PD_AMODE_DISPLAYPORT]; + else if (svid == USB_VID_GOOGLE) + return alt_mode[PD_AMODE_GOOGLE]; + return 0; } static int svdm_exit_mode(int port, uint32_t *payload) { - alt_mode = 0; - if (PD_VDO_VID(payload[0]) == USB_SID_DISPLAYPORT) + if (PD_VDO_VID(payload[0]) == USB_SID_DISPLAYPORT) { gpio_set_level(GPIO_PD_SBU_ENABLE, 0); - else if (PD_VDO_VID(payload[0]) == USB_VID_GOOGLE) - gfu_mode = 0; - else + alt_mode[PD_AMODE_DISPLAYPORT] = 0; + } else if (PD_VDO_VID(payload[0]) == USB_VID_GOOGLE) { + alt_mode[PD_AMODE_GOOGLE] = 0; + } else { CPRINTF("Unknown exit mode req:0x%08x\n", payload[0]); + } return 1; /* Must return ACK */ } @@ -251,7 +253,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, { int rsize; - if (PD_VDO_VID(payload[0]) != USB_VID_GOOGLE || !gfu_mode) + if (PD_VDO_VID(payload[0]) != USB_VID_GOOGLE || + !alt_mode[PD_AMODE_GOOGLE]) return 0; *rpayload = payload; |