1 /*
2  *	include/linux/pc_keyb.h
3  *
4  *	PC Keyboard And Keyboard Controller
5  *
6  *	(c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
7  */
8 
9 /*
10  *	Configuration Switches
11  */
12 #undef KBD_REPORT_ERR			/* Report keyboard errors */
13 #define KBD_REPORT_UNKN			/* Report unknown scan codes */
14 #define KBD_REPORT_TIMEOUTS		/* Report keyboard timeouts */
15 #undef KBD_IS_FOCUS_9000		/* We have the brain-damaged FOCUS-9000 keyboard */
16 #undef INITIALIZE_MOUSE			/* Define if your PS/2 mouse needs initialization. */
17 
18 #define KBD_INIT_TIMEOUT 1000		/* Timeout in ms for initializing the keyboard */
19 #define KBC_TIMEOUT 250			/* Timeout in ms for sending to keyboard controller */
20 #define KBD_TIMEOUT 1000		/* Timeout in ms for keyboard command acknowledge */
21 
22 /*
23  *	Internal variables of the driver
24  */
25 extern unsigned char pckbd_read_mask;
26 extern unsigned char aux_device_present;
27 
28 /*
29  *	Keyboard Controller Registers on normal PCs.
30  */
31 #define KBD_STATUS_REG		0x64	/* Status register (R) */
32 #define KBD_CNTL_REG		0x64	/* Controller command register (W) */
33 #define KBD_DATA_REG		0x60	/* Keyboard data register (R/W) */
34 
35 /*
36  *	Keyboard Controller Commands
37  */
38 #define KBD_CCMD_READ_MODE	0x20	/* Read mode bits */
39 #define KBD_CCMD_WRITE_MODE	0x60	/* Write mode bits */
40 #define KBD_CCMD_GET_VERSION	0xA1	/* Get controller version */
41 #define KBD_CCMD_MOUSE_DISABLE	0xA7	/* Disable mouse interface */
42 #define KBD_CCMD_MOUSE_ENABLE	0xA8	/* Enable mouse interface */
43 #define KBD_CCMD_TEST_MOUSE	0xA9	/* Mouse interface test */
44 #define KBD_CCMD_SELF_TEST	0xAA	/* Controller self test */
45 #define KBD_CCMD_KBD_TEST	0xAB	/* Keyboard interface test */
46 #define KBD_CCMD_KBD_DISABLE	0xAD	/* Keyboard interface disable */
47 #define KBD_CCMD_KBD_ENABLE	0xAE	/* Keyboard interface enable */
48 #define KBD_CCMD_WRITE_AUX_OBUF	0xD3    /* Write to output buffer as if
49 					   initiated by the auxiliary device */
50 #define KBD_CCMD_WRITE_MOUSE	0xD4	/* Write the following byte to the mouse */
51 
52 /*
53  *	Keyboard Commands
54  */
55 #define KBD_CMD_SET_LEDS	0xED	/* Set keyboard leds */
56 #define KBD_CMD_SET_RATE	0xF3	/* Set typematic rate */
57 #define KBD_CMD_ENABLE		0xF4	/* Enable scanning */
58 #define KBD_CMD_DISABLE		0xF5	/* Disable scanning */
59 #define KBD_CMD_RESET		0xFF	/* Reset */
60 
61 /*
62  *	Keyboard Replies
63  */
64 #define KBD_REPLY_POR		0xAA	/* Power on reset */
65 #define KBD_REPLY_ACK		0xFA	/* Command ACK */
66 #define KBD_REPLY_RESEND	0xFE	/* Command NACK, send the cmd again */
67 
68 /*
69  *	Status Register Bits
70  */
71 #define KBD_STAT_OBF		0x01	/* Keyboard output buffer full */
72 #define KBD_STAT_IBF		0x02	/* Keyboard input buffer full */
73 #define KBD_STAT_SELFTEST	0x04	/* Self test successful */
74 #define KBD_STAT_CMD		0x08	/* Last write was a command write (0=data) */
75 #define KBD_STAT_UNLOCKED	0x10	/* Zero if keyboard locked */
76 #define KBD_STAT_MOUSE_OBF	0x20	/* Mouse output buffer full */
77 #define KBD_STAT_GTO		0x40	/* General receive/xmit timeout */
78 #define KBD_STAT_PERR		0x80	/* Parity error */
79 
80 #define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
81 
82 /*
83  *	Controller Mode Register Bits
84  */
85 #define KBD_MODE_KBD_INT	0x01	/* Keyboard data generate IRQ1 */
86 #define KBD_MODE_MOUSE_INT	0x02	/* Mouse data generate IRQ12 */
87 #define KBD_MODE_SYS		0x04	/* The system flag (?) */
88 #define KBD_MODE_NO_KEYLOCK	0x08	/* The keylock doesn't affect the keyboard if set */
89 #define KBD_MODE_DISABLE_KBD	0x10	/* Disable keyboard interface */
90 #define KBD_MODE_DISABLE_MOUSE	0x20	/* Disable mouse interface */
91 #define KBD_MODE_KCC		0x40	/* Scan code conversion to PC format */
92 #define KBD_MODE_RFU		0x80
93 
94 /*
95  *	Mouse Commands
96  */
97 #define AUX_SET_RES		0xE8	/* Set resolution */
98 #define AUX_SET_SCALE11		0xE6	/* Set 1:1 scaling */
99 #define AUX_SET_SCALE21		0xE7	/* Set 2:1 scaling */
100 #define AUX_GET_SCALE		0xE9	/* Get scaling factor */
101 #define AUX_SET_STREAM		0xEA	/* Set stream mode */
102 #define AUX_SET_SAMPLE		0xF3	/* Set sample rate */
103 #define AUX_ENABLE_DEV		0xF4	/* Enable aux device */
104 #define AUX_DISABLE_DEV		0xF5	/* Disable aux device */
105 #define AUX_RESET		0xFF	/* Reset aux device */
106 #define AUX_ACK			0xFA	/* Command byte ACK. */
107 
108 #define AUX_BUF_SIZE		2048	/* This might be better divisible by
109 					   three to make overruns stay in sync
110 					   but then the read function would need
111 					   a lock etc - ick */
112 
113 #if 0
114 struct aux_queue {
115 	unsigned long head;
116 	unsigned long tail;
117 	wait_queue_head_t proc_list;
118 	struct fasync_struct *fasync;
119 	unsigned char buf[AUX_BUF_SIZE];
120 };
121 #endif
122