1 /*************************************************************************/
2 /* $Id: hfc4s8s_l1.c,v 1.10 2005/02/09 16:31:09 martinb1 Exp $ */
3 /* HFC-4S/8S low layer interface for Cologne Chip HFC-4S/8S isdn chips */
4 /* The low layer (L1) is implemented as a loadable module for usage with */
5 /* the HiSax isdn driver for passive cards. */
7 /* Author: Werner Cornelius */
8 /* (C) 2003 Cornelius Consult (werner@cornelius-consult.de) */
10 /* Driver maintained by Cologne Chip */
11 /* - Martin Bachem, support@colognechip.com */
13 /* This driver only works with chip revisions >= 1, older revision 0 */
14 /* engineering samples (only first manufacturer sample cards) will not */
15 /* work and are rejected by the driver. */
17 /* This file distributed under the GNU GPL. */
19 /* See Version History at the end of this file */
21 /*************************************************************************/
23 #include <linux/module.h>
24 #include <linux/init.h>
25 #include <linux/config.h>
26 #include <linux/pci.h>
27 #include <linux/interrupt.h>
28 #include <linux/delay.h>
29 #include <linux/timer.h>
30 #include <linux/skbuff.h>
31 #include <linux/wait.h>
34 #include "hfc4s8s_l1.h"
36 static const char hfc4s8s_rev
[] = "Revision: 1.10";
38 /***************************************************************/
39 /* adjustable transparent mode fifo threshold */
40 /* The value defines the used fifo threshold with the equation */
42 /* notify number of bytes = 2 * 2 ^ TRANS_FIFO_THRES */
44 /* The default value is 5 which results in a buffer size of 64 */
45 /* and an interrupt rate of 8ms. */
46 /* The maximum value is 7 due to fifo size restrictions. */
47 /* Values below 3-4 are not recommended due to high interrupt */
48 /* load of the processor. For non critical applications the */
49 /* value should be raised to 7 to reduce any interrupt overhead*/
50 /***************************************************************/
51 #define TRANS_FIFO_THRES 5
56 #define CLOCKMODE_0 0 /* ext. 24.576 MhZ clk freq, int. single clock mode */
57 #define CLOCKMODE_1 1 /* ext. 49.576 MhZ clk freq, int. single clock mode */
58 #define CHIP_ID_SHIFT 4
60 #define MAX_D_FRAME_SIZE 270
61 #define MAX_B_FRAME_SIZE 1536
62 #define TRANS_TIMER_MODE (TRANS_FIFO_THRES & 0xf)
63 #define TRANS_FIFO_BYTES (2 << TRANS_FIFO_THRES)
64 #define MAX_F_CNT 0x0f
66 #define CLKDEL_NT 0x6c
71 #define L1_TIMER_T4 2 /* minimum in jiffies */
72 #define L1_TIMER_T3 (7 * HZ) /* activation timeout */
73 #define L1_TIMER_T1 ((120 * HZ) / 1000) /* NT mode deactivation timeout */
81 /* private driver_data */
89 static struct pci_device_id hfc4s8s_ids
[] = {
90 {.vendor
= PCI_VENDOR_ID_CCD
,
91 .device
= PCI_DEVICE_ID_4S
,
95 (unsigned long) &((hfc4s8s_param
) {CHIP_ID_4S
, CLOCKMODE_0
, 4,
96 "HFC-4S Evaluation Board"}),
98 {.vendor
= PCI_VENDOR_ID_CCD
,
99 .device
= PCI_DEVICE_ID_8S
,
103 (unsigned long) &((hfc4s8s_param
) {CHIP_ID_8S
, CLOCKMODE_0
, 8,
104 "HFC-8S Evaluation Board"}),
106 {.vendor
= PCI_VENDOR_ID_CCD
,
107 .device
= PCI_DEVICE_ID_4S
,
111 (unsigned long) &((hfc4s8s_param
) {CHIP_ID_4S
, CLOCKMODE_1
, 4,
114 {.vendor
= PCI_VENDOR_ID_CCD
,
115 .device
= PCI_DEVICE_ID_8S
,
119 (unsigned long) &((hfc4s8s_param
) {CHIP_ID_8S
, CLOCKMODE_1
, 8,
125 MODULE_DEVICE_TABLE(pci
, hfc4s8s_ids
);
127 MODULE_AUTHOR("Werner Cornelius, werner@cornelius-consult.de");
128 MODULE_DESCRIPTION("ISDN layer 1 for Cologne Chip HFC-4S/8S chips");
129 MODULE_LICENSE("GPL");
134 struct hfc4s8s_btype
{
136 struct hisax_b_if b_if
;
137 struct hfc4s8s_l1
*l1p
;
138 struct sk_buff_head tx_queue
;
139 struct sk_buff
*tx_skb
;
140 struct sk_buff
*rx_skb
;
151 struct _hfc4s8s_hw
*hw
; /* pointer to hardware area */
152 int l1_state
; /* actual l1 state */
153 struct timer_list l1_timer
; /* layer 1 timer structure */
154 int nt_mode
; /* set to nt mode */
155 int st_num
; /* own index */
156 int enabled
; /* interface is enabled */
157 struct sk_buff_head d_tx_queue
; /* send queue */
158 int tx_cnt
; /* bytes to send */
159 struct hisax_d_if d_if
; /* D-channel interface */
160 struct hfc4s8s_btype b_ch
[2]; /* B-channel data */
161 struct hisax_b_if
*b_table
[2];
164 /**********************/
165 /* hardware structure */
166 /**********************/
167 typedef struct _hfc4s8s_hw
{
178 hfc4s8s_param driver_data
;
181 struct work_struct tqueue
;
182 struct hfc4s8s_l1 l1
[HFC_MAX_ST
];
187 volatile u_char r_irq_statech
; /* active isdn l1 status */
188 u_char r_irqmsk_statchg
; /* enabled isdn status ints */
189 u_char r_irq_fifo_blx
[8]; /* fifo status registers */
190 u_char fifo_rx_trans_enables
[8]; /* mask for enabled transparent rx fifos */
191 u_char fifo_slow_timer_service
[8]; /* mask for fifos needing slower timer service */
192 volatile u_char r_irq_oview
; /* contents of overview register */
193 volatile u_char timer_irq
;
194 int timer_usg_cnt
; /* number of channels using timer */
200 /***************************/
201 /* inline function defines */
202 /***************************/
203 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM /* inline functions mempry mapped */
205 /* memory write and dummy IO read to avoid PCI byte merge problems */
206 #define Write_hfc8(a,b,c) {(*((volatile u_char *)(a->membase+b)) = c); inb(a->iobase+4);}
207 /* memory write without dummy IO access for fifo data access */
208 #define fWrite_hfc8(a,b,c) (*((volatile u_char *)(a->membase+b)) = c)
209 #define Read_hfc8(a,b) (*((volatile u_char *)(a->membase+b)))
210 #define Write_hfc16(a,b,c) (*((volatile unsigned short *)(a->membase+b)) = c)
211 #define Read_hfc16(a,b) (*((volatile unsigned short *)(a->membase+b)))
212 #define Write_hfc32(a,b,c) (*((volatile unsigned long *)(a->membase+b)) = c)
213 #define Read_hfc32(a,b) (*((volatile unsigned long *)(a->membase+b)))
214 #define wait_busy(a) {while ((Read_hfc8(a, R_STATUS) & M_BUSY));}
215 #define PCI_ENA_MEMIO 0x03
219 /* inline functions io mapped */
221 SetRegAddr(hfc4s8s_hw
* a
, u_char b
)
223 outb(b
, (a
->iobase
) + 4);
227 GetRegAddr(hfc4s8s_hw
* a
)
229 return (inb((volatile u_int
) (a
->iobase
+ 4)));
234 Write_hfc8(hfc4s8s_hw
* a
, u_char b
, u_char c
)
241 fWrite_hfc8(hfc4s8s_hw
* a
, u_char c
)
247 Write_hfc16(hfc4s8s_hw
* a
, u_char b
, u_short c
)
254 Write_hfc32(hfc4s8s_hw
* a
, u_char b
, u_long c
)
261 fWrite_hfc32(hfc4s8s_hw
* a
, u_long c
)
267 Read_hfc8(hfc4s8s_hw
* a
, u_char b
)
270 return (inb((volatile u_int
) a
->iobase
));
274 fRead_hfc8(hfc4s8s_hw
* a
)
276 return (inb((volatile u_int
) a
->iobase
));
280 static inline u_short
281 Read_hfc16(hfc4s8s_hw
* a
, u_char b
)
284 return (inw((volatile u_int
) a
->iobase
));
288 Read_hfc32(hfc4s8s_hw
* a
, u_char b
)
291 return (inl((volatile u_int
) a
->iobase
));
295 fRead_hfc32(hfc4s8s_hw
* a
)
297 return (inl((volatile u_int
) a
->iobase
));
301 wait_busy(hfc4s8s_hw
* a
)
303 SetRegAddr(a
, R_STATUS
);
304 while (inb((volatile u_int
) a
->iobase
) & M_BUSY
);
307 #define PCI_ENA_REGIO 0x01
309 #endif /* CONFIG_HISAX_HFC4S8S_PCIMEM */
311 /******************************************************/
312 /* function to read critical counter registers that */
313 /* may be udpated by the chip during read */
314 /******************************************************/
316 Read_hfc8_stable(hfc4s8s_hw
* hw
, int reg
)
320 ref8
= Read_hfc8(hw
, reg
);
321 while (((in8
= Read_hfc8(hw
, reg
)) != ref8
)) {
328 Read_hfc16_stable(hfc4s8s_hw
* hw
, int reg
)
333 ref16
= Read_hfc16(hw
, reg
);
334 while (((in16
= Read_hfc16(hw
, reg
)) != ref16
)) {
340 /*****************************/
341 /* D-channel call from HiSax */
342 /*****************************/
344 dch_l2l1(struct hisax_d_if
*iface
, int pr
, void *arg
)
346 struct hfc4s8s_l1
*l1
= iface
->ifc
.priv
;
347 struct sk_buff
*skb
= (struct sk_buff
*) arg
;
352 case (PH_DATA
| REQUEST
):
357 spin_lock_irqsave(&l1
->lock
, flags
);
358 skb_queue_tail(&l1
->d_tx_queue
, skb
);
359 if ((skb_queue_len(&l1
->d_tx_queue
) == 1) &&
361 l1
->hw
->mr
.r_irq_fifo_blx
[l1
->st_num
] |=
363 spin_unlock_irqrestore(&l1
->lock
, flags
);
364 schedule_work(&l1
->hw
->tqueue
);
366 spin_unlock_irqrestore(&l1
->lock
, flags
);
369 case (PH_ACTIVATE
| REQUEST
):
373 if (l1
->l1_state
< 6) {
374 spin_lock_irqsave(&l1
->lock
,
377 Write_hfc8(l1
->hw
, R_ST_SEL
,
379 Write_hfc8(l1
->hw
, A_ST_WR_STA
,
381 mod_timer(&l1
->l1_timer
,
382 jiffies
+ L1_TIMER_T3
);
383 spin_unlock_irqrestore(&l1
->lock
,
385 } else if (l1
->l1_state
== 7)
386 l1
->d_if
.ifc
.l1l2(&l1
->d_if
.ifc
,
391 if (l1
->l1_state
!= 3) {
392 spin_lock_irqsave(&l1
->lock
,
394 Write_hfc8(l1
->hw
, R_ST_SEL
,
396 Write_hfc8(l1
->hw
, A_ST_WR_STA
,
398 spin_unlock_irqrestore(&l1
->lock
,
400 } else if (l1
->l1_state
== 3)
401 l1
->d_if
.ifc
.l1l2(&l1
->d_if
.ifc
,
410 "HFC-4S/8S: Unknown D-chan cmd 0x%x received, ignored\n",
415 l1
->d_if
.ifc
.l1l2(&l1
->d_if
.ifc
,
416 PH_DEACTIVATE
| INDICATION
, NULL
);
419 /*****************************/
420 /* B-channel call from HiSax */
421 /*****************************/
423 bch_l2l1(struct hisax_if
*ifc
, int pr
, void *arg
)
425 struct hfc4s8s_btype
*bch
= ifc
->priv
;
426 struct hfc4s8s_l1
*l1
= bch
->l1p
;
427 struct sk_buff
*skb
= (struct sk_buff
*) arg
;
428 int mode
= (int) arg
;
433 case (PH_DATA
| REQUEST
):
434 if (!l1
->enabled
|| (bch
->mode
== L1_MODE_NULL
)) {
438 spin_lock_irqsave(&l1
->lock
, flags
);
439 skb_queue_tail(&bch
->tx_queue
, skb
);
440 if (!bch
->tx_skb
&& (bch
->tx_cnt
<= 0)) {
441 l1
->hw
->mr
.r_irq_fifo_blx
[l1
->st_num
] |=
442 ((bch
->bchan
== 1) ? 1 : 4);
443 spin_unlock_irqrestore(&l1
->lock
, flags
);
444 schedule_work(&l1
->hw
->tqueue
);
446 spin_unlock_irqrestore(&l1
->lock
, flags
);
449 case (PH_ACTIVATE
| REQUEST
):
450 case (PH_DEACTIVATE
| REQUEST
):
453 if (pr
== (PH_DEACTIVATE
| REQUEST
))
458 spin_lock_irqsave(&l1
->lock
,
460 l1
->hw
->mr
.timer_usg_cnt
++;
462 fifo_slow_timer_service
[l1
->
467 Write_hfc8(l1
->hw
, R_FIFO
,
472 Write_hfc8(l1
->hw
, A_CON_HDLC
, 0xc); /* HDLC mode, flag fill, connect ST */
473 Write_hfc8(l1
->hw
, A_SUBCH_CFG
, 0); /* 8 bits */
474 Write_hfc8(l1
->hw
, A_IRQ_MSK
, 1); /* enable TX interrupts for hdlc */
475 Write_hfc8(l1
->hw
, A_INC_RES_FIFO
, 2); /* reset fifo */
478 Write_hfc8(l1
->hw
, R_FIFO
,
483 Write_hfc8(l1
->hw
, A_CON_HDLC
, 0xc); /* HDLC mode, flag fill, connect ST */
484 Write_hfc8(l1
->hw
, A_SUBCH_CFG
, 0); /* 8 bits */
485 Write_hfc8(l1
->hw
, A_IRQ_MSK
, 1); /* enable RX interrupts for hdlc */
486 Write_hfc8(l1
->hw
, A_INC_RES_FIFO
, 2); /* reset fifo */
488 Write_hfc8(l1
->hw
, R_ST_SEL
,
490 l1
->hw
->mr
.r_ctrl0
|=
492 Write_hfc8(l1
->hw
, A_ST_CTRL0
,
494 bch
->mode
= L1_MODE_HDLC
;
495 spin_unlock_irqrestore(&l1
->lock
,
498 bch
->b_if
.ifc
.l1l2(&bch
->b_if
.ifc
,
505 spin_lock_irqsave(&l1
->lock
,
508 fifo_rx_trans_enables
[l1
->
513 l1
->hw
->mr
.timer_usg_cnt
++;
514 Write_hfc8(l1
->hw
, R_FIFO
,
519 Write_hfc8(l1
->hw
, A_CON_HDLC
, 0xf); /* Transparent mode, 1 fill, connect ST */
520 Write_hfc8(l1
->hw
, A_SUBCH_CFG
, 0); /* 8 bits */
521 Write_hfc8(l1
->hw
, A_IRQ_MSK
, 0); /* disable TX interrupts */
522 Write_hfc8(l1
->hw
, A_INC_RES_FIFO
, 2); /* reset fifo */
525 Write_hfc8(l1
->hw
, R_FIFO
,
530 Write_hfc8(l1
->hw
, A_CON_HDLC
, 0xf); /* Transparent mode, 1 fill, connect ST */
531 Write_hfc8(l1
->hw
, A_SUBCH_CFG
, 0); /* 8 bits */
532 Write_hfc8(l1
->hw
, A_IRQ_MSK
, 0); /* disable RX interrupts */
533 Write_hfc8(l1
->hw
, A_INC_RES_FIFO
, 2); /* reset fifo */
535 Write_hfc8(l1
->hw
, R_ST_SEL
,
537 l1
->hw
->mr
.r_ctrl0
|=
539 Write_hfc8(l1
->hw
, A_ST_CTRL0
,
541 bch
->mode
= L1_MODE_TRANS
;
542 spin_unlock_irqrestore(&l1
->lock
,
545 bch
->b_if
.ifc
.l1l2(&bch
->b_if
.ifc
,
552 if (bch
->mode
== L1_MODE_NULL
)
554 spin_lock_irqsave(&l1
->lock
,
557 fifo_slow_timer_service
[l1
->
563 fifo_rx_trans_enables
[l1
->
568 l1
->hw
->mr
.timer_usg_cnt
--;
569 Write_hfc8(l1
->hw
, R_FIFO
,
574 Write_hfc8(l1
->hw
, A_IRQ_MSK
, 0); /* disable TX interrupts */
576 Write_hfc8(l1
->hw
, R_FIFO
,
581 Write_hfc8(l1
->hw
, A_IRQ_MSK
, 0); /* disable RX interrupts */
582 Write_hfc8(l1
->hw
, R_ST_SEL
,
584 l1
->hw
->mr
.r_ctrl0
&=
586 Write_hfc8(l1
->hw
, A_ST_CTRL0
,
588 spin_unlock_irqrestore(&l1
->lock
,
591 bch
->mode
= L1_MODE_NULL
;
592 bch
->b_if
.ifc
.l1l2(&bch
->b_if
.ifc
,
597 dev_kfree_skb(bch
->tx_skb
);
601 dev_kfree_skb(bch
->rx_skb
);
604 skb_queue_purge(&bch
->tx_queue
);
610 /* timer is only used when at least one b channel */
611 /* is set up to transparent mode */
612 if (l1
->hw
->mr
.timer_usg_cnt
) {
613 Write_hfc8(l1
->hw
, R_IRQMSK_MISC
,
616 Write_hfc8(l1
->hw
, R_IRQMSK_MISC
, 0);
623 "HFC-4S/8S: Unknown B-chan cmd 0x%x received, ignored\n",
628 bch
->b_if
.ifc
.l1l2(&bch
->b_if
.ifc
,
629 PH_DEACTIVATE
| INDICATION
, NULL
);
632 /**************************/
633 /* layer 1 timer function */
634 /**************************/
636 hfc_l1_timer(struct hfc4s8s_l1
*l1
)
643 spin_lock_irqsave(&l1
->lock
, flags
);
646 Write_hfc8(l1
->hw
, R_ST_SEL
, l1
->st_num
);
647 Write_hfc8(l1
->hw
, A_ST_WR_STA
, 0x11);
648 spin_unlock_irqrestore(&l1
->lock
, flags
);
649 l1
->d_if
.ifc
.l1l2(&l1
->d_if
.ifc
,
650 PH_DEACTIVATE
| INDICATION
, NULL
);
651 spin_lock_irqsave(&l1
->lock
, flags
);
653 Write_hfc8(l1
->hw
, A_ST_WR_STA
, 0x1);
654 spin_unlock_irqrestore(&l1
->lock
, flags
);
656 /* activation timed out */
657 Write_hfc8(l1
->hw
, R_ST_SEL
, l1
->st_num
);
658 Write_hfc8(l1
->hw
, A_ST_WR_STA
, 0x13);
659 spin_unlock_irqrestore(&l1
->lock
, flags
);
660 l1
->d_if
.ifc
.l1l2(&l1
->d_if
.ifc
,
661 PH_DEACTIVATE
| INDICATION
, NULL
);
662 spin_lock_irqsave(&l1
->lock
, flags
);
663 Write_hfc8(l1
->hw
, R_ST_SEL
, l1
->st_num
);
664 Write_hfc8(l1
->hw
, A_ST_WR_STA
, 0x3);
665 spin_unlock_irqrestore(&l1
->lock
, flags
);
669 /****************************************/
670 /* a complete D-frame has been received */
671 /****************************************/
673 rx_d_frame(struct hfc4s8s_l1
*l1p
, int ech
)
685 Write_hfc8(l1p
->hw
, R_FIFO
,
686 (l1p
->st_num
* 8 + ((ech
) ? 7 : 5)));
689 f1
= Read_hfc8_stable(l1p
->hw
, A_F1
);
690 f2
= Read_hfc8(l1p
->hw
, A_F2
);
693 df
= f1
- f2
+ MAX_F_CNT
+ 1;
697 return; /* no complete frame in fifo */
700 z1
= Read_hfc16_stable(l1p
->hw
, A_Z1
);
701 z2
= Read_hfc16(l1p
->hw
, A_Z2
);
707 if (!(skb
= dev_alloc_skb(MAX_D_FRAME_SIZE
))) {
709 "HFC-4S/8S: Could not allocate D/E "
710 "channel receive buffer");
711 Write_hfc8(l1p
->hw
, A_INC_RES_FIFO
, 2);
716 if (((z1
< 4) || (z1
> MAX_D_FRAME_SIZE
))) {
719 /* remove errornous D frame */
722 Write_hfc8(l1p
->hw
, A_INC_RES_FIFO
, 2);
726 /* read errornous D frame */
728 #ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
729 SetRegAddr(l1p
->hw
, A_FIFO_DATA0
);
733 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
734 Read_hfc32(l1p
->hw
, A_FIFO_DATA0
);
736 fRead_hfc32(l1p
->hw
);
742 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
743 Read_hfc8(l1p
->hw
, A_FIFO_DATA0
);
748 Write_hfc8(l1p
->hw
, A_INC_RES_FIFO
, 1);
756 #ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
757 SetRegAddr(l1p
->hw
, A_FIFO_DATA0
);
761 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
762 *((unsigned long *) cp
) =
763 Read_hfc32(l1p
->hw
, A_FIFO_DATA0
);
765 *((unsigned long *) cp
) = fRead_hfc32(l1p
->hw
);
772 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
773 *cp
++ = Read_hfc8(l1p
->hw
, A_FIFO_DATA0
);
775 *cp
++ = fRead_hfc8(l1p
->hw
);
778 Write_hfc8(l1p
->hw
, A_INC_RES_FIFO
, 1); /* increment f counter */
784 skb
->len
= (cp
- skb
->data
) - 2;
786 l1p
->d_if
.ifc
.l1l2(&l1p
->d_if
.ifc
,
787 PH_DATA_E
| INDICATION
,
790 l1p
->d_if
.ifc
.l1l2(&l1p
->d_if
.ifc
,
791 PH_DATA
| INDICATION
,
797 /*************************************************************/
798 /* a B-frame has been received (perhaps not fully completed) */
799 /*************************************************************/
801 rx_b_frame(struct hfc4s8s_btype
*bch
)
803 int z1
, z2
, hdlc_complete
;
805 struct hfc4s8s_l1
*l1
= bch
->l1p
;
808 if (!l1
->enabled
|| (bch
->mode
== L1_MODE_NULL
))
813 Write_hfc8(l1
->hw
, R_FIFO
,
814 (l1
->st_num
* 8 + ((bch
->bchan
== 1) ? 1 : 3)));
817 if (bch
->mode
== L1_MODE_HDLC
) {
818 f1
= Read_hfc8_stable(l1
->hw
, A_F1
);
819 f2
= Read_hfc8(l1
->hw
, A_F2
);
820 hdlc_complete
= ((f1
^ f2
) & MAX_F_CNT
);
823 z1
= Read_hfc16_stable(l1
->hw
, A_Z1
);
824 z2
= Read_hfc16(l1
->hw
, A_Z2
);
834 if (!(skb
= bch
->rx_skb
)) {
837 dev_alloc_skb((bch
->mode
==
839 : (MAX_B_FRAME_SIZE
+ 3)))) {
841 "HFC-4S/8S: Could not allocate B "
842 "channel receive buffer");
845 bch
->rx_ptr
= skb
->data
;
849 skb
->len
= (bch
->rx_ptr
- skb
->data
) + z1
;
851 /* HDLC length check */
852 if ((bch
->mode
== L1_MODE_HDLC
) &&
853 ((hdlc_complete
&& (skb
->len
< 4)) ||
854 (skb
->len
> (MAX_B_FRAME_SIZE
+ 3)))) {
857 bch
->rx_ptr
= skb
->data
;
858 Write_hfc8(l1
->hw
, A_INC_RES_FIFO
, 2); /* reset fifo */
862 #ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
863 SetRegAddr(l1
->hw
, A_FIFO_DATA0
);
867 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
868 *((unsigned long *) bch
->rx_ptr
) =
869 Read_hfc32(l1
->hw
, A_FIFO_DATA0
);
871 *((unsigned long *) bch
->rx_ptr
) =
879 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
880 *(bch
->rx_ptr
++) = Read_hfc8(l1
->hw
, A_FIFO_DATA0
);
882 *(bch
->rx_ptr
++) = fRead_hfc8(l1
->hw
);
886 /* increment f counter */
887 Write_hfc8(l1
->hw
, A_INC_RES_FIFO
, 1);
894 bch
->rx_ptr
= skb
->data
;
899 if (hdlc_complete
|| (bch
->mode
== L1_MODE_TRANS
)) {
902 bch
->b_if
.ifc
.l1l2(&bch
->b_if
.ifc
,
903 PH_DATA
| INDICATION
, skb
);
909 /********************************************/
910 /* a D-frame has been/should be transmitted */
911 /********************************************/
913 tx_d_frame(struct hfc4s8s_l1
*l1p
)
920 if (l1p
->l1_state
!= 7)
924 Write_hfc8(l1p
->hw
, R_FIFO
, (l1p
->st_num
* 8 + 4));
927 f1
= Read_hfc8(l1p
->hw
, A_F1
);
928 f2
= Read_hfc8_stable(l1p
->hw
, A_F2
);
930 if ((f1
^ f2
) & MAX_F_CNT
)
931 return; /* fifo is still filled */
933 if (l1p
->tx_cnt
> 0) {
936 l1p
->d_if
.ifc
.l1l2(&l1p
->d_if
.ifc
, PH_DATA
| CONFIRM
,
940 if ((skb
= skb_dequeue(&l1p
->d_tx_queue
))) {
943 #ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
944 SetRegAddr(l1p
->hw
, A_FIFO_DATA0
);
948 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
949 fWrite_hfc32(l1p
->hw
, A_FIFO_DATA0
,
950 *(unsigned long *) cp
);
952 SetRegAddr(l1p
->hw
, A_FIFO_DATA0
);
953 fWrite_hfc32(l1p
->hw
, *(unsigned long *) cp
);
959 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
961 fWrite_hfc8(l1p
->hw
, A_FIFO_DATA0
, *cp
++);
964 fWrite_hfc8(l1p
->hw
, *cp
++);
967 l1p
->tx_cnt
= skb
->truesize
;
968 Write_hfc8(l1p
->hw
, A_INC_RES_FIFO
, 1); /* increment f counter */
975 /******************************************************/
976 /* a B-frame may be transmitted (or is not completed) */
977 /******************************************************/
979 tx_b_frame(struct hfc4s8s_btype
*bch
)
982 struct hfc4s8s_l1
*l1
= bch
->l1p
;
984 int cnt
, max
, hdlc_num
, ack_len
= 0;
986 if (!l1
->enabled
|| (bch
->mode
== L1_MODE_NULL
))
990 Write_hfc8(l1
->hw
, R_FIFO
,
991 (l1
->st_num
* 8 + ((bch
->bchan
== 1) ? 0 : 2)));
995 if (bch
->mode
== L1_MODE_HDLC
) {
996 hdlc_num
= Read_hfc8(l1
->hw
, A_F1
) & MAX_F_CNT
;
998 (Read_hfc8_stable(l1
->hw
, A_F2
) & MAX_F_CNT
);
1002 break; /* fifo still filled up with hdlc frames */
1006 if (!(skb
= bch
->tx_skb
)) {
1007 if (!(skb
= skb_dequeue(&bch
->tx_queue
))) {
1008 l1
->hw
->mr
.fifo_slow_timer_service
[l1
->
1010 &= ~((bch
->bchan
== 1) ? 1 : 4);
1011 break; /* list empty */
1018 l1
->hw
->mr
.fifo_slow_timer_service
[l1
->st_num
] |=
1019 ((bch
->bchan
== 1) ? 1 : 4);
1021 l1
->hw
->mr
.fifo_slow_timer_service
[l1
->st_num
] &=
1022 ~((bch
->bchan
== 1) ? 1 : 4);
1024 max
= Read_hfc16_stable(l1
->hw
, A_Z2
);
1025 max
-= Read_hfc16(l1
->hw
, A_Z1
);
1031 break; /* don't write to small amounts of bytes */
1033 cnt
= skb
->len
- bch
->tx_cnt
;
1036 cp
= skb
->data
+ bch
->tx_cnt
;
1039 #ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
1040 SetRegAddr(l1
->hw
, A_FIFO_DATA0
);
1043 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
1044 fWrite_hfc32(l1
->hw
, A_FIFO_DATA0
,
1045 *(unsigned long *) cp
);
1047 fWrite_hfc32(l1
->hw
, *(unsigned long *) cp
);
1054 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
1055 fWrite_hfc8(l1
->hw
, A_FIFO_DATA0
, *cp
++);
1057 fWrite_hfc8(l1
->hw
, *cp
++);
1060 if (bch
->tx_cnt
>= skb
->len
) {
1061 if (bch
->mode
== L1_MODE_HDLC
) {
1062 /* increment f counter */
1063 Write_hfc8(l1
->hw
, A_INC_RES_FIFO
, 1);
1065 ack_len
+= skb
->truesize
;
1071 Write_hfc8(l1
->hw
, R_FIFO
,
1073 ((bch
->bchan
== 1) ? 0 : 2)));
1078 bch
->b_if
.ifc
.l1l2((struct hisax_if
*) &bch
->b_if
,
1079 PH_DATA
| CONFIRM
, (void *) ack_len
);
1082 /*************************************/
1083 /* bottom half handler for interrupt */
1084 /*************************************/
1086 hfc4s8s_bh(hfc4s8s_hw
* hw
)
1089 struct hfc4s8s_l1
*l1p
;
1090 volatile u_char
*fifo_stat
;
1093 /* handle layer 1 state changes */
1097 if ((b
& hw
->mr
.r_irq_statech
)) {
1098 /* reset l1 event */
1099 hw
->mr
.r_irq_statech
&= ~b
;
1102 u_char oldstate
= l1p
->l1_state
;
1104 Write_hfc8(l1p
->hw
, R_ST_SEL
,
1111 && (l1p
->l1_state
!= 3))
1112 l1p
->d_if
.ifc
.l1l2(&l1p
->
1120 if (l1p
->l1_state
!= 2) {
1121 del_timer(&l1p
->l1_timer
);
1122 if (l1p
->l1_state
== 3) {
1132 /* allow transition */
1133 Write_hfc8(hw
, A_ST_WR_STA
,
1135 mod_timer(&l1p
->l1_timer
,
1140 "HFC-4S/8S: NT ch %d l1 state %d -> %d\n",
1141 l1p
->st_num
, oldstate
,
1144 u_char oldstate
= l1p
->l1_state
;
1146 Write_hfc8(l1p
->hw
, R_ST_SEL
,
1152 if (((l1p
->l1_state
== 3) &&
1154 (oldstate
== 8))) ||
1157 && (l1p
->l1_state
== 8))) {
1158 mod_timer(&l1p
->l1_timer
,
1162 if (l1p
->l1_state
== 7) {
1174 if (l1p
->l1_state
== 3) {
1189 "HFC-4S/8S: TE %d ch %d l1 state %d -> %d\n",
1191 l1p
->st_num
, oldstate
,
1200 /* now handle the fifos */
1202 fifo_stat
= hw
->mr
.r_irq_fifo_blx
;
1204 while (idx
< hw
->driver_data
.max_st_ports
) {
1206 if (hw
->mr
.timer_irq
) {
1207 *fifo_stat
|= hw
->mr
.fifo_rx_trans_enables
[idx
];
1208 if (hw
->fifo_sched_cnt
<= 0) {
1210 hw
->mr
.fifo_slow_timer_service
[l1p
->
1214 /* ignore fifo 6 (TX E fifo) */
1215 *fifo_stat
&= 0xff - 0x40;
1217 while (*fifo_stat
) {
1219 if (!l1p
->nt_mode
) {
1220 /* RX Fifo has data to read */
1221 if ((*fifo_stat
& 0x20)) {
1222 *fifo_stat
&= ~0x20;
1225 /* E Fifo has data to read */
1226 if ((*fifo_stat
& 0x80)) {
1227 *fifo_stat
&= ~0x80;
1230 /* TX Fifo completed send */
1231 if ((*fifo_stat
& 0x10)) {
1232 *fifo_stat
&= ~0x10;
1236 /* B1 RX Fifo has data to read */
1237 if ((*fifo_stat
& 0x2)) {
1239 rx_b_frame(l1p
->b_ch
);
1241 /* B1 TX Fifo has send completed */
1242 if ((*fifo_stat
& 0x1)) {
1244 tx_b_frame(l1p
->b_ch
);
1246 /* B2 RX Fifo has data to read */
1247 if ((*fifo_stat
& 0x8)) {
1249 rx_b_frame(l1p
->b_ch
+ 1);
1251 /* B2 TX Fifo has send completed */
1252 if ((*fifo_stat
& 0x4)) {
1254 tx_b_frame(l1p
->b_ch
+ 1);
1262 if (hw
->fifo_sched_cnt
<= 0)
1263 hw
->fifo_sched_cnt
+= (1 << (7 - TRANS_TIMER_MODE
));
1264 hw
->mr
.timer_irq
= 0; /* clear requested timer irq */
1267 /*********************/
1268 /* interrupt handler */
1269 /*********************/
1271 hfc4s8s_interrupt(int intno
, void *dev_id
, struct pt_regs
*regs
)
1273 hfc4s8s_hw
*hw
= dev_id
;
1275 volatile u_char
*ovp
;
1279 if (!hw
|| !(hw
->mr
.r_irq_ctrl
& M_GLOB_IRQ_EN
))
1282 #ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
1283 /* read current selected regsister */
1284 old_ioreg
= GetRegAddr(hw
);
1287 /* Layer 1 State change */
1288 hw
->mr
.r_irq_statech
|=
1289 (Read_hfc8(hw
, R_SCI
) & hw
->mr
.r_irqmsk_statchg
);
1291 (b
= (Read_hfc8(hw
, R_STATUS
) & (M_MISC_IRQSTA
| M_FR_IRQSTA
)))
1292 && !hw
->mr
.r_irq_statech
) {
1293 #ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
1294 SetRegAddr(hw
, old_ioreg
);
1300 if (Read_hfc8(hw
, R_IRQ_MISC
) & M_TI_IRQ
) {
1301 hw
->mr
.timer_irq
= 1;
1302 hw
->fifo_sched_cnt
--;
1306 if ((ovr
= Read_hfc8(hw
, R_IRQ_OVIEW
))) {
1307 hw
->mr
.r_irq_oview
|= ovr
;
1308 idx
= R_IRQ_FIFO_BL0
;
1309 ovp
= hw
->mr
.r_irq_fifo_blx
;
1312 *ovp
|= Read_hfc8(hw
, idx
);
1320 /* queue the request to allow other cards to interrupt */
1321 schedule_work(&hw
->tqueue
);
1323 #ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
1324 SetRegAddr(hw
, old_ioreg
);
1327 } /* hfc4s8s_interrupt */
1329 /***********************************************************************/
1330 /* reset the complete chip, don't release the chips irq but disable it */
1331 /***********************************************************************/
1333 chipreset(hfc4s8s_hw
* hw
)
1337 spin_lock_irqsave(&hw
->lock
, flags
);
1338 Write_hfc8(hw
, R_CTRL
, 0); /* use internal RAM */
1339 Write_hfc8(hw
, R_RAM_MISC
, 0); /* 32k*8 RAM */
1340 Write_hfc8(hw
, R_FIFO_MD
, 0); /* fifo mode 386 byte/fifo simple mode */
1341 Write_hfc8(hw
, R_CIRM
, M_SRES
); /* reset chip */
1342 hw
->mr
.r_irq_ctrl
= 0; /* interrupt is inactive */
1343 spin_unlock_irqrestore(&hw
->lock
, flags
);
1346 Write_hfc8(hw
, R_CIRM
, 0); /* disable reset */
1349 Write_hfc8(hw
, R_PCM_MD0
, M_PCM_MD
); /* master mode */
1350 Write_hfc8(hw
, R_RAM_MISC
, M_FZ_MD
); /* transmit fifo option */
1351 if (hw
->driver_data
.clock_mode
== 1)
1352 Write_hfc8(hw
, R_BRG_PCM_CFG
, M_PCM_CLK
); /* PCM clk / 2 */
1353 Write_hfc8(hw
, R_TI_WD
, TRANS_TIMER_MODE
); /* timer interval */
1355 memset(&hw
->mr
, 0, sizeof(hw
->mr
));
1358 /********************************************/
1359 /* disable/enable hardware in nt or te mode */
1360 /********************************************/
1362 hfc_hardware_enable(hfc4s8s_hw
* hw
, int enable
, int nt_mode
)
1369 /* save system vars */
1370 hw
->nt_mode
= nt_mode
;
1372 /* enable fifo and state irqs, but not global irq enable */
1373 hw
->mr
.r_irq_ctrl
= M_FIFO_IRQ
;
1374 Write_hfc8(hw
, R_IRQ_CTRL
, hw
->mr
.r_irq_ctrl
);
1375 hw
->mr
.r_irqmsk_statchg
= 0;
1376 Write_hfc8(hw
, R_SCI_MSK
, hw
->mr
.r_irqmsk_statchg
);
1377 Write_hfc8(hw
, R_PWM_MD
, 0x80);
1378 Write_hfc8(hw
, R_PWM1
, 26);
1380 Write_hfc8(hw
, R_ST_SYNC
, M_AUTO_SYNC
);
1382 /* enable the line interfaces and fifos */
1383 for (i
= 0; i
< hw
->driver_data
.max_st_ports
; i
++) {
1384 hw
->mr
.r_irqmsk_statchg
|= (1 << i
);
1385 Write_hfc8(hw
, R_SCI_MSK
, hw
->mr
.r_irqmsk_statchg
);
1386 Write_hfc8(hw
, R_ST_SEL
, i
);
1387 Write_hfc8(hw
, A_ST_CLK_DLY
,
1388 ((nt_mode
) ? CLKDEL_NT
: CLKDEL_TE
));
1389 hw
->mr
.r_ctrl0
= ((nt_mode
) ? CTRL0_NT
: CTRL0_TE
);
1390 Write_hfc8(hw
, A_ST_CTRL0
, hw
->mr
.r_ctrl0
);
1391 Write_hfc8(hw
, A_ST_CTRL2
, 3);
1392 Write_hfc8(hw
, A_ST_WR_STA
, 0); /* enable state machine */
1394 hw
->l1
[i
].enabled
= 1;
1395 hw
->l1
[i
].nt_mode
= nt_mode
;
1399 Write_hfc8(hw
, R_FIFO
, i
* 8 + 7); /* E fifo */
1401 Write_hfc8(hw
, A_CON_HDLC
, 0x11); /* HDLC mode, 1 fill, connect ST */
1402 Write_hfc8(hw
, A_SUBCH_CFG
, 2); /* only 2 bits */
1403 Write_hfc8(hw
, A_IRQ_MSK
, 1); /* enable interrupt */
1404 Write_hfc8(hw
, A_INC_RES_FIFO
, 2); /* reset fifo */
1407 /* setup D RX-fifo */
1408 Write_hfc8(hw
, R_FIFO
, i
* 8 + 5); /* RX fifo */
1410 Write_hfc8(hw
, A_CON_HDLC
, 0x11); /* HDLC mode, 1 fill, connect ST */
1411 Write_hfc8(hw
, A_SUBCH_CFG
, 2); /* only 2 bits */
1412 Write_hfc8(hw
, A_IRQ_MSK
, 1); /* enable interrupt */
1413 Write_hfc8(hw
, A_INC_RES_FIFO
, 2); /* reset fifo */
1416 /* setup D TX-fifo */
1417 Write_hfc8(hw
, R_FIFO
, i
* 8 + 4); /* TX fifo */
1419 Write_hfc8(hw
, A_CON_HDLC
, 0x11); /* HDLC mode, 1 fill, connect ST */
1420 Write_hfc8(hw
, A_SUBCH_CFG
, 2); /* only 2 bits */
1421 Write_hfc8(hw
, A_IRQ_MSK
, 1); /* enable interrupt */
1422 Write_hfc8(hw
, A_INC_RES_FIFO
, 2); /* reset fifo */
1426 sprintf(if_name
, "hfc4s8s_%d%d_", hw
->cardnum
, i
);
1429 (&hw
->l1
[i
].d_if
, hw
->l1
[i
].b_table
, if_name
,
1430 ((nt_mode
) ? 3 : 2))) {
1432 hw
->l1
[i
].enabled
= 0;
1433 hw
->mr
.r_irqmsk_statchg
&= ~(1 << i
);
1434 Write_hfc8(hw
, R_SCI_MSK
,
1435 hw
->mr
.r_irqmsk_statchg
);
1437 "HFC-4S/8S: Unable to register S/T device %s, break\n",
1442 spin_lock_irqsave(&hw
->lock
, flags
);
1443 hw
->mr
.r_irq_ctrl
|= M_GLOB_IRQ_EN
;
1444 Write_hfc8(hw
, R_IRQ_CTRL
, hw
->mr
.r_irq_ctrl
);
1445 spin_unlock_irqrestore(&hw
->lock
, flags
);
1447 /* disable hardware */
1448 spin_lock_irqsave(&hw
->lock
, flags
);
1449 hw
->mr
.r_irq_ctrl
&= ~M_GLOB_IRQ_EN
;
1450 Write_hfc8(hw
, R_IRQ_CTRL
, hw
->mr
.r_irq_ctrl
);
1451 spin_unlock_irqrestore(&hw
->lock
, flags
);
1453 for (i
= hw
->driver_data
.max_st_ports
- 1; i
>= 0; i
--) {
1454 hw
->l1
[i
].enabled
= 0;
1455 hisax_unregister(&hw
->l1
[i
].d_if
);
1456 del_timer(&hw
->l1
[i
].l1_timer
);
1457 skb_queue_purge(&hw
->l1
[i
].d_tx_queue
);
1458 skb_queue_purge(&hw
->l1
[i
].b_ch
[0].tx_queue
);
1459 skb_queue_purge(&hw
->l1
[i
].b_ch
[1].tx_queue
);
1463 } /* hfc_hardware_enable */
1465 /******************************************/
1466 /* disable memory mapped ports / io ports */
1467 /******************************************/
1469 release_pci_ports(hfc4s8s_hw
* hw
)
1471 pci_write_config_word(hw
->pdev
, PCI_COMMAND
, 0);
1472 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
1474 iounmap((void *) hw
->membase
);
1477 release_region(hw
->iobase
, 8);
1481 /*****************************************/
1482 /* enable memory mapped ports / io ports */
1483 /*****************************************/
1485 enable_pci_ports(hfc4s8s_hw
* hw
)
1487 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
1488 pci_write_config_word(hw
->pdev
, PCI_COMMAND
, PCI_ENA_MEMIO
);
1490 pci_write_config_word(hw
->pdev
, PCI_COMMAND
, PCI_ENA_REGIO
);
1494 /*************************************/
1495 /* initialise the HFC-4s/8s hardware */
1496 /* return 0 on success. */
1497 /*************************************/
1498 static int __devinit
1499 setup_instance(hfc4s8s_hw
* hw
)
1504 for (i
= 0; i
< HFC_MAX_ST
; i
++) {
1505 struct hfc4s8s_l1
*l1p
;
1508 spin_lock_init(&l1p
->lock
);
1510 l1p
->l1_timer
.function
= (void *) hfc_l1_timer
;
1511 l1p
->l1_timer
.data
= (long) (l1p
);
1512 init_timer(&l1p
->l1_timer
);
1514 skb_queue_head_init(&l1p
->d_tx_queue
);
1515 l1p
->d_if
.ifc
.priv
= hw
->l1
+ i
;
1516 l1p
->d_if
.ifc
.l2l1
= (void *) dch_l2l1
;
1518 spin_lock_init(&l1p
->b_ch
[0].lock
);
1519 l1p
->b_ch
[0].b_if
.ifc
.l2l1
= (void *) bch_l2l1
;
1520 l1p
->b_ch
[0].b_if
.ifc
.priv
= (void *) &l1p
->b_ch
[0];
1521 l1p
->b_ch
[0].l1p
= hw
->l1
+ i
;
1522 l1p
->b_ch
[0].bchan
= 1;
1523 l1p
->b_table
[0] = &l1p
->b_ch
[0].b_if
;
1524 skb_queue_head_init(&l1p
->b_ch
[0].tx_queue
);
1526 spin_lock_init(&l1p
->b_ch
[1].lock
);
1527 l1p
->b_ch
[1].b_if
.ifc
.l2l1
= (void *) bch_l2l1
;
1528 l1p
->b_ch
[1].b_if
.ifc
.priv
= (void *) &l1p
->b_ch
[1];
1529 l1p
->b_ch
[1].l1p
= hw
->l1
+ i
;
1530 l1p
->b_ch
[1].bchan
= 2;
1531 l1p
->b_table
[1] = &l1p
->b_ch
[1].b_if
;
1532 skb_queue_head_init(&l1p
->b_ch
[1].tx_queue
);
1535 enable_pci_ports(hw
);
1538 i
= Read_hfc8(hw
, R_CHIP_ID
) >> CHIP_ID_SHIFT
;
1539 if (i
!= hw
->driver_data
.chip_id
) {
1541 "HFC-4S/8S: invalid chip id 0x%x instead of 0x%x, card ignored\n",
1542 i
, hw
->driver_data
.chip_id
);
1546 i
= Read_hfc8(hw
, R_CHIP_RV
) & 0xf;
1549 "HFC-4S/8S: chip revision 0 not supported, card ignored\n");
1553 INIT_WORK(&hw
->tqueue
, (void *) (void *) hfc4s8s_bh
, hw
);
1556 (hw
->irq
, hfc4s8s_interrupt
, SA_SHIRQ
, hw
->card_name
, hw
)) {
1558 "HFC-4S/8S: unable to alloc irq %d, card ignored\n",
1562 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
1564 "HFC-4S/8S: found PCI card at membase 0x%p, irq %d\n",
1565 hw
->hw_membase
, hw
->irq
);
1568 "HFC-4S/8S: found PCI card at iobase 0x%x, irq %d\n",
1569 hw
->iobase
, hw
->irq
);
1572 hfc_hardware_enable(hw
, 1, 0);
1578 release_pci_ports(hw
);
1583 /*****************************************/
1584 /* PCI hotplug interface: probe new card */
1585 /*****************************************/
1586 static int __devinit
1587 hfc4s8s_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
1590 hfc4s8s_param
*driver_data
= (hfc4s8s_param
*) ent
->driver_data
;
1593 if (!(hw
= kmalloc(sizeof(hfc4s8s_hw
), GFP_ATOMIC
))) {
1594 printk(KERN_ERR
"No kmem for HFC-4S/8S card\n");
1597 memset(hw
, 0, sizeof(hfc4s8s_hw
));
1600 err
= pci_enable_device(pdev
);
1605 hw
->cardnum
= card_cnt
;
1606 sprintf(hw
->card_name
, "hfc4s8s_%d", hw
->cardnum
);
1607 printk(KERN_INFO
"HFC-4S/8S: found adapter %s (%s) at %s\n",
1608 driver_data
->device_name
, hw
->card_name
, pci_name(pdev
));
1610 spin_lock_init(&hw
->lock
);
1612 hw
->driver_data
= *driver_data
;
1613 hw
->irq
= pdev
->irq
;
1614 hw
->iobase
= pci_resource_start(pdev
, 0);
1616 #ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
1617 hw
->hw_membase
= (u_char
*) pci_resource_start(pdev
, 1);
1618 hw
->membase
= ioremap((ulong
) hw
->hw_membase
, 256);
1620 if (!request_region(hw
->iobase
, 8, hw
->card_name
)) {
1622 "HFC-4S/8S: failed to rquest address space at 0x%04x\n",
1628 pci_set_drvdata(pdev
, hw
);
1629 err
= setup_instance(hw
);
1639 /**************************************/
1640 /* PCI hotplug interface: remove card */
1641 /**************************************/
1642 static void __devexit
1643 hfc4s8s_remove(struct pci_dev
*pdev
)
1645 hfc4s8s_hw
*hw
= pci_get_drvdata(pdev
);
1647 printk(KERN_INFO
"HFC-4S/8S: removing card %d\n", hw
->cardnum
);
1648 hfc_hardware_enable(hw
, 0, 0);
1651 free_irq(hw
->irq
, hw
);
1653 release_pci_ports(hw
);
1656 pci_disable_device(pdev
);
1661 static struct pci_driver hfc4s8s_driver
= {
1663 probe
:hfc4s8s_probe
,
1664 remove
:__devexit_p(hfc4s8s_remove
),
1665 id_table
:hfc4s8s_ids
,
1668 /**********************/
1669 /* driver Module init */
1670 /**********************/
1672 hfc4s8s_module_init(void)
1677 "HFC-4S/8S: Layer 1 driver module for HFC-4S/8S isdn chips, %s\n",
1680 "HFC-4S/8S: (C) 2003 Cornelius Consult, www.cornelius-consult.de\n");
1684 err
= pci_register_driver(&hfc4s8s_driver
);
1688 printk(KERN_INFO
"HFC-4S/8S: found %d cards\n", card_cnt
);
1690 #if !defined(CONFIG_HOTPLUG)
1693 pci_unregister_driver(&hfc4s8s_driver
);
1701 } /* hfc4s8s_init_hw */
1703 /*************************************/
1704 /* driver module exit : */
1705 /* release the HFC-4s/8s hardware */
1706 /*************************************/
1708 hfc4s8s_module_exit(void)
1710 pci_unregister_driver(&hfc4s8s_driver
);
1711 printk(KERN_INFO
"HFC-4S/8S: module removed\n");
1712 } /* hfc4s8s_release_hw */
1714 module_init(hfc4s8s_module_init
);
1715 module_exit(hfc4s8s_module_exit
);