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 | |
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')
-rw-r--r-- | board/npcx_evb/gpio.inc | 12 | ||||
-rw-r--r-- | board/npcx_evb_arm/gpio.inc | 12 | ||||
-rw-r--r-- | board/wheatley/board.c | 11 | ||||
-rw-r--r-- | board/wheatley/gpio.inc | 8 |
4 files changed, 37 insertions, 6 deletions
diff --git a/board/npcx_evb/gpio.inc b/board/npcx_evb/gpio.inc index ee6013e2bd..03e3fcc071 100644 --- a/board/npcx_evb/gpio.inc +++ b/board/npcx_evb/gpio.inc @@ -45,9 +45,6 @@ GPIO(I2C3_SDA, PIN(D, 0), GPIO_ODR_HIGH) GPIO(BOARD_VERSION1, PIN(6, 4), GPIO_INPUT) /* Board version stuffing resistor 1 */ GPIO(BOARD_VERSION2, PIN(6, 5), GPIO_INPUT) /* Board version stuffing resistor 2 */ GPIO(BOARD_VERSION3, PIN(6, 6), GPIO_INPUT) /* Board version stuffing resistor 3 */ -#ifdef CONFIG_KEYBOARD_COL2_INVERTED -GPIO(KBD_KSO2, PIN(1, 7), GPIO_OUT_LOW) /* Negative edge triggered keyboard irq. */ -#endif /**************************** Alternate pins for UART/I2C/ADC/SPI/PWM/MFT ****************************/ /* Alternate pins for UART/I2C/ADC/SPI/PWM/MFT */ @@ -74,3 +71,12 @@ ALTERNATE(PIN_MASK(9, 0x08), 3, MODULE_PWM, 0) /* MFT-1/TA1_TACH1 fo ALTERNATE(PIN_MASK(4, 0x01), 3, MODULE_PWM, 0) /* MFT-1/TA1_TACH1 for FAN Test GPIO40 */ #endif #endif + +/* 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) diff --git a/board/npcx_evb_arm/gpio.inc b/board/npcx_evb_arm/gpio.inc index dd169a1806..c4aeed25ae 100644 --- a/board/npcx_evb_arm/gpio.inc +++ b/board/npcx_evb_arm/gpio.inc @@ -46,9 +46,6 @@ GPIO(I2C3_SDA, PIN(D, 0), GPIO_ODR_HIGH) GPIO(BOARD_VERSION1, PIN(6, 4), GPIO_INPUT) /* Board version stuffing resistor 1 */ GPIO(BOARD_VERSION2, PIN(6, 5), GPIO_INPUT) /* Board version stuffing resistor 2 */ GPIO(BOARD_VERSION3, PIN(6, 6), GPIO_INPUT) /* Board version stuffing resistor 3 */ -#ifdef CONFIG_KEYBOARD_COL2_INVERTED -GPIO(KBD_KSO2, PIN(1, 7), GPIO_OUT_LOW) /* Negative edge triggered keyboard irq. */ -#endif /**************************** Alternate pins for UART/I2C/ADC/SPI/PWM/MFT ****************************/ /* Alternate pins for UART/I2C/ADC/SPI/PWM/MFT */ @@ -75,3 +72,12 @@ ALTERNATE(PIN_MASK(9, 0x08), 3, MODULE_PWM, 0) /* MFT-1/TA1_TACH1 fo ALTERNATE(PIN_MASK(4, 0x01), 3, MODULE_PWM, 0) /* MFT-1/TA1_TACH1 for FAN Test GPIO40 */ #endif #endif + +/* 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) 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) |