diff options
author | Martin Bachem <info@colognechip.com> | 2007-08-21 08:26:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-08-21 13:14:28 -0400 |
commit | d6c59c13c070cb9d043edf38b4639fdacdb0c18c (patch) | |
tree | 2714d82e3f40dd6af5f3ea46b0df1fc4e9ea0791 /drivers/isdn | |
parent | 36ce1514117b92b7372e1b041ccc686855454d33 (diff) |
hisax: update hfc_usb driver
This fixes handling of USB ISO completion error -EXDEV and includes
several other changes to current CVS version at isdn4linux.de (changes
in debug flags, style of code remarks, etc)
Signed-off-by: Martin Bachem <info@colognechip.com>
Acked-by: Karsten Keil <kkeil@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/isdn')
-rw-r--r-- | drivers/isdn/hisax/hfc_usb.c | 603 | ||||
-rw-r--r-- | drivers/isdn/hisax/hfc_usb.h | 130 |
2 files changed, 288 insertions, 445 deletions
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c index b1a26e02df02..60843b3f3b6f 100644 --- a/drivers/isdn/hisax/hfc_usb.c +++ b/drivers/isdn/hisax/hfc_usb.c | |||
@@ -1,12 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | * hfc_usb.c | 2 | * hfc_usb.c |
3 | * | 3 | * |
4 | * $Id: hfc_usb.c,v 2.3.2.13 2006/02/17 17:17:22 mbachem Exp $ | 4 | * $Id: hfc_usb.c,v 2.3.2.20 2007/08/20 14:07:54 mbachem Exp $ |
5 | * | 5 | * |
6 | * modular HiSax ISDN driver for Colognechip HFC-S USB chip | 6 | * modular HiSax ISDN driver for Colognechip HFC-S USB chip |
7 | * | 7 | * |
8 | * Authors : Peter Sprenger (sprenger@moving-bytes.de) | 8 | * Authors : Peter Sprenger (sprenger@moving-bytes.de) |
9 | * Martin Bachem (info@colognechip.com) | 9 | * Martin Bachem (m.bachem@gmx.de, info@colognechip.com) |
10 | * | 10 | * |
11 | * based on the first hfc_usb driver of | 11 | * based on the first hfc_usb driver of |
12 | * Werner Cornelius (werner@isdn-development.de) | 12 | * Werner Cornelius (werner@isdn-development.de) |
@@ -37,24 +37,25 @@ | |||
37 | #include <linux/kernel_stat.h> | 37 | #include <linux/kernel_stat.h> |
38 | #include <linux/usb.h> | 38 | #include <linux/usb.h> |
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/smp_lock.h> | ||
41 | #include <linux/sched.h> | ||
42 | #include <linux/moduleparam.h> | ||
40 | #include "hisax.h" | 43 | #include "hisax.h" |
41 | #include "hisax_if.h" | 44 | #include "hisax_if.h" |
42 | #include "hfc_usb.h" | 45 | #include "hfc_usb.h" |
43 | 46 | ||
44 | static const char *hfcusb_revision = | 47 | static const char *hfcusb_revision = |
45 | "$Revision: 2.3.2.13 $ $Date: 2006/02/17 17:17:22 $ "; | 48 | "$Revision: 2.3.2.20 $ $Date: 2007/08/20 14:07:54 $ "; |
46 | 49 | ||
47 | /* Hisax debug support | 50 | /* Hisax debug support |
48 | * use "modprobe debug=x" where x is bitfield of USB_DBG & ISDN_DBG | 51 | * debug flags defined in hfc_usb.h as HFCUSB_DBG_[*] |
49 | */ | 52 | */ |
50 | #ifdef CONFIG_HISAX_DEBUG | ||
51 | #include <linux/moduleparam.h> | ||
52 | #define __debug_variable hfc_debug | 53 | #define __debug_variable hfc_debug |
53 | #include "hisax_debug.h" | 54 | #include "hisax_debug.h" |
54 | static u_int debug; | 55 | static u_int debug; |
55 | module_param(debug, uint, 0); | 56 | module_param(debug, uint, 0); |
56 | static int hfc_debug; | 57 | static int hfc_debug; |
57 | #endif | 58 | |
58 | 59 | ||
59 | /* private vendor specific data */ | 60 | /* private vendor specific data */ |
60 | typedef struct { | 61 | typedef struct { |
@@ -63,9 +64,7 @@ typedef struct { | |||
63 | char *vend_name; // device name | 64 | char *vend_name; // device name |
64 | } hfcsusb_vdata; | 65 | } hfcsusb_vdata; |
65 | 66 | ||
66 | /****************************************/ | 67 | /* VID/PID device list */ |
67 | /* data defining the devices to be used */ | ||
68 | /****************************************/ | ||
69 | static struct usb_device_id hfcusb_idtab[] = { | 68 | static struct usb_device_id hfcusb_idtab[] = { |
70 | { | 69 | { |
71 | USB_DEVICE(0x0959, 0x2bd0), | 70 | USB_DEVICE(0x0959, 0x2bd0), |
@@ -90,49 +89,47 @@ static struct usb_device_id hfcusb_idtab[] = { | |||
90 | .driver_info = (unsigned long) &((hfcsusb_vdata) | 89 | .driver_info = (unsigned long) &((hfcsusb_vdata) |
91 | {LED_SCHEME1, {4, 0, 2, 1}, | 90 | {LED_SCHEME1, {4, 0, 2, 1}, |
92 | "Stollmann USB TA"}), | 91 | "Stollmann USB TA"}), |
93 | }, | 92 | }, |
94 | { | 93 | { |
95 | USB_DEVICE(0x0742, 0x2009), | 94 | USB_DEVICE(0x0742, 0x2009), |
96 | .driver_info = (unsigned long) &((hfcsusb_vdata) | 95 | .driver_info = (unsigned long) &((hfcsusb_vdata) |
97 | {LED_SCHEME1, {4, 0, 2, 1}, | 96 | {LED_SCHEME1, {4, 0, 2, 1}, |
98 | "Aceex USB ISDN TA"}), | 97 | "Aceex USB ISDN TA"}), |
99 | }, | 98 | }, |
100 | { | 99 | { |
101 | USB_DEVICE(0x0742, 0x200A), | 100 | USB_DEVICE(0x0742, 0x200A), |
102 | .driver_info = (unsigned long) &((hfcsusb_vdata) | 101 | .driver_info = (unsigned long) &((hfcsusb_vdata) |
103 | {LED_SCHEME1, {4, 0, 2, 1}, | 102 | {LED_SCHEME1, {4, 0, 2, 1}, |
104 | "OEM USB ISDN TA"}), | 103 | "OEM USB ISDN TA"}), |
105 | }, | 104 | }, |
106 | { | 105 | { |
107 | USB_DEVICE(0x08e3, 0x0301), | 106 | USB_DEVICE(0x08e3, 0x0301), |
108 | .driver_info = (unsigned long) &((hfcsusb_vdata) | 107 | .driver_info = (unsigned long) &((hfcsusb_vdata) |
109 | {LED_SCHEME1, {2, 0, 1, 4}, | 108 | {LED_SCHEME1, {2, 0, 1, 4}, |
110 | "Olitec USB RNIS"}), | 109 | "Olitec USB RNIS"}), |
111 | }, | 110 | }, |
112 | { | 111 | { |
113 | USB_DEVICE(0x07fa, 0x0846), | 112 | USB_DEVICE(0x07fa, 0x0846), |
114 | .driver_info = (unsigned long) &((hfcsusb_vdata) | 113 | .driver_info = (unsigned long) &((hfcsusb_vdata) |
115 | {LED_SCHEME1, {0x80, -64, -32, -16}, | 114 | {LED_SCHEME1, {0x80, -64, -32, -16}, |
116 | "Bewan Modem RNIS USB"}), | 115 | "Bewan Modem RNIS USB"}), |
117 | }, | 116 | }, |
118 | { | 117 | { |
119 | USB_DEVICE(0x07fa, 0x0847), | 118 | USB_DEVICE(0x07fa, 0x0847), |
120 | .driver_info = (unsigned long) &((hfcsusb_vdata) | 119 | .driver_info = (unsigned long) &((hfcsusb_vdata) |
121 | {LED_SCHEME1, {0x80, -64, -32, -16}, | 120 | {LED_SCHEME1, {0x80, -64, -32, -16}, |
122 | "Djinn Numeris USB"}), | 121 | "Djinn Numeris USB"}), |
123 | }, | 122 | }, |
124 | { | 123 | { |
125 | USB_DEVICE(0x07b0, 0x0006), | 124 | USB_DEVICE(0x07b0, 0x0006), |
126 | .driver_info = (unsigned long) &((hfcsusb_vdata) | 125 | .driver_info = (unsigned long) &((hfcsusb_vdata) |
127 | {LED_SCHEME1, {0x80, -64, -32, -16}, | 126 | {LED_SCHEME1, {0x80, -64, -32, -16}, |
128 | "Twister ISDN TA"}), | 127 | "Twister ISDN TA"}), |
129 | }, | 128 | }, |
130 | { } | 129 | { } |
131 | }; | 130 | }; |
132 | 131 | ||
133 | /***************************************************************/ | ||
134 | /* structure defining input+output fifos (interrupt/bulk mode) */ | 132 | /* structure defining input+output fifos (interrupt/bulk mode) */ |
135 | /***************************************************************/ | ||
136 | struct usb_fifo; /* forward definition */ | 133 | struct usb_fifo; /* forward definition */ |
137 | typedef struct iso_urb_struct { | 134 | typedef struct iso_urb_struct { |
138 | struct urb *purb; | 135 | struct urb *purb; |
@@ -140,8 +137,8 @@ typedef struct iso_urb_struct { | |||
140 | struct usb_fifo *owner_fifo; /* pointer to owner fifo */ | 137 | struct usb_fifo *owner_fifo; /* pointer to owner fifo */ |
141 | } iso_urb_struct; | 138 | } iso_urb_struct; |
142 | 139 | ||
143 | |||
144 | struct hfcusb_data; /* forward definition */ | 140 | struct hfcusb_data; /* forward definition */ |
141 | |||
145 | typedef struct usb_fifo { | 142 | typedef struct usb_fifo { |
146 | int fifonum; /* fifo index attached to this structure */ | 143 | int fifonum; /* fifo index attached to this structure */ |
147 | int active; /* fifo is currently active */ | 144 | int active; /* fifo is currently active */ |
@@ -160,15 +157,12 @@ typedef struct usb_fifo { | |||
160 | struct hisax_if *hif; /* hisax interface */ | 157 | struct hisax_if *hif; /* hisax interface */ |
161 | int delete_flg; /* only delete skbuff once */ | 158 | int delete_flg; /* only delete skbuff once */ |
162 | int last_urblen; /* remember length of last packet */ | 159 | int last_urblen; /* remember length of last packet */ |
163 | |||
164 | } usb_fifo; | 160 | } usb_fifo; |
165 | 161 | ||
166 | /*********************************************/ | ||
167 | /* structure holding all data for one device */ | 162 | /* structure holding all data for one device */ |
168 | /*********************************************/ | ||
169 | typedef struct hfcusb_data { | 163 | typedef struct hfcusb_data { |
170 | /* HiSax Interface for loadable Layer1 drivers */ | 164 | /* HiSax Interface for loadable Layer1 drivers */ |
171 | struct hisax_d_if d_if; /* see hisax_if.h */ | 165 | struct hisax_d_if d_if; /* see hisax_if.h */ |
172 | struct hisax_b_if b_if[2]; /* see hisax_if.h */ | 166 | struct hisax_b_if b_if[2]; /* see hisax_if.h */ |
173 | int protocol; | 167 | int protocol; |
174 | 168 | ||
@@ -176,12 +170,13 @@ typedef struct hfcusb_data { | |||
176 | int if_used; /* used interface number */ | 170 | int if_used; /* used interface number */ |
177 | int alt_used; /* used alternate config */ | 171 | int alt_used; /* used alternate config */ |
178 | int ctrl_paksize; /* control pipe packet size */ | 172 | int ctrl_paksize; /* control pipe packet size */ |
179 | int ctrl_in_pipe, ctrl_out_pipe; /* handles for control pipe */ | 173 | int ctrl_in_pipe, /* handles for control pipe */ |
174 | ctrl_out_pipe; | ||
180 | int cfg_used; /* configuration index used */ | 175 | int cfg_used; /* configuration index used */ |
181 | int vend_idx; /* vendor found */ | 176 | int vend_idx; /* vendor found */ |
182 | int b_mode[2]; /* B-channel mode */ | 177 | int b_mode[2]; /* B-channel mode */ |
183 | int l1_activated; /* layer 1 activated */ | 178 | int l1_activated; /* layer 1 activated */ |
184 | int disc_flag; /* 'true' if device was disonnected to avoid some USB actions */ | 179 | int disc_flag; /* TRUE if device was disonnected to avoid some USB actions */ |
185 | int packet_size, iso_packet_size; | 180 | int packet_size, iso_packet_size; |
186 | 181 | ||
187 | /* control pipe background handling */ | 182 | /* control pipe background handling */ |
@@ -208,7 +203,6 @@ typedef struct hfcusb_data { | |||
208 | static void collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, | 203 | static void collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, |
209 | int finish); | 204 | int finish); |
210 | 205 | ||
211 | |||
212 | static inline const char * | 206 | static inline const char * |
213 | symbolic(struct hfcusb_symbolic_list list[], const int num) | 207 | symbolic(struct hfcusb_symbolic_list list[], const int num) |
214 | { | 208 | { |
@@ -219,10 +213,6 @@ symbolic(struct hfcusb_symbolic_list list[], const int num) | |||
219 | return "<unknown ERROR>"; | 213 | return "<unknown ERROR>"; |
220 | } | 214 | } |
221 | 215 | ||
222 | |||
223 | /******************************************************/ | ||
224 | /* start next background transfer for control channel */ | ||
225 | /******************************************************/ | ||
226 | static void | 216 | static void |
227 | ctrl_start_transfer(hfcusb_data * hfc) | 217 | ctrl_start_transfer(hfcusb_data * hfc) |
228 | { | 218 | { |
@@ -240,10 +230,6 @@ ctrl_start_transfer(hfcusb_data * hfc) | |||
240 | } | 230 | } |
241 | } /* ctrl_start_transfer */ | 231 | } /* ctrl_start_transfer */ |
242 | 232 | ||
243 | /************************************/ | ||
244 | /* queue a control transfer request */ | ||
245 | /* return 0 on success. */ | ||
246 | /************************************/ | ||
247 | static int | 233 | static int |
248 | queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action) | 234 | queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action) |
249 | { | 235 | { |
@@ -260,19 +246,8 @@ queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action) | |||
260 | if (++hfc->ctrl_cnt == 1) | 246 | if (++hfc->ctrl_cnt == 1) |
261 | ctrl_start_transfer(hfc); | 247 | ctrl_start_transfer(hfc); |
262 | return (0); | 248 | return (0); |
263 | } /* queue_control_request */ | ||
264 | |||
265 | static int | ||
266 | control_action_handler(hfcusb_data * hfc, int reg, int val, int action) | ||
267 | { | ||
268 | if (!action) | ||
269 | return (1); /* no action defined */ | ||
270 | return (0); | ||
271 | } | 249 | } |
272 | 250 | ||
273 | /***************************************************************/ | ||
274 | /* control completion routine handling background control cmds */ | ||
275 | /***************************************************************/ | ||
276 | static void | 251 | static void |
277 | ctrl_complete(struct urb *urb) | 252 | ctrl_complete(struct urb *urb) |
278 | { | 253 | { |
@@ -282,9 +257,6 @@ ctrl_complete(struct urb *urb) | |||
282 | urb->dev = hfc->dev; | 257 | urb->dev = hfc->dev; |
283 | if (hfc->ctrl_cnt) { | 258 | if (hfc->ctrl_cnt) { |
284 | buf = &hfc->ctrl_buff[hfc->ctrl_out_idx]; | 259 | buf = &hfc->ctrl_buff[hfc->ctrl_out_idx]; |
285 | control_action_handler(hfc, buf->hfc_reg, buf->reg_val, | ||
286 | buf->action); | ||
287 | |||
288 | hfc->ctrl_cnt--; /* decrement actual count */ | 260 | hfc->ctrl_cnt--; /* decrement actual count */ |
289 | if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) | 261 | if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) |
290 | hfc->ctrl_out_idx = 0; /* pointer wrap */ | 262 | hfc->ctrl_out_idx = 0; /* pointer wrap */ |
@@ -293,9 +265,7 @@ ctrl_complete(struct urb *urb) | |||
293 | } | 265 | } |
294 | } /* ctrl_complete */ | 266 | } /* ctrl_complete */ |
295 | 267 | ||
296 | /***************************************************/ | ||
297 | /* write led data to auxport & invert if necessary */ | 268 | /* write led data to auxport & invert if necessary */ |
298 | /***************************************************/ | ||
299 | static void | 269 | static void |
300 | write_led(hfcusb_data * hfc, __u8 led_state) | 270 | write_led(hfcusb_data * hfc, __u8 led_state) |
301 | { | 271 | { |
@@ -305,9 +275,6 @@ write_led(hfcusb_data * hfc, __u8 led_state) | |||
305 | } | 275 | } |
306 | } | 276 | } |
307 | 277 | ||
308 | /**************************/ | ||
309 | /* handle LED bits */ | ||
310 | /**************************/ | ||
311 | static void | 278 | static void |
312 | set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset) | 279 | set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset) |
313 | { | 280 | { |
@@ -324,9 +291,7 @@ set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset) | |||
324 | } | 291 | } |
325 | } | 292 | } |
326 | 293 | ||
327 | /**************************/ | 294 | /* handle LED requests */ |
328 | /* handle LED requests */ | ||
329 | /**************************/ | ||
330 | static void | 295 | static void |
331 | handle_led(hfcusb_data * hfc, int event) | 296 | handle_led(hfcusb_data * hfc, int event) |
332 | { | 297 | { |
@@ -339,85 +304,73 @@ handle_led(hfcusb_data * hfc, int event) | |||
339 | 304 | ||
340 | switch (event) { | 305 | switch (event) { |
341 | case LED_POWER_ON: | 306 | case LED_POWER_ON: |
342 | set_led_bit(hfc, driver_info->led_bits[0], | 307 | set_led_bit(hfc, driver_info->led_bits[0], 0); |
343 | 0); | 308 | set_led_bit(hfc, driver_info->led_bits[1], 1); |
344 | set_led_bit(hfc, driver_info->led_bits[1], | 309 | set_led_bit(hfc, driver_info->led_bits[2], 1); |
345 | 1); | 310 | set_led_bit(hfc, driver_info->led_bits[3], 1); |
346 | set_led_bit(hfc, driver_info->led_bits[2], | ||
347 | 1); | ||
348 | set_led_bit(hfc, driver_info->led_bits[3], | ||
349 | 1); | ||
350 | break; | 311 | break; |
351 | case LED_POWER_OFF: /* no Power off handling */ | 312 | case LED_POWER_OFF: |
313 | set_led_bit(hfc, driver_info->led_bits[0], 1); | ||
314 | set_led_bit(hfc, driver_info->led_bits[1], 1); | ||
315 | set_led_bit(hfc, driver_info->led_bits[2], 1); | ||
316 | set_led_bit(hfc, driver_info->led_bits[3], 1); | ||
352 | break; | 317 | break; |
353 | case LED_S0_ON: | 318 | case LED_S0_ON: |
354 | set_led_bit(hfc, driver_info->led_bits[1], | 319 | set_led_bit(hfc, driver_info->led_bits[1], 0); |
355 | 0); | ||
356 | break; | 320 | break; |
357 | case LED_S0_OFF: | 321 | case LED_S0_OFF: |
358 | set_led_bit(hfc, driver_info->led_bits[1], | 322 | set_led_bit(hfc, driver_info->led_bits[1], 1); |
359 | 1); | ||
360 | break; | 323 | break; |
361 | case LED_B1_ON: | 324 | case LED_B1_ON: |
362 | set_led_bit(hfc, driver_info->led_bits[2], | 325 | set_led_bit(hfc, driver_info->led_bits[2], 0); |
363 | 0); | ||
364 | break; | 326 | break; |
365 | case LED_B1_OFF: | 327 | case LED_B1_OFF: |
366 | set_led_bit(hfc, driver_info->led_bits[2], | 328 | set_led_bit(hfc, driver_info->led_bits[2], 1); |
367 | 1); | ||
368 | break; | 329 | break; |
369 | case LED_B2_ON: | 330 | case LED_B2_ON: |
370 | set_led_bit(hfc, driver_info->led_bits[3], | 331 | set_led_bit(hfc, driver_info->led_bits[3], 0); |
371 | 0); | ||
372 | break; | 332 | break; |
373 | case LED_B2_OFF: | 333 | case LED_B2_OFF: |
374 | set_led_bit(hfc, driver_info->led_bits[3], | 334 | set_led_bit(hfc, driver_info->led_bits[3], 1); |
375 | 1); | ||
376 | break; | 335 | break; |
377 | } | 336 | } |
378 | write_led(hfc, hfc->led_state); | 337 | write_led(hfc, hfc->led_state); |
379 | } | 338 | } |
380 | 339 | ||
381 | /********************************/ | 340 | /* ISDN l1 timer T3 expires */ |
382 | /* called when timer t3 expires */ | ||
383 | /********************************/ | ||
384 | static void | 341 | static void |
385 | l1_timer_expire_t3(hfcusb_data * hfc) | 342 | l1_timer_expire_t3(hfcusb_data * hfc) |
386 | { | 343 | { |
387 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, | 344 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, |
388 | NULL); | 345 | NULL); |
389 | #ifdef CONFIG_HISAX_DEBUG | 346 | |
390 | DBG(ISDN_DBG, | 347 | DBG(HFCUSB_DBG_STATES, |
391 | "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T3 expire)"); | 348 | "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T3 expire)"); |
392 | #endif | 349 | |
393 | hfc->l1_activated = false; | 350 | hfc->l1_activated = 0; |
394 | handle_led(hfc, LED_S0_OFF); | 351 | handle_led(hfc, LED_S0_OFF); |
395 | /* deactivate : */ | 352 | /* deactivate : */ |
396 | queue_control_request(hfc, HFCUSB_STATES, 0x10, 1); | 353 | queue_control_request(hfc, HFCUSB_STATES, 0x10, 1); |
397 | queue_control_request(hfc, HFCUSB_STATES, 3, 1); | 354 | queue_control_request(hfc, HFCUSB_STATES, 3, 1); |
398 | } | 355 | } |
399 | 356 | ||
400 | /********************************/ | 357 | /* ISDN l1 timer T4 expires */ |
401 | /* called when timer t4 expires */ | ||
402 | /********************************/ | ||
403 | static void | 358 | static void |
404 | l1_timer_expire_t4(hfcusb_data * hfc) | 359 | l1_timer_expire_t4(hfcusb_data * hfc) |
405 | { | 360 | { |
406 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, | 361 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, |
407 | NULL); | 362 | NULL); |
408 | #ifdef CONFIG_HISAX_DEBUG | 363 | |
409 | DBG(ISDN_DBG, | 364 | DBG(HFCUSB_DBG_STATES, |
410 | "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T4 expire)"); | 365 | "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T4 expire)"); |
411 | #endif | 366 | |
412 | hfc->l1_activated = false; | 367 | hfc->l1_activated = 0; |
413 | handle_led(hfc, LED_S0_OFF); | 368 | handle_led(hfc, LED_S0_OFF); |
414 | } | 369 | } |
415 | 370 | ||
416 | /*****************************/ | 371 | /* S0 state changed */ |
417 | /* handle S0 state changes */ | ||
418 | /*****************************/ | ||
419 | static void | 372 | static void |
420 | state_handler(hfcusb_data * hfc, __u8 state) | 373 | s0_state_handler(hfcusb_data * hfc, __u8 state) |
421 | { | 374 | { |
422 | __u8 old_state; | 375 | __u8 old_state; |
423 | 376 | ||
@@ -425,38 +378,29 @@ state_handler(hfcusb_data * hfc, __u8 state) | |||
425 | if (state == old_state || state < 1 || state > 8) | 378 | if (state == old_state || state < 1 || state > 8) |
426 | return; | 379 | return; |
427 | 380 | ||
428 | #ifdef CONFIG_HISAX_DEBUG | 381 | DBG(HFCUSB_DBG_STATES, "HFC-S USB: S0 statechange(%d -> %d)", |
429 | DBG(ISDN_DBG, "HFC-S USB: new S0 state:%d old_state:%d", state, | 382 | old_state, state); |
430 | old_state); | 383 | |
431 | #endif | ||
432 | if (state < 4 || state == 7 || state == 8) { | 384 | if (state < 4 || state == 7 || state == 8) { |
433 | if (timer_pending(&hfc->t3_timer)) | 385 | if (timer_pending(&hfc->t3_timer)) |
434 | del_timer(&hfc->t3_timer); | 386 | del_timer(&hfc->t3_timer); |
435 | #ifdef CONFIG_HISAX_DEBUG | 387 | DBG(HFCUSB_DBG_STATES, "HFC-S USB: T3 deactivated"); |
436 | DBG(ISDN_DBG, "HFC-S USB: T3 deactivated"); | ||
437 | #endif | ||
438 | } | 388 | } |
439 | if (state >= 7) { | 389 | if (state >= 7) { |
440 | if (timer_pending(&hfc->t4_timer)) | 390 | if (timer_pending(&hfc->t4_timer)) |
441 | del_timer(&hfc->t4_timer); | 391 | del_timer(&hfc->t4_timer); |
442 | #ifdef CONFIG_HISAX_DEBUG | 392 | DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 deactivated"); |
443 | DBG(ISDN_DBG, "HFC-S USB: T4 deactivated"); | ||
444 | #endif | ||
445 | } | 393 | } |
446 | 394 | ||
447 | if (state == 7 && !hfc->l1_activated) { | 395 | if (state == 7 && !hfc->l1_activated) { |
448 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, | 396 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, |
449 | PH_ACTIVATE | INDICATION, NULL); | 397 | PH_ACTIVATE | INDICATION, NULL); |
450 | #ifdef CONFIG_HISAX_DEBUG | 398 | DBG(HFCUSB_DBG_STATES, "HFC-S USB: PH_ACTIVATE | INDICATION sent"); |
451 | DBG(ISDN_DBG, "HFC-S USB: PH_ACTIVATE | INDICATION sent"); | 399 | hfc->l1_activated = 1; |
452 | #endif | ||
453 | hfc->l1_activated = true; | ||
454 | handle_led(hfc, LED_S0_ON); | 400 | handle_led(hfc, LED_S0_ON); |
455 | } else if (state <= 3 /* && activated */ ) { | 401 | } else if (state <= 3 /* && activated */ ) { |
456 | if (old_state == 7 || old_state == 8) { | 402 | if (old_state == 7 || old_state == 8) { |
457 | #ifdef CONFIG_HISAX_DEBUG | 403 | DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 activated"); |
458 | DBG(ISDN_DBG, "HFC-S USB: T4 activated"); | ||
459 | #endif | ||
460 | if (!timer_pending(&hfc->t4_timer)) { | 404 | if (!timer_pending(&hfc->t4_timer)) { |
461 | hfc->t4_timer.expires = | 405 | hfc->t4_timer.expires = |
462 | jiffies + (HFC_TIMER_T4 * HZ) / 1000; | 406 | jiffies + (HFC_TIMER_T4 * HZ) / 1000; |
@@ -466,18 +410,15 @@ state_handler(hfcusb_data * hfc, __u8 state) | |||
466 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, | 410 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, |
467 | PH_DEACTIVATE | INDICATION, | 411 | PH_DEACTIVATE | INDICATION, |
468 | NULL); | 412 | NULL); |
469 | #ifdef CONFIG_HISAX_DEBUG | 413 | DBG(HFCUSB_DBG_STATES, |
470 | DBG(ISDN_DBG, | ||
471 | "HFC-S USB: PH_DEACTIVATE | INDICATION sent"); | 414 | "HFC-S USB: PH_DEACTIVATE | INDICATION sent"); |
472 | #endif | 415 | hfc->l1_activated = 0; |
473 | hfc->l1_activated = false; | ||
474 | handle_led(hfc, LED_S0_OFF); | 416 | handle_led(hfc, LED_S0_OFF); |
475 | } | 417 | } |
476 | } | 418 | } |
477 | hfc->l1_state = state; | 419 | hfc->l1_state = state; |
478 | } | 420 | } |
479 | 421 | ||
480 | /* prepare iso urb */ | ||
481 | static void | 422 | static void |
482 | fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, | 423 | fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, |
483 | void *buf, int num_packets, int packet_size, int interval, | 424 | void *buf, int num_packets, int packet_size, int interval, |
@@ -503,15 +444,16 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, | |||
503 | } | 444 | } |
504 | 445 | ||
505 | /* allocs urbs and start isoc transfer with two pending urbs to avoid | 446 | /* allocs urbs and start isoc transfer with two pending urbs to avoid |
506 | gaps in the transfer chain */ | 447 | * gaps in the transfer chain |
448 | */ | ||
507 | static int | 449 | static int |
508 | start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, | 450 | start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, |
509 | usb_complete_t complete, int packet_size) | 451 | usb_complete_t complete, int packet_size) |
510 | { | 452 | { |
511 | int i, k, errcode; | 453 | int i, k, errcode; |
512 | 454 | ||
513 | printk(KERN_INFO "HFC-S USB: starting ISO-chain for Fifo %i\n", | 455 | DBG(HFCUSB_DBG_INIT, "HFC-S USB: starting ISO-URBs for fifo:%d\n", |
514 | fifo->fifonum); | 456 | fifo->fifonum); |
515 | 457 | ||
516 | /* allocate Memory for Iso out Urbs */ | 458 | /* allocate Memory for Iso out Urbs */ |
517 | for (i = 0; i < 2; i++) { | 459 | for (i = 0; i < 2; i++) { |
@@ -556,10 +498,9 @@ start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, | |||
556 | 498 | ||
557 | errcode = usb_submit_urb(fifo->iso[i].purb, GFP_KERNEL); | 499 | errcode = usb_submit_urb(fifo->iso[i].purb, GFP_KERNEL); |
558 | fifo->active = (errcode >= 0) ? 1 : 0; | 500 | fifo->active = (errcode >= 0) ? 1 : 0; |
559 | if (errcode < 0) { | 501 | if (errcode < 0) |
560 | printk(KERN_INFO "HFC-S USB: %s URB nr:%d\n", | 502 | printk(KERN_INFO "HFC-S USB: usb_submit_urb URB nr:%d, error(%i): '%s'\n", |
561 | symbolic(urb_errlist, errcode), i); | 503 | i, errcode, symbolic(urb_errlist, errcode)); |
562 | }; | ||
563 | } | 504 | } |
564 | return (fifo->active); | 505 | return (fifo->active); |
565 | } | 506 | } |
@@ -572,16 +513,15 @@ stop_isoc_chain(usb_fifo * fifo) | |||
572 | 513 | ||
573 | for (i = 0; i < 2; i++) { | 514 | for (i = 0; i < 2; i++) { |
574 | if (fifo->iso[i].purb) { | 515 | if (fifo->iso[i].purb) { |
575 | #ifdef CONFIG_HISAX_DEBUG | 516 | DBG(HFCUSB_DBG_INIT, |
576 | DBG(USB_DBG, | ||
577 | "HFC-S USB: Stopping iso chain for fifo %i.%i", | 517 | "HFC-S USB: Stopping iso chain for fifo %i.%i", |
578 | fifo->fifonum, i); | 518 | fifo->fifonum, i); |
579 | #endif | ||
580 | usb_kill_urb(fifo->iso[i].purb); | 519 | usb_kill_urb(fifo->iso[i].purb); |
581 | usb_free_urb(fifo->iso[i].purb); | 520 | usb_free_urb(fifo->iso[i].purb); |
582 | fifo->iso[i].purb = NULL; | 521 | fifo->iso[i].purb = NULL; |
583 | } | 522 | } |
584 | } | 523 | } |
524 | |||
585 | usb_kill_urb(fifo->urb); | 525 | usb_kill_urb(fifo->urb); |
586 | usb_free_urb(fifo->urb); | 526 | usb_free_urb(fifo->urb); |
587 | fifo->urb = NULL; | 527 | fifo->urb = NULL; |
@@ -594,9 +534,6 @@ static int iso_packets[8] = | |||
594 | ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D | 534 | ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D |
595 | }; | 535 | }; |
596 | 536 | ||
597 | /*****************************************************/ | ||
598 | /* transmit completion routine for all ISO tx fifos */ | ||
599 | /*****************************************************/ | ||
600 | static void | 537 | static void |
601 | tx_iso_complete(struct urb *urb) | 538 | tx_iso_complete(struct urb *urb) |
602 | { | 539 | { |
@@ -607,20 +544,38 @@ tx_iso_complete(struct urb *urb) | |||
607 | errcode; | 544 | errcode; |
608 | int frame_complete, transp_mode, fifon, status; | 545 | int frame_complete, transp_mode, fifon, status; |
609 | __u8 threshbit; | 546 | __u8 threshbit; |
610 | __u8 threshtable[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 }; | ||
611 | 547 | ||
612 | fifon = fifo->fifonum; | 548 | fifon = fifo->fifonum; |
613 | status = urb->status; | 549 | status = urb->status; |
614 | 550 | ||
615 | tx_offset = 0; | 551 | tx_offset = 0; |
616 | 552 | ||
553 | /* ISO transfer only partially completed, | ||
554 | look at individual frame status for details */ | ||
555 | if (status == -EXDEV) { | ||
556 | DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete with -EXDEV" | ||
557 | ", urb->status %d, fifonum %d\n", | ||
558 | status, fifon); | ||
559 | |||
560 | for (k = 0; k < iso_packets[fifon]; ++k) { | ||
561 | errcode = urb->iso_frame_desc[k].status; | ||
562 | if (errcode) | ||
563 | DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete " | ||
564 | "packet %i, status: %i\n", | ||
565 | k, errcode); | ||
566 | } | ||
567 | |||
568 | // clear status, so go on with ISO transfers | ||
569 | status = 0; | ||
570 | } | ||
571 | |||
617 | if (fifo->active && !status) { | 572 | if (fifo->active && !status) { |
618 | transp_mode = 0; | 573 | transp_mode = 0; |
619 | if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS) | 574 | if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS) |
620 | transp_mode = true; | 575 | transp_mode = 1; |
621 | 576 | ||
622 | /* is FifoFull-threshold set for our channel? */ | 577 | /* is FifoFull-threshold set for our channel? */ |
623 | threshbit = threshtable[fifon] & hfc->threshold_mask; | 578 | threshbit = (hfc->threshold_mask & (1 << fifon)); |
624 | num_isoc_packets = iso_packets[fifon]; | 579 | num_isoc_packets = iso_packets[fifon]; |
625 | 580 | ||
626 | /* predict dataflow to avoid fifo overflow */ | 581 | /* predict dataflow to avoid fifo overflow */ |
@@ -635,8 +590,9 @@ tx_iso_complete(struct urb *urb) | |||
635 | tx_iso_complete, urb->context); | 590 | tx_iso_complete, urb->context); |
636 | memset(context_iso_urb->buffer, 0, | 591 | memset(context_iso_urb->buffer, 0, |
637 | sizeof(context_iso_urb->buffer)); | 592 | sizeof(context_iso_urb->buffer)); |
638 | frame_complete = false; | 593 | frame_complete = 0; |
639 | /* Generate next Iso Packets */ | 594 | |
595 | /* Generate next ISO Packets */ | ||
640 | for (k = 0; k < num_isoc_packets; ++k) { | 596 | for (k = 0; k < num_isoc_packets; ++k) { |
641 | if (fifo->skbuff) { | 597 | if (fifo->skbuff) { |
642 | len = fifo->skbuff->len; | 598 | len = fifo->skbuff->len; |
@@ -661,7 +617,7 @@ tx_iso_complete(struct urb *urb) | |||
661 | /* add 2 byte flags and 16bit CRC at end of ISDN frame */ | 617 | /* add 2 byte flags and 16bit CRC at end of ISDN frame */ |
662 | fifo->bit_line += 32; | 618 | fifo->bit_line += 32; |
663 | } | 619 | } |
664 | frame_complete = true; | 620 | frame_complete = 1; |
665 | } | 621 | } |
666 | 622 | ||
667 | memcpy(context_iso_urb->buffer + | 623 | memcpy(context_iso_urb->buffer + |
@@ -688,7 +644,7 @@ tx_iso_complete(struct urb *urb) | |||
688 | } | 644 | } |
689 | 645 | ||
690 | if (frame_complete) { | 646 | if (frame_complete) { |
691 | fifo->delete_flg = true; | 647 | fifo->delete_flg = 1; |
692 | fifo->hif->l1l2(fifo->hif, | 648 | fifo->hif->l1l2(fifo->hif, |
693 | PH_DATA | CONFIRM, | 649 | PH_DATA | CONFIRM, |
694 | (void *) (unsigned long) fifo->skbuff-> | 650 | (void *) (unsigned long) fifo->skbuff-> |
@@ -696,30 +652,26 @@ tx_iso_complete(struct urb *urb) | |||
696 | if (fifo->skbuff && fifo->delete_flg) { | 652 | if (fifo->skbuff && fifo->delete_flg) { |
697 | dev_kfree_skb_any(fifo->skbuff); | 653 | dev_kfree_skb_any(fifo->skbuff); |
698 | fifo->skbuff = NULL; | 654 | fifo->skbuff = NULL; |
699 | fifo->delete_flg = false; | 655 | fifo->delete_flg = 0; |
700 | } | 656 | } |
701 | frame_complete = false; | 657 | frame_complete = 0; |
702 | } | 658 | } |
703 | } | 659 | } |
704 | errcode = usb_submit_urb(urb, GFP_ATOMIC); | 660 | errcode = usb_submit_urb(urb, GFP_ATOMIC); |
705 | if (errcode < 0) { | 661 | if (errcode < 0) { |
706 | printk(KERN_INFO | 662 | printk(KERN_INFO |
707 | "HFC-S USB: error submitting ISO URB: %d \n", | 663 | "HFC-S USB: error submitting ISO URB: %d\n", |
708 | errcode); | 664 | errcode); |
709 | } | 665 | } |
710 | } else { | 666 | } else { |
711 | if (status && !hfc->disc_flag) { | 667 | if (status && !hfc->disc_flag) { |
712 | printk(KERN_INFO | 668 | printk(KERN_INFO |
713 | "HFC-S USB: tx_iso_complete : urb->status %s (%i), fifonum=%d\n", | 669 | "HFC-S USB: tx_iso_complete: error(%i): '%s', fifonum=%d\n", |
714 | symbolic(urb_errlist, status), status, | 670 | status, symbolic(urb_errlist, status), fifon); |
715 | fifon); | ||
716 | } | 671 | } |
717 | } | 672 | } |
718 | } /* tx_iso_complete */ | 673 | } |
719 | 674 | ||
720 | /*****************************************************/ | ||
721 | /* receive completion routine for all ISO tx fifos */ | ||
722 | /*****************************************************/ | ||
723 | static void | 675 | static void |
724 | rx_iso_complete(struct urb *urb) | 676 | rx_iso_complete(struct urb *urb) |
725 | { | 677 | { |
@@ -731,21 +683,25 @@ rx_iso_complete(struct urb *urb) | |||
731 | unsigned int iso_status; | 683 | unsigned int iso_status; |
732 | __u8 *buf; | 684 | __u8 *buf; |
733 | static __u8 eof[8]; | 685 | static __u8 eof[8]; |
734 | #ifdef CONFIG_HISAX_DEBUG | ||
735 | __u8 i; | ||
736 | #endif | ||
737 | 686 | ||
738 | fifon = fifo->fifonum; | 687 | fifon = fifo->fifonum; |
739 | status = urb->status; | 688 | status = urb->status; |
740 | 689 | ||
741 | if (urb->status == -EOVERFLOW) { | 690 | if (urb->status == -EOVERFLOW) { |
742 | #ifdef CONFIG_HISAX_DEBUG | 691 | DBG(HFCUSB_DBG_VERBOSE_USB, |
743 | DBG(USB_DBG, | 692 | "HFC-USB: ignoring USB DATAOVERRUN fifo(%i)", fifon); |
744 | "HFC-USB: ignoring USB DATAOVERRUN for fifo %i \n", | 693 | status = 0; |
745 | fifon); | 694 | } |
746 | #endif | 695 | |
696 | /* ISO transfer only partially completed, | ||
697 | look at individual frame status for details */ | ||
698 | if (status == -EXDEV) { | ||
699 | DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: rx_iso_complete with -EXDEV " | ||
700 | "urb->status %d, fifonum %d\n", | ||
701 | status, fifon); | ||
747 | status = 0; | 702 | status = 0; |
748 | } | 703 | } |
704 | |||
749 | if (fifo->active && !status) { | 705 | if (fifo->active && !status) { |
750 | num_isoc_packets = iso_packets[fifon]; | 706 | num_isoc_packets = iso_packets[fifon]; |
751 | maxlen = fifo->usb_packet_maxlen; | 707 | maxlen = fifo->usb_packet_maxlen; |
@@ -754,40 +710,38 @@ rx_iso_complete(struct urb *urb) | |||
754 | offset = urb->iso_frame_desc[k].offset; | 710 | offset = urb->iso_frame_desc[k].offset; |
755 | buf = context_iso_urb->buffer + offset; | 711 | buf = context_iso_urb->buffer + offset; |
756 | iso_status = urb->iso_frame_desc[k].status; | 712 | iso_status = urb->iso_frame_desc[k].status; |
757 | #ifdef CONFIG_HISAX_DEBUG | 713 | |
758 | if (iso_status && !hfc->disc_flag) | 714 | if (iso_status && !hfc->disc_flag) |
759 | DBG(USB_DBG, | 715 | DBG(HFCUSB_DBG_VERBOSE_USB, |
760 | "HFC-S USB: ISO packet failure - status:%x", | 716 | "HFC-S USB: rx_iso_complete " |
761 | iso_status); | 717 | "ISO packet %i, status: %i\n", |
718 | k, iso_status); | ||
762 | 719 | ||
763 | if ((fifon == 5) && (debug > 1)) { | 720 | if (fifon == HFCUSB_D_RX) { |
764 | printk(KERN_INFO | 721 | DBG(HFCUSB_DBG_VERBOSE_USB, |
765 | "HFC-S USB: ISO-D-RX lst_urblen:%2d " | 722 | "HFC-S USB: ISO-D-RX lst_urblen:%2d " |
766 | "act_urblen:%2d max-urblen:%2d " | 723 | "act_urblen:%2d max-urblen:%2d EOF:0x%0x", |
767 | "EOF:0x%0x DATA: ", | ||
768 | fifo->last_urblen, len, maxlen, | 724 | fifo->last_urblen, len, maxlen, |
769 | eof[5]); | 725 | eof[5]); |
770 | for (i = 0; i < len; i++) | 726 | |
771 | printk("%.2x ", buf[i]); | 727 | DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len); |
772 | printk("\n"); | ||
773 | } | 728 | } |
774 | #endif | 729 | |
775 | if (fifo->last_urblen != maxlen) { | 730 | if (fifo->last_urblen != maxlen) { |
776 | /* the threshold mask is in the 2nd status byte */ | 731 | /* the threshold mask is in the 2nd status byte */ |
777 | hfc->threshold_mask = buf[1]; | 732 | hfc->threshold_mask = buf[1]; |
778 | /* care for L1 state only for D-Channel | 733 | /* care for L1 state only for D-Channel |
779 | to avoid overlapped iso completions */ | 734 | to avoid overlapped iso completions */ |
780 | if (fifon == 5) { | 735 | if (fifon == HFCUSB_D_RX) { |
781 | /* the S0 state is in the upper half | 736 | /* the S0 state is in the upper half |
782 | of the 1st status byte */ | 737 | of the 1st status byte */ |
783 | state_handler(hfc, buf[0] >> 4); | 738 | s0_state_handler(hfc, buf[0] >> 4); |
784 | } | 739 | } |
785 | eof[fifon] = buf[0] & 1; | 740 | eof[fifon] = buf[0] & 1; |
786 | if (len > 2) | 741 | if (len > 2) |
787 | collect_rx_frame(fifo, buf + 2, | 742 | collect_rx_frame(fifo, buf + 2, |
788 | len - 2, | 743 | len - 2, |
789 | (len < | 744 | (len < maxlen) ? |
790 | maxlen) ? | ||
791 | eof[fifon] : 0); | 745 | eof[fifon] : 0); |
792 | } else { | 746 | } else { |
793 | collect_rx_frame(fifo, buf, len, | 747 | collect_rx_frame(fifo, buf, len, |
@@ -804,41 +758,37 @@ rx_iso_complete(struct urb *urb) | |||
804 | rx_iso_complete, urb->context); | 758 | rx_iso_complete, urb->context); |
805 | errcode = usb_submit_urb(urb, GFP_ATOMIC); | 759 | errcode = usb_submit_urb(urb, GFP_ATOMIC); |
806 | if (errcode < 0) { | 760 | if (errcode < 0) { |
807 | printk(KERN_INFO | 761 | printk(KERN_ERR |
808 | "HFC-S USB: error submitting ISO URB: %d \n", | 762 | "HFC-S USB: error submitting ISO URB: %d\n", |
809 | errcode); | 763 | errcode); |
810 | } | 764 | } |
811 | } else { | 765 | } else { |
812 | if (status && !hfc->disc_flag) { | 766 | if (status && !hfc->disc_flag) { |
813 | printk(KERN_INFO | 767 | printk(KERN_ERR |
814 | "HFC-S USB: rx_iso_complete : " | 768 | "HFC-S USB: rx_iso_complete : " |
815 | "urb->status %d, fifonum %d\n", | 769 | "urb->status %d, fifonum %d\n", |
816 | status, fifon); | 770 | status, fifon); |
817 | } | 771 | } |
818 | } | 772 | } |
819 | } /* rx_iso_complete */ | 773 | } |
820 | 774 | ||
821 | /*****************************************************/ | 775 | /* collect rx data from INT- and ISO-URBs */ |
822 | /* collect data from interrupt or isochron in */ | ||
823 | /*****************************************************/ | ||
824 | static void | 776 | static void |
825 | collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) | 777 | collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) |
826 | { | 778 | { |
827 | hfcusb_data *hfc = fifo->hfc; | 779 | hfcusb_data *hfc = fifo->hfc; |
828 | int transp_mode, fifon; | 780 | int transp_mode, fifon; |
829 | #ifdef CONFIG_HISAX_DEBUG | 781 | |
830 | int i; | ||
831 | #endif | ||
832 | fifon = fifo->fifonum; | 782 | fifon = fifo->fifonum; |
833 | transp_mode = 0; | 783 | transp_mode = 0; |
834 | if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS) | 784 | if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS) |
835 | transp_mode = true; | 785 | transp_mode = 1; |
836 | 786 | ||
837 | if (!fifo->skbuff) { | 787 | if (!fifo->skbuff) { |
838 | fifo->skbuff = dev_alloc_skb(fifo->max_size + 3); | 788 | fifo->skbuff = dev_alloc_skb(fifo->max_size + 3); |
839 | if (!fifo->skbuff) { | 789 | if (!fifo->skbuff) { |
840 | printk(KERN_INFO | 790 | printk(KERN_ERR |
841 | "HFC-S USB: cannot allocate buffer (dev_alloc_skb) fifo:%d\n", | 791 | "HFC-S USB: cannot allocate buffer for fifo(%d)\n", |
842 | fifon); | 792 | fifon); |
843 | return; | 793 | return; |
844 | } | 794 | } |
@@ -847,17 +797,11 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) | |||
847 | if (fifo->skbuff->len + len < fifo->max_size) { | 797 | if (fifo->skbuff->len + len < fifo->max_size) { |
848 | memcpy(skb_put(fifo->skbuff, len), data, len); | 798 | memcpy(skb_put(fifo->skbuff, len), data, len); |
849 | } else { | 799 | } else { |
850 | #ifdef CONFIG_HISAX_DEBUG | 800 | DBG(HFCUSB_DBG_FIFO_ERR, |
851 | printk(KERN_INFO "HFC-S USB: "); | 801 | "HCF-USB: got frame exceeded fifo->max_size(%d) fifo(%d)", |
852 | for (i = 0; i < 15; i++) | ||
853 | printk("%.2x ", | ||
854 | fifo->skbuff->data[fifo->skbuff-> | ||
855 | len - 15 + i]); | ||
856 | printk("\n"); | ||
857 | #endif | ||
858 | printk(KERN_INFO | ||
859 | "HCF-USB: got frame exceeded fifo->max_size:%d on fifo:%d\n", | ||
860 | fifo->max_size, fifon); | 802 | fifo->max_size, fifon); |
803 | DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff); | ||
804 | skb_trim(fifo->skbuff, 0); | ||
861 | } | 805 | } |
862 | } | 806 | } |
863 | if (transp_mode && fifo->skbuff->len >= 128) { | 807 | if (transp_mode && fifo->skbuff->len >= 128) { |
@@ -870,6 +814,13 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) | |||
870 | if (finish) { | 814 | if (finish) { |
871 | if ((!fifo->skbuff->data[fifo->skbuff->len - 1]) | 815 | if ((!fifo->skbuff->data[fifo->skbuff->len - 1]) |
872 | && (fifo->skbuff->len > 3)) { | 816 | && (fifo->skbuff->len > 3)) { |
817 | |||
818 | if (fifon == HFCUSB_D_RX) { | ||
819 | DBG(HFCUSB_DBG_DCHANNEL, | ||
820 | "HFC-S USB: D-RX len(%d)", fifo->skbuff->len); | ||
821 | DBG_SKB(HFCUSB_DBG_DCHANNEL, fifo->skbuff); | ||
822 | } | ||
823 | |||
873 | /* remove CRC & status */ | 824 | /* remove CRC & status */ |
874 | skb_trim(fifo->skbuff, fifo->skbuff->len - 3); | 825 | skb_trim(fifo->skbuff, fifo->skbuff->len - 3); |
875 | if (fifon == HFCUSB_PCM_RX) { | 826 | if (fifon == HFCUSB_PCM_RX) { |
@@ -882,39 +833,17 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) | |||
882 | fifo->skbuff); | 833 | fifo->skbuff); |
883 | fifo->skbuff = NULL; /* buffer was freed from upper layer */ | 834 | fifo->skbuff = NULL; /* buffer was freed from upper layer */ |
884 | } else { | 835 | } else { |
885 | if (fifo->skbuff->len > 3) { | 836 | DBG(HFCUSB_DBG_FIFO_ERR, |
886 | printk(KERN_INFO | 837 | "HFC-S USB: ERROR frame len(%d) fifo(%d)", |
887 | "HFC-S USB: got frame %d bytes but CRC ERROR on fifo:%d!!!\n", | 838 | fifo->skbuff->len, fifon); |
888 | fifo->skbuff->len, fifon); | 839 | DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff); |
889 | #ifdef CONFIG_HISAX_DEBUG | ||
890 | if (debug > 1) { | ||
891 | printk(KERN_INFO "HFC-S USB: "); | ||
892 | for (i = 0; i < 15; i++) | ||
893 | printk("%.2x ", | ||
894 | fifo->skbuff-> | ||
895 | data[fifo->skbuff-> | ||
896 | len - 15 + i]); | ||
897 | printk("\n"); | ||
898 | } | ||
899 | #endif | ||
900 | } | ||
901 | #ifdef CONFIG_HISAX_DEBUG | ||
902 | else { | ||
903 | printk(KERN_INFO | ||
904 | "HFC-S USB: frame to small (%d bytes)!!!\n", | ||
905 | fifo->skbuff->len); | ||
906 | } | ||
907 | #endif | ||
908 | skb_trim(fifo->skbuff, 0); | 840 | skb_trim(fifo->skbuff, 0); |
909 | } | 841 | } |
910 | } | 842 | } |
911 | } | 843 | } |
912 | 844 | ||
913 | /***********************************************/ | ||
914 | /* receive completion routine for all rx fifos */ | ||
915 | /***********************************************/ | ||
916 | static void | 845 | static void |
917 | rx_complete(struct urb *urb) | 846 | rx_int_complete(struct urb *urb) |
918 | { | 847 | { |
919 | int len; | 848 | int len; |
920 | int status; | 849 | int status; |
@@ -922,18 +851,14 @@ rx_complete(struct urb *urb) | |||
922 | usb_fifo *fifo = (usb_fifo *) urb->context; | 851 | usb_fifo *fifo = (usb_fifo *) urb->context; |
923 | hfcusb_data *hfc = fifo->hfc; | 852 | hfcusb_data *hfc = fifo->hfc; |
924 | static __u8 eof[8]; | 853 | static __u8 eof[8]; |
925 | #ifdef CONFIG_HISAX_DEBUG | ||
926 | __u8 i; | ||
927 | #endif | ||
928 | 854 | ||
929 | urb->dev = hfc->dev; /* security init */ | 855 | urb->dev = hfc->dev; /* security init */ |
930 | 856 | ||
931 | fifon = fifo->fifonum; | 857 | fifon = fifo->fifonum; |
932 | if ((!fifo->active) || (urb->status)) { | 858 | if ((!fifo->active) || (urb->status)) { |
933 | #ifdef CONFIG_HISAX_DEBUG | 859 | DBG(HFCUSB_DBG_INIT, "HFC-S USB: RX-Fifo %i is going down (%i)", |
934 | DBG(USB_DBG, "HFC-S USB: RX-Fifo %i is going down (%i)", | ||
935 | fifon, urb->status); | 860 | fifon, urb->status); |
936 | #endif | 861 | |
937 | fifo->urb->interval = 0; /* cancel automatic rescheduling */ | 862 | fifo->urb->interval = 0; /* cancel automatic rescheduling */ |
938 | if (fifo->skbuff) { | 863 | if (fifo->skbuff) { |
939 | dev_kfree_skb_any(fifo->skbuff); | 864 | dev_kfree_skb_any(fifo->skbuff); |
@@ -945,22 +870,20 @@ rx_complete(struct urb *urb) | |||
945 | buf = fifo->buffer; | 870 | buf = fifo->buffer; |
946 | maxlen = fifo->usb_packet_maxlen; | 871 | maxlen = fifo->usb_packet_maxlen; |
947 | 872 | ||
948 | #ifdef CONFIG_HISAX_DEBUG | 873 | if (fifon == HFCUSB_D_RX) { |
949 | if ((fifon == 5) && (debug > 1)) { | 874 | DBG(HFCUSB_DBG_VERBOSE_USB, |
950 | printk(KERN_INFO | 875 | "HFC-S USB: INT-D-RX lst_urblen:%2d " |
951 | "HFC-S USB: INT-D-RX lst_urblen:%2d act_urblen:%2d max-urblen:%2d EOF:0x%0x DATA: ", | 876 | "act_urblen:%2d max-urblen:%2d EOF:0x%0x", |
952 | fifo->last_urblen, len, maxlen, eof[5]); | 877 | fifo->last_urblen, len, maxlen, |
953 | for (i = 0; i < len; i++) | 878 | eof[5]); |
954 | printk("%.2x ", buf[i]); | 879 | DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len); |
955 | printk("\n"); | ||
956 | } | 880 | } |
957 | #endif | ||
958 | 881 | ||
959 | if (fifo->last_urblen != fifo->usb_packet_maxlen) { | 882 | if (fifo->last_urblen != fifo->usb_packet_maxlen) { |
960 | /* the threshold mask is in the 2nd status byte */ | 883 | /* the threshold mask is in the 2nd status byte */ |
961 | hfc->threshold_mask = buf[1]; | 884 | hfc->threshold_mask = buf[1]; |
962 | /* the S0 state is in the upper half of the 1st status byte */ | 885 | /* the S0 state is in the upper half of the 1st status byte */ |
963 | state_handler(hfc, buf[0] >> 4); | 886 | s0_state_handler(hfc, buf[0] >> 4); |
964 | eof[fifon] = buf[0] & 1; | 887 | eof[fifon] = buf[0] & 1; |
965 | /* if we have more than the 2 status bytes -> collect data */ | 888 | /* if we have more than the 2 status bytes -> collect data */ |
966 | if (len > 2) | 889 | if (len > 2) |
@@ -975,20 +898,19 @@ rx_complete(struct urb *urb) | |||
975 | status = usb_submit_urb(urb, GFP_ATOMIC); | 898 | status = usb_submit_urb(urb, GFP_ATOMIC); |
976 | if (status) { | 899 | if (status) { |
977 | printk(KERN_INFO | 900 | printk(KERN_INFO |
978 | "HFC-S USB: error resubmitting URN at rx_complete...\n"); | 901 | "HFC-S USB: %s error resubmitting URB fifo(%d)\n", |
902 | __FUNCTION__, fifon); | ||
979 | } | 903 | } |
980 | } /* rx_complete */ | 904 | } |
981 | 905 | ||
982 | /***************************************************/ | 906 | /* start initial INT-URB for certain fifo */ |
983 | /* start the interrupt transfer for the given fifo */ | ||
984 | /***************************************************/ | ||
985 | static void | 907 | static void |
986 | start_int_fifo(usb_fifo * fifo) | 908 | start_int_fifo(usb_fifo * fifo) |
987 | { | 909 | { |
988 | int errcode; | 910 | int errcode; |
989 | 911 | ||
990 | printk(KERN_INFO "HFC-S USB: starting intr IN fifo:%d\n", | 912 | DBG(HFCUSB_DBG_INIT, "HFC-S USB: starting RX INT-URB for fifo:%d\n", |
991 | fifo->fifonum); | 913 | fifo->fifonum); |
992 | 914 | ||
993 | if (!fifo->urb) { | 915 | if (!fifo->urb) { |
994 | fifo->urb = usb_alloc_urb(0, GFP_KERNEL); | 916 | fifo->urb = usb_alloc_urb(0, GFP_KERNEL); |
@@ -997,33 +919,28 @@ start_int_fifo(usb_fifo * fifo) | |||
997 | } | 919 | } |
998 | usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe, | 920 | usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe, |
999 | fifo->buffer, fifo->usb_packet_maxlen, | 921 | fifo->buffer, fifo->usb_packet_maxlen, |
1000 | rx_complete, fifo, fifo->intervall); | 922 | rx_int_complete, fifo, fifo->intervall); |
1001 | fifo->active = 1; /* must be marked active */ | 923 | fifo->active = 1; /* must be marked active */ |
1002 | errcode = usb_submit_urb(fifo->urb, GFP_KERNEL); | 924 | errcode = usb_submit_urb(fifo->urb, GFP_KERNEL); |
1003 | if (errcode) { | 925 | if (errcode) { |
1004 | printk(KERN_INFO | 926 | printk(KERN_ERR |
1005 | "HFC-S USB: submit URB error(start_int_info): status:%i\n", | 927 | "HFC-S USB: submit URB error(start_int_info): status:%i\n", |
1006 | errcode); | 928 | errcode); |
1007 | fifo->active = 0; | 929 | fifo->active = 0; |
1008 | fifo->skbuff = NULL; | 930 | fifo->skbuff = NULL; |
1009 | } | 931 | } |
1010 | } /* start_int_fifo */ | 932 | } |
1011 | 933 | ||
1012 | /*****************************/ | ||
1013 | /* set the B-channel mode */ | ||
1014 | /*****************************/ | ||
1015 | static void | 934 | static void |
1016 | set_hfcmode(hfcusb_data * hfc, int channel, int mode) | 935 | setup_bchannel(hfcusb_data * hfc, int channel, int mode) |
1017 | { | 936 | { |
1018 | __u8 val, idx_table[2] = { 0, 2 }; | 937 | __u8 val, idx_table[2] = { 0, 2 }; |
1019 | 938 | ||
1020 | if (hfc->disc_flag) { | 939 | if (hfc->disc_flag) { |
1021 | return; | 940 | return; |
1022 | } | 941 | } |
1023 | #ifdef CONFIG_HISAX_DEBUG | 942 | DBG(HFCUSB_DBG_STATES, "HFC-S USB: setting channel %d to mode %d", |
1024 | DBG(ISDN_DBG, "HFC-S USB: setting channel %d to mode %d", channel, | 943 | channel, mode); |
1025 | mode); | ||
1026 | #endif | ||
1027 | hfc->b_mode[channel] = mode; | 944 | hfc->b_mode[channel] = mode; |
1028 | 945 | ||
1029 | /* setup CON_HDLC */ | 946 | /* setup CON_HDLC */ |
@@ -1080,20 +997,17 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg) | |||
1080 | switch (pr) { | 997 | switch (pr) { |
1081 | case PH_ACTIVATE | REQUEST: | 998 | case PH_ACTIVATE | REQUEST: |
1082 | if (fifo->fifonum == HFCUSB_D_TX) { | 999 | if (fifo->fifonum == HFCUSB_D_TX) { |
1083 | #ifdef CONFIG_HISAX_DEBUG | 1000 | DBG(HFCUSB_DBG_STATES, |
1084 | DBG(ISDN_DBG, | ||
1085 | "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST"); | 1001 | "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST"); |
1086 | #endif | 1002 | |
1087 | if (hfc->l1_state != 3 | 1003 | if (hfc->l1_state != 3 |
1088 | && hfc->l1_state != 7) { | 1004 | && hfc->l1_state != 7) { |
1089 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, | 1005 | hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, |
1090 | PH_DEACTIVATE | | 1006 | PH_DEACTIVATE | |
1091 | INDICATION, | 1007 | INDICATION, |
1092 | NULL); | 1008 | NULL); |
1093 | #ifdef CONFIG_HISAX_DEBUG | 1009 | DBG(HFCUSB_DBG_STATES, |
1094 | DBG(ISDN_DBG, | ||
1095 | "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)"); | 1010 | "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)"); |
1096 | #endif | ||
1097 | } else { | 1011 | } else { |
1098 | if (hfc->l1_state == 7) { /* l1 already active */ | 1012 | if (hfc->l1_state == 7) { /* l1 already active */ |
1099 | hfc->d_if.ifc.l1l2(&hfc-> | 1013 | hfc->d_if.ifc.l1l2(&hfc-> |
@@ -1103,10 +1017,8 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg) | |||
1103 | | | 1017 | | |
1104 | INDICATION, | 1018 | INDICATION, |
1105 | NULL); | 1019 | NULL); |
1106 | #ifdef CONFIG_HISAX_DEBUG | 1020 | DBG(HFCUSB_DBG_STATES, |
1107 | DBG(ISDN_DBG, | ||
1108 | "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)"); | 1021 | "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)"); |
1109 | #endif | ||
1110 | } else { | 1022 | } else { |
1111 | /* force sending sending INFO1 */ | 1023 | /* force sending sending INFO1 */ |
1112 | queue_control_request(hfc, | 1024 | queue_control_request(hfc, |
@@ -1132,11 +1044,9 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg) | |||
1132 | } | 1044 | } |
1133 | } | 1045 | } |
1134 | } else { | 1046 | } else { |
1135 | #ifdef CONFIG_HISAX_DEBUG | 1047 | DBG(HFCUSB_DBG_STATES, |
1136 | DBG(ISDN_DBG, | 1048 | "HFC_USB: hfc_usb_d_l2l1 B-chan: PH_ACTIVATE | REQUEST"); |
1137 | "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_ACTIVATE | REQUEST"); | 1049 | setup_bchannel(hfc, |
1138 | #endif | ||
1139 | set_hfcmode(hfc, | ||
1140 | (fifo->fifonum == | 1050 | (fifo->fifonum == |
1141 | HFCUSB_B1_TX) ? 0 : 1, | 1051 | HFCUSB_B1_TX) ? 0 : 1, |
1142 | (long) arg); | 1052 | (long) arg); |
@@ -1147,18 +1057,12 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg) | |||
1147 | break; | 1057 | break; |
1148 | case PH_DEACTIVATE | REQUEST: | 1058 | case PH_DEACTIVATE | REQUEST: |
1149 | if (fifo->fifonum == HFCUSB_D_TX) { | 1059 | if (fifo->fifonum == HFCUSB_D_TX) { |
1150 | #ifdef CONFIG_HISAX_DEBUG | 1060 | DBG(HFCUSB_DBG_STATES, |
1151 | DBG(ISDN_DBG, | ||
1152 | "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST"); | 1061 | "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST"); |
1153 | #endif | ||
1154 | printk(KERN_INFO | ||
1155 | "HFC-S USB: ISDN TE device should not deativate...\n"); | ||
1156 | } else { | 1062 | } else { |
1157 | #ifdef CONFIG_HISAX_DEBUG | 1063 | DBG(HFCUSB_DBG_STATES, |
1158 | DBG(ISDN_DBG, | ||
1159 | "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST"); | 1064 | "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST"); |
1160 | #endif | 1065 | setup_bchannel(hfc, |
1161 | set_hfcmode(hfc, | ||
1162 | (fifo->fifonum == | 1066 | (fifo->fifonum == |
1163 | HFCUSB_B1_TX) ? 0 : 1, | 1067 | HFCUSB_B1_TX) ? 0 : 1, |
1164 | (int) L1_MODE_NULL); | 1068 | (int) L1_MODE_NULL); |
@@ -1171,25 +1075,20 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg) | |||
1171 | if (fifo->skbuff && fifo->delete_flg) { | 1075 | if (fifo->skbuff && fifo->delete_flg) { |
1172 | dev_kfree_skb_any(fifo->skbuff); | 1076 | dev_kfree_skb_any(fifo->skbuff); |
1173 | fifo->skbuff = NULL; | 1077 | fifo->skbuff = NULL; |
1174 | fifo->delete_flg = false; | 1078 | fifo->delete_flg = 0; |
1175 | } | 1079 | } |
1176 | fifo->skbuff = arg; /* we have a new buffer */ | 1080 | fifo->skbuff = arg; /* we have a new buffer */ |
1177 | break; | 1081 | break; |
1178 | default: | 1082 | default: |
1179 | printk(KERN_INFO | 1083 | DBG(HFCUSB_DBG_STATES, |
1180 | "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x\n", | 1084 | "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x", pr); |
1181 | pr); | ||
1182 | break; | 1085 | break; |
1183 | } | 1086 | } |
1184 | } | 1087 | } |
1185 | 1088 | ||
1186 | /***************************************************************************/ | 1089 | /* initial init HFC-S USB chip registers, HiSax interface, USB URBs */ |
1187 | /* usb_init is called once when a new matching device is detected to setup */ | ||
1188 | /* main parameters. It registers the driver at the main hisax module. */ | ||
1189 | /* on success 0 is returned. */ | ||
1190 | /***************************************************************************/ | ||
1191 | static int | 1090 | static int |
1192 | usb_init(hfcusb_data * hfc) | 1091 | hfc_usb_init(hfcusb_data * hfc) |
1193 | { | 1092 | { |
1194 | usb_fifo *fifo; | 1093 | usb_fifo *fifo; |
1195 | int i, err; | 1094 | int i, err; |
@@ -1214,11 +1113,11 @@ usb_init(hfcusb_data * hfc) | |||
1214 | /* aux = output, reset off */ | 1113 | /* aux = output, reset off */ |
1215 | write_usb(hfc, HFCUSB_CIRM, 0x10); | 1114 | write_usb(hfc, HFCUSB_CIRM, 0x10); |
1216 | 1115 | ||
1217 | /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */ | 1116 | /* set USB_SIZE to match wMaxPacketSize for INT or BULK transfers */ |
1218 | write_usb(hfc, HFCUSB_USB_SIZE, | 1117 | write_usb(hfc, HFCUSB_USB_SIZE, |
1219 | (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4)); | 1118 | (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4)); |
1220 | 1119 | ||
1221 | /* set USB_SIZE_I to match the wMaxPacketSize for ISO transfers */ | 1120 | /* set USB_SIZE_I to match wMaxPacketSize for ISO transfers */ |
1222 | write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size); | 1121 | write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size); |
1223 | 1122 | ||
1224 | /* enable PCM/GCI master mode */ | 1123 | /* enable PCM/GCI master mode */ |
@@ -1257,8 +1156,8 @@ usb_init(hfcusb_data * hfc) | |||
1257 | hfc->b_mode[0] = L1_MODE_NULL; | 1156 | hfc->b_mode[0] = L1_MODE_NULL; |
1258 | hfc->b_mode[1] = L1_MODE_NULL; | 1157 | hfc->b_mode[1] = L1_MODE_NULL; |
1259 | 1158 | ||
1260 | hfc->l1_activated = false; | 1159 | hfc->l1_activated = 0; |
1261 | hfc->disc_flag = false; | 1160 | hfc->disc_flag = 0; |
1262 | hfc->led_state = 0; | 1161 | hfc->led_state = 0; |
1263 | hfc->led_new_data = 0; | 1162 | hfc->led_new_data = 0; |
1264 | hfc->old_led_state = 0; | 1163 | hfc->old_led_state = 0; |
@@ -1349,11 +1248,9 @@ usb_init(hfcusb_data * hfc) | |||
1349 | handle_led(hfc, LED_POWER_ON); | 1248 | handle_led(hfc, LED_POWER_ON); |
1350 | 1249 | ||
1351 | return (0); | 1250 | return (0); |
1352 | } /* usb_init */ | 1251 | } |
1353 | 1252 | ||
1354 | /*************************************************/ | 1253 | /* initial callback for each plugged USB device */ |
1355 | /* function called to probe a new plugged device */ | ||
1356 | /*************************************************/ | ||
1357 | static int | 1254 | static int |
1358 | hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | 1255 | hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
1359 | { | 1256 | { |
@@ -1378,11 +1275,6 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1378 | } | 1275 | } |
1379 | } | 1276 | } |
1380 | 1277 | ||
1381 | #ifdef CONFIG_HISAX_DEBUG | ||
1382 | DBG(USB_DBG, | ||
1383 | "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", ifnum, | ||
1384 | iface->desc.bAlternateSetting, intf->minor); | ||
1385 | #endif | ||
1386 | printk(KERN_INFO | 1278 | printk(KERN_INFO |
1387 | "HFC-S USB: probing interface(%d) actalt(%d) minor(%d)\n", | 1279 | "HFC-S USB: probing interface(%d) actalt(%d) minor(%d)\n", |
1388 | ifnum, iface->desc.bAlternateSetting, intf->minor); | 1280 | ifnum, iface->desc.bAlternateSetting, intf->minor); |
@@ -1403,15 +1295,11 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1403 | 1295 | ||
1404 | /* check for config EOL element */ | 1296 | /* check for config EOL element */ |
1405 | while (validconf[cfg_used][0]) { | 1297 | while (validconf[cfg_used][0]) { |
1406 | cfg_found = true; | 1298 | cfg_found = 1; |
1407 | vcf = validconf[cfg_used]; | 1299 | vcf = validconf[cfg_used]; |
1408 | /* first endpoint descriptor */ | 1300 | /* first endpoint descriptor */ |
1409 | ep = iface->endpoint; | 1301 | ep = iface->endpoint; |
1410 | #ifdef CONFIG_HISAX_DEBUG | 1302 | |
1411 | DBG(USB_DBG, | ||
1412 | "HFC-S USB: (if=%d alt=%d cfg_used=%d)\n", | ||
1413 | ifnum, probe_alt_setting, cfg_used); | ||
1414 | #endif | ||
1415 | memcpy(cmptbl, vcf, 16 * sizeof(int)); | 1303 | memcpy(cmptbl, vcf, 16 * sizeof(int)); |
1416 | 1304 | ||
1417 | /* check for all endpoints in this alternate setting */ | 1305 | /* check for all endpoints in this alternate setting */ |
@@ -1425,7 +1313,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1425 | idx++; | 1313 | idx++; |
1426 | attr = ep->desc.bmAttributes; | 1314 | attr = ep->desc.bmAttributes; |
1427 | if (cmptbl[idx] == EP_NUL) { | 1315 | if (cmptbl[idx] == EP_NUL) { |
1428 | cfg_found = false; | 1316 | cfg_found = 0; |
1429 | } | 1317 | } |
1430 | if (attr == USB_ENDPOINT_XFER_INT | 1318 | if (attr == USB_ENDPOINT_XFER_INT |
1431 | && cmptbl[idx] == EP_INT) | 1319 | && cmptbl[idx] == EP_INT) |
@@ -1438,16 +1326,9 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1438 | cmptbl[idx] = EP_NUL; | 1326 | cmptbl[idx] = EP_NUL; |
1439 | 1327 | ||
1440 | /* check if all INT endpoints match minimum interval */ | 1328 | /* check if all INT endpoints match minimum interval */ |
1441 | if (attr == USB_ENDPOINT_XFER_INT | 1329 | if ((attr == USB_ENDPOINT_XFER_INT) |
1442 | && ep->desc.bInterval < | 1330 | && (ep->desc.bInterval < vcf[17])) { |
1443 | vcf[17]) { | 1331 | cfg_found = 0; |
1444 | #ifdef CONFIG_HISAX_DEBUG | ||
1445 | if (cfg_found) | ||
1446 | DBG(USB_DBG, | ||
1447 | "HFC-S USB: Interrupt Endpoint interval < %d found - skipping config", | ||
1448 | vcf[17]); | ||
1449 | #endif | ||
1450 | cfg_found = false; | ||
1451 | } | 1332 | } |
1452 | ep++; | 1333 | ep++; |
1453 | } | 1334 | } |
@@ -1455,7 +1336,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1455 | /* all entries must be EP_NOP or EP_NUL for a valid config */ | 1336 | /* all entries must be EP_NOP or EP_NUL for a valid config */ |
1456 | if (cmptbl[i] != EP_NOP | 1337 | if (cmptbl[i] != EP_NOP |
1457 | && cmptbl[i] != EP_NUL) | 1338 | && cmptbl[i] != EP_NUL) |
1458 | cfg_found = false; | 1339 | cfg_found = 0; |
1459 | } | 1340 | } |
1460 | if (cfg_found) { | 1341 | if (cfg_found) { |
1461 | if (cfg_used < small_match) { | 1342 | if (cfg_used < small_match) { |
@@ -1464,23 +1345,16 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1464 | probe_alt_setting; | 1345 | probe_alt_setting; |
1465 | iface_used = iface; | 1346 | iface_used = iface; |
1466 | } | 1347 | } |
1467 | #ifdef CONFIG_HISAX_DEBUG | ||
1468 | DBG(USB_DBG, | ||
1469 | "HFC-USB: small_match=%x %x\n", | ||
1470 | small_match, alt_used); | ||
1471 | #endif | ||
1472 | } | 1348 | } |
1473 | cfg_used++; | 1349 | cfg_used++; |
1474 | } | 1350 | } |
1475 | alt_idx++; | 1351 | alt_idx++; |
1476 | } /* (alt_idx < intf->num_altsetting) */ | 1352 | } /* (alt_idx < intf->num_altsetting) */ |
1477 | 1353 | ||
1478 | /* found a valid USB Ta Endpint config */ | 1354 | /* found a valid USB Ta Endpint config */ |
1479 | if (small_match != 0xffff) { | 1355 | if (small_match != 0xffff) { |
1480 | iface = iface_used; | 1356 | iface = iface_used; |
1481 | if (! | 1357 | if (!(context = kzalloc(sizeof(hfcusb_data), GFP_KERNEL))) |
1482 | (context = | ||
1483 | kzalloc(sizeof(hfcusb_data), GFP_KERNEL))) | ||
1484 | return (-ENOMEM); /* got no mem */ | 1358 | return (-ENOMEM); /* got no mem */ |
1485 | 1359 | ||
1486 | ep = iface->endpoint; | 1360 | ep = iface->endpoint; |
@@ -1613,20 +1487,15 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1613 | driver_info; | 1487 | driver_info; |
1614 | printk(KERN_INFO "HFC-S USB: detected \"%s\"\n", | 1488 | printk(KERN_INFO "HFC-S USB: detected \"%s\"\n", |
1615 | driver_info->vend_name); | 1489 | driver_info->vend_name); |
1616 | #ifdef CONFIG_HISAX_DEBUG | 1490 | |
1617 | DBG(USB_DBG, | 1491 | DBG(HFCUSB_DBG_INIT, |
1618 | "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d)\n", | 1492 | "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d), E-Channel(%d)", |
1619 | conf_str[small_match], context->if_used, | 1493 | conf_str[small_match], context->if_used, |
1620 | context->alt_used); | 1494 | context->alt_used, |
1621 | printk(KERN_INFO | 1495 | validconf[small_match][18]); |
1622 | "HFC-S USB: E-channel (\"ECHO:\") logging "); | 1496 | |
1623 | if (validconf[small_match][18]) | ||
1624 | printk(" possible\n"); | ||
1625 | else | ||
1626 | printk("NOT possible\n"); | ||
1627 | #endif | ||
1628 | /* init the chip and register the driver */ | 1497 | /* init the chip and register the driver */ |
1629 | if (usb_init(context)) { | 1498 | if (hfc_usb_init(context)) { |
1630 | usb_kill_urb(context->ctrl_urb); | 1499 | usb_kill_urb(context->ctrl_urb); |
1631 | usb_free_urb(context->ctrl_urb); | 1500 | usb_free_urb(context->ctrl_urb); |
1632 | context->ctrl_urb = NULL; | 1501 | context->ctrl_urb = NULL; |
@@ -1643,17 +1512,19 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1643 | return (-EIO); | 1512 | return (-EIO); |
1644 | } | 1513 | } |
1645 | 1514 | ||
1646 | /****************************************************/ | 1515 | /* callback for unplugged USB device */ |
1647 | /* function called when an active device is removed */ | ||
1648 | /****************************************************/ | ||
1649 | static void | 1516 | static void |
1650 | hfc_usb_disconnect(struct usb_interface | 1517 | hfc_usb_disconnect(struct usb_interface |
1651 | *intf) | 1518 | *intf) |
1652 | { | 1519 | { |
1653 | hfcusb_data *context = usb_get_intfdata(intf); | 1520 | hfcusb_data *context = usb_get_intfdata(intf); |
1654 | int i; | 1521 | int i; |
1522 | |||
1523 | handle_led(context, LED_POWER_OFF); | ||
1524 | schedule_timeout((10 * HZ) / 1000); | ||
1525 | |||
1655 | printk(KERN_INFO "HFC-S USB: device disconnect\n"); | 1526 | printk(KERN_INFO "HFC-S USB: device disconnect\n"); |
1656 | context->disc_flag = true; | 1527 | context->disc_flag = 1; |
1657 | usb_set_intfdata(intf, NULL); | 1528 | usb_set_intfdata(intf, NULL); |
1658 | if (!context) | 1529 | if (!context) |
1659 | return; | 1530 | return; |
@@ -1661,25 +1532,22 @@ hfc_usb_disconnect(struct usb_interface | |||
1661 | del_timer(&context->t3_timer); | 1532 | del_timer(&context->t3_timer); |
1662 | if (timer_pending(&context->t4_timer)) | 1533 | if (timer_pending(&context->t4_timer)) |
1663 | del_timer(&context->t4_timer); | 1534 | del_timer(&context->t4_timer); |
1535 | |||
1664 | /* tell all fifos to terminate */ | 1536 | /* tell all fifos to terminate */ |
1665 | for (i = 0; i < HFCUSB_NUM_FIFOS; i++) { | 1537 | for (i = 0; i < HFCUSB_NUM_FIFOS; i++) { |
1666 | if (context->fifos[i].usb_transfer_mode == USB_ISOC) { | 1538 | if (context->fifos[i].usb_transfer_mode == USB_ISOC) { |
1667 | if (context->fifos[i].active > 0) { | 1539 | if (context->fifos[i].active > 0) { |
1668 | stop_isoc_chain(&context->fifos[i]); | 1540 | stop_isoc_chain(&context->fifos[i]); |
1669 | #ifdef CONFIG_HISAX_DEBUG | 1541 | DBG(HFCUSB_DBG_INIT, |
1670 | DBG(USB_DBG, | 1542 | "HFC-S USB: %s stopping ISOC chain Fifo(%i)", |
1671 | "HFC-S USB: hfc_usb_disconnect: stopping ISOC chain Fifo no %i", | 1543 | __FUNCTION__, i); |
1672 | i); | ||
1673 | #endif | ||
1674 | } | 1544 | } |
1675 | } else { | 1545 | } else { |
1676 | if (context->fifos[i].active > 0) { | 1546 | if (context->fifos[i].active > 0) { |
1677 | context->fifos[i].active = 0; | 1547 | context->fifos[i].active = 0; |
1678 | #ifdef CONFIG_HISAX_DEBUG | 1548 | DBG(HFCUSB_DBG_INIT, |
1679 | DBG(USB_DBG, | 1549 | "HFC-S USB: %s unlinking URB for Fifo(%i)", |
1680 | "HFC-S USB: hfc_usb_disconnect: unlinking URB for Fifo no %i", | 1550 | __FUNCTION__, i); |
1681 | i); | ||
1682 | #endif | ||
1683 | } | 1551 | } |
1684 | usb_kill_urb(context->fifos[i].urb); | 1552 | usb_kill_urb(context->fifos[i].urb); |
1685 | usb_free_urb(context->fifos[i].urb); | 1553 | usb_free_urb(context->fifos[i].urb); |
@@ -1692,34 +1560,29 @@ hfc_usb_disconnect(struct usb_interface | |||
1692 | context->ctrl_urb = NULL; | 1560 | context->ctrl_urb = NULL; |
1693 | hisax_unregister(&context->d_if); | 1561 | hisax_unregister(&context->d_if); |
1694 | kfree(context); /* free our structure again */ | 1562 | kfree(context); /* free our structure again */ |
1695 | } /* hfc_usb_disconnect */ | 1563 | } |
1696 | 1564 | ||
1697 | /************************************/ | ||
1698 | /* our driver information structure */ | ||
1699 | /************************************/ | ||
1700 | static struct usb_driver hfc_drv = { | 1565 | static struct usb_driver hfc_drv = { |
1701 | .name = "hfc_usb", | 1566 | .name = "hfc_usb", |
1702 | .id_table = hfcusb_idtab, | 1567 | .id_table = hfcusb_idtab, |
1703 | .probe = hfc_usb_probe, | 1568 | .probe = hfc_usb_probe, |
1704 | .disconnect = hfc_usb_disconnect, | 1569 | .disconnect = hfc_usb_disconnect, |
1705 | }; | 1570 | }; |
1571 | |||
1706 | static void __exit | 1572 | static void __exit |
1707 | hfc_usb_exit(void) | 1573 | hfc_usb_mod_exit(void) |
1708 | { | 1574 | { |
1709 | #ifdef CONFIG_HISAX_DEBUG | 1575 | usb_deregister(&hfc_drv); /* release our driver */ |
1710 | DBG(USB_DBG, "HFC-S USB: calling \"hfc_usb_exit\" ..."); | ||
1711 | #endif | ||
1712 | usb_deregister(&hfc_drv); /* release our driver */ | ||
1713 | printk(KERN_INFO "HFC-S USB: module removed\n"); | 1576 | printk(KERN_INFO "HFC-S USB: module removed\n"); |
1714 | } | 1577 | } |
1715 | 1578 | ||
1716 | static int __init | 1579 | static int __init |
1717 | hfc_usb_init(void) | 1580 | hfc_usb_mod_init(void) |
1718 | { | 1581 | { |
1582 | char revstr[30], datestr[30], dummy[30]; | ||
1719 | #ifndef CONFIG_HISAX_DEBUG | 1583 | #ifndef CONFIG_HISAX_DEBUG |
1720 | unsigned int debug = -1; | 1584 | hfc_debug = debug; |
1721 | #endif | 1585 | #endif |
1722 | char revstr[30], datestr[30], dummy[30]; | ||
1723 | sscanf(hfcusb_revision, | 1586 | sscanf(hfcusb_revision, |
1724 | "%s %s $ %s %s %s $ ", dummy, revstr, | 1587 | "%s %s $ %s %s %s $ ", dummy, revstr, |
1725 | dummy, datestr, dummy); | 1588 | dummy, datestr, dummy); |
@@ -1734,8 +1597,8 @@ hfc_usb_init(void) | |||
1734 | return (0); | 1597 | return (0); |
1735 | } | 1598 | } |
1736 | 1599 | ||
1737 | module_init(hfc_usb_init); | 1600 | module_init(hfc_usb_mod_init); |
1738 | module_exit(hfc_usb_exit); | 1601 | module_exit(hfc_usb_mod_exit); |
1739 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1602 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1740 | MODULE_DESCRIPTION(DRIVER_DESC); | 1603 | MODULE_DESCRIPTION(DRIVER_DESC); |
1741 | MODULE_LICENSE("GPL"); | 1604 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/isdn/hisax/hfc_usb.h b/drivers/isdn/hisax/hfc_usb.h index 471f2354dfde..e79f56568d30 100644 --- a/drivers/isdn/hisax/hfc_usb.h +++ b/drivers/isdn/hisax/hfc_usb.h | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * hfc_usb.h | 2 | * hfc_usb.h |
3 | * | 3 | * |
4 | * $Id: hfc_usb.h,v 4.2 2005/04/07 15:27:17 martinb1 Exp $ | 4 | * $Id: hfc_usb.h,v 1.1.2.5 2007/08/20 14:36:03 mbachem Exp $ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef __HFC_USB_H__ | 7 | #ifndef __HFC_USB_H__ |
8 | #define __HFC_USB_H__ | 8 | #define __HFC_USB_H__ |
@@ -10,25 +10,20 @@ | |||
10 | #define DRIVER_AUTHOR "Peter Sprenger (sprenger@moving-byters.de)" | 10 | #define DRIVER_AUTHOR "Peter Sprenger (sprenger@moving-byters.de)" |
11 | #define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver" | 11 | #define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver" |
12 | 12 | ||
13 | #define VERBOSE_USB_DEBUG | ||
14 | 13 | ||
14 | #define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */ | ||
15 | #define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */ | ||
16 | #define HFC_TIMER_T4 500 /* time for state change interval */ | ||
15 | 17 | ||
16 | /***********/ | 18 | #define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ |
17 | /* defines */ | 19 | #define HFCUSB_L1_DRX 1 /* D-frame received */ |
18 | /***********/ | 20 | #define HFCUSB_L1_ERX 2 /* E-frame received */ |
19 | #define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */ | 21 | #define HFCUSB_L1_DTX 4 /* D-frames completed */ |
20 | #define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */ | ||
21 | #define HFC_TIMER_T4 500 /* time for state change interval */ | ||
22 | 22 | ||
23 | #define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ | 23 | #define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ |
24 | #define HFCUSB_L1_DRX 1 /* D-frame received */ | ||
25 | #define HFCUSB_L1_ERX 2 /* E-frame received */ | ||
26 | #define HFCUSB_L1_DTX 4 /* D-frames completed */ | ||
27 | 24 | ||
28 | #define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ | 25 | #define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ |
29 | 26 | #define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */ | |
30 | #define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ | ||
31 | #define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */ | ||
32 | 27 | ||
33 | #define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ | 28 | #define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ |
34 | #define HFCUSB_CIRM 0x00 /* cirm register index */ | 29 | #define HFCUSB_CIRM 0x00 /* cirm register index */ |
@@ -52,9 +47,8 @@ | |||
52 | 47 | ||
53 | #define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */ | 48 | #define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */ |
54 | 49 | ||
55 | /******************/ | 50 | |
56 | /* fifo registers */ | 51 | /* fifo registers */ |
57 | /******************/ | ||
58 | #define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ | 52 | #define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ |
59 | #define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ | 53 | #define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ |
60 | #define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ | 54 | #define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ |
@@ -66,9 +60,9 @@ | |||
66 | #define HFCUSB_PCM_RX 7 | 60 | #define HFCUSB_PCM_RX 7 |
67 | 61 | ||
68 | /* | 62 | /* |
69 | * used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just | 63 | * used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just |
70 | * supports ISO out, while the Cologne Chip EVAL TA just supports BULK out | 64 | * supports ISO out, while the Cologne Chip EVAL TA just supports BULK out |
71 | */ | 65 | */ |
72 | #define USB_INT 0 | 66 | #define USB_INT 0 |
73 | #define USB_BULK 1 | 67 | #define USB_BULK 1 |
74 | #define USB_ISOC 2 | 68 | #define USB_ISOC 2 |
@@ -77,49 +71,36 @@ | |||
77 | #define ISOC_PACKETS_B 8 | 71 | #define ISOC_PACKETS_B 8 |
78 | #define ISO_BUFFER_SIZE 128 | 72 | #define ISO_BUFFER_SIZE 128 |
79 | 73 | ||
80 | // ISO send definitions | 74 | /* Fifo flow Control for TX ISO */ |
81 | #define SINK_MAX 68 | 75 | #define SINK_MAX 68 |
82 | #define SINK_MIN 48 | 76 | #define SINK_MIN 48 |
83 | #define SINK_DMIN 12 | 77 | #define SINK_DMIN 12 |
84 | #define SINK_DMAX 18 | 78 | #define SINK_DMAX 18 |
85 | #define BITLINE_INF (-64*8) | 79 | #define BITLINE_INF (-64*8) |
86 | 80 | ||
87 | 81 | /* HFC-S USB register access by Control-URSs */ | |
88 | /**********/ | ||
89 | /* macros */ | ||
90 | /**********/ | ||
91 | #define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT) | 82 | #define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT) |
92 | #define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) | 83 | #define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) |
93 | |||
94 | |||
95 | /*******************/ | ||
96 | /* Debugging Flags */ | ||
97 | /*******************/ | ||
98 | #define USB_DBG 1 | ||
99 | #define ISDN_DBG 2 | ||
100 | |||
101 | |||
102 | /* *********************/ | ||
103 | /* USB related defines */ | ||
104 | /***********************/ | ||
105 | #define HFC_CTRL_BUFSIZE 32 | 84 | #define HFC_CTRL_BUFSIZE 32 |
106 | 85 | ||
107 | |||
108 | |||
109 | /*************************************************/ | ||
110 | /* entry and size of output/input control buffer */ | 86 | /* entry and size of output/input control buffer */ |
111 | /*************************************************/ | ||
112 | typedef struct { | 87 | typedef struct { |
113 | __u8 hfc_reg; /* register number */ | 88 | __u8 hfc_reg; /* register number */ |
114 | __u8 reg_val; /* value to be written (or read) */ | 89 | __u8 reg_val; /* value to be written (or read) */ |
115 | int action; /* data for action handler */ | 90 | int action; /* data for action handler */ |
116 | } ctrl_buft; | 91 | } ctrl_buft; |
117 | 92 | ||
93 | /* Debugging Flags */ | ||
94 | #define HFCUSB_DBG_INIT 0x0001 | ||
95 | #define HFCUSB_DBG_STATES 0x0002 | ||
96 | #define HFCUSB_DBG_DCHANNEL 0x0080 | ||
97 | #define HFCUSB_DBG_FIFO_ERR 0x4000 | ||
98 | #define HFCUSB_DBG_VERBOSE_USB 0x8000 | ||
118 | 99 | ||
119 | /********************/ | 100 | /* |
120 | /* URB error codes: */ | 101 | * URB error codes: |
121 | /********************/ | 102 | * Used to represent a list of values and their respective symbolic names |
122 | /* Used to represent a list of values and their respective symbolic names */ | 103 | */ |
123 | struct hfcusb_symbolic_list { | 104 | struct hfcusb_symbolic_list { |
124 | const int num; | 105 | const int num; |
125 | const char *name; | 106 | const char *name; |
@@ -134,20 +115,20 @@ static struct hfcusb_symbolic_list urb_errlist[] = { | |||
134 | {-ENXIO, "URB already queued"}, | 115 | {-ENXIO, "URB already queued"}, |
135 | {-EFBIG, "Too much ISO frames requested"}, | 116 | {-EFBIG, "Too much ISO frames requested"}, |
136 | {-ENOSR, "Buffer error (overrun)"}, | 117 | {-ENOSR, "Buffer error (overrun)"}, |
137 | {-EPIPE, "Specified endpoint is stalled"}, | 118 | {-EPIPE, "Specified endpoint is stalled (device not responding)"}, |
138 | {-EOVERFLOW, "Babble (bad cable?)"}, | 119 | {-EOVERFLOW, "Babble (bad cable?)"}, |
139 | {-EPROTO, "Bit-stuff error (bad cable?)"}, | 120 | {-EPROTO, "Bit-stuff error (bad cable?)"}, |
140 | {-EILSEQ, "CRC or missing token"}, | 121 | {-EILSEQ, "CRC/Timeout"}, |
141 | {-ETIME, "Device did not respond"}, | 122 | {-ETIMEDOUT, "NAK (device does not respond)"}, |
142 | {-ESHUTDOWN, "Device unplugged"}, | 123 | {-ESHUTDOWN, "Device unplugged"}, |
143 | {-1, NULL} | 124 | {-1, NULL} |
144 | }; | 125 | }; |
145 | 126 | ||
146 | 127 | ||
147 | /*****************************************************/ | 128 | /* |
148 | /* device dependant information to support different */ | 129 | * device dependant information to support different |
149 | /* ISDN Ta's using the HFC-S USB chip */ | 130 | * ISDN Ta's using the HFC-S USB chip |
150 | /*****************************************************/ | 131 | */ |
151 | 132 | ||
152 | /* USB descriptor need to contain one of the following EndPoint combination: */ | 133 | /* USB descriptor need to contain one of the following EndPoint combination: */ |
153 | #define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT | 134 | #define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT |
@@ -155,16 +136,19 @@ static struct hfcusb_symbolic_list urb_errlist[] = { | |||
155 | #define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT | 136 | #define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT |
156 | #define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT | 137 | #define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT |
157 | 138 | ||
158 | #define EP_NUL 1 // Endpoint at this position not allowed | 139 | #define EP_NUL 1 // Endpoint at this position not allowed |
159 | #define EP_NOP 2 // all type of endpoints allowed at this position | 140 | #define EP_NOP 2 // all type of endpoints allowed at this position |
160 | #define EP_ISO 3 // Isochron endpoint mandatory at this position | 141 | #define EP_ISO 3 // Isochron endpoint mandatory at this position |
161 | #define EP_BLK 4 // Bulk endpoint mandatory at this position | 142 | #define EP_BLK 4 // Bulk endpoint mandatory at this position |
162 | #define EP_INT 5 // Interrupt endpoint mandatory at this position | 143 | #define EP_INT 5 // Interrupt endpoint mandatory at this position |
163 | 144 | ||
164 | /* this array represents all endpoints possible in the HCF-USB the last | 145 | /* |
165 | * 3 entries are the configuration number, the minimum interval for | 146 | * List of all supported endpoint configuration sets, used to find the |
166 | * Interrupt endpoints & boolean if E-channel logging possible | 147 | * best matching endpoint configuration within a devices' USB descriptor. |
167 | */ | 148 | * We need at least 3 RX endpoints, and 3 TX endpoints, either |
149 | * INT-in and ISO-out, or ISO-in and ISO-out) | ||
150 | * with 4 RX endpoints even E-Channel logging is possible | ||
151 | */ | ||
168 | static int validconf[][19] = { | 152 | static int validconf[][19] = { |
169 | // INT in, ISO out config | 153 | // INT in, ISO out config |
170 | {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT, | 154 | {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT, |
@@ -193,7 +177,6 @@ static char *conf_str[] = { | |||
193 | }; | 177 | }; |
194 | #endif | 178 | #endif |
195 | 179 | ||
196 | |||
197 | typedef struct { | 180 | typedef struct { |
198 | int vendor; // vendor id | 181 | int vendor; // vendor id |
199 | int prod_id; // product id | 182 | int prod_id; // product id |
@@ -202,9 +185,9 @@ typedef struct { | |||
202 | signed short led_bits[8]; // array of 8 possible LED bitmask settings | 185 | signed short led_bits[8]; // array of 8 possible LED bitmask settings |
203 | } vendor_data; | 186 | } vendor_data; |
204 | 187 | ||
205 | #define LED_OFF 0 // no LED support | 188 | #define LED_OFF 0 // no LED support |
206 | #define LED_SCHEME1 1 // LED standard scheme | 189 | #define LED_SCHEME1 1 // LED standard scheme |
207 | #define LED_SCHEME2 2 // not used yet... | 190 | #define LED_SCHEME2 2 // not used yet... |
208 | 191 | ||
209 | #define LED_POWER_ON 1 | 192 | #define LED_POWER_ON 1 |
210 | #define LED_POWER_OFF 2 | 193 | #define LED_POWER_OFF 2 |
@@ -217,11 +200,8 @@ typedef struct { | |||
217 | #define LED_B2_OFF 9 | 200 | #define LED_B2_OFF 9 |
218 | #define LED_B2_DATA 10 | 201 | #define LED_B2_DATA 10 |
219 | 202 | ||
220 | #define LED_NORMAL 0 // LEDs are normal | 203 | #define LED_NORMAL 0 // LEDs are normal |
221 | #define LED_INVERTED 1 // LEDs are inverted | 204 | #define LED_INVERTED 1 // LEDs are inverted |
222 | |||
223 | /* time in ms to perform a Flashing LED when B-Channel has traffic */ | ||
224 | #define LED_TIME 250 | ||
225 | 205 | ||
226 | 206 | ||
227 | #endif // __HFC_USB_H__ | 207 | #endif // __HFC_USB_H__ |