summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2017-01-24 10:55:46 -0800
committerScott Collyer <scollyer@chromium.org>2017-01-26 16:10:30 +0000
commit44676699b08f7f6ccaba3d8b89a41c79f3c29cb2 (patch)
tree71f3f550f0a4e54973d086c7941681da9cacf7de /common
parent45817826e17528782d65f7571b1224ef99f67faa (diff)
downloadchrome-ec-44676699b08f7f6ccaba3d8b89a41c79f3c29cb2.tar.gz
pd: Move PD_DEFAULT_STATE to a common define in usb_pd.h
Servo_v4 requires the ability to have a different default state per port. In previous devices, the assumption was that each supported port had the same default usb pd state and power role. This CL moves the by the default power role which in turn is derived from CONFIG_USB_PD_DUAL_ROLE. In addiiton to moving the location, it now uses 'port' as argument so it can be port specific if required. PD_DEFAULT_STATE was a board.h specific config, but in practice each instance used to date was set to PD_STATE_SNK_DISCONNECTED if CONFIG_USB_PD_DUAL_ROLE was defined and set to PD_STATE_SRC_DISCONNECTED otherwise. BUG=chrome-os-partner:61878 BRANCH=servo TEST=Manual run 'make -j buildall' to verify that all instances of PD_DEFAULT_STATE were removed. Change-Id: Iaf40718668732f525485ed7942ee7fc246d3f75d Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/431787 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_pd_protocol.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 0378d817f4..28f7796240 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1599,7 +1599,7 @@ void pd_task(void)
/* Initialize TCPM driver and wait for TCPC to be ready */
res = tcpm_init(port);
CPRINTS("TCPC p%d init %s", port, res ? "failed" : "ready");
- this_state = res ? PD_STATE_SUSPENDED : PD_DEFAULT_STATE;
+ this_state = res ? PD_STATE_SUSPENDED : PD_DEFAULT_STATE(port);
#ifdef CONFIG_USB_PD_DUAL_ROLE
/*
@@ -1705,7 +1705,7 @@ void pd_task(void)
/* Ensure state variables are at default */
pd[port].power_role = PD_ROLE_DEFAULT;
pd[port].vdm_state = VDM_STATE_DONE;
- set_state(port, PD_DEFAULT_STATE);
+ set_state(port, PD_DEFAULT_STATE(port));
}
}
#endif
@@ -2989,7 +2989,8 @@ void pd_set_suspend(int port, int enable)
int tries = 3;
do {
- set_state(port, enable ? PD_STATE_SUSPENDED : PD_DEFAULT_STATE);
+ set_state(port, enable ? PD_STATE_SUSPENDED :
+ PD_DEFAULT_STATE(port));
task_wake(PD_PORT_TO_TASK_ID(port));
} while (enable && pd[port].task_state != PD_STATE_SUSPENDED
&& --tries);