input: Flush the keyboard buffer before resetting it
If U-Boot is not the first-stage bootloader the keyboard may already be set up. Make sure to flush any data before trying to reset it. This avoids a long timeout / hang. Add some comments and a log category while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
7a187a89fd
commit
d8062e9503
1 changed files with 19 additions and 0 deletions
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
/* i8042.c - Intel 8042 keyboard driver routines */
|
/* i8042.c - Intel 8042 keyboard driver routines */
|
||||||
|
|
||||||
|
#define LOG_CATEGORY UCLASS_KEYBOARD
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
|
@ -54,6 +56,14 @@ static unsigned char ext_key_map[] = {
|
||||||
0x00 /* map end */
|
0x00 /* map end */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kbd_input_empty() - Wait until the keyboard is ready for a command
|
||||||
|
*
|
||||||
|
* Checks the IBF flag (input buffer full), waiting for it to indicate that
|
||||||
|
* any previous command has been processed.
|
||||||
|
*
|
||||||
|
* Return: true if ready, false if it timed out
|
||||||
|
*/
|
||||||
static int kbd_input_empty(void)
|
static int kbd_input_empty(void)
|
||||||
{
|
{
|
||||||
int kbd_timeout = KBD_TIMEOUT * 1000;
|
int kbd_timeout = KBD_TIMEOUT * 1000;
|
||||||
|
@ -64,6 +74,12 @@ static int kbd_input_empty(void)
|
||||||
return kbd_timeout != -1;
|
return kbd_timeout != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kbd_output_full() - Wait until the keyboard has data available
|
||||||
|
*
|
||||||
|
* Checks the OBF flag (output buffer full), waiting for it to indicate that
|
||||||
|
* a response to a previous command is available
|
||||||
|
*/
|
||||||
static int kbd_output_full(void)
|
static int kbd_output_full(void)
|
||||||
{
|
{
|
||||||
int kbd_timeout = KBD_TIMEOUT * 1000;
|
int kbd_timeout = KBD_TIMEOUT * 1000;
|
||||||
|
@ -127,6 +143,9 @@ static int kbd_reset(int quirk)
|
||||||
{
|
{
|
||||||
int config;
|
int config;
|
||||||
|
|
||||||
|
if (!kbd_input_empty())
|
||||||
|
goto err;
|
||||||
|
|
||||||
/* controller self test */
|
/* controller self test */
|
||||||
if (kbd_cmd_read(CMD_SELF_TEST) != KBC_TEST_OK)
|
if (kbd_cmd_read(CMD_SELF_TEST) != KBC_TEST_OK)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Reference in a new issue