summaryrefslogtreecommitdiffstats
path: root/include/asm-mips/keyboard.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-mips/keyboard.h')
-rw-r--r--include/asm-mips/keyboard.h198
1 files changed, 45 insertions, 153 deletions
diff --git a/include/asm-mips/keyboard.h b/include/asm-mips/keyboard.h
index 04dada787..2c4396f04 100644
--- a/include/asm-mips/keyboard.h
+++ b/include/asm-mips/keyboard.h
@@ -4,12 +4,34 @@
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
+ *
+ * This file is a mess. Put on your peril sensitive glasses.
*/
#ifndef __ASM_MIPS_KEYBOARD_H
#define __ASM_MIPS_KEYBOARD_H
+#ifdef __KERNEL__
+
#include <linux/config.h>
#include <linux/delay.h>
+#include <linux/ioport.h>
+
+extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
+extern int pckbd_getkeycode(unsigned int scancode);
+extern int pckbd_pretranslate(unsigned char scancode, char raw_mode);
+extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
+ char raw_mode);
+extern char pckbd_unexpected_up(unsigned char keycode);
+extern void pckbd_leds(unsigned char leds);
+extern void pckbd_init_hw(void);
+
+#define kbd_setkeycode pckbd_setkeycode
+#define kbd_getkeycode pckbd_getkeycode
+#define kbd_pretranslate pckbd_pretranslate
+#define kbd_translate pckbd_translate
+#define kbd_unexpected_up pckbd_unexpected_up
+#define kbd_leds pckbd_leds
+#define kbd_init_hw pckbd_init_hw
/*
* The default IO slowdown is doing 'inb()'s from 0x61, which should be
@@ -21,6 +43,13 @@
#define SLOW_IO_BY_JUMPING
#include <asm/io.h>
+/*
+ * keyboard controller registers
+ */
+#define KBD_STATUS_REG (unsigned int) 0x64
+#define KBD_CNTL_REG (unsigned int) 0x64
+#define KBD_DATA_REG (unsigned int) 0x60
+
#ifdef CONFIG_SGI
#include <asm/segment.h>
#include <asm/sgihpc.h>
@@ -44,8 +73,8 @@
#ifndef CONFIG_SGI
#define KBD_REPORT_ERR
#endif
-
-__initfunc(int initialize_kbd(void));
+#define KBD_REPORT_UNKN
+/* #define KBD_IS_FOCUS_9000 */
int (*kbd_inb_p)(unsigned short port);
int (*kbd_inb)(unsigned short port);
@@ -60,14 +89,16 @@ void (*kbd_outb)(unsigned char data, unsigned short port);
/* XXX Define both and ... */
#ifdef CONFIG_MIPS_JAZZ
#define INIT_KBD /* full initialization for the keyboard controller. */
-static volatile keyboard_hardware *kh = (void *) JAZZ_KEYBOARD_ADDRESS;
+#define __khtype keyboard_hardware
#endif
#ifdef CONFIG_SGI
#define INIT_KBD /* full initialization for the keyboard controller. */
-volatile struct hpc_keyb *kh = (struct hpc_keyb *) (KSEG1 + 0x1fbd9800 + 64);
+#define __khtype struct hpc_keyb
#endif
+static volatile __khtype *kh;
+
static int
jazz_kbd_inb_p(unsigned short port)
{
@@ -147,158 +178,14 @@ port_kbd_outb(unsigned char data, unsigned short port)
return outb(data, port);
}
-#ifdef INIT_KBD
-static int
-kbd_wait_for_input(void)
-{
- int n;
- int status, data;
-
- n = TIMEOUT_CONST;
- do {
- status = kbd_inb(KBD_STATUS_REG);
- /*
- * Wait for input data to become available. This bit will
- * then be cleared by the following read of the DATA
- * register.
- */
-
- if (!(status & KBD_OBF))
- continue;
-
- data = kbd_inb(KBD_DATA_REG);
-
- /*
- * Check to see if a timeout error has occurred. This means
- * that transmission was started but did not complete in the
- * normal time cycle. PERR is set when a parity error occurred
- * in the last transmission.
- */
- if (status & (KBD_GTO | KBD_PERR)) {
- continue;
- }
- return (data & 0xff);
- } while (--n);
- return (-1); /* timed-out if fell through to here... */
-}
-
-static void kbd_write(int address, int data)
-{
- int status;
-
- do {
- status = kbd_inb(KBD_STATUS_REG); /* spin until input buffer empty*/
- } while (status & KBD_IBF);
- kbd_outb(data, address); /* write out the data*/
-}
-
-__initfunc(int initialize_kbd(void))
-{
- unsigned long flags;
-
- save_flags(flags); cli();
-
- /* Flush any pending input. */
- while (kbd_wait_for_input() != -1)
- continue;
+static inline void kb_wait(void);
+static int send_data(unsigned char data);
- /*
- * Test the keyboard interface.
- * This seems to be the only way to get it going.
- * If the test is successful a x55 is placed in the input buffer.
- */
- kbd_write(KBD_CNTL_REG, KBD_SELF_TEST);
- if (kbd_wait_for_input() != 0x55) {
- printk(KERN_WARNING "initialize_kbd: "
- "keyboard failed self test.\n");
- restore_flags(flags);
- return(-1);
- }
-
- /*
- * Perform a keyboard interface test. This causes the controller
- * to test the keyboard clock and data lines. The results of the
- * test are placed in the input buffer.
- */
- kbd_write(KBD_CNTL_REG, KBD_SELF_TEST2);
- if (kbd_wait_for_input() != 0x00) {
- printk(KERN_WARNING "initialize_kbd: "
- "keyboard failed self test 2.\n");
- restore_flags(flags);
- return(-1);
- }
-
- /* Enable the keyboard by allowing the keyboard clock to run. */
- kbd_write(KBD_CNTL_REG, KBD_CNTL_ENABLE);
-
- /*
- * Reset keyboard. If the read times out
- * then the assumption is that no keyboard is
- * plugged into the machine.
- * This defaults the keyboard to scan-code set 2.
- */
- kbd_write(KBD_DATA_REG, KBD_RESET);
- if (kbd_wait_for_input() != KBD_ACK) {
- printk(KERN_WARNING "initialize_kbd: "
- "reset kbd failed, no ACK.\n");
- restore_flags(flags);
- return(-1);
- }
-
- /*
- * Give the keyboard some time to breathe ...
- * ... or it fucks up the floppy controller, too. Wiered.
- */
- udelay(20);
-
- if (kbd_wait_for_input() != KBD_POR) {
- printk(KERN_WARNING "initialize_kbd: "
- "reset kbd failed, not POR.\n");
- restore_flags(flags);
- return(-1);
- }
-
- /*
- * now do a DEFAULTS_DISABLE always
- */
- kbd_write(KBD_DATA_REG, KBD_DISABLE);
- if (kbd_wait_for_input() != KBD_ACK) {
- printk(KERN_WARNING "initialize_kbd: "
- "disable kbd failed, no ACK.\n");
- restore_flags(flags);
- return(-1);
- }
-
- /*
- * Enable keyboard interrupt, operate in "sys" mode,
- * enable keyboard (by clearing the disable keyboard bit),
- * disable mouse, do conversion of keycodes.
- */
- kbd_write(KBD_CNTL_REG, KBD_WRITE_MODE);
- kbd_write(KBD_DATA_REG, KBD_EKI|KBD_SYS|KBD_DMS|KBD_KCC);
-
- /*
- * now ENABLE the keyboard to set it scanning...
- */
- kbd_write(KBD_DATA_REG, KBD_ENABLE);
- if (kbd_wait_for_input() != KBD_ACK) {
- printk(KERN_WARNING "initialize_kbd: "
- "keyboard enable failed.\n");
- restore_flags(flags);
- return(-1);
- }
-
- restore_flags(flags);
-
- return (1);
-}
-#endif
-
-extern __inline__ void
-keyboard_setup(void)
+extern __inline__ void keyboard_setup(void)
{
#ifdef CONFIG_MIPS_JAZZ
if (mips_machgroup == MACH_GROUP_JAZZ) {
+ kh = (void *) JAZZ_KEYBOARD_ADDRESS;
kbd_inb_p = jazz_kbd_inb_p;
kbd_inb = jazz_kbd_inb;
kbd_outb_p = jazz_kbd_outb_p;
@@ -308,7 +195,6 @@ keyboard_setup(void)
*/
*((volatile u16 *)JAZZ_IO_IRQ_ENABLE) |= JAZZ_IE_KEYBOARD;
set_cp0_status(IE_IRQ1, IE_IRQ1);
- initialize_kbd();
} else
#endif
if (mips_machgroup == MACH_GROUP_ARC || /* this is for Deskstation */
@@ -334,6 +220,12 @@ keyboard_setup(void)
if (!send_data(0xf0) || !send_data(0x02))
printk("Scanmode 2 change failed\n");
}
+#ifdef CONFIG_SGI
+ if (mips_machgroup == MACH_SGI_INDY) {
+ kh = (struct hpc_keyb *) (KSEG1 + 0x1fbd9800 + 64);
+ }
+#endif
}
+#endif /* __KERNEL */
#endif /* __ASM_MIPS_KEYBOARD_H */