diff options
Diffstat (limited to 'drivers/net/irda/sir-dev.h')
-rw-r--r-- | drivers/net/irda/sir-dev.h | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/drivers/net/irda/sir-dev.h b/drivers/net/irda/sir-dev.h new file mode 100644 index 000000000000..f0b8bc3637e5 --- /dev/null +++ b/drivers/net/irda/sir-dev.h | |||
@@ -0,0 +1,202 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * sir.h: include file for irda-sir device abstraction layer | ||
4 | * | ||
5 | * Copyright (c) 2002 Martin Diehl | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License as | ||
9 | * published by the Free Software Foundation; either version 2 of | ||
10 | * the License, or (at your option) any later version. | ||
11 | * | ||
12 | ********************************************************************/ | ||
13 | |||
14 | #ifndef IRDA_SIR_H | ||
15 | #define IRDA_SIR_H | ||
16 | |||
17 | #include <linux/netdevice.h> | ||
18 | |||
19 | #include <net/irda/irda.h> | ||
20 | #include <net/irda/irda_device.h> // iobuff_t | ||
21 | |||
22 | /* FIXME: unify irda_request with sir_fsm! */ | ||
23 | |||
24 | struct irda_request { | ||
25 | struct list_head lh_request; | ||
26 | unsigned long pending; | ||
27 | void (*func)(void *); | ||
28 | void *data; | ||
29 | struct timer_list timer; | ||
30 | }; | ||
31 | |||
32 | struct sir_fsm { | ||
33 | struct semaphore sem; | ||
34 | struct irda_request rq; | ||
35 | unsigned state, substate; | ||
36 | int param; | ||
37 | int result; | ||
38 | }; | ||
39 | |||
40 | #define SIRDEV_STATE_WAIT_TX_COMPLETE 0x0100 | ||
41 | |||
42 | /* substates for wait_tx_complete */ | ||
43 | #define SIRDEV_STATE_WAIT_XMIT 0x0101 | ||
44 | #define SIRDEV_STATE_WAIT_UNTIL_SENT 0x0102 | ||
45 | #define SIRDEV_STATE_TX_DONE 0x0103 | ||
46 | |||
47 | #define SIRDEV_STATE_DONGLE_OPEN 0x0300 | ||
48 | |||
49 | /* 0x0301-0x03ff reserved for individual dongle substates */ | ||
50 | |||
51 | #define SIRDEV_STATE_DONGLE_CLOSE 0x0400 | ||
52 | |||
53 | /* 0x0401-0x04ff reserved for individual dongle substates */ | ||
54 | |||
55 | #define SIRDEV_STATE_SET_DTR_RTS 0x0500 | ||
56 | |||
57 | #define SIRDEV_STATE_SET_SPEED 0x0700 | ||
58 | #define SIRDEV_STATE_DONGLE_CHECK 0x0800 | ||
59 | #define SIRDEV_STATE_DONGLE_RESET 0x0900 | ||
60 | |||
61 | /* 0x0901-0x09ff reserved for individual dongle substates */ | ||
62 | |||
63 | #define SIRDEV_STATE_DONGLE_SPEED 0x0a00 | ||
64 | /* 0x0a01-0x0aff reserved for individual dongle substates */ | ||
65 | |||
66 | #define SIRDEV_STATE_PORT_SPEED 0x0b00 | ||
67 | #define SIRDEV_STATE_DONE 0x0c00 | ||
68 | #define SIRDEV_STATE_ERROR 0x0d00 | ||
69 | #define SIRDEV_STATE_COMPLETE 0x0e00 | ||
70 | |||
71 | #define SIRDEV_STATE_DEAD 0xffff | ||
72 | |||
73 | |||
74 | struct sir_dev; | ||
75 | |||
76 | struct dongle_driver { | ||
77 | |||
78 | struct module *owner; | ||
79 | |||
80 | const char *driver_name; | ||
81 | |||
82 | IRDA_DONGLE type; | ||
83 | |||
84 | int (*open)(struct sir_dev *dev); | ||
85 | int (*close)(struct sir_dev *dev); | ||
86 | int (*reset)(struct sir_dev *dev); | ||
87 | int (*set_speed)(struct sir_dev *dev, unsigned speed); | ||
88 | |||
89 | struct list_head dongle_list; | ||
90 | }; | ||
91 | |||
92 | struct sir_driver { | ||
93 | |||
94 | struct module *owner; | ||
95 | |||
96 | const char *driver_name; | ||
97 | |||
98 | int qos_mtt_bits; | ||
99 | |||
100 | int (*chars_in_buffer)(struct sir_dev *dev); | ||
101 | void (*wait_until_sent)(struct sir_dev *dev); | ||
102 | int (*set_speed)(struct sir_dev *dev, unsigned speed); | ||
103 | int (*set_dtr_rts)(struct sir_dev *dev, int dtr, int rts); | ||
104 | |||
105 | int (*do_write)(struct sir_dev *dev, const unsigned char *ptr, size_t len); | ||
106 | |||
107 | int (*start_dev)(struct sir_dev *dev); | ||
108 | int (*stop_dev)(struct sir_dev *dev); | ||
109 | }; | ||
110 | |||
111 | |||
112 | /* exported */ | ||
113 | |||
114 | extern int irda_register_dongle(struct dongle_driver *new); | ||
115 | extern int irda_unregister_dongle(struct dongle_driver *drv); | ||
116 | |||
117 | extern struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *name); | ||
118 | extern int sirdev_put_instance(struct sir_dev *self); | ||
119 | |||
120 | extern int sirdev_set_dongle(struct sir_dev *dev, IRDA_DONGLE type); | ||
121 | extern void sirdev_write_complete(struct sir_dev *dev); | ||
122 | extern int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count); | ||
123 | |||
124 | /* low level helpers for SIR device/dongle setup */ | ||
125 | extern int sirdev_raw_write(struct sir_dev *dev, const char *buf, int len); | ||
126 | extern int sirdev_raw_read(struct sir_dev *dev, char *buf, int len); | ||
127 | extern int sirdev_set_dtr_rts(struct sir_dev *dev, int dtr, int rts); | ||
128 | |||
129 | /* not exported */ | ||
130 | |||
131 | extern int sirdev_get_dongle(struct sir_dev *self, IRDA_DONGLE type); | ||
132 | extern int sirdev_put_dongle(struct sir_dev *self); | ||
133 | |||
134 | extern void sirdev_enable_rx(struct sir_dev *dev); | ||
135 | extern int sirdev_schedule_request(struct sir_dev *dev, int state, unsigned param); | ||
136 | extern int __init irda_thread_create(void); | ||
137 | extern void __exit irda_thread_join(void); | ||
138 | |||
139 | /* inline helpers */ | ||
140 | |||
141 | static inline int sirdev_schedule_speed(struct sir_dev *dev, unsigned speed) | ||
142 | { | ||
143 | return sirdev_schedule_request(dev, SIRDEV_STATE_SET_SPEED, speed); | ||
144 | } | ||
145 | |||
146 | static inline int sirdev_schedule_dongle_open(struct sir_dev *dev, int dongle_id) | ||
147 | { | ||
148 | return sirdev_schedule_request(dev, SIRDEV_STATE_DONGLE_OPEN, dongle_id); | ||
149 | } | ||
150 | |||
151 | static inline int sirdev_schedule_dongle_close(struct sir_dev *dev) | ||
152 | { | ||
153 | return sirdev_schedule_request(dev, SIRDEV_STATE_DONGLE_CLOSE, 0); | ||
154 | } | ||
155 | |||
156 | static inline int sirdev_schedule_dtr_rts(struct sir_dev *dev, int dtr, int rts) | ||
157 | { | ||
158 | int dtrrts; | ||
159 | |||
160 | dtrrts = ((dtr) ? 0x02 : 0x00) | ((rts) ? 0x01 : 0x00); | ||
161 | return sirdev_schedule_request(dev, SIRDEV_STATE_SET_DTR_RTS, dtrrts); | ||
162 | } | ||
163 | |||
164 | #if 0 | ||
165 | static inline int sirdev_schedule_mode(struct sir_dev *dev, int mode) | ||
166 | { | ||
167 | return sirdev_schedule_request(dev, SIRDEV_STATE_SET_MODE, mode); | ||
168 | } | ||
169 | #endif | ||
170 | |||
171 | |||
172 | struct sir_dev { | ||
173 | struct net_device *netdev; | ||
174 | struct net_device_stats stats; | ||
175 | |||
176 | struct irlap_cb *irlap; | ||
177 | |||
178 | struct qos_info qos; | ||
179 | |||
180 | char hwname[32]; | ||
181 | |||
182 | struct sir_fsm fsm; | ||
183 | atomic_t enable_rx; | ||
184 | int raw_tx; | ||
185 | spinlock_t tx_lock; | ||
186 | |||
187 | u32 new_speed; | ||
188 | u32 flags; | ||
189 | |||
190 | unsigned speed; | ||
191 | |||
192 | iobuff_t tx_buff; /* Transmit buffer */ | ||
193 | iobuff_t rx_buff; /* Receive buffer */ | ||
194 | struct sk_buff *tx_skb; | ||
195 | |||
196 | const struct dongle_driver * dongle_drv; | ||
197 | const struct sir_driver * drv; | ||
198 | void *priv; | ||
199 | |||
200 | }; | ||
201 | |||
202 | #endif /* IRDA_SIR_H */ | ||