summaryrefslogtreecommitdiff
path: root/test/kb_8042.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-09-29 00:55:36 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-01 08:16:34 +0000
commitc77575ac0daa5966772779cedbaab6f607cf9a98 (patch)
treef1e7cf3ca7f232e4be95b7bd57e652253eddaacc /test/kb_8042.c
parent2d856c51039153effe4b9e9d7924c841fb741da5 (diff)
downloadchrome-ec-c77575ac0daa5966772779cedbaab6f607cf9a98.tar.gz
Emulator support of fake GPIO input
For all GPIOs, the current values are recorded. A test can then change the value of a GPIO input by gpio_set_level(). The changed value is recorded and also interrupt is fired if the change fits the interrupt flags defined in board/host/board.c. BUG=chrome-os-partner:19235 TEST=Pass all tests BRANCH=None Change-Id: If8e547e5adf4a20dcb118f5fe2187293005d4ca3 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170907 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'test/kb_8042.c')
-rw-r--r--test/kb_8042.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/test/kb_8042.c b/test/kb_8042.c
index 0bac5fedcf..88bae5d633 100644
--- a/test/kb_8042.c
+++ b/test/kb_8042.c
@@ -29,8 +29,6 @@ static unsigned int lpc_char_cnt;
/*****************************************************************************/
/* Mock functions */
-static int mock_power_button = 1;
-
int lid_is_open(void)
{
return 1;
@@ -41,13 +39,6 @@ void lpc_keyboard_put_char(uint8_t chr, int send_irq)
lpc_char_buf[lpc_char_cnt++] = chr;
}
-int gpio_get_level(enum gpio_signal signal)
-{
- if (signal == GPIO_POWER_BUTTON_L)
- return mock_power_button;
- return 0;
-}
-
/*****************************************************************************/
/* Test utilities */
@@ -209,33 +200,27 @@ static int test_power_button(void)
set_scancode(1);
test_chipset_on();
- mock_power_button = 0;
- power_button_interrupt(GPIO_POWER_BUTTON_L);
+ gpio_set_level(GPIO_POWER_BUTTON_L, 0);
VERIFY_LPC_CHAR_DELAY("\xe0\x5e", 100);
- mock_power_button = 1;
- power_button_interrupt(GPIO_POWER_BUTTON_L);
+ gpio_set_level(GPIO_POWER_BUTTON_L, 1);
VERIFY_LPC_CHAR_DELAY("\xe0\xde", 100);
set_scancode(2);
write_cmd_byte(read_cmd_byte() & ~I8042_XLATE);
- mock_power_button = 0;
- power_button_interrupt(GPIO_POWER_BUTTON_L);
+ gpio_set_level(GPIO_POWER_BUTTON_L, 0);
VERIFY_LPC_CHAR_DELAY("\xe0\x37", 100);
- mock_power_button = 1;
- power_button_interrupt(GPIO_POWER_BUTTON_L);
+ gpio_set_level(GPIO_POWER_BUTTON_L, 1);
VERIFY_LPC_CHAR_DELAY("\xe0\xf0\x37", 100);
test_chipset_off();
- mock_power_button = 0;
- power_button_interrupt(GPIO_POWER_BUTTON_L);
+ gpio_set_level(GPIO_POWER_BUTTON_L, 0);
VERIFY_NO_CHAR();
- mock_power_button = 1;
- power_button_interrupt(GPIO_POWER_BUTTON_L);
+ gpio_set_level(GPIO_POWER_BUTTON_L, 1);
VERIFY_NO_CHAR();
return EC_SUCCESS;