pd: export the data role to the AP

For dual-role USB ports (host/device), let the AP know whether we are
currently DFP (USB host) or UFP (USB device) by exporting the data role
in addition to the power role in the EC_CMD_USB_PD_CONTROL response.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=none
TEST=ectool --name=cros_pd usbpd 0
plug various accessories on the port and see properly "SRC DFP" for the
USB key, "SNK DFP" for the power supply and "SNK UFP" for a regular
C-to-A charging cable.

Change-Id: I292da15fa8cf3566109dd05995ef1d00bed6f92d
Reviewed-on: https://chromium-review.googlesource.com/242012
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vincent Palatin
2015-01-20 11:48:23 -08:00
committed by ChromeOS Commit Bot
parent 43806f07e3
commit 9e07dfb6cb
3 changed files with 7 additions and 5 deletions

View File

@@ -3255,7 +3255,8 @@ static int hc_usb_pd_control(struct host_cmd_handler_args *args)
args->response_size = sizeof(*r);
} else {
r_v1->enabled = pd_comm_enabled;
r_v1->role = pd[p->port].power_role;
r_v1->role = pd[p->port].power_role |
(pd[p->port].data_role << 1);
r_v1->polarity = pd[p->port].polarity;
strzcpy(r_v1->state,
pd_state_names[pd[p->port].task_state],

View File

@@ -2741,7 +2741,7 @@ struct ec_response_usb_pd_control {
struct ec_response_usb_pd_control_v1 {
uint8_t enabled;
uint8_t role;
uint8_t role; /* [0] power: 0=SNK/1=SRC [1] data: 0=UFP/1=DFP */
uint8_t polarity;
char state[32];
} __packed;

View File

@@ -3136,9 +3136,10 @@ int cmd_usb_pd(int argc, char *argv[])
r->role == PD_ROLE_SOURCE ? "SRC" : "SNK",
r->polarity + 1, r->state);
} else {
printf("Port C%d is %sabled, Role:%s Polarity:CC%d State:%s\n",
p.port, (r_v1->enabled) ? "en" : "dis",
r_v1->role == PD_ROLE_SOURCE ? "SRC" : "SNK",
printf("Port C%d is %s, Role:%s %s Polarity:CC%d State:%s\n",
p.port, (r_v1->enabled) ? "enabled" : "disabled",
r_v1->role & PD_ROLE_SOURCE ? "SRC" : "SNK",
r_v1->role & (PD_ROLE_DFP << 1) ? "DFP" : "UFP",
r_v1->polarity + 1, r_v1->state);
}
return (rv < 0 ? rv : 0);