summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-06-09 11:01:54 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-10 03:33:33 +0000
commitd2c47812664c13d4330600caadafc59d62b814c9 (patch)
tree8520174486078f45d248dded0f79637568da770a
parent8f65ad20e3ad75365117830d50b96c0b5d941be7 (diff)
downloadchrome-ec-d2c47812664c13d4330600caadafc59d62b814c9.tar.gz
pd: enable charging through suzyQ debug accessory
Enable charging through debug accessory by setting input current limit to 3A when debug accessory is detected. Add new dual-role toggling state for stay sink unless VBUS is detected, which allows us to detect debug accessory when we are not normally dual-role toggling. BUG=none BRANCH=smaug TEST=plug suzyQ into ryu in S0 and in S5 and make sure that we go to the SRC_ACCESSORY state and set charger input current limit appropriately. Change-Id: I6262c9d6cd0ae7159f343d36e19d290c2f2e0181 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/276368 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/usb_pd_protocol.c46
-rw-r--r--include/usb_pd.h3
2 files changed, 40 insertions, 9 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 9dd27fcd95..a9f3eaa62a 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1144,12 +1144,14 @@ void pd_set_dual_role(enum pd_dual_role_states state)
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
/*
* Change to sink if port is currently a source AND (new DRP
- * state is force sink OR new DRP state is toggle off and we
- * are in the source disconnected state).
+ * state is force sink OR new DRP state is either toggle off
+ * or debug accessory toggle only and we are in the source
+ * disconnected state).
*/
if (pd[i].power_role == PD_ROLE_SOURCE &&
(drp_state == PD_DRP_FORCE_SINK ||
- (drp_state == PD_DRP_TOGGLE_OFF
+ ((drp_state == PD_DRP_TOGGLE_OFF
+ || drp_state == PD_DRP_DEBUG_ACC_TOGGLE)
&& pd[i].task_state == PD_STATE_SRC_DISCONNECTED))) {
pd[i].power_role = PD_ROLE_SINK;
set_state(i, PD_STATE_SNK_DISCONNECTED);
@@ -1484,8 +1486,13 @@ void pd_task(void)
#endif
#ifdef CONFIG_CASE_CLOSED_DEBUG
- if (new_cc_state == PD_CC_DEBUG_ACC)
+ if (new_cc_state == PD_CC_DEBUG_ACC) {
ccd_set_mode(CCD_MODE_ENABLED);
+ typec_set_input_current_limit(
+ port, 3000, TYPE_C_VOLTAGE);
+ charge_manager_update_dualrole(
+ port, CAP_DEDICATED);
+ }
#endif
set_state(port, PD_STATE_SRC_ACCESSORY);
}
@@ -1825,11 +1832,13 @@ void pd_task(void)
/*
* If no source detected, check for role toggle.
- * Do not toggle if VBUS is present.
+ * If VBUS is detected, and we are in the debug
+ * accessory toggle state, then allow toggling.
*/
- if (drp_state == PD_DRP_TOGGLE_ON &&
- get_time().val >= next_role_swap &&
- !pd_snk_is_vbus_provided(port)) {
+ if ((drp_state == PD_DRP_TOGGLE_ON &&
+ get_time().val >= next_role_swap) ||
+ (drp_state == PD_DRP_DEBUG_ACC_TOGGLE &&
+ pd_snk_is_vbus_provided(port))) {
/* Swap roles to source */
pd[port].power_role = PD_ROLE_SOURCE;
set_state(port, PD_STATE_SRC_DISCONNECTED);
@@ -2417,7 +2426,15 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, dual_role_on, HOOK_PRIO_DEFAULT);
static void dual_role_off(void)
{
+#ifdef CONFIG_CASE_CLOSED_DEBUG
+ /*
+ * Allow toggling to source only if VBUS is present in order
+ * to detect debug accessory.
+ */
+ pd_set_dual_role(PD_DRP_DEBUG_ACC_TOGGLE);
+#else
pd_set_dual_role(PD_DRP_TOGGLE_OFF);
+#endif
CPRINTS("chipset -> S3");
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, dual_role_off, HOOK_PRIO_DEFAULT);
@@ -2426,6 +2443,14 @@ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, dual_role_off, HOOK_PRIO_DEFAULT);
static void dual_role_force_sink(void)
{
pd_set_dual_role(PD_DRP_FORCE_SINK);
+
+#ifdef CONFIG_CASE_CLOSED_DEBUG
+ /*
+ * Allow toggling to source only if VBUS is present in order
+ * to detect debug accessory.
+ */
+ pd_set_dual_role(PD_DRP_DEBUG_ACC_TOGGLE);
+#endif
CPRINTS("chipset -> S5");
}
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, dual_role_force_sink, HOOK_PRIO_DEFAULT);
@@ -2624,6 +2649,9 @@ static int command_pd(int argc, char **argv)
case PD_DRP_FORCE_SOURCE:
ccprintf("force source\n");
break;
+ case PD_DRP_DEBUG_ACC_TOGGLE:
+ ccprintf("debug acc toggle\n");
+ break;
}
} else {
if (!strcasecmp(argv[2], "on"))
@@ -2634,6 +2662,8 @@ static int command_pd(int argc, char **argv)
pd_set_dual_role(PD_DRP_FORCE_SINK);
else if (!strcasecmp(argv[2], "source"))
pd_set_dual_role(PD_DRP_FORCE_SOURCE);
+ else if (!strcasecmp(argv[2], "debug"))
+ pd_set_dual_role(PD_DRP_DEBUG_ACC_TOGGLE);
else
return EC_ERROR_PARAM3;
}
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 2a432936f4..82387f1b1c 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -724,7 +724,8 @@ enum pd_dual_role_states {
PD_DRP_TOGGLE_ON,
PD_DRP_TOGGLE_OFF,
PD_DRP_FORCE_SINK,
- PD_DRP_FORCE_SOURCE
+ PD_DRP_FORCE_SOURCE,
+ PD_DRP_DEBUG_ACC_TOGGLE
};
/**
* Get dual role state