summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-12-28 12:47:48 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-28 23:48:00 +0000
commit6794147bb960d9b0668741e6bd7d82f7cadf7eba (patch)
tree55dea791dac5ba5c25f0042bb8f9dd99be3772f9
parent02bcfba2c3e1aa4ac71a234314477cd5b2758dea (diff)
downloadchrome-ec-6794147bb960d9b0668741e6bd7d82f7cadf7eba.tar.gz
tpcmv2: Fix compile error for Zephyr builds
Fix Type-C max source mutex for compatibility with Zephyr environment. BUG=none BRANCH=none TEST=make buildall TEST=build zephyr-chrome for volteer Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ibae899b8c937e0ed673ce9661584091440d40c1f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2605327 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
-rw-r--r--common/usbc/usb_pd_dpm.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c
index 6643fed42c..a64d31d841 100644
--- a/common/usbc/usb_pd_dpm.c
+++ b/common/usbc/usb_pd_dpm.c
@@ -358,7 +358,11 @@ void dpm_run(int port)
* them
*/
static uint32_t max_current_claimed;
-static struct mutex max_current_claimed_lock;
+static mutex_t max_current_claimed_lock;
+
+#ifdef CONFIG_ZEPHYR
+static bool dpm_mutex_initialized;
+#endif
static uint32_t sink_max_pdo_requested; /* Ports with PD sink needing > 1.5A */
@@ -383,6 +387,13 @@ static void balance_source_ports(void)
{
uint32_t removed_ports, new_ports;
+#ifdef CONFIG_ZEPHYR
+ if (!dpm_mutex_initialized) {
+ (void)k_mutex_init(&max_current_claimed_lock);
+ dpm_mutex_initialized = true;
+ }
+#endif
+
mutex_lock(&max_current_claimed_lock);
/* Remove any ports which no longer require 3.0 A */