summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorSam Hurst <shurst@google.com>2021-06-24 09:27:09 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-28 23:30:36 +0000
commit92a6d035526a4914e03e06d4eb7b0a6c928938e2 (patch)
treef0bc809492890f8dd056fbc177fe615f37b2c3a8 /zephyr
parent9679fba5d5dec3e68401ad56c4137c055116d683 (diff)
downloadchrome-ec-92a6d035526a4914e03e06d4eb7b0a6c928938e2.tar.gz
zephyr: add support for mkbp wake event mask
Add support in the devicetree for masking mkbp events to prevent said events from waking up a suspended system. BUG=b:190503252 BRANCH=none TEST=make buildall TEST=zmake testall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ib53b8f96c2fb4704e25ce4fb62eb277a16d92cd9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2985820
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/Kconfig26
-rw-r--r--zephyr/dts/bindings/cros_mkbp_event/ec-mkbp-event.yaml16
-rw-r--r--zephyr/include/dt-bindings/wake_mask_event_defines.h71
-rw-r--r--zephyr/shim/include/config_chip.h14
4 files changed, 127 insertions, 0 deletions
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index 5bd8be5006..5c01a09314 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -418,6 +418,32 @@ config PLATFORM_EC_MKBP_EVENT
This requires a MKBP event delivery method(GPIO, HOST_EVENT, and etc)
+config PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK
+ bool "MKBP event wakeup mask"
+ depends on PLATFORM_EC_MKBP_EVENT
+ help
+ Enable which MKBP events should wakeup the system in suspend.
+ For example:
+ The MKBP events are enabled in the devicetree by the wakeup-mask
+ property of the ec-mkbp-event-wakeup-mask node as follows:
+ wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \
+ MKBP_EVENT_HOST_EVENT | \
+ MKBP_EVENT_SENSOR_FIFO)>;
+ The mkbp events are defined in dt-bindings/wake_mask_event_defines.h
+
+config PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK
+ bool "MKBP host event wakeup mask"
+ depends on PLATFORM_EC_MKBP_EVENT
+ help
+ Enable which host events should wakeup the system in suspend.
+ For example:
+ The host events are enabled in the devicetree by the wakeup-mask
+ property of the ec-mkbp-host-event-wakeup-mask node as follows:
+ wakeup-mask = <(HOST_EVENT_LID_OPEN | \
+ HOST_EVENT_POWER_BUTTON | \
+ HOST_EVENT_AC_CONNECTED)>;
+ The host events are defined in dt-bindings/wake_mask_event_defines.h
+
config PLATFORM_EC_MPU
bool "Support Memory-Protection Unit (MPU)"
depends on CPU_CORTEX_M
diff --git a/zephyr/dts/bindings/cros_mkbp_event/ec-mkbp-event.yaml b/zephyr/dts/bindings/cros_mkbp_event/ec-mkbp-event.yaml
new file mode 100644
index 0000000000..c8f5a0c376
--- /dev/null
+++ b/zephyr/dts/bindings/cros_mkbp_event/ec-mkbp-event.yaml
@@ -0,0 +1,16 @@
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description: EC MKBP Event node
+
+compatible: "ec-wake-mask-event"
+
+properties:
+ wakeup-mask:
+ required: false
+ type: int
+ default: 0
+ description:
+ Define the MKBP or host events that will wake up the application
+ processor from suspend mode.
diff --git a/zephyr/include/dt-bindings/wake_mask_event_defines.h b/zephyr/include/dt-bindings/wake_mask_event_defines.h
new file mode 100644
index 0000000000..80be063279
--- /dev/null
+++ b/zephyr/include/dt-bindings/wake_mask_event_defines.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+#ifndef DT_BINDINGS_WAKE_MASK_EVENT_DEFINES_H_
+#define DT_BINDINGS_WAKE_MASK_EVENT_DEFINES_H_
+
+#ifndef BIT
+#define BIT(n) (1U << n)
+#endif
+
+/*
+ * NOTE: The convention in the Zephyr code is to have the public header file
+ * include the dt-binding header file to avoid duplicate definitions.
+ * However, ec_commands.h is shared with the linux kernel so we can't do that.
+ *
+ * Please consult include/ec_commands.h for explanations of the macros
+ * defined in this file.
+ */
+
+#define MKBP_EVENT_KEY_MATRIX BIT(0)
+#define MKBP_EVENT_HOST_EVENT BIT(1)
+#define MKBP_EVENT_SENSOR_FIFO BIT(2)
+#define MKBP_EVENT_BUTTON BIT(3)
+#define MKBP_EVENT_SWITCH BIT(4)
+#define MKBP_EVENT_FINGERPRINT BIT(5)
+#define MKBP_EVENT_SYSRQ BIT(6)
+#define MKBP_EVENT_HOST_EVENT64 BIT(7)
+#define MKBP_EVENT_CEC_EVENT BIT(8)
+#define MKBP_EVENT_CEC_MESSAGE BIT(9)
+#define MKBP_EVENT_DP_ALT_MODE_ENTERED BIT(10)
+#define MKBP_EVENT_ONLINE_CALIBRATION BIT(11)
+#define MKBP_EVENT_PCHG BIT(12)
+
+#define HOST_EVENT_NONE BIT(0)
+#define HOST_EVENT_LID_CLOSED BIT(1)
+#define HOST_EVENT_LID_OPEN BIT(2)
+#define HOST_EVENT_POWER_BUTTON BIT(3)
+#define HOST_EVENT_AC_CONNECTED BIT(4)
+#define HOST_EVENT_AC_DISCONNECTED BIT(5)
+#define HOST_EVENT_BATTERY_LOW BIT(6)
+#define HOST_EVENT_BATTERY_CRITICAL BIT(7)
+#define HOST_EVENT_BATTERY BIT(8)
+#define HOST_EVENT_THERMAL_THRESHOLD BIT(9)
+#define HOST_EVENT_DEVICE BIT(10)
+#define HOST_EVENT_THERMAL BIT(11)
+#define HOST_EVENT_USB_CHARGER BIT(12)
+#define HOST_EVENT_KEY_PRESSED BIT(13)
+#define HOST_EVENT_INTERFACE_READY BIT(14)
+#define HOST_EVENT_KEYBOARD_RECOVERY BIT(15)
+#define HOST_EVENT_THERMAL_SHUTDOWN BIT(16)
+#define HOST_EVENT_BATTERY_SHUTDOWN BIT(17)
+#define HOST_EVENT_THROTTLE_START BIT(18)
+#define HOST_EVENT_THROTTLE_STOP BIT(19)
+#define HOST_EVENT_HANG_DETECT BIT(20)
+#define HOST_EVENT_HANG_REBOOT BIT(21)
+#define HOST_EVENT_PD_MCU BIT(22)
+#define HOST_EVENT_BATTERY_STATUS BIT(23)
+#define HOST_EVENT_PANIC BIT(24)
+#define HOST_EVENT_KEYBOARD_FASTBOOT BIT(25)
+#define HOST_EVENT_RTC BIT(26)
+#define HOST_EVENT_MKBP BIT(27)
+#define HOST_EVENT_USB_MUX BIT(28)
+#define HOST_EVENT_MODE_CHANGE BIT(29)
+#define HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT BIT(30)
+#define HOST_EVENT_WOV BIT(31)
+#define HOST_EVENT_INVALID BIT(32)
+
+#endif /* DT_BINDINGS_WAKE_MASK_EVENT_DEFINES_H_ */
+
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 512097baac..5791fde968 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -441,6 +441,20 @@
#define CONFIG_MKBP_INPUT_DEVICES
#endif
+#undef CONFIG_MKBP_EVENT_WAKEUP_MASK
+#if defined(CONFIG_PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK) && \
+ DT_NODE_EXISTS(DT_PATH(ec_mkbp_event_wakeup_mask))
+#define CONFIG_MKBP_EVENT_WAKEUP_MASK \
+ DT_PROP(DT_PATH(ec_mkbp_event_wakeup_mask), wakeup_mask)
+#endif
+
+#undef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
+#if defined(CONFIG_PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK) && \
+ DT_NODE_EXISTS(DT_PATH(ec_mkbp_host_event_wakeup_mask))
+#define CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK \
+ DT_PROP(DT_PATH(ec_mkbp_host_event_wakeup_mask), wakeup_mask)
+#endif
+
#undef CONFIG_CMD_KEYBOARD
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_KEYBOARD
#define CONFIG_CMD_KEYBOARD