summaryrefslogtreecommitdiff
path: root/common/usbc/usbc_task.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2020-09-01 18:08:52 -0700
committerCommit Bot <commit-bot@chromium.org>2020-09-09 18:59:36 +0000
commit5041496934c14966aed77b4ffab501b8663cfb24 (patch)
treed6f3bb6b13e532c5a5e949aafcbcad58efbe2461 /common/usbc/usbc_task.c
parentc444abbfb6df6d0f25f631bae89cd26f717574d4 (diff)
downloadchrome-ec-5041496934c14966aed77b4ffab501b8663cfb24.tar.gz
cleanup: Move High-priority interrupt task to a separate file
BUG=none BRANCH=none TEST=make buildall -j Change-Id: I63a964721a5471d6a00894cb0cb94e9656c10893 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2389325 Reviewed-by: Poornima Tom <poornima.tom@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usbc/usbc_task.c')
-rw-r--r--common/usbc/usbc_task.c100
1 files changed, 1 insertions, 99 deletions
diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c
index f52d19ea0d..7099154f38 100644
--- a/common/usbc/usbc_task.c
+++ b/common/usbc/usbc_task.c
@@ -56,104 +56,6 @@ void tc_start_event_loop(int port)
}
}
-/* High-priority interrupt tasks implementations */
-#ifdef CONFIG_HAS_TASK_PD_INT
-
-/* Used to conditionally compile code in main pd task. */
-#define HAS_DEFFERED_INTERRUPT_HANDLER
-
-/* Events for pd_interrupt_handler_task */
-#define PD_PROCESS_INTERRUPT (1<<0)
-
-static uint8_t pd_int_task_id[CONFIG_USB_PD_PORT_MAX_COUNT];
-
-void schedule_deferred_pd_interrupt(const int port)
-{
- task_set_event(pd_int_task_id[port], PD_PROCESS_INTERRUPT, 0);
-}
-
-/*
- * Theoretically, we may need to support up to 400 USB-PD packets per second for
- * intensive operations such as FW update over PD. This value has tested well
- * preventing watchdog resets with a single bad port partner plugged in.
- */
-#define ALERT_STORM_MAX_COUNT 400
-#define ALERT_STORM_INTERVAL SECOND
-
-/*
- * Main task entry point that handles PD interrupts for a single port
- *
- * @param p The PD port number for which to handle interrupts (pointer is
- * reinterpreted as an integer directly).
- */
-void pd_interrupt_handler_task(void *p)
-{
- const int port = (int) ((intptr_t) p);
- const int port_mask = (PD_STATUS_TCPC_ALERT_0 << port);
- struct {
- int count;
- timestamp_t time;
- } storm_tracker[CONFIG_USB_PD_PORT_MAX_COUNT] = {};
-
- ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
-
- /*
- * If port does not exist, return
- */
- if (port >= board_get_usb_pd_port_count())
- return;
-
- pd_int_task_id[port] = task_get_current();
-
- while (1) {
- const int evt = task_wait_event(-1);
-
- if (evt & PD_PROCESS_INTERRUPT) {
- /*
- * While the interrupt signal is asserted; we have more
- * work to do. This effectively makes the interrupt a
- * level-interrupt instead of an edge-interrupt without
- * having to enable/disable a real level-interrupt in
- * multiple locations.
- *
- * Also, if the port is disabled do not process
- * interrupts. Upon existing suspend, we schedule a
- * PD_PROCESS_INTERRUPT to check if we missed anything.
- */
- while ((tcpc_get_alert_status() & port_mask) &&
- pd_is_port_enabled(port)) {
- timestamp_t now;
-
- tcpc_alert(port);
-
- now = get_time();
- if (timestamp_expired(storm_tracker[port].time,
- &now)) {
- /* Reset timer into future */
- storm_tracker[port].time.val =
- now.val + ALERT_STORM_INTERVAL;
-
- /*
- * Start at 1 since we are processing an
- * interrupt right now
- */
- storm_tracker[port].count = 1;
- } else if (++storm_tracker[port].count >
- ALERT_STORM_MAX_COUNT) {
- CPRINTS("C%d: Interrupt storm detected."
- " Disabling port temporarily",
- port);
-
- pd_set_suspend(port, 1);
- pd_deferred_resume(port);
- }
- }
- }
- }
-}
-#endif /* CONFIG_HAS_TASK_PD_INT */
-
-
static void pd_task_init(int port)
{
if (IS_ENABLED(CONFIG_USB_TYPEC_SM))
@@ -167,7 +69,7 @@ static void pd_task_init(int port)
* Otherwise future interrupts will never fire because another edge
* never happens. Note this needs to happen after set_state() is called.
*/
- if (IS_ENABLED(HAS_DEFFERED_INTERRUPT_HANDLER))
+ if (IS_ENABLED(CONFIG_HAS_TASK_PD_INT))
schedule_deferred_pd_interrupt(port);
}