]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/serio.h
Input: serio_driver - drop private pointer
[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
7e044e05 18#include <linux/types.h>
1da177e4
LT
19#include <linux/interrupt.h>
20#include <linux/list.h>
21#include <linux/spinlock.h>
c4e32e9f 22#include <linux/mutex.h>
1da177e4
LT
23#include <linux/device.h>
24#include <linux/mod_devicetable.h>
25
26struct serio {
27 void *port_data;
28
29 char name[32];
30 char phys[32];
31
7e044e05 32 bool manual_bind;
1da177e4
LT
33
34 struct serio_device_id id;
35
36 spinlock_t lock; /* protects critical sections from port's interrupt handler */
37
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 *);
43
44 struct serio *parent, *child;
88aa0103 45 unsigned int depth; /* level of nesting in serio hierarchy */
1da177e4
LT
46
47 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
c4e32e9f 48 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
1da177e4
LT
49
50 struct device dev;
1da177e4
LT
51
52 struct list_head node;
53};
54#define to_serio_port(d) container_of(d, struct serio, dev)
55
56struct serio_driver {
ceee4271 57 const char *description;
1da177e4 58
ceee4271 59 const struct serio_device_id *id_table;
7e044e05 60 bool manual_bind;
1da177e4
LT
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 87
4b315627 88int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name);
a822bea7 89static inline int __must_check serio_register_driver(struct serio_driver *drv)
4b315627
GKH
90{
91 return __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME);
92}
1da177e4
LT
93void serio_unregister_driver(struct serio_driver *drv);
94
95static inline int serio_write(struct serio *serio, unsigned char data)
96{
97 if (serio->write)
98 return serio->write(serio, data);
99 else
100 return -1;
101}
102
103static inline void serio_drv_write_wakeup(struct serio *serio)
104{
105 if (serio->drv && serio->drv->write_wakeup)
106 serio->drv->write_wakeup(serio);
107}
108
1da177e4 109/*
0b28002f 110 * Use the following functions to manipulate serio's per-port
1da177e4
LT
111 * driver-specific data.
112 */
113static inline void *serio_get_drvdata(struct serio *serio)
114{
115 return dev_get_drvdata(&serio->dev);
116}
117
118static inline void serio_set_drvdata(struct serio *serio, void *data)
119{
120 dev_set_drvdata(&serio->dev, data);
121}
122
123/*
0b28002f 124 * Use the following functions to protect critical sections in
1da177e4
LT
125 * driver code from port's interrupt handler
126 */
127static inline void serio_pause_rx(struct serio *serio)
128{
129 spin_lock_irq(&serio->lock);
130}
131
132static inline void serio_continue_rx(struct serio *serio)
133{
134 spin_unlock_irq(&serio->lock);
135}
136
1da177e4
LT
137#endif
138
139/*
140 * bit masks for use in "interrupt" flags (3rd argument)
141 */
142#define SERIO_TIMEOUT 1
143#define SERIO_PARITY 2
144#define SERIO_FRAME 4
145
146/*
147 * Serio types
148 */
149#define SERIO_XT 0x00
150#define SERIO_8042 0x01
151#define SERIO_RS232 0x02
152#define SERIO_HIL_MLC 0x03
153#define SERIO_PS_PSTHRU 0x05
154#define SERIO_8042_XL 0x06
155
156/*
f3d1eb19 157 * Serio protocols
1da177e4
LT
158 */
159#define SERIO_UNKNOWN 0x00
160#define SERIO_MSC 0x01
161#define SERIO_SUN 0x02
162#define SERIO_MS 0x03
163#define SERIO_MP 0x04
164#define SERIO_MZ 0x05
165#define SERIO_MZP 0x06
166#define SERIO_MZPP 0x07
167#define SERIO_VSXXXAA 0x08
168#define SERIO_SUNKBD 0x10
169#define SERIO_WARRIOR 0x18
170#define SERIO_SPACEORB 0x19
171#define SERIO_MAGELLAN 0x1a
172#define SERIO_SPACEBALL 0x1b
173#define SERIO_GUNZE 0x1c
174#define SERIO_IFORCE 0x1d
175#define SERIO_STINGER 0x1e
176#define SERIO_NEWTON 0x1f
177#define SERIO_STOWAWAY 0x20
178#define SERIO_H3600 0x21
179#define SERIO_PS2SER 0x22
180#define SERIO_TWIDKBD 0x23
181#define SERIO_TWIDJOY 0x24
182#define SERIO_HIL 0x25
183#define SERIO_SNES232 0x26
184#define SERIO_SEMTECH 0x27
185#define SERIO_LKKBD 0x28
186#define SERIO_ELO 0x29
187#define SERIO_MICROTOUCH 0x30
ee479999 188#define SERIO_PENMOUNT 0x31
4003dff4 189#define SERIO_TOUCHRIGHT 0x32
11ea3173 190#define SERIO_TOUCHWIN 0x33
b9cdad74 191#define SERIO_TAOSEVM 0x34
85f202d5 192#define SERIO_FUJITSU 0x35
3e24e2b5 193#define SERIO_ZHENHUA 0x36
3cadd2d9 194#define SERIO_INEXIO 0x37
ab96ddec 195#define SERIO_TOUCHIT213 0x38
3eb1aa43 196#define SERIO_W8001 0x39
a5f523bc 197#define SERIO_DYNAPRO 0x3a
422dee56 198#define SERIO_HAMPSHIRE 0x3b
1da177e4
LT
199
200#endif