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
;
164 struct net_device_stats
*stats
= hdlc_stats(dev
);
166 desc_t
*desc
= &get_status(port
)->tx_descs
[port
->tx_in
];
167 struct sk_buff
*skb
= port
->tx_skbs
[port
->tx_in
];
169 switch (desc
->stat
) {
172 netif_wake_queue(dev
);
175 case PACKET_UNDERRUN
:
177 stats
->tx_fifo_errors
++;
182 stats
->tx_bytes
+= skb
->len
;
184 desc
->stat
= PACKET_EMPTY
; /* Free descriptor */
185 pci_unmap_single(port
->card
->pdev
, desc
->address
, skb
->len
,
187 dev_kfree_skb_irq(skb
);
188 port
->tx_in
= (port
->tx_in
+ 1) % TX_BUFFERS
;
194 /* Receive complete interrupt service */
195 static inline void wanxl_rx_intr(card_t
*card
)
198 while (desc
= &card
->status
->rx_descs
[card
->rx_in
],
199 desc
->stat
!= PACKET_EMPTY
) {
200 if ((desc
->stat
& PACKET_PORT_MASK
) > card
->n_ports
)
201 printk(KERN_CRIT
"wanXL %s: received packet for"
202 " nonexistent port\n", pci_name(card
->pdev
));
204 struct sk_buff
*skb
= card
->rx_skbs
[card
->rx_in
];
205 port_t
*port
= &card
->ports
[desc
->stat
&
207 struct net_device
*dev
= port
->dev
;
208 struct net_device_stats
*stats
= hdlc_stats(dev
);
213 pci_unmap_single(card
->pdev
, desc
->address
,
216 skb_put(skb
, desc
->length
);
219 printk(KERN_DEBUG
"%s RX(%i):", dev
->name
,
224 stats
->rx_bytes
+= skb
->len
;
225 dev
->last_rx
= jiffies
;
226 skb
->protocol
= hdlc_type_trans(skb
, dev
);
232 skb
= dev_alloc_skb(BUFFER_LENGTH
);
233 desc
->address
= skb
?
234 pci_map_single(card
->pdev
, skb
->data
,
236 PCI_DMA_FROMDEVICE
) : 0;
237 card
->rx_skbs
[card
->rx_in
] = skb
;
240 desc
->stat
= PACKET_EMPTY
; /* Free descriptor */
241 card
->rx_in
= (card
->rx_in
+ 1) % RX_QUEUE_LENGTH
;
247 static irqreturn_t
wanxl_intr(int irq
, void* dev_id
)
249 card_t
*card
= dev_id
;
255 while((stat
= readl(card
->plx
+ PLX_DOORBELL_FROM_CARD
)) != 0) {
257 writel(stat
, card
->plx
+ PLX_DOORBELL_FROM_CARD
);
259 for (i
= 0; i
< card
->n_ports
; i
++) {
260 if (stat
& (1 << (DOORBELL_FROM_CARD_TX_0
+ i
)))
261 wanxl_tx_intr(&card
->ports
[i
]);
262 if (stat
& (1 << (DOORBELL_FROM_CARD_CABLE_0
+ i
)))
263 wanxl_cable_intr(&card
->ports
[i
]);
265 if (stat
& (1 << DOORBELL_FROM_CARD_RX
))
269 return IRQ_RETVAL(handled
);
274 static int wanxl_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
276 port_t
*port
= dev_to_port(dev
);
279 spin_lock(&port
->lock
);
281 desc
= &get_status(port
)->tx_descs
[port
->tx_out
];
282 if (desc
->stat
!= PACKET_EMPTY
) {
283 /* should never happen - previous xmit should stop queue */
285 printk(KERN_DEBUG
"%s: transmitter buffer full\n", dev
->name
);
287 netif_stop_queue(dev
);
288 spin_unlock_irq(&port
->lock
);
289 return 1; /* request packet to be queued */
293 printk(KERN_DEBUG
"%s TX(%i):", dev
->name
, skb
->len
);
297 port
->tx_skbs
[port
->tx_out
] = skb
;
298 desc
->address
= pci_map_single(port
->card
->pdev
, skb
->data
, skb
->len
,
300 desc
->length
= skb
->len
;
301 desc
->stat
= PACKET_FULL
;
302 writel(1 << (DOORBELL_TO_CARD_TX_0
+ port
->node
),
303 port
->card
->plx
+ PLX_DOORBELL_TO_CARD
);
304 dev
->trans_start
= jiffies
;
306 port
->tx_out
= (port
->tx_out
+ 1) % TX_BUFFERS
;
308 if (get_status(port
)->tx_descs
[port
->tx_out
].stat
!= PACKET_EMPTY
) {
309 netif_stop_queue(dev
);
311 printk(KERN_DEBUG
"%s: transmitter buffer full\n", dev
->name
);
315 spin_unlock(&port
->lock
);
321 static int wanxl_attach(struct net_device
*dev
, unsigned short encoding
,
322 unsigned short parity
)
324 port_t
*port
= dev_to_port(dev
);
326 if (encoding
!= ENCODING_NRZ
&&
327 encoding
!= ENCODING_NRZI
)
330 if (parity
!= PARITY_NONE
&&
331 parity
!= PARITY_CRC32_PR1_CCITT
&&
332 parity
!= PARITY_CRC16_PR1_CCITT
&&
333 parity
!= PARITY_CRC32_PR0_CCITT
&&
334 parity
!= PARITY_CRC16_PR0_CCITT
)
337 get_status(port
)->encoding
= encoding
;
338 get_status(port
)->parity
= parity
;
344 static int wanxl_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
346 const size_t size
= sizeof(sync_serial_settings
);
347 sync_serial_settings line
;
348 port_t
*port
= dev_to_port(dev
);
350 if (cmd
!= SIOCWANDEV
)
351 return hdlc_ioctl(dev
, ifr
, cmd
);
353 switch (ifr
->ifr_settings
.type
) {
355 ifr
->ifr_settings
.type
= IF_IFACE_SYNC_SERIAL
;
356 if (ifr
->ifr_settings
.size
< size
) {
357 ifr
->ifr_settings
.size
= size
; /* data size wanted */
360 line
.clock_type
= get_status(port
)->clocking
;
364 if (copy_to_user(ifr
->ifr_settings
.ifs_ifsu
.sync
, &line
, size
))
368 case IF_IFACE_SYNC_SERIAL
:
369 if (!capable(CAP_NET_ADMIN
))
371 if (dev
->flags
& IFF_UP
)
374 if (copy_from_user(&line
, ifr
->ifr_settings
.ifs_ifsu
.sync
,
378 if (line
.clock_type
!= CLOCK_EXT
&&
379 line
.clock_type
!= CLOCK_TXFROMRX
)
380 return -EINVAL
; /* No such clock setting */
382 if (line
.loopback
!= 0)
385 get_status(port
)->clocking
= line
.clock_type
;
389 return hdlc_ioctl(dev
, ifr
, cmd
);
395 static int wanxl_open(struct net_device
*dev
)
397 port_t
*port
= dev_to_port(dev
);
398 u8 __iomem
*dbr
= port
->card
->plx
+ PLX_DOORBELL_TO_CARD
;
399 unsigned long timeout
;
402 if (get_status(port
)->open
) {
403 printk(KERN_ERR
"%s: port already open\n", dev
->name
);
406 if ((i
= hdlc_open(dev
)) != 0)
409 port
->tx_in
= port
->tx_out
= 0;
410 for (i
= 0; i
< TX_BUFFERS
; i
++)
411 get_status(port
)->tx_descs
[i
].stat
= PACKET_EMPTY
;
412 /* signal the card */
413 writel(1 << (DOORBELL_TO_CARD_OPEN_0
+ port
->node
), dbr
);
415 timeout
= jiffies
+ HZ
;
417 if (get_status(port
)->open
) {
418 netif_start_queue(dev
);
421 while (time_after(timeout
, jiffies
));
423 printk(KERN_ERR
"%s: unable to open port\n", dev
->name
);
424 /* ask the card to close the port, should it be still alive */
425 writel(1 << (DOORBELL_TO_CARD_CLOSE_0
+ port
->node
), dbr
);
431 static int wanxl_close(struct net_device
*dev
)
433 port_t
*port
= dev_to_port(dev
);
434 unsigned long timeout
;
438 /* signal the card */
439 writel(1 << (DOORBELL_TO_CARD_CLOSE_0
+ port
->node
),
440 port
->card
->plx
+ PLX_DOORBELL_TO_CARD
);
442 timeout
= jiffies
+ HZ
;
444 if (!get_status(port
)->open
)
446 while (time_after(timeout
, jiffies
));
448 if (get_status(port
)->open
)
449 printk(KERN_ERR
"%s: unable to close port\n", dev
->name
);
451 netif_stop_queue(dev
);
453 for (i
= 0; i
< TX_BUFFERS
; i
++) {
454 desc_t
*desc
= &get_status(port
)->tx_descs
[i
];
456 if (desc
->stat
!= PACKET_EMPTY
) {
457 desc
->stat
= PACKET_EMPTY
;
458 pci_unmap_single(port
->card
->pdev
, desc
->address
,
459 port
->tx_skbs
[i
]->len
,
461 dev_kfree_skb(port
->tx_skbs
[i
]);
469 static struct net_device_stats
*wanxl_get_stats(struct net_device
*dev
)
471 struct net_device_stats
*stats
= hdlc_stats(dev
);
472 port_t
*port
= dev_to_port(dev
);
474 stats
->rx_over_errors
= get_status(port
)->rx_overruns
;
475 stats
->rx_frame_errors
= get_status(port
)->rx_frame_errors
;
476 stats
->rx_errors
= stats
->rx_over_errors
+ stats
->rx_frame_errors
;
482 static int wanxl_puts_command(card_t
*card
, u32 cmd
)
484 unsigned long timeout
= jiffies
+ 5 * HZ
;
486 writel(cmd
, card
->plx
+ PLX_MAILBOX_1
);
488 if (readl(card
->plx
+ PLX_MAILBOX_1
) == 0)
492 }while (time_after(timeout
, jiffies
));
499 static void wanxl_reset(card_t
*card
)
501 u32 old_value
= readl(card
->plx
+ PLX_CONTROL
) & ~PLX_CTL_RESET
;
503 writel(0x80, card
->plx
+ PLX_MAILBOX_0
);
504 writel(old_value
| PLX_CTL_RESET
, card
->plx
+ PLX_CONTROL
);
505 readl(card
->plx
+ PLX_CONTROL
); /* wait for posted write */
507 writel(old_value
, card
->plx
+ PLX_CONTROL
);
508 readl(card
->plx
+ PLX_CONTROL
); /* wait for posted write */
513 static void wanxl_pci_remove_one(struct pci_dev
*pdev
)
515 card_t
*card
= pci_get_drvdata(pdev
);
518 for (i
= 0; i
< card
->n_ports
; i
++) {
519 unregister_hdlc_device(card
->ports
[i
].dev
);
520 free_netdev(card
->ports
[i
].dev
);
523 /* unregister and free all host resources */
525 free_irq(card
->irq
, card
);
529 for (i
= 0; i
< RX_QUEUE_LENGTH
; i
++)
530 if (card
->rx_skbs
[i
]) {
531 pci_unmap_single(card
->pdev
,
532 card
->status
->rx_descs
[i
].address
,
533 BUFFER_LENGTH
, PCI_DMA_FROMDEVICE
);
534 dev_kfree_skb(card
->rx_skbs
[i
]);
541 pci_free_consistent(pdev
, sizeof(card_status_t
),
542 card
->status
, card
->status_address
);
544 pci_release_regions(pdev
);
545 pci_disable_device(pdev
);
546 pci_set_drvdata(pdev
, NULL
);
551 #include "wanxlfw.inc"
553 static int __devinit
wanxl_pci_init_one(struct pci_dev
*pdev
,
554 const struct pci_device_id
*ent
)
558 unsigned long timeout
;
559 u32 plx_phy
; /* PLX PCI base address */
560 u32 mem_phy
; /* memory PCI base addr */
561 u8 __iomem
*mem
; /* memory virtual base addr */
562 int i
, ports
, alloc_size
;
565 static int printed_version
;
566 if (!printed_version
) {
568 printk(KERN_INFO
"%s\n", version
);
572 i
= pci_enable_device(pdev
);
576 /* QUICC can only access first 256 MB of host RAM directly,
577 but PLX9060 DMA does 32-bits for actual packet data transfers */
579 /* FIXME when PCI/DMA subsystems are fixed.
580 We set both dma_mask and consistent_dma_mask to 28 bits
581 and pray pci_alloc_consistent() will use this info. It should
582 work on most platforms */
583 if (pci_set_consistent_dma_mask(pdev
, DMA_28BIT_MASK
) ||
584 pci_set_dma_mask(pdev
, DMA_28BIT_MASK
)) {
585 printk(KERN_ERR
"wanXL: No usable DMA configuration\n");
589 i
= pci_request_regions(pdev
, "wanXL");
591 pci_disable_device(pdev
);
595 switch (pdev
->device
) {
596 case PCI_DEVICE_ID_SBE_WANXL100
: ports
= 1; break;
597 case PCI_DEVICE_ID_SBE_WANXL200
: ports
= 2; break;
601 alloc_size
= sizeof(card_t
) + ports
* sizeof(port_t
);
602 card
= kzalloc(alloc_size
, GFP_KERNEL
);
604 printk(KERN_ERR
"wanXL %s: unable to allocate memory\n",
606 pci_release_regions(pdev
);
607 pci_disable_device(pdev
);
611 pci_set_drvdata(pdev
, card
);
614 card
->status
= pci_alloc_consistent(pdev
, sizeof(card_status_t
),
615 &card
->status_address
);
616 if (card
->status
== NULL
) {
617 wanxl_pci_remove_one(pdev
);
622 printk(KERN_DEBUG
"wanXL %s: pci_alloc_consistent() returned memory"
623 " at 0x%LX\n", pci_name(pdev
),
624 (unsigned long long)card
->status_address
);
627 /* FIXME when PCI/DMA subsystems are fixed.
628 We set both dma_mask and consistent_dma_mask back to 32 bits
629 to indicate the card can do 32-bit DMA addressing */
630 if (pci_set_consistent_dma_mask(pdev
, DMA_32BIT_MASK
) ||
631 pci_set_dma_mask(pdev
, DMA_32BIT_MASK
)) {
632 printk(KERN_ERR
"wanXL: No usable DMA configuration\n");
633 wanxl_pci_remove_one(pdev
);
637 /* set up PLX mapping */
638 plx_phy
= pci_resource_start(pdev
, 0);
640 card
->plx
= ioremap_nocache(plx_phy
, 0x70);
642 printk(KERN_ERR
"wanxl: ioremap() failed\n");
643 wanxl_pci_remove_one(pdev
);
647 #if RESET_WHILE_LOADING
651 timeout
= jiffies
+ 20 * HZ
;
652 while ((stat
= readl(card
->plx
+ PLX_MAILBOX_0
)) != 0) {
653 if (time_before(timeout
, jiffies
)) {
654 printk(KERN_WARNING
"wanXL %s: timeout waiting for"
655 " PUTS to complete\n", pci_name(pdev
));
656 wanxl_pci_remove_one(pdev
);
660 switch(stat
& 0xC0) {
661 case 0x00: /* hmm - PUTS completed with non-zero code? */
662 case 0x80: /* PUTS still testing the hardware */
666 printk(KERN_WARNING
"wanXL %s: PUTS test 0x%X"
667 " failed\n", pci_name(pdev
), stat
& 0x30);
668 wanxl_pci_remove_one(pdev
);
675 /* get on-board memory size (PUTS detects no more than 4 MB) */
676 ramsize
= readl(card
->plx
+ PLX_MAILBOX_2
) & MBX2_MEMSZ_MASK
;
678 /* set up on-board RAM mapping */
679 mem_phy
= pci_resource_start(pdev
, 2);
682 /* sanity check the board's reported memory size */
683 if (ramsize
< BUFFERS_ADDR
+
684 (TX_BUFFERS
+ RX_BUFFERS
) * BUFFER_LENGTH
* ports
) {
685 printk(KERN_WARNING
"wanXL %s: no enough on-board RAM"
686 " (%u bytes detected, %u bytes required)\n",
687 pci_name(pdev
), ramsize
, BUFFERS_ADDR
+
688 (TX_BUFFERS
+ RX_BUFFERS
) * BUFFER_LENGTH
* ports
);
689 wanxl_pci_remove_one(pdev
);
693 if (wanxl_puts_command(card
, MBX1_CMD_BSWAP
)) {
694 printk(KERN_WARNING
"wanXL %s: unable to Set Byte Swap"
695 " Mode\n", pci_name(pdev
));
696 wanxl_pci_remove_one(pdev
);
700 for (i
= 0; i
< RX_QUEUE_LENGTH
; i
++) {
701 struct sk_buff
*skb
= dev_alloc_skb(BUFFER_LENGTH
);
702 card
->rx_skbs
[i
] = skb
;
704 card
->status
->rx_descs
[i
].address
=
705 pci_map_single(card
->pdev
, skb
->data
,
710 mem
= ioremap_nocache(mem_phy
, PDM_OFFSET
+ sizeof(firmware
));
712 printk(KERN_ERR
"wanxl: ioremap() failed\n");
713 wanxl_pci_remove_one(pdev
);
717 for (i
= 0; i
< sizeof(firmware
); i
+= 4)
718 writel(ntohl(*(__be32
*)(firmware
+ i
)), mem
+ PDM_OFFSET
+ i
);
720 for (i
= 0; i
< ports
; i
++)
721 writel(card
->status_address
+
722 (void *)&card
->status
->port_status
[i
] -
723 (void *)card
->status
, mem
+ PDM_OFFSET
+ 4 + i
* 4);
724 writel(card
->status_address
, mem
+ PDM_OFFSET
+ 20);
725 writel(PDM_OFFSET
, mem
);
728 writel(0, card
->plx
+ PLX_MAILBOX_5
);
730 if (wanxl_puts_command(card
, MBX1_CMD_ABORTJ
)) {
731 printk(KERN_WARNING
"wanXL %s: unable to Abort and Jump\n",
733 wanxl_pci_remove_one(pdev
);
738 timeout
= jiffies
+ 5 * HZ
;
740 if ((stat
= readl(card
->plx
+ PLX_MAILBOX_5
)) != 0)
743 }while (time_after(timeout
, jiffies
));
746 printk(KERN_WARNING
"wanXL %s: timeout while initializing card "
747 "firmware\n", pci_name(pdev
));
748 wanxl_pci_remove_one(pdev
);
756 printk(KERN_INFO
"wanXL %s: at 0x%X, %u KB of RAM at 0x%X, irq %u\n",
757 pci_name(pdev
), plx_phy
, ramsize
/ 1024, mem_phy
, pdev
->irq
);
760 if (request_irq(pdev
->irq
, wanxl_intr
, IRQF_SHARED
, "wanXL", card
)) {
761 printk(KERN_WARNING
"wanXL %s: could not allocate IRQ%i.\n",
762 pci_name(pdev
), pdev
->irq
);
763 wanxl_pci_remove_one(pdev
);
766 card
->irq
= pdev
->irq
;
768 for (i
= 0; i
< ports
; i
++) {
770 port_t
*port
= &card
->ports
[i
];
771 struct net_device
*dev
= alloc_hdlcdev(port
);
773 printk(KERN_ERR
"wanXL %s: unable to allocate"
774 " memory\n", pci_name(pdev
));
775 wanxl_pci_remove_one(pdev
);
780 hdlc
= dev_to_hdlc(dev
);
781 spin_lock_init(&port
->lock
);
782 dev
->tx_queue_len
= 50;
783 dev
->do_ioctl
= wanxl_ioctl
;
784 dev
->open
= wanxl_open
;
785 dev
->stop
= wanxl_close
;
786 hdlc
->attach
= wanxl_attach
;
787 hdlc
->xmit
= wanxl_xmit
;
788 dev
->get_stats
= wanxl_get_stats
;
791 get_status(port
)->clocking
= CLOCK_EXT
;
792 if (register_hdlc_device(dev
)) {
793 printk(KERN_ERR
"wanXL %s: unable to register hdlc"
794 " device\n", pci_name(pdev
));
796 wanxl_pci_remove_one(pdev
);
802 printk(KERN_INFO
"wanXL %s: port", pci_name(pdev
));
803 for (i
= 0; i
< ports
; i
++)
804 printk("%s #%i: %s", i
? "," : "", i
,
805 card
->ports
[i
].dev
->name
);
808 for (i
= 0; i
< ports
; i
++)
809 wanxl_cable_intr(&card
->ports
[i
]); /* get carrier status etc.*/
814 static struct pci_device_id wanxl_pci_tbl
[] __devinitdata
= {
815 { PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_SBE_WANXL100
, PCI_ANY_ID
,
816 PCI_ANY_ID
, 0, 0, 0 },
817 { PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_SBE_WANXL200
, PCI_ANY_ID
,
818 PCI_ANY_ID
, 0, 0, 0 },
819 { PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_SBE_WANXL400
, PCI_ANY_ID
,
820 PCI_ANY_ID
, 0, 0, 0 },
825 static struct pci_driver wanxl_pci_driver
= {
827 .id_table
= wanxl_pci_tbl
,
828 .probe
= wanxl_pci_init_one
,
829 .remove
= wanxl_pci_remove_one
,
833 static int __init
wanxl_init_module(void)
836 printk(KERN_INFO
"%s\n", version
);
838 return pci_register_driver(&wanxl_pci_driver
);
841 static void __exit
wanxl_cleanup_module(void)
843 pci_unregister_driver(&wanxl_pci_driver
);
847 MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
848 MODULE_DESCRIPTION("SBE Inc. wanXL serial port driver");
849 MODULE_LICENSE("GPL v2");
850 MODULE_DEVICE_TABLE(pci
, wanxl_pci_tbl
);
852 module_init(wanxl_init_module
);
853 module_exit(wanxl_cleanup_module
);