pd: add a connection flag to pd port info for host

Export what the PD protocol stack thinks about the port connection
state. This simplifies getting a meaningful data role/power role from the
host (eg we are not really a UFP if we are simply dual-role toggling but
not connected).

Do not increment the command version as this is mostly
backward-compatible and currently no client actually uses that field.

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

BRANCH=samus
BUG=none
TEST=ectool --name=cros_pd usbpd 0
plug and unplug various accessories on the port and check the result.

Change-Id: Ief3e0d47b6a288bcfc5b8fbb8156f29fd09dd336
Reviewed-on: https://chromium-review.googlesource.com/266120
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vincent Palatin
2015-04-17 09:43:33 -07:00
committed by ChromeOS Commit Bot
parent 78de9268b7
commit 0df89000a5
3 changed files with 6 additions and 4 deletions

View File

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

View File

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

View File

@@ -3710,8 +3710,9 @@ 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 %s, Role:%s %s Polarity:CC%d State:%s\n",
p.port, (r_v1->enabled) ? "enabled" : "disabled",
printf("Port C%d is %s,%s, Role:%s %s Polarity:CC%d State:%s\n",
p.port, (r_v1->enabled & 1) ? "enabled" : "disabled",
(r_v1->enabled & 2) ? "connected" : "disconnected",
r_v1->role & PD_ROLE_SOURCE ? "SRC" : "SNK",
r_v1->role & (PD_ROLE_DFP << 1) ? "DFP" : "UFP",
r_v1->polarity + 1, r_v1->state);