ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / serio.h
1 #ifndef _SERIO_H
2 #define _SERIO_H
3
4 /*
5  * Copyright (C) 1999-2002 Vojtech Pavlik
6 *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published by
9  * the Free Software Foundation.
10  */
11
12 #include <linux/ioctl.h>
13 #include <linux/interrupt.h>
14
15 #define SPIOCSTYPE      _IOW('q', 0x01, unsigned long)
16
17 #ifdef __KERNEL__
18
19 #include <linux/list.h>
20
21 struct serio {
22         void *private;
23         void *driver;
24         char *name;
25         char *phys;
26
27         unsigned short idbus;
28         unsigned short idvendor;
29         unsigned short idproduct;
30         unsigned short idversion;
31
32         unsigned long type;
33         unsigned long event;
34
35         int (*write)(struct serio *, unsigned char);
36         int (*open)(struct serio *);
37         void (*close)(struct serio *);
38
39         struct serio_dev *dev;
40
41         struct list_head node;
42 };
43
44 struct serio_dev {
45         void *private;
46         char *name;
47
48         void (*write_wakeup)(struct serio *);
49         irqreturn_t (*interrupt)(struct serio *, unsigned char,
50                         unsigned int, struct pt_regs *);
51         void (*connect)(struct serio *, struct serio_dev *dev);
52         int  (*reconnect)(struct serio *);
53         void (*disconnect)(struct serio *);
54         void (*cleanup)(struct serio *);
55
56         struct list_head node;
57 };
58
59 int serio_open(struct serio *serio, struct serio_dev *dev);
60 void serio_close(struct serio *serio);
61 void serio_rescan(struct serio *serio);
62 void serio_reconnect(struct serio *serio);
63 irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs);
64
65 void serio_register_port(struct serio *serio);
66 void serio_register_port_delayed(struct serio *serio);
67 void __serio_register_port(struct serio *serio);
68 void serio_unregister_port(struct serio *serio);
69 void serio_unregister_port_delayed(struct serio *serio);
70 void __serio_unregister_port(struct serio *serio);
71 void serio_register_device(struct serio_dev *dev);
72 void serio_unregister_device(struct serio_dev *dev);
73
74 static __inline__ int serio_write(struct serio *serio, unsigned char data)
75 {
76         if (serio->write)
77                 return serio->write(serio, data);
78         else
79                 return -1;
80 }
81
82 static __inline__ void serio_dev_write_wakeup(struct serio *serio)
83 {
84         if (serio->dev && serio->dev->write_wakeup)
85                 serio->dev->write_wakeup(serio);
86 }
87
88 static __inline__ void serio_cleanup(struct serio *serio)
89 {
90         if (serio->dev && serio->dev->cleanup)
91                 serio->dev->cleanup(serio);
92 }
93
94 #endif
95
96 /*
97  * bit masks for use in "interrupt" flags (3rd argument)
98  */
99 #define SERIO_TIMEOUT   1
100 #define SERIO_PARITY    2
101 #define SERIO_FRAME     4
102
103 #define SERIO_TYPE      0xff000000UL
104 #define SERIO_XT        0x00000000UL
105 #define SERIO_8042      0x01000000UL
106 #define SERIO_RS232     0x02000000UL
107 #define SERIO_HIL_MLC   0x03000000UL
108 #define SERIO_PC9800    0x04000000UL
109 #define SERIO_PS_PSTHRU 0x05000000UL
110 #define SERIO_8042_XL   0x06000000UL
111
112 #define SERIO_PROTO     0xFFUL
113 #define SERIO_MSC       0x01
114 #define SERIO_SUN       0x02
115 #define SERIO_MS        0x03
116 #define SERIO_MP        0x04
117 #define SERIO_MZ        0x05
118 #define SERIO_MZP       0x06
119 #define SERIO_MZPP      0x07
120 #define SERIO_VSXXXAA   0x08
121 #define SERIO_SUNKBD    0x10
122 #define SERIO_WARRIOR   0x18
123 #define SERIO_SPACEORB  0x19
124 #define SERIO_MAGELLAN  0x1a
125 #define SERIO_SPACEBALL 0x1b
126 #define SERIO_GUNZE     0x1c
127 #define SERIO_IFORCE    0x1d
128 #define SERIO_STINGER   0x1e
129 #define SERIO_NEWTON    0x1f
130 #define SERIO_STOWAWAY  0x20
131 #define SERIO_H3600     0x21
132 #define SERIO_PS2SER    0x22
133 #define SERIO_TWIDKBD   0x23
134 #define SERIO_TWIDJOY   0x24
135 #define SERIO_HIL       0x25
136 #define SERIO_SNES232   0x26
137 #define SERIO_SEMTECH   0x27
138 #define SERIO_LKKBD     0x28
139
140 #define SERIO_ID        0xff00UL
141 #define SERIO_EXTRA     0xff0000UL
142
143 #endif