summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2021-11-05 16:30:29 +1100
committerCommit Bot <commit-bot@chromium.org>2021-11-10 02:35:34 +0000
commit9e02276344957c87ea9747f84aea260958ebf3f9 (patch)
treeaaed866964fea32ca0a4769157b8d55aaa30e3e8
parent910ceb134826d28e7e810131f01c3cf6ac31e054 (diff)
downloadchrome-ec-9e02276344957c87ea9747f84aea260958ebf3f9.tar.gz
zephyr: support shared PD interrupts
Some boards share an interrupt line between multiple PD ports by running pd_shared_alert_task in a task instead of individual per-port tasks. Add support for that by adding USB-C options for shared interrupts and using those to enable the shared interrupt task for the chosen ports. BUG=b:204860054 TEST=builds BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Ice67a6a74b0a2f42982de6e19aa1a478c0a4e068 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3263604 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/Kconfig.tasks10
-rw-r--r--zephyr/Kconfig.usbc39
-rw-r--r--zephyr/shim/include/shimmed_task_id.h16
3 files changed, 65 insertions, 0 deletions
diff --git a/zephyr/Kconfig.tasks b/zephyr/Kconfig.tasks
index 1c4e50fa84..457a911d18 100644
--- a/zephyr/Kconfig.tasks
+++ b/zephyr/Kconfig.tasks
@@ -230,9 +230,16 @@ config HAS_TASK_PD_C3
help
This turns on the PD_C3 task for devices with 4 ports.
+config HAS_TASK_PD_INT_SHARED
+ bool # Selected by PLATFORM_EC_USB_PD_INT_SHARED
+ help
+ This turns on the PD_INT_SHARED task which services PD message
+ interrupts for any port which has a shared IRQ enabled.
+
config HAS_TASK_PD_INT_C0
bool
depends on PLATFORM_EC_USB_POWER_DELIVERY
+ depends on !PLATFORM_EC_USB_PD_PORT_0_SHARED
default y if PLATFORM_EC_USB_PD_PORT_MAX_COUNT > 0
help
This turns on the PD_INT_C0 task which handles servicing of Power
@@ -243,6 +250,7 @@ config HAS_TASK_PD_INT_C0
config HAS_TASK_PD_INT_C1
bool
depends on PLATFORM_EC_USB_POWER_DELIVERY
+ depends on !PLATFORM_EC_USB_PD_PORT_1_SHARED
default y if PLATFORM_EC_USB_PD_PORT_MAX_COUNT > 1
help
This turns on the PD_INT_C1 task for devices with >=2 ports.
@@ -250,6 +258,7 @@ config HAS_TASK_PD_INT_C1
config HAS_TASK_PD_INT_C2
bool
depends on PLATFORM_EC_USB_POWER_DELIVERY
+ depends on !PLATFORM_EC_USB_PD_PORT_2_SHARED
default y if PLATFORM_EC_USB_PD_PORT_MAX_COUNT > 2
help
This turns on the PD_INT_C2 task for devices with >=3 ports.
@@ -257,6 +266,7 @@ config HAS_TASK_PD_INT_C2
config HAS_TASK_PD_INT_C3
bool
depends on PLATFORM_EC_USB_POWER_DELIVERY
+ depends on !PLATFORM_EC_USB_PD_PORT_2_SHARED
default y if PLATFORM_EC_USB_PD_PORT_MAX_COUNT > 3
help
This turns on the PD_INT_C3 task for devices with 4 ports.
diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc
index 67f3fbcc33..343de8b4a7 100644
--- a/zephyr/Kconfig.usbc
+++ b/zephyr/Kconfig.usbc
@@ -250,6 +250,45 @@ menuconfig PLATFORM_EC_USB_POWER_DELIVERY
if PLATFORM_EC_USB_POWER_DELIVERY
+menuconfig PLATFORM_EC_USB_PD_INT_SHARED
+ bool "USB-C ports share PD interrupts"
+ select HAS_TASK_PD_INT_SHARED
+ help
+ This enables processing of shared interrupts where multiple ports
+ share a single IRQ on the EC. Only one shared IRQ is supported,
+ but any combination of ports can be serviced by that one IRQ.
+
+if PLATFORM_EC_USB_PD_INT_SHARED
+
+config PLATFORM_EC_USB_PD_PORT_0_SHARED
+ bool "Port 0 IRQ is shared"
+ help
+ Enable handling of port 0 PD interrupts signalled by an IRQ that is
+ shared by every other port enabled in this section.
+
+config PLATFORM_EC_USB_PD_PORT_1_SHARED
+ bool "Port 1 IRQ is shared"
+ depends on PLATFORM_EC_USB_PD_PORT_MAX_COUNT > 1
+ help
+ Enable handling of port 1 PD interrupts signalled by an IRQ that is
+ shared by every other port enabled in this section.
+
+config PLATFORM_EC_USB_PD_PORT_2_SHARED
+ bool "Port 2 IRQ is shared"
+ depends on PLATFORM_EC_USB_PD_PORT_MAX_COUNT > 2
+ help
+ Enable handling of port 2 PD interrupts signalled by an IRQ that is
+ shared by every other port enabled in this section.
+
+config PLATFORM_EC_USB_PD_PORT_3_SHARED
+ bool "Port 3 IRQ is shared"
+ depends on PLATFORM_EC_USB_PD_PORT_MAX_COUNT > 3
+ help
+ Enable handling of port 3 PD interrupts signalled by an IRQ that is
+ shared by every other port enabled in this section.
+
+endif # PLATFORM_EC_USB_PD_INT_SHARED
+
config PLATFORM_EC_USB_PD_HOST_CMD
bool "Host commands related to USB Power Delivery"
default y
diff --git a/zephyr/shim/include/shimmed_task_id.h b/zephyr/shim/include/shimmed_task_id.h
index f56edf0806..082c305cca 100644
--- a/zephyr/shim/include/shimmed_task_id.h
+++ b/zephyr/shim/include/shimmed_task_id.h
@@ -12,6 +12,18 @@
typedef uint8_t task_id_t;
/*
+ * Bitmask of port enable bits, expanding to a value like `BIT(0) | BIT(2) | 0`.
+ */
+#define PD_INT_SHARED_PORT_MASK ( \
+ FOR_EACH_NONEMPTY_TERM(BIT, (|), \
+ IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED, (0)), \
+ IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_1_SHARED, (1)), \
+ IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_2_SHARED, (2)), \
+ IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_3_SHARED, (3)), \
+ ) 0 \
+)
+
+/*
* Highest priority on bottom -- same as in platform/ec. List of CROS_EC_TASK
* items. See CONFIG_TASK_LIST in platform/ec's config.h for more information.
* For tests that want their own custom tasks, use CONFIG_HAS_TEST_TASKS and not
@@ -67,6 +79,10 @@ typedef uint8_t task_id_t;
COND_CODE_1(HAS_TASK_PD_C3, \
(CROS_EC_TASK(PD_C3, pd_task, 0, \
CONFIG_TASK_PD_STACK_SIZE)), ()) \
+ IF_ENABLED(CONFIG_HAS_TASK_PD_INT_SHARED, \
+ (CROS_EC_TASK(PD_INT_SHARED, pd_shared_alert_task, \
+ PD_INT_SHARED_PORT_MASK, \
+ CONFIG_TASK_PD_INT_STACK_SIZE))) \
COND_CODE_1(HAS_TASK_PD_INT_C0, \
(CROS_EC_TASK(PD_INT_C0, pd_interrupt_handler_task, 0, \
CONFIG_TASK_PD_INT_STACK_SIZE)), ()) \