summaryrefslogtreecommitdiffstats
path: root/arch/mips/lib/kbd-std.c
blob: 8e7e69ecc1e754291c65868de3a841aa842ea8c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* $Id: kbd-std.c,v 1.2 1999/06/11 14:29:45 ralf Exp $
 *
 * 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.
 *
 * Routines for standard PC style keyboards accessible via I/O ports.
 *
 * Copyright (C) 1998, 1999 by Ralf Baechle
 */
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/pc_keyb.h>
#include <asm/keyboard.h>
#include <asm/io.h>

#define KEYBOARD_IRQ 1
#define AUX_IRQ 12

static void std_kbd_request_region(void)
{
	request_region(0x60, 16, "keyboard");
}

static int std_kbd_request_irq(void (*handler)(int, void *, struct pt_regs *))
{
	return request_irq(KEYBOARD_IRQ, handler, 0, "keyboard", NULL);
}

static int std_aux_request_irq(void (*handler)(int, void *, struct pt_regs *))
{
	return request_irq(AUX_IRQ, handler, 0, "PS/2 Mouse", NULL);
}

static void std_aux_free_irq(void)
{
	free_irq(AUX_IRQ, NULL);
}

static unsigned char std_kbd_read_input(void)
{
	return inb(KBD_DATA_REG);
}

static void std_kbd_write_output(unsigned char val)
{
	int status;

	do {
		status = inb(KBD_CNTL_REG);
	} while (status & KBD_STAT_IBF);
	outb(val, KBD_DATA_REG);
}

static void std_kbd_write_command(unsigned char val)
{
	int status;

	do {
		status = inb(KBD_CNTL_REG);
	} while (status & KBD_STAT_IBF);
	outb(val, KBD_CNTL_REG);
}

static unsigned char std_kbd_read_status(void)
{
	return inb(KBD_STATUS_REG);
}

struct kbd_ops std_kbd_ops = {
	std_kbd_request_region,
	std_kbd_request_irq,

	std_aux_request_irq,
	std_aux_free_irq,

	std_kbd_read_input,
	std_kbd_write_output,
	std_kbd_write_command,
	std_kbd_read_status
};