ryu: plankton: allow plankton to send VDM to enter CCD

Create new custom VDM to notify DUT to enter case closed
debugging mode. Send this VDM from Plankton when the case
closed debugging enable button is pressed. Once DUT
receives the CCD enable VDM, CCD remains enabled until
a reboot. Note, this is polarity dependent, so cable
might need to be flipped.

BUG=chrome-os-partner:42569
BRANCH=smaug
TEST=load on plankton and ryu. attach full feature C to C
cable (must have USB3.0 wires). make sure plankton is in
USB mode (USB_SS_USB_MODE light should be set, which can be
done by pressing DP_USB_TOGGLE button). Press CASE_CLOSE_EN
button to send VDM, and then attach micro-B to debug port
CN14 on plankton. See that VID/PID for Ryu show up in lsusb
on host, and EC console works. If device does not show up,
flip polarity of cable.

Change-Id: Ifa469e4a43e32089becd75fe6cdfe0ed462d950b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/287441
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Alec Berg
2015-07-21 15:52:45 -07:00
committed by ChromeOS Commit Bot
parent 0115834bb6
commit 642fa3f3bc
3 changed files with 18 additions and 1 deletions

View File

@@ -126,6 +126,7 @@ enum usbc_action {
USBC_ACT_MUX_FLIP,
USBC_ACT_CABLE_POLARITY0,
USBC_ACT_CABLE_POLARITY1,
USBC_ACT_CCD_EN,
/* Number of USBC actions */
USBC_ACT_COUNT
@@ -310,6 +311,9 @@ static void set_usbc_action(enum usbc_action act)
case USBC_ACT_CABLE_POLARITY1:
gpio_set_level(GPIO_USBC_POLARITY, 1);
break;
case USBC_ACT_CCD_EN:
pd_send_vdm(0, USB_VID_GOOGLE, VDO_CMD_CCD_EN, NULL, 0);
break;
default:
break;
}
@@ -358,6 +362,9 @@ static void button_deferred(void)
case GPIO_DBG_MUX_FLIP_L:
set_usbc_action(USBC_ACT_MUX_FLIP);
break;
case GPIO_DBG_CASE_CLOSE_EN_L:
set_usbc_action(USBC_ACT_CCD_EN);
break;
default:
break;
}
@@ -499,6 +506,8 @@ static int cmd_usbc_action(int argc, char *argv[])
act = USBC_ACT_12V_TO_DUT;
else if (!strcasecmp(argv[1], "20v"))
act = USBC_ACT_20V_TO_DUT;
else if (!strcasecmp(argv[1], "ccd"))
act = USBC_ACT_CCD_EN;
else if (!strcasecmp(argv[1], "dev"))
act = USBC_ACT_DEVICE;
else if (!strcasecmp(argv[1], "usb"))
@@ -519,7 +528,7 @@ static int cmd_usbc_action(int argc, char *argv[])
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(usbc_action, cmd_usbc_action,
"<5v|12v|20v|dev|usb|dp|flip|pol0|pol1>",
"<5v|12v|20v|ccd|dev|usb|dp|flip|pol0|pol1>",
"Set Plankton type-C port state",
NULL);
@@ -647,6 +656,7 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_DBG_CHG_TO_DEV_L);
gpio_enable_interrupt(GPIO_DBG_USB_TOGGLE_L);
gpio_enable_interrupt(GPIO_DBG_MUX_FLIP_L);
gpio_enable_interrupt(GPIO_DBG_CASE_CLOSE_EN_L);
/* TODO(crosbug.com/33761): poll DBG_20V_TO_DUT_L */
enable_dbg20v_poll();

View File

@@ -4,6 +4,7 @@
*/
#include "config.h"
#include "case_closed_debug.h"
#include "charge_manager.h"
#include "charger.h"
#include "common.h"
@@ -252,6 +253,11 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload,
pd_log_recv_vdm(port, cnt, payload);
break;
#endif /* CONFIG_USB_PD_LOGGING */
#ifdef CONFIG_CASE_CLOSED_DEBUG
case VDO_CMD_CCD_EN:
ccd_set_mode(CCD_MODE_ENABLED);
break;
#endif
}
return 0;

View File

@@ -325,6 +325,7 @@ struct pd_policy {
#define VDO_CMD_CURRENT VDO_CMD_VENDOR(11)
#define VDO_CMD_FLIP VDO_CMD_VENDOR(12)
#define VDO_CMD_GET_LOG VDO_CMD_VENDOR(13)
#define VDO_CMD_CCD_EN VDO_CMD_VENDOR(14)
#define PD_VDO_VID(vdo) ((vdo) >> 16)
#define PD_VDO_SVDM(vdo) (((vdo) >> 15) & 1)