diff options
author | Simon Glass <sjg@chromium.org> | 2020-11-04 16:51:58 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-06 03:42:15 +0000 |
commit | 8f91458a1b888bb75f6f4d3ffe4d0de1a221a589 (patch) | |
tree | 894dccba23a7a475dd63d4f3770ea4a4714a8abe | |
parent | 29c78b9d50929ae3a2d78752a50314305ab515da (diff) | |
download | chrome-ec-8f91458a1b888bb75f6f4d3ffe4d0de1a221a589.tar.gz |
zephyr: Allow keyboard_8042 to build with zephyr
Make a few changes so that this file can build. It does not work yet.
BUG=b:167405015
BRANCH=none
TEST=make BOARD=volteer
zmake configure .../zephyr-chrome/projects/experimental/volteer \
-B /tmp/z/cos
zmake build /tmp/z/cos
See there are no errors
Change-Id: If68cc8e4541f513013481bde859fbe2f4681a0bc
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521358
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | common/keyboard_8042.c | 35 | ||||
-rw-r--r-- | zephyr/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/Kconfig | 25 | ||||
-rw-r--r-- | zephyr/shim/include/config_chip.h | 5 |
4 files changed, 62 insertions, 5 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index 4e3a5b4b98..12a7da2560 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -38,6 +38,26 @@ #define CPRINTS5(format, args...) #endif +/* + * This command needs malloc to work. Could we use this instead? + * + * #define CMD_KEYBOARD_LOG IS_ENABLED(CONFIG_MALLOC) + */ +#ifdef CONFIG_MALLOC +#define CMD_KEYBOARD_LOG 1 +#else +#define CMD_KEYBOARD_LOG 0 +#endif + +#ifdef CONFIG_ZEPHYR +/* b/171815541: Implement these when LPC is ready */ +void lpc_keyboard_clear_buffer(void) {} +void lpc_keyboard_resume_irq(void) {} +int lpc_keyboard_has_char(void) { return 0; } +void lpc_keyboard_put_char(uint8_t chr, int send_irq) {} +int lpc_keyboard_input_pending(void) { return 0; } +#endif + static enum { STATE_NORMAL = 0, STATE_SCANCODE, @@ -68,7 +88,7 @@ enum scancode_set_list { * Mutex to control write access to the to-host buffer head. Don't need to * mutex the tail because reads are only done in one place. */ -static struct mutex to_host_mutex; +static mutex_t to_host_mutex; /* Queue command/data to the host */ enum { @@ -1141,10 +1161,11 @@ static int command_keyboard_log(int argc, char **argv) return EC_SUCCESS; } +#if CMD_KEYBOARD_LOG DECLARE_CONSOLE_COMMAND(kblog, command_keyboard_log, "[on | off]", "Print or toggle keyboard event log"); - +#endif static int command_keyboard(int argc, char **argv) { @@ -1220,7 +1241,7 @@ static int command_8042(int argc, char **argv) return command_codeset(argc - 1, argv + 1); else if (!strcasecmp(argv[1], "ctrlram")) return command_controller_ram(argc - 1, argv + 1); - else if (!strcasecmp(argv[1], "kblog")) + else if (CMD_KEYBOARD_LOG && !strcasecmp(argv[1], "kblog")) return command_keyboard_log(argc - 1, argv + 1); else if (!strcasecmp(argv[1], "kbd")) return command_keyboard(argc - 1, argv + 1); @@ -1237,8 +1258,10 @@ static int command_8042(int argc, char **argv) command_controller_ram( sizeof(ctlram_argv) / sizeof(ctlram_argv[0]), ctlram_argv); - ccprintf("\n- Keyboard log:\n"); - command_keyboard_log(argc, argv); + if (CMD_KEYBOARD_LOG) { + ccprintf("\n- Keyboard log:\n"); + command_keyboard_log(argc, argv); + } ccprintf("\n- Keyboard:\n"); command_keyboard(argc, argv); ccprintf("\n- Internal:\n"); @@ -1300,6 +1323,7 @@ static void keyboard_restore_state(void) } DECLARE_HOOK(HOOK_INIT, keyboard_restore_state, HOOK_PRIO_DEFAULT); +#ifdef CONFIG_POWER_BUTTON /** * Handle power button changing state. */ @@ -1310,3 +1334,4 @@ static void keyboard_power_button(void) } DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, keyboard_power_button, HOOK_PRIO_DEFAULT); +#endif diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 3a0530e782..c9aa8bf115 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -36,5 +36,7 @@ add_subdirectory_ifdef(CONFIG_PLATFORM_EC "shim/src") zephyr_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c") zephyr_sources_ifdef(CONFIG_SHELL "${PLATFORM_EC}/common/gpio_commands.c") +zephyr_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042 + "${PLATFORM_EC}/common/keyboard_8042.c") zephyr_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/queue.c") zephyr_sources_ifdef(CONFIG_PLATFORM_EC_TIMER "${PLATFORM_EC}/common/timer.c") diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 8a534f8eb6..82637ff5cd 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -28,6 +28,31 @@ config ZEPHYR This should always be enabled. It's a workaround for config.h not being available in some headers. +menuconfig PLATFORM_EC_KEYBOARD + bool "Enable keybaord support" + default y + help + Enable compilation of support for scanning a keyboard and providing + the resulting input to the AP over the host interface. This consists + of a keyboard-scanning task which provides key scans via it calling + keyboard_state_changed() (for i8042) or its client calling + keyboard_scan_get_state() (for MKBP). + +choice "Protocol select" + prompt "Select the keyboard protocol to use" + +config PLATFORM_EC_KEYBOARD_PROTOCOL_8042 + bool "i8042" + help + Use the i8042 protocol to communicate with the AP. This dates from the + Intel 8042 keyboard controller chip released in 1976. It uses two-way + communication via a few 8-bit registers, allowing key codes to be + sent to the AP when keys are pressed and released. + + See here for docs: https://wiki.osdev.org/%228042%22_PS/2_Controller + +endchoice # PLATFORM_EC_KEYBOARD + menuconfig PLATFORM_EC_TIMER bool "Enable the EC timer module" default y diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index dc5f14865c..a9a0bb651a 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -29,6 +29,11 @@ #define CONFIG_CMD_GETTIME #endif /* CONFIG_PLATFORM_EC_TIMER_CMD_GETTIME */ +#undef CONFIG_KEYBOARD_PROTOCOL_8042 +#ifdef CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042 +#define CONFIG_KEYBOARD_PROTOCOL_8042 +#endif /* CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042 */ + #undef CONFIG_CMD_TIMERINFO #ifdef CONFIG_PLATFORM_EC_TIMER_CMD_TIMERINFO #define CONFIG_CMD_TIMERINFO |