summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerrit <chrome-bot@google.com>2012-05-25 02:41:26 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2012-05-25 02:41:26 -0700
commit61902efd16095af85764bd4b2df51415df49ea55 (patch)
tree4605e4899a9935a7a59f17ae8aa368da9d8b392d
parent09f23c8aa86ba5271952bb2d0da802c93131f089 (diff)
parentb62a71a7eb9e1d7e6099ce183aa937de7939f480 (diff)
downloadchrome-ec-61902efd16095af85764bd4b2df51415df49ea55.tar.gz
Merge "Fix disabling columns when power button is pressed"
-rw-r--r--chip/lm4/keyboard_scan.c54
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;