diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-03-20 13:47:35 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-03-22 11:24:28 -0700 |
commit | 743c05f01f8f2b19dbf565bee645076fff75c42d (patch) | |
tree | cbad9ab036c32b3b4d47ad2ad4ded17f18fb02b6 /include | |
parent | cdb08e12217367f0ac8c6ce0dc1df2e27f80563e (diff) | |
download | chrome-ec-743c05f01f8f2b19dbf565bee645076fff75c42d.tar.gz |
Add keyboard_raw interface
This is the low-level platform-dependent interface to drive keyboard
columns, read rows, and handle keyboard interrupts.
Both lm4 and stm32 had something like this before, but the interfaces
weren't fully explicit or compatible.
BUG=chrome-os-partner:18360
BRANCH=none
TEST=manual
- Build all platforms.
- Boot system and test typing on keyboard.
- Hold power+refresh+esc to test boot key detection; should go to recovery.
Change-Id: Ie3bcc1d066a4da5204f0e236daeb52c4064a6213
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46156
Diffstat (limited to 'include')
-rw-r--r-- | include/keyboard_raw.h | 74 | ||||
-rw-r--r-- | include/keyboard_scan.h | 12 |
2 files changed, 74 insertions, 12 deletions
diff --git a/include/keyboard_raw.h b/include/keyboard_raw.h new file mode 100644 index 0000000000..6432335a52 --- /dev/null +++ b/include/keyboard_raw.h @@ -0,0 +1,74 @@ +/* Copyright (c) 2013 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. + * + * Raw access to keyboard GPIOs. + * + * The keyboard matrix is read by driving output signals on the column lines + * and reading the row lines. + */ + +#ifndef __CROS_EC_KEYBOARD_RAW_H +#define __CROS_EC_KEYBOARD_RAW_H + +#include "common.h" +#include "gpio.h" + +/* used for select_column() */ +enum keyboard_column_index { + KEYBOARD_COLUMN_ALL = -2, /* Drive all columns */ + KEYBOARD_COLUMN_NONE = -1, /* Drive no columns (tri-state all) */ + /* 0 ~ 12 for the corresponding column */ +}; + +/** + * Initialize the raw keyboard interface. + * + * Must be called before any other functions in this interface. + */ +void keyboard_raw_init(void); + +/** + * Finish intitialization after task scheduling has started. + * + * Call from the keyboard scan task. + */ +void keyboard_raw_task_start(void); + +/** + * Drive the specified column low. + * + * Other columns are tristated. See enum keyboard_column_index for special + * values for <col>. + */ +void keyboard_raw_drive_column(int col); + +/** + * Read raw row state. + * + * Bits are 1 if signal is present, 0 if not present. + */ +int keyboard_raw_read_rows(void); + +/** + * Enable or disable keyboard interrupts. + * + * Enabling interrupts will clear any pending interrupt bits. To avoid missing + * any interrupts that occur between the end of scanning and then, you should + * call keyboard_raw_read_rows() after this. If it returns non-zero, disable + * interrupts and go back to polling mode instead of waiting for an interrupt. + */ +void keyboard_raw_enable_interrupt(int enable); + +#ifdef CONFIG_TASK_KEYSCAN + +/** + * GPIO interrupt for raw keyboard input + */ +void keyboard_raw_gpio_interrupt(enum gpio_signal signal); + +#else +#define keyboard_raw_gpio_interrupt NULL +#endif + +#endif /* __CROS_EC_KEYBOARD_RAW_H */ diff --git a/include/keyboard_scan.h b/include/keyboard_scan.h index 54e7259c21..e0f883375a 100644 --- a/include/keyboard_scan.h +++ b/include/keyboard_scan.h @@ -9,7 +9,6 @@ #define __CROS_EC_KEYBOARD_SCAN_H #include "common.h" -#include "gpio.h" /** * Initializes the module. @@ -52,15 +51,4 @@ void keyboard_enable_scanning(int enable); */ void keyboard_send_battery_key(void); -#ifdef CONFIG_TASK_KEYSCAN - -/** - * Keyboard scan GPIO interrupt. - */ -void keyboard_scan_interrupt(enum gpio_signal signal); - -#else -#define keyboard_scan_interrupt NULL -#endif - #endif /* __CROS_EC_KEYBOARD_SCAN_H */ |