summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-06-06 12:29:43 -0700
committerGerrit <chrome-bot@google.com>2012-06-07 09:59:54 -0700
commitc736b2874c5144c752491c5bfe7025a91034767a (patch)
tree2d9a97cc0b230a5a4dad087a32230f04cc51ebf9
parent12eecc012ba5c0c37beafa03fe70f97fedf3e726 (diff)
downloadchrome-ec-c736b2874c5144c752491c5bfe7025a91034767a.tar.gz
Switch keyboard outputs to open-drain
BUG=chrome-os-partner:10209 TEST=boot system and type on console; should still work Change-Id: I9f89420acd59947baee445fc2a655857809f8fb9 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/24636
-rw-r--r--chip/lm4/keyboard_scan.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/chip/lm4/keyboard_scan.c b/chip/lm4/keyboard_scan.c
index ae7223f69f..0d2909e53a 100644
--- a/chip/lm4/keyboard_scan.c
+++ b/chip/lm4/keyboard_scan.c
@@ -87,25 +87,20 @@ static void select_column(int col)
{
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;
+ LM4_GPIO_DATA(LM4_GPIO_P, 0xff) = 0xff;
+ LM4_GPIO_DATA(LM4_GPIO_Q, 0x1f) = 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;
- if (col < 8) {
- LM4_GPIO_DIR(LM4_GPIO_P) |= 1 << col;
+ LM4_GPIO_DATA(LM4_GPIO_P, 0xff) = 0xff;
+ LM4_GPIO_DATA(LM4_GPIO_Q, 0x1f) = 0x1f;
+ if (col < 8)
LM4_GPIO_DATA(LM4_GPIO_P, 1 << col) = 0;
- } else {
- LM4_GPIO_DIR(LM4_GPIO_Q) |= 1 << (col - 8);
+ else
LM4_GPIO_DATA(LM4_GPIO_Q, 1 << (col - 8)) = 0;
- }
}
}
@@ -278,19 +273,16 @@ static int check_boot_key(int index, int mask)
int keyboard_scan_init(void)
{
- volatile uint32_t scratch __attribute__((unused));
-
- /* Enable clock to GPIO modules N,P,Q */
- /* TODO: gpio_pre_init() enables all the GPIO modules, so can remove
- * this entirely. */
- LM4_SYSTEM_RCGCGPIO |= 0x7000;
- scratch = LM4_SYSTEM_RCGCGPIO;
-
- /* Clear GPIOAFSEL and enable digital function for rows */
+ /* Set column outputs as open-drain; we either pull them low or let
+ * them float high. */
LM4_GPIO_AFSEL(LM4_GPIO_P) = 0; /* KSO[7:0] */
- LM4_GPIO_DEN(LM4_GPIO_P) = 0xff;
LM4_GPIO_AFSEL(LM4_GPIO_Q) &= ~0x1f; /* KSO[12:8] */
+ LM4_GPIO_DEN(LM4_GPIO_P) = 0xff;
LM4_GPIO_DEN(LM4_GPIO_Q) |= 0x1f;
+ LM4_GPIO_DIR(LM4_GPIO_P) = 0xff;
+ LM4_GPIO_DIR(LM4_GPIO_Q) |= 0x1f;
+ LM4_GPIO_ODR(LM4_GPIO_P) = 0xff;
+ LM4_GPIO_ODR(LM4_GPIO_Q) |= 0x1f;
/* Set row inputs with pull-up */
LM4_GPIO_AFSEL(KB_SCAN_ROW_GPIO) &= 0xff;