Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Comtrol SV11 card driver |
| 3 | * |
| 4 | * This is a slightly odd Z85230 synchronous driver. All you need to |
| 5 | * know basically is |
| 6 | * |
| 7 | * Its a genuine Z85230 |
| 8 | * |
| 9 | * It supports DMA using two DMA channels in SYNC mode. The driver doesn't |
| 10 | * use these facilities |
| 11 | * |
| 12 | * The control port is at io+1, the data at io+3 and turning off the DMA |
| 13 | * is done by writing 0 to io+4 |
| 14 | * |
| 15 | * The hardware does the bus handling to avoid the need for delays between |
| 16 | * touching control registers. |
| 17 | * |
| 18 | * Port B isnt wired (why - beats me) |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 19 | * |
| 20 | * Generic HDLC port Copyright (C) 2008 Krzysztof Halasa <khc@pm.waw.pl> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/mm.h> |
| 26 | #include <linux/net.h> |
| 27 | #include <linux/skbuff.h> |
| 28 | #include <linux/netdevice.h> |
| 29 | #include <linux/if_arp.h> |
| 30 | #include <linux/delay.h> |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 31 | #include <linux/hdlc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/ioport.h> |
| 33 | #include <net/arp.h> |
| 34 | |
Al Viro | 8272997 | 2005-12-06 05:53:04 -0500 | [diff] [blame] | 35 | #include <asm/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <asm/io.h> |
| 37 | #include <asm/dma.h> |
| 38 | #include <asm/byteorder.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include "z85230.h" |
| 40 | |
| 41 | static int dma; |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | /* |
| 44 | * Network driver support routines |
| 45 | */ |
| 46 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 47 | static inline struct z8530_dev* dev_to_sv(struct net_device *dev) |
| 48 | { |
| 49 | return (struct z8530_dev *)dev_to_hdlc(dev)->priv; |
| 50 | } |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | /* |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 53 | * Frame receive. Simple for our card as we do HDLC and there |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | * is no funny garbage involved |
| 55 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 56 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | static void hostess_input(struct z8530_channel *c, struct sk_buff *skb) |
| 58 | { |
| 59 | /* Drop the CRC - it's not a good idea to try and negotiate it ;) */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 60 | skb_trim(skb, skb->len - 2); |
| 61 | skb->protocol = hdlc_type_trans(skb, c->netdevice); |
Arnaldo Carvalho de Melo | 98e399f | 2007-03-19 15:33:04 -0700 | [diff] [blame] | 62 | skb_reset_mac_header(skb); |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 63 | skb->dev = c->netdevice; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | /* |
| 65 | * Send it to the PPP layer. We don't have time to process |
| 66 | * it right now. |
| 67 | */ |
| 68 | netif_rx(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | } |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | /* |
| 72 | * We've been placed in the UP state |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 73 | */ |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | static int hostess_open(struct net_device *d) |
| 76 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 77 | struct z8530_dev *sv11 = dev_to_sv(d); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | int err = -1; |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | /* |
| 81 | * Link layer up |
| 82 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 83 | switch (dma) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | case 0: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 85 | err = z8530_sync_open(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | break; |
| 87 | case 1: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 88 | err = z8530_sync_dma_open(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | break; |
| 90 | case 2: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 91 | err = z8530_sync_txdma_open(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | break; |
| 93 | } |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 94 | |
| 95 | if (err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | return err; |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 97 | |
| 98 | err = hdlc_open(d); |
| 99 | if (err) { |
| 100 | switch (dma) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | case 0: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 102 | z8530_sync_close(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | break; |
| 104 | case 1: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 105 | z8530_sync_dma_close(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | break; |
| 107 | case 2: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 108 | z8530_sync_txdma_close(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | break; |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 110 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | return err; |
| 112 | } |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 113 | sv11->chanA.rx_function = hostess_input; |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | /* |
| 116 | * Go go go |
| 117 | */ |
| 118 | |
| 119 | netif_start_queue(d); |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | static int hostess_close(struct net_device *d) |
| 124 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 125 | struct z8530_dev *sv11 = dev_to_sv(d); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | /* |
| 127 | * Discard new frames |
| 128 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 129 | sv11->chanA.rx_function = z8530_null_rx; |
| 130 | |
| 131 | hdlc_close(d); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | netif_stop_queue(d); |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 133 | |
| 134 | switch (dma) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | case 0: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 136 | z8530_sync_close(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | break; |
| 138 | case 1: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 139 | z8530_sync_dma_close(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | break; |
| 141 | case 2: |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 142 | z8530_sync_txdma_close(d, &sv11->chanA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | break; |
| 144 | } |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd) |
| 149 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 150 | /* struct z8530_dev *sv11=dev_to_sv(d); |
| 151 | z8530_ioctl(d,&sv11->chanA,ifr,cmd) */ |
| 152 | return hdlc_ioctl(d, ifr, cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | /* |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 156 | * Passed network frames, fire them downwind. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 158 | |
Stephen Hemminger | d71a674 | 2009-08-31 19:50:47 +0000 | [diff] [blame] | 159 | static netdev_tx_t hostess_queue_xmit(struct sk_buff *skb, |
| 160 | struct net_device *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 162 | return z8530_queue_xmit(&dev_to_sv(d)->chanA, skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 165 | static int hostess_attach(struct net_device *dev, unsigned short encoding, |
| 166 | unsigned short parity) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 168 | if (encoding == ENCODING_NRZ && parity == PARITY_CRC16_PR1_CCITT) |
| 169 | return 0; |
| 170 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /* |
| 174 | * Description block for a Comtrol Hostess SV11 card |
| 175 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 176 | |
Krzysztof Hałasa | 991990a | 2009-01-08 22:52:11 +0100 | [diff] [blame] | 177 | static const struct net_device_ops hostess_ops = { |
| 178 | .ndo_open = hostess_open, |
| 179 | .ndo_stop = hostess_close, |
| 180 | .ndo_change_mtu = hdlc_change_mtu, |
| 181 | .ndo_start_xmit = hdlc_start_xmit, |
| 182 | .ndo_do_ioctl = hostess_ioctl, |
| 183 | }; |
| 184 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 185 | static struct z8530_dev *sv11_init(int iobase, int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 187 | struct z8530_dev *sv; |
| 188 | struct net_device *netdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | /* |
| 190 | * Get the needed I/O space |
| 191 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 192 | |
| 193 | if (!request_region(iobase, 8, "Comtrol SV11")) { |
| 194 | printk(KERN_WARNING "hostess: I/O 0x%X already in use.\n", |
| 195 | iobase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | return NULL; |
| 197 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 199 | sv = kzalloc(sizeof(struct z8530_dev), GFP_KERNEL); |
| 200 | if (!sv) |
| 201 | goto err_kzalloc; |
| 202 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | /* |
| 204 | * Stuff in the I/O addressing |
| 205 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 206 | |
| 207 | sv->active = 0; |
| 208 | |
| 209 | sv->chanA.ctrlio = iobase + 1; |
| 210 | sv->chanA.dataio = iobase + 3; |
| 211 | sv->chanB.ctrlio = -1; |
| 212 | sv->chanB.dataio = -1; |
| 213 | sv->chanA.irqs = &z8530_nop; |
| 214 | sv->chanB.irqs = &z8530_nop; |
| 215 | |
| 216 | outb(0, iobase + 4); /* DMA off */ |
| 217 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | /* We want a fast IRQ for this device. Actually we'd like an even faster |
| 219 | IRQ ;) - This is one driver RtLinux is made for */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 220 | |
| 221 | if (request_irq(irq, &z8530_interrupt, IRQF_DISABLED, |
| 222 | "Hostess SV11", sv) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | printk(KERN_WARNING "hostess: IRQ %d already in use.\n", irq); |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 224 | goto err_irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 226 | |
| 227 | sv->irq = irq; |
| 228 | sv->chanA.private = sv; |
| 229 | sv->chanA.dev = sv; |
| 230 | sv->chanB.dev = sv; |
| 231 | |
| 232 | if (dma) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | /* |
| 234 | * You can have DMA off or 1 and 3 thats the lot |
| 235 | * on the Comtrol. |
| 236 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 237 | sv->chanA.txdma = 3; |
| 238 | sv->chanA.rxdma = 1; |
| 239 | outb(0x03 | 0x08, iobase + 4); /* DMA on */ |
| 240 | if (request_dma(sv->chanA.txdma, "Hostess SV/11 (TX)")) |
| 241 | goto err_txdma; |
| 242 | |
| 243 | if (dma == 1) |
| 244 | if (request_dma(sv->chanA.rxdma, "Hostess SV/11 (RX)")) |
| 245 | goto err_rxdma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | /* Kill our private IRQ line the hostess can end up chattering |
| 249 | until the configuration is set */ |
| 250 | disable_irq(irq); |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | /* |
| 253 | * Begin normal initialise |
| 254 | */ |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 255 | |
| 256 | if (z8530_init(sv)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | printk(KERN_ERR "Z8530 series device not found.\n"); |
| 258 | enable_irq(irq); |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 259 | goto free_dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 261 | z8530_channel_load(&sv->chanB, z8530_dead_port); |
| 262 | if (sv->type == Z85C30) |
| 263 | z8530_channel_load(&sv->chanA, z8530_hdlc_kilostream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | else |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 265 | z8530_channel_load(&sv->chanA, z8530_hdlc_kilostream_85230); |
| 266 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | enable_irq(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | |
| 269 | /* |
| 270 | * Now we can take the IRQ |
| 271 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 273 | sv->chanA.netdevice = netdev = alloc_hdlcdev(sv); |
| 274 | if (!netdev) |
| 275 | goto free_dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 277 | dev_to_hdlc(netdev)->attach = hostess_attach; |
| 278 | dev_to_hdlc(netdev)->xmit = hostess_queue_xmit; |
Krzysztof Hałasa | 991990a | 2009-01-08 22:52:11 +0100 | [diff] [blame] | 279 | netdev->netdev_ops = &hostess_ops; |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 280 | netdev->base_addr = iobase; |
| 281 | netdev->irq = irq; |
| 282 | |
| 283 | if (register_hdlc_device(netdev)) { |
| 284 | printk(KERN_ERR "hostess: unable to register HDLC device.\n"); |
| 285 | free_netdev(netdev); |
| 286 | goto free_dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 288 | |
| 289 | z8530_describe(sv, "I/O", iobase); |
| 290 | sv->active = 1; |
| 291 | return sv; |
| 292 | |
| 293 | free_dma: |
| 294 | if (dma == 1) |
| 295 | free_dma(sv->chanA.rxdma); |
| 296 | err_rxdma: |
| 297 | if (dma) |
| 298 | free_dma(sv->chanA.txdma); |
| 299 | err_txdma: |
| 300 | free_irq(irq, sv); |
| 301 | err_irq: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | kfree(sv); |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 303 | err_kzalloc: |
| 304 | release_region(iobase, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | return NULL; |
| 306 | } |
| 307 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 308 | static void sv11_shutdown(struct z8530_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 310 | unregister_hdlc_device(dev->chanA.netdevice); |
| 311 | z8530_shutdown(dev); |
| 312 | free_irq(dev->irq, dev); |
| 313 | if (dma) { |
| 314 | if (dma == 1) |
| 315 | free_dma(dev->chanA.rxdma); |
| 316 | free_dma(dev->chanA.txdma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | } |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 318 | release_region(dev->chanA.ctrlio - 1, 8); |
| 319 | free_netdev(dev->chanA.netdevice); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | kfree(dev); |
| 321 | } |
| 322 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 323 | static int io = 0x200; |
| 324 | static int irq = 9; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | |
| 326 | module_param(io, int, 0); |
| 327 | MODULE_PARM_DESC(io, "The I/O base of the Comtrol Hostess SV11 card"); |
| 328 | module_param(dma, int, 0); |
| 329 | MODULE_PARM_DESC(dma, "Set this to 1 to use DMA1/DMA3 for TX/RX"); |
| 330 | module_param(irq, int, 0); |
| 331 | MODULE_PARM_DESC(irq, "The interrupt line setting for the Comtrol Hostess SV11 card"); |
| 332 | |
| 333 | MODULE_AUTHOR("Alan Cox"); |
| 334 | MODULE_LICENSE("GPL"); |
| 335 | MODULE_DESCRIPTION("Modular driver for the Comtrol Hostess SV11"); |
| 336 | |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 337 | static struct z8530_dev *sv11_unit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
| 339 | int init_module(void) |
| 340 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 341 | if ((sv11_unit = sv11_init(io, irq)) == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | return -ENODEV; |
| 343 | return 0; |
| 344 | } |
| 345 | |
| 346 | void cleanup_module(void) |
| 347 | { |
Krzysztof Hałasa | 52e8a6a | 2008-07-02 17:47:52 +0200 | [diff] [blame] | 348 | if (sv11_unit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | sv11_shutdown(sv11_unit); |
| 350 | } |