diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-05-24 16:08:49 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-05-24 16:42:34 -0700 |
commit | b62a71a7eb9e1d7e6099ce183aa937de7939f480 (patch) | |
tree | 1c2be38c8e0479fb3973a6903e787fa67bf77463 /chip | |
parent | b0fe45560828542ec3dd129db7d9cf59e92349d4 (diff) | |
download | chrome-ec-b62a71a7eb9e1d7e6099ce183aa937de7939f480.tar.gz |
Fix disabling columns when power button is pressed
This works around a problem where columns are not tri-stated when
calling select_column(COLUMN_ASSERT_ALL) with enable_scanning=0.
Also removes polling for power button released; we can use the same
task wait for that as we do for a keypress.
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=chrome-os-partner:7486
TEST=manual
1) press g then press power button repeatedly. EC is not rebooted.
2) press power button the g repeatedly. EC is not rebooted.
3) press power+refresh (or ESC on proto1). EC is rebooted.
Change-Id: I43a0beae1a6c0ef8fa9379a8fff47b6006e63c8c
Diffstat (limited to 'chip')
-rw-r--r-- | chip/lm4/keyboard_scan.c | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/chip/lm4/keyboard_scan.c b/chip/lm4/keyboard_scan.c index 2faa2a88f6..86516b4c59 100644 --- a/chip/lm4/keyboard_scan.c +++ b/chip/lm4/keyboard_scan.c @@ -35,18 +35,6 @@ * * Other: * PWR_BTN# = PK7 (handled by gpio module) - * - * - * BDS board: - * - * Columns (outputs): - * KSO0 - KSO7 = PQ0:7 - * KSO8 - KSO11 = PK0:3 - * KSO12 = PN2 - * Rows (inputs): - * KSI0 - KSI7 = PH0:7 - * Other: - * PWR_BTN# = PC5 (handled by gpio module) */ @@ -93,27 +81,28 @@ static const uint8_t actual_key_masks[4][KB_COLS] = { #define MASK_INDEX_F 3 #define MASK_VALUE_F 0x10 -/* Drives the specified column low; other columns are tri-stated */ + +/* Drive the specified column low; other columns are tri-stated */ static void select_column(int col) { - if (col == COLUMN_ASSERT_ALL) { - if (!enable_scanning) - return; + if (col == COLUMN_TRI_STATE_ALL || !enable_scanning) { + /* Tri-state all outputs */ + LM4_GPIO_DIR(LM4_GPIO_P) = 0; + LM4_GPIO_DIR(LM4_GPIO_Q) &= ~0x1f; + } else if (col == COLUMN_ASSERT_ALL) { + /* Assert all outputs */ LM4_GPIO_DIR(LM4_GPIO_P) = 0xff; LM4_GPIO_DIR(LM4_GPIO_Q) |= 0x1f; LM4_GPIO_DATA(LM4_GPIO_P, 0xff) = 0; LM4_GPIO_DATA(LM4_GPIO_Q, 0x1f) = 0; } else { + /* Assert a single output */ LM4_GPIO_DIR(LM4_GPIO_P) = 0; LM4_GPIO_DIR(LM4_GPIO_Q) &= ~0x1f; - /* Return after the above TRI_STATE_ALL has be run. */ - if (!enable_scanning) - return; - - if (col >= 0 && col < 8) { + if (col < 8) { LM4_GPIO_DIR(LM4_GPIO_P) |= 1 << col; LM4_GPIO_DATA(LM4_GPIO_P, 1 << col) = 0; - } else if (col != COLUMN_TRI_STATE_ALL) { + } else { LM4_GPIO_DIR(LM4_GPIO_Q) |= 1 << (col - 8); LM4_GPIO_DATA(LM4_GPIO_Q, 1 << (col - 8)) = 0; } @@ -371,8 +360,13 @@ void keyboard_scan_task(void) enable_scanning = 1; while (1) { + /* Enable all outputs */ wait_for_interrupt(); - task_wait_event(-1); + + /* Wait for scanning enabled and key pressed. */ + do { + task_wait_event(-1); + } while (!enable_scanning); enter_polling_mode(); /* Busy polling keyboard state. */ @@ -390,10 +384,6 @@ void keyboard_scan_task(void) } } } - /* Don't continue if the power button is not released yet. */ - while (!enable_scanning) { - usleep(SCAN_LOOP_DELAY); - } } } @@ -427,6 +417,7 @@ void keyboard_put_char(uint8_t chr, int send_irq) #endif } + void keyboard_clear_buffer(void) { #if defined(HOST_KB_BUS_LPC) @@ -436,6 +427,7 @@ void keyboard_clear_buffer(void) #endif } + void keyboard_resume_interrupt(void) { #if defined(HOST_KB_BUS_LPC) @@ -445,16 +437,16 @@ void keyboard_resume_interrupt(void) #endif } -/* We don't support this API yet, just return -1 */ + int keyboard_get_scan(uint8_t **buffp, int max_bytes) { + /* We don't support this API yet; just return -1. */ return -1; } -/* The actuall implementation is controlling the enable_scanning variable, - * then that controls whether select_column() can pull-down columns or not. - */ +/* The actual implementation is controlling the enable_scanning variable, then + * that controls whether select_column() can pull-down columns or not. */ void keyboard_enable_scanning(int enable) { enable_scanning = enable; |