diff options
-rw-r--r-- | arch/mips/deskstation/hw-access.c | 34 | ||||
-rw-r--r-- | arch/mips/deskstation/setup.c | 3 | ||||
-rw-r--r-- | arch/mips/jazz/hw-access.c | 34 | ||||
-rw-r--r-- | arch/mips/jazz/setup.c | 3 | ||||
-rw-r--r-- | arch/mips/sgi/kernel/setup.c | 37 | ||||
-rw-r--r-- | arch/mips/sni/hw-access.c | 35 | ||||
-rw-r--r-- | arch/mips/sni/setup.c | 3 | ||||
-rw-r--r-- | drivers/char/pc_keyb.c | 63 | ||||
-rw-r--r-- | drivers/char/psaux.c | 650 | ||||
-rw-r--r-- | include/asm-alpha/keyboard.h | 36 | ||||
-rw-r--r-- | include/asm-i386/keyboard.h | 48 | ||||
-rw-r--r-- | include/asm-mips/keyboard.h | 229 | ||||
-rw-r--r-- | include/asm-ppc/keyboard.h | 33 |
13 files changed, 609 insertions, 599 deletions
diff --git a/arch/mips/deskstation/hw-access.c b/arch/mips/deskstation/hw-access.c index 418bac5f6..8b1bd0e3b 100644 --- a/arch/mips/deskstation/hw-access.c +++ b/arch/mips/deskstation/hw-access.c @@ -5,10 +5,13 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1996 by Ralf Baechle + * Copyright (C) 1996, 1997 by Ralf Baechle + * + * $Id: hw-access.c,v 1.2 1997/07/23 17:40:54 ralf Exp $ */ #include <linux/config.h> #include <linux/delay.h> +#include <linux/kbdcntrlr.h> #include <linux/kernel.h> #include <linux/linkage.h> #include <linux/types.h> @@ -194,3 +197,32 @@ struct feature deskstation_rpc44_feature = { rtc_write_data }; #endif + +static unsigned char dtc_read_input(void) +{ + return inb(KBD_DATA_REG); +} + +static void dtc_write_output(unsigned char val) +{ + outb(val, KBD_DATA_REG); +} + +static void dtc_write_command(unsigned char val) +{ + outb(val, KBD_CNTL_REG); +} + +static unsigned char dtc_read_status(void) +{ + return inb(KBD_STATUS_REG); +} + +static void dtc_rm200_keyboard_setup(void) +{ + kbd_read_input = dtc_read_input; + kbd_write_output = dtc_write_output; + kbd_write_command = dtc_write_command; + kbd_read_status = dtc_read_status; + request_region(0x60, 16, "keyboard"); +} diff --git a/arch/mips/deskstation/setup.c b/arch/mips/deskstation/setup.c index 8b70a656c..939730b91 100644 --- a/arch/mips/deskstation/setup.c +++ b/arch/mips/deskstation/setup.c @@ -6,6 +6,8 @@ * for more details. * * Copyright (C) 1996, 1997 by Ralf Baechle + * + * $Id: setup.c,v 1.2 1997/07/23 17:40:54 ralf Exp $ */ #include <linux/config.h> #include <linux/init.h> @@ -102,6 +104,7 @@ __initfunc(void deskstation_setup(void)) #endif } fd_cacheflush = deskstation_fd_cacheflush; + keyboard_setup = dtc_keyboard_setup; request_region(0x00,0x20,"dma1"); request_region(0x40,0x20,"timer"); request_region(0x70,0x10,"rtc"); diff --git a/arch/mips/jazz/hw-access.c b/arch/mips/jazz/hw-access.c index 52a61165f..482e50cb2 100644 --- a/arch/mips/jazz/hw-access.c +++ b/arch/mips/jazz/hw-access.c @@ -5,7 +5,7 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1995, 1996 by Ralf Baechle + * Copyright (C) 1995, 1996, 1997 by Ralf Baechle */ #include <linux/delay.h> #include <linux/linkage.h> @@ -15,6 +15,7 @@ #include <asm/vector.h> #include <asm/jazz.h> #include <asm/jazzdma.h> +#include <asm/keyboard.h> #include <asm/pgtable.h> #include <asm/mc146818rtc.h> @@ -146,3 +147,34 @@ struct feature jazz_feature = { rtc_read_data, rtc_write_data }; + +static volatile keyboard_hardware *jazz_kh = JAZZ_KEYBOARD_ADDRESS; + +static unsigned char jazz_read_input(void) +{ + return jazz_kh->data; +} + +static void jazz_write_output(unsigned char val) +{ + jazz_kh->data = val; +} + +static void jazz_write_command(unsigned char val) +{ + jazz_kh->command = val; +} + +static unsigned char jazz_read_status(void) +{ + return jazz_kh->command; +} + +void jazz_keyboard_setup(void) +{ + kbd_read_input = jazz_read_input; + kbd_write_output = jazz_write_output; + kbd_write_command = jazz_write_command; + kbd_read_status = jazz_read_status; + request_region(0x60, 16, "keyboard"); +} diff --git a/arch/mips/jazz/setup.c b/arch/mips/jazz/setup.c index e7550e7ad..3b9924ef5 100644 --- a/arch/mips/jazz/setup.c +++ b/arch/mips/jazz/setup.c @@ -12,6 +12,7 @@ #include <linux/sched.h> #include <linux/interrupt.h> #include <asm/bootinfo.h> +#include <asm/keyboard.h> #include <asm/irq.h> #include <asm/jazz.h> #include <asm/ptrace.h> @@ -32,6 +33,7 @@ static struct irqaction irq2 = { no_action, 0, 0, "cascade", NULL, NULL}; extern asmlinkage void jazz_handle_int(void); extern asmlinkage void jazz_fd_cacheflush(const void *addr, size_t size); extern struct feature jazz_feature; +extern void jazz_keyboard_setup(void); extern void jazz_machine_restart(char *command); extern void jazz_machine_halt(void); @@ -96,6 +98,7 @@ __initfunc(void jazz_setup(void)) irq_setup = jazz_irq_setup; fd_cacheflush = jazz_fd_cacheflush; + keyboard_setup = jazz_keyboard_setup; feature = &jazz_feature; // Will go away port_base = JAZZ_PORT_BASE; isa_slot_offset = 0xe3000000; diff --git a/arch/mips/sgi/kernel/setup.c b/arch/mips/sgi/kernel/setup.c index f3e329656..04cdb6235 100644 --- a/arch/mips/sgi/kernel/setup.c +++ b/arch/mips/sgi/kernel/setup.c @@ -1,7 +1,9 @@ -/* $Id: setup.c,v 1.2 1997/06/28 22:47:44 ralf Exp $ +/* * setup.c: SGI specific setup, including init of the feature struct. * * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + * + * $Id: setup.c,v 1.4 1997/07/23 17:59:23 ralf Exp $ */ #ifndef __GOGOGO__ #error "... about to fuckup your Indy?" @@ -9,6 +11,8 @@ #include <linux/kernel.h> #include <linux/sched.h> +#include <asm/addrspace.h> +#include <asm/keyboard.h> #include <asm/reboot.h> #include <asm/vector.h> #include <asm/sgialib.h> @@ -26,6 +30,36 @@ extern void sgi_machine_power_off(void); struct feature sgi_feature = { }; +static volatile struct hpc_keyb *sgi_kh = (struct hpc_keyb *) (KSEG1 + 0x1fbd9800 + 64); + +static unsigned char sgi_read_input(void) +{ + return sgi_kh->data; +} + +static void sgi_write_output(unsigned char val) +{ + sgi_kh->data = val; +} + +static void sgi_write_command(unsigned char val) +{ + sgi_kh->command = val; +} + +static unsigned char sgi_read_status(void) +{ + return sgi_kh->command; +} + +static void sgi_keyboard_setup(void) +{ + kbd_read_input = sgi_read_input; + kbd_write_output = sgi_write_output; + kbd_write_command = sgi_write_command; + kbd_read_status = sgi_read_status; +} + static void sgi_irq_setup(void) { sgint_init(); @@ -52,6 +86,7 @@ void sgi_setup(void) irq_setup = sgi_irq_setup; feature = &sgi_feature; + keyboard_setup = sgi_keyboard_setup; _machine_restart = sgi_machine_restart; _machine_halt = sgi_machine_halt; diff --git a/arch/mips/sni/hw-access.c b/arch/mips/sni/hw-access.c index 39cbec410..5ffa6fdd9 100644 --- a/arch/mips/sni/hw-access.c +++ b/arch/mips/sni/hw-access.c @@ -5,9 +5,12 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1996 by Ralf Baechle + * Copyright (C) 1996, 1997 by Ralf Baechle + * + * $Id: hw-access.c,v 1.2 1997/07/23 17:41:07 ralf Exp $ */ #include <linux/delay.h> +#include <linux/kbdcntrlr.h> #include <linux/kernel.h> #include <linux/linkage.h> #include <linux/types.h> @@ -15,6 +18,7 @@ #include <asm/bootinfo.h> #include <asm/cachectl.h> #include <asm/dma.h> +#include <asm/keyboard.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/mc146818rtc.h> @@ -157,3 +161,32 @@ struct feature sni_rm200_pci_feature = { rtc_read_data, rtc_write_data }; + +static unsigned char sni_read_input(void) +{ + return inb(KBD_DATA_REG); +} + +static void sni_write_output(unsigned char val) +{ + outb(val, KBD_DATA_REG); +} + +static void sni_write_command(unsigned char val) +{ + outb(val, KBD_CNTL_REG); +} + +static unsigned char sni_read_status(void) +{ + return inb(KBD_STATUS_REG); +} + +void sni_rm200_keyboard_setup(void) +{ + kbd_read_input = sni_read_input; + kbd_write_output = sni_write_output; + kbd_write_command = sni_write_command; + kbd_read_status = sni_read_status; + request_region(0x60, 16, "keyboard"); +} diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c index 7fa76a490..b73c857b4 100644 --- a/arch/mips/sni/setup.c +++ b/arch/mips/sni/setup.c @@ -15,6 +15,7 @@ #include <linux/timex.h> #include <linux/pci.h> #include <asm/bootinfo.h> +#include <asm/keyboard.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/processor.h> @@ -36,6 +37,7 @@ static struct irqaction irq2 = { no_action, 0, 0, "cascade", NULL, NULL}; extern asmlinkage void sni_rm200_pci_handle_int(void); extern asmlinkage void sni_fd_cacheflush(const void *addr, size_t size); extern struct feature sni_rm200_pci_feature; +extern void sni_rm200_keyboard_setup(void); extern void sni_machine_restart(char *command); extern void sni_machine_halt(void); @@ -127,6 +129,7 @@ __initfunc(void sni_rm200_pci_setup(void)) fd_cacheflush = sni_fd_cacheflush; // Will go away feature = &sni_rm200_pci_feature; port_base = SNI_PORT_BASE; + keyboard_setup = sni_rm200_keyboard_setup; /* * Setup (E)ISA I/O memory access stuff diff --git a/drivers/char/pc_keyb.c b/drivers/char/pc_keyb.c index 9e3267aaf..fd1c8e862 100644 --- a/drivers/char/pc_keyb.c +++ b/drivers/char/pc_keyb.c @@ -16,15 +16,15 @@ #include <linux/init.h> #include <linux/kbd_ll.h> -/* Some configuration switches are present in the include file... */ - -#include "pc_keyb.h" - #include <asm/keyboard.h> #include <asm/bitops.h> #include <asm/io.h> #include <asm/system.h> +/* Some configuration switches are present in the include file... */ + +#include "pc_keyb.h" + /* * In case we run on a non-x86 hardware we need to initialize both the keyboard * controller and the keyboard. On a x86, the BIOS will already have initialized @@ -40,7 +40,7 @@ __initfunc(static int kbd_wait_for_input(void)) n = KBD_TIMEOUT; do { - status = kbd_inb(KBD_STATUS_REG); + status = kbd_read_status(); /* * Wait for input data to become available. This bit will * then be cleared by the following read of the DATA @@ -50,7 +50,7 @@ __initfunc(static int kbd_wait_for_input(void)) if (!(status & KBD_STAT_OBF)) continue; - data = kbd_inb(KBD_DATA_REG); + data = kbd_read_input(); /* * Check to see if a timeout error has occurred. This means @@ -66,14 +66,24 @@ __initfunc(static int kbd_wait_for_input(void)) return -1; /* timed-out if fell through to here... */ } -__initfunc(static void kbd_write(int address, int data)) +__initfunc(static void init_write_command(int data)) +{ + int status; + + do { + status = kbd_read_status(); + } while (status & KBD_STAT_IBF); + kbd_write_command(data); +} + +__initfunc(static void init_write_output(int data)) { int status; do { - status = kbd_inb(KBD_STATUS_REG); + status = kbd_read_status(); } while (status & KBD_STAT_IBF); - kbd_outb(data, address); + kbd_write_output(data); } __initfunc(static char *initialize_kbd2(void)) @@ -89,7 +99,7 @@ __initfunc(static char *initialize_kbd2(void)) * If the test is successful a x55 is placed in the input buffer. */ - kbd_write(KBD_CNTL_REG, KBD_CCMD_SELF_TEST); + init_write_command(KBD_CCMD_SELF_TEST); if (kbd_wait_for_input() != 0x55) return "Keyboard failed self test"; @@ -99,13 +109,13 @@ __initfunc(static char *initialize_kbd2(void)) * test are placed in the input buffer. */ - kbd_write(KBD_CNTL_REG, KBD_CCMD_KBD_TEST); + init_write_command(KBD_CCMD_KBD_TEST); if (kbd_wait_for_input() != 0x00) return "Keyboard interface failed self test"; /* Enable the keyboard by allowing the keyboard clock to run. */ - kbd_write(KBD_CNTL_REG, KBD_CCMD_KBD_ENABLE); + init_write_command(KBD_CCMD_KBD_ENABLE); /* * Reset keyboard. If the read times out @@ -114,7 +124,7 @@ __initfunc(static char *initialize_kbd2(void)) * This defaults the keyboard to scan-code set 2. */ - kbd_write(KBD_DATA_REG, KBD_CMD_RESET); + init_write_output(KBD_CMD_RESET); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Keyboard reset failed, no ACK"; if (kbd_wait_for_input() != KBD_REPLY_POR) @@ -125,17 +135,17 @@ __initfunc(static char *initialize_kbd2(void)) * in the disabled state. */ - kbd_write(KBD_DATA_REG, KBD_CMD_DISABLE); + init_write_output(KBD_CMD_DISABLE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Disable keyboard: no ACK"; - kbd_write(KBD_CNTL_REG, KBD_CCMD_WRITE_MODE); - kbd_write(KBD_DATA_REG, KBD_MODE_KBD_INT + init_write_command(KBD_CCMD_WRITE_MODE); + init_write_output(KBD_MODE_KBD_INT | KBD_MODE_SYS | KBD_MODE_DISABLE_MOUSE | KBD_MODE_KCC); - kbd_write(KBD_DATA_REG, KBD_CMD_ENABLE); + init_write_output(KBD_CMD_ENABLE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Enable keyboard: no ACK"; @@ -143,10 +153,10 @@ __initfunc(static char *initialize_kbd2(void)) * Finally, set the typematic rate to maximum. */ - kbd_write(KBD_DATA_REG, KBD_CMD_SET_RATE); + init_write_output(KBD_CMD_SET_RATE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Set rate: no ACK"; - kbd_write(KBD_DATA_REG, 0x00); + init_write_output(0x00); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Set rate: no ACK"; @@ -184,7 +194,7 @@ static inline void kb_wait(void) int i; for (i=0; i<KBD_TIMEOUT; i++) - if (! (kbd_inb_p(KBD_STATUS_REG) & KBD_STAT_IBF)) + if (! (kbd_read_status() & KBD_STAT_IBF)) return; printk(KERN_WARNING "Keyboard timed out\n"); } @@ -329,7 +339,7 @@ int pckbd_getkeycode(unsigned int scancode) static inline void send_cmd(unsigned char c) { kb_wait(); - kbd_outb(c, KBD_CNTL_REG); + kbd_write_command(c); } #define disable_keyboard() do { send_cmd(KBD_CCMD_KBD_DISABLE); kb_wait(); } while (0) @@ -490,7 +500,7 @@ static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs) kbd_pt_regs = regs; disable_keyboard(); - status = kbd_inb_p(KBD_STATUS_REG); + status = kbd_read_status(); do { unsigned char scancode; @@ -498,11 +508,11 @@ static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (status & kbd_read_mask & KBD_STAT_MOUSE_OBF) break; - scancode = kbd_inb(KBD_DATA_REG); + scancode = kbd_read_input(); if ((status & KBD_STAT_OBF) && do_acknowledge(scancode)) handle_scancode(scancode); - status = kbd_inb(KBD_STATUS_REG); + status = kbd_read_status(); } while (status & (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)); mark_bh(KEYBOARD_BH); @@ -524,9 +534,10 @@ static int send_data(unsigned char data) acknowledge = 0; resend = 0; reply_expected = 1; - kbd_outb_p(data, KBD_DATA_REG); + kbd_write_output(data); + kbd_pause(); for(i=0; i<0x200000; i++) { - kbd_inb_p(KBD_STATUS_REG); /* just as a delay */ + kbd_read_status(); /* just as a delay */ if (acknowledge) return 1; if (resend) diff --git a/drivers/char/psaux.c b/drivers/char/psaux.c index eea857b8a..d329a6883 100644 --- a/drivers/char/psaux.c +++ b/drivers/char/psaux.c @@ -28,6 +28,8 @@ * * Fixed keyboard lockups at open time * 3-Jul-96, 22-Aug-96 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> + * + * Cleanup by Martin Mares, 01-Jun-97 (now uses the new PC kbd include) */ /* Uncomment the following line if your mouse needs initialization. */ @@ -36,7 +38,6 @@ #include <linux/module.h> -#include <linux/config.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/interrupt.h> @@ -53,140 +54,115 @@ #include <asm/uaccess.h> #include <asm/system.h> -#include "pc_keyb.h" - -#ifdef CONFIG_SGI -#include <asm/segment.h> -#include <asm/sgihpc.h> -#endif - -#define PSMOUSE_MINOR 1 /* minor device # for this mouse */ - -/* aux controller ports */ -#define AUX_INPUT_PORT 0x60 /* Aux device output buffer */ -#define AUX_OUTPUT_PORT 0x60 /* Aux device input buffer */ -#define AUX_COMMAND 0x64 /* Aux device command buffer */ -#define AUX_STATUS 0x64 /* Aux device status reg */ - -/* aux controller status bits */ -#define AUX_OBUF_FULL 0x21 /* output buffer (from device) full */ -#define AUX_IBUF_FULL 0x02 /* input buffer (to device) full */ +#include <linux/config.h> -/* aux controller commands */ -#define AUX_CMD_WRITE 0x60 /* value to write to controller */ -#define AUX_MAGIC_WRITE 0xd4 /* value to send aux device data */ +#include "pc_keyb.h" -#define AUX_INTS_ON 0x47 /* enable controller interrupts */ -#define AUX_INTS_OFF 0x65 /* disable controller interrupts */ +#include <asm/keyboard.h> -#define AUX_DISABLE 0xa7 /* disable aux */ -#define AUX_ENABLE 0xa8 /* enable aux */ +/* + * Generic declarations for both PS2 and 82C710 + */ +#define PSMOUSE_MINOR 1 /* minor device # for this mouse */ -#define MAX_RETRIES 60 /* some aux operations take long time*/ -#if defined(__alpha__) && !defined(CONFIG_PCI) -# define AUX_IRQ 9 /* Jensen is odd indeed */ -#else -# define AUX_IRQ 12 -#endif #define AUX_BUF_SIZE 2048 -#ifdef CONFIG_SGI -extern volatile struct hpc_keyb *sgi_kh; /* see keyboard.c */ +struct aux_queue { + unsigned long head; + unsigned long tail; + struct wait_queue *proc_list; + struct fasync_struct *fasync; + unsigned char buf[AUX_BUF_SIZE]; +}; -extern __inline__ int -ps2_inb_p(unsigned short port) -{ - int result; +static struct aux_queue *queue; +static int aux_ready = 0; +static int aux_count = 0; +static int aux_present = 0; - if(port == AUX_INPUT_PORT) - result = sgi_kh->data; - else if(port == AUX_STATUS) - result = sgi_kh->command; - return result; -} +/* + * Shared subroutines + */ -extern __inline__ int -ps2_inb(unsigned short port) +static unsigned int get_from_queue(void) { - int result; - - if(port == AUX_INPUT_PORT) - result = sgi_kh->data; - else if(port == AUX_STATUS) - result = sgi_kh->command; + unsigned int result; + unsigned long flags; + save_flags(flags); + cli(); + result = queue->buf[queue->tail]; + queue->tail = (queue->tail + 1) & (AUX_BUF_SIZE-1); + restore_flags(flags); return result; } -extern __inline__ void -ps2_outb_p(unsigned char data, unsigned short port) -{ - if(port == AUX_OUTPUT_PORT) - sgi_kh->data = data; - else if(port == AUX_COMMAND) - sgi_kh->command = data; -} -extern __inline__ void -ps2_outb(unsigned char data, unsigned short port) +static inline int queue_empty(void) { - if(port == AUX_OUTPUT_PORT) - sgi_kh->data = data; - else if(port == AUX_COMMAND) - sgi_kh->command = data; + return queue->head == queue->tail; } -#else -#define ps2_inb_p inb_p -#define ps2_inb inb -#define ps2_outb_p outb_p -#define ps2_outb outb -#endif - -/* 82C710 definitions */ -#define QP_DATA 0x310 /* Data Port I/O Address */ -#define QP_STATUS 0x311 /* Status Port I/O Address */ +static int fasync_aux(struct inode *inode, struct file *filp, int on) +{ + int retval; -#define QP_DEV_IDLE 0x01 /* Device Idle */ -#define QP_RX_FULL 0x02 /* Device Char received */ -#define QP_TX_IDLE 0x04 /* Device XMIT Idle */ -#define QP_RESET 0x08 /* Device Reset */ -#define QP_INTS_ON 0x10 /* Device Interrupt On */ -#define QP_ERROR_FLAG 0x20 /* Device Error */ -#define QP_CLEAR 0x40 /* Device Clear */ -#define QP_ENABLE 0x80 /* Device Enable */ + retval = fasync_helper(inode, filp, on, &queue->fasync); + if (retval < 0) + return retval; + return 0; +} -#define QP_IRQ 12 +/* + * PS/2 Aux Device + */ -extern unsigned char aux_device_present; -extern unsigned char kbd_read_mask; /* from keyboard.c */ +#define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT) +#define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) -struct aux_queue { - unsigned long head; - unsigned long tail; - struct wait_queue *proc_list; - struct fasync_struct *fasync; - unsigned char buf[AUX_BUF_SIZE]; -}; +#define MAX_RETRIES 60 /* some aux operations take long time*/ -static struct aux_queue *queue; -static int aux_ready = 0; -static int aux_count = 0; -static int aux_present = 0; -static int poll_aux_status(void); -static int poll_aux_status_nosleep(void); -static int fasync_aux(struct inode *inode, struct file *filp, int on); +/* + * Status polling + */ -#ifdef CONFIG_82C710_MOUSE -static int qp_present = 0; -static int qp_count = 0; -static int qp_data = QP_DATA; -static int qp_status = QP_STATUS; +static int poll_aux_status(void) +{ + int retries=0; + unsigned char status; -static int poll_qp_status(void); -static int probe_qp(void); -#endif + while ((kbd_read_status() & 0x03) && retries < MAX_RETRIES) { + status = kbd_read_status(); + kbd_pause(); + if ((status & AUX_STAT_OBF) == AUX_STAT_OBF) { + kbd_read_input(); + kbd_pause(); + } + current->state = TASK_INTERRUPTIBLE; + current->timeout = jiffies + (5*HZ + 99) / 100; + schedule(); + retries++; + } + return !(retries==MAX_RETRIES); +} +static int poll_aux_status_nosleep(void) +{ + int retries = 0; + unsigned char status; + + while ((kbd_read_status() & (KBD_STAT_IBF | KBD_STAT_OBF)) + && retries < 1000000) { + status = kbd_read_status(); + kbd_pause(); + if ((status & AUX_STAT_OBF) == AUX_STAT_OBF) { + kbd_read_input(); + kbd_pause(); + } + retries++; + } + return !(retries == 1000000); +} /* * Write to aux device @@ -195,9 +171,9 @@ static int probe_qp(void); static void aux_write_dev(int val) { poll_aux_status(); - ps2_outb_p(AUX_MAGIC_WRITE,AUX_COMMAND); /* write magic cookie */ + kbd_write_command(KBD_CCMD_WRITE_MOUSE); /* Write magic cookie */ poll_aux_status(); - ps2_outb_p(val,AUX_OUTPUT_PORT); /* write data */ + kbd_write_output(val); /* Write data */ } /* @@ -208,24 +184,19 @@ static void aux_write_dev(int val) __initfunc(static void aux_write_dev_nosleep(int val)) { poll_aux_status_nosleep(); - ps2_outb_p(KBD_CCMD_WRITE_MOUSE, KBD_CNTL_REG); + kbd_write_command(KBD_CCMD_WRITE_MOUSE); poll_aux_status_nosleep(); - ps2_outb_p(val, KBD_DATA_REG); + kbd_write_output(val); } -static int aux_write_ack(int val) +__initfunc(static int aux_write_ack(int val)) { - int retries = 0; - - poll_aux_status_nosleep(); - ps2_outb_p(AUX_MAGIC_WRITE,AUX_COMMAND); - poll_aux_status_nosleep(); - ps2_outb_p(val,AUX_OUTPUT_PORT); + aux_write_dev_nosleep(val); poll_aux_status_nosleep(); - if ((ps2_inb(AUX_STATUS) & AUX_OBUF_FULL) == AUX_OBUF_FULL) + if ((kbd_read_status() & AUX_STAT_OBF) == AUX_STAT_OBF) { - return (ps2_inb(AUX_INPUT_PORT)); + return kbd_read_input(); } return 0; } @@ -238,38 +209,15 @@ static int aux_write_ack(int val) static void aux_write_cmd(int val) { poll_aux_status(); - ps2_outb_p(AUX_CMD_WRITE,AUX_COMMAND); + kbd_write_command(KBD_CCMD_WRITE_MODE); poll_aux_status(); - ps2_outb_p(val,AUX_OUTPUT_PORT); + kbd_write_output(val); } - -static unsigned int get_from_queue(void) -{ - unsigned int result; - unsigned long flags; - - save_flags(flags); - cli(); - result = queue->buf[queue->tail]; - queue->tail = (queue->tail + 1) & (AUX_BUF_SIZE-1); - restore_flags(flags); - return result; -} - - -static inline int queue_empty(void) -{ - return queue->head == queue->tail; -} - - - /* * Interrupt from the auxiliary device: a character * is waiting in the keyboard/aux controller. */ - #ifdef CONFIG_SGI /* On the SGI we export this routine because the keyboard chirps at * the same interrupt level. The status and data bytes are passed @@ -282,7 +230,7 @@ void aux_interrupt(unsigned char status, unsigned char data) int head = queue->head; int maxhead = (queue->tail-1) & (AUX_BUF_SIZE-1); - if ((status & AUX_OBUF_FULL) != AUX_OBUF_FULL) + if ((status & AUX_STAT_OBF) != AUX_STAT_OBF) return; add_mouse_randomness(queue->buf[head] = data); @@ -304,10 +252,10 @@ static void aux_interrupt(int cpl, void *dev_id, struct pt_regs * regs) int head = queue->head; int maxhead = (queue->tail-1) & (AUX_BUF_SIZE-1); - if ((ps2_inb(AUX_STATUS) & AUX_OBUF_FULL) != AUX_OBUF_FULL) + if ((kbd_read_status() & AUX_STAT_OBF) != AUX_STAT_OBF) return; - add_mouse_randomness(queue->buf[head] = ps2_inb(AUX_INPUT_PORT)); + add_mouse_randomness(queue->buf[head] = kbd_read_input()); if (head != maxhead) { head++; head &= AUX_BUF_SIZE-1; @@ -320,31 +268,6 @@ static void aux_interrupt(int cpl, void *dev_id, struct pt_regs * regs) } #endif /* !defined(CONFIG_SGI) */ -/* - * Interrupt handler for the 82C710 mouse port. A character - * is waiting in the 82C710. - */ - -#ifdef CONFIG_82C710_MOUSE -static void qp_interrupt(int cpl, void *dev_id, struct pt_regs * regs) -{ - int head = queue->head; - int maxhead = (queue->tail-1) & (AUX_BUF_SIZE-1); - - add_mouse_randomness(queue->buf[head] = ps2_inb(qp_data)); - if (head != maxhead) { - head++; - head &= AUX_BUF_SIZE-1; - } - queue->head = head; - aux_ready = 1; - if (queue->fasync) - kill_fasync(queue->fasync, SIGIO); - wake_up_interruptible(&queue->proc_list); -} -#endif - - static int release_aux(struct inode * inode, struct file * file) { fasync_aux(inode, file, 0); @@ -352,57 +275,17 @@ static int release_aux(struct inode * inode, struct file * file) return 0; /* disable kbd bh to avoid mixing of cmd bytes */ disable_bh(KEYBOARD_BH); - aux_write_cmd(AUX_INTS_OFF); /* disable controller ints */ + aux_write_cmd(AUX_INTS_OFF); /* Disable controller ints */ poll_aux_status(); - ps2_outb_p(AUX_DISABLE,AUX_COMMAND); /* Disable Aux device */ + kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable Aux device */ poll_aux_status(); /* reenable kbd bh */ enable_bh(KEYBOARD_BH); -#ifdef CONFIG_MCA - free_irq(AUX_IRQ, inode); -#else -#ifndef CONFIG_SGI - free_irq(AUX_IRQ, NULL); -#endif -#endif + ps2_free_irq(inode); MOD_DEC_USE_COUNT; return 0; } -#ifdef CONFIG_82C710_MOUSE -static int release_qp(struct inode * inode, struct file * file) -{ - unsigned char status; - - fasync_aux(inode, file, 0); - if (!--qp_count) { - if (!poll_qp_status()) - printk("Warning: Mouse device busy in release_qp()\n"); - status = ps2_inb_p(qp_status); - ps2_outb_p(status & ~(QP_ENABLE|QP_INTS_ON), qp_status); - if (!poll_qp_status()) - printk("Warning: Mouse device busy in release_qp()\n"); - free_irq(QP_IRQ, NULL); - MOD_DEC_USE_COUNT; - } - return 0; -} -#endif - -static int fasync_aux(struct inode *inode, struct file *filp, int on) -{ - int retval; - - retval = fasync_helper(inode, filp, on, &queue->fasync); - if (retval < 0) - return retval; - return 0; -} - -/* - * Install interrupt handler. - * Enable auxiliary device. - */ static int open_aux(struct inode * inode, struct file * file) { @@ -415,14 +298,7 @@ static int open_aux(struct inode * inode, struct file * file) return -EBUSY; } queue->head = queue->tail = 0; /* Flush input queue */ -#ifdef CONFIG_MCA - if (request_irq(AUX_IRQ, aux_interrupt, MCA_bus ? SA_SHIRQ : 0, "PS/2 Mouse", inode)) -#else -#ifndef CONFIG_SGI - if (request_irq(AUX_IRQ, aux_interrupt, 0, "PS/2 Mouse", NULL)) -#endif -#endif - { + if(ps2_request_irq()) { aux_count--; return -EBUSY; } @@ -430,9 +306,9 @@ static int open_aux(struct inode * inode, struct file * file) /* disable kbd bh to avoid mixing of cmd bytes */ disable_bh(KEYBOARD_BH); poll_aux_status(); - ps2_outb_p(AUX_ENABLE,AUX_COMMAND); /* Enable Aux */ - aux_write_dev(AUX_ENABLE_DEV); /* enable aux device */ - aux_write_cmd(AUX_INTS_ON); /* enable controller ints */ + kbd_write_command(KBD_CCMD_MOUSE_ENABLE); /* Enable Aux */ + aux_write_dev(AUX_ENABLE_DEV); /* Enable aux device */ + aux_write_cmd(AUX_INTS_ON); /* Enable controller ints */ poll_aux_status(); /* reenable kbd bh */ enable_bh(KEYBOARD_BH); @@ -441,7 +317,112 @@ static int open_aux(struct inode * inode, struct file * file) return 0; } +/* + * Write to the aux device. + */ + +static long write_aux(struct inode * inode, struct file * file, + const char * buffer, unsigned long count) +{ + int retval = 0; + + if (count) { + int written = 0; + + /* disable kbd bh to avoid mixing of cmd bytes */ + disable_bh(KEYBOARD_BH); + + do { + char c; + if (!poll_aux_status()) + break; + kbd_write_command(KBD_CCMD_WRITE_MOUSE); + if (!poll_aux_status()) + break; + get_user(c, buffer++); + kbd_write_output(c); + written++; + } while (--count); + /* reenable kbd bh */ + enable_bh(KEYBOARD_BH); + retval = -EIO; + if (written) { + retval = written; + inode->i_mtime = CURRENT_TIME; + } + } + + return retval; +} + +/* + * 82C710 Interface + */ + #ifdef CONFIG_82C710_MOUSE + +#define QP_DATA 0x310 /* Data Port I/O Address */ +#define QP_STATUS 0x311 /* Status Port I/O Address */ + +#define QP_DEV_IDLE 0x01 /* Device Idle */ +#define QP_RX_FULL 0x02 /* Device Char received */ +#define QP_TX_IDLE 0x04 /* Device XMIT Idle */ +#define QP_RESET 0x08 /* Device Reset */ +#define QP_INTS_ON 0x10 /* Device Interrupt On */ +#define QP_ERROR_FLAG 0x20 /* Device Error */ +#define QP_CLEAR 0x40 /* Device Clear */ +#define QP_ENABLE 0x80 /* Device Enable */ + +#define QP_IRQ 12 + +static int qp_present = 0; +static int qp_count = 0; +static int qp_data = QP_DATA; +static int qp_status = QP_STATUS; + +static int poll_qp_status(void); +static int probe_qp(void); + +/* + * Interrupt handler for the 82C710 mouse port. A character + * is waiting in the 82C710. + */ + +static void qp_interrupt(int cpl, void *dev_id, struct pt_regs * regs) +{ + int head = queue->head; + int maxhead = (queue->tail-1) & (AUX_BUF_SIZE-1); + + add_mouse_randomness(queue->buf[head] = inb(qp_data)); + if (head != maxhead) { + head++; + head &= AUX_BUF_SIZE-1; + } + queue->head = head; + aux_ready = 1; + if (queue->fasync) + kill_fasync(queue->fasync, SIGIO); + wake_up_interruptible(&queue->proc_list); +} + +static int release_qp(struct inode * inode, struct file * file) +{ + unsigned char status; + + fasync_aux(inode, file, 0); + if (!--qp_count) { + if (!poll_qp_status()) + printk("Warning: Mouse device busy in release_qp()\n"); + status = inb_p(qp_status); + outb_p(status & ~(QP_ENABLE|QP_INTS_ON), qp_status); + if (!poll_qp_status()) + printk("Warning: Mouse device busy in release_qp()\n"); + free_irq(QP_IRQ, NULL); + MOD_DEC_USE_COUNT; + } + return 0; +} + /* * Install interrupt handler. * Enable the device, enable interrupts. @@ -462,71 +443,30 @@ static int open_qp(struct inode * inode, struct file * file) return -EBUSY; } - status = ps2_inb_p(qp_status); + status = inb_p(qp_status); status |= (QP_ENABLE|QP_RESET); - ps2_outb_p(status, qp_status); + outb_p(status, qp_status); status &= ~(QP_RESET); - ps2_outb_p(status, qp_status); + outb_p(status, qp_status); queue->head = queue->tail = 0; /* Flush input queue */ status |= QP_INTS_ON; - ps2_outb_p(status, qp_status); /* Enable interrupts */ + outb_p(status, qp_status); /* Enable interrupts */ while (!poll_qp_status()) { printk("Error: Mouse device busy in open_qp()\n"); qp_count--; status &= ~(QP_ENABLE|QP_INTS_ON); - ps2_outb_p(status, qp_status); + outb_p(status, qp_status); free_irq(QP_IRQ, NULL); return -EBUSY; } - ps2_outb_p(AUX_ENABLE_DEV, qp_data); /* Wake up mouse */ + outb_p(AUX_ENABLE_DEV, qp_data); /* Wake up mouse */ MOD_INC_USE_COUNT; return 0; } -#endif - -/* - * Write to the aux device. - */ - -static long write_aux(struct inode * inode, struct file * file, - const char * buffer, unsigned long count) -{ - int retval = 0; - - if (count) { - int written = 0; - - /* disable kbd bh to avoid mixing of cmd bytes */ - disable_bh(KEYBOARD_BH); - - do { - char c; - if (!poll_aux_status()) - break; - ps2_outb_p(AUX_MAGIC_WRITE,AUX_COMMAND); - if (!poll_aux_status()) - break; - get_user(c, buffer++); - ps2_outb_p(c, AUX_OUTPUT_PORT); - written++; - } while (--count); - /* reenable kbd bh */ - enable_bh(KEYBOARD_BH); - retval = -EIO; - if (written) { - retval = written; - inode->i_mtime = CURRENT_TIME; - } - } - - return retval; -} - -#ifdef CONFIG_82C710_MOUSE /* * Write to the 82C710 mouse device. */ @@ -541,13 +481,69 @@ static long write_qp(struct inode * inode, struct file * file, if (!poll_qp_status()) return -EIO; get_user(c, buffer++); - ps2_outb_p(c, qp_data); + outb_p(c, qp_data); } inode->i_mtime = CURRENT_TIME; return count; } + +/* + * Wait for device to send output char and flush any input char. + */ + +static int poll_qp_status(void) +{ + int retries=0; + + while ((inb(qp_status)&(QP_RX_FULL|QP_TX_IDLE|QP_DEV_IDLE)) + != (QP_DEV_IDLE|QP_TX_IDLE) + && retries < MAX_RETRIES) { + + if (inb_p(qp_status)&(QP_RX_FULL)) + inb_p(qp_data); + current->state = TASK_INTERRUPTIBLE; + current->timeout = jiffies + (5*HZ + 99) / 100; + schedule(); + retries++; + } + return !(retries==MAX_RETRIES); +} + +/* + * Function to read register in 82C710. + */ + +static inline unsigned char read_710(unsigned char index) +{ + outb_p(index, 0x390); /* Write index */ + return inb_p(0x391); /* Read the data */ +} + +/* + * See if we can find a 82C710 device. Read mouse address. + */ + +__initfunc(static int probe_qp(void)) +{ + outb_p(0x55, 0x2fa); /* Any value except 9, ff or 36 */ + outb_p(0xaa, 0x3fa); /* Inverse of 55 */ + outb_p(0x36, 0x3fa); /* Address the chip */ + outb_p(0xe4, 0x3fa); /* 390/4; 390 = config address */ + outb_p(0x1b, 0x2fa); /* Inverse of e4 */ + if (read_710(0x0f) != 0xe4) /* Config address found? */ + return 0; /* No: no 82C710 here */ + qp_data = read_710(0x0d)*4; /* Get mouse I/O address */ + qp_status = qp_data+1; + outb_p(0x0f, 0x390); + outb_p(0x0f, 0x391); /* Close config mode */ + return 1; +} + #endif +/* + * Generic part continues... + */ /* * Put bytes from input queue to buffer. @@ -588,7 +584,6 @@ repeat: return 0; } - static unsigned int aux_poll(struct file *file, poll_table * wait) { poll_wait(&queue->proc_list, wait); @@ -597,7 +592,6 @@ static unsigned int aux_poll(struct file *file, poll_table * wait) return 0; } - struct file_operations psaux_fops = { NULL, /* seek */ read_aux, @@ -612,7 +606,6 @@ struct file_operations psaux_fops = { fasync_aux, }; - /* * Initialize driver. First check for a 82C710 chip; if found * forget about the Aux port and use the *_qp functions. @@ -643,7 +636,7 @@ __initfunc(int psaux_init(void)) printk(KERN_INFO "PS/2 auxiliary pointing device detected -- driver installed.\n"); aux_present = 1; #ifdef CONFIG_VT - kbd_read_mask = AUX_OBUF_FULL; + kbd_read_mask = AUX_STAT_OBF; #endif } else { return -EIO; @@ -654,8 +647,8 @@ __initfunc(int psaux_init(void)) queue->head = queue->tail = 0; queue->proc_list = NULL; if (!qp_found) { -#if defined INITIALIZE_DEVICE - ps2_outb_p(AUX_ENABLE,AUX_COMMAND); /* Enable Aux */ +#ifdef INITIALIZE_DEVICE + kbd_write_command(AUX_ENABLE); /* Enable Aux */ aux_write_ack(AUX_SET_SAMPLE); aux_write_ack(100); /* 100 samples/sec */ aux_write_ack(AUX_SET_RES); @@ -663,11 +656,11 @@ __initfunc(int psaux_init(void)) aux_write_ack(AUX_SET_SCALE21); /* 2:1 scaling */ poll_aux_status_nosleep(); #endif /* INITIALIZE_DEVICE */ - ps2_outb_p(KBD_CCMD_MOUSE_DISABLE, AUX_COMMAND); /* Disable Aux device */ - poll_aux_status_nosleep(); - ps2_outb_p(KBD_CCMD_WRITE_MODE, AUX_COMMAND); + kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable Aux device */ poll_aux_status_nosleep(); - ps2_outb_p(AUX_INTS_OFF, AUX_OUTPUT_PORT); + kbd_write_command(KBD_CCMD_WRITE_MODE); + poll_aux_status_nosleep(); /* Disable interrupts */ + kbd_write_output(AUX_INTS_OFF); /* on the controller */ } return 0; } @@ -675,7 +668,7 @@ __initfunc(int psaux_init(void)) #ifdef MODULE int init_module(void) { - return psaux_init(); /*?? Bjorn */ + return psaux_init(); } void cleanup_module(void) @@ -684,84 +677,3 @@ void cleanup_module(void) kfree(queue); } #endif - -static int poll_aux_status(void) -{ - int retries=0; - - while ((ps2_inb(AUX_STATUS)&0x03) && retries < MAX_RETRIES) { - if ((ps2_inb_p(AUX_STATUS) & AUX_OBUF_FULL) == AUX_OBUF_FULL) - ps2_inb_p(AUX_INPUT_PORT); - current->state = TASK_INTERRUPTIBLE; - current->timeout = jiffies + (5*HZ + 99) / 100; - schedule(); - retries++; - } - return !(retries==MAX_RETRIES); -} - -static int poll_aux_status_nosleep(void) -{ - int retries = 0; - - while ((ps2_inb(AUX_STATUS)&0x03) && retries < 1000000) { - if ((ps2_inb_p(AUX_STATUS) & AUX_OBUF_FULL) == AUX_OBUF_FULL) - ps2_inb_p(AUX_INPUT_PORT); - retries++; - } - return !(retries == 1000000); -} - -#ifdef CONFIG_82C710_MOUSE -/* - * Wait for device to send output char and flush any input char. - */ - -static int poll_qp_status(void) -{ - int retries=0; - - while ((ps2_inb(qp_status)&(QP_RX_FULL|QP_TX_IDLE|QP_DEV_IDLE)) - != (QP_DEV_IDLE|QP_TX_IDLE) - && retries < MAX_RETRIES) { - - if (ps2_inb_p(qp_status)&(QP_RX_FULL)) - ps2_inb_p(qp_data); - current->state = TASK_INTERRUPTIBLE; - current->timeout = jiffies + (5*HZ + 99) / 100; - schedule(); - retries++; - } - return !(retries==MAX_RETRIES); -} - -/* - * Function to read register in 82C710. - */ - -static inline unsigned char read_710(unsigned char index) -{ - ps2_outb_p(index, 0x390); /* Write index */ - return ps2_inb_p(0x391); /* Read the data */ -} - -/* - * See if we can find a 82C710 device. Read mouse address. - */ - -__initfunc(static int probe_qp(void)) -{ - ps2_outb_p(0x55, 0x2fa); /* Any value except 9, ff or 36 */ - ps2_outb_p(0xaa, 0x3fa); /* Inverse of 55 */ - ps2_outb_p(0x36, 0x3fa); /* Address the chip */ - ps2_outb_p(0xe4, 0x3fa); /* 390/4; 390 = config address */ - ps2_outb_p(0x1b, 0x2fa); /* Inverse of e4 */ - if (read_710(0x0f) != 0xe4) /* Config address found? */ - return 0; /* No: no 82C710 here */ - qp_data = read_710(0x0d)*4; /* Get mouse I/O address */ - qp_status = qp_data+1; - ps2_outb_p(0x0f, 0x390); - ps2_outb_p(0x0f, 0x391); /* Close config mode */ - return 1; -} -#endif diff --git a/include/asm-alpha/keyboard.h b/include/asm-alpha/keyboard.h index 3caa220eb..263cf8050 100644 --- a/include/asm-alpha/keyboard.h +++ b/include/asm-alpha/keyboard.h @@ -2,6 +2,8 @@ * linux/include/asm-alpha/keyboard.h * * Created 3 Nov 1996 by Geert Uytterhoeven + * + * $Id: keyboard.h,v 1.3 1997/07/22 23:18:14 ralf Exp $ */ /* @@ -13,6 +15,7 @@ #ifdef __KERNEL__ +#include <linux/config.h> #include <linux/ioport.h> #include <asm/io.h> @@ -45,15 +48,32 @@ extern void pckbd_init_hw(void); #define KBD_CNTL_REG (unsigned int) 0x64 #define KBD_DATA_REG (unsigned int) 0x60 -#define kbd_inb_p(port) inb_p(port) -#define kbd_inb(port) inb(port) -#define kbd_outb_p(data,port) outb_p(data,port) -#define kbd_outb(data,port) outb(data,port) +/* How to access the keyboard macros on this platform. */ +#define kbd_read_input() inb(KBD_DATA_REG) +#define kbd_read_status() inb(KBD_STATUS_REG) +#define kbd_write_output(val) outb(val, KBD_DATA_REG) +#define kbd_write_command(val) outb(val, KBD_CNTL_REG) + +/* Some stoneage hardware needs delays after some operations. */ +#define kbd_pause() do { } while(0) + +#define keyboard_setup() \ + request_region(0x60, 16, "keyboard") + +/* + * Machine specific bits for the PS/2 driver + */ + +#if defined(CONFIG_PCI) +#define AUX_IRQ 12 +#else +#define AUX_IRQ 9 /* Jensen is odd indeed */ +#endif + +#define ps2_request_irq() \ + request_irq(AUX_IRQ, aux_interrupt, 0, "PS/2 Mouse", NULL) -extern __inline__ void keyboard_setup() -{ - request_region(0x60,16,"keyboard"); -} +#define ps2_free_irq(inode) free_irq(AUX_IRQ, NULL) #endif /* __KERNEL__ */ #endif /* __ASM_ALPHA_KEYBOARD_H */ diff --git a/include/asm-i386/keyboard.h b/include/asm-i386/keyboard.h index 2ea9ce385..eaf0fa874 100644 --- a/include/asm-i386/keyboard.h +++ b/include/asm-i386/keyboard.h @@ -2,6 +2,8 @@ * linux/include/asm-i386/keyboard.h * * Created 3 Nov 1996 by Geert Uytterhoeven + * + * $Id: keyboard.h,v 1.4 1997/07/23 06:06:09 ralf Exp $ */ /* @@ -13,6 +15,8 @@ #ifdef __KERNEL__ +#include <linux/config.h> +#include <linux/kernel.h> #include <asm/io.h> #define KEYBOARD_IRQ 1 @@ -35,16 +39,42 @@ extern void pckbd_init_hw(void); #define kbd_leds pckbd_leds #define kbd_init_hw pckbd_init_hw -#define kbd_inb_p(port) inb_p(port) -#define kbd_inb(port) inb(port) -#define kbd_outb_p(data,port) outb_p(data,port) -#define kbd_outb(data,port) outb(data,port) +/* How to access the keyboard macros on this platform. */ +#define kbd_read_input() inb(KBD_DATA_REG) +#define kbd_read_status() inb(KBD_STATUS_REG) +#define kbd_write_output(val) outb(val, KBD_DATA_REG) +#define kbd_write_command(val) outb(val, KBD_CNTL_REG) + +/* Some stoneage hardware needs delays after some operations. */ +#define kbd_pause() do { SLOW_DOWN_IO; } while(0) + +#define keyboard_setup() \ + request_region(0x60, 16, "keyboard") + +/* + * Machine specific bits for the PS/2 driver + */ + +#define AUX_IRQ 12 + +#ifdef CONFIG_MCA + +#define ps2_request_irq() \ + request_irq(AUX_IRQ, aux_interrupt, MCA_bus ? SA_SHIRQ : 0, \ + "PS/2 Mouse", inode) + +#else /* !defined(CONFIG_MCA) */ + +#define ps2_request_irq() \ + request_irq(AUX_IRQ, aux_interrupt, 0, "PS/2 Mouse", NULL) + +#endif /* !defined(CONFIG_MCA) */ -extern __inline__ void -keyboard_setup() -{ - request_region(0x60,16,"keyboard"); -} +#ifdef CONFIG_MCA +#define ps2_free_irq(inode) free_irq(AUX_IRQ, inode) +#else +#define ps2_free_irq(inode) free_irq(AUX_IRQ, NULL) +#endif #endif /* __KERNEL__ */ #endif /* __ASM_i386_KEYBOARD_H */ diff --git a/include/asm-mips/keyboard.h b/include/asm-mips/keyboard.h index 1c746dc66..499024c3b 100644 --- a/include/asm-mips/keyboard.h +++ b/include/asm-mips/keyboard.h @@ -5,9 +5,7 @@ * 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. - * - * $Id:$ + * $Id: keyboard.h,v 1.5 1997/07/23 17:41:07 ralf Exp $ */ #ifndef __ASM_MIPS_KEYBOARD_H #define __ASM_MIPS_KEYBOARD_H @@ -17,6 +15,7 @@ #include <linux/config.h> #include <linux/delay.h> #include <linux/ioport.h> +#include <asm/bootinfo.h> extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode); extern int pckbd_getkeycode(unsigned int scancode); @@ -35,200 +34,72 @@ extern void pckbd_init_hw(void); #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 - * safe. But as that is the keyboard controller chip address, we do our - * slowdowns here by doing short jumps: the keyboard controller should - * be able to keep up - */ -#define REALLY_SLOW_IO -#define SLOW_IO_BY_JUMPING -#include <asm/io.h> +#define INIT_KBD /* full initialization for the keyboard controller. */ -/* - * keyboard controller registers - */ -#define M_KBD_STATUS_REG (unsigned int) 0x64 -#define M_KBD_CNTL_REG (unsigned int) 0x64 -#define M_KBD_DATA_REG (unsigned int) 0x60 +/* Some stoneage hardware needs delays after some operations. */ +#define kbd_pause() do { } while(0) -#ifdef CONFIG_SGI -#include <asm/segment.h> -#include <asm/sgihpc.h> -#endif -#include <asm/bootinfo.h> -#include <asm/jazz.h> +/* Pointers to keyboard hardware access and init functions. */ +unsigned char (*kbd_read_input)(void); +void (*kbd_write_output)(unsigned char val); +void (*kbd_write_command)(unsigned char val); +unsigned char (*kbd_read_status)(void); -#ifdef CONFIG_SGI -#define KEYBOARD_IRQ 20 -#else -/* Not true for Jazz machines, we cheat a bit for 'em. */ -#define KEYBOARD_IRQ 1 -#endif +void (*keyboard_setup)(void); -#ifdef CONFIG_SGI -#define DISABLE_KBD_DURING_INTERRUPTS 1 -#else -#define DISABLE_KBD_DURING_INTERRUPTS 0 -#endif +#ifdef CONFIG_MIPS_JAZZ -int (*kbd_inb_p)(unsigned short port); -int (*kbd_inb)(unsigned short port); -void (*kbd_outb_p)(unsigned char data, unsigned short port); -void (*kbd_outb)(unsigned char data, unsigned short port); +/* Not true for Jazz machines, we cheat a bit for 'em. */ +#define KEYBOARD_IRQ 1 -#ifdef CONFIG_MIPS_JAZZ -#define INIT_KBD /* full initialization for the keyboard controller. */ +/* + * No PS/2 style mouse support for Jazz machines + */ -static volatile keyboard_hardware *jazz_kh; - -static int -jazz_kbd_inb_p(unsigned short port) -{ - int result; - - if(port == M_KBD_DATA_REG) - result = jazz_kh->data; - else /* Must be M_KBD_STATUS_REG */ - result = jazz_kh->command; - inb(0x80); - - return result; -} - -static int -jazz_kbd_inb(unsigned short port) -{ - int result; - - if(port == M_KBD_DATA_REG) - result = jazz_kh->data; - else /* Must be M_KBD_STATUS_REG */ - result = jazz_kh->command; - - return result; -} - -static void -jazz_kbd_outb_p(unsigned char data, unsigned short port) -{ - if(port == M_KBD_DATA_REG) - jazz_kh->data = data; - else if(port == M_KBD_CNTL_REG) - jazz_kh->command = data; - inb(0x80); -} - -static void -jazz_kbd_outb(unsigned char data, unsigned short port) -{ - if(port == M_KBD_DATA_REG) - jazz_kh->data = data; - else if(port == M_KBD_CNTL_REG) - jazz_kh->command = data; -} #endif /* CONFIG_MIPS_JAZZ */ #ifdef CONFIG_SGI -#define INIT_KBD /* full initialization for the keyboard controller. */ + +#define DISABLE_KBD_DURING_INTERRUPTS 1 + +#define KEYBOARD_IRQ 20 /* - * Global because the PS/2 MOUSE driver accesses it also. + * Machine specific bits for the PS/2 driver. + * Aux device and keyboard share the interrupt on the Indy. */ -volatile struct hpc_keyb *sgi_kh; - -static int -sgi_kbd_inb(unsigned short port) -{ - int result; - - if(port == M_KBD_DATA_REG) - result = sgi_kh->data; - else /* Must be M_KBD_STATUS_REG */ - result = sgi_kh->command; - - return result; -} - -static void -sgi_kbd_outb(unsigned char data, unsigned short port) -{ - if(port == M_KBD_DATA_REG) - sgi_kh->data = data; - else if(port == M_KBD_CNTL_REG) - sgi_kh->command = data; -} + +#define ps2_request_irq() 0 +#define ps2_free_irq(void) do { } while(0); + #endif /* CONFIG_SGI */ +#if defined(CONFIG_ACER_PICA_61) || defined(CONFIG_SNI_RM200_PCI) \ + || defined(CONFIG_DESKSTATION_RPC44) || defined(CONFIG_DESKSTATION_TYNE) +#define CONF_KEYBOARD_USES_IO_PORTS +#endif + +#ifdef CONF_KEYBOARD_USES_IO_PORTS /* * Most other MIPS machines access the keyboard controller via - * ordinary I/O ports. + * memory mapped I/O ports. */ -static int -port_kbd_inb_p(unsigned short port) -{ - return inb_p(port); -} - -static int -port_kbd_inb(unsigned short port) -{ - return inb(port); -} - -static void -port_kbd_outb_p(unsigned char data, unsigned short port) -{ - return outb_p(data, port); -} - -static void -port_kbd_outb(unsigned char data, unsigned short port) -{ - return outb(data, port); -} - -extern __inline__ void keyboard_setup(void) -{ -#ifdef CONFIG_MIPS_JAZZ - if (mips_machgroup == MACH_GROUP_JAZZ) { - 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; - kbd_outb = jazz_kbd_outb; - /* - * Enable keyboard interrupts. - */ - *((volatile u16 *)JAZZ_IO_IRQ_ENABLE) |= JAZZ_IE_KEYBOARD; - set_cp0_status(IE_IRQ1, IE_IRQ1); - } else -#endif - if (mips_machgroup == MACH_GROUP_ARC || /* this is for Deskstation */ - (mips_machgroup == MACH_GROUP_SNI_RM - && mips_machtype == MACH_SNI_RM200_PCI)) { - /* - * These machines address their keyboard via the normal - * port address range. - * - * Also enable Scan Mode 2. - */ - kbd_inb_p = port_kbd_inb_p; - kbd_inb = port_kbd_inb; - kbd_outb_p = port_kbd_outb_p; - kbd_outb = port_kbd_outb; - request_region(0x60,16,"keyboard"); - } -#ifdef CONFIG_SGI - if (mips_machgroup == MACH_GROUP_SGI) { - sgi_kh = (struct hpc_keyb *) (KSEG1 + 0x1fbd9800 + 64); - kbd_inb_p = sgi_kbd_inb; - kbd_inb = sgi_kbd_inb; - kbd_outb_p = sgi_kbd_outb; - kbd_outb = sgi_kbd_outb; - } -#endif -} +#include <asm/io.h> + +#define KEYBOARD_IRQ 1 + +/* + * Machine specific bits for the PS/2 driver + */ + +#define AUX_IRQ 12 + +#define ps2_request_irq() \ + request_irq(AUX_IRQ, aux_interrupt, 0, "PS/2 Mouse", NULL) + +#define ps2_free_irq(inode) free_irq(AUX_IRQ, NULL) + +#endif /* CONF_KEYBOARD_USES_IO_PORTS */ #endif /* __KERNEL */ #endif /* __ASM_MIPS_KEYBOARD_H */ diff --git a/include/asm-ppc/keyboard.h b/include/asm-ppc/keyboard.h index 418476b2d..9ac4139b9 100644 --- a/include/asm-ppc/keyboard.h +++ b/include/asm-ppc/keyboard.h @@ -2,6 +2,8 @@ * linux/include/asm-ppc/keyboard.h * * Created 3 Nov 1996 by Geert Uytterhoeven + * + * $Id: keyboard.h,v 1.3 1997/07/22 23:18:19 ralf Exp $ */ /* @@ -13,6 +15,8 @@ #ifdef __KERNEL__ +#include <asm/io.h> + #define KEYBOARD_IRQ 1 #define DISABLE_KBD_DURING_INTERRUPTS 0 @@ -33,12 +37,33 @@ extern void pckbd_init_hw(void); #define kbd_leds pckbd_leds #define kbd_init_hw pckbd_init_hw +/* How to access the keyboard macros on this platform. */ +#define kbd_read_input() inb(KBD_DATA_REG) +#define kbd_read_status() inb(KBD_STATUS_REG) +#define kbd_write_output(val) outb(val, KBD_DATA_REG) +#define kbd_write_command(val) outb(val, KBD_CNTL_REG) + +/* Some stoneage hardware needs delays after some operations. */ +#define kbd_pause() do { } while(0) + #define INIT_KBD -extern __inline__ void keyboard_setup() -{ - request_region(0x60,16,"keyboard"); -} +#define keyboard_setup() \ + request_region(0x60, 16, "keyboard") + +/* + * Machine specific bits for the PS/2 driver + * + * FIXME: does any PPC machine use the PS/2 driver at all? If so, + * this should work, if not it's dead code ... + */ + +#define AUX_IRQ 12 + +#define ps2_request_irq() \ + request_irq(AUX_IRQ, aux_interrupt, 0, "PS/2 Mouse", NULL) + +#define ps2_free_irq(inode) free_irq(AUX_IRQ, NULL) #endif /* __KERNEL__ */ |