1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * mISDN driver for Colognechip HFC-S USB chip
5 * Copyright 2001 by Peter Sprenger (sprenger@moving-bytes.de)
6 * Copyright 2008 by Martin Bachem (info@bachem-it.com)
9 * debug=<n>, default=0, with n=0xHHHHGGGG
10 * H - l1 driver flags described in hfcsusb.h
11 * G - common mISDN debug flags described at mISDNhw.h
13 * poll=<n>, default 128
14 * n : burst size of PH_DATA_IND at transparent rx data
16 * Revision: 0.3.3 (socket), 2008-11-05
19 #include <linux/module.h>
20 #include <linux/delay.h>
21 #include <linux/usb.h>
22 #include <linux/mISDNhw.h>
23 #include <linux/slab.h>
26 static unsigned int debug
;
27 static int poll
= DEFAULT_TRANSP_BURST_SZ
;
29 static LIST_HEAD(HFClist
);
30 static DEFINE_RWLOCK(HFClock
);
33 MODULE_AUTHOR("Martin Bachem");
34 MODULE_LICENSE("GPL");
35 module_param(debug
, uint
, S_IRUGO
| S_IWUSR
);
36 module_param(poll
, int, 0);
38 static int hfcsusb_cnt
;
40 /* some function prototypes */
41 static void hfcsusb_ph_command(struct hfcsusb
*hw
, u_char command
);
42 static void release_hw(struct hfcsusb
*hw
);
43 static void reset_hfcsusb(struct hfcsusb
*hw
);
44 static void setPortMode(struct hfcsusb
*hw
);
45 static void hfcsusb_start_endpoint(struct hfcsusb
*hw
, int channel
);
46 static void hfcsusb_stop_endpoint(struct hfcsusb
*hw
, int channel
);
47 static int hfcsusb_setup_bch(struct bchannel
*bch
, int protocol
);
48 static void deactivate_bchannel(struct bchannel
*bch
);
49 static void hfcsusb_ph_info(struct hfcsusb
*hw
);
51 /* start next background transfer for control channel */
53 ctrl_start_transfer(struct hfcsusb
*hw
)
55 if (debug
& DBG_HFC_CALL_TRACE
)
56 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
59 hw
->ctrl_urb
->pipe
= hw
->ctrl_out_pipe
;
60 hw
->ctrl_urb
->setup_packet
= (u_char
*)&hw
->ctrl_write
;
61 hw
->ctrl_urb
->transfer_buffer
= NULL
;
62 hw
->ctrl_urb
->transfer_buffer_length
= 0;
63 hw
->ctrl_write
.wIndex
=
64 cpu_to_le16(hw
->ctrl_buff
[hw
->ctrl_out_idx
].hfcs_reg
);
65 hw
->ctrl_write
.wValue
=
66 cpu_to_le16(hw
->ctrl_buff
[hw
->ctrl_out_idx
].reg_val
);
68 usb_submit_urb(hw
->ctrl_urb
, GFP_ATOMIC
);
73 * queue a control transfer request to write HFC-S USB
74 * chip register using CTRL resuest queue
76 static int write_reg(struct hfcsusb
*hw
, __u8 reg
, __u8 val
)
80 if (debug
& DBG_HFC_CALL_TRACE
)
81 printk(KERN_DEBUG
"%s: %s reg(0x%02x) val(0x%02x)\n",
82 hw
->name
, __func__
, reg
, val
);
84 spin_lock(&hw
->ctrl_lock
);
85 if (hw
->ctrl_cnt
>= HFC_CTRL_BUFSIZE
) {
86 spin_unlock(&hw
->ctrl_lock
);
89 buf
= &hw
->ctrl_buff
[hw
->ctrl_in_idx
];
92 if (++hw
->ctrl_in_idx
>= HFC_CTRL_BUFSIZE
)
94 if (++hw
->ctrl_cnt
== 1)
95 ctrl_start_transfer(hw
);
96 spin_unlock(&hw
->ctrl_lock
);
101 /* control completion routine handling background control cmds */
103 ctrl_complete(struct urb
*urb
)
105 struct hfcsusb
*hw
= (struct hfcsusb
*) urb
->context
;
107 if (debug
& DBG_HFC_CALL_TRACE
)
108 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
112 hw
->ctrl_cnt
--; /* decrement actual count */
113 if (++hw
->ctrl_out_idx
>= HFC_CTRL_BUFSIZE
)
114 hw
->ctrl_out_idx
= 0; /* pointer wrap */
116 ctrl_start_transfer(hw
); /* start next transfer */
120 /* handle LED bits */
122 set_led_bit(struct hfcsusb
*hw
, signed short led_bits
, int set_on
)
126 hw
->led_state
&= ~abs(led_bits
);
128 hw
->led_state
|= led_bits
;
131 hw
->led_state
|= abs(led_bits
);
133 hw
->led_state
&= ~led_bits
;
137 /* handle LED requests */
139 handle_led(struct hfcsusb
*hw
, int event
)
141 struct hfcsusb_vdata
*driver_info
= (struct hfcsusb_vdata
*)
142 hfcsusb_idtab
[hw
->vend_idx
].driver_info
;
145 if (driver_info
->led_scheme
== LED_OFF
)
147 tmpled
= hw
->led_state
;
151 set_led_bit(hw
, driver_info
->led_bits
[0], 1);
152 set_led_bit(hw
, driver_info
->led_bits
[1], 0);
153 set_led_bit(hw
, driver_info
->led_bits
[2], 0);
154 set_led_bit(hw
, driver_info
->led_bits
[3], 0);
157 set_led_bit(hw
, driver_info
->led_bits
[0], 0);
158 set_led_bit(hw
, driver_info
->led_bits
[1], 0);
159 set_led_bit(hw
, driver_info
->led_bits
[2], 0);
160 set_led_bit(hw
, driver_info
->led_bits
[3], 0);
163 set_led_bit(hw
, driver_info
->led_bits
[1], 1);
166 set_led_bit(hw
, driver_info
->led_bits
[1], 0);
169 set_led_bit(hw
, driver_info
->led_bits
[2], 1);
172 set_led_bit(hw
, driver_info
->led_bits
[2], 0);
175 set_led_bit(hw
, driver_info
->led_bits
[3], 1);
178 set_led_bit(hw
, driver_info
->led_bits
[3], 0);
182 if (hw
->led_state
!= tmpled
) {
183 if (debug
& DBG_HFC_CALL_TRACE
)
184 printk(KERN_DEBUG
"%s: %s reg(0x%02x) val(x%02x)\n",
186 HFCUSB_P_DATA
, hw
->led_state
);
188 write_reg(hw
, HFCUSB_P_DATA
, hw
->led_state
);
193 * Layer2 -> Layer 1 Bchannel data
196 hfcusb_l2l1B(struct mISDNchannel
*ch
, struct sk_buff
*skb
)
198 struct bchannel
*bch
= container_of(ch
, struct bchannel
, ch
);
199 struct hfcsusb
*hw
= bch
->hw
;
201 struct mISDNhead
*hh
= mISDN_HEAD_P(skb
);
204 if (debug
& DBG_HFC_CALL_TRACE
)
205 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
209 spin_lock_irqsave(&hw
->lock
, flags
);
210 ret
= bchannel_senddata(bch
, skb
);
211 spin_unlock_irqrestore(&hw
->lock
, flags
);
212 if (debug
& DBG_HFC_CALL_TRACE
)
213 printk(KERN_DEBUG
"%s: %s PH_DATA_REQ ret(%i)\n",
214 hw
->name
, __func__
, ret
);
218 case PH_ACTIVATE_REQ
:
219 if (!test_and_set_bit(FLG_ACTIVE
, &bch
->Flags
)) {
220 hfcsusb_start_endpoint(hw
, bch
->nr
- 1);
221 ret
= hfcsusb_setup_bch(bch
, ch
->protocol
);
225 _queue_data(ch
, PH_ACTIVATE_IND
, MISDN_ID_ANY
,
226 0, NULL
, GFP_KERNEL
);
228 case PH_DEACTIVATE_REQ
:
229 deactivate_bchannel(bch
);
230 _queue_data(ch
, PH_DEACTIVATE_IND
, MISDN_ID_ANY
,
231 0, NULL
, GFP_KERNEL
);
241 * send full D/B channel status information
242 * as MPH_INFORMATION_IND
245 hfcsusb_ph_info(struct hfcsusb
*hw
)
248 struct dchannel
*dch
= &hw
->dch
;
251 phi
= kzalloc(struct_size(phi
, bch
, dch
->dev
.nrbchan
), GFP_ATOMIC
);
255 phi
->dch
.ch
.protocol
= hw
->protocol
;
256 phi
->dch
.ch
.Flags
= dch
->Flags
;
257 phi
->dch
.state
= dch
->state
;
258 phi
->dch
.num_bch
= dch
->dev
.nrbchan
;
259 for (i
= 0; i
< dch
->dev
.nrbchan
; i
++) {
260 phi
->bch
[i
].protocol
= hw
->bch
[i
].ch
.protocol
;
261 phi
->bch
[i
].Flags
= hw
->bch
[i
].Flags
;
263 _queue_data(&dch
->dev
.D
, MPH_INFORMATION_IND
, MISDN_ID_ANY
,
264 struct_size(phi
, bch
, dch
->dev
.nrbchan
), phi
, GFP_ATOMIC
);
269 * Layer2 -> Layer 1 Dchannel data
272 hfcusb_l2l1D(struct mISDNchannel
*ch
, struct sk_buff
*skb
)
274 struct mISDNdevice
*dev
= container_of(ch
, struct mISDNdevice
, D
);
275 struct dchannel
*dch
= container_of(dev
, struct dchannel
, dev
);
276 struct mISDNhead
*hh
= mISDN_HEAD_P(skb
);
277 struct hfcsusb
*hw
= dch
->hw
;
283 if (debug
& DBG_HFC_CALL_TRACE
)
284 printk(KERN_DEBUG
"%s: %s: PH_DATA_REQ\n",
287 spin_lock_irqsave(&hw
->lock
, flags
);
288 ret
= dchannel_senddata(dch
, skb
);
289 spin_unlock_irqrestore(&hw
->lock
, flags
);
292 queue_ch_frame(ch
, PH_DATA_CNF
, hh
->id
, NULL
);
296 case PH_ACTIVATE_REQ
:
297 if (debug
& DBG_HFC_CALL_TRACE
)
298 printk(KERN_DEBUG
"%s: %s: PH_ACTIVATE_REQ %s\n",
300 (hw
->protocol
== ISDN_P_NT_S0
) ? "NT" : "TE");
302 if (hw
->protocol
== ISDN_P_NT_S0
) {
304 if (test_bit(FLG_ACTIVE
, &dch
->Flags
)) {
305 _queue_data(&dch
->dev
.D
,
306 PH_ACTIVATE_IND
, MISDN_ID_ANY
, 0,
309 hfcsusb_ph_command(hw
,
311 test_and_set_bit(FLG_L2_ACTIVATED
,
315 hfcsusb_ph_command(hw
, HFC_L1_ACTIVATE_TE
);
316 ret
= l1_event(dch
->l1
, hh
->prim
);
320 case PH_DEACTIVATE_REQ
:
321 if (debug
& DBG_HFC_CALL_TRACE
)
322 printk(KERN_DEBUG
"%s: %s: PH_DEACTIVATE_REQ\n",
324 test_and_clear_bit(FLG_L2_ACTIVATED
, &dch
->Flags
);
326 if (hw
->protocol
== ISDN_P_NT_S0
) {
327 hfcsusb_ph_command(hw
, HFC_L1_DEACTIVATE_NT
);
328 spin_lock_irqsave(&hw
->lock
, flags
);
329 skb_queue_purge(&dch
->squeue
);
331 dev_kfree_skb(dch
->tx_skb
);
336 dev_kfree_skb(dch
->rx_skb
);
339 test_and_clear_bit(FLG_TX_BUSY
, &dch
->Flags
);
340 spin_unlock_irqrestore(&hw
->lock
, flags
);
342 if (test_and_clear_bit(FLG_L1_BUSY
, &dch
->Flags
))
343 dchannel_sched_event(&hc
->dch
, D_CLEARBUSY
);
347 ret
= l1_event(dch
->l1
, hh
->prim
);
349 case MPH_INFORMATION_REQ
:
359 * Layer 1 callback function
362 hfc_l1callback(struct dchannel
*dch
, u_int cmd
)
364 struct hfcsusb
*hw
= dch
->hw
;
366 if (debug
& DBG_HFC_CALL_TRACE
)
367 printk(KERN_DEBUG
"%s: %s cmd 0x%x\n",
368 hw
->name
, __func__
, cmd
);
378 skb_queue_purge(&dch
->squeue
);
380 dev_kfree_skb(dch
->tx_skb
);
385 dev_kfree_skb(dch
->rx_skb
);
388 test_and_clear_bit(FLG_TX_BUSY
, &dch
->Flags
);
390 case PH_ACTIVATE_IND
:
391 test_and_set_bit(FLG_ACTIVE
, &dch
->Flags
);
392 _queue_data(&dch
->dev
.D
, cmd
, MISDN_ID_ANY
, 0, NULL
,
395 case PH_DEACTIVATE_IND
:
396 test_and_clear_bit(FLG_ACTIVE
, &dch
->Flags
);
397 _queue_data(&dch
->dev
.D
, cmd
, MISDN_ID_ANY
, 0, NULL
,
401 if (dch
->debug
& DEBUG_HW
)
402 printk(KERN_DEBUG
"%s: %s: unknown cmd %x\n",
403 hw
->name
, __func__
, cmd
);
411 open_dchannel(struct hfcsusb
*hw
, struct mISDNchannel
*ch
,
412 struct channel_req
*rq
)
416 if (debug
& DEBUG_HW_OPEN
)
417 printk(KERN_DEBUG
"%s: %s: dev(%d) open addr(%i) from %p\n",
418 hw
->name
, __func__
, hw
->dch
.dev
.id
, rq
->adr
.channel
,
419 __builtin_return_address(0));
420 if (rq
->protocol
== ISDN_P_NONE
)
423 test_and_clear_bit(FLG_ACTIVE
, &hw
->dch
.Flags
);
424 test_and_clear_bit(FLG_ACTIVE
, &hw
->ech
.Flags
);
425 hfcsusb_start_endpoint(hw
, HFC_CHAN_D
);
427 /* E-Channel logging */
428 if (rq
->adr
.channel
== 1) {
429 if (hw
->fifos
[HFCUSB_PCM_RX
].pipe
) {
430 hfcsusb_start_endpoint(hw
, HFC_CHAN_E
);
431 set_bit(FLG_ACTIVE
, &hw
->ech
.Flags
);
432 _queue_data(&hw
->ech
.dev
.D
, PH_ACTIVATE_IND
,
433 MISDN_ID_ANY
, 0, NULL
, GFP_ATOMIC
);
439 hw
->protocol
= rq
->protocol
;
440 if (rq
->protocol
== ISDN_P_TE_S0
) {
441 err
= create_l1(&hw
->dch
, hfc_l1callback
);
446 ch
->protocol
= rq
->protocol
;
449 if (rq
->protocol
!= ch
->protocol
)
450 return -EPROTONOSUPPORT
;
453 if (((ch
->protocol
== ISDN_P_NT_S0
) && (hw
->dch
.state
== 3)) ||
454 ((ch
->protocol
== ISDN_P_TE_S0
) && (hw
->dch
.state
== 7)))
455 _queue_data(ch
, PH_ACTIVATE_IND
, MISDN_ID_ANY
,
456 0, NULL
, GFP_KERNEL
);
458 if (!try_module_get(THIS_MODULE
))
459 printk(KERN_WARNING
"%s: %s: cannot get module\n",
465 open_bchannel(struct hfcsusb
*hw
, struct channel_req
*rq
)
467 struct bchannel
*bch
;
469 if (rq
->adr
.channel
== 0 || rq
->adr
.channel
> 2)
471 if (rq
->protocol
== ISDN_P_NONE
)
474 if (debug
& DBG_HFC_CALL_TRACE
)
475 printk(KERN_DEBUG
"%s: %s B%i\n",
476 hw
->name
, __func__
, rq
->adr
.channel
);
478 bch
= &hw
->bch
[rq
->adr
.channel
- 1];
479 if (test_and_set_bit(FLG_OPEN
, &bch
->Flags
))
480 return -EBUSY
; /* b-channel can be only open once */
481 bch
->ch
.protocol
= rq
->protocol
;
484 if (!try_module_get(THIS_MODULE
))
485 printk(KERN_WARNING
"%s: %s:cannot get module\n",
491 channel_ctrl(struct hfcsusb
*hw
, struct mISDN_ctrl_req
*cq
)
495 if (debug
& DBG_HFC_CALL_TRACE
)
496 printk(KERN_DEBUG
"%s: %s op(0x%x) channel(0x%x)\n",
497 hw
->name
, __func__
, (cq
->op
), (cq
->channel
));
500 case MISDN_CTRL_GETOP
:
501 cq
->op
= MISDN_CTRL_LOOP
| MISDN_CTRL_CONNECT
|
502 MISDN_CTRL_DISCONNECT
;
505 printk(KERN_WARNING
"%s: %s: unknown Op %x\n",
506 hw
->name
, __func__
, cq
->op
);
514 * device control function
517 hfc_dctrl(struct mISDNchannel
*ch
, u_int cmd
, void *arg
)
519 struct mISDNdevice
*dev
= container_of(ch
, struct mISDNdevice
, D
);
520 struct dchannel
*dch
= container_of(dev
, struct dchannel
, dev
);
521 struct hfcsusb
*hw
= dch
->hw
;
522 struct channel_req
*rq
;
525 if (dch
->debug
& DEBUG_HW
)
526 printk(KERN_DEBUG
"%s: %s: cmd:%x %p\n",
527 hw
->name
, __func__
, cmd
, arg
);
531 if ((rq
->protocol
== ISDN_P_TE_S0
) ||
532 (rq
->protocol
== ISDN_P_NT_S0
))
533 err
= open_dchannel(hw
, ch
, rq
);
535 err
= open_bchannel(hw
, rq
);
541 if (debug
& DEBUG_HW_OPEN
)
543 "%s: %s: dev(%d) close from %p (open %d)\n",
544 hw
->name
, __func__
, hw
->dch
.dev
.id
,
545 __builtin_return_address(0), hw
->open
);
547 hfcsusb_stop_endpoint(hw
, HFC_CHAN_D
);
548 if (hw
->fifos
[HFCUSB_PCM_RX
].pipe
)
549 hfcsusb_stop_endpoint(hw
, HFC_CHAN_E
);
550 handle_led(hw
, LED_POWER_ON
);
552 module_put(THIS_MODULE
);
554 case CONTROL_CHANNEL
:
555 err
= channel_ctrl(hw
, arg
);
558 if (dch
->debug
& DEBUG_HW
)
559 printk(KERN_DEBUG
"%s: %s: unknown command %x\n",
560 hw
->name
, __func__
, cmd
);
567 * S0 TE state change event handler
570 ph_state_te(struct dchannel
*dch
)
572 struct hfcsusb
*hw
= dch
->hw
;
574 if (debug
& DEBUG_HW
) {
575 if (dch
->state
<= HFC_MAX_TE_LAYER1_STATE
)
576 printk(KERN_DEBUG
"%s: %s: %s\n", hw
->name
, __func__
,
577 HFC_TE_LAYER1_STATES
[dch
->state
]);
579 printk(KERN_DEBUG
"%s: %s: TE F%d\n",
580 hw
->name
, __func__
, dch
->state
);
583 switch (dch
->state
) {
585 l1_event(dch
->l1
, HW_RESET_IND
);
588 l1_event(dch
->l1
, HW_DEACT_IND
);
592 l1_event(dch
->l1
, ANYSIGNAL
);
595 l1_event(dch
->l1
, INFO2
);
598 l1_event(dch
->l1
, INFO4_P8
);
602 handle_led(hw
, LED_S0_ON
);
604 handle_led(hw
, LED_S0_OFF
);
608 * S0 NT state change event handler
611 ph_state_nt(struct dchannel
*dch
)
613 struct hfcsusb
*hw
= dch
->hw
;
615 if (debug
& DEBUG_HW
) {
616 if (dch
->state
<= HFC_MAX_NT_LAYER1_STATE
)
617 printk(KERN_DEBUG
"%s: %s: %s\n",
619 HFC_NT_LAYER1_STATES
[dch
->state
]);
622 printk(KERN_INFO DRIVER_NAME
"%s: %s: NT G%d\n",
623 hw
->name
, __func__
, dch
->state
);
626 switch (dch
->state
) {
628 test_and_clear_bit(FLG_ACTIVE
, &dch
->Flags
);
629 test_and_clear_bit(FLG_L2_ACTIVATED
, &dch
->Flags
);
631 hw
->timers
&= ~NT_ACTIVATION_TIMER
;
632 handle_led(hw
, LED_S0_OFF
);
636 if (hw
->nt_timer
< 0) {
638 hw
->timers
&= ~NT_ACTIVATION_TIMER
;
639 hfcsusb_ph_command(dch
->hw
, HFC_L1_DEACTIVATE_NT
);
641 hw
->timers
|= NT_ACTIVATION_TIMER
;
642 hw
->nt_timer
= NT_T1_COUNT
;
643 /* allow G2 -> G3 transition */
644 write_reg(hw
, HFCUSB_STATES
, 2 | HFCUSB_NT_G2_G3
);
649 hw
->timers
&= ~NT_ACTIVATION_TIMER
;
650 test_and_set_bit(FLG_ACTIVE
, &dch
->Flags
);
651 _queue_data(&dch
->dev
.D
, PH_ACTIVATE_IND
,
652 MISDN_ID_ANY
, 0, NULL
, GFP_ATOMIC
);
653 handle_led(hw
, LED_S0_ON
);
657 hw
->timers
&= ~NT_ACTIVATION_TIMER
;
666 ph_state(struct dchannel
*dch
)
668 struct hfcsusb
*hw
= dch
->hw
;
670 if (hw
->protocol
== ISDN_P_NT_S0
)
672 else if (hw
->protocol
== ISDN_P_TE_S0
)
677 * disable/enable BChannel for desired protocoll
680 hfcsusb_setup_bch(struct bchannel
*bch
, int protocol
)
682 struct hfcsusb
*hw
= bch
->hw
;
683 __u8 conhdlc
, sctrl
, sctrl_r
;
685 if (debug
& DEBUG_HW
)
686 printk(KERN_DEBUG
"%s: %s: protocol %x-->%x B%d\n",
687 hw
->name
, __func__
, bch
->state
, protocol
,
690 /* setup val for CON_HDLC */
692 if (protocol
> ISDN_P_NONE
)
693 conhdlc
= 8; /* enable FIFO */
696 case (-1): /* used for init */
700 if (bch
->state
== ISDN_P_NONE
)
701 return 0; /* already in idle state */
702 bch
->state
= ISDN_P_NONE
;
703 clear_bit(FLG_HDLC
, &bch
->Flags
);
704 clear_bit(FLG_TRANSPARENT
, &bch
->Flags
);
708 bch
->state
= protocol
;
709 set_bit(FLG_TRANSPARENT
, &bch
->Flags
);
711 case (ISDN_P_B_HDLC
):
712 bch
->state
= protocol
;
713 set_bit(FLG_HDLC
, &bch
->Flags
);
716 if (debug
& DEBUG_HW
)
717 printk(KERN_DEBUG
"%s: %s: prot not known %x\n",
718 hw
->name
, __func__
, protocol
);
722 if (protocol
>= ISDN_P_NONE
) {
723 write_reg(hw
, HFCUSB_FIFO
, (bch
->nr
== 1) ? 0 : 2);
724 write_reg(hw
, HFCUSB_CON_HDLC
, conhdlc
);
725 write_reg(hw
, HFCUSB_INC_RES_F
, 2);
726 write_reg(hw
, HFCUSB_FIFO
, (bch
->nr
== 1) ? 1 : 3);
727 write_reg(hw
, HFCUSB_CON_HDLC
, conhdlc
);
728 write_reg(hw
, HFCUSB_INC_RES_F
, 2);
730 sctrl
= 0x40 + ((hw
->protocol
== ISDN_P_TE_S0
) ? 0x00 : 0x04);
732 if (test_bit(FLG_ACTIVE
, &hw
->bch
[0].Flags
)) {
736 if (test_bit(FLG_ACTIVE
, &hw
->bch
[1].Flags
)) {
740 write_reg(hw
, HFCUSB_SCTRL
, sctrl
);
741 write_reg(hw
, HFCUSB_SCTRL_R
, sctrl_r
);
743 if (protocol
> ISDN_P_NONE
)
744 handle_led(hw
, (bch
->nr
== 1) ? LED_B1_ON
: LED_B2_ON
);
746 handle_led(hw
, (bch
->nr
== 1) ? LED_B1_OFF
:
754 hfcsusb_ph_command(struct hfcsusb
*hw
, u_char command
)
756 if (debug
& DEBUG_HW
)
757 printk(KERN_DEBUG
"%s: %s: %x\n",
758 hw
->name
, __func__
, command
);
761 case HFC_L1_ACTIVATE_TE
:
762 /* force sending sending INFO1 */
763 write_reg(hw
, HFCUSB_STATES
, 0x14);
764 /* start l1 activation */
765 write_reg(hw
, HFCUSB_STATES
, 0x04);
768 case HFC_L1_FORCE_DEACTIVATE_TE
:
769 write_reg(hw
, HFCUSB_STATES
, 0x10);
770 write_reg(hw
, HFCUSB_STATES
, 0x03);
773 case HFC_L1_ACTIVATE_NT
:
774 if (hw
->dch
.state
== 3)
775 _queue_data(&hw
->dch
.dev
.D
, PH_ACTIVATE_IND
,
776 MISDN_ID_ANY
, 0, NULL
, GFP_ATOMIC
);
778 write_reg(hw
, HFCUSB_STATES
, HFCUSB_ACTIVATE
|
779 HFCUSB_DO_ACTION
| HFCUSB_NT_G2_G3
);
782 case HFC_L1_DEACTIVATE_NT
:
783 write_reg(hw
, HFCUSB_STATES
,
790 * Layer 1 B-channel hardware access
793 channel_bctrl(struct bchannel
*bch
, struct mISDN_ctrl_req
*cq
)
795 return mISDN_ctrl_bchannel(bch
, cq
);
798 /* collect data from incoming interrupt or isochron USB data */
800 hfcsusb_rx_frame(struct usb_fifo
*fifo
, __u8
*data
, unsigned int len
,
803 struct hfcsusb
*hw
= fifo
->hw
;
804 struct sk_buff
*rx_skb
= NULL
;
806 int fifon
= fifo
->fifonum
;
811 if (debug
& DBG_HFC_CALL_TRACE
)
812 printk(KERN_DEBUG
"%s: %s: fifo(%i) len(%i) "
813 "dch(%p) bch(%p) ech(%p)\n",
814 hw
->name
, __func__
, fifon
, len
,
815 fifo
->dch
, fifo
->bch
, fifo
->ech
);
820 if ((!!fifo
->dch
+ !!fifo
->bch
+ !!fifo
->ech
) != 1) {
821 printk(KERN_DEBUG
"%s: %s: undefined channel\n",
826 spin_lock_irqsave(&hw
->lock
, flags
);
828 rx_skb
= fifo
->dch
->rx_skb
;
829 maxlen
= fifo
->dch
->maxlen
;
833 if (test_bit(FLG_RX_OFF
, &fifo
->bch
->Flags
)) {
834 fifo
->bch
->dropcnt
+= len
;
835 spin_unlock_irqrestore(&hw
->lock
, flags
);
838 maxlen
= bchannel_get_rxbuf(fifo
->bch
, len
);
839 rx_skb
= fifo
->bch
->rx_skb
;
843 pr_warn("%s.B%d: No bufferspace for %d bytes\n",
844 hw
->name
, fifo
->bch
->nr
, len
);
845 spin_unlock_irqrestore(&hw
->lock
, flags
);
848 maxlen
= fifo
->bch
->maxlen
;
849 hdlc
= test_bit(FLG_HDLC
, &fifo
->bch
->Flags
);
852 rx_skb
= fifo
->ech
->rx_skb
;
853 maxlen
= fifo
->ech
->maxlen
;
857 if (fifo
->dch
|| fifo
->ech
) {
859 rx_skb
= mI_alloc_skb(maxlen
, GFP_ATOMIC
);
862 fifo
->dch
->rx_skb
= rx_skb
;
864 fifo
->ech
->rx_skb
= rx_skb
;
867 printk(KERN_DEBUG
"%s: %s: No mem for rx_skb\n",
869 spin_unlock_irqrestore(&hw
->lock
, flags
);
873 /* D/E-Channel SKB range check */
874 if ((rx_skb
->len
+ len
) >= MAX_DFRAME_LEN_L1
) {
875 printk(KERN_DEBUG
"%s: %s: sbk mem exceeded "
876 "for fifo(%d) HFCUSB_D_RX\n",
877 hw
->name
, __func__
, fifon
);
879 spin_unlock_irqrestore(&hw
->lock
, flags
);
884 skb_put_data(rx_skb
, data
, len
);
887 /* we have a complete hdlc packet */
889 if ((rx_skb
->len
> 3) &&
890 (!(rx_skb
->data
[rx_skb
->len
- 1]))) {
891 if (debug
& DBG_HFC_FIFO_VERBOSE
) {
892 printk(KERN_DEBUG
"%s: %s: fifon(%i)"
894 hw
->name
, __func__
, fifon
,
897 while (i
< rx_skb
->len
)
903 /* remove CRC & status */
904 skb_trim(rx_skb
, rx_skb
->len
- 3);
907 recv_Dchannel(fifo
->dch
);
909 recv_Bchannel(fifo
->bch
, MISDN_ID_ANY
,
912 recv_Echannel(fifo
->ech
,
915 if (debug
& DBG_HFC_FIFO_VERBOSE
) {
917 "%s: CRC or minlen ERROR fifon(%i) "
919 hw
->name
, fifon
, rx_skb
->len
);
921 while (i
< rx_skb
->len
)
930 /* deliver transparent data to layer2 */
931 recv_Bchannel(fifo
->bch
, MISDN_ID_ANY
, false);
933 spin_unlock_irqrestore(&hw
->lock
, flags
);
937 fill_isoc_urb(struct urb
*urb
, struct usb_device
*dev
, unsigned int pipe
,
938 void *buf
, int num_packets
, int packet_size
, int interval
,
939 usb_complete_t complete
, void *context
)
943 usb_fill_bulk_urb(urb
, dev
, pipe
, buf
, packet_size
* num_packets
,
946 urb
->number_of_packets
= num_packets
;
947 urb
->transfer_flags
= URB_ISO_ASAP
;
948 urb
->actual_length
= 0;
949 urb
->interval
= interval
;
951 for (k
= 0; k
< num_packets
; k
++) {
952 urb
->iso_frame_desc
[k
].offset
= packet_size
* k
;
953 urb
->iso_frame_desc
[k
].length
= packet_size
;
954 urb
->iso_frame_desc
[k
].actual_length
= 0;
958 /* receive completion routine for all ISO tx fifos */
960 rx_iso_complete(struct urb
*urb
)
962 struct iso_urb
*context_iso_urb
= (struct iso_urb
*) urb
->context
;
963 struct usb_fifo
*fifo
= context_iso_urb
->owner_fifo
;
964 struct hfcsusb
*hw
= fifo
->hw
;
965 int k
, len
, errcode
, offset
, num_isoc_packets
, fifon
, maxlen
,
966 status
, iso_status
, i
;
972 fifon
= fifo
->fifonum
;
973 status
= urb
->status
;
975 spin_lock_irqsave(&hw
->lock
, flags
);
976 if (fifo
->stop_gracefull
) {
977 fifo
->stop_gracefull
= 0;
979 spin_unlock_irqrestore(&hw
->lock
, flags
);
982 spin_unlock_irqrestore(&hw
->lock
, flags
);
985 * ISO transfer only partially completed,
986 * look at individual frame status for details
988 if (status
== -EXDEV
) {
989 if (debug
& DEBUG_HW
)
990 printk(KERN_DEBUG
"%s: %s: with -EXDEV "
991 "urb->status %d, fifonum %d\n",
992 hw
->name
, __func__
, status
, fifon
);
994 /* clear status, so go on with ISO transfers */
999 if (fifo
->active
&& !status
) {
1000 num_isoc_packets
= iso_packets
[fifon
];
1001 maxlen
= fifo
->usb_packet_maxlen
;
1003 for (k
= 0; k
< num_isoc_packets
; ++k
) {
1004 len
= urb
->iso_frame_desc
[k
].actual_length
;
1005 offset
= urb
->iso_frame_desc
[k
].offset
;
1006 buf
= context_iso_urb
->buffer
+ offset
;
1007 iso_status
= urb
->iso_frame_desc
[k
].status
;
1009 if (iso_status
&& (debug
& DBG_HFC_FIFO_VERBOSE
)) {
1010 printk(KERN_DEBUG
"%s: %s: "
1011 "ISO packet %i, status: %i\n",
1012 hw
->name
, __func__
, k
, iso_status
);
1015 /* USB data log for every D ISO in */
1016 if ((fifon
== HFCUSB_D_RX
) &&
1017 (debug
& DBG_HFC_USB_VERBOSE
)) {
1019 "%s: %s: %d (%d/%d) len(%d) ",
1020 hw
->name
, __func__
, urb
->start_frame
,
1021 k
, num_isoc_packets
- 1,
1023 for (i
= 0; i
< len
; i
++)
1024 printk("%x ", buf
[i
]);
1029 if (fifo
->last_urblen
!= maxlen
) {
1031 * save fifo fill-level threshold bits
1032 * to use them later in TX ISO URB
1035 hw
->threshold_mask
= buf
[1];
1037 if (fifon
== HFCUSB_D_RX
)
1038 s0_state
= (buf
[0] >> 4);
1040 eof
[fifon
] = buf
[0] & 1;
1042 hfcsusb_rx_frame(fifo
, buf
+ 2,
1043 len
- 2, (len
< maxlen
)
1046 hfcsusb_rx_frame(fifo
, buf
, len
,
1049 fifo
->last_urblen
= len
;
1053 /* signal S0 layer1 state change */
1054 if ((s0_state
) && (hw
->initdone
) &&
1055 (s0_state
!= hw
->dch
.state
)) {
1056 hw
->dch
.state
= s0_state
;
1057 schedule_event(&hw
->dch
, FLG_PHCHANGE
);
1060 fill_isoc_urb(urb
, fifo
->hw
->dev
, fifo
->pipe
,
1061 context_iso_urb
->buffer
, num_isoc_packets
,
1062 fifo
->usb_packet_maxlen
, fifo
->intervall
,
1063 (usb_complete_t
)rx_iso_complete
, urb
->context
);
1064 errcode
= usb_submit_urb(urb
, GFP_ATOMIC
);
1066 if (debug
& DEBUG_HW
)
1067 printk(KERN_DEBUG
"%s: %s: error submitting "
1069 hw
->name
, __func__
, errcode
);
1072 if (status
&& (debug
& DBG_HFC_URB_INFO
))
1073 printk(KERN_DEBUG
"%s: %s: rx_iso_complete : "
1074 "urb->status %d, fifonum %d\n",
1075 hw
->name
, __func__
, status
, fifon
);
1079 /* receive completion routine for all interrupt rx fifos */
1081 rx_int_complete(struct urb
*urb
)
1084 __u8
*buf
, maxlen
, fifon
;
1085 struct usb_fifo
*fifo
= (struct usb_fifo
*) urb
->context
;
1086 struct hfcsusb
*hw
= fifo
->hw
;
1088 unsigned long flags
;
1090 spin_lock_irqsave(&hw
->lock
, flags
);
1091 if (fifo
->stop_gracefull
) {
1092 fifo
->stop_gracefull
= 0;
1094 spin_unlock_irqrestore(&hw
->lock
, flags
);
1097 spin_unlock_irqrestore(&hw
->lock
, flags
);
1099 fifon
= fifo
->fifonum
;
1100 if ((!fifo
->active
) || (urb
->status
)) {
1101 if (debug
& DBG_HFC_URB_ERROR
)
1103 "%s: %s: RX-Fifo %i is going down (%i)\n",
1104 hw
->name
, __func__
, fifon
, urb
->status
);
1106 fifo
->urb
->interval
= 0; /* cancel automatic rescheduling */
1109 len
= urb
->actual_length
;
1111 maxlen
= fifo
->usb_packet_maxlen
;
1113 /* USB data log for every D INT in */
1114 if ((fifon
== HFCUSB_D_RX
) && (debug
& DBG_HFC_USB_VERBOSE
)) {
1115 printk(KERN_DEBUG
"%s: %s: D RX INT len(%d) ",
1116 hw
->name
, __func__
, len
);
1117 for (i
= 0; i
< len
; i
++)
1118 printk("%02x ", buf
[i
]);
1122 if (fifo
->last_urblen
!= fifo
->usb_packet_maxlen
) {
1123 /* the threshold mask is in the 2nd status byte */
1124 hw
->threshold_mask
= buf
[1];
1126 /* signal S0 layer1 state change */
1127 if (hw
->initdone
&& ((buf
[0] >> 4) != hw
->dch
.state
)) {
1128 hw
->dch
.state
= (buf
[0] >> 4);
1129 schedule_event(&hw
->dch
, FLG_PHCHANGE
);
1132 eof
[fifon
] = buf
[0] & 1;
1133 /* if we have more than the 2 status bytes -> collect data */
1135 hfcsusb_rx_frame(fifo
, buf
+ 2,
1136 urb
->actual_length
- 2,
1137 (len
< maxlen
) ? eof
[fifon
] : 0);
1139 hfcsusb_rx_frame(fifo
, buf
, urb
->actual_length
,
1140 (len
< maxlen
) ? eof
[fifon
] : 0);
1142 fifo
->last_urblen
= urb
->actual_length
;
1144 status
= usb_submit_urb(urb
, GFP_ATOMIC
);
1146 if (debug
& DEBUG_HW
)
1147 printk(KERN_DEBUG
"%s: %s: error resubmitting USB\n",
1148 hw
->name
, __func__
);
1152 /* transmit completion routine for all ISO tx fifos */
1154 tx_iso_complete(struct urb
*urb
)
1156 struct iso_urb
*context_iso_urb
= (struct iso_urb
*) urb
->context
;
1157 struct usb_fifo
*fifo
= context_iso_urb
->owner_fifo
;
1158 struct hfcsusb
*hw
= fifo
->hw
;
1159 struct sk_buff
*tx_skb
;
1160 int k
, tx_offset
, num_isoc_packets
, sink
, remain
, current_len
,
1163 int frame_complete
, fifon
, status
, fillempty
= 0;
1165 unsigned long flags
;
1167 spin_lock_irqsave(&hw
->lock
, flags
);
1168 if (fifo
->stop_gracefull
) {
1169 fifo
->stop_gracefull
= 0;
1171 spin_unlock_irqrestore(&hw
->lock
, flags
);
1176 tx_skb
= fifo
->dch
->tx_skb
;
1177 tx_idx
= &fifo
->dch
->tx_idx
;
1179 } else if (fifo
->bch
) {
1180 tx_skb
= fifo
->bch
->tx_skb
;
1181 tx_idx
= &fifo
->bch
->tx_idx
;
1182 hdlc
= test_bit(FLG_HDLC
, &fifo
->bch
->Flags
);
1183 if (!tx_skb
&& !hdlc
&&
1184 test_bit(FLG_FILLEMPTY
, &fifo
->bch
->Flags
))
1187 printk(KERN_DEBUG
"%s: %s: neither BCH nor DCH\n",
1188 hw
->name
, __func__
);
1189 spin_unlock_irqrestore(&hw
->lock
, flags
);
1193 fifon
= fifo
->fifonum
;
1194 status
= urb
->status
;
1199 * ISO transfer only partially completed,
1200 * look at individual frame status for details
1202 if (status
== -EXDEV
) {
1203 if (debug
& DBG_HFC_URB_ERROR
)
1204 printk(KERN_DEBUG
"%s: %s: "
1205 "-EXDEV (%i) fifon (%d)\n",
1206 hw
->name
, __func__
, status
, fifon
);
1208 /* clear status, so go on with ISO transfers */
1212 if (fifo
->active
&& !status
) {
1213 /* is FifoFull-threshold set for our channel? */
1214 threshbit
= (hw
->threshold_mask
& (1 << fifon
));
1215 num_isoc_packets
= iso_packets
[fifon
];
1217 /* predict dataflow to avoid fifo overflow */
1218 if (fifon
>= HFCUSB_D_TX
)
1219 sink
= (threshbit
) ? SINK_DMIN
: SINK_DMAX
;
1221 sink
= (threshbit
) ? SINK_MIN
: SINK_MAX
;
1222 fill_isoc_urb(urb
, fifo
->hw
->dev
, fifo
->pipe
,
1223 context_iso_urb
->buffer
, num_isoc_packets
,
1224 fifo
->usb_packet_maxlen
, fifo
->intervall
,
1225 (usb_complete_t
)tx_iso_complete
, urb
->context
);
1226 memset(context_iso_urb
->buffer
, 0,
1227 sizeof(context_iso_urb
->buffer
));
1230 for (k
= 0; k
< num_isoc_packets
; ++k
) {
1231 /* analyze tx success of previous ISO packets */
1232 if (debug
& DBG_HFC_URB_ERROR
) {
1233 errcode
= urb
->iso_frame_desc
[k
].status
;
1235 printk(KERN_DEBUG
"%s: %s: "
1236 "ISO packet %i, status: %i\n",
1237 hw
->name
, __func__
, k
, errcode
);
1241 /* Generate next ISO Packets */
1243 remain
= tx_skb
->len
- *tx_idx
;
1245 remain
= 15; /* > not complete */
1250 fifo
->bit_line
-= sink
;
1251 current_len
= (0 - fifo
->bit_line
) / 8;
1252 if (current_len
> 14)
1254 if (current_len
< 0)
1256 if (remain
< current_len
)
1257 current_len
= remain
;
1259 /* how much bit do we put on the line? */
1260 fifo
->bit_line
+= current_len
* 8;
1262 context_iso_urb
->buffer
[tx_offset
] = 0;
1263 if (current_len
== remain
) {
1265 /* signal frame completion */
1267 buffer
[tx_offset
] = 1;
1268 /* add 2 byte flags and 16bit
1269 * CRC at end of ISDN frame */
1270 fifo
->bit_line
+= 32;
1275 /* copy tx data to iso-urb buffer */
1276 p
= context_iso_urb
->buffer
+ tx_offset
+ 1;
1278 memset(p
, fifo
->bch
->fill
[0],
1281 memcpy(p
, (tx_skb
->data
+ *tx_idx
),
1283 *tx_idx
+= current_len
;
1285 urb
->iso_frame_desc
[k
].offset
= tx_offset
;
1286 urb
->iso_frame_desc
[k
].length
= current_len
+ 1;
1288 /* USB data log for every D ISO out */
1289 if ((fifon
== HFCUSB_D_RX
) && !fillempty
&&
1290 (debug
& DBG_HFC_USB_VERBOSE
)) {
1292 "%s: %s (%d/%d) offs(%d) len(%d) ",
1294 k
, num_isoc_packets
- 1,
1295 urb
->iso_frame_desc
[k
].offset
,
1296 urb
->iso_frame_desc
[k
].length
);
1298 for (i
= urb
->iso_frame_desc
[k
].offset
;
1299 i
< (urb
->iso_frame_desc
[k
].offset
1300 + urb
->iso_frame_desc
[k
].length
);
1303 context_iso_urb
->buffer
[i
]);
1305 printk(" skb->len(%i) tx-idx(%d)\n",
1306 tx_skb
->len
, *tx_idx
);
1309 tx_offset
+= (current_len
+ 1);
1311 urb
->iso_frame_desc
[k
].offset
= tx_offset
++;
1312 urb
->iso_frame_desc
[k
].length
= 1;
1313 /* we lower data margin every msec */
1314 fifo
->bit_line
-= sink
;
1315 if (fifo
->bit_line
< BITLINE_INF
)
1316 fifo
->bit_line
= BITLINE_INF
;
1319 if (frame_complete
) {
1322 if (debug
& DBG_HFC_FIFO_VERBOSE
) {
1323 printk(KERN_DEBUG
"%s: %s: "
1324 "fifon(%i) new TX len(%i): ",
1326 fifon
, tx_skb
->len
);
1328 while (i
< tx_skb
->len
)
1334 dev_kfree_skb(tx_skb
);
1336 if (fifo
->dch
&& get_next_dframe(fifo
->dch
))
1337 tx_skb
= fifo
->dch
->tx_skb
;
1338 else if (fifo
->bch
&&
1339 get_next_bframe(fifo
->bch
))
1340 tx_skb
= fifo
->bch
->tx_skb
;
1343 errcode
= usb_submit_urb(urb
, GFP_ATOMIC
);
1345 if (debug
& DEBUG_HW
)
1347 "%s: %s: error submitting ISO URB: %d \n",
1348 hw
->name
, __func__
, errcode
);
1352 * abuse DChannel tx iso completion to trigger NT mode state
1353 * changes tx_iso_complete is assumed to be called every
1354 * fifo->intervall (ms)
1356 if ((fifon
== HFCUSB_D_TX
) && (hw
->protocol
== ISDN_P_NT_S0
)
1357 && (hw
->timers
& NT_ACTIVATION_TIMER
)) {
1358 if ((--hw
->nt_timer
) < 0)
1359 schedule_event(&hw
->dch
, FLG_PHCHANGE
);
1363 if (status
&& (debug
& DBG_HFC_URB_ERROR
))
1364 printk(KERN_DEBUG
"%s: %s: urb->status %s (%i)"
1367 symbolic(urb_errlist
, status
), status
, fifon
);
1369 spin_unlock_irqrestore(&hw
->lock
, flags
);
1373 * allocs urbs and start isoc transfer with two pending urbs to avoid
1374 * gaps in the transfer chain
1377 start_isoc_chain(struct usb_fifo
*fifo
, int num_packets_per_urb
,
1378 usb_complete_t complete
, int packet_size
)
1380 struct hfcsusb
*hw
= fifo
->hw
;
1384 printk(KERN_DEBUG
"%s: %s: fifo %i\n",
1385 hw
->name
, __func__
, fifo
->fifonum
);
1387 /* allocate Memory for Iso out Urbs */
1388 for (i
= 0; i
< 2; i
++) {
1389 if (!(fifo
->iso
[i
].urb
)) {
1391 usb_alloc_urb(num_packets_per_urb
, GFP_KERNEL
);
1392 if (!(fifo
->iso
[i
].urb
)) {
1394 "%s: %s: alloc urb for fifo %i failed",
1395 hw
->name
, __func__
, fifo
->fifonum
);
1398 fifo
->iso
[i
].owner_fifo
= (struct usb_fifo
*) fifo
;
1399 fifo
->iso
[i
].indx
= i
;
1401 /* Init the first iso */
1402 if (ISO_BUFFER_SIZE
>=
1403 (fifo
->usb_packet_maxlen
*
1404 num_packets_per_urb
)) {
1405 fill_isoc_urb(fifo
->iso
[i
].urb
,
1406 fifo
->hw
->dev
, fifo
->pipe
,
1407 fifo
->iso
[i
].buffer
,
1408 num_packets_per_urb
,
1409 fifo
->usb_packet_maxlen
,
1410 fifo
->intervall
, complete
,
1412 memset(fifo
->iso
[i
].buffer
, 0,
1413 sizeof(fifo
->iso
[i
].buffer
));
1415 for (k
= 0; k
< num_packets_per_urb
; k
++) {
1417 iso_frame_desc
[k
].offset
=
1420 iso_frame_desc
[k
].length
=
1425 "%s: %s: ISO Buffer size to small!\n",
1426 hw
->name
, __func__
);
1429 fifo
->bit_line
= BITLINE_INF
;
1431 errcode
= usb_submit_urb(fifo
->iso
[i
].urb
, GFP_KERNEL
);
1432 fifo
->active
= (errcode
>= 0) ? 1 : 0;
1433 fifo
->stop_gracefull
= 0;
1435 printk(KERN_DEBUG
"%s: %s: %s URB nr:%d\n",
1437 symbolic(urb_errlist
, errcode
), i
);
1440 return fifo
->active
;
1444 stop_iso_gracefull(struct usb_fifo
*fifo
)
1446 struct hfcsusb
*hw
= fifo
->hw
;
1450 for (i
= 0; i
< 2; i
++) {
1451 spin_lock_irqsave(&hw
->lock
, flags
);
1453 printk(KERN_DEBUG
"%s: %s for fifo %i.%i\n",
1454 hw
->name
, __func__
, fifo
->fifonum
, i
);
1455 fifo
->stop_gracefull
= 1;
1456 spin_unlock_irqrestore(&hw
->lock
, flags
);
1459 for (i
= 0; i
< 2; i
++) {
1461 while (fifo
->stop_gracefull
&& timeout
--)
1462 schedule_timeout_interruptible((HZ
/ 1000) * 16);
1463 if (debug
&& fifo
->stop_gracefull
)
1464 printk(KERN_DEBUG
"%s: ERROR %s for fifo %i.%i\n",
1465 hw
->name
, __func__
, fifo
->fifonum
, i
);
1470 stop_int_gracefull(struct usb_fifo
*fifo
)
1472 struct hfcsusb
*hw
= fifo
->hw
;
1476 spin_lock_irqsave(&hw
->lock
, flags
);
1478 printk(KERN_DEBUG
"%s: %s for fifo %i\n",
1479 hw
->name
, __func__
, fifo
->fifonum
);
1480 fifo
->stop_gracefull
= 1;
1481 spin_unlock_irqrestore(&hw
->lock
, flags
);
1484 while (fifo
->stop_gracefull
&& timeout
--)
1485 schedule_timeout_interruptible((HZ
/ 1000) * 3);
1486 if (debug
&& fifo
->stop_gracefull
)
1487 printk(KERN_DEBUG
"%s: ERROR %s for fifo %i\n",
1488 hw
->name
, __func__
, fifo
->fifonum
);
1491 /* start the interrupt transfer for the given fifo */
1493 start_int_fifo(struct usb_fifo
*fifo
)
1495 struct hfcsusb
*hw
= fifo
->hw
;
1499 printk(KERN_DEBUG
"%s: %s: INT IN fifo:%d\n",
1500 hw
->name
, __func__
, fifo
->fifonum
);
1503 fifo
->urb
= usb_alloc_urb(0, GFP_KERNEL
);
1507 usb_fill_int_urb(fifo
->urb
, fifo
->hw
->dev
, fifo
->pipe
,
1508 fifo
->buffer
, fifo
->usb_packet_maxlen
,
1509 (usb_complete_t
)rx_int_complete
, fifo
, fifo
->intervall
);
1511 fifo
->stop_gracefull
= 0;
1512 errcode
= usb_submit_urb(fifo
->urb
, GFP_KERNEL
);
1514 printk(KERN_DEBUG
"%s: %s: submit URB: status:%i\n",
1515 hw
->name
, __func__
, errcode
);
1521 setPortMode(struct hfcsusb
*hw
)
1523 if (debug
& DEBUG_HW
)
1524 printk(KERN_DEBUG
"%s: %s %s\n", hw
->name
, __func__
,
1525 (hw
->protocol
== ISDN_P_TE_S0
) ? "TE" : "NT");
1527 if (hw
->protocol
== ISDN_P_TE_S0
) {
1528 write_reg(hw
, HFCUSB_SCTRL
, 0x40);
1529 write_reg(hw
, HFCUSB_SCTRL_E
, 0x00);
1530 write_reg(hw
, HFCUSB_CLKDEL
, CLKDEL_TE
);
1531 write_reg(hw
, HFCUSB_STATES
, 3 | 0x10);
1532 write_reg(hw
, HFCUSB_STATES
, 3);
1534 write_reg(hw
, HFCUSB_SCTRL
, 0x44);
1535 write_reg(hw
, HFCUSB_SCTRL_E
, 0x09);
1536 write_reg(hw
, HFCUSB_CLKDEL
, CLKDEL_NT
);
1537 write_reg(hw
, HFCUSB_STATES
, 1 | 0x10);
1538 write_reg(hw
, HFCUSB_STATES
, 1);
1543 reset_hfcsusb(struct hfcsusb
*hw
)
1545 struct usb_fifo
*fifo
;
1548 if (debug
& DEBUG_HW
)
1549 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
1552 write_reg(hw
, HFCUSB_CIRM
, 8);
1554 /* aux = output, reset off */
1555 write_reg(hw
, HFCUSB_CIRM
, 0x10);
1557 /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */
1558 write_reg(hw
, HFCUSB_USB_SIZE
, (hw
->packet_size
/ 8) |
1559 ((hw
->packet_size
/ 8) << 4));
1561 /* set USB_SIZE_I to match the the wMaxPacketSize for ISO transfers */
1562 write_reg(hw
, HFCUSB_USB_SIZE_I
, hw
->iso_packet_size
);
1564 /* enable PCM/GCI master mode */
1565 write_reg(hw
, HFCUSB_MST_MODE1
, 0); /* set default values */
1566 write_reg(hw
, HFCUSB_MST_MODE0
, 1); /* enable master mode */
1568 /* init the fifos */
1569 write_reg(hw
, HFCUSB_F_THRES
,
1570 (HFCUSB_TX_THRESHOLD
/ 8) | ((HFCUSB_RX_THRESHOLD
/ 8) << 4));
1573 for (i
= 0; i
< HFCUSB_NUM_FIFOS
; i
++) {
1574 write_reg(hw
, HFCUSB_FIFO
, i
); /* select the desired fifo */
1576 (i
<= HFCUSB_B2_RX
) ? MAX_BCH_SIZE
: MAX_DFRAME_LEN
;
1577 fifo
[i
].last_urblen
= 0;
1579 /* set 2 bit for D- & E-channel */
1580 write_reg(hw
, HFCUSB_HDLC_PAR
, ((i
<= HFCUSB_B2_RX
) ? 0 : 2));
1582 /* enable all fifos */
1583 if (i
== HFCUSB_D_TX
)
1584 write_reg(hw
, HFCUSB_CON_HDLC
,
1585 (hw
->protocol
== ISDN_P_NT_S0
) ? 0x08 : 0x09);
1587 write_reg(hw
, HFCUSB_CON_HDLC
, 0x08);
1588 write_reg(hw
, HFCUSB_INC_RES_F
, 2); /* reset the fifo */
1591 write_reg(hw
, HFCUSB_SCTRL_R
, 0); /* disable both B receivers */
1592 handle_led(hw
, LED_POWER_ON
);
1595 /* start USB data pipes dependand on device's endpoint configuration */
1597 hfcsusb_start_endpoint(struct hfcsusb
*hw
, int channel
)
1599 /* quick check if endpoint already running */
1600 if ((channel
== HFC_CHAN_D
) && (hw
->fifos
[HFCUSB_D_RX
].active
))
1602 if ((channel
== HFC_CHAN_B1
) && (hw
->fifos
[HFCUSB_B1_RX
].active
))
1604 if ((channel
== HFC_CHAN_B2
) && (hw
->fifos
[HFCUSB_B2_RX
].active
))
1606 if ((channel
== HFC_CHAN_E
) && (hw
->fifos
[HFCUSB_PCM_RX
].active
))
1609 /* start rx endpoints using USB INT IN method */
1610 if (hw
->cfg_used
== CNF_3INT3ISO
|| hw
->cfg_used
== CNF_4INT3ISO
)
1611 start_int_fifo(hw
->fifos
+ channel
* 2 + 1);
1613 /* start rx endpoints using USB ISO IN method */
1614 if (hw
->cfg_used
== CNF_3ISO3ISO
|| hw
->cfg_used
== CNF_4ISO3ISO
) {
1617 start_isoc_chain(hw
->fifos
+ HFCUSB_D_RX
,
1619 (usb_complete_t
)rx_iso_complete
,
1623 start_isoc_chain(hw
->fifos
+ HFCUSB_PCM_RX
,
1625 (usb_complete_t
)rx_iso_complete
,
1629 start_isoc_chain(hw
->fifos
+ HFCUSB_B1_RX
,
1631 (usb_complete_t
)rx_iso_complete
,
1635 start_isoc_chain(hw
->fifos
+ HFCUSB_B2_RX
,
1637 (usb_complete_t
)rx_iso_complete
,
1643 /* start tx endpoints using USB ISO OUT method */
1646 start_isoc_chain(hw
->fifos
+ HFCUSB_D_TX
,
1648 (usb_complete_t
)tx_iso_complete
, 1);
1651 start_isoc_chain(hw
->fifos
+ HFCUSB_B1_TX
,
1653 (usb_complete_t
)tx_iso_complete
, 1);
1656 start_isoc_chain(hw
->fifos
+ HFCUSB_B2_TX
,
1658 (usb_complete_t
)tx_iso_complete
, 1);
1663 /* stop USB data pipes dependand on device's endpoint configuration */
1665 hfcsusb_stop_endpoint(struct hfcsusb
*hw
, int channel
)
1667 /* quick check if endpoint currently running */
1668 if ((channel
== HFC_CHAN_D
) && (!hw
->fifos
[HFCUSB_D_RX
].active
))
1670 if ((channel
== HFC_CHAN_B1
) && (!hw
->fifos
[HFCUSB_B1_RX
].active
))
1672 if ((channel
== HFC_CHAN_B2
) && (!hw
->fifos
[HFCUSB_B2_RX
].active
))
1674 if ((channel
== HFC_CHAN_E
) && (!hw
->fifos
[HFCUSB_PCM_RX
].active
))
1677 /* rx endpoints using USB INT IN method */
1678 if (hw
->cfg_used
== CNF_3INT3ISO
|| hw
->cfg_used
== CNF_4INT3ISO
)
1679 stop_int_gracefull(hw
->fifos
+ channel
* 2 + 1);
1681 /* rx endpoints using USB ISO IN method */
1682 if (hw
->cfg_used
== CNF_3ISO3ISO
|| hw
->cfg_used
== CNF_4ISO3ISO
)
1683 stop_iso_gracefull(hw
->fifos
+ channel
* 2 + 1);
1685 /* tx endpoints using USB ISO OUT method */
1686 if (channel
!= HFC_CHAN_E
)
1687 stop_iso_gracefull(hw
->fifos
+ channel
* 2);
1691 /* Hardware Initialization */
1693 setup_hfcsusb(struct hfcsusb
*hw
)
1695 void *dmabuf
= kmalloc(sizeof(u_char
), GFP_KERNEL
);
1699 if (debug
& DBG_HFC_CALL_TRACE
)
1700 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
1705 ret
= read_reg_atomic(hw
, HFCUSB_CHIP_ID
, dmabuf
);
1707 memcpy(&b
, dmabuf
, sizeof(u_char
));
1710 /* check the chip id */
1712 printk(KERN_DEBUG
"%s: %s: cannot read chip id\n",
1713 hw
->name
, __func__
);
1716 if (b
!= HFCUSB_CHIPID
) {
1717 printk(KERN_DEBUG
"%s: %s: Invalid chip id 0x%02x\n",
1718 hw
->name
, __func__
, b
);
1722 /* first set the needed config, interface and alternate */
1723 (void) usb_set_interface(hw
->dev
, hw
->if_used
, hw
->alt_used
);
1727 /* init the background machinery for control requests */
1728 hw
->ctrl_read
.bRequestType
= 0xc0;
1729 hw
->ctrl_read
.bRequest
= 1;
1730 hw
->ctrl_read
.wLength
= cpu_to_le16(1);
1731 hw
->ctrl_write
.bRequestType
= 0x40;
1732 hw
->ctrl_write
.bRequest
= 0;
1733 hw
->ctrl_write
.wLength
= 0;
1734 usb_fill_control_urb(hw
->ctrl_urb
, hw
->dev
, hw
->ctrl_out_pipe
,
1735 (u_char
*)&hw
->ctrl_write
, NULL
, 0,
1736 (usb_complete_t
)ctrl_complete
, hw
);
1743 release_hw(struct hfcsusb
*hw
)
1745 if (debug
& DBG_HFC_CALL_TRACE
)
1746 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
1749 * stop all endpoints gracefully
1750 * TODO: mISDN_core should generate CLOSE_CHANNEL
1751 * signals after calling mISDN_unregister_device()
1753 hfcsusb_stop_endpoint(hw
, HFC_CHAN_D
);
1754 hfcsusb_stop_endpoint(hw
, HFC_CHAN_B1
);
1755 hfcsusb_stop_endpoint(hw
, HFC_CHAN_B2
);
1756 if (hw
->fifos
[HFCUSB_PCM_RX
].pipe
)
1757 hfcsusb_stop_endpoint(hw
, HFC_CHAN_E
);
1758 if (hw
->protocol
== ISDN_P_TE_S0
)
1759 l1_event(hw
->dch
.l1
, CLOSE_CHANNEL
);
1761 mISDN_unregister_device(&hw
->dch
.dev
);
1762 mISDN_freebchannel(&hw
->bch
[1]);
1763 mISDN_freebchannel(&hw
->bch
[0]);
1764 mISDN_freedchannel(&hw
->dch
);
1767 usb_kill_urb(hw
->ctrl_urb
);
1768 usb_free_urb(hw
->ctrl_urb
);
1769 hw
->ctrl_urb
= NULL
;
1773 usb_set_intfdata(hw
->intf
, NULL
);
1774 list_del(&hw
->list
);
1780 deactivate_bchannel(struct bchannel
*bch
)
1782 struct hfcsusb
*hw
= bch
->hw
;
1785 if (bch
->debug
& DEBUG_HW
)
1786 printk(KERN_DEBUG
"%s: %s: bch->nr(%i)\n",
1787 hw
->name
, __func__
, bch
->nr
);
1789 spin_lock_irqsave(&hw
->lock
, flags
);
1790 mISDN_clear_bchannel(bch
);
1791 spin_unlock_irqrestore(&hw
->lock
, flags
);
1792 hfcsusb_setup_bch(bch
, ISDN_P_NONE
);
1793 hfcsusb_stop_endpoint(hw
, bch
->nr
- 1);
1797 * Layer 1 B-channel hardware access
1800 hfc_bctrl(struct mISDNchannel
*ch
, u_int cmd
, void *arg
)
1802 struct bchannel
*bch
= container_of(ch
, struct bchannel
, ch
);
1805 if (bch
->debug
& DEBUG_HW
)
1806 printk(KERN_DEBUG
"%s: cmd:%x %p\n", __func__
, cmd
, arg
);
1810 case HW_TESTRX_HDLC
:
1816 test_and_clear_bit(FLG_OPEN
, &bch
->Flags
);
1817 deactivate_bchannel(bch
);
1818 ch
->protocol
= ISDN_P_NONE
;
1820 module_put(THIS_MODULE
);
1823 case CONTROL_CHANNEL
:
1824 ret
= channel_bctrl(bch
, arg
);
1827 printk(KERN_WARNING
"%s: unknown prim(%x)\n",
1834 setup_instance(struct hfcsusb
*hw
, struct device
*parent
)
1839 if (debug
& DBG_HFC_CALL_TRACE
)
1840 printk(KERN_DEBUG
"%s: %s\n", hw
->name
, __func__
);
1842 spin_lock_init(&hw
->ctrl_lock
);
1843 spin_lock_init(&hw
->lock
);
1845 mISDN_initdchannel(&hw
->dch
, MAX_DFRAME_LEN_L1
, ph_state
);
1846 hw
->dch
.debug
= debug
& 0xFFFF;
1848 hw
->dch
.dev
.Dprotocols
= (1 << ISDN_P_TE_S0
) | (1 << ISDN_P_NT_S0
);
1849 hw
->dch
.dev
.D
.send
= hfcusb_l2l1D
;
1850 hw
->dch
.dev
.D
.ctrl
= hfc_dctrl
;
1852 /* enable E-Channel logging */
1853 if (hw
->fifos
[HFCUSB_PCM_RX
].pipe
)
1854 mISDN_initdchannel(&hw
->ech
, MAX_DFRAME_LEN_L1
, NULL
);
1856 hw
->dch
.dev
.Bprotocols
= (1 << (ISDN_P_B_RAW
& ISDN_P_B_MASK
)) |
1857 (1 << (ISDN_P_B_HDLC
& ISDN_P_B_MASK
));
1858 hw
->dch
.dev
.nrbchan
= 2;
1859 for (i
= 0; i
< 2; i
++) {
1860 hw
->bch
[i
].nr
= i
+ 1;
1861 set_channelmap(i
+ 1, hw
->dch
.dev
.channelmap
);
1862 hw
->bch
[i
].debug
= debug
;
1863 mISDN_initbchannel(&hw
->bch
[i
], MAX_DATA_MEM
, poll
>> 1);
1865 hw
->bch
[i
].ch
.send
= hfcusb_l2l1B
;
1866 hw
->bch
[i
].ch
.ctrl
= hfc_bctrl
;
1867 hw
->bch
[i
].ch
.nr
= i
+ 1;
1868 list_add(&hw
->bch
[i
].ch
.list
, &hw
->dch
.dev
.bchannels
);
1871 hw
->fifos
[HFCUSB_B1_TX
].bch
= &hw
->bch
[0];
1872 hw
->fifos
[HFCUSB_B1_RX
].bch
= &hw
->bch
[0];
1873 hw
->fifos
[HFCUSB_B2_TX
].bch
= &hw
->bch
[1];
1874 hw
->fifos
[HFCUSB_B2_RX
].bch
= &hw
->bch
[1];
1875 hw
->fifos
[HFCUSB_D_TX
].dch
= &hw
->dch
;
1876 hw
->fifos
[HFCUSB_D_RX
].dch
= &hw
->dch
;
1877 hw
->fifos
[HFCUSB_PCM_RX
].ech
= &hw
->ech
;
1878 hw
->fifos
[HFCUSB_PCM_TX
].ech
= &hw
->ech
;
1880 err
= setup_hfcsusb(hw
);
1884 snprintf(hw
->name
, MISDN_MAX_IDLEN
- 1, "%s.%d", DRIVER_NAME
,
1886 printk(KERN_INFO
"%s: registered as '%s'\n",
1887 DRIVER_NAME
, hw
->name
);
1889 err
= mISDN_register_device(&hw
->dch
.dev
, parent
, hw
->name
);
1894 write_lock_irqsave(&HFClock
, flags
);
1895 list_add_tail(&hw
->list
, &HFClist
);
1896 write_unlock_irqrestore(&HFClock
, flags
);
1900 mISDN_freebchannel(&hw
->bch
[1]);
1901 mISDN_freebchannel(&hw
->bch
[0]);
1902 mISDN_freedchannel(&hw
->dch
);
1908 hfcsusb_probe(struct usb_interface
*intf
, const struct usb_device_id
*id
)
1911 struct usb_device
*dev
= interface_to_usbdev(intf
);
1912 struct usb_host_interface
*iface
= intf
->cur_altsetting
;
1913 struct usb_host_interface
*iface_used
= NULL
;
1914 struct usb_host_endpoint
*ep
;
1915 struct hfcsusb_vdata
*driver_info
;
1916 int ifnum
= iface
->desc
.bInterfaceNumber
, i
, idx
, alt_idx
,
1917 probe_alt_setting
, vend_idx
, cfg_used
, *vcf
, attr
, cfg_found
,
1918 ep_addr
, cmptbl
[16], small_match
, iso_packet_size
, packet_size
,
1922 for (i
= 0; hfcsusb_idtab
[i
].idVendor
; i
++) {
1923 if ((le16_to_cpu(dev
->descriptor
.idVendor
)
1924 == hfcsusb_idtab
[i
].idVendor
) &&
1925 (le16_to_cpu(dev
->descriptor
.idProduct
)
1926 == hfcsusb_idtab
[i
].idProduct
)) {
1933 "%s: interface(%d) actalt(%d) minor(%d) vend_idx(%d)\n",
1934 __func__
, ifnum
, iface
->desc
.bAlternateSetting
,
1935 intf
->minor
, vend_idx
);
1937 if (vend_idx
== 0xffff) {
1939 "%s: no valid vendor found in USB descriptor\n",
1943 /* if vendor and product ID is OK, start probing alternate settings */
1947 /* default settings */
1948 iso_packet_size
= 16;
1951 while (alt_idx
< intf
->num_altsetting
) {
1952 iface
= intf
->altsetting
+ alt_idx
;
1953 probe_alt_setting
= iface
->desc
.bAlternateSetting
;
1956 while (validconf
[cfg_used
][0]) {
1958 vcf
= validconf
[cfg_used
];
1959 ep
= iface
->endpoint
;
1960 memcpy(cmptbl
, vcf
, 16 * sizeof(int));
1962 /* check for all endpoints in this alternate setting */
1963 for (i
= 0; i
< iface
->desc
.bNumEndpoints
; i
++) {
1964 ep_addr
= ep
->desc
.bEndpointAddress
;
1966 /* get endpoint base */
1967 idx
= ((ep_addr
& 0x7f) - 1) * 2;
1973 attr
= ep
->desc
.bmAttributes
;
1975 if (cmptbl
[idx
] != EP_NOP
) {
1976 if (cmptbl
[idx
] == EP_NUL
)
1978 if (attr
== USB_ENDPOINT_XFER_INT
1979 && cmptbl
[idx
] == EP_INT
)
1980 cmptbl
[idx
] = EP_NUL
;
1981 if (attr
== USB_ENDPOINT_XFER_BULK
1982 && cmptbl
[idx
] == EP_BLK
)
1983 cmptbl
[idx
] = EP_NUL
;
1984 if (attr
== USB_ENDPOINT_XFER_ISOC
1985 && cmptbl
[idx
] == EP_ISO
)
1986 cmptbl
[idx
] = EP_NUL
;
1988 if (attr
== USB_ENDPOINT_XFER_INT
&&
1989 ep
->desc
.bInterval
< vcf
[17]) {
1996 for (i
= 0; i
< 16; i
++)
1997 if (cmptbl
[i
] != EP_NOP
&& cmptbl
[i
] != EP_NUL
)
2001 if (small_match
< cfg_used
) {
2002 small_match
= cfg_used
;
2003 alt_used
= probe_alt_setting
;
2010 } /* (alt_idx < intf->num_altsetting) */
2012 /* not found a valid USB Ta Endpoint config */
2013 if (small_match
== -1)
2017 hw
= kzalloc(sizeof(struct hfcsusb
), GFP_KERNEL
);
2019 return -ENOMEM
; /* got no mem */
2020 snprintf(hw
->name
, MISDN_MAX_IDLEN
- 1, "%s", DRIVER_NAME
);
2022 ep
= iface
->endpoint
;
2023 vcf
= validconf
[small_match
];
2025 for (i
= 0; i
< iface
->desc
.bNumEndpoints
; i
++) {
2028 ep_addr
= ep
->desc
.bEndpointAddress
;
2029 /* get endpoint base */
2030 idx
= ((ep_addr
& 0x7f) - 1) * 2;
2033 f
= &hw
->fifos
[idx
& 7];
2035 /* init Endpoints */
2036 if (vcf
[idx
] == EP_NOP
|| vcf
[idx
] == EP_NUL
) {
2040 switch (ep
->desc
.bmAttributes
) {
2041 case USB_ENDPOINT_XFER_INT
:
2042 f
->pipe
= usb_rcvintpipe(dev
,
2043 ep
->desc
.bEndpointAddress
);
2044 f
->usb_transfer_mode
= USB_INT
;
2045 packet_size
= le16_to_cpu(ep
->desc
.wMaxPacketSize
);
2047 case USB_ENDPOINT_XFER_BULK
:
2049 f
->pipe
= usb_rcvbulkpipe(dev
,
2050 ep
->desc
.bEndpointAddress
);
2052 f
->pipe
= usb_sndbulkpipe(dev
,
2053 ep
->desc
.bEndpointAddress
);
2054 f
->usb_transfer_mode
= USB_BULK
;
2055 packet_size
= le16_to_cpu(ep
->desc
.wMaxPacketSize
);
2057 case USB_ENDPOINT_XFER_ISOC
:
2059 f
->pipe
= usb_rcvisocpipe(dev
,
2060 ep
->desc
.bEndpointAddress
);
2062 f
->pipe
= usb_sndisocpipe(dev
,
2063 ep
->desc
.bEndpointAddress
);
2064 f
->usb_transfer_mode
= USB_ISOC
;
2065 iso_packet_size
= le16_to_cpu(ep
->desc
.wMaxPacketSize
);
2072 f
->fifonum
= idx
& 7;
2074 f
->usb_packet_maxlen
=
2075 le16_to_cpu(ep
->desc
.wMaxPacketSize
);
2076 f
->intervall
= ep
->desc
.bInterval
;
2080 hw
->dev
= dev
; /* save device */
2081 hw
->if_used
= ifnum
; /* save used interface */
2082 hw
->alt_used
= alt_used
; /* and alternate config */
2083 hw
->ctrl_paksize
= dev
->descriptor
.bMaxPacketSize0
; /* control size */
2084 hw
->cfg_used
= vcf
[16]; /* store used config */
2085 hw
->vend_idx
= vend_idx
; /* store found vendor */
2086 hw
->packet_size
= packet_size
;
2087 hw
->iso_packet_size
= iso_packet_size
;
2089 /* create the control pipes needed for register access */
2090 hw
->ctrl_in_pipe
= usb_rcvctrlpipe(hw
->dev
, 0);
2091 hw
->ctrl_out_pipe
= usb_sndctrlpipe(hw
->dev
, 0);
2093 driver_info
= (struct hfcsusb_vdata
*)
2094 hfcsusb_idtab
[vend_idx
].driver_info
;
2096 hw
->ctrl_urb
= usb_alloc_urb(0, GFP_KERNEL
);
2097 if (!hw
->ctrl_urb
) {
2098 pr_warn("%s: No memory for control urb\n",
2099 driver_info
->vend_name
);
2104 pr_info("%s: %s: detected \"%s\" (%s, if=%d alt=%d)\n",
2105 hw
->name
, __func__
, driver_info
->vend_name
,
2106 conf_str
[small_match
], ifnum
, alt_used
);
2108 if (setup_instance(hw
, dev
->dev
.parent
))
2112 usb_set_intfdata(hw
->intf
, hw
);
2116 /* function called when an active device is removed */
2118 hfcsusb_disconnect(struct usb_interface
*intf
)
2120 struct hfcsusb
*hw
= usb_get_intfdata(intf
);
2121 struct hfcsusb
*next
;
2124 printk(KERN_INFO
"%s: device disconnected\n", hw
->name
);
2126 handle_led(hw
, LED_POWER_OFF
);
2129 list_for_each_entry_safe(hw
, next
, &HFClist
, list
)
2134 usb_set_intfdata(intf
, NULL
);
2137 static struct usb_driver hfcsusb_drv
= {
2138 .name
= DRIVER_NAME
,
2139 .id_table
= hfcsusb_idtab
,
2140 .probe
= hfcsusb_probe
,
2141 .disconnect
= hfcsusb_disconnect
,
2142 .disable_hub_initiated_lpm
= 1,
2145 module_usb_driver(hfcsusb_drv
);