summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul E Rangel <rrangel@chromium.org>2022-08-15 15:56:10 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-18 14:47:22 +0000
commit08d69143b21125f717d7e695481f28ecdfc6d559 (patch)
tree144160d8efbd0b22190b6f0a4cc63eeb2db3bda5
parent5af88437a4f126c37224f5b3a4c001d14c091d3e (diff)
downloadchrome-ec-08d69143b21125f717d7e695481f28ecdfc6d559.tar.gz
8042: Rename I8042_CMD to ATKBD_CMD and move to a different file
These are actually AT Keyboard commands, and not specific to the i8042 controller. Using the correct prefix will make it easier to understand which device we are interacting with. I also moved the definitions into a different file to make it clear that there is a separation between the two protocols. BUG=b:242886255 BRANCH=none TEST=build guybrush Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I160f1d71edbce80606d8bcb01dbeb0d2192cfa93 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3835508 Code-Coverage: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r--common/keyboard_8042.c33
-rw-r--r--include/atkbd_protocol.h37
-rw-r--r--include/i8042_protocol.h20
-rw-r--r--test/kb_8042.c9
4 files changed, 59 insertions, 40 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index 0c7041937f..fe7e4b8e73 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -14,6 +14,7 @@
#include "hooks.h"
#include "host_command.h"
#include "i8042_protocol.h"
+#include "atkbd_protocol.h"
#include "keyboard_8042_sharedlib.h"
#include "keyboard_config.h"
#include "keyboard_protocol.h"
@@ -650,65 +651,65 @@ static int handle_keyboard_data(uint8_t data, uint8_t *output)
default: /* STATE_NORMAL */
switch (data) {
- case I8042_CMD_GSCANSET: /* also I8042_CMD_SSCANSET */
+ case ATKBD_CMD_GSCANSET: /* also ATKBD_CMD_SSCANSET */
output[out_len++] = I8042_RET_ACK;
data_port_state = STATE_SCANCODE;
break;
- case I8042_CMD_SETLEDS:
+ case ATKBD_CMD_SETLEDS:
/* Chrome OS doesn't have keyboard LEDs, so ignore */
output[out_len++] = I8042_RET_ACK;
data_port_state = STATE_SETLEDS;
break;
- case I8042_CMD_EX_SETLEDS:
+ case ATKBD_CMD_EX_SETLEDS:
output[out_len++] = I8042_RET_ACK;
data_port_state = STATE_EX_SETLEDS_1;
break;
- case I8042_CMD_DIAG_ECHO:
+ case ATKBD_CMD_DIAG_ECHO:
output[out_len++] = I8042_RET_ACK;
- output[out_len++] = I8042_CMD_DIAG_ECHO;
+ output[out_len++] = ATKBD_CMD_DIAG_ECHO;
break;
- case I8042_CMD_GETID: /* fall-thru */
- case I8042_CMD_OK_GETID:
+ case ATKBD_CMD_GETID: /* fall-thru */
+ case ATKBD_CMD_OK_GETID:
output[out_len++] = I8042_RET_ACK;
output[out_len++] = 0xab; /* Regular keyboards */
output[out_len++] = 0x83;
break;
- case I8042_CMD_SETREP:
+ case ATKBD_CMD_SETREP:
output[out_len++] = I8042_RET_ACK;
data_port_state = STATE_SETREP;
break;
- case I8042_CMD_ENABLE:
+ case ATKBD_CMD_ENABLE:
output[out_len++] = I8042_RET_ACK;
keystroke_enable(1);
keyboard_clear_buffer();
break;
- case I8042_CMD_RESET_DIS:
+ case ATKBD_CMD_RESET_DIS:
output[out_len++] = I8042_RET_ACK;
keystroke_enable(0);
reset_rate_and_delay();
keyboard_clear_buffer();
break;
- case I8042_CMD_RESET_DEF:
+ case ATKBD_CMD_RESET_DEF:
output[out_len++] = I8042_RET_ACK;
reset_rate_and_delay();
keyboard_clear_buffer();
break;
- case I8042_CMD_RESET:
+ case ATKBD_CMD_RESET:
reset_rate_and_delay();
keyboard_clear_buffer();
output[out_len++] = I8042_RET_ACK;
break;
- case I8042_CMD_RESEND:
+ case ATKBD_CMD_RESEND:
save_for_resend = 0;
for (i = 0; i < resend_command_len; ++i)
output[out_len++] = resend_command[i];
@@ -719,9 +720,9 @@ static int handle_keyboard_data(uint8_t data, uint8_t *output)
/* U-boot hack. Just ignore; don't reply. */
break;
- case I8042_CMD_SETALL_MB: /* fall-thru */
- case I8042_CMD_SETALL_MBR:
- case I8042_CMD_EX_ENABLE:
+ case ATKBD_CMD_SETALL_MB: /* fall-thru */
+ case ATKBD_CMD_SETALL_MBR:
+ case ATKBD_CMD_EX_ENABLE:
default:
output[out_len++] = I8042_RET_NAK;
CPRINTS("KB Unsupported i8042 data 0x%02x", data);
diff --git a/include/atkbd_protocol.h b/include/atkbd_protocol.h
new file mode 100644
index 0000000000..70a4b4ca86
--- /dev/null
+++ b/include/atkbd_protocol.h
@@ -0,0 +1,37 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * ATKBD keyboard protocol constants.
+ *
+ * See the IBL PC AT Technical Reference Manual Section 4.
+ * i.e., 6183355_PC_AT_Technical_Reference_Mar86.pdf
+ *
+ * https://archive.org/details/bitsavers_ibmpcat618ferenceMar86_25829277/page/n151/mode/2up
+ */
+
+#ifndef __CROS_EC_ATKBD_PROTOCOL_H
+#define __CROS_EC_ATKBD_PROTOCOL_H
+
+#define ATKBD_CMD_OK_GETID 0xe8
+#define ATKBD_CMD_EX_ENABLE 0xea
+#define ATKBD_CMD_EX_SETLEDS 0xeb
+#define ATKBD_CMD_SETLEDS 0xed
+#define ATKBD_CMD_DIAG_ECHO 0xee
+#define ATKBD_CMD_GSCANSET 0xf0
+#define ATKBD_CMD_SSCANSET 0xf0
+#define ATKBD_CMD_GETID 0xf2
+#define ATKBD_CMD_SETREP 0xf3
+#define ATKBD_CMD_ENABLE 0xf4
+#define ATKBD_CMD_RESET_DIS 0xf5
+#define ATKBD_CMD_RESET_DEF 0xf6
+#define ATKBD_CMD_ALL_TYPEM 0xf7
+#define ATKBD_CMD_SETALL_MB 0xf8
+#define ATKBD_CMD_SETALL_MBR 0xfa
+#define ATKBD_CMD_SET_A_KEY_T 0xfb
+#define ATKBD_CMD_SET_A_KEY_MR 0xfc
+#define ATKBD_CMD_SET_A_KEY_M 0xfd
+#define ATKBD_CMD_RESEND 0xfe
+#define ATKBD_CMD_RESET 0xff
+
+#endif /* __CROS_EC_ATKBD_PROTOCOL_H */
diff --git a/include/i8042_protocol.h b/include/i8042_protocol.h
index f56da0956c..f5ca10dbf7 100644
--- a/include/i8042_protocol.h
+++ b/include/i8042_protocol.h
@@ -14,27 +14,7 @@
#define I8042_CMD_MOUSE_1_1 0xe6
#define I8042_CMD_MOUSE_2_1 0xe7
#define I8042_CMD_MOUSE_RES 0xe8
-#define I8042_CMD_OK_GETID 0xe8
#define I8042_CMD_GET_MOUSE 0xe9
-#define I8042_CMD_EX_ENABLE 0xea
-#define I8042_CMD_EX_SETLEDS 0xeb
-#define I8042_CMD_SETLEDS 0xed
-#define I8042_CMD_DIAG_ECHO 0xee
-#define I8042_CMD_GSCANSET 0xf0
-#define I8042_CMD_SSCANSET 0xf0
-#define I8042_CMD_GETID 0xf2
-#define I8042_CMD_SETREP 0xf3
-#define I8042_CMD_ENABLE 0xf4
-#define I8042_CMD_RESET_DIS 0xf5
-#define I8042_CMD_RESET_DEF 0xf6
-#define I8042_CMD_ALL_TYPEM 0xf7
-#define I8042_CMD_SETALL_MB 0xf8
-#define I8042_CMD_SETALL_MBR 0xfa
-#define I8042_CMD_SET_A_KEY_T 0xfb
-#define I8042_CMD_SET_A_KEY_MR 0xfc
-#define I8042_CMD_SET_A_KEY_M 0xfd
-#define I8042_CMD_RESET 0xff
-#define I8042_CMD_RESEND 0xfe
/* port 0x64 */
#define I8042_READ_CMD_BYTE 0x20
diff --git a/test/kb_8042.c b/test/kb_8042.c
index 1a3681aa28..7f1f2b388f 100644
--- a/test/kb_8042.c
+++ b/test/kb_8042.c
@@ -5,6 +5,7 @@
* Tests for keyboard MKBP protocol
*/
+#include "atkbd_protocol.h"
#include "common.h"
#include "console.h"
#include "ec_commands.h"
@@ -50,20 +51,20 @@ static void press_key(int c, int r, int pressed)
static void enable_keystroke(int enabled)
{
- uint8_t data = enabled ? I8042_CMD_ENABLE : I8042_CMD_RESET_DIS;
+ uint8_t data = enabled ? ATKBD_CMD_ENABLE : ATKBD_CMD_RESET_DIS;
keyboard_host_write(data, 0);
msleep(30);
}
static void reset_8042(void)
{
- keyboard_host_write(I8042_CMD_RESET_DEF, 0);
+ keyboard_host_write(ATKBD_CMD_RESET_DEF, 0);
msleep(30);
}
static void set_typematic(uint8_t val)
{
- keyboard_host_write(I8042_CMD_SETREP, 0);
+ keyboard_host_write(ATKBD_CMD_SETREP, 0);
msleep(30);
keyboard_host_write(val, 0);
msleep(30);
@@ -71,7 +72,7 @@ static void set_typematic(uint8_t val)
static void set_scancode(uint8_t s)
{
- keyboard_host_write(I8042_CMD_SSCANSET, 0);
+ keyboard_host_write(ATKBD_CMD_SSCANSET, 0);
msleep(30);
keyboard_host_write(s, 0);
msleep(30);