diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2016-05-04 14:30:33 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2017-11-06 16:48:16 +0000 |
commit | cc13a8b9ae68c91fe755a77de62e1821251ceba3 (patch) | |
tree | e78506b728dfde75e085b0756b693ab560fdea2d | |
parent | ffa30cd912e75949db5454046cdbfba3164245a4 (diff) | |
download | chrome-ec-cc13a8b9ae68c91fe755a77de62e1821251ceba3.tar.gz |
[HACK] pd: twinkie: allow sending SOP' Discover Identity
Add a console command (e.g. 'pd 0 vdm ident') to send a Discover
Identity with SOP' to read a cable e-marker information when we are in
sink mode.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=none
TEST=plug a Twinkie to one end of a full-featured type-C cable (with
e-Marker) and Samus to the other end (to get VCONN)
Go into 'Sink' on Twinkie
> tw sink
[11.922071 Jumping to image RW]
Pretend that we have a cable rather than a receptacle with 2 CC
connected
> tw resistor rd 0
We are seeing VBUS and VCONN
> tw cc
CC1 = 421 mV ; CC2 = 2491 mV
> tw vbus
VBUS = 5056 mV ; 0 mA
Send the Discover Identity VDM
> pd 0 vdm ident
Dump the values returned
> pe 0 dump
IDENT:
[ID Header] 1c00050d :: PCable, VID:050d
[Cert Stat] 00000000
[2] 030a0000 [3] 11082032
SVID[0]: 04b4 MODES: [1] 00000001
Change-Id: I08a48af9062821518109db557589b7155f228a37
Reviewed-on: https://chromium-review.googlesource.com/684302
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/twinkie/board.h | 3 | ||||
-rw-r--r-- | board/twinkie/usb_pd_policy.c | 11 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 8 | ||||
-rw-r--r-- | common/usb_pd_tcpc.c | 5 |
4 files changed, 25 insertions, 2 deletions
diff --git a/board/twinkie/board.h b/board/twinkie/board.h index 2de4f1843f..05d11e2724 100644 --- a/board/twinkie/board.h +++ b/board/twinkie/board.h @@ -24,6 +24,8 @@ #define CONFIG_WEBUSB_URL "storage.googleapis.com/webtwinkie.org/tool.html" #define CONFIG_USB_POWER_DELIVERY +#define CONFIG_USB_PD_ALT_MODE +#define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_INTERNAL_COMP #define CONFIG_USB_PD_PORT_COUNT 1 @@ -43,6 +45,7 @@ #define CONFIG_ADC #define CONFIG_BOARD_PRE_INIT #define CONFIG_CMD_REBOOT_DFU +#define CONFIG_CMD_USB_PD_PE #define CONFIG_I2C #define CONFIG_I2C_MASTER #define CONFIG_INA231 diff --git a/board/twinkie/usb_pd_policy.c b/board/twinkie/usb_pd_policy.c index 8c70f438df..1a55456f20 100644 --- a/board/twinkie/usb_pd_policy.c +++ b/board/twinkie/usb_pd_policy.c @@ -99,8 +99,19 @@ void pd_execute_data_swap(int port, int data_role) /* Do nothing */ } +/* ----------------- Vendor Defined Messages ------------------ */ +const struct svdm_response svdm_rsp = { + .identity = NULL, + .svids = NULL, + .modes = NULL, +}; + int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) { return 0; } + +const struct svdm_amode_fx supported_modes[] = { +}; +const int supported_modes_cnt = ARRAY_SIZE(supported_modes); diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index ee4ae31ab0..426414deca 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -152,6 +152,7 @@ static struct pd_protocol { /* next Vendor Defined Message to send */ uint32_t vdo_data[VDO_MAX_SIZE]; uint8_t vdo_count; + uint8_t vdm_tx_type; /* VDO to retry if UFP responder replied busy. */ uint32_t vdo_retry; @@ -1269,8 +1270,9 @@ static void pd_vdm_send_state_machine(int port) header = PD_HEADER(PD_DATA_VENDOR_DEF, pd[port].power_role, pd[port].data_role, pd[port].msg_id, (int)pd[port].vdo_count); - res = pd_transmit(port, TCPC_TX_SOP, header, + res = pd_transmit(port, pd[port].vdm_tx_type, header, pd[port].vdo_data); + pd[port].vdm_tx_type = TCPC_TX_SOP; if (res < 0) { pd[port].vdm_state = VDM_STATE_ERR_SEND; } else { @@ -3478,6 +3480,10 @@ static int command_pd(int argc, char **argv) } else if (!strncasecmp(argv[3], "vers", 4)) { pd_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_VERSION, NULL, 0); + } else if (!strncasecmp(argv[3], "ident", 4)) { + pd[port].vdm_tx_type = TCPC_TX_SOP_PRIME; + pd_send_vdm(port, USB_SID_PD, CMD_DISCOVER_IDENT, + NULL, 0); } else { return EC_ERROR_PARAM_COUNT; } diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index c3222cb57a..4846e33c2a 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -754,7 +754,10 @@ static int cc_voltage_to_status(int port, int cc_volt, int cc_sel) } #ifdef CONFIG_USB_PD_DUAL_ROLE else if (pd[port].cc_pull == TYPEC_CC_RD) { - if (cc_volt >= TYPE_C_SRC_3000_THRESHOLD) + if (cc_volt >= 3*TYPE_C_SRC_3000_THRESHOLD/2) + /* HACK for Twinkie: that's VCONN, ignore it */ + return TYPEC_CC_VOLT_OPEN; + else if (cc_volt >= TYPE_C_SRC_3000_THRESHOLD) return TYPEC_CC_VOLT_SNK_3_0; else if (cc_volt >= TYPE_C_SRC_1500_THRESHOLD) return TYPEC_CC_VOLT_SNK_1_5; |