mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
southbridge drivers in Kconfig. * It includes initial superio code as well, but there is at least one error in the pnp_device.c/superio scenario left * Fixed biosemu.c, vm86.c, pnp_device.c (sort of) * Enable vm86 instead of x86emu per default for vga init for now. This makes VGA in qemu work. There might be a bug in x86emu or the compiler I am using. (gcc version 4.1.2 20070115 (prerelease) (SUSE Linux)) * Import isa-dma.c, keyboard.c and i8259.c from v2 /pc80, which was taken from LinuxBIOSv1 released from LANL under release LA-CC Number 00-34 and using parts from the Linux kernel. This patch makes vga and keyboard work in qemu. Yippie Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Ronald G. Minnich <rminnich@gmail.com> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@260 f3766cd6-281f-0410-b1cd-43a5c92072e9
79 lines
1.8 KiB
C
79 lines
1.8 KiB
C
#include <console/console.h>
|
|
#include <keyboard.h>
|
|
#include <device/device.h>
|
|
#include <arch/io.h>
|
|
|
|
static int kbd_empty_input_buffer(void)
|
|
{
|
|
unsigned long timeout;
|
|
for(timeout = 1000000; timeout && (inb(0x64) & 0x02); timeout--) {
|
|
post_code(0);
|
|
}
|
|
return !!timeout;
|
|
}
|
|
|
|
static int kbd_empty_output_buffer(void)
|
|
{
|
|
unsigned long timeout;
|
|
for(timeout = 1000000; timeout && ((inb(0x64) & 0x01) == 0); timeout--) {
|
|
post_code(0);
|
|
}
|
|
return !!timeout;
|
|
}
|
|
|
|
/* much better keyboard init courtesy ollie@sis.com.tw
|
|
TODO: Typematic Setting, the keyboard is too slow for me */
|
|
static void pc_keyboard_init(struct pc_keyboard *keyboard)
|
|
{
|
|
unsigned char regval;
|
|
|
|
/* send cmd = 0xAA, self test 8042 */
|
|
outb(0xaa, 0x64);
|
|
|
|
/* empty input buffer or any other command/data will be lost */
|
|
if (!kbd_empty_input_buffer()) {
|
|
printk(BIOS_ERR, "Keyboard input buffer would not empty\n");
|
|
return;
|
|
}
|
|
|
|
/* empty output buffer or any other command/data will be lost */
|
|
if (!kbd_empty_output_buffer()) {
|
|
printk(BIOS_ERR, "Keyboard output buffer would not empty\n");
|
|
return;
|
|
}
|
|
|
|
/* read self-test result, 0x55 should be returned form 0x60 */
|
|
if ((regval = inb(0x60) != 0x55))
|
|
return;
|
|
|
|
/* enable keyboard interface */
|
|
outb(0x60, 0x64);
|
|
kbd_empty_input_buffer();
|
|
|
|
/* send cmd: enable IRQ 1 */
|
|
outb(0x61, 0x60);
|
|
kbd_empty_input_buffer();
|
|
|
|
/* reset kerboard and self test (keyboard side) */
|
|
outb(0xff, 0x60);
|
|
|
|
/* empty inut bufferm or any other command/data will be lost */
|
|
kbd_empty_input_buffer();
|
|
|
|
/* empty output buffer or any other command/data will be lost */
|
|
kbd_empty_output_buffer();
|
|
|
|
if ((regval = inb(0x60) != 0xfa))
|
|
return;
|
|
|
|
kbd_empty_output_buffer();
|
|
if ((regval = inb(0x60) != 0xaa))
|
|
return;
|
|
}
|
|
|
|
void init_pc_keyboard(unsigned int port0, unsigned int port1, struct pc_keyboard *kbd)
|
|
{
|
|
if ((port0 == 0x60) && (port1 == 0x64)) {
|
|
pc_keyboard_init(kbd);
|
|
}
|
|
}
|