diff --git a/board/rambi/board.h b/board/rambi/board.h index 2fdb718013..deb00abc15 100644 --- a/board/rambi/board.h +++ b/board/rambi/board.h @@ -13,6 +13,7 @@ #define CONFIG_BOARD_VERSION #define CONFIG_CMD_GSV #define CONFIG_EXTPOWER_GPIO +#define CONFIG_KEYBOARD_COL2_INVERTED #define CONFIG_KEYBOARD_PROTOCOL_8042 #define CONFIG_LED_COMMON #undef CONFIG_PECI diff --git a/chip/lm4/keyboard_raw.c b/chip/lm4/keyboard_raw.c index 2104bd08a9..2a158769a4 100644 --- a/chip/lm4/keyboard_raw.c +++ b/chip/lm4/keyboard_raw.c @@ -53,23 +53,22 @@ void keyboard_raw_task_start(void) test_mockable void keyboard_raw_drive_column(int col) { - if (col == KEYBOARD_COLUMN_NONE) { - /* Tri-state all outputs */ - LM4_GPIO_DATA(LM4_GPIO_P, 0xff) = 0xff; - LM4_GPIO_DATA(LM4_GPIO_Q, 0x1f) = 0x1f; - } else if (col == KEYBOARD_COLUMN_ALL) { - /* Assert all outputs */ - LM4_GPIO_DATA(LM4_GPIO_P, 0xff) = 0; - LM4_GPIO_DATA(LM4_GPIO_Q, 0x1f) = 0; - } else { - /* Assert a single output */ - 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_DATA(LM4_GPIO_Q, 1 << (col - 8)) = 0; - } + int mask; + + if (col == KEYBOARD_COLUMN_NONE) + mask = 0x1fff; /* Tri-state all outputs */ + else if (col == KEYBOARD_COLUMN_ALL) + mask = 0; /* Assert all outputs */ + else + mask = 0x1fff ^ (1 << col); /* Assert a single output */ + +#ifdef CONFIG_KEYBOARD_COL2_INVERTED + /* Invert column 2 output */ + mask ^= (1 << 2); +#endif + + LM4_GPIO_DATA(LM4_GPIO_P, 0xff) = mask & 0xff; + LM4_GPIO_DATA(LM4_GPIO_Q, 0x1f) = (mask >> 8) & 0x1f; } test_mockable int keyboard_raw_read_rows(void) diff --git a/include/config.h b/include/config.h index 09478a1557..21821100a7 100644 --- a/include/config.h +++ b/include/config.h @@ -426,6 +426,14 @@ /*****************************************************************************/ /* Keyboard config */ +/* + * The Silego reset chip sits in between the EC and the physical keyboard on + * column 2. To save power in low-power modes, some Silego variants require + * the signal to be inverted so that the open-drain output from the EC isn't + * costing power due to the pull-up resistor in the Silego. + */ +#undef CONFIG_KEYBOARD_COL2_INVERTED + /* Enable extra debugging output from keyboard modules */ #undef CONFIG_KEYBOARD_DEBUG