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>
This commit is contained in:
parent
d1da7769c3
commit
9dc53922a4
2 changed files with 57 additions and 14 deletions
|
|
@ -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 @@ void set_kbc_ps2_mode(void)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue