2 * wanXL serial card driver for Linux
5 * Copyright (C) 2003 Krzysztof Halasa <khc@pm.waw.pl>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License
9 * as published by the Free Software Foundation.
12 * - Only DTE (external clock) support with NRZ and NRZI encodings
13 * - wanXL100 will require minor driver modifications, no access to hw
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/slab.h>
19 #include <linux/sched.h>
20 #include <linux/types.h>
21 #include <linux/fcntl.h>
22 #include <linux/string.h>
23 #include <linux/errno.h>
24 #include <linux/init.h>
25 #include <linux/ioport.h>
26 #include <linux/netdevice.h>
27 #include <linux/hdlc.h>
28 #include <linux/pci.h>
29 #include <linux/dma-mapping.h>
30 #include <linux/delay.h>
35 static const char* version
= "wanXL serial card driver version: 0.48";
37 #define PLX_CTL_RESET 0x40000000 /* adapter reset */
42 /* MAILBOX #1 - PUTS COMMANDS */
43 #define MBX1_CMD_ABORTJ 0x85000000 /* Abort and Jump */
44 #ifdef __LITTLE_ENDIAN
45 #define MBX1_CMD_BSWAP 0x8C000001 /* little-endian Byte Swap Mode */
47 #define MBX1_CMD_BSWAP 0x8C000000 /* big-endian Byte Swap Mode */
50 /* MAILBOX #2 - DRAM SIZE */
51 #define MBX2_MEMSZ_MASK 0xFFFF0000 /* PUTS Memory Size Register mask */
55 struct net_device
*dev
;
57 spinlock_t lock
; /* for wanxl_xmit */
58 int node
; /* physical port #0 - 3 */
59 unsigned int clock_type
;
61 struct sk_buff
*tx_skbs
[TX_BUFFERS
];
66 desc_t rx_descs
[RX_QUEUE_LENGTH
];
67 port_status_t port_status
[4];
71 typedef struct card_t
{
72 int n_ports
; /* 1, 2 or 4 ports */
75 u8 __iomem
*plx
; /* PLX PCI9060 virtual base address */
76 struct pci_dev
*pdev
; /* for pci_name(pdev) */
78 struct sk_buff
*rx_skbs
[RX_QUEUE_LENGTH
];
79 card_status_t
*status
; /* shared between host and card */
80 dma_addr_t status_address
;
81 port_t ports
[0]; /* 1 - 4 port_t structures follow */
86 static inline port_t
* dev_to_port(struct net_device
*dev
)
88 return (port_t
*)dev_to_hdlc(dev
)->priv
;
92 static inline port_status_t
* get_status(port_t
*port
)
94 return &port
->card
->status
->port_status
[port
->node
];
99 static inline dma_addr_t
pci_map_single_debug(struct pci_dev
*pdev
, void *ptr
,
100 size_t size
, int direction
)
102 dma_addr_t addr
= pci_map_single(pdev
, ptr
, size
, direction
);
103 if (addr
+ size
> 0x100000000LL
)
104 printk(KERN_CRIT
"wanXL %s: pci_map_single() returned memory"
105 " at 0x%LX!\n", pci_name(pdev
),
106 (unsigned long long)addr
);
110 #undef pci_map_single
111 #define pci_map_single pci_map_single_debug
115 /* Cable and/or personality module change interrupt service */
116 static inline void wanxl_cable_intr(port_t
*port
)
118 u32 value
= get_status(port
)->cable
;
120 const char *cable
, *pm
, *dte
= "", *dsr
= "", *dcd
= "";
122 switch(value
& 0x7) {
123 case STATUS_CABLE_V35
: cable
= "V.35"; break;
124 case STATUS_CABLE_X21
: cable
= "X.21"; break;
125 case STATUS_CABLE_V24
: cable
= "V.24"; break;
126 case STATUS_CABLE_EIA530
: cable
= "EIA530"; break;
127 case STATUS_CABLE_NONE
: cable
= "no"; break;
128 default: cable
= "invalid";
131 switch((value
>> STATUS_CABLE_PM_SHIFT
) & 0x7) {
132 case STATUS_CABLE_V35
: pm
= "V.35"; break;
133 case STATUS_CABLE_X21
: pm
= "X.21"; break;
134 case STATUS_CABLE_V24
: pm
= "V.24"; break;
135 case STATUS_CABLE_EIA530
: pm
= "EIA530"; break;
136 case STATUS_CABLE_NONE
: pm
= "no personality"; valid
= 0; break;
137 default: pm
= "invalid personality"; valid
= 0;
141 if ((value
& 7) == ((value
>> STATUS_CABLE_PM_SHIFT
) & 7)) {
142 dsr
= (value
& STATUS_CABLE_DSR
) ? ", DSR ON" :
144 dcd
= (value
& STATUS_CABLE_DCD
) ? ", carrier ON" :
147 dte
= (value
& STATUS_CABLE_DCE
) ? " DCE" : " DTE";
149 printk(KERN_INFO
"%s: %s%s module, %s cable%s%s\n",
150 port
->dev
->name
, pm
, dte
, cable
, dsr
, dcd
);
152 if (value
& STATUS_CABLE_DCD
)
153 netif_carrier_on(port
->dev
);
155 netif_carrier_off(port
->dev
);
160 /* Transmit complete interrupt service */
161 static inline void wanxl_tx_intr(port_t
*port
)
163 struct net_device
*dev
= port
->dev
;
165 desc_t
*desc
= &get_status(port
)->tx_descs
[port
->tx_in
];
166 struct sk_buff
*skb
= port
->tx_skbs
[port
->tx_in
];
168 switch (desc
->stat
) {
171 netif_wake_queue(dev
);
174 case PACKET_UNDERRUN
:
175 dev
->stats
.tx_errors
++;
176 dev
->stats
.tx_fifo_errors
++;
180 dev
->stats
.tx_packets
++;
181 dev
->stats
.tx_bytes
+= skb
->len
;
183 desc
->stat
= PACKET_EMPTY
; /* Free descriptor */
184 pci_unmap_single(port
->card
->pdev
, desc
->address
, skb
->len
,
186 dev_kfree_skb_irq(skb
);
187 port
->tx_in
= (port
->tx_in
+ 1) % TX_BUFFERS
;
193 /* Receive complete interrupt service */
194 static inline void wanxl_rx_intr(card_t
*card
)
197 while (desc
= &card
->status
->rx_descs
[card
->rx_in
],
198 desc
->stat
!= PACKET_EMPTY
) {
199 if ((desc
->stat
& PACKET_PORT_MASK
) > card
->n_ports
)
200 printk(KERN_CRIT
"wanXL %s: received packet for"
201 " nonexistent port\n", pci_name(card
->pdev
));
203 struct sk_buff
*skb
= card
->rx_skbs
[card
->rx_in
];
204 port_t
*port
= &card
->ports
[desc
->stat
&
206 struct net_device
*dev
= port
->dev
;
209 dev
->stats
.rx_dropped
++;
211 pci_unmap_single(card
->pdev
, desc
->address
,
214 skb_put(skb
, desc
->length
);
217 printk(KERN_DEBUG
"%s RX(%i):", dev
->name
,
221 dev
->stats
.rx_packets
++;
222 dev
->stats
.rx_bytes
+= skb
->len
;
223 skb
->protocol
= hdlc_type_trans(skb
, dev
);
229 skb
= dev_alloc_skb(BUFFER_LENGTH
);
230 desc
->address
= skb
?
231 pci_map_single(card
->pdev
, skb
->data
,
233 PCI_DMA_FROMDEVICE
) : 0;
234 card
->rx_skbs
[card
->rx_in
] = skb
;
237 desc
->stat
= PACKET_EMPTY
; /* Free descriptor */
238 card
->rx_in
= (card
->rx_in
+ 1) % RX_QUEUE_LENGTH
;
244 static irqreturn_t
wanxl_intr(int irq
, void* dev_id
)
246 card_t
*card
= dev_id
;
252 while((stat
= readl(card
->plx
+ PLX_DOORBELL_FROM_CARD
)) != 0) {
254 writel(stat
, card
->plx
+ PLX_DOORBELL_FROM_CARD
);
256 for (i
= 0; i
< card
->n_ports
; i
++) {
257 if (stat
& (1 << (DOORBELL_FROM_CARD_TX_0
+ i
)))
258 wanxl_tx_intr(&card
->ports
[i
]);
259 if (stat
& (1 << (DOORBELL_FROM_CARD_CABLE_0
+ i
)))
260 wanxl_cable_intr(&card
->ports
[i
]);
262 if (stat
& (1 << DOORBELL_FROM_CARD_RX
))
266 return IRQ_RETVAL(handled
);
271 static int wanxl_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
273 port_t
*port
= dev_to_port(dev
);
276 spin_lock(&port
->lock
);
278 desc
= &get_status(port
)->tx_descs
[port
->tx_out
];
279 if (desc
->stat
!= PACKET_EMPTY
) {
280 /* should never happen - previous xmit should stop queue */
282 printk(KERN_DEBUG
"%s: transmitter buffer full\n", dev
->name
);
284 netif_stop_queue(dev
);
285 spin_unlock_irq(&port
->lock
);
286 return 1; /* request packet to be queued */
290 printk(KERN_DEBUG
"%s TX(%i):", dev
->name
, skb
->len
);
294 port
->tx_skbs
[port
->tx_out
] = skb
;
295 desc
->address
= pci_map_single(port
->card
->pdev
, skb
->data
, skb
->len
,
297 desc
->length
= skb
->len
;
298 desc
->stat
= PACKET_FULL
;
299 writel(1 << (DOORBELL_TO_CARD_TX_0
+ port
->node
),
300 port
->card
->plx
+ PLX_DOORBELL_TO_CARD
);
301 dev
->trans_start
= jiffies
;
303 port
->tx_out
= (port
->tx_out
+ 1) % TX_BUFFERS
;
305 if (get_status(port
)->tx_descs
[port
->tx_out
].stat
!= PACKET_EMPTY
) {
306 netif_stop_queue(dev
);
308 printk(KERN_DEBUG
"%s: transmitter buffer full\n", dev
->name
);
312 spin_unlock(&port
->lock
);
318 static int wanxl_attach(struct net_device
*dev
, unsigned short encoding
,
319 unsigned short parity
)
321 port_t
*port
= dev_to_port(dev
);
323 if (encoding
!= ENCODING_NRZ
&&
324 encoding
!= ENCODING_NRZI
)
327 if (parity
!= PARITY_NONE
&&
328 parity
!= PARITY_CRC32_PR1_CCITT
&&
329 parity
!= PARITY_CRC16_PR1_CCITT
&&
330 parity
!= PARITY_CRC32_PR0_CCITT
&&
331 parity
!= PARITY_CRC16_PR0_CCITT
)
334 get_status(port
)->encoding
= encoding
;
335 get_status(port
)->parity
= parity
;
341 static int wanxl_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
343 const size_t size
= sizeof(sync_serial_settings
);
344 sync_serial_settings line
;
345 port_t
*port
= dev_to_port(dev
);
347 if (cmd
!= SIOCWANDEV
)
348 return hdlc_ioctl(dev
, ifr
, cmd
);
350 switch (ifr
->ifr_settings
.type
) {
352 ifr
->ifr_settings
.type
= IF_IFACE_SYNC_SERIAL
;
353 if (ifr
->ifr_settings
.size
< size
) {
354 ifr
->ifr_settings
.size
= size
; /* data size wanted */
357 line
.clock_type
= get_status(port
)->clocking
;
361 if (copy_to_user(ifr
->ifr_settings
.ifs_ifsu
.sync
, &line
, size
))
365 case IF_IFACE_SYNC_SERIAL
:
366 if (!capable(CAP_NET_ADMIN
))
368 if (dev
->flags
& IFF_UP
)
371 if (copy_from_user(&line
, ifr
->ifr_settings
.ifs_ifsu
.sync
,
375 if (line
.clock_type
!= CLOCK_EXT
&&
376 line
.clock_type
!= CLOCK_TXFROMRX
)
377 return -EINVAL
; /* No such clock setting */
379 if (line
.loopback
!= 0)
382 get_status(port
)->clocking
= line
.clock_type
;
386 return hdlc_ioctl(dev
, ifr
, cmd
);
392 static int wanxl_open(struct net_device
*dev
)
394 port_t
*port
= dev_to_port(dev
);
395 u8 __iomem
*dbr
= port
->card
->plx
+ PLX_DOORBELL_TO_CARD
;
396 unsigned long timeout
;
399 if (get_status(port
)->open
) {
400 printk(KERN_ERR
"%s: port already open\n", dev
->name
);
403 if ((i
= hdlc_open(dev
)) != 0)
406 port
->tx_in
= port
->tx_out
= 0;
407 for (i
= 0; i
< TX_BUFFERS
; i
++)
408 get_status(port
)->tx_descs
[i
].stat
= PACKET_EMPTY
;
409 /* signal the card */
410 writel(1 << (DOORBELL_TO_CARD_OPEN_0
+ port
->node
), dbr
);
412 timeout
= jiffies
+ HZ
;
414 if (get_status(port
)->open
) {
415 netif_start_queue(dev
);
418 } while (time_after(timeout
, jiffies
));
420 printk(KERN_ERR
"%s: unable to open port\n", dev
->name
);
421 /* ask the card to close the port, should it be still alive */
422 writel(1 << (DOORBELL_TO_CARD_CLOSE_0
+ port
->node
), dbr
);
428 static int wanxl_close(struct net_device
*dev
)
430 port_t
*port
= dev_to_port(dev
);
431 unsigned long timeout
;
435 /* signal the card */
436 writel(1 << (DOORBELL_TO_CARD_CLOSE_0
+ port
->node
),
437 port
->card
->plx
+ PLX_DOORBELL_TO_CARD
);
439 timeout
= jiffies
+ HZ
;
441 if (!get_status(port
)->open
)
443 } while (time_after(timeout
, jiffies
));
445 if (get_status(port
)->open
)
446 printk(KERN_ERR
"%s: unable to close port\n", dev
->name
);
448 netif_stop_queue(dev
);
450 for (i
= 0; i
< TX_BUFFERS
; i
++) {
451 desc_t
*desc
= &get_status(port
)->tx_descs
[i
];
453 if (desc
->stat
!= PACKET_EMPTY
) {
454 desc
->stat
= PACKET_EMPTY
;
455 pci_unmap_single(port
->card
->pdev
, desc
->address
,
456 port
->tx_skbs
[i
]->len
,
458 dev_kfree_skb(port
->tx_skbs
[i
]);
466 static struct net_device_stats
*wanxl_get_stats(struct net_device
*dev
)
468 port_t
*port
= dev_to_port(dev
);
470 dev
->stats
.rx_over_errors
= get_status(port
)->rx_overruns
;
471 dev
->stats
.rx_frame_errors
= get_status(port
)->rx_frame_errors
;
472 dev
->stats
.rx_errors
= dev
->stats
.rx_over_errors
+
473 dev
->stats
.rx_frame_errors
;
479 static int wanxl_puts_command(card_t
*card
, u32 cmd
)
481 unsigned long timeout
= jiffies
+ 5 * HZ
;
483 writel(cmd
, card
->plx
+ PLX_MAILBOX_1
);
485 if (readl(card
->plx
+ PLX_MAILBOX_1
) == 0)
489 }while (time_after(timeout
, jiffies
));
496 static void wanxl_reset(card_t
*card
)
498 u32 old_value
= readl(card
->plx
+ PLX_CONTROL
) & ~PLX_CTL_RESET
;
500 writel(0x80, card
->plx
+ PLX_MAILBOX_0
);
501 writel(old_value
| PLX_CTL_RESET
, card
->plx
+ PLX_CONTROL
);
502 readl(card
->plx
+ PLX_CONTROL
); /* wait for posted write */
504 writel(old_value
, card
->plx
+ PLX_CONTROL
);
505 readl(card
->plx
+ PLX_CONTROL
); /* wait for posted write */
510 static void wanxl_pci_remove_one(struct pci_dev
*pdev
)
512 card_t
*card
= pci_get_drvdata(pdev
);
515 for (i
= 0; i
< card
->n_ports
; i
++) {
516 unregister_hdlc_device(card
->ports
[i
].dev
);
517 free_netdev(card
->ports
[i
].dev
);
520 /* unregister and free all host resources */
522 free_irq(card
->irq
, card
);
526 for (i
= 0; i
< RX_QUEUE_LENGTH
; i
++)
527 if (card
->rx_skbs
[i
]) {
528 pci_unmap_single(card
->pdev
,
529 card
->status
->rx_descs
[i
].address
,
530 BUFFER_LENGTH
, PCI_DMA_FROMDEVICE
);
531 dev_kfree_skb(card
->rx_skbs
[i
]);
538 pci_free_consistent(pdev
, sizeof(card_status_t
),
539 card
->status
, card
->status_address
);
541 pci_release_regions(pdev
);
542 pci_disable_device(pdev
);
543 pci_set_drvdata(pdev
, NULL
);
548 #include "wanxlfw.inc"
550 static const struct net_device_ops wanxl_ops
= {
551 .ndo_open
= wanxl_open
,
552 .ndo_stop
= wanxl_close
,
553 .ndo_change_mtu
= hdlc_change_mtu
,
554 .ndo_start_xmit
= hdlc_start_xmit
,
555 .ndo_do_ioctl
= wanxl_ioctl
,
556 .ndo_get_stats
= wanxl_get_stats
,
559 static int __devinit
wanxl_pci_init_one(struct pci_dev
*pdev
,
560 const struct pci_device_id
*ent
)
564 unsigned long timeout
;
565 u32 plx_phy
; /* PLX PCI base address */
566 u32 mem_phy
; /* memory PCI base addr */
567 u8 __iomem
*mem
; /* memory virtual base addr */
568 int i
, ports
, alloc_size
;
571 static int printed_version
;
572 if (!printed_version
) {
574 printk(KERN_INFO
"%s\n", version
);
578 i
= pci_enable_device(pdev
);
582 /* QUICC can only access first 256 MB of host RAM directly,
583 but PLX9060 DMA does 32-bits for actual packet data transfers */
585 /* FIXME when PCI/DMA subsystems are fixed.
586 We set both dma_mask and consistent_dma_mask to 28 bits
587 and pray pci_alloc_consistent() will use this info. It should
588 work on most platforms */
589 if (pci_set_consistent_dma_mask(pdev
, DMA_28BIT_MASK
) ||
590 pci_set_dma_mask(pdev
, DMA_28BIT_MASK
)) {
591 printk(KERN_ERR
"wanXL: No usable DMA configuration\n");
595 i
= pci_request_regions(pdev
, "wanXL");
597 pci_disable_device(pdev
);
601 switch (pdev
->device
) {
602 case PCI_DEVICE_ID_SBE_WANXL100
: ports
= 1; break;
603 case PCI_DEVICE_ID_SBE_WANXL200
: ports
= 2; break;
607 alloc_size
= sizeof(card_t
) + ports
* sizeof(port_t
);
608 card
= kzalloc(alloc_size
, GFP_KERNEL
);
610 printk(KERN_ERR
"wanXL %s: unable to allocate memory\n",
612 pci_release_regions(pdev
);
613 pci_disable_device(pdev
);
617 pci_set_drvdata(pdev
, card
);
620 card
->status
= pci_alloc_consistent(pdev
, sizeof(card_status_t
),
621 &card
->status_address
);
622 if (card
->status
== NULL
) {
623 wanxl_pci_remove_one(pdev
);
628 printk(KERN_DEBUG
"wanXL %s: pci_alloc_consistent() returned memory"
629 " at 0x%LX\n", pci_name(pdev
),
630 (unsigned long long)card
->status_address
);
633 /* FIXME when PCI/DMA subsystems are fixed.
634 We set both dma_mask and consistent_dma_mask back to 32 bits
635 to indicate the card can do 32-bit DMA addressing */
636 if (pci_set_consistent_dma_mask(pdev
, DMA_BIT_MASK(32)) ||
637 pci_set_dma_mask(pdev
, DMA_BIT_MASK(32))) {
638 printk(KERN_ERR
"wanXL: No usable DMA configuration\n");
639 wanxl_pci_remove_one(pdev
);
643 /* set up PLX mapping */
644 plx_phy
= pci_resource_start(pdev
, 0);
646 card
->plx
= ioremap_nocache(plx_phy
, 0x70);
648 printk(KERN_ERR
"wanxl: ioremap() failed\n");
649 wanxl_pci_remove_one(pdev
);
653 #if RESET_WHILE_LOADING
657 timeout
= jiffies
+ 20 * HZ
;
658 while ((stat
= readl(card
->plx
+ PLX_MAILBOX_0
)) != 0) {
659 if (time_before(timeout
, jiffies
)) {
660 printk(KERN_WARNING
"wanXL %s: timeout waiting for"
661 " PUTS to complete\n", pci_name(pdev
));
662 wanxl_pci_remove_one(pdev
);
666 switch(stat
& 0xC0) {
667 case 0x00: /* hmm - PUTS completed with non-zero code? */
668 case 0x80: /* PUTS still testing the hardware */
672 printk(KERN_WARNING
"wanXL %s: PUTS test 0x%X"
673 " failed\n", pci_name(pdev
), stat
& 0x30);
674 wanxl_pci_remove_one(pdev
);
681 /* get on-board memory size (PUTS detects no more than 4 MB) */
682 ramsize
= readl(card
->plx
+ PLX_MAILBOX_2
) & MBX2_MEMSZ_MASK
;
684 /* set up on-board RAM mapping */
685 mem_phy
= pci_resource_start(pdev
, 2);
688 /* sanity check the board's reported memory size */
689 if (ramsize
< BUFFERS_ADDR
+
690 (TX_BUFFERS
+ RX_BUFFERS
) * BUFFER_LENGTH
* ports
) {
691 printk(KERN_WARNING
"wanXL %s: no enough on-board RAM"
692 " (%u bytes detected, %u bytes required)\n",
693 pci_name(pdev
), ramsize
, BUFFERS_ADDR
+
694 (TX_BUFFERS
+ RX_BUFFERS
) * BUFFER_LENGTH
* ports
);
695 wanxl_pci_remove_one(pdev
);
699 if (wanxl_puts_command(card
, MBX1_CMD_BSWAP
)) {
700 printk(KERN_WARNING
"wanXL %s: unable to Set Byte Swap"
701 " Mode\n", pci_name(pdev
));
702 wanxl_pci_remove_one(pdev
);
706 for (i
= 0; i
< RX_QUEUE_LENGTH
; i
++) {
707 struct sk_buff
*skb
= dev_alloc_skb(BUFFER_LENGTH
);
708 card
->rx_skbs
[i
] = skb
;
710 card
->status
->rx_descs
[i
].address
=
711 pci_map_single(card
->pdev
, skb
->data
,
716 mem
= ioremap_nocache(mem_phy
, PDM_OFFSET
+ sizeof(firmware
));
718 printk(KERN_ERR
"wanxl: ioremap() failed\n");
719 wanxl_pci_remove_one(pdev
);
723 for (i
= 0; i
< sizeof(firmware
); i
+= 4)
724 writel(ntohl(*(__be32
*)(firmware
+ i
)), mem
+ PDM_OFFSET
+ i
);
726 for (i
= 0; i
< ports
; i
++)
727 writel(card
->status_address
+
728 (void *)&card
->status
->port_status
[i
] -
729 (void *)card
->status
, mem
+ PDM_OFFSET
+ 4 + i
* 4);
730 writel(card
->status_address
, mem
+ PDM_OFFSET
+ 20);
731 writel(PDM_OFFSET
, mem
);
734 writel(0, card
->plx
+ PLX_MAILBOX_5
);
736 if (wanxl_puts_command(card
, MBX1_CMD_ABORTJ
)) {
737 printk(KERN_WARNING
"wanXL %s: unable to Abort and Jump\n",
739 wanxl_pci_remove_one(pdev
);
744 timeout
= jiffies
+ 5 * HZ
;
746 if ((stat
= readl(card
->plx
+ PLX_MAILBOX_5
)) != 0)
749 }while (time_after(timeout
, jiffies
));
752 printk(KERN_WARNING
"wanXL %s: timeout while initializing card "
753 "firmware\n", pci_name(pdev
));
754 wanxl_pci_remove_one(pdev
);
762 printk(KERN_INFO
"wanXL %s: at 0x%X, %u KB of RAM at 0x%X, irq %u\n",
763 pci_name(pdev
), plx_phy
, ramsize
/ 1024, mem_phy
, pdev
->irq
);
766 if (request_irq(pdev
->irq
, wanxl_intr
, IRQF_SHARED
, "wanXL", card
)) {
767 printk(KERN_WARNING
"wanXL %s: could not allocate IRQ%i.\n",
768 pci_name(pdev
), pdev
->irq
);
769 wanxl_pci_remove_one(pdev
);
772 card
->irq
= pdev
->irq
;
774 for (i
= 0; i
< ports
; i
++) {
776 port_t
*port
= &card
->ports
[i
];
777 struct net_device
*dev
= alloc_hdlcdev(port
);
779 printk(KERN_ERR
"wanXL %s: unable to allocate"
780 " memory\n", pci_name(pdev
));
781 wanxl_pci_remove_one(pdev
);
786 hdlc
= dev_to_hdlc(dev
);
787 spin_lock_init(&port
->lock
);
788 dev
->tx_queue_len
= 50;
789 dev
->netdev_ops
= &wanxl_ops
;
790 hdlc
->attach
= wanxl_attach
;
791 hdlc
->xmit
= wanxl_xmit
;
794 get_status(port
)->clocking
= CLOCK_EXT
;
795 if (register_hdlc_device(dev
)) {
796 printk(KERN_ERR
"wanXL %s: unable to register hdlc"
797 " device\n", pci_name(pdev
));
799 wanxl_pci_remove_one(pdev
);
805 printk(KERN_INFO
"wanXL %s: port", pci_name(pdev
));
806 for (i
= 0; i
< ports
; i
++)
807 printk("%s #%i: %s", i
? "," : "", i
,
808 card
->ports
[i
].dev
->name
);
811 for (i
= 0; i
< ports
; i
++)
812 wanxl_cable_intr(&card
->ports
[i
]); /* get carrier status etc.*/
817 static struct pci_device_id wanxl_pci_tbl
[] __devinitdata
= {
818 { PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_SBE_WANXL100
, PCI_ANY_ID
,
819 PCI_ANY_ID
, 0, 0, 0 },
820 { PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_SBE_WANXL200
, PCI_ANY_ID
,
821 PCI_ANY_ID
, 0, 0, 0 },
822 { PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_SBE_WANXL400
, PCI_ANY_ID
,
823 PCI_ANY_ID
, 0, 0, 0 },
828 static struct pci_driver wanxl_pci_driver
= {
830 .id_table
= wanxl_pci_tbl
,
831 .probe
= wanxl_pci_init_one
,
832 .remove
= wanxl_pci_remove_one
,
836 static int __init
wanxl_init_module(void)
839 printk(KERN_INFO
"%s\n", version
);
841 return pci_register_driver(&wanxl_pci_driver
);
844 static void __exit
wanxl_cleanup_module(void)
846 pci_unregister_driver(&wanxl_pci_driver
);
850 MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
851 MODULE_DESCRIPTION("SBE Inc. wanXL serial port driver");
852 MODULE_LICENSE("GPL v2");
853 MODULE_DEVICE_TABLE(pci
, wanxl_pci_tbl
);
855 module_init(wanxl_init_module
);
856 module_exit(wanxl_cleanup_module
);