]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/serio.h
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
[net-next-2.6.git] / include / linux / serio.h
CommitLineData
1da177e4
LT
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
14#define SPIOCSTYPE _IOW('q', 0x01, unsigned long)
15
16#ifdef __KERNEL__
17
18#include <linux/interrupt.h>
19#include <linux/list.h>
20#include <linux/spinlock.h>
c4e32e9f 21#include <linux/mutex.h>
1da177e4
LT
22#include <linux/device.h>
23#include <linux/mod_devicetable.h>
24
25struct serio {
26 void *port_data;
27
28 char name[32];
29 char phys[32];
30
31 unsigned int manual_bind;
32
33 struct serio_device_id id;
34
35 spinlock_t lock; /* protects critical sections from port's interrupt handler */
36
37 int (*write)(struct serio *, unsigned char);
38 int (*open)(struct serio *);
39 void (*close)(struct serio *);
40 int (*start)(struct serio *);
41 void (*stop)(struct serio *);
42
43 struct serio *parent, *child;
44
45 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
c4e32e9f 46 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
1da177e4
LT
47
48 struct device dev;
49 unsigned int registered; /* port has been fully registered with driver core */
50
51 struct list_head node;
52};
53#define to_serio_port(d) container_of(d, struct serio, dev)
54
55struct serio_driver {
56 void *private;
57 char *description;
58
59 struct serio_device_id *id_table;
60 unsigned int manual_bind;
61
62 void (*write_wakeup)(struct serio *);
7d12e780 63 irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
1da177e4
LT
64 int (*connect)(struct serio *, struct serio_driver *drv);
65 int (*reconnect)(struct serio *);
66 void (*disconnect)(struct serio *);
67 void (*cleanup)(struct serio *);
68
69 struct device_driver driver;
70};
71#define to_serio_driver(d) container_of(d, struct serio_driver, driver)
72
73int serio_open(struct serio *serio, struct serio_driver *drv);
74void serio_close(struct serio *serio);
75void serio_rescan(struct serio *serio);
76void serio_reconnect(struct serio *serio);
7d12e780 77irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags);
1da177e4
LT
78
79void __serio_register_port(struct serio *serio, struct module *owner);
80static inline void serio_register_port(struct serio *serio)
81{
82 __serio_register_port(serio, THIS_MODULE);
83}
84
85void serio_unregister_port(struct serio *serio);
dbf4ccd6 86void serio_unregister_child_port(struct serio *serio);
1da177e4
LT
87void __serio_unregister_port_delayed(struct serio *serio, struct module *owner);
88static inline void serio_unregister_port_delayed(struct serio *serio)
89{
90 __serio_unregister_port_delayed(serio, THIS_MODULE);
91}
92
93void __serio_register_driver(struct serio_driver *drv, struct module *owner);
94static inline void serio_register_driver(struct serio_driver *drv)
95{
96 __serio_register_driver(drv, THIS_MODULE);
97}
98
99void serio_unregister_driver(struct serio_driver *drv);
100
101static inline int serio_write(struct serio *serio, unsigned char data)
102{
103 if (serio->write)
104 return serio->write(serio, data);
105 else
106 return -1;
107}
108
109static inline void serio_drv_write_wakeup(struct serio *serio)
110{
111 if (serio->drv && serio->drv->write_wakeup)
112 serio->drv->write_wakeup(serio);
113}
114
115static inline void serio_cleanup(struct serio *serio)
116{
117 if (serio->drv && serio->drv->cleanup)
118 serio->drv->cleanup(serio);
119}
120
121/*
0b28002f 122 * Use the following functions to manipulate serio's per-port
1da177e4
LT
123 * driver-specific data.
124 */
125static inline void *serio_get_drvdata(struct serio *serio)
126{
127 return dev_get_drvdata(&serio->dev);
128}
129
130static inline void serio_set_drvdata(struct serio *serio, void *data)
131{
132 dev_set_drvdata(&serio->dev, data);
133}
134
135/*
0b28002f 136 * Use the following functions to protect critical sections in
1da177e4
LT
137 * driver code from port's interrupt handler
138 */
139static inline void serio_pause_rx(struct serio *serio)
140{
141 spin_lock_irq(&serio->lock);
142}
143
144static inline void serio_continue_rx(struct serio *serio)
145{
146 spin_unlock_irq(&serio->lock);
147}
148
149/*
0b28002f 150 * Use the following functions to pin serio's driver in process context
1da177e4
LT
151 */
152static inline int serio_pin_driver(struct serio *serio)
153{
c4e32e9f 154 return mutex_lock_interruptible(&serio->drv_mutex);
1da177e4
LT
155}
156
dbf4ccd6
DT
157static inline void serio_pin_driver_uninterruptible(struct serio *serio)
158{
c4e32e9f 159 mutex_lock(&serio->drv_mutex);
dbf4ccd6
DT
160}
161
1da177e4
LT
162static inline void serio_unpin_driver(struct serio *serio)
163{
c4e32e9f 164 mutex_unlock(&serio->drv_mutex);
1da177e4
LT
165}
166
167
168#endif
169
170/*
171 * bit masks for use in "interrupt" flags (3rd argument)
172 */
173#define SERIO_TIMEOUT 1
174#define SERIO_PARITY 2
175#define SERIO_FRAME 4
176
177/*
178 * Serio types
179 */
180#define SERIO_XT 0x00
181#define SERIO_8042 0x01
182#define SERIO_RS232 0x02
183#define SERIO_HIL_MLC 0x03
184#define SERIO_PS_PSTHRU 0x05
185#define SERIO_8042_XL 0x06
186
187/*
188 * Serio types
189 */
190#define SERIO_UNKNOWN 0x00
191#define SERIO_MSC 0x01
192#define SERIO_SUN 0x02
193#define SERIO_MS 0x03
194#define SERIO_MP 0x04
195#define SERIO_MZ 0x05
196#define SERIO_MZP 0x06
197#define SERIO_MZPP 0x07
198#define SERIO_VSXXXAA 0x08
199#define SERIO_SUNKBD 0x10
200#define SERIO_WARRIOR 0x18
201#define SERIO_SPACEORB 0x19
202#define SERIO_MAGELLAN 0x1a
203#define SERIO_SPACEBALL 0x1b
204#define SERIO_GUNZE 0x1c
205#define SERIO_IFORCE 0x1d
206#define SERIO_STINGER 0x1e
207#define SERIO_NEWTON 0x1f
208#define SERIO_STOWAWAY 0x20
209#define SERIO_H3600 0x21
210#define SERIO_PS2SER 0x22
211#define SERIO_TWIDKBD 0x23
212#define SERIO_TWIDJOY 0x24
213#define SERIO_HIL 0x25
214#define SERIO_SNES232 0x26
215#define SERIO_SEMTECH 0x27
216#define SERIO_LKKBD 0x28
217#define SERIO_ELO 0x29
218#define SERIO_MICROTOUCH 0x30
ee479999 219#define SERIO_PENMOUNT 0x31
4003dff4 220#define SERIO_TOUCHRIGHT 0x32
11ea3173 221#define SERIO_TOUCHWIN 0x33
1da177e4
LT
222
223#endif