aboutsummaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2015-08-24 01:00:05 -0700
committerSimon Glass <sjg@chromium.org>2015-08-26 07:54:16 -0700
commit835dd000503591d8eb59a191f7220768898737b3 (patch)
tree57f554d9a4098ffae048b1cf022e9257982307cf /drivers/input
parent3928d66a5e7f55a860f2dd150231f51c8cc9d5fc (diff)
downloadu-boot-835dd000503591d8eb59a191f7220768898737b3.zip
u-boot-835dd000503591d8eb59a191f7220768898737b3.tar.gz
u-boot-835dd000503591d8eb59a191f7220768898737b3.tar.bz2
x86: i8042: Clean up the driver per coding convention
- Rename CamelCase variables to conform U-Boot coding convention - Rename wait_until_kbd_output_full() to kbd_output_full() - Change to use macros for i8042 command and control register bits Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/i8042.c230
1 files changed, 118 insertions, 112 deletions
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 126b222..e8f59df 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -10,27 +10,30 @@
/* includes */
#include <common.h>
+#include <asm/io.h>
#include <i8042.h>
/* defines */
+#define in8(p) inb(p)
+#define out8(p, v) outb(v, p)
#ifdef CONFIG_CONSOLE_CURSOR
extern void console_cursor(int state);
-static int blinkCount = CONFIG_SYS_CONSOLE_BLINK_COUNT;
+static int blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
static int cursor_state;
#endif
/* locals */
-static int kbd_input = -1; /* no input yet */
-static int kbd_mapping = KBD_US; /* default US keyboard */
-static int kbd_flags = NORMAL; /* after reset */
-static int kbd_state; /* unshift code */
+static int kbd_input = -1; /* no input yet */
+static int kbd_mapping = KBD_US; /* default US keyboard */
+static int kbd_flags = NORMAL; /* after reset */
+static int kbd_state; /* unshift code */
static unsigned char kbd_fct_map[144] = {
/* kbd_fct_map table for scan code */
- 0, AS, AS, AS, AS, AS, AS, AS, /* scan 0- 7 */
- AS, AS, AS, AS, AS, AS, AS, AS, /* scan 8- F */
+ 0, AS, AS, AS, AS, AS, AS, AS, /* scan 00-07 */
+ AS, AS, AS, AS, AS, AS, AS, AS, /* scan 08-0F */
AS, AS, AS, AS, AS, AS, AS, AS, /* scan 10-17 */
AS, AS, AS, AS, AS, CN, AS, AS, /* scan 18-1F */
AS, AS, AS, AS, AS, AS, AS, AS, /* scan 20-27 */
@@ -52,8 +55,8 @@ static unsigned char kbd_fct_map[144] = {
static unsigned char kbd_key_map[2][5][144] = {
{ /* US keyboard */
{ /* unshift code */
- 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 0- 7 */
- '7', '8', '9', '0', '-', '=', 0x08, '\t', /* scan 8- F */
+ 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 00-07 */
+ '7', '8', '9', '0', '-', '=', 0x08, '\t', /* scan 08-0F */
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', /* scan 10-17 */
'o', 'p', '[', ']', '\r', CN, 'a', 's', /* scan 18-1F */
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* scan 20-27 */
@@ -72,8 +75,8 @@ static unsigned char kbd_key_map[2][5][144] = {
0, 'D', 'C', 0, 'B', 0, '@', 'P' /* extended */
},
{ /* shift code */
- 0, 0x1b, '!', '@', '#', '$', '%', '^', /* scan 0- 7 */
- '&', '*', '(', ')', '_', '+', 0x08, '\t', /* scan 8- F */
+ 0, 0x1b, '!', '@', '#', '$', '%', '^', /* scan 00-07 */
+ '&', '*', '(', ')', '_', '+', 0x08, '\t', /* scan 08-0F */
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', /* scan 10-17 */
'O', 'P', '{', '}', '\r', CN, 'A', 'S', /* scan 18-1F */
'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', /* scan 20-27 */
@@ -92,8 +95,8 @@ static unsigned char kbd_key_map[2][5][144] = {
0, 'D', 'C', 0, 'B', 0, '@', 'P' /* extended */
},
{ /* control code */
- 0xff, 0x1b, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, /* scan 0- 7 */
- 0x1e, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, '\t', /* scan 8- F */
+ 0xff, 0x1b, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
+ 0x1e, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, '\t', /* scan 08-0F */
0x11, 0x17, 0x05, 0x12, 0x14, 0x19, 0x15, 0x09, /* scan 10-17 */
0x0f, 0x10, 0x1b, 0x1d, '\r', CN, 0x01, 0x13, /* scan 18-1F */
0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0c, 0xff, /* scan 20-27 */
@@ -112,8 +115,8 @@ static unsigned char kbd_key_map[2][5][144] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff /* extended */
},
{ /* non numeric code */
- 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 0- 7 */
- '7', '8', '9', '0', '-', '=', 0x08, '\t', /* scan 8- F */
+ 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 00-07 */
+ '7', '8', '9', '0', '-', '=', 0x08, '\t', /* scan 08-0F */
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', /* scan 10-17 */
'o', 'p', '[', ']', '\r', CN, 'a', 's', /* scan 18-1F */
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* scan 20-27 */
@@ -132,30 +135,30 @@ static unsigned char kbd_key_map[2][5][144] = {
0, 'D', 'C', 0, 'B', 0, '@', 'P' /* extended */
},
{ /* right alt mode - not used in US keyboard */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 0 - 7 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 8 - F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10 -17 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 18 -1F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20 -27 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28 -2F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30 -37 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38 -3F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40 -47 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48 -4F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 50 -57 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58 -5F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60 -67 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68 -6F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70 -77 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78 -7F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 08-0F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 50-57 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* extended */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff /* extended */
}
},
- { /* german keyboard */
+ { /* German keyboard */
{ /* unshift code */
- 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 0- 7 */
- '7', '8', '9', '0', 0xe1, '\'', 0x08, '\t', /* scan 8- F */
+ 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 00-07 */
+ '7', '8', '9', '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', /* scan 10-17 */
'o', 'p', 0x81, '+', '\r', CN, 'a', 's', /* scan 18-1F */
'd', 'f', 'g', 'h', 'j', 'k', 'l', 0x94, /* scan 20-27 */
@@ -174,8 +177,8 @@ static unsigned char kbd_key_map[2][5][144] = {
0, 'D', 'C', 0, 'B', 0, '@', 'P' /* extended */
},
{ /* shift code */
- 0, 0x1b, '!', '"', 0x15, '$', '%', '&', /* scan 0- 7 */
- '/', '(', ')', '=', '?', '`', 0x08, '\t', /* scan 8- F */
+ 0, 0x1b, '!', '"', 0x15, '$', '%', '&', /* scan 00-07 */
+ '/', '(', ')', '=', '?', '`', 0x08, '\t', /* scan 08-0F */
'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', /* scan 10-17 */
'O', 'P', 0x9a, '*', '\r', CN, 'A', 'S', /* scan 18-1F */
'D', 'F', 'G', 'H', 'J', 'K', 'L', 0x99, /* scan 20-27 */
@@ -194,8 +197,8 @@ static unsigned char kbd_key_map[2][5][144] = {
0, 'D', 'C', 0, 'B', 0, '@', 'P' /* extended */
},
{ /* control code */
- 0xff, 0x1b, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, /* scan 0- 7 */
- 0x1e, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, '\t', /* scan 8- F */
+ 0xff, 0x1b, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
+ 0x1e, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, '\t', /* scan 08-0F */
0x11, 0x17, 0x05, 0x12, 0x14, 0x19, 0x15, 0x09, /* scan 10-17 */
0x0f, 0x10, 0x1b, 0x1d, '\r', CN, 0x01, 0x13, /* scan 18-1F */
0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0c, 0xff, /* scan 20-27 */
@@ -214,8 +217,8 @@ static unsigned char kbd_key_map[2][5][144] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff /* extended */
},
{ /* non numeric code */
- 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 0- 7 */
- '7', '8', '9', '0', 0xe1, '\'', 0x08, '\t', /* scan 8- F */
+ 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 00-07 */
+ '7', '8', '9', '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', /* scan 10-17 */
'o', 'p', 0x81, '+', '\r', CN, 'a', 's', /* scan 18-1F */
'd', 'f', 'g', 'h', 'j', 'k', 'l', 0x94, /* scan 20-27 */
@@ -233,23 +236,23 @@ static unsigned char kbd_key_map[2][5][144] = {
'\r', CN, '/', '*', ' ', ST, 'F', 'A', /* extended */
0, 'D', 'C', 0, 'B', 0, '@', 'P' /* extended */
},
- { /* Right alt mode - is used in German keyboard */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 0 - 7 */
- '{', '[', ']', '}', '\\', 0xff, 0xff, 0xff, /* scan 8 - F */
- '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10 -17 */
- 0xff, 0xff, 0xff, '~', 0xff, 0xff, 0xff, 0xff, /* scan 18 -1F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20 -27 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28 -2F */
- 0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30 -37 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38 -3F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40 -47 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48 -4F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, '|', 0xff, /* scan 50 -57 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58 -5F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60 -67 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68 -6F */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70 -77 */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78 -7F */
+ { /* right alt mode - is used in German keyboard */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
+ '{', '[', ']', '}', '\\', 0xff, 0xff, 0xff, /* scan 08-0F */
+ '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
+ 0xff, 0xff, 0xff, '~', 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
+ 0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, '|', 0xff, /* scan 50-57 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* extended */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff /* extended */
}
@@ -278,30 +281,30 @@ static unsigned char ext_key_map[] = {
static int kbd_input_empty(void)
{
- int kbdTimeout = KBD_TIMEOUT * 1000;
+ int kbd_timeout = KBD_TIMEOUT * 1000;
- while ((in8(I8042_STATUS_REG) & I8042_STATUS_IN_DATA) && kbdTimeout--)
+ while ((in8(I8042_STS_REG) & STATUS_IBF) && kbd_timeout--)
udelay(1);
- return kbdTimeout != -1;
+ return kbd_timeout != -1;
}
-static int wait_until_kbd_output_full(void)
+static int kbd_output_full(void)
{
- int kbdTimeout = KBD_TIMEOUT * 1000;
+ int kbd_timeout = KBD_TIMEOUT * 1000;
- while (((in8(I8042_STATUS_REG) & 0x01) == 0) && kbdTimeout--)
+ while (((in8(I8042_STS_REG) & STATUS_OBF) == 0) && kbd_timeout--)
udelay(1);
- return kbdTimeout != -1;
+ return kbd_timeout != -1;
}
static void kbd_led_set(void)
{
kbd_input_empty();
- out8(I8042_DATA_REG, 0xed); /* SET LED command */
+ out8(I8042_DATA_REG, CMD_SET_KBD_LED);
kbd_input_empty();
- out8(I8042_DATA_REG, (kbd_flags & 0x7)); /* LED bits only */
+ out8(I8042_DATA_REG, (kbd_flags & 0x7));
}
static void kbd_normal(unsigned char scan_code)
@@ -315,7 +318,7 @@ static void kbd_normal(unsigned char scan_code)
/* if caps lock convert upper to lower */
if (((kbd_flags & CAPS) == CAPS) &&
- (chr >= 'a' && chr <= 'z')) {
+ (chr >= 'a' && chr <= 'z')) {
chr -= 'a' - 'A';
}
kbd_input = chr;
@@ -349,7 +352,7 @@ static void kbd_num(unsigned char scan_code)
if ((kbd_flags & BRK) == NORMAL) {
kbd_flags ^= NUM;
kbd_state = (kbd_flags & NUM) ? AS : NM;
- kbd_led_set(); /* update keyboard LED */
+ kbd_led_set();
}
}
@@ -368,7 +371,7 @@ static void kbd_caps(unsigned char scan_code)
{
if ((kbd_flags & BRK) == NORMAL) {
kbd_flags ^= CAPS;
- kbd_led_set(); /* update keyboard LED */
+ kbd_led_set();
}
}
@@ -376,7 +379,7 @@ static void kbd_scroll(unsigned char scan_code)
{
if ((kbd_flags & BRK) == NORMAL) {
kbd_flags ^= STP;
- kbd_led_set(); /* update keyboard LED */
+ kbd_led_set();
if (kbd_flags & STP)
kbd_input = 0x13;
else
@@ -399,8 +402,8 @@ static void kbd_conv_char(unsigned char scan_code)
if ((scan_code == 0xe1) || (kbd_flags & E1)) {
if (scan_code == 0xe1) {
- kbd_flags ^= BRK; /* reset the break flag */
- kbd_flags ^= E1; /* bitwise EXOR with E1 flag */
+ kbd_flags ^= BRK; /* reset the break flag */
+ kbd_flags ^= E1; /* bitwise EXOR with E1 flag */
}
return;
}
@@ -445,55 +448,57 @@ static void kbd_conv_char(unsigned char scan_code)
kbd_scroll(scan_code);
break;
}
+
return;
}
-/******************************************************************************/
-
static int kbd_reset(void)
{
/* KB Reset */
if (kbd_input_empty() == 0)
return -1;
- out8(I8042_DATA_REG, 0xff);
+ out8(I8042_DATA_REG, CMD_RESET_KBD);
- if (wait_until_kbd_output_full() == 0)
+ if (kbd_output_full() == 0)
return -1;
- if (in8(I8042_DATA_REG) != 0xfa) /* ACK */
+ if (in8(I8042_DATA_REG) != KBD_ACK)
return -1;
- if (wait_until_kbd_output_full() == 0)
+ if (kbd_output_full() == 0)
return -1;
- if (in8(I8042_DATA_REG) != 0xaa) /* Test Pass*/
+ if (in8(I8042_DATA_REG) != KBD_POR)
return -1;
if (kbd_input_empty() == 0)
return -1;
/* Set KBC mode */
- out8(I8042_COMMAND_REG, 0x60);
+ out8(I8042_CMD_REG, CMD_WR_CONFIG);
if (kbd_input_empty() == 0)
return -1;
- out8(I8042_DATA_REG, 0x45);
+ out8(I8042_DATA_REG,
+ CONFIG_AT_TRANS | CONFIG_SET_BIST | CONFIG_KIRQ_EN);
if (kbd_input_empty() == 0)
return -1;
/* Enable Keyboard */
- out8(I8042_COMMAND_REG, 0xae);
+ out8(I8042_CMD_REG, CMD_KBD_EN);
if (kbd_input_empty() == 0)
return -1;
- out8(I8042_COMMAND_REG, 0x60);
+ out8(I8042_CMD_REG, CMD_WR_CONFIG);
if (kbd_input_empty() == 0)
return -1;
- out8(I8042_DATA_REG, 0xf4);
+ out8(I8042_DATA_REG,
+ CONFIG_AT_TRANS | CONFIG_MCLK_DIS |
+ CONFIG_KCLK_DIS | CONFIG_SET_BIST);
if (kbd_input_empty() == 0)
return -1;
@@ -502,7 +507,7 @@ static int kbd_reset(void)
static int kbd_controller_present(void)
{
- return in8(I8042_STATUS_REG) != 0xff;
+ return in8(I8042_STS_REG) != 0xff;
}
/*
@@ -520,18 +525,18 @@ void i8042_flush(void)
int timeout;
/*
- * The delay is to give the keyboard controller some time to fill the
- * next byte.
+ * The delay is to give the keyboard controller some time
+ * to fill the next byte.
*/
while (1) {
- timeout = 100; /* wait for no longer than 100us */
- while (timeout > 0 && !(in8(I8042_STATUS_REG) & 0x01)) {
+ timeout = 100; /* wait for no longer than 100us */
+ while (timeout > 0 && !(in8(I8042_STS_REG) & STATUS_OBF)) {
udelay(1);
timeout--;
}
- /* Try to pull next byte if not timeout. */
- if (in8(I8042_STATUS_REG) & 0x01)
+ /* Try to pull next byte if not timeout */
+ if (in8(I8042_STS_REG) & STATUS_OBF)
in8(I8042_DATA_REG);
else
break;
@@ -544,7 +549,7 @@ int i8042_disable(void)
return -1;
/* Disable keyboard */
- out8(I8042_COMMAND_REG, 0xad);
+ out8(I8042_CMD_REG, CMD_KBD_DIS);
if (kbd_input_empty() == 0)
return -1;
@@ -552,17 +557,16 @@ int i8042_disable(void)
return 0;
}
-/*******************************************************************************
- *
- * i8042_kbd_init - reset keyboard and init state flags
- */
+/* i8042_kbd_init - reset keyboard and init state flags */
int i8042_kbd_init(void)
{
int keymap, try;
char *penv;
- if (!kbd_controller_present() || board_i8042_skip())
+ if (!kbd_controller_present() || board_i8042_skip()) {
+ debug("i8042 keyboard controller is not present\n");
return -1;
+ }
/* Init keyboard device (default US layout) */
keymap = KBD_US;
@@ -578,32 +582,33 @@ int i8042_kbd_init(void)
kbd_flags = NORMAL;
kbd_state = 0;
kbd_led_set();
+
return 0;
}
}
+
return -1;
}
-
-/*******************************************************************************
- *
+/*
* i8042_tstc - test if keyboard input is available
- * option: cursor blinking if called in a loop
+ *
+ * option: cursor blinking if called in a loop
*/
int i8042_tstc(struct stdio_dev *dev)
{
unsigned char scan_code = 0;
#ifdef CONFIG_CONSOLE_CURSOR
- if (--blinkCount == 0) {
+ if (--blink_count == 0) {
cursor_state ^= 1;
console_cursor(cursor_state);
- blinkCount = CONFIG_SYS_CONSOLE_BLINK_COUNT;
+ blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
udelay(10);
}
#endif
- if ((in8(I8042_STATUS_REG) & 0x01) == 0) {
+ if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
return 0;
} else {
scan_code = in8(I8042_DATA_REG);
@@ -615,14 +620,14 @@ int i8042_tstc(struct stdio_dev *dev)
if (kbd_input != -1)
return 1;
}
+
return 0;
}
-
-/*******************************************************************************
- *
+/*
* i8042_getc - wait till keyboard input is available
- * option: turn on/off cursor while waiting
+ *
+ * option: turn on/off cursor while waiting
*/
int i8042_getc(struct stdio_dev *dev)
{
@@ -630,21 +635,22 @@ int i8042_getc(struct stdio_dev *dev)
unsigned char scan_code;
while (kbd_input == -1) {
- while ((in8(I8042_STATUS_REG) & 0x01) == 0) {
+ while ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
#ifdef CONFIG_CONSOLE_CURSOR
- if (--blinkCount == 0) {
+ if (--blink_count == 0) {
cursor_state ^= 1;
console_cursor(cursor_state);
- blinkCount = CONFIG_SYS_CONSOLE_BLINK_COUNT;
+ blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
}
udelay(10);
#endif
}
scan_code = in8(I8042_DATA_REG);
if (scan_code != 0xfa)
- kbd_conv_char (scan_code);
+ kbd_conv_char(scan_code);
}
ret_chr = kbd_input;
kbd_input = -1;
+
return ret_chr;
}