2 * mISDN driver for Colognechip HFC-S USB chip
4 * Copyright 2001 by Peter Sprenger (sprenger@moving-bytes.de)
5 * Copyright 2008 by Martin Bachem (info@bachem-it.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * debug=<n>, default=0, with n=0xHHHHGGGG
24 * H - l1 driver flags described in hfcsusb.h
25 * G - common mISDN debug flags described at mISDNhw.h
27 * poll=<n>, default 128
28 * n : burst size of PH_DATA_IND at transparent rx data
30 * Revision: 0.3.3 (socket), 2008-11-05
33 #include <linux/module.h>
34 #include <linux/delay.h>
35 #include <linux/usb.h>
36 #include <linux/mISDNhw.h>
37 #include <linux/slab.h>
40 static unsigned int debug
;
41 static int poll
= DEFAULT_TRANSP_BURST_SZ
;
43 static LIST_HEAD(HFClist
);
44 static DEFINE_RWLOCK(HFClock
);
47 MODULE_AUTHOR("Martin Bachem");
48 MODULE_LICENSE("GPL");
49 module_param(debug
, uint
, S_IRUGO
| S_IWUSR
);
50 module_param(poll
, int, 0);
52 static int hfcsusb_cnt
;
54 /* some function prototypes */
55 static void hfcsusb_ph_command(struct hfcsusb
*hw
, u_char command
);
56 static void release_hw(struct hfcsusb
*hw
);
57 static void reset_hfcsusb(struct hfcsusb
*hw
);
58 static void setPortMode(struct hfcsusb
*hw
);
59 static void hfcsusb_start_endpoint(struct hfcsusb
*hw
, int channel
);
60 static void hfcsusb_stop_endpoint(struct hfcsusb
*hw
, int channel
);
61 static int hfcsusb_setup_bch(struct bchannel
*bch
, int protocol
);
62 static void deactivate_bchannel(struct bchannel
*bch
);
63 static void hfcsusb_ph_info(struct hfcsusb
*hw
);
65 /* start next background transfer for control channel */
67 ctrl_start_transfer(struct hfcsusb
*hw
)
69 if (debug
& DBG_HFC_CALL_TRACE
)
70 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
73 hw
->ctrl_urb
->pipe
= hw
->ctrl_out_pipe
;
74 hw
->ctrl_urb
->setup_packet
= (u_char
*)&hw
->ctrl_write
;
75 hw
->ctrl_urb
->transfer_buffer
= NULL
;
76 hw
->ctrl_urb
->transfer_buffer_length
= 0;
77 hw
->ctrl_write
.wIndex
=
78 cpu_to_le16(hw
->ctrl_buff
[hw
->ctrl_out_idx
].hfcs_reg
);
79 hw
->ctrl_write
.wValue
=
80 cpu_to_le16(hw
->ctrl_buff
[hw
->ctrl_out_idx
].reg_val
);
82 usb_submit_urb(hw
->ctrl_urb
, GFP_ATOMIC
);
87 * queue a control transfer request to write HFC-S USB
88 * chip register using CTRL resuest queue
90 static int write_reg(struct hfcsusb
*hw
, __u8 reg
, __u8 val
)
94 if (debug
& DBG_HFC_CALL_TRACE
)
95 printk(KERN_DEBUG
"%s: %s reg(0x%02x) val(0x%02x)\n",
96 hw
->name
, __func__
, reg
, val
);
98 spin_lock(&hw
->ctrl_lock
);
99 if (hw
->ctrl_cnt
>= HFC_CTRL_BUFSIZE
) {
100 spin_unlock(&hw
->ctrl_lock
);
103 buf
= &hw
->ctrl_buff
[hw
->ctrl_in_idx
];
106 if (++hw
->ctrl_in_idx
>= HFC_CTRL_BUFSIZE
)
108 if (++hw
->ctrl_cnt
== 1)
109 ctrl_start_transfer(hw
);
110 spin_unlock(&hw
->ctrl_lock
);
115 /* control completion routine handling background control cmds */
117 ctrl_complete(struct urb
*urb
)
119 struct hfcsusb
*hw
= (struct hfcsusb
*) urb
->context
;
121 if (debug
& DBG_HFC_CALL_TRACE
)
122 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
126 hw
->ctrl_cnt
--; /* decrement actual count */
127 if (++hw
->ctrl_out_idx
>= HFC_CTRL_BUFSIZE
)
128 hw
->ctrl_out_idx
= 0; /* pointer wrap */
130 ctrl_start_transfer(hw
); /* start next transfer */
134 /* handle LED bits */
136 set_led_bit(struct hfcsusb
*hw
, signed short led_bits
, int set_on
)
140 hw
->led_state
&= ~abs(led_bits
);
142 hw
->led_state
|= led_bits
;
145 hw
->led_state
|= abs(led_bits
);
147 hw
->led_state
&= ~led_bits
;
151 /* handle LED requests */
153 handle_led(struct hfcsusb
*hw
, int event
)
155 struct hfcsusb_vdata
*driver_info
= (struct hfcsusb_vdata
*)
156 hfcsusb_idtab
[hw
->vend_idx
].driver_info
;
159 if (driver_info
->led_scheme
== LED_OFF
)
161 tmpled
= hw
->led_state
;
165 set_led_bit(hw
, driver_info
->led_bits
[0], 1);
166 set_led_bit(hw
, driver_info
->led_bits
[1], 0);
167 set_led_bit(hw
, driver_info
->led_bits
[2], 0);
168 set_led_bit(hw
, driver_info
->led_bits
[3], 0);
171 set_led_bit(hw
, driver_info
->led_bits
[0], 0);
172 set_led_bit(hw
, driver_info
->led_bits
[1], 0);
173 set_led_bit(hw
, driver_info
->led_bits
[2], 0);
174 set_led_bit(hw
, driver_info
->led_bits
[3], 0);
177 set_led_bit(hw
, driver_info
->led_bits
[1], 1);
180 set_led_bit(hw
, driver_info
->led_bits
[1], 0);
183 set_led_bit(hw
, driver_info
->led_bits
[2], 1);
186 set_led_bit(hw
, driver_info
->led_bits
[2], 0);
189 set_led_bit(hw
, driver_info
->led_bits
[3], 1);
192 set_led_bit(hw
, driver_info
->led_bits
[3], 0);
196 if (hw
->led_state
!= tmpled
) {
197 if (debug
& DBG_HFC_CALL_TRACE
)
198 printk(KERN_DEBUG
"%s: %s reg(0x%02x) val(x%02x)\n",
200 HFCUSB_P_DATA
, hw
->led_state
);
202 write_reg(hw
, HFCUSB_P_DATA
, hw
->led_state
);
207 * Layer2 -> Layer 1 Bchannel data
210 hfcusb_l2l1B(struct mISDNchannel
*ch
, struct sk_buff
*skb
)
212 struct bchannel
*bch
= container_of(ch
, struct bchannel
, ch
);
213 struct hfcsusb
*hw
= bch
->hw
;
215 struct mISDNhead
*hh
= mISDN_HEAD_P(skb
);
218 if (debug
& DBG_HFC_CALL_TRACE
)
219 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
223 spin_lock_irqsave(&hw
->lock
, flags
);
224 ret
= bchannel_senddata(bch
, skb
);
225 spin_unlock_irqrestore(&hw
->lock
, flags
);
226 if (debug
& DBG_HFC_CALL_TRACE
)
227 printk(KERN_DEBUG
"%s: %s PH_DATA_REQ ret(%i)\n",
228 hw
->name
, __func__
, ret
);
232 case PH_ACTIVATE_REQ
:
233 if (!test_and_set_bit(FLG_ACTIVE
, &bch
->Flags
)) {
234 hfcsusb_start_endpoint(hw
, bch
->nr
- 1);
235 ret
= hfcsusb_setup_bch(bch
, ch
->protocol
);
239 _queue_data(ch
, PH_ACTIVATE_IND
, MISDN_ID_ANY
,
240 0, NULL
, GFP_KERNEL
);
242 case PH_DEACTIVATE_REQ
:
243 deactivate_bchannel(bch
);
244 _queue_data(ch
, PH_DEACTIVATE_IND
, MISDN_ID_ANY
,
245 0, NULL
, GFP_KERNEL
);
255 * send full D/B channel status information
256 * as MPH_INFORMATION_IND
259 hfcsusb_ph_info(struct hfcsusb
*hw
)
262 struct dchannel
*dch
= &hw
->dch
;
265 phi
= kzalloc(sizeof(struct ph_info
) +
266 dch
->dev
.nrbchan
* sizeof(struct ph_info_ch
), GFP_ATOMIC
);
267 phi
->dch
.ch
.protocol
= hw
->protocol
;
268 phi
->dch
.ch
.Flags
= dch
->Flags
;
269 phi
->dch
.state
= dch
->state
;
270 phi
->dch
.num_bch
= dch
->dev
.nrbchan
;
271 for (i
= 0; i
< dch
->dev
.nrbchan
; i
++) {
272 phi
->bch
[i
].protocol
= hw
->bch
[i
].ch
.protocol
;
273 phi
->bch
[i
].Flags
= hw
->bch
[i
].Flags
;
275 _queue_data(&dch
->dev
.D
, MPH_INFORMATION_IND
, MISDN_ID_ANY
,
276 sizeof(struct ph_info_dch
) + dch
->dev
.nrbchan
*
277 sizeof(struct ph_info_ch
), phi
, GFP_ATOMIC
);
282 * Layer2 -> Layer 1 Dchannel data
285 hfcusb_l2l1D(struct mISDNchannel
*ch
, struct sk_buff
*skb
)
287 struct mISDNdevice
*dev
= container_of(ch
, struct mISDNdevice
, D
);
288 struct dchannel
*dch
= container_of(dev
, struct dchannel
, dev
);
289 struct mISDNhead
*hh
= mISDN_HEAD_P(skb
);
290 struct hfcsusb
*hw
= dch
->hw
;
296 if (debug
& DBG_HFC_CALL_TRACE
)
297 printk(KERN_DEBUG
"%s: %s: PH_DATA_REQ\n",
300 spin_lock_irqsave(&hw
->lock
, flags
);
301 ret
= dchannel_senddata(dch
, skb
);
302 spin_unlock_irqrestore(&hw
->lock
, flags
);
305 queue_ch_frame(ch
, PH_DATA_CNF
, hh
->id
, NULL
);
309 case PH_ACTIVATE_REQ
:
310 if (debug
& DBG_HFC_CALL_TRACE
)
311 printk(KERN_DEBUG
"%s: %s: PH_ACTIVATE_REQ %s\n",
313 (hw
->protocol
== ISDN_P_NT_S0
) ? "NT" : "TE");
315 if (hw
->protocol
== ISDN_P_NT_S0
) {
317 if (test_bit(FLG_ACTIVE
, &dch
->Flags
)) {
318 _queue_data(&dch
->dev
.D
,
319 PH_ACTIVATE_IND
, MISDN_ID_ANY
, 0,
322 hfcsusb_ph_command(hw
,
324 test_and_set_bit(FLG_L2_ACTIVATED
,
328 hfcsusb_ph_command(hw
, HFC_L1_ACTIVATE_TE
);
329 ret
= l1_event(dch
->l1
, hh
->prim
);
333 case PH_DEACTIVATE_REQ
:
334 if (debug
& DBG_HFC_CALL_TRACE
)
335 printk(KERN_DEBUG
"%s: %s: PH_DEACTIVATE_REQ\n",
337 test_and_clear_bit(FLG_L2_ACTIVATED
, &dch
->Flags
);
339 if (hw
->protocol
== ISDN_P_NT_S0
) {
340 hfcsusb_ph_command(hw
, HFC_L1_DEACTIVATE_NT
);
341 spin_lock_irqsave(&hw
->lock
, flags
);
342 skb_queue_purge(&dch
->squeue
);
344 dev_kfree_skb(dch
->tx_skb
);
349 dev_kfree_skb(dch
->rx_skb
);
352 test_and_clear_bit(FLG_TX_BUSY
, &dch
->Flags
);
353 spin_unlock_irqrestore(&hw
->lock
, flags
);
355 if (test_and_clear_bit(FLG_L1_BUSY
, &dch
->Flags
))
356 dchannel_sched_event(&hc
->dch
, D_CLEARBUSY
);
360 ret
= l1_event(dch
->l1
, hh
->prim
);
362 case MPH_INFORMATION_REQ
:
372 * Layer 1 callback function
375 hfc_l1callback(struct dchannel
*dch
, u_int cmd
)
377 struct hfcsusb
*hw
= dch
->hw
;
379 if (debug
& DBG_HFC_CALL_TRACE
)
380 printk(KERN_DEBUG
"%s: %s cmd 0x%x\n",
381 hw
->name
, __func__
, cmd
);
391 skb_queue_purge(&dch
->squeue
);
393 dev_kfree_skb(dch
->tx_skb
);
398 dev_kfree_skb(dch
->rx_skb
);
401 test_and_clear_bit(FLG_TX_BUSY
, &dch
->Flags
);
403 case PH_ACTIVATE_IND
:
404 test_and_set_bit(FLG_ACTIVE
, &dch
->Flags
);
405 _queue_data(&dch
->dev
.D
, cmd
, MISDN_ID_ANY
, 0, NULL
,
408 case PH_DEACTIVATE_IND
:
409 test_and_clear_bit(FLG_ACTIVE
, &dch
->Flags
);
410 _queue_data(&dch
->dev
.D
, cmd
, MISDN_ID_ANY
, 0, NULL
,
414 if (dch
->debug
& DEBUG_HW
)
415 printk(KERN_DEBUG
"%s: %s: unknown cmd %x\n",
416 hw
->name
, __func__
, cmd
);
424 open_dchannel(struct hfcsusb
*hw
, struct mISDNchannel
*ch
,
425 struct channel_req
*rq
)
429 if (debug
& DEBUG_HW_OPEN
)
430 printk(KERN_DEBUG
"%s: %s: dev(%d) open addr(%i) from %p\n",
431 hw
->name
, __func__
, hw
->dch
.dev
.id
, rq
->adr
.channel
,
432 __builtin_return_address(0));
433 if (rq
->protocol
== ISDN_P_NONE
)
436 test_and_clear_bit(FLG_ACTIVE
, &hw
->dch
.Flags
);
437 test_and_clear_bit(FLG_ACTIVE
, &hw
->ech
.Flags
);
438 hfcsusb_start_endpoint(hw
, HFC_CHAN_D
);
440 /* E-Channel logging */
441 if (rq
->adr
.channel
== 1) {
442 if (hw
->fifos
[HFCUSB_PCM_RX
].pipe
) {
443 hfcsusb_start_endpoint(hw
, HFC_CHAN_E
);
444 set_bit(FLG_ACTIVE
, &hw
->ech
.Flags
);
445 _queue_data(&hw
->ech
.dev
.D
, PH_ACTIVATE_IND
,
446 MISDN_ID_ANY
, 0, NULL
, GFP_ATOMIC
);
452 hw
->protocol
= rq
->protocol
;
453 if (rq
->protocol
== ISDN_P_TE_S0
) {
454 err
= create_l1(&hw
->dch
, hfc_l1callback
);
459 ch
->protocol
= rq
->protocol
;
462 if (rq
->protocol
!= ch
->protocol
)
463 return -EPROTONOSUPPORT
;
466 if (((ch
->protocol
== ISDN_P_NT_S0
) && (hw
->dch
.state
== 3)) ||
467 ((ch
->protocol
== ISDN_P_TE_S0
) && (hw
->dch
.state
== 7)))
468 _queue_data(ch
, PH_ACTIVATE_IND
, MISDN_ID_ANY
,
469 0, NULL
, GFP_KERNEL
);
471 if (!try_module_get(THIS_MODULE
))
472 printk(KERN_WARNING
"%s: %s: cannot get module\n",
478 open_bchannel(struct hfcsusb
*hw
, struct channel_req
*rq
)
480 struct bchannel
*bch
;
482 if (rq
->adr
.channel
== 0 || rq
->adr
.channel
> 2)
484 if (rq
->protocol
== ISDN_P_NONE
)
487 if (debug
& DBG_HFC_CALL_TRACE
)
488 printk(KERN_DEBUG
"%s: %s B%i\n",
489 hw
->name
, __func__
, rq
->adr
.channel
);
491 bch
= &hw
->bch
[rq
->adr
.channel
- 1];
492 if (test_and_set_bit(FLG_OPEN
, &bch
->Flags
))
493 return -EBUSY
; /* b-channel can be only open once */
494 bch
->ch
.protocol
= rq
->protocol
;
497 if (!try_module_get(THIS_MODULE
))
498 printk(KERN_WARNING
"%s: %s:cannot get module\n",
504 channel_ctrl(struct hfcsusb
*hw
, struct mISDN_ctrl_req
*cq
)
508 if (debug
& DBG_HFC_CALL_TRACE
)
509 printk(KERN_DEBUG
"%s: %s op(0x%x) channel(0x%x)\n",
510 hw
->name
, __func__
, (cq
->op
), (cq
->channel
));
513 case MISDN_CTRL_GETOP
:
514 cq
->op
= MISDN_CTRL_LOOP
| MISDN_CTRL_CONNECT
|
515 MISDN_CTRL_DISCONNECT
;
518 printk(KERN_WARNING
"%s: %s: unknown Op %x\n",
519 hw
->name
, __func__
, cq
->op
);
527 * device control function
530 hfc_dctrl(struct mISDNchannel
*ch
, u_int cmd
, void *arg
)
532 struct mISDNdevice
*dev
= container_of(ch
, struct mISDNdevice
, D
);
533 struct dchannel
*dch
= container_of(dev
, struct dchannel
, dev
);
534 struct hfcsusb
*hw
= dch
->hw
;
535 struct channel_req
*rq
;
538 if (dch
->debug
& DEBUG_HW
)
539 printk(KERN_DEBUG
"%s: %s: cmd:%x %p\n",
540 hw
->name
, __func__
, cmd
, arg
);
544 if ((rq
->protocol
== ISDN_P_TE_S0
) ||
545 (rq
->protocol
== ISDN_P_NT_S0
))
546 err
= open_dchannel(hw
, ch
, rq
);
548 err
= open_bchannel(hw
, rq
);
554 if (debug
& DEBUG_HW_OPEN
)
556 "%s: %s: dev(%d) close from %p (open %d)\n",
557 hw
->name
, __func__
, hw
->dch
.dev
.id
,
558 __builtin_return_address(0), hw
->open
);
560 hfcsusb_stop_endpoint(hw
, HFC_CHAN_D
);
561 if (hw
->fifos
[HFCUSB_PCM_RX
].pipe
)
562 hfcsusb_stop_endpoint(hw
, HFC_CHAN_E
);
563 handle_led(hw
, LED_POWER_ON
);
565 module_put(THIS_MODULE
);
567 case CONTROL_CHANNEL
:
568 err
= channel_ctrl(hw
, arg
);
571 if (dch
->debug
& DEBUG_HW
)
572 printk(KERN_DEBUG
"%s: %s: unknown command %x\n",
573 hw
->name
, __func__
, cmd
);
580 * S0 TE state change event handler
583 ph_state_te(struct dchannel
*dch
)
585 struct hfcsusb
*hw
= dch
->hw
;
587 if (debug
& DEBUG_HW
) {
588 if (dch
->state
<= HFC_MAX_TE_LAYER1_STATE
)
589 printk(KERN_DEBUG
"%s: %s: %s\n", hw
->name
, __func__
,
590 HFC_TE_LAYER1_STATES
[dch
->state
]);
592 printk(KERN_DEBUG
"%s: %s: TE F%d\n",
593 hw
->name
, __func__
, dch
->state
);
596 switch (dch
->state
) {
598 l1_event(dch
->l1
, HW_RESET_IND
);
601 l1_event(dch
->l1
, HW_DEACT_IND
);
605 l1_event(dch
->l1
, ANYSIGNAL
);
608 l1_event(dch
->l1
, INFO2
);
611 l1_event(dch
->l1
, INFO4_P8
);
615 handle_led(hw
, LED_S0_ON
);
617 handle_led(hw
, LED_S0_OFF
);
621 * S0 NT state change event handler
624 ph_state_nt(struct dchannel
*dch
)
626 struct hfcsusb
*hw
= dch
->hw
;
628 if (debug
& DEBUG_HW
) {
629 if (dch
->state
<= HFC_MAX_NT_LAYER1_STATE
)
630 printk(KERN_DEBUG
"%s: %s: %s\n",
632 HFC_NT_LAYER1_STATES
[dch
->state
]);
635 printk(KERN_INFO DRIVER_NAME
"%s: %s: NT G%d\n",
636 hw
->name
, __func__
, dch
->state
);
639 switch (dch
->state
) {
641 test_and_clear_bit(FLG_ACTIVE
, &dch
->Flags
);
642 test_and_clear_bit(FLG_L2_ACTIVATED
, &dch
->Flags
);
644 hw
->timers
&= ~NT_ACTIVATION_TIMER
;
645 handle_led(hw
, LED_S0_OFF
);
649 if (hw
->nt_timer
< 0) {
651 hw
->timers
&= ~NT_ACTIVATION_TIMER
;
652 hfcsusb_ph_command(dch
->hw
, HFC_L1_DEACTIVATE_NT
);
654 hw
->timers
|= NT_ACTIVATION_TIMER
;
655 hw
->nt_timer
= NT_T1_COUNT
;
656 /* allow G2 -> G3 transition */
657 write_reg(hw
, HFCUSB_STATES
, 2 | HFCUSB_NT_G2_G3
);
662 hw
->timers
&= ~NT_ACTIVATION_TIMER
;
663 test_and_set_bit(FLG_ACTIVE
, &dch
->Flags
);
664 _queue_data(&dch
->dev
.D
, PH_ACTIVATE_IND
,
665 MISDN_ID_ANY
, 0, NULL
, GFP_ATOMIC
);
666 handle_led(hw
, LED_S0_ON
);
670 hw
->timers
&= ~NT_ACTIVATION_TIMER
;
679 ph_state(struct dchannel
*dch
)
681 struct hfcsusb
*hw
= dch
->hw
;
683 if (hw
->protocol
== ISDN_P_NT_S0
)
685 else if (hw
->protocol
== ISDN_P_TE_S0
)
690 * disable/enable BChannel for desired protocoll
693 hfcsusb_setup_bch(struct bchannel
*bch
, int protocol
)
695 struct hfcsusb
*hw
= bch
->hw
;
696 __u8 conhdlc
, sctrl
, sctrl_r
;
698 if (debug
& DEBUG_HW
)
699 printk(KERN_DEBUG
"%s: %s: protocol %x-->%x B%d\n",
700 hw
->name
, __func__
, bch
->state
, protocol
,
703 /* setup val for CON_HDLC */
705 if (protocol
> ISDN_P_NONE
)
706 conhdlc
= 8; /* enable FIFO */
709 case (-1): /* used for init */
713 if (bch
->state
== ISDN_P_NONE
)
714 return 0; /* already in idle state */
715 bch
->state
= ISDN_P_NONE
;
716 clear_bit(FLG_HDLC
, &bch
->Flags
);
717 clear_bit(FLG_TRANSPARENT
, &bch
->Flags
);
721 bch
->state
= protocol
;
722 set_bit(FLG_TRANSPARENT
, &bch
->Flags
);
724 case (ISDN_P_B_HDLC
):
725 bch
->state
= protocol
;
726 set_bit(FLG_HDLC
, &bch
->Flags
);
729 if (debug
& DEBUG_HW
)
730 printk(KERN_DEBUG
"%s: %s: prot not known %x\n",
731 hw
->name
, __func__
, protocol
);
735 if (protocol
>= ISDN_P_NONE
) {
736 write_reg(hw
, HFCUSB_FIFO
, (bch
->nr
== 1) ? 0 : 2);
737 write_reg(hw
, HFCUSB_CON_HDLC
, conhdlc
);
738 write_reg(hw
, HFCUSB_INC_RES_F
, 2);
739 write_reg(hw
, HFCUSB_FIFO
, (bch
->nr
== 1) ? 1 : 3);
740 write_reg(hw
, HFCUSB_CON_HDLC
, conhdlc
);
741 write_reg(hw
, HFCUSB_INC_RES_F
, 2);
743 sctrl
= 0x40 + ((hw
->protocol
== ISDN_P_TE_S0
) ? 0x00 : 0x04);
745 if (test_bit(FLG_ACTIVE
, &hw
->bch
[0].Flags
)) {
749 if (test_bit(FLG_ACTIVE
, &hw
->bch
[1].Flags
)) {
753 write_reg(hw
, HFCUSB_SCTRL
, sctrl
);
754 write_reg(hw
, HFCUSB_SCTRL_R
, sctrl_r
);
756 if (protocol
> ISDN_P_NONE
)
757 handle_led(hw
, (bch
->nr
== 1) ? LED_B1_ON
: LED_B2_ON
);
759 handle_led(hw
, (bch
->nr
== 1) ? LED_B1_OFF
:
767 hfcsusb_ph_command(struct hfcsusb
*hw
, u_char command
)
769 if (debug
& DEBUG_HW
)
770 printk(KERN_DEBUG
"%s: %s: %x\n",
771 hw
->name
, __func__
, command
);
774 case HFC_L1_ACTIVATE_TE
:
775 /* force sending sending INFO1 */
776 write_reg(hw
, HFCUSB_STATES
, 0x14);
777 /* start l1 activation */
778 write_reg(hw
, HFCUSB_STATES
, 0x04);
781 case HFC_L1_FORCE_DEACTIVATE_TE
:
782 write_reg(hw
, HFCUSB_STATES
, 0x10);
783 write_reg(hw
, HFCUSB_STATES
, 0x03);
786 case HFC_L1_ACTIVATE_NT
:
787 if (hw
->dch
.state
== 3)
788 _queue_data(&hw
->dch
.dev
.D
, PH_ACTIVATE_IND
,
789 MISDN_ID_ANY
, 0, NULL
, GFP_ATOMIC
);
791 write_reg(hw
, HFCUSB_STATES
, HFCUSB_ACTIVATE
|
792 HFCUSB_DO_ACTION
| HFCUSB_NT_G2_G3
);
795 case HFC_L1_DEACTIVATE_NT
:
796 write_reg(hw
, HFCUSB_STATES
,
803 * Layer 1 B-channel hardware access
806 channel_bctrl(struct bchannel
*bch
, struct mISDN_ctrl_req
*cq
)
808 return mISDN_ctrl_bchannel(bch
, cq
);
811 /* collect data from incoming interrupt or isochron USB data */
813 hfcsusb_rx_frame(struct usb_fifo
*fifo
, __u8
*data
, unsigned int len
,
816 struct hfcsusb
*hw
= fifo
->hw
;
817 struct sk_buff
*rx_skb
= NULL
;
819 int fifon
= fifo
->fifonum
;
823 if (debug
& DBG_HFC_CALL_TRACE
)
824 printk(KERN_DEBUG
"%s: %s: fifo(%i) len(%i) "
825 "dch(%p) bch(%p) ech(%p)\n",
826 hw
->name
, __func__
, fifon
, len
,
827 fifo
->dch
, fifo
->bch
, fifo
->ech
);
832 if ((!!fifo
->dch
+ !!fifo
->bch
+ !!fifo
->ech
) != 1) {
833 printk(KERN_DEBUG
"%s: %s: undefined channel\n",
838 spin_lock(&hw
->lock
);
840 rx_skb
= fifo
->dch
->rx_skb
;
841 maxlen
= fifo
->dch
->maxlen
;
845 if (test_bit(FLG_RX_OFF
, &fifo
->bch
->Flags
)) {
846 fifo
->bch
->dropcnt
+= len
;
847 spin_unlock(&hw
->lock
);
850 maxlen
= bchannel_get_rxbuf(fifo
->bch
, len
);
851 rx_skb
= fifo
->bch
->rx_skb
;
855 pr_warning("%s.B%d: No bufferspace for %d bytes\n",
856 hw
->name
, fifo
->bch
->nr
, len
);
857 spin_unlock(&hw
->lock
);
860 maxlen
= fifo
->bch
->maxlen
;
861 hdlc
= test_bit(FLG_HDLC
, &fifo
->bch
->Flags
);
864 rx_skb
= fifo
->ech
->rx_skb
;
865 maxlen
= fifo
->ech
->maxlen
;
869 if (fifo
->dch
|| fifo
->ech
) {
871 rx_skb
= mI_alloc_skb(maxlen
, GFP_ATOMIC
);
874 fifo
->dch
->rx_skb
= rx_skb
;
876 fifo
->ech
->rx_skb
= rx_skb
;
879 printk(KERN_DEBUG
"%s: %s: No mem for rx_skb\n",
881 spin_unlock(&hw
->lock
);
885 /* D/E-Channel SKB range check */
886 if ((rx_skb
->len
+ len
) >= MAX_DFRAME_LEN_L1
) {
887 printk(KERN_DEBUG
"%s: %s: sbk mem exceeded "
888 "for fifo(%d) HFCUSB_D_RX\n",
889 hw
->name
, __func__
, fifon
);
891 spin_unlock(&hw
->lock
);
896 memcpy(skb_put(rx_skb
, len
), data
, len
);
899 /* we have a complete hdlc packet */
901 if ((rx_skb
->len
> 3) &&
902 (!(rx_skb
->data
[rx_skb
->len
- 1]))) {
903 if (debug
& DBG_HFC_FIFO_VERBOSE
) {
904 printk(KERN_DEBUG
"%s: %s: fifon(%i)"
906 hw
->name
, __func__
, fifon
,
909 while (i
< rx_skb
->len
)
915 /* remove CRC & status */
916 skb_trim(rx_skb
, rx_skb
->len
- 3);
919 recv_Dchannel(fifo
->dch
);
921 recv_Bchannel(fifo
->bch
, MISDN_ID_ANY
,
924 recv_Echannel(fifo
->ech
,
927 if (debug
& DBG_HFC_FIFO_VERBOSE
) {
929 "%s: CRC or minlen ERROR fifon(%i) "
931 hw
->name
, fifon
, rx_skb
->len
);
933 while (i
< rx_skb
->len
)
942 /* deliver transparent data to layer2 */
943 recv_Bchannel(fifo
->bch
, MISDN_ID_ANY
, false);
945 spin_unlock(&hw
->lock
);
949 fill_isoc_urb(struct urb
*urb
, struct usb_device
*dev
, unsigned int pipe
,
950 void *buf
, int num_packets
, int packet_size
, int interval
,
951 usb_complete_t complete
, void *context
)
955 usb_fill_bulk_urb(urb
, dev
, pipe
, buf
, packet_size
* num_packets
,
958 urb
->number_of_packets
= num_packets
;
959 urb
->transfer_flags
= URB_ISO_ASAP
;
960 urb
->actual_length
= 0;
961 urb
->interval
= interval
;
963 for (k
= 0; k
< num_packets
; k
++) {
964 urb
->iso_frame_desc
[k
].offset
= packet_size
* k
;
965 urb
->iso_frame_desc
[k
].length
= packet_size
;
966 urb
->iso_frame_desc
[k
].actual_length
= 0;
970 /* receive completion routine for all ISO tx fifos */
972 rx_iso_complete(struct urb
*urb
)
974 struct iso_urb
*context_iso_urb
= (struct iso_urb
*) urb
->context
;
975 struct usb_fifo
*fifo
= context_iso_urb
->owner_fifo
;
976 struct hfcsusb
*hw
= fifo
->hw
;
977 int k
, len
, errcode
, offset
, num_isoc_packets
, fifon
, maxlen
,
978 status
, iso_status
, i
;
983 fifon
= fifo
->fifonum
;
984 status
= urb
->status
;
986 spin_lock(&hw
->lock
);
987 if (fifo
->stop_gracefull
) {
988 fifo
->stop_gracefull
= 0;
990 spin_unlock(&hw
->lock
);
993 spin_unlock(&hw
->lock
);
996 * ISO transfer only partially completed,
997 * look at individual frame status for details
999 if (status
== -EXDEV
) {
1000 if (debug
& DEBUG_HW
)
1001 printk(KERN_DEBUG
"%s: %s: with -EXDEV "
1002 "urb->status %d, fifonum %d\n",
1003 hw
->name
, __func__
, status
, fifon
);
1005 /* clear status, so go on with ISO transfers */
1010 if (fifo
->active
&& !status
) {
1011 num_isoc_packets
= iso_packets
[fifon
];
1012 maxlen
= fifo
->usb_packet_maxlen
;
1014 for (k
= 0; k
< num_isoc_packets
; ++k
) {
1015 len
= urb
->iso_frame_desc
[k
].actual_length
;
1016 offset
= urb
->iso_frame_desc
[k
].offset
;
1017 buf
= context_iso_urb
->buffer
+ offset
;
1018 iso_status
= urb
->iso_frame_desc
[k
].status
;
1020 if (iso_status
&& (debug
& DBG_HFC_FIFO_VERBOSE
)) {
1021 printk(KERN_DEBUG
"%s: %s: "
1022 "ISO packet %i, status: %i\n",
1023 hw
->name
, __func__
, k
, iso_status
);
1026 /* USB data log for every D ISO in */
1027 if ((fifon
== HFCUSB_D_RX
) &&
1028 (debug
& DBG_HFC_USB_VERBOSE
)) {
1030 "%s: %s: %d (%d/%d) len(%d) ",
1031 hw
->name
, __func__
, urb
->start_frame
,
1032 k
, num_isoc_packets
- 1,
1034 for (i
= 0; i
< len
; i
++)
1035 printk("%x ", buf
[i
]);
1040 if (fifo
->last_urblen
!= maxlen
) {
1042 * save fifo fill-level threshold bits
1043 * to use them later in TX ISO URB
1046 hw
->threshold_mask
= buf
[1];
1048 if (fifon
== HFCUSB_D_RX
)
1049 s0_state
= (buf
[0] >> 4);
1051 eof
[fifon
] = buf
[0] & 1;
1053 hfcsusb_rx_frame(fifo
, buf
+ 2,
1054 len
- 2, (len
< maxlen
)
1057 hfcsusb_rx_frame(fifo
, buf
, len
,
1060 fifo
->last_urblen
= len
;
1064 /* signal S0 layer1 state change */
1065 if ((s0_state
) && (hw
->initdone
) &&
1066 (s0_state
!= hw
->dch
.state
)) {
1067 hw
->dch
.state
= s0_state
;
1068 schedule_event(&hw
->dch
, FLG_PHCHANGE
);
1071 fill_isoc_urb(urb
, fifo
->hw
->dev
, fifo
->pipe
,
1072 context_iso_urb
->buffer
, num_isoc_packets
,
1073 fifo
->usb_packet_maxlen
, fifo
->intervall
,
1074 (usb_complete_t
)rx_iso_complete
, urb
->context
);
1075 errcode
= usb_submit_urb(urb
, GFP_ATOMIC
);
1077 if (debug
& DEBUG_HW
)
1078 printk(KERN_DEBUG
"%s: %s: error submitting "
1080 hw
->name
, __func__
, errcode
);
1083 if (status
&& (debug
& DBG_HFC_URB_INFO
))
1084 printk(KERN_DEBUG
"%s: %s: rx_iso_complete : "
1085 "urb->status %d, fifonum %d\n",
1086 hw
->name
, __func__
, status
, fifon
);
1090 /* receive completion routine for all interrupt rx fifos */
1092 rx_int_complete(struct urb
*urb
)
1095 __u8
*buf
, maxlen
, fifon
;
1096 struct usb_fifo
*fifo
= (struct usb_fifo
*) urb
->context
;
1097 struct hfcsusb
*hw
= fifo
->hw
;
1100 spin_lock(&hw
->lock
);
1101 if (fifo
->stop_gracefull
) {
1102 fifo
->stop_gracefull
= 0;
1104 spin_unlock(&hw
->lock
);
1107 spin_unlock(&hw
->lock
);
1109 fifon
= fifo
->fifonum
;
1110 if ((!fifo
->active
) || (urb
->status
)) {
1111 if (debug
& DBG_HFC_URB_ERROR
)
1113 "%s: %s: RX-Fifo %i is going down (%i)\n",
1114 hw
->name
, __func__
, fifon
, urb
->status
);
1116 fifo
->urb
->interval
= 0; /* cancel automatic rescheduling */
1119 len
= urb
->actual_length
;
1121 maxlen
= fifo
->usb_packet_maxlen
;
1123 /* USB data log for every D INT in */
1124 if ((fifon
== HFCUSB_D_RX
) && (debug
& DBG_HFC_USB_VERBOSE
)) {
1125 printk(KERN_DEBUG
"%s: %s: D RX INT len(%d) ",
1126 hw
->name
, __func__
, len
);
1127 for (i
= 0; i
< len
; i
++)
1128 printk("%02x ", buf
[i
]);
1132 if (fifo
->last_urblen
!= fifo
->usb_packet_maxlen
) {
1133 /* the threshold mask is in the 2nd status byte */
1134 hw
->threshold_mask
= buf
[1];
1136 /* signal S0 layer1 state change */
1137 if (hw
->initdone
&& ((buf
[0] >> 4) != hw
->dch
.state
)) {
1138 hw
->dch
.state
= (buf
[0] >> 4);
1139 schedule_event(&hw
->dch
, FLG_PHCHANGE
);
1142 eof
[fifon
] = buf
[0] & 1;
1143 /* if we have more than the 2 status bytes -> collect data */
1145 hfcsusb_rx_frame(fifo
, buf
+ 2,
1146 urb
->actual_length
- 2,
1147 (len
< maxlen
) ? eof
[fifon
] : 0);
1149 hfcsusb_rx_frame(fifo
, buf
, urb
->actual_length
,
1150 (len
< maxlen
) ? eof
[fifon
] : 0);
1152 fifo
->last_urblen
= urb
->actual_length
;
1154 status
= usb_submit_urb(urb
, GFP_ATOMIC
);
1156 if (debug
& DEBUG_HW
)
1157 printk(KERN_DEBUG
"%s: %s: error resubmitting USB\n",
1158 hw
->name
, __func__
);
1162 /* transmit completion routine for all ISO tx fifos */
1164 tx_iso_complete(struct urb
*urb
)
1166 struct iso_urb
*context_iso_urb
= (struct iso_urb
*) urb
->context
;
1167 struct usb_fifo
*fifo
= context_iso_urb
->owner_fifo
;
1168 struct hfcsusb
*hw
= fifo
->hw
;
1169 struct sk_buff
*tx_skb
;
1170 int k
, tx_offset
, num_isoc_packets
, sink
, remain
, current_len
,
1173 int frame_complete
, fifon
, status
, fillempty
= 0;
1176 spin_lock(&hw
->lock
);
1177 if (fifo
->stop_gracefull
) {
1178 fifo
->stop_gracefull
= 0;
1180 spin_unlock(&hw
->lock
);
1185 tx_skb
= fifo
->dch
->tx_skb
;
1186 tx_idx
= &fifo
->dch
->tx_idx
;
1188 } else if (fifo
->bch
) {
1189 tx_skb
= fifo
->bch
->tx_skb
;
1190 tx_idx
= &fifo
->bch
->tx_idx
;
1191 hdlc
= test_bit(FLG_HDLC
, &fifo
->bch
->Flags
);
1192 if (!tx_skb
&& !hdlc
&&
1193 test_bit(FLG_FILLEMPTY
, &fifo
->bch
->Flags
))
1196 printk(KERN_DEBUG
"%s: %s: neither BCH nor DCH\n",
1197 hw
->name
, __func__
);
1198 spin_unlock(&hw
->lock
);
1202 fifon
= fifo
->fifonum
;
1203 status
= urb
->status
;
1208 * ISO transfer only partially completed,
1209 * look at individual frame status for details
1211 if (status
== -EXDEV
) {
1212 if (debug
& DBG_HFC_URB_ERROR
)
1213 printk(KERN_DEBUG
"%s: %s: "
1214 "-EXDEV (%i) fifon (%d)\n",
1215 hw
->name
, __func__
, status
, fifon
);
1217 /* clear status, so go on with ISO transfers */
1221 if (fifo
->active
&& !status
) {
1222 /* is FifoFull-threshold set for our channel? */
1223 threshbit
= (hw
->threshold_mask
& (1 << fifon
));
1224 num_isoc_packets
= iso_packets
[fifon
];
1226 /* predict dataflow to avoid fifo overflow */
1227 if (fifon
>= HFCUSB_D_TX
)
1228 sink
= (threshbit
) ? SINK_DMIN
: SINK_DMAX
;
1230 sink
= (threshbit
) ? SINK_MIN
: SINK_MAX
;
1231 fill_isoc_urb(urb
, fifo
->hw
->dev
, fifo
->pipe
,
1232 context_iso_urb
->buffer
, num_isoc_packets
,
1233 fifo
->usb_packet_maxlen
, fifo
->intervall
,
1234 (usb_complete_t
)tx_iso_complete
, urb
->context
);
1235 memset(context_iso_urb
->buffer
, 0,
1236 sizeof(context_iso_urb
->buffer
));
1239 for (k
= 0; k
< num_isoc_packets
; ++k
) {
1240 /* analyze tx success of previous ISO packets */
1241 if (debug
& DBG_HFC_URB_ERROR
) {
1242 errcode
= urb
->iso_frame_desc
[k
].status
;
1244 printk(KERN_DEBUG
"%s: %s: "
1245 "ISO packet %i, status: %i\n",
1246 hw
->name
, __func__
, k
, errcode
);
1250 /* Generate next ISO Packets */
1252 remain
= tx_skb
->len
- *tx_idx
;
1254 remain
= 15; /* > not complete */
1259 fifo
->bit_line
-= sink
;
1260 current_len
= (0 - fifo
->bit_line
) / 8;
1261 if (current_len
> 14)
1263 if (current_len
< 0)
1265 if (remain
< current_len
)
1266 current_len
= remain
;
1268 /* how much bit do we put on the line? */
1269 fifo
->bit_line
+= current_len
* 8;
1271 context_iso_urb
->buffer
[tx_offset
] = 0;
1272 if (current_len
== remain
) {
1274 /* signal frame completion */
1276 buffer
[tx_offset
] = 1;
1277 /* add 2 byte flags and 16bit
1278 * CRC at end of ISDN frame */
1279 fifo
->bit_line
+= 32;
1284 /* copy tx data to iso-urb buffer */
1285 p
= context_iso_urb
->buffer
+ tx_offset
+ 1;
1287 memset(p
, fifo
->bch
->fill
[0],
1290 memcpy(p
, (tx_skb
->data
+ *tx_idx
),
1292 *tx_idx
+= current_len
;
1294 urb
->iso_frame_desc
[k
].offset
= tx_offset
;
1295 urb
->iso_frame_desc
[k
].length
= current_len
+ 1;
1297 /* USB data log for every D ISO out */
1298 if ((fifon
== HFCUSB_D_RX
) && !fillempty
&&
1299 (debug
& DBG_HFC_USB_VERBOSE
)) {
1301 "%s: %s (%d/%d) offs(%d) len(%d) ",
1303 k
, num_isoc_packets
- 1,
1304 urb
->iso_frame_desc
[k
].offset
,
1305 urb
->iso_frame_desc
[k
].length
);
1307 for (i
= urb
->iso_frame_desc
[k
].offset
;
1308 i
< (urb
->iso_frame_desc
[k
].offset
1309 + urb
->iso_frame_desc
[k
].length
);
1312 context_iso_urb
->buffer
[i
]);
1314 printk(" skb->len(%i) tx-idx(%d)\n",
1315 tx_skb
->len
, *tx_idx
);
1318 tx_offset
+= (current_len
+ 1);
1320 urb
->iso_frame_desc
[k
].offset
= tx_offset
++;
1321 urb
->iso_frame_desc
[k
].length
= 1;
1322 /* we lower data margin every msec */
1323 fifo
->bit_line
-= sink
;
1324 if (fifo
->bit_line
< BITLINE_INF
)
1325 fifo
->bit_line
= BITLINE_INF
;
1328 if (frame_complete
) {
1331 if (debug
& DBG_HFC_FIFO_VERBOSE
) {
1332 printk(KERN_DEBUG
"%s: %s: "
1333 "fifon(%i) new TX len(%i): ",
1335 fifon
, tx_skb
->len
);
1337 while (i
< tx_skb
->len
)
1343 dev_kfree_skb(tx_skb
);
1345 if (fifo
->dch
&& get_next_dframe(fifo
->dch
))
1346 tx_skb
= fifo
->dch
->tx_skb
;
1347 else if (fifo
->bch
&&
1348 get_next_bframe(fifo
->bch
))
1349 tx_skb
= fifo
->bch
->tx_skb
;
1352 errcode
= usb_submit_urb(urb
, GFP_ATOMIC
);
1354 if (debug
& DEBUG_HW
)
1356 "%s: %s: error submitting ISO URB: %d \n",
1357 hw
->name
, __func__
, errcode
);
1361 * abuse DChannel tx iso completion to trigger NT mode state
1362 * changes tx_iso_complete is assumed to be called every
1363 * fifo->intervall (ms)
1365 if ((fifon
== HFCUSB_D_TX
) && (hw
->protocol
== ISDN_P_NT_S0
)
1366 && (hw
->timers
& NT_ACTIVATION_TIMER
)) {
1367 if ((--hw
->nt_timer
) < 0)
1368 schedule_event(&hw
->dch
, FLG_PHCHANGE
);
1372 if (status
&& (debug
& DBG_HFC_URB_ERROR
))
1373 printk(KERN_DEBUG
"%s: %s: urb->status %s (%i)"
1376 symbolic(urb_errlist
, status
), status
, fifon
);
1378 spin_unlock(&hw
->lock
);
1382 * allocs urbs and start isoc transfer with two pending urbs to avoid
1383 * gaps in the transfer chain
1386 start_isoc_chain(struct usb_fifo
*fifo
, int num_packets_per_urb
,
1387 usb_complete_t complete
, int packet_size
)
1389 struct hfcsusb
*hw
= fifo
->hw
;
1393 printk(KERN_DEBUG
"%s: %s: fifo %i\n",
1394 hw
->name
, __func__
, fifo
->fifonum
);
1396 /* allocate Memory for Iso out Urbs */
1397 for (i
= 0; i
< 2; i
++) {
1398 if (!(fifo
->iso
[i
].urb
)) {
1400 usb_alloc_urb(num_packets_per_urb
, GFP_KERNEL
);
1401 if (!(fifo
->iso
[i
].urb
)) {
1403 "%s: %s: alloc urb for fifo %i failed",
1404 hw
->name
, __func__
, fifo
->fifonum
);
1406 fifo
->iso
[i
].owner_fifo
= (struct usb_fifo
*) fifo
;
1407 fifo
->iso
[i
].indx
= i
;
1409 /* Init the first iso */
1410 if (ISO_BUFFER_SIZE
>=
1411 (fifo
->usb_packet_maxlen
*
1412 num_packets_per_urb
)) {
1413 fill_isoc_urb(fifo
->iso
[i
].urb
,
1414 fifo
->hw
->dev
, fifo
->pipe
,
1415 fifo
->iso
[i
].buffer
,
1416 num_packets_per_urb
,
1417 fifo
->usb_packet_maxlen
,
1418 fifo
->intervall
, complete
,
1420 memset(fifo
->iso
[i
].buffer
, 0,
1421 sizeof(fifo
->iso
[i
].buffer
));
1423 for (k
= 0; k
< num_packets_per_urb
; k
++) {
1425 iso_frame_desc
[k
].offset
=
1428 iso_frame_desc
[k
].length
=
1433 "%s: %s: ISO Buffer size to small!\n",
1434 hw
->name
, __func__
);
1437 fifo
->bit_line
= BITLINE_INF
;
1439 errcode
= usb_submit_urb(fifo
->iso
[i
].urb
, GFP_KERNEL
);
1440 fifo
->active
= (errcode
>= 0) ? 1 : 0;
1441 fifo
->stop_gracefull
= 0;
1443 printk(KERN_DEBUG
"%s: %s: %s URB nr:%d\n",
1445 symbolic(urb_errlist
, errcode
), i
);
1448 return fifo
->active
;
1452 stop_iso_gracefull(struct usb_fifo
*fifo
)
1454 struct hfcsusb
*hw
= fifo
->hw
;
1458 for (i
= 0; i
< 2; i
++) {
1459 spin_lock_irqsave(&hw
->lock
, flags
);
1461 printk(KERN_DEBUG
"%s: %s for fifo %i.%i\n",
1462 hw
->name
, __func__
, fifo
->fifonum
, i
);
1463 fifo
->stop_gracefull
= 1;
1464 spin_unlock_irqrestore(&hw
->lock
, flags
);
1467 for (i
= 0; i
< 2; i
++) {
1469 while (fifo
->stop_gracefull
&& timeout
--)
1470 schedule_timeout_interruptible((HZ
/ 1000) * 16);
1471 if (debug
&& fifo
->stop_gracefull
)
1472 printk(KERN_DEBUG
"%s: ERROR %s for fifo %i.%i\n",
1473 hw
->name
, __func__
, fifo
->fifonum
, i
);
1478 stop_int_gracefull(struct usb_fifo
*fifo
)
1480 struct hfcsusb
*hw
= fifo
->hw
;
1484 spin_lock_irqsave(&hw
->lock
, flags
);
1486 printk(KERN_DEBUG
"%s: %s for fifo %i\n",
1487 hw
->name
, __func__
, fifo
->fifonum
);
1488 fifo
->stop_gracefull
= 1;
1489 spin_unlock_irqrestore(&hw
->lock
, flags
);
1492 while (fifo
->stop_gracefull
&& timeout
--)
1493 schedule_timeout_interruptible((HZ
/ 1000) * 3);
1494 if (debug
&& fifo
->stop_gracefull
)
1495 printk(KERN_DEBUG
"%s: ERROR %s for fifo %i\n",
1496 hw
->name
, __func__
, fifo
->fifonum
);
1499 /* start the interrupt transfer for the given fifo */
1501 start_int_fifo(struct usb_fifo
*fifo
)
1503 struct hfcsusb
*hw
= fifo
->hw
;
1507 printk(KERN_DEBUG
"%s: %s: INT IN fifo:%d\n",
1508 hw
->name
, __func__
, fifo
->fifonum
);
1511 fifo
->urb
= usb_alloc_urb(0, GFP_KERNEL
);
1515 usb_fill_int_urb(fifo
->urb
, fifo
->hw
->dev
, fifo
->pipe
,
1516 fifo
->buffer
, fifo
->usb_packet_maxlen
,
1517 (usb_complete_t
)rx_int_complete
, fifo
, fifo
->intervall
);
1519 fifo
->stop_gracefull
= 0;
1520 errcode
= usb_submit_urb(fifo
->urb
, GFP_KERNEL
);
1522 printk(KERN_DEBUG
"%s: %s: submit URB: status:%i\n",
1523 hw
->name
, __func__
, errcode
);
1529 setPortMode(struct hfcsusb
*hw
)
1531 if (debug
& DEBUG_HW
)
1532 printk(KERN_DEBUG
"%s: %s %s\n", hw
->name
, __func__
,
1533 (hw
->protocol
== ISDN_P_TE_S0
) ? "TE" : "NT");
1535 if (hw
->protocol
== ISDN_P_TE_S0
) {
1536 write_reg(hw
, HFCUSB_SCTRL
, 0x40);
1537 write_reg(hw
, HFCUSB_SCTRL_E
, 0x00);
1538 write_reg(hw
, HFCUSB_CLKDEL
, CLKDEL_TE
);
1539 write_reg(hw
, HFCUSB_STATES
, 3 | 0x10);
1540 write_reg(hw
, HFCUSB_STATES
, 3);
1542 write_reg(hw
, HFCUSB_SCTRL
, 0x44);
1543 write_reg(hw
, HFCUSB_SCTRL_E
, 0x09);
1544 write_reg(hw
, HFCUSB_CLKDEL
, CLKDEL_NT
);
1545 write_reg(hw
, HFCUSB_STATES
, 1 | 0x10);
1546 write_reg(hw
, HFCUSB_STATES
, 1);
1551 reset_hfcsusb(struct hfcsusb
*hw
)
1553 struct usb_fifo
*fifo
;
1556 if (debug
& DEBUG_HW
)
1557 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
1560 write_reg(hw
, HFCUSB_CIRM
, 8);
1562 /* aux = output, reset off */
1563 write_reg(hw
, HFCUSB_CIRM
, 0x10);
1565 /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */
1566 write_reg(hw
, HFCUSB_USB_SIZE
, (hw
->packet_size
/ 8) |
1567 ((hw
->packet_size
/ 8) << 4));
1569 /* set USB_SIZE_I to match the the wMaxPacketSize for ISO transfers */
1570 write_reg(hw
, HFCUSB_USB_SIZE_I
, hw
->iso_packet_size
);
1572 /* enable PCM/GCI master mode */
1573 write_reg(hw
, HFCUSB_MST_MODE1
, 0); /* set default values */
1574 write_reg(hw
, HFCUSB_MST_MODE0
, 1); /* enable master mode */
1576 /* init the fifos */
1577 write_reg(hw
, HFCUSB_F_THRES
,
1578 (HFCUSB_TX_THRESHOLD
/ 8) | ((HFCUSB_RX_THRESHOLD
/ 8) << 4));
1581 for (i
= 0; i
< HFCUSB_NUM_FIFOS
; i
++) {
1582 write_reg(hw
, HFCUSB_FIFO
, i
); /* select the desired fifo */
1584 (i
<= HFCUSB_B2_RX
) ? MAX_BCH_SIZE
: MAX_DFRAME_LEN
;
1585 fifo
[i
].last_urblen
= 0;
1587 /* set 2 bit for D- & E-channel */
1588 write_reg(hw
, HFCUSB_HDLC_PAR
, ((i
<= HFCUSB_B2_RX
) ? 0 : 2));
1590 /* enable all fifos */
1591 if (i
== HFCUSB_D_TX
)
1592 write_reg(hw
, HFCUSB_CON_HDLC
,
1593 (hw
->protocol
== ISDN_P_NT_S0
) ? 0x08 : 0x09);
1595 write_reg(hw
, HFCUSB_CON_HDLC
, 0x08);
1596 write_reg(hw
, HFCUSB_INC_RES_F
, 2); /* reset the fifo */
1599 write_reg(hw
, HFCUSB_SCTRL_R
, 0); /* disable both B receivers */
1600 handle_led(hw
, LED_POWER_ON
);
1603 /* start USB data pipes dependand on device's endpoint configuration */
1605 hfcsusb_start_endpoint(struct hfcsusb
*hw
, int channel
)
1607 /* quick check if endpoint already running */
1608 if ((channel
== HFC_CHAN_D
) && (hw
->fifos
[HFCUSB_D_RX
].active
))
1610 if ((channel
== HFC_CHAN_B1
) && (hw
->fifos
[HFCUSB_B1_RX
].active
))
1612 if ((channel
== HFC_CHAN_B2
) && (hw
->fifos
[HFCUSB_B2_RX
].active
))
1614 if ((channel
== HFC_CHAN_E
) && (hw
->fifos
[HFCUSB_PCM_RX
].active
))
1617 /* start rx endpoints using USB INT IN method */
1618 if (hw
->cfg_used
== CNF_3INT3ISO
|| hw
->cfg_used
== CNF_4INT3ISO
)
1619 start_int_fifo(hw
->fifos
+ channel
* 2 + 1);
1621 /* start rx endpoints using USB ISO IN method */
1622 if (hw
->cfg_used
== CNF_3ISO3ISO
|| hw
->cfg_used
== CNF_4ISO3ISO
) {
1625 start_isoc_chain(hw
->fifos
+ HFCUSB_D_RX
,
1627 (usb_complete_t
)rx_iso_complete
,
1631 start_isoc_chain(hw
->fifos
+ HFCUSB_PCM_RX
,
1633 (usb_complete_t
)rx_iso_complete
,
1637 start_isoc_chain(hw
->fifos
+ HFCUSB_B1_RX
,
1639 (usb_complete_t
)rx_iso_complete
,
1643 start_isoc_chain(hw
->fifos
+ HFCUSB_B2_RX
,
1645 (usb_complete_t
)rx_iso_complete
,
1651 /* start tx endpoints using USB ISO OUT method */
1654 start_isoc_chain(hw
->fifos
+ HFCUSB_D_TX
,
1656 (usb_complete_t
)tx_iso_complete
, 1);
1659 start_isoc_chain(hw
->fifos
+ HFCUSB_B1_TX
,
1661 (usb_complete_t
)tx_iso_complete
, 1);
1664 start_isoc_chain(hw
->fifos
+ HFCUSB_B2_TX
,
1666 (usb_complete_t
)tx_iso_complete
, 1);
1671 /* stop USB data pipes dependand on device's endpoint configuration */
1673 hfcsusb_stop_endpoint(struct hfcsusb
*hw
, int channel
)
1675 /* quick check if endpoint currently running */
1676 if ((channel
== HFC_CHAN_D
) && (!hw
->fifos
[HFCUSB_D_RX
].active
))
1678 if ((channel
== HFC_CHAN_B1
) && (!hw
->fifos
[HFCUSB_B1_RX
].active
))
1680 if ((channel
== HFC_CHAN_B2
) && (!hw
->fifos
[HFCUSB_B2_RX
].active
))
1682 if ((channel
== HFC_CHAN_E
) && (!hw
->fifos
[HFCUSB_PCM_RX
].active
))
1685 /* rx endpoints using USB INT IN method */
1686 if (hw
->cfg_used
== CNF_3INT3ISO
|| hw
->cfg_used
== CNF_4INT3ISO
)
1687 stop_int_gracefull(hw
->fifos
+ channel
* 2 + 1);
1689 /* rx endpoints using USB ISO IN method */
1690 if (hw
->cfg_used
== CNF_3ISO3ISO
|| hw
->cfg_used
== CNF_4ISO3ISO
)
1691 stop_iso_gracefull(hw
->fifos
+ channel
* 2 + 1);
1693 /* tx endpoints using USB ISO OUT method */
1694 if (channel
!= HFC_CHAN_E
)
1695 stop_iso_gracefull(hw
->fifos
+ channel
* 2);
1699 /* Hardware Initialization */
1701 setup_hfcsusb(struct hfcsusb
*hw
)
1705 if (debug
& DBG_HFC_CALL_TRACE
)
1706 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
1708 /* check the chip id */
1709 if (read_reg_atomic(hw
, HFCUSB_CHIP_ID
, &b
) != 1) {
1710 printk(KERN_DEBUG
"%s: %s: cannot read chip id\n",
1711 hw
->name
, __func__
);
1714 if (b
!= HFCUSB_CHIPID
) {
1715 printk(KERN_DEBUG
"%s: %s: Invalid chip id 0x%02x\n",
1716 hw
->name
, __func__
, b
);
1720 /* first set the needed config, interface and alternate */
1721 (void) usb_set_interface(hw
->dev
, hw
->if_used
, hw
->alt_used
);
1725 /* init the background machinery for control requests */
1726 hw
->ctrl_read
.bRequestType
= 0xc0;
1727 hw
->ctrl_read
.bRequest
= 1;
1728 hw
->ctrl_read
.wLength
= cpu_to_le16(1);
1729 hw
->ctrl_write
.bRequestType
= 0x40;
1730 hw
->ctrl_write
.bRequest
= 0;
1731 hw
->ctrl_write
.wLength
= 0;
1732 usb_fill_control_urb(hw
->ctrl_urb
, hw
->dev
, hw
->ctrl_out_pipe
,
1733 (u_char
*)&hw
->ctrl_write
, NULL
, 0,
1734 (usb_complete_t
)ctrl_complete
, hw
);
1741 release_hw(struct hfcsusb
*hw
)
1743 if (debug
& DBG_HFC_CALL_TRACE
)
1744 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
1747 * stop all endpoints gracefully
1748 * TODO: mISDN_core should generate CLOSE_CHANNEL
1749 * signals after calling mISDN_unregister_device()
1751 hfcsusb_stop_endpoint(hw
, HFC_CHAN_D
);
1752 hfcsusb_stop_endpoint(hw
, HFC_CHAN_B1
);
1753 hfcsusb_stop_endpoint(hw
, HFC_CHAN_B2
);
1754 if (hw
->fifos
[HFCUSB_PCM_RX
].pipe
)
1755 hfcsusb_stop_endpoint(hw
, HFC_CHAN_E
);
1756 if (hw
->protocol
== ISDN_P_TE_S0
)
1757 l1_event(hw
->dch
.l1
, CLOSE_CHANNEL
);
1759 mISDN_unregister_device(&hw
->dch
.dev
);
1760 mISDN_freebchannel(&hw
->bch
[1]);
1761 mISDN_freebchannel(&hw
->bch
[0]);
1762 mISDN_freedchannel(&hw
->dch
);
1765 usb_kill_urb(hw
->ctrl_urb
);
1766 usb_free_urb(hw
->ctrl_urb
);
1767 hw
->ctrl_urb
= NULL
;
1771 usb_set_intfdata(hw
->intf
, NULL
);
1772 list_del(&hw
->list
);
1778 deactivate_bchannel(struct bchannel
*bch
)
1780 struct hfcsusb
*hw
= bch
->hw
;
1783 if (bch
->debug
& DEBUG_HW
)
1784 printk(KERN_DEBUG
"%s: %s: bch->nr(%i)\n",
1785 hw
->name
, __func__
, bch
->nr
);
1787 spin_lock_irqsave(&hw
->lock
, flags
);
1788 mISDN_clear_bchannel(bch
);
1789 spin_unlock_irqrestore(&hw
->lock
, flags
);
1790 hfcsusb_setup_bch(bch
, ISDN_P_NONE
);
1791 hfcsusb_stop_endpoint(hw
, bch
->nr
- 1);
1795 * Layer 1 B-channel hardware access
1798 hfc_bctrl(struct mISDNchannel
*ch
, u_int cmd
, void *arg
)
1800 struct bchannel
*bch
= container_of(ch
, struct bchannel
, ch
);
1803 if (bch
->debug
& DEBUG_HW
)
1804 printk(KERN_DEBUG
"%s: cmd:%x %p\n", __func__
, cmd
, arg
);
1808 case HW_TESTRX_HDLC
:
1814 test_and_clear_bit(FLG_OPEN
, &bch
->Flags
);
1815 deactivate_bchannel(bch
);
1816 ch
->protocol
= ISDN_P_NONE
;
1818 module_put(THIS_MODULE
);
1821 case CONTROL_CHANNEL
:
1822 ret
= channel_bctrl(bch
, arg
);
1825 printk(KERN_WARNING
"%s: unknown prim(%x)\n",
1832 setup_instance(struct hfcsusb
*hw
, struct device
*parent
)
1837 if (debug
& DBG_HFC_CALL_TRACE
)
1838 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
1840 spin_lock_init(&hw
->ctrl_lock
);
1841 spin_lock_init(&hw
->lock
);
1843 mISDN_initdchannel(&hw
->dch
, MAX_DFRAME_LEN_L1
, ph_state
);
1844 hw
->dch
.debug
= debug
& 0xFFFF;
1846 hw
->dch
.dev
.Dprotocols
= (1 << ISDN_P_TE_S0
) | (1 << ISDN_P_NT_S0
);
1847 hw
->dch
.dev
.D
.send
= hfcusb_l2l1D
;
1848 hw
->dch
.dev
.D
.ctrl
= hfc_dctrl
;
1850 /* enable E-Channel logging */
1851 if (hw
->fifos
[HFCUSB_PCM_RX
].pipe
)
1852 mISDN_initdchannel(&hw
->ech
, MAX_DFRAME_LEN_L1
, NULL
);
1854 hw
->dch
.dev
.Bprotocols
= (1 << (ISDN_P_B_RAW
& ISDN_P_B_MASK
)) |
1855 (1 << (ISDN_P_B_HDLC
& ISDN_P_B_MASK
));
1856 hw
->dch
.dev
.nrbchan
= 2;
1857 for (i
= 0; i
< 2; i
++) {
1858 hw
->bch
[i
].nr
= i
+ 1;
1859 set_channelmap(i
+ 1, hw
->dch
.dev
.channelmap
);
1860 hw
->bch
[i
].debug
= debug
;
1861 mISDN_initbchannel(&hw
->bch
[i
], MAX_DATA_MEM
, poll
>> 1);
1863 hw
->bch
[i
].ch
.send
= hfcusb_l2l1B
;
1864 hw
->bch
[i
].ch
.ctrl
= hfc_bctrl
;
1865 hw
->bch
[i
].ch
.nr
= i
+ 1;
1866 list_add(&hw
->bch
[i
].ch
.list
, &hw
->dch
.dev
.bchannels
);
1869 hw
->fifos
[HFCUSB_B1_TX
].bch
= &hw
->bch
[0];
1870 hw
->fifos
[HFCUSB_B1_RX
].bch
= &hw
->bch
[0];
1871 hw
->fifos
[HFCUSB_B2_TX
].bch
= &hw
->bch
[1];
1872 hw
->fifos
[HFCUSB_B2_RX
].bch
= &hw
->bch
[1];
1873 hw
->fifos
[HFCUSB_D_TX
].dch
= &hw
->dch
;
1874 hw
->fifos
[HFCUSB_D_RX
].dch
= &hw
->dch
;
1875 hw
->fifos
[HFCUSB_PCM_RX
].ech
= &hw
->ech
;
1876 hw
->fifos
[HFCUSB_PCM_TX
].ech
= &hw
->ech
;
1878 err
= setup_hfcsusb(hw
);
1882 snprintf(hw
->name
, MISDN_MAX_IDLEN
- 1, "%s.%d", DRIVER_NAME
,
1884 printk(KERN_INFO
"%s: registered as '%s'\n",
1885 DRIVER_NAME
, hw
->name
);
1887 err
= mISDN_register_device(&hw
->dch
.dev
, parent
, hw
->name
);
1892 write_lock_irqsave(&HFClock
, flags
);
1893 list_add_tail(&hw
->list
, &HFClist
);
1894 write_unlock_irqrestore(&HFClock
, flags
);
1898 mISDN_freebchannel(&hw
->bch
[1]);
1899 mISDN_freebchannel(&hw
->bch
[0]);
1900 mISDN_freedchannel(&hw
->dch
);
1906 hfcsusb_probe(struct usb_interface
*intf
, const struct usb_device_id
*id
)
1909 struct usb_device
*dev
= interface_to_usbdev(intf
);
1910 struct usb_host_interface
*iface
= intf
->cur_altsetting
;
1911 struct usb_host_interface
*iface_used
= NULL
;
1912 struct usb_host_endpoint
*ep
;
1913 struct hfcsusb_vdata
*driver_info
;
1914 int ifnum
= iface
->desc
.bInterfaceNumber
, i
, idx
, alt_idx
,
1915 probe_alt_setting
, vend_idx
, cfg_used
, *vcf
, attr
, cfg_found
,
1916 ep_addr
, cmptbl
[16], small_match
, iso_packet_size
, packet_size
,
1920 for (i
= 0; hfcsusb_idtab
[i
].idVendor
; i
++) {
1921 if ((le16_to_cpu(dev
->descriptor
.idVendor
)
1922 == hfcsusb_idtab
[i
].idVendor
) &&
1923 (le16_to_cpu(dev
->descriptor
.idProduct
)
1924 == hfcsusb_idtab
[i
].idProduct
)) {
1931 "%s: interface(%d) actalt(%d) minor(%d) vend_idx(%d)\n",
1932 __func__
, ifnum
, iface
->desc
.bAlternateSetting
,
1933 intf
->minor
, vend_idx
);
1935 if (vend_idx
== 0xffff) {
1937 "%s: no valid vendor found in USB descriptor\n",
1941 /* if vendor and product ID is OK, start probing alternate settings */
1945 /* default settings */
1946 iso_packet_size
= 16;
1949 while (alt_idx
< intf
->num_altsetting
) {
1950 iface
= intf
->altsetting
+ alt_idx
;
1951 probe_alt_setting
= iface
->desc
.bAlternateSetting
;
1954 while (validconf
[cfg_used
][0]) {
1956 vcf
= validconf
[cfg_used
];
1957 ep
= iface
->endpoint
;
1958 memcpy(cmptbl
, vcf
, 16 * sizeof(int));
1960 /* check for all endpoints in this alternate setting */
1961 for (i
= 0; i
< iface
->desc
.bNumEndpoints
; i
++) {
1962 ep_addr
= ep
->desc
.bEndpointAddress
;
1964 /* get endpoint base */
1965 idx
= ((ep_addr
& 0x7f) - 1) * 2;
1968 attr
= ep
->desc
.bmAttributes
;
1970 if (cmptbl
[idx
] != EP_NOP
) {
1971 if (cmptbl
[idx
] == EP_NUL
)
1973 if (attr
== USB_ENDPOINT_XFER_INT
1974 && cmptbl
[idx
] == EP_INT
)
1975 cmptbl
[idx
] = EP_NUL
;
1976 if (attr
== USB_ENDPOINT_XFER_BULK
1977 && cmptbl
[idx
] == EP_BLK
)
1978 cmptbl
[idx
] = EP_NUL
;
1979 if (attr
== USB_ENDPOINT_XFER_ISOC
1980 && cmptbl
[idx
] == EP_ISO
)
1981 cmptbl
[idx
] = EP_NUL
;
1983 if (attr
== USB_ENDPOINT_XFER_INT
&&
1984 ep
->desc
.bInterval
< vcf
[17]) {
1991 for (i
= 0; i
< 16; i
++)
1992 if (cmptbl
[i
] != EP_NOP
&& cmptbl
[i
] != EP_NUL
)
1996 if (small_match
< cfg_used
) {
1997 small_match
= cfg_used
;
1998 alt_used
= probe_alt_setting
;
2005 } /* (alt_idx < intf->num_altsetting) */
2007 /* not found a valid USB Ta Endpoint config */
2008 if (small_match
== -1)
2012 hw
= kzalloc(sizeof(struct hfcsusb
), GFP_KERNEL
);
2014 return -ENOMEM
; /* got no mem */
2015 snprintf(hw
->name
, MISDN_MAX_IDLEN
- 1, "%s", DRIVER_NAME
);
2017 ep
= iface
->endpoint
;
2018 vcf
= validconf
[small_match
];
2020 for (i
= 0; i
< iface
->desc
.bNumEndpoints
; i
++) {
2023 ep_addr
= ep
->desc
.bEndpointAddress
;
2024 /* get endpoint base */
2025 idx
= ((ep_addr
& 0x7f) - 1) * 2;
2028 f
= &hw
->fifos
[idx
& 7];
2030 /* init Endpoints */
2031 if (vcf
[idx
] == EP_NOP
|| vcf
[idx
] == EP_NUL
) {
2035 switch (ep
->desc
.bmAttributes
) {
2036 case USB_ENDPOINT_XFER_INT
:
2037 f
->pipe
= usb_rcvintpipe(dev
,
2038 ep
->desc
.bEndpointAddress
);
2039 f
->usb_transfer_mode
= USB_INT
;
2040 packet_size
= le16_to_cpu(ep
->desc
.wMaxPacketSize
);
2042 case USB_ENDPOINT_XFER_BULK
:
2044 f
->pipe
= usb_rcvbulkpipe(dev
,
2045 ep
->desc
.bEndpointAddress
);
2047 f
->pipe
= usb_sndbulkpipe(dev
,
2048 ep
->desc
.bEndpointAddress
);
2049 f
->usb_transfer_mode
= USB_BULK
;
2050 packet_size
= le16_to_cpu(ep
->desc
.wMaxPacketSize
);
2052 case USB_ENDPOINT_XFER_ISOC
:
2054 f
->pipe
= usb_rcvisocpipe(dev
,
2055 ep
->desc
.bEndpointAddress
);
2057 f
->pipe
= usb_sndisocpipe(dev
,
2058 ep
->desc
.bEndpointAddress
);
2059 f
->usb_transfer_mode
= USB_ISOC
;
2060 iso_packet_size
= le16_to_cpu(ep
->desc
.wMaxPacketSize
);
2067 f
->fifonum
= idx
& 7;
2069 f
->usb_packet_maxlen
=
2070 le16_to_cpu(ep
->desc
.wMaxPacketSize
);
2071 f
->intervall
= ep
->desc
.bInterval
;
2075 hw
->dev
= dev
; /* save device */
2076 hw
->if_used
= ifnum
; /* save used interface */
2077 hw
->alt_used
= alt_used
; /* and alternate config */
2078 hw
->ctrl_paksize
= dev
->descriptor
.bMaxPacketSize0
; /* control size */
2079 hw
->cfg_used
= vcf
[16]; /* store used config */
2080 hw
->vend_idx
= vend_idx
; /* store found vendor */
2081 hw
->packet_size
= packet_size
;
2082 hw
->iso_packet_size
= iso_packet_size
;
2084 /* create the control pipes needed for register access */
2085 hw
->ctrl_in_pipe
= usb_rcvctrlpipe(hw
->dev
, 0);
2086 hw
->ctrl_out_pipe
= usb_sndctrlpipe(hw
->dev
, 0);
2088 driver_info
= (struct hfcsusb_vdata
*)
2089 hfcsusb_idtab
[vend_idx
].driver_info
;
2091 hw
->ctrl_urb
= usb_alloc_urb(0, GFP_KERNEL
);
2092 if (!hw
->ctrl_urb
) {
2093 pr_warn("%s: No memory for control urb\n",
2094 driver_info
->vend_name
);
2099 pr_info("%s: %s: detected \"%s\" (%s, if=%d alt=%d)\n",
2100 hw
->name
, __func__
, driver_info
->vend_name
,
2101 conf_str
[small_match
], ifnum
, alt_used
);
2103 if (setup_instance(hw
, dev
->dev
.parent
))
2107 usb_set_intfdata(hw
->intf
, hw
);
2111 /* function called when an active device is removed */
2113 hfcsusb_disconnect(struct usb_interface
*intf
)
2115 struct hfcsusb
*hw
= usb_get_intfdata(intf
);
2116 struct hfcsusb
*next
;
2119 printk(KERN_INFO
"%s: device disconnected\n", hw
->name
);
2121 handle_led(hw
, LED_POWER_OFF
);
2124 list_for_each_entry_safe(hw
, next
, &HFClist
, list
)
2129 usb_set_intfdata(intf
, NULL
);
2132 static struct usb_driver hfcsusb_drv
= {
2133 .name
= DRIVER_NAME
,
2134 .id_table
= hfcsusb_idtab
,
2135 .probe
= hfcsusb_probe
,
2136 .disconnect
= hfcsusb_disconnect
,
2137 .disable_hub_initiated_lpm
= 1,
2140 module_usb_driver(hfcsusb_drv
);