summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-03-11 11:44:18 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-13 03:40:49 +0000
commit4c75ac48d3d366e950ebb0def90e661d70a13895 (patch)
treeb76f3104c8550f494a447f535920a72b08eae5c5
parent179972d2f99d454edb7240892a5878b02669de9c (diff)
downloadchrome-ec-4c75ac48d3d366e950ebb0def90e661d70a13895.tar.gz
pd: make source-only PD devices compatible with the common runtime
Add the proper checks to be able to compile source-only PD devices with the common runtime. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:37078 TEST=make buildall build honeybuns without CONFIG_USB_PD_DUAL_ROLE defined Change-Id: I7ad0b39b2e62736117ec2d7b5163502afbf14786 Reviewed-on: https://chromium-review.googlesource.com/259112 Reviewed-by: Scott Collyer <scollyer@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/usb_pd_protocol.c14
-rw-r--r--include/usb_pd.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 97ae02f585..639de2c287 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -306,9 +306,9 @@ struct mutex pd_crc_lock;
#ifdef CONFIG_COMMON_RUNTIME
static const char * const pd_state_names[] = {
- "DISABLED",
+ "DISABLED", "SUSPENDED",
#ifdef CONFIG_USB_PD_DUAL_ROLE
- "SUSPENDED", "SNK_DISCONNECTED", "SNK_DISCONNECTED_DEBOUNCE",
+ "SNK_DISCONNECTED", "SNK_DISCONNECTED_DEBOUNCE",
"SNK_HARD_RESET_RECOVER",
"SNK_DISCOVERY", "SNK_REQUESTED", "SNK_TRANSITION", "SNK_READY",
"SNK_DR_SWAP", "SNK_SWAP_INIT", "SNK_SWAP_SNK_DISABLE",
@@ -2947,6 +2947,7 @@ int pd_fetch_acc_log_entry(int port)
return EC_RES_SUCCESS;
}
+#ifdef CONFIG_USB_PD_DUAL_ROLE
void pd_request_source_voltage(int port, int mv)
{
pd_set_max_voltage(mv);
@@ -2963,6 +2964,7 @@ void pd_request_source_voltage(int port, int mv)
task_wake(PORT_TO_TASK_ID(port));
}
+#endif /* CONFIG_USB_PD_DUAL_ROLE */
static int command_pd(int argc, char **argv)
{
@@ -2972,7 +2974,7 @@ static int command_pd(int argc, char **argv)
if (argc < 2)
return EC_ERROR_PARAM_COUNT;
-#ifdef CONFIG_CMD_PD
+#if defined(CONFIG_CMD_PD) && defined(CONFIG_USB_PD_DUAL_ROLE)
/* command: pd <subcmd> <args> */
if (!strcasecmp(argv[1], "dualrole")) {
if (argc < 3) {
@@ -3052,7 +3054,7 @@ static int command_pd(int argc, char **argv)
return EC_ERROR_PARAM_COUNT;
if (*e || port >= PD_PORT_COUNT)
return EC_ERROR_PARAM2;
-#ifdef CONFIG_CMD_PD
+#if defined(CONFIG_CMD_PD) && defined(CONFIG_USB_PD_DUAL_ROLE)
if (!strcasecmp(argv[2], "tx")) {
set_state(port, PD_STATE_SNK_DISCOVERY);
@@ -3218,6 +3220,8 @@ DECLARE_CONSOLE_COMMAND(typec, command_typec,
#endif /* CONFIG_CMD_TYPEC */
#endif /* CONFIG_USBC_SS_MUX */
+#ifdef HAS_TASK_HOSTCMD
+
static int hc_pd_ports(struct host_cmd_handler_args *args)
{
struct ec_response_usb_pd_ports *r = args->response;
@@ -3477,4 +3481,6 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_SET_AMODE,
EC_VER_MASK(0));
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
+#endif /* HAS_TASK_HOSTCMD */
+
#endif /* CONFIG_COMMON_RUNTIME */
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 14200efa2c..cf8dffc41f 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -580,8 +580,8 @@ struct pd_policy {
enum pd_states {
PD_STATE_DISABLED,
-#ifdef CONFIG_USB_PD_DUAL_ROLE
PD_STATE_SUSPENDED,
+#ifdef CONFIG_USB_PD_DUAL_ROLE
PD_STATE_SNK_DISCONNECTED,
PD_STATE_SNK_DISCONNECTED_DEBOUNCE,
PD_STATE_SNK_HARD_RESET_RECOVER,