summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Barnes <robbarnes@google.com>2021-01-05 14:15:48 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-08 22:26:33 +0000
commit3dce77c9f02c0df967cdc49d5766d6449cf9f5b5 (patch)
tree465aeb8d5855612f5027b18b8effc407c9012eee
parent7782e4b048662f4a5fdc89e15676a13e3c674e41 (diff)
downloadchrome-ec-3dce77c9f02c0df967cdc49d5766d6449cf9f5b5.tar.gz
guybrush: Implement tcpc_alert_event and tcpc_get_alert_status
Implement tcp_alert_event and tcpc_get_alert_status. Add pd_task and pd_interrupt_handler_task tasks. BUG=None BRANCH=None TEST=Build Change-Id: I99b6802eb4ebe59ca3ca25bb0c7f9e8af8be3bd2 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2611822 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--baseboard/guybrush/base_ec.tasklist6
-rw-r--r--baseboard/guybrush/baseboard.c60
2 files changed, 64 insertions, 2 deletions
diff --git a/baseboard/guybrush/base_ec.tasklist b/baseboard/guybrush/base_ec.tasklist
index e9214fda1c..cb567355ef 100644
--- a/baseboard/guybrush/base_ec.tasklist
+++ b/baseboard/guybrush/base_ec.tasklist
@@ -16,4 +16,8 @@
TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(POWERBTN, power_button_task, NULL, VENTI_TASK_STACK_SIZE) \
- TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE)
+ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_C0, pd_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_C1, pd_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, TASK_STACK_SIZE)
diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c
index 33844c38a9..0b65f8995f 100644
--- a/baseboard/guybrush/baseboard.c
+++ b/baseboard/guybrush/baseboard.c
@@ -432,7 +432,65 @@ void sbu_fault_interrupt(enum ioex_signal signal)
void tcpc_alert_event(enum gpio_signal signal)
{
- /* TODO */
+ int port;
+
+ switch (signal) {
+ case GPIO_USB_C0_TCPC_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_TCPC_INT_ODL:
+ port = 1;
+ break;
+ default:
+ return;
+ }
+
+ schedule_deferred_pd_interrupt(port);
+}
+
+static void reset_pd_port(int port, enum gpio_signal reset_gpio_l,
+ int hold_delay, int post_delay)
+{
+ gpio_set_level(reset_gpio_l, 0);
+ msleep(hold_delay);
+ gpio_set_level(reset_gpio_l, 1);
+ if (post_delay)
+ msleep(post_delay);
+}
+
+
+void board_reset_pd_mcu(void)
+{
+ /* Reset TCPC0 */
+ reset_pd_port(USBC_PORT_C0, GPIO_USB_C0_TCPC_RST_L,
+ NCT38XX_RESET_HOLD_DELAY_MS,
+ NCT38XX_RESET_POST_DELAY_MS);
+
+ /* Reset TCPC1 */
+ reset_pd_port(USBC_PORT_C1, GPIO_USB_C1_TCPC_RST_L,
+ NCT38XX_RESET_HOLD_DELAY_MS,
+ NCT38XX_RESET_POST_DELAY_MS);
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+
+ /*
+ * Check which port has the ALERT line set and ignore if that TCPC has
+ * its reset line active.
+ */
+ if (!gpio_get_level(GPIO_USB_C0_TCPC_INT_ODL)) {
+ if (gpio_get_level(GPIO_USB_C0_TCPC_RST_L) != 0)
+ status |= PD_STATUS_TCPC_ALERT_0;
+ }
+
+ if (!gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL)) {
+ if (gpio_get_level(GPIO_USB_C1_TCPC_RST_L) != 0)
+ status |= PD_STATUS_TCPC_ALERT_1;
+ }
+
+ return status;
}
void ppc_interrupt(enum gpio_signal signal)