summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2021-08-09 16:00:31 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-10 22:19:32 +0000
commit8f1cc4196595280d5c5b817b4015b6d9a308e5c0 (patch)
tree88baeefe55813656f96f9658209bd715bd86c37b
parentd38c5745d486004da1eb7b942b4ce3dbcf7a9be7 (diff)
downloadchrome-ec-8f1cc4196595280d5c5b817b4015b6d9a308e5c0.tar.gz
zephyr: Create devicetree node for keyscan
Create devicetree node to specify the keyscan runtime parameters. BUG=b:195945894 BRANCH=none TEST=zmake testall TEST=verify keyboard on Volteer with next CL Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I4dbf5e4f2205f31651d33b6ffc1ecd1dd6696795 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3083721 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/dts/bindings/keyboard/cros-keyscan.yaml82
-rw-r--r--zephyr/shim/src/CMakeLists.txt1
-rw-r--r--zephyr/shim/src/keyscan.c34
3 files changed, 117 insertions, 0 deletions
diff --git a/zephyr/dts/bindings/keyboard/cros-keyscan.yaml b/zephyr/dts/bindings/keyboard/cros-keyscan.yaml
new file mode 100644
index 0000000000..11caf7fd11
--- /dev/null
+++ b/zephyr/dts/bindings/keyboard/cros-keyscan.yaml
@@ -0,0 +1,82 @@
+ # 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: Keyboard scanning properties
+
+compatible: "cros-keyscan"
+
+properties:
+ output-settle:
+ type: int
+ required: false
+ default: 80
+ description: |
+ Delay time, in microseconds, between setting up output and waiting for
+ it to settle. 80 microseconds is the recommended value when column 2
+ of the keyboard passes through the Google Security Chip. Otherwise 50
+ microseconds is the recommended value.
+
+ debounce-down:
+ type: int
+ required: false
+ default: 9000
+ description: |
+ Time, in microseconds, to debounce key-down.
+
+ debounce-up:
+ type: int
+ required: false
+ default: 30000
+ description: |
+ Time, in microseconds, to debounce key-up.
+
+ scan-period:
+ type: int
+ required: false
+ default: 3000
+ description: |
+ Time between scans when keyboard scan task runs in polling mode.
+
+ min-post-scan-delay:
+ type: int
+ required: false
+ default: 1000
+ description: |
+ Minimum time between end of one scan and start of the next one.
+ This ensures keyboard scanning doesn't starve the rest of the system
+ if the scan period is set too short, or if other higher-priority
+ system activity is starving the keyboard scan task too.
+
+ poll-timeout:
+ type: int
+ required: false
+ default: 100000
+ description: |
+ Revert to interrupt mode after no keyboard activity for this period.
+ Specified in microseconds.
+
+ actual-key-mask:
+ type: array
+ required: false
+ default: [
+ 0x1c, # C0
+ 0xff, # C1
+ 0xff, # C2
+ 0xff, # C3
+ 0xff, # C4
+ 0xf5, # C5
+ 0xff, # C6
+ 0xa4, # C7
+ 0xfe, # C8
+ 0x55, # C9
+ 0xfa, # C10
+ 0xff, # C11
+ 0xca, # C12
+ 0x00, # C13 for keypad
+ 0x00, # C14 for keypad
+ ]
+ description: |
+ Keyboard scanning mask. For each keyboard column, specify which
+ keyboard rows actually exist. Default key mask includes scanning for
+ full Chromebook keyboard, excluding the keypad.
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
index 9b198ec3f2..7be2e75fb2 100644
--- a/zephyr/shim/src/CMakeLists.txt
+++ b/zephyr/shim/src/CMakeLists.txt
@@ -26,6 +26,7 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD host_command.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE
console_buffer.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD keyboard_raw.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD keyscan.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MKBP_EVENT mkbp_event.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MOTIONSENSE
motionsense_sensors.c)
diff --git a/zephyr/shim/src/keyscan.c b/zephyr/shim/src/keyscan.c
new file mode 100644
index 0000000000..514d9ffaed
--- /dev/null
+++ b/zephyr/shim/src/keyscan.c
@@ -0,0 +1,34 @@
+/* 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.
+ */
+
+#define DT_DRV_COMPAT cros_kb_raw_keyscan
+
+#include <assert.h>
+#include <kernel.h>
+#include <soc.h>
+
+#include "keyboard_scan.h"
+
+#if DT_NODE_EXISTS(DT_INST(0, cros_kb_raw_keyscan))
+
+/* The keyboard matrix should have at least enough columns for the
+ * standard keyboard with no keypad.
+ */
+BUILD_ASSERT(DT_INST_PROP_LEN(0, actual_key_mask) >= KEYBOARD_COLS_NO_KEYPAD);
+
+/*
+ * Override the default keyscan_config if the board defines a
+ * cros-kb-raw-keyscan node.
+ */
+__override struct keyboard_scan_config keyscan_config = {
+ .output_settle_us = DT_INST_PROP(0, output_settle),
+ .debounce_down_us = DT_INST_PROP(0, debounce_down),
+ .debounce_up_us = DT_INST_PROP(0, debounce_up),
+ .scan_period_us = DT_INST_PROP(0, scan_period),
+ .min_post_scan_delay_us = DT_INST_PROP(0, min_post_scan_delay),
+ .poll_timeout_us = DT_INST_PROP(0, poll_timeout),
+ .actual_key_mask = DT_INST_PROP(0, actual_key_mask),
+};
+#endif