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)
19 #include <linux/list.h>
20 #include <linux/spinlock.h>
21 #include <linux/device.h>
30 unsigned int manual_bind;
33 unsigned short idvendor;
34 unsigned short idproduct;
35 unsigned short idversion;
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 and serio->sem */
49 struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */
53 struct list_head node;
55 #define to_serio_port(d) container_of(d, struct serio, dev)
61 unsigned int manual_bind;
63 void (*write_wakeup)(struct serio *);
64 irqreturn_t (*interrupt)(struct serio *, unsigned char,
65 unsigned int, struct pt_regs *);
66 void (*connect)(struct serio *, struct serio_driver *drv);
67 int (*reconnect)(struct serio *);
68 void (*disconnect)(struct serio *);
69 void (*cleanup)(struct serio *);
71 struct device_driver driver;
73 struct list_head node;
75 #define to_serio_driver(d) container_of(d, struct serio_driver, driver)
77 int serio_open(struct serio *serio, struct serio_driver *drv);
78 void serio_close(struct serio *serio);
79 void serio_rescan(struct serio *serio);
80 void serio_reconnect(struct serio *serio);
81 irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs);
83 void serio_register_port(struct serio *serio);
84 void serio_register_port_delayed(struct serio *serio);
85 void serio_unregister_port(struct serio *serio);
86 void serio_unregister_port_delayed(struct serio *serio);
88 void serio_register_driver(struct serio_driver *drv);
89 void serio_unregister_driver(struct serio_driver *drv);
91 static __inline__ int serio_write(struct serio *serio, unsigned char data)
94 return serio->write(serio, data);
99 static __inline__ void serio_drv_write_wakeup(struct serio *serio)
101 if (serio->drv && serio->drv->write_wakeup)
102 serio->drv->write_wakeup(serio);
105 static __inline__ void serio_cleanup(struct serio *serio)
107 if (serio->drv && serio->drv->cleanup)
108 serio->drv->cleanup(serio);
113 * Use the following fucntions to protect critical sections in
114 * driver code from port's interrupt handler
116 static __inline__ void serio_pause_rx(struct serio *serio)
118 spin_lock_irq(&serio->lock);
121 static __inline__ void serio_continue_rx(struct serio *serio)
123 spin_unlock_irq(&serio->lock);
127 * Use the following fucntions to pin serio's driver in process context
129 static __inline__ int serio_pin_driver(struct serio *serio)
131 return down_interruptible(&serio->drv_sem);
134 static __inline__ void serio_unpin_driver(struct serio *serio)
143 * bit masks for use in "interrupt" flags (3rd argument)
145 #define SERIO_TIMEOUT 1
146 #define SERIO_PARITY 2
147 #define SERIO_FRAME 4
149 #define SERIO_TYPE 0xff000000UL
150 #define SERIO_XT 0x00000000UL
151 #define SERIO_8042 0x01000000UL
152 #define SERIO_RS232 0x02000000UL
153 #define SERIO_HIL_MLC 0x03000000UL
154 #define SERIO_PS_PSTHRU 0x05000000UL
155 #define SERIO_8042_XL 0x06000000UL
157 #define SERIO_PROTO 0xFFUL
158 #define SERIO_MSC 0x01
159 #define SERIO_SUN 0x02
160 #define SERIO_MS 0x03
161 #define SERIO_MP 0x04
162 #define SERIO_MZ 0x05
163 #define SERIO_MZP 0x06
164 #define SERIO_MZPP 0x07
165 #define SERIO_VSXXXAA 0x08
166 #define SERIO_SUNKBD 0x10
167 #define SERIO_WARRIOR 0x18
168 #define SERIO_SPACEORB 0x19
169 #define SERIO_MAGELLAN 0x1a
170 #define SERIO_SPACEBALL 0x1b
171 #define SERIO_GUNZE 0x1c
172 #define SERIO_IFORCE 0x1d
173 #define SERIO_STINGER 0x1e
174 #define SERIO_NEWTON 0x1f
175 #define SERIO_STOWAWAY 0x20
176 #define SERIO_H3600 0x21
177 #define SERIO_PS2SER 0x22
178 #define SERIO_TWIDKBD 0x23
179 #define SERIO_TWIDJOY 0x24
180 #define SERIO_HIL 0x25
181 #define SERIO_SNES232 0x26
182 #define SERIO_SEMTECH 0x27
183 #define SERIO_LKKBD 0x28
185 #define SERIO_ID 0xff00UL
186 #define SERIO_EXTRA 0xff0000UL