jsm: Fixed EEH recovery error
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / serio.h
blobca82861b0e461d6798e6a05a977352dca24335e5
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>
14 #define SPIOCSTYPE _IOW('q', 0x01, unsigned long)
16 #ifdef __KERNEL__
18 #include <linux/types.h>
19 #include <linux/interrupt.h>
20 #include <linux/list.h>
21 #include <linux/spinlock.h>
22 #include <linux/mutex.h>
23 #include <linux/device.h>
24 #include <linux/mod_devicetable.h>
26 struct serio {
27 void *port_data;
29 char name[32];
30 char phys[32];
32 bool manual_bind;
34 struct serio_device_id id;
36 spinlock_t lock; /* protects critical sections from port's interrupt handler */
38 int (*write)(struct serio *, unsigned char);
39 int (*open)(struct serio *);
40 void (*close)(struct serio *);
41 int (*start)(struct serio *);
42 void (*stop)(struct serio *);
44 struct serio *parent;
45 struct list_head child_node; /* Entry in parent->children list */
46 struct list_head children;
47 unsigned int depth; /* level of nesting in serio hierarchy */
49 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
50 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
52 struct device dev;
54 struct list_head node;
56 #define to_serio_port(d) container_of(d, struct serio, dev)
58 struct serio_driver {
59 const char *description;
61 const struct serio_device_id *id_table;
62 bool manual_bind;
64 void (*write_wakeup)(struct serio *);
65 irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
66 int (*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 #define to_serio_driver(d) container_of(d, struct serio_driver, driver)
75 int serio_open(struct serio *serio, struct serio_driver *drv);
76 void serio_close(struct serio *serio);
77 void serio_rescan(struct serio *serio);
78 void serio_reconnect(struct serio *serio);
79 irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags);
81 void __serio_register_port(struct serio *serio, struct module *owner);
83 /* use a define to avoid include chaining to get THIS_MODULE */
84 #define serio_register_port(serio) \
85 __serio_register_port(serio, THIS_MODULE)
87 void serio_unregister_port(struct serio *serio);
88 void serio_unregister_child_port(struct serio *serio);
90 int __must_check __serio_register_driver(struct serio_driver *drv,
91 struct module *owner, const char *mod_name);
93 /* use a define to avoid include chaining to get THIS_MODULE & friends */
94 #define serio_register_driver(drv) \
95 __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
97 void serio_unregister_driver(struct serio_driver *drv);
99 static inline int serio_write(struct serio *serio, unsigned char data)
101 if (serio->write)
102 return serio->write(serio, data);
103 else
104 return -1;
107 static inline void serio_drv_write_wakeup(struct serio *serio)
109 if (serio->drv && serio->drv->write_wakeup)
110 serio->drv->write_wakeup(serio);
114 * Use the following functions to manipulate serio's per-port
115 * driver-specific data.
117 static inline void *serio_get_drvdata(struct serio *serio)
119 return dev_get_drvdata(&serio->dev);
122 static inline void serio_set_drvdata(struct serio *serio, void *data)
124 dev_set_drvdata(&serio->dev, data);
128 * Use the following functions to protect critical sections in
129 * driver code from port's interrupt handler
131 static inline void serio_pause_rx(struct serio *serio)
133 spin_lock_irq(&serio->lock);
136 static inline void serio_continue_rx(struct serio *serio)
138 spin_unlock_irq(&serio->lock);
141 #endif
144 * bit masks for use in "interrupt" flags (3rd argument)
146 #define SERIO_TIMEOUT 1
147 #define SERIO_PARITY 2
148 #define SERIO_FRAME 4
151 * Serio types
153 #define SERIO_XT 0x00
154 #define SERIO_8042 0x01
155 #define SERIO_RS232 0x02
156 #define SERIO_HIL_MLC 0x03
157 #define SERIO_PS_PSTHRU 0x05
158 #define SERIO_8042_XL 0x06
161 * Serio protocols
163 #define SERIO_UNKNOWN 0x00
164 #define SERIO_MSC 0x01
165 #define SERIO_SUN 0x02
166 #define SERIO_MS 0x03
167 #define SERIO_MP 0x04
168 #define SERIO_MZ 0x05
169 #define SERIO_MZP 0x06
170 #define SERIO_MZPP 0x07
171 #define SERIO_VSXXXAA 0x08
172 #define SERIO_SUNKBD 0x10
173 #define SERIO_WARRIOR 0x18
174 #define SERIO_SPACEORB 0x19
175 #define SERIO_MAGELLAN 0x1a
176 #define SERIO_SPACEBALL 0x1b
177 #define SERIO_GUNZE 0x1c
178 #define SERIO_IFORCE 0x1d
179 #define SERIO_STINGER 0x1e
180 #define SERIO_NEWTON 0x1f
181 #define SERIO_STOWAWAY 0x20
182 #define SERIO_H3600 0x21
183 #define SERIO_PS2SER 0x22
184 #define SERIO_TWIDKBD 0x23
185 #define SERIO_TWIDJOY 0x24
186 #define SERIO_HIL 0x25
187 #define SERIO_SNES232 0x26
188 #define SERIO_SEMTECH 0x27
189 #define SERIO_LKKBD 0x28
190 #define SERIO_ELO 0x29
191 #define SERIO_MICROTOUCH 0x30
192 #define SERIO_PENMOUNT 0x31
193 #define SERIO_TOUCHRIGHT 0x32
194 #define SERIO_TOUCHWIN 0x33
195 #define SERIO_TAOSEVM 0x34
196 #define SERIO_FUJITSU 0x35
197 #define SERIO_ZHENHUA 0x36
198 #define SERIO_INEXIO 0x37
199 #define SERIO_TOUCHIT213 0x38
200 #define SERIO_W8001 0x39
201 #define SERIO_DYNAPRO 0x3a
202 #define SERIO_HAMPSHIRE 0x3b
203 #define SERIO_PS2MULT 0x3c
204 #define SERIO_TSC40 0x3d
206 #endif