MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / linux / serio.h
blobf84b362a561f330142e3af2473ec8e8c786569c9
1 #ifndef _SERIO_H
2 #define _SERIO_H
4 /*
5 * Copyright (C) 1999-2002 Vojtech Pavlik
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.
12 #include <linux/ioctl.h>
13 #include <linux/interrupt.h>
15 #define SPIOCSTYPE _IOW('q', 0x01, unsigned long)
17 #ifdef __KERNEL__
19 #include <linux/list.h>
20 #include <linux/spinlock.h>
21 #include <linux/device.h>
23 struct serio {
24 void *private;
25 void *port_data;
27 char name[32];
28 char phys[32];
30 unsigned int manual_bind;
32 unsigned short idbus;
33 unsigned short idvendor;
34 unsigned short idproduct;
35 unsigned short idversion;
37 unsigned long type;
38 unsigned long event;
40 spinlock_t lock; /* protects critical sections from port's interrupt handler */
42 int (*write)(struct serio *, unsigned char);
43 int (*open)(struct serio *);
44 void (*close)(struct serio *);
46 struct serio *parent, *child;
48 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock */
50 struct device dev;
52 struct list_head node;
54 #define to_serio_port(d) container_of(d, struct serio, dev)
56 struct serio_driver {
57 void *private;
58 char *description;
60 unsigned int manual_bind;
62 void (*write_wakeup)(struct serio *);
63 irqreturn_t (*interrupt)(struct serio *, unsigned char,
64 unsigned int, struct pt_regs *);
65 void (*connect)(struct serio *, struct serio_driver *drv);
66 int (*reconnect)(struct serio *);
67 void (*disconnect)(struct serio *);
68 void (*cleanup)(struct serio *);
70 struct device_driver driver;
72 struct list_head node;
74 #define to_serio_driver(d) container_of(d, struct serio_driver, driver)
76 int serio_open(struct serio *serio, struct serio_driver *drv);
77 void serio_close(struct serio *serio);
78 void serio_rescan(struct serio *serio);
79 void serio_reconnect(struct serio *serio);
80 irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs);
82 void serio_register_port(struct serio *serio);
83 void serio_register_port_delayed(struct serio *serio);
84 void serio_unregister_port(struct serio *serio);
85 void serio_unregister_port_delayed(struct serio *serio);
87 void serio_register_driver(struct serio_driver *drv);
88 void serio_unregister_driver(struct serio_driver *drv);
90 static __inline__ int serio_write(struct serio *serio, unsigned char data)
92 if (serio->write)
93 return serio->write(serio, data);
94 else
95 return -1;
98 static __inline__ void serio_drv_write_wakeup(struct serio *serio)
100 if (serio->drv && serio->drv->write_wakeup)
101 serio->drv->write_wakeup(serio);
104 static __inline__ void serio_cleanup(struct serio *serio)
106 if (serio->drv && serio->drv->cleanup)
107 serio->drv->cleanup(serio);
112 * Use the following fucntions to protect critical sections in
113 * driver code from port's interrupt handler
115 static __inline__ void serio_pause_rx(struct serio *serio)
117 spin_lock_irq(&serio->lock);
120 static __inline__ void serio_continue_rx(struct serio *serio)
122 spin_unlock_irq(&serio->lock);
126 #endif
129 * bit masks for use in "interrupt" flags (3rd argument)
131 #define SERIO_TIMEOUT 1
132 #define SERIO_PARITY 2
133 #define SERIO_FRAME 4
135 #define SERIO_TYPE 0xff000000UL
136 #define SERIO_XT 0x00000000UL
137 #define SERIO_8042 0x01000000UL
138 #define SERIO_RS232 0x02000000UL
139 #define SERIO_HIL_MLC 0x03000000UL
140 #define SERIO_PS_PSTHRU 0x05000000UL
141 #define SERIO_8042_XL 0x06000000UL
143 #define SERIO_PROTO 0xFFUL
144 #define SERIO_MSC 0x01
145 #define SERIO_SUN 0x02
146 #define SERIO_MS 0x03
147 #define SERIO_MP 0x04
148 #define SERIO_MZ 0x05
149 #define SERIO_MZP 0x06
150 #define SERIO_MZPP 0x07
151 #define SERIO_VSXXXAA 0x08
152 #define SERIO_SUNKBD 0x10
153 #define SERIO_WARRIOR 0x18
154 #define SERIO_SPACEORB 0x19
155 #define SERIO_MAGELLAN 0x1a
156 #define SERIO_SPACEBALL 0x1b
157 #define SERIO_GUNZE 0x1c
158 #define SERIO_IFORCE 0x1d
159 #define SERIO_STINGER 0x1e
160 #define SERIO_NEWTON 0x1f
161 #define SERIO_STOWAWAY 0x20
162 #define SERIO_H3600 0x21
163 #define SERIO_PS2SER 0x22
164 #define SERIO_TWIDKBD 0x23
165 #define SERIO_TWIDJOY 0x24
166 #define SERIO_HIL 0x25
167 #define SERIO_SNES232 0x26
168 #define SERIO_SEMTECH 0x27
169 #define SERIO_LKKBD 0x28
171 #define SERIO_ID 0xff00UL
172 #define SERIO_EXTRA 0xff0000UL
174 #endif