summaryrefslogtreecommitdiff
path: root/common/host_command_pd.c
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-11-19 16:51:37 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-11-25 12:59:17 -0800
commit767e132d133b6f1216d630bd3b59e893a59bcffa (patch)
treecd42c82ce7d2246484f3980a1dc7e9966e57e633 /common/host_command_pd.c
parent9665d0b1df2edf954e2c3578c4905d5ca8138edc (diff)
downloadchrome-ec-767e132d133b6f1216d630bd3b59e893a59bcffa.tar.gz
pd: Add support for multiple distinct TCPC alert signals
If multiple TCPCs are present on a system then we may have multiple alert signals, each of which alerts us to the status of a different TCPC. Make boards with external non cros-ec TCPCs define tcpc_get_alert_status, which returns alert status based upon any alert GPIOs present, and then service only ports which are alerting. BUG=chromium:551683,chrome-os-partner:47851 TEST=Verify snoball PDCMD task sleeps appropriately when no devices are inserted, and verify ports go to PD_DISCOVERY state when we attach samus. Also verify that glados / glados_pd can still negotiate PD. BRANCH=None Change-Id: Iae6c4e1ef4d6685cb5bf7feef713505925a07c8c Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/313209 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/host_command_pd.c')
-rw-r--r--common/host_command_pd.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/common/host_command_pd.c b/common/host_command_pd.c
index 477b602796..70178bf933 100644
--- a/common/host_command_pd.c
+++ b/common/host_command_pd.c
@@ -133,16 +133,25 @@ static void pd_check_chg_status(struct ec_response_pd_status *pd_status)
#endif /* CONFIG_HOSTCMD_PD */
#ifdef USB_TCPM_WITH_OFF_CHIP_TCPC
-static void pd_check_tcpc_alert(struct ec_response_pd_status *pd_status)
+static void pd_service_tcpc_ports(uint16_t port_status)
{
int i;
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
- if (!pd_status ||
- (pd_status->status & (PD_STATUS_TCPC_ALERT_0 << i)))
+ if (port_status & (PD_STATUS_TCPC_ALERT_0 << i))
tcpc_alert(i);
}
}
+
+static int pd_get_alert(void)
+{
+#ifdef CONFIG_HOSTCMD_PD
+ return !gpio_get_level(GPIO_PD_MCU_INT);
+#else
+ return !!tcpc_get_alert_status();
+#endif
+}
+
#endif /* USB_TCPM_WITH_OFF_CHIP_TCPC */
static void pd_exchange_status(uint32_t ec_state)
@@ -179,16 +188,15 @@ static void pd_exchange_status(uint32_t ec_state)
#ifdef USB_TCPM_WITH_OFF_CHIP_TCPC
#ifdef CONFIG_HOSTCMD_PD
- pd_check_tcpc_alert(&pd_status);
+ pd_service_tcpc_ports(pd_status.status);
#else
- pd_check_tcpc_alert(NULL);
+ pd_service_tcpc_ports(tcpc_get_alert_status());
#endif
- if (!first_exchange) {
+ if (!first_exchange)
usleep(50*MSEC);
- first_exchange = 0;
- }
- } while (!gpio_get_level(GPIO_PD_MCU_INT));
+ first_exchange = 0;
+ } while (pd_get_alert());
#endif /* USB_TCPM_WITH_OFF_CHIP_TCPC */
}