Matt DeVillier has submitted this change. ( https://review.coreboot.org/c/coreboot/+/85330?usp=email )
(
3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: drivers/pc80/pc/keyboard.c: Add function to change a command byte bit ......................................................................
drivers/pc80/pc/keyboard.c: Add function to change a command byte bit
Some keyboard controllers need to have a specific bit in the command byte set (e.g. PC_KBC_TRANSLATE) in order for the keyboard to function properly.
Change-Id: I8745d1848f223634043eecc4659021a76a2b239b Signed-off-by: Nicholas Sudsgaard devel+coreboot@nsudsgaard.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/85330 Reviewed-by: Paul Menzel paulepanter@mailbox.org Reviewed-by: Jérémy Compostella jeremy.compostella@intel.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/drivers/pc80/pc/keyboard.c M src/include/pc80/keyboard.h 2 files changed, 57 insertions(+), 14 deletions(-)
Approvals: Paul Menzel: Looks good to me, but someone else must approve build bot (Jenkins): Verified Jérémy Compostella: Looks good to me, approved
diff --git a/src/drivers/pc80/pc/keyboard.c b/src/drivers/pc80/pc/keyboard.c index a96dba7..f086391 100644 --- a/src/drivers/pc80/pc/keyboard.c +++ b/src/drivers/pc80/pc/keyboard.c @@ -22,19 +22,6 @@ #define KBC_CMD_SELF_TEST 0xAA // Controller self-test #define KBC_CMD_KBD_TEST 0xAB // Keyboard Interface test
-/* The Keyboard controller command byte - * BIT | Description - * ----+------------------------------------------------------- - * 7 | reserved, must be zero - * 6 | XT Translation, (1 = on, 0 = off) - * 5 | Disable Mouse Port (1 = disable, 0 = enable) - * 4 | Disable Keyboard Port (1 = disable, 0 = enable) - * 3 | reserved, must be zero - * 2 | System Flag (1 = self-test passed. DO NOT SET TO ZERO) - * 1 | Mouse Port Interrupts (1 = enable, 0 = disable) - * 0 | Keyboard Port Interrupts (1 = enable, 0 = disable) - */ - // Keyboard Controller Replies #define KBC_REPLY_SELFTEST_OK 0x55 // controller self-test succeeded
@@ -369,3 +356,34 @@
kbc_cleanup_buffers(); } + +enum cb_err pc_keyboard_set_command_byte_bit(u8 bit, u8 value) +{ + if (!kbc_input_buffer_empty()) { + printk(BIOS_ERR, "Timeout waiting to read command byte\n"); + return CB_KBD_INTERFACE_FAILURE; + } + outb(KBC_CMD_READ_COMMAND, KBD_COMMAND); + + if (!kbc_output_buffer_full()) { + printk(BIOS_ERR, "Timeout waiting to read command byte\n"); + return CB_KBD_INTERFACE_FAILURE; + } + u8 byte = inb(KBD_DATA); + + if (!kbc_input_buffer_empty()) { + printk(BIOS_ERR, "Timeout waiting to write command byte\n"); + return CB_KBD_INTERFACE_FAILURE; + } + outb(KBC_CMD_WRITE_COMMAND, KBD_COMMAND); + + byte = value ? (byte | BIT(bit)) : (byte & ~BIT(bit)); + + if (!kbc_input_buffer_empty()) { + printk(BIOS_ERR, "Timeout waiting to write command byte\n"); + return CB_KBD_INTERFACE_FAILURE; + } + outb(byte, KBD_DATA); + + return CB_SUCCESS; +} diff --git a/src/include/pc80/keyboard.h b/src/include/pc80/keyboard.h index 6664980..a799e33d 100644 --- a/src/include/pc80/keyboard.h +++ b/src/include/pc80/keyboard.h @@ -3,12 +3,37 @@ #ifndef PC80_KEYBOARD_H #define PC80_KEYBOARD_H
-#include <stdint.h> +#include <types.h>
#define NO_AUX_DEVICE 0 #define PROBE_AUX_DEVICE 1
+/* + * The Keyboard controller command byte + * + * BIT | Description + * ----+------------------------------------------------------- + * 7 | reserved, must be zero : + * 6 | XT Translation : 1 = on, 0 = off + * 5 | Disable Mouse Port : 1 = disable, 0 = enable + * 4 | Disable Keyboard Port : 1 = disable, 0 = enable + * 3 | reserved, must be zero : + * 2 | System Flag : 1 = self-test passed (DO NOT SET TO ZERO) + * 1 | Mouse Port Interrupts : 1 = enable, 0 = disable + * 0 | Keyboard Port Interrupts : 1 = enable, 0 = disable + * ----+------------------------------------------------------- + */ +enum { + PC_KBC_KBD_INT = 0, + PC_KBC_AUX_INT = 1, + PC_KBC_SYS = 2, + PC_KBC_KBD_DISABLE = 4, + PC_KBC_AUX_DISABLE = 5, + PC_KBC_TRANSLATE = 6, +}; + uint8_t pc_keyboard_init(uint8_t probe_aux); void set_kbc_ps2_mode(void); +enum cb_err pc_keyboard_set_command_byte_bit(u8 bit, u8 value);
#endif /* PC80_KEYBOARD_H */