diff options
author | Anton Staaf <robotboy@chromium.org> | 2016-02-29 13:56:31 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-03-02 11:22:51 -0800 |
commit | e3d6310cc97f71683b4b192045d6a3521369ad2b (patch) | |
tree | 33ebd943970a432fbecadbad3cff37bb6cb17d89 /board/wheatley | |
parent | c86c7799dd89af5d8d0303d38c264e6bcc0271e5 (diff) | |
download | chrome-ec-e3d6310cc97f71683b4b192045d6a3521369ad2b.tar.gz |
NPCX: Convert keyboard pins to use ALTERNATE macro
Previously the keyboard row and column pins could not use the GPIO
alternate function mechanism because their DEVALT bits were inverted
with respect to all of the others, making it impossible to correctly
configure them. With the refactor of the GPIO driver we can now add
the keyboard DEVALT entries to the gpio_alt_table, and use the
ALTERNATE macro and associated APIs to control the keyboard pin states.
The Wheatley RO firmware image is still 320 bytes smaller than before
the GPIO refactor.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Ran on Wheatley, manually verified keyboard functionality
Change-Id: Id04bc010834b5d95050b03ace6b0e1c5690757bf
Reviewed-on: https://chromium-review.googlesource.com/329762
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'board/wheatley')
-rw-r--r-- | board/wheatley/board.c | 11 | ||||
-rw-r--r-- | board/wheatley/gpio.inc | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/board/wheatley/board.c b/board/wheatley/board.c index c556741dd9..537214b0d7 100644 --- a/board/wheatley/board.c +++ b/board/wheatley/board.c @@ -406,6 +406,17 @@ void board_set_gpio_hibernate_state(void) /* Change GPIOs' state in hibernate for better power consumption */ for (i = 0; i < ARRAY_SIZE(hibernate_pins); ++i) gpio_set_flags(hibernate_pins[i][0], hibernate_pins[i][1]); + + gpio_config_module(MODULE_KEYBOARD_SCAN, 0); + + /* + * Calling gpio_config_module sets disabled alternate function pins to + * GPIO_INPUT. But to prevent keypresses causing leakage currents + * while hibernating we want to enable GPIO_PULL_UP as well. + */ + gpio_set_flags_by_mask(0x2, 0x03, GPIO_INPUT | GPIO_PULL_UP); + gpio_set_flags_by_mask(0x1, 0xFF, GPIO_INPUT | GPIO_PULL_UP); + gpio_set_flags_by_mask(0x0, 0xE0, GPIO_INPUT | GPIO_PULL_UP); } /* Any wheatley boards post version 2 should have ROP_LDO_EN stuffed. */ diff --git a/board/wheatley/gpio.inc b/board/wheatley/gpio.inc index c3b9db8cff..8d16b9d817 100644 --- a/board/wheatley/gpio.inc +++ b/board/wheatley/gpio.inc @@ -149,3 +149,11 @@ ALTERNATE(PIN_MASK(4, 0x16), 1, MODULE_ADC, 0) /* ADC1/ADC3/ADC4 for AD ALTERNATE(PIN_MASK(B, 0x80), 3, MODULE_POWER_LED, 0) /* PWM5 for CHARGE_LED1 */ ALTERNATE(PIN_MASK(C, 0x01), 3, MODULE_POWER_LED, 0) /* PWM6 for CHARGE_LED2 */ +/* Keyboard Columns */ +ALTERNATE(PIN_MASK(0, 0xE0), 0, MODULE_KEYBOARD_SCAN, 0) +ALTERNATE(PIN_MASK(1, 0xFF), 0, MODULE_KEYBOARD_SCAN, 0) +ALTERNATE(PIN_MASK(2, 0x03), 0, MODULE_KEYBOARD_SCAN, 0) + +/* Keyboard Rows */ +ALTERNATE(PIN_MASK(2, 0xFC), 0, MODULE_KEYBOARD_SCAN, 0) +ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KEYBOARD_SCAN, 0) |