* better
[mascara-docs.git] / i386 / linux-2.3.21 / arch / mips / jazz / kbd-jazz.c
blob1dfed0384354b6e8245142f4d5508986bc9a4f6a
1 /* $Id: kbd-jazz.c,v 1.1 1998/10/28 12:38:10 ralf Exp $
3 * Low-level hardware access stuff for Jazz family machines.
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
9 * Copyright (C) 1995, 1996, 1997, 1998 by Ralf Baechle
11 #include <linux/sched.h>
12 #include <linux/pc_keyb.h>
13 #include <asm/keyboard.h>
14 #include <asm/jazz.h>
16 #define jazz_kh ((keyboard_hardware *) JAZZ_KEYBOARD_ADDRESS)
18 static void jazz_request_region(void)
20 /* No I/O ports are being used on Jazz. */
23 static int jazz_request_irq(void (*handler)(int, void *, struct pt_regs *))
25 int res;
27 res = request_irq(JAZZ_KEYBOARD_IRQ, handler, 0, "keyboard", NULL);
28 if (res != 0)
29 return res;
31 /* jazz_request_irq() should do this ... */
32 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE,
33 r4030_read_reg16(JAZZ_IO_IRQ_ENABLE)
34 | JAZZ_IE_KEYBOARD);
36 return 0;
39 static int jazz_aux_request_irq(void (*handler)(int, void *, struct pt_regs *))
41 int ret;
43 ret = request_irq(JAZZ_MOUSE_IRQ, handler, 0, "PS/2 Mouse", NULL);
44 if (ret != 0)
45 return ret;
47 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE,
48 r4030_read_reg16(JAZZ_IO_IRQ_ENABLE) |
49 JAZZ_IE_MOUSE);
50 return 0;
53 static void jazz_aux_free_irq(void)
55 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE,
56 r4030_read_reg16(JAZZ_IO_IRQ_ENABLE)
57 | JAZZ_IE_MOUSE);
58 free_irq(JAZZ_MOUSE_IRQ, NULL);
61 static unsigned char jazz_read_input(void)
63 return jazz_kh->data;
66 static void jazz_write_output(unsigned char val)
68 int status;
70 do {
71 status = jazz_kh->command;
72 } while (status & KBD_STAT_IBF);
73 jazz_kh->data = val;
76 static void jazz_write_command(unsigned char val)
78 int status;
80 do {
81 status = jazz_kh->command;
82 } while (status & KBD_STAT_IBF);
83 jazz_kh->command = val;
86 static unsigned char jazz_read_status(void)
88 return jazz_kh->command;
91 struct kbd_ops jazz_kbd_ops = {
92 jazz_request_region,
93 jazz_request_irq,
95 jazz_aux_request_irq,
96 jazz_aux_free_irq,
98 jazz_read_input,
99 jazz_write_output,
100 jazz_write_command,
101 jazz_read_status