diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 12:00:33 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 12:00:33 -0500 |
commit | 3d14b5beba35250c548d3851a2b84fce742d8311 (patch) | |
tree | 065e3d93c3fcbc5ee4c44fa78662393cddbdf6de /drivers/net/pcmcia/3c589_cs.c | |
parent | 0719dc341389882cc834ed18fc9b7fc6006b2b85 (diff) | |
parent | 1bf8e6219552d5dd27012d567ec8c4bb9c2d86b4 (diff) |
Merge branch 'sa1100' into devel
Diffstat (limited to 'drivers/net/pcmcia/3c589_cs.c')
-rw-r--r-- | drivers/net/pcmcia/3c589_cs.c | 102 |
1 files changed, 35 insertions, 67 deletions
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 569fb06793cf..6f8d7e2e5922 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c | |||
@@ -130,14 +130,6 @@ MODULE_LICENSE("GPL"); | |||
130 | /* Special hook for setting if_port when module is loaded */ | 130 | /* Special hook for setting if_port when module is loaded */ |
131 | INT_MODULE_PARM(if_port, 0); | 131 | INT_MODULE_PARM(if_port, 0); |
132 | 132 | ||
133 | #ifdef PCMCIA_DEBUG | ||
134 | INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); | ||
135 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) | ||
136 | static char *version = | ||
137 | DRV_NAME ".c " DRV_VERSION " 2001/10/13 00:08:50 (David Hinds)"; | ||
138 | #else | ||
139 | #define DEBUG(n, args...) | ||
140 | #endif | ||
141 | 133 | ||
142 | /*====================================================================*/ | 134 | /*====================================================================*/ |
143 | 135 | ||
@@ -189,7 +181,7 @@ static int tc589_probe(struct pcmcia_device *link) | |||
189 | struct el3_private *lp; | 181 | struct el3_private *lp; |
190 | struct net_device *dev; | 182 | struct net_device *dev; |
191 | 183 | ||
192 | DEBUG(0, "3c589_attach()\n"); | 184 | dev_dbg(&link->dev, "3c589_attach()\n"); |
193 | 185 | ||
194 | /* Create new ethernet device */ | 186 | /* Create new ethernet device */ |
195 | dev = alloc_etherdev(sizeof(struct el3_private)); | 187 | dev = alloc_etherdev(sizeof(struct el3_private)); |
@@ -202,10 +194,8 @@ static int tc589_probe(struct pcmcia_device *link) | |||
202 | spin_lock_init(&lp->lock); | 194 | spin_lock_init(&lp->lock); |
203 | link->io.NumPorts1 = 16; | 195 | link->io.NumPorts1 = 16; |
204 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | 196 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
205 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; | 197 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
206 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | ||
207 | link->irq.Handler = &el3_interrupt; | 198 | link->irq.Handler = &el3_interrupt; |
208 | link->irq.Instance = dev; | ||
209 | link->conf.Attributes = CONF_ENABLE_IRQ; | 199 | link->conf.Attributes = CONF_ENABLE_IRQ; |
210 | link->conf.IntType = INT_MEMORY_AND_IO; | 200 | link->conf.IntType = INT_MEMORY_AND_IO; |
211 | link->conf.ConfigIndex = 1; | 201 | link->conf.ConfigIndex = 1; |
@@ -231,7 +221,7 @@ static void tc589_detach(struct pcmcia_device *link) | |||
231 | { | 221 | { |
232 | struct net_device *dev = link->priv; | 222 | struct net_device *dev = link->priv; |
233 | 223 | ||
234 | DEBUG(0, "3c589_detach(0x%p)\n", link); | 224 | dev_dbg(&link->dev, "3c589_detach\n"); |
235 | 225 | ||
236 | if (link->dev_node) | 226 | if (link->dev_node) |
237 | unregister_netdev(dev); | 227 | unregister_netdev(dev); |
@@ -249,29 +239,20 @@ static void tc589_detach(struct pcmcia_device *link) | |||
249 | 239 | ||
250 | ======================================================================*/ | 240 | ======================================================================*/ |
251 | 241 | ||
252 | #define CS_CHECK(fn, ret) \ | ||
253 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | ||
254 | |||
255 | static int tc589_config(struct pcmcia_device *link) | 242 | static int tc589_config(struct pcmcia_device *link) |
256 | { | 243 | { |
257 | struct net_device *dev = link->priv; | 244 | struct net_device *dev = link->priv; |
258 | struct el3_private *lp = netdev_priv(dev); | 245 | struct el3_private *lp = netdev_priv(dev); |
259 | tuple_t tuple; | ||
260 | __le16 buf[32]; | ||
261 | __be16 *phys_addr; | 246 | __be16 *phys_addr; |
262 | int last_fn, last_ret, i, j, multi = 0, fifo; | 247 | int ret, i, j, multi = 0, fifo; |
263 | unsigned int ioaddr; | 248 | unsigned int ioaddr; |
264 | char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; | 249 | char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; |
250 | u8 *buf; | ||
251 | size_t len; | ||
265 | 252 | ||
266 | DEBUG(0, "3c589_config(0x%p)\n", link); | 253 | dev_dbg(&link->dev, "3c589_config\n"); |
267 | 254 | ||
268 | phys_addr = (__be16 *)dev->dev_addr; | 255 | phys_addr = (__be16 *)dev->dev_addr; |
269 | tuple.Attributes = 0; | ||
270 | tuple.TupleData = (cisdata_t *)buf; | ||
271 | tuple.TupleDataMax = sizeof(buf); | ||
272 | tuple.TupleOffset = 0; | ||
273 | tuple.Attributes = TUPLE_RETURN_COMMON; | ||
274 | |||
275 | /* Is this a 3c562? */ | 256 | /* Is this a 3c562? */ |
276 | if (link->manf_id != MANFID_3COM) | 257 | if (link->manf_id != MANFID_3COM) |
277 | printk(KERN_INFO "3c589_cs: hmmm, is this really a " | 258 | printk(KERN_INFO "3c589_cs: hmmm, is this really a " |
@@ -287,12 +268,16 @@ static int tc589_config(struct pcmcia_device *link) | |||
287 | if (i == 0) | 268 | if (i == 0) |
288 | break; | 269 | break; |
289 | } | 270 | } |
290 | if (i != 0) { | 271 | if (i != 0) |
291 | cs_error(link, RequestIO, i); | ||
292 | goto failed; | 272 | goto failed; |
293 | } | 273 | |
294 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 274 | ret = pcmcia_request_irq(link, &link->irq); |
295 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 275 | if (ret) |
276 | goto failed; | ||
277 | |||
278 | ret = pcmcia_request_configuration(link, &link->conf); | ||
279 | if (ret) | ||
280 | goto failed; | ||
296 | 281 | ||
297 | dev->irq = link->irq.AssignedIRQ; | 282 | dev->irq = link->irq.AssignedIRQ; |
298 | dev->base_addr = link->io.BasePort1; | 283 | dev->base_addr = link->io.BasePort1; |
@@ -301,12 +286,13 @@ static int tc589_config(struct pcmcia_device *link) | |||
301 | 286 | ||
302 | /* The 3c589 has an extra EEPROM for configuration info, including | 287 | /* The 3c589 has an extra EEPROM for configuration info, including |
303 | the hardware address. The 3c562 puts the address in the CIS. */ | 288 | the hardware address. The 3c562 puts the address in the CIS. */ |
304 | tuple.DesiredTuple = 0x88; | 289 | len = pcmcia_get_tuple(link, 0x88, &buf); |
305 | if (pcmcia_get_first_tuple(link, &tuple) == 0) { | 290 | if (buf && len >= 6) { |
306 | pcmcia_get_tuple_data(link, &tuple); | 291 | for (i = 0; i < 3; i++) |
307 | for (i = 0; i < 3; i++) | 292 | phys_addr[i] = htons(le16_to_cpu(buf[i*2])); |
308 | phys_addr[i] = htons(le16_to_cpu(buf[i])); | 293 | kfree(buf); |
309 | } else { | 294 | } else { |
295 | kfree(buf); /* 0 < len < 6 */ | ||
310 | for (i = 0; i < 3; i++) | 296 | for (i = 0; i < 3; i++) |
311 | phys_addr[i] = htons(read_eeprom(ioaddr, i)); | 297 | phys_addr[i] = htons(read_eeprom(ioaddr, i)); |
312 | if (phys_addr[0] == htons(0x6060)) { | 298 | if (phys_addr[0] == htons(0x6060)) { |
@@ -328,7 +314,7 @@ static int tc589_config(struct pcmcia_device *link) | |||
328 | printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); | 314 | printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); |
329 | 315 | ||
330 | link->dev_node = &lp->node; | 316 | link->dev_node = &lp->node; |
331 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); | 317 | SET_NETDEV_DEV(dev, &link->dev); |
332 | 318 | ||
333 | if (register_netdev(dev) != 0) { | 319 | if (register_netdev(dev) != 0) { |
334 | printk(KERN_ERR "3c589_cs: register_netdev() failed\n"); | 320 | printk(KERN_ERR "3c589_cs: register_netdev() failed\n"); |
@@ -347,8 +333,6 @@ static int tc589_config(struct pcmcia_device *link) | |||
347 | if_names[dev->if_port]); | 333 | if_names[dev->if_port]); |
348 | return 0; | 334 | return 0; |
349 | 335 | ||
350 | cs_failed: | ||
351 | cs_error(link, last_fn, last_ret); | ||
352 | failed: | 336 | failed: |
353 | tc589_release(link); | 337 | tc589_release(link); |
354 | return -ENODEV; | 338 | return -ENODEV; |
@@ -511,24 +495,8 @@ static void netdev_get_drvinfo(struct net_device *dev, | |||
511 | sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); | 495 | sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); |
512 | } | 496 | } |
513 | 497 | ||
514 | #ifdef PCMCIA_DEBUG | ||
515 | static u32 netdev_get_msglevel(struct net_device *dev) | ||
516 | { | ||
517 | return pc_debug; | ||
518 | } | ||
519 | |||
520 | static void netdev_set_msglevel(struct net_device *dev, u32 level) | ||
521 | { | ||
522 | pc_debug = level; | ||
523 | } | ||
524 | #endif /* PCMCIA_DEBUG */ | ||
525 | |||
526 | static const struct ethtool_ops netdev_ethtool_ops = { | 498 | static const struct ethtool_ops netdev_ethtool_ops = { |
527 | .get_drvinfo = netdev_get_drvinfo, | 499 | .get_drvinfo = netdev_get_drvinfo, |
528 | #ifdef PCMCIA_DEBUG | ||
529 | .get_msglevel = netdev_get_msglevel, | ||
530 | .set_msglevel = netdev_set_msglevel, | ||
531 | #endif /* PCMCIA_DEBUG */ | ||
532 | }; | 500 | }; |
533 | 501 | ||
534 | static int el3_config(struct net_device *dev, struct ifmap *map) | 502 | static int el3_config(struct net_device *dev, struct ifmap *map) |
@@ -563,7 +531,7 @@ static int el3_open(struct net_device *dev) | |||
563 | lp->media.expires = jiffies + HZ; | 531 | lp->media.expires = jiffies + HZ; |
564 | add_timer(&lp->media); | 532 | add_timer(&lp->media); |
565 | 533 | ||
566 | DEBUG(1, "%s: opened, status %4.4x.\n", | 534 | dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", |
567 | dev->name, inw(dev->base_addr + EL3_STATUS)); | 535 | dev->name, inw(dev->base_addr + EL3_STATUS)); |
568 | 536 | ||
569 | return 0; | 537 | return 0; |
@@ -596,7 +564,7 @@ static void pop_tx_status(struct net_device *dev) | |||
596 | if (tx_status & 0x30) | 564 | if (tx_status & 0x30) |
597 | tc589_wait_for_completion(dev, TxReset); | 565 | tc589_wait_for_completion(dev, TxReset); |
598 | if (tx_status & 0x38) { | 566 | if (tx_status & 0x38) { |
599 | DEBUG(1, "%s: transmit error: status 0x%02x\n", | 567 | pr_debug("%s: transmit error: status 0x%02x\n", |
600 | dev->name, tx_status); | 568 | dev->name, tx_status); |
601 | outw(TxEnable, ioaddr + EL3_CMD); | 569 | outw(TxEnable, ioaddr + EL3_CMD); |
602 | dev->stats.tx_aborted_errors++; | 570 | dev->stats.tx_aborted_errors++; |
@@ -612,7 +580,7 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb, | |||
612 | struct el3_private *priv = netdev_priv(dev); | 580 | struct el3_private *priv = netdev_priv(dev); |
613 | unsigned long flags; | 581 | unsigned long flags; |
614 | 582 | ||
615 | DEBUG(3, "%s: el3_start_xmit(length = %ld) called, " | 583 | pr_debug("%s: el3_start_xmit(length = %ld) called, " |
616 | "status %4.4x.\n", dev->name, (long)skb->len, | 584 | "status %4.4x.\n", dev->name, (long)skb->len, |
617 | inw(ioaddr + EL3_STATUS)); | 585 | inw(ioaddr + EL3_STATUS)); |
618 | 586 | ||
@@ -654,14 +622,14 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id) | |||
654 | 622 | ||
655 | ioaddr = dev->base_addr; | 623 | ioaddr = dev->base_addr; |
656 | 624 | ||
657 | DEBUG(3, "%s: interrupt, status %4.4x.\n", | 625 | pr_debug("%s: interrupt, status %4.4x.\n", |
658 | dev->name, inw(ioaddr + EL3_STATUS)); | 626 | dev->name, inw(ioaddr + EL3_STATUS)); |
659 | 627 | ||
660 | spin_lock(&lp->lock); | 628 | spin_lock(&lp->lock); |
661 | while ((status = inw(ioaddr + EL3_STATUS)) & | 629 | while ((status = inw(ioaddr + EL3_STATUS)) & |
662 | (IntLatch | RxComplete | StatsFull)) { | 630 | (IntLatch | RxComplete | StatsFull)) { |
663 | if ((status & 0xe000) != 0x2000) { | 631 | if ((status & 0xe000) != 0x2000) { |
664 | DEBUG(1, "%s: interrupt from dead card\n", dev->name); | 632 | pr_debug("%s: interrupt from dead card\n", dev->name); |
665 | handled = 0; | 633 | handled = 0; |
666 | break; | 634 | break; |
667 | } | 635 | } |
@@ -670,7 +638,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id) | |||
670 | el3_rx(dev); | 638 | el3_rx(dev); |
671 | 639 | ||
672 | if (status & TxAvailable) { | 640 | if (status & TxAvailable) { |
673 | DEBUG(3, " TX room bit was handled.\n"); | 641 | pr_debug(" TX room bit was handled.\n"); |
674 | /* There's room in the FIFO for a full-sized packet. */ | 642 | /* There's room in the FIFO for a full-sized packet. */ |
675 | outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); | 643 | outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); |
676 | netif_wake_queue(dev); | 644 | netif_wake_queue(dev); |
@@ -722,7 +690,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id) | |||
722 | 690 | ||
723 | lp->last_irq = jiffies; | 691 | lp->last_irq = jiffies; |
724 | spin_unlock(&lp->lock); | 692 | spin_unlock(&lp->lock); |
725 | DEBUG(3, "%s: exiting interrupt, status %4.4x.\n", | 693 | pr_debug("%s: exiting interrupt, status %4.4x.\n", |
726 | dev->name, inw(ioaddr + EL3_STATUS)); | 694 | dev->name, inw(ioaddr + EL3_STATUS)); |
727 | return IRQ_RETVAL(handled); | 695 | return IRQ_RETVAL(handled); |
728 | } | 696 | } |
@@ -833,7 +801,7 @@ static void update_stats(struct net_device *dev) | |||
833 | { | 801 | { |
834 | unsigned int ioaddr = dev->base_addr; | 802 | unsigned int ioaddr = dev->base_addr; |
835 | 803 | ||
836 | DEBUG(2, "%s: updating the statistics.\n", dev->name); | 804 | pr_debug("%s: updating the statistics.\n", dev->name); |
837 | /* Turn off statistics updates while reading. */ | 805 | /* Turn off statistics updates while reading. */ |
838 | outw(StatsDisable, ioaddr + EL3_CMD); | 806 | outw(StatsDisable, ioaddr + EL3_CMD); |
839 | /* Switch to the stats window, and read everything. */ | 807 | /* Switch to the stats window, and read everything. */ |
@@ -861,7 +829,7 @@ static int el3_rx(struct net_device *dev) | |||
861 | int worklimit = 32; | 829 | int worklimit = 32; |
862 | short rx_status; | 830 | short rx_status; |
863 | 831 | ||
864 | DEBUG(3, "%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n", | 832 | pr_debug("%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n", |
865 | dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS)); | 833 | dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS)); |
866 | while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) && | 834 | while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) && |
867 | worklimit > 0) { | 835 | worklimit > 0) { |
@@ -883,7 +851,7 @@ static int el3_rx(struct net_device *dev) | |||
883 | 851 | ||
884 | skb = dev_alloc_skb(pkt_len+5); | 852 | skb = dev_alloc_skb(pkt_len+5); |
885 | 853 | ||
886 | DEBUG(3, " Receiving packet size %d status %4.4x.\n", | 854 | pr_debug(" Receiving packet size %d status %4.4x.\n", |
887 | pkt_len, rx_status); | 855 | pkt_len, rx_status); |
888 | if (skb != NULL) { | 856 | if (skb != NULL) { |
889 | skb_reserve(skb, 2); | 857 | skb_reserve(skb, 2); |
@@ -894,7 +862,7 @@ static int el3_rx(struct net_device *dev) | |||
894 | dev->stats.rx_packets++; | 862 | dev->stats.rx_packets++; |
895 | dev->stats.rx_bytes += pkt_len; | 863 | dev->stats.rx_bytes += pkt_len; |
896 | } else { | 864 | } else { |
897 | DEBUG(1, "%s: couldn't allocate a sk_buff of" | 865 | pr_debug("%s: couldn't allocate a sk_buff of" |
898 | " size %d.\n", dev->name, pkt_len); | 866 | " size %d.\n", dev->name, pkt_len); |
899 | dev->stats.rx_dropped++; | 867 | dev->stats.rx_dropped++; |
900 | } | 868 | } |
@@ -935,7 +903,7 @@ static int el3_close(struct net_device *dev) | |||
935 | struct pcmcia_device *link = lp->p_dev; | 903 | struct pcmcia_device *link = lp->p_dev; |
936 | unsigned int ioaddr = dev->base_addr; | 904 | unsigned int ioaddr = dev->base_addr; |
937 | 905 | ||
938 | DEBUG(1, "%s: shutting down ethercard.\n", dev->name); | 906 | dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name); |
939 | 907 | ||
940 | if (pcmcia_dev_present(link)) { | 908 | if (pcmcia_dev_present(link)) { |
941 | /* Turn off statistics ASAP. We update dev->stats below. */ | 909 | /* Turn off statistics ASAP. We update dev->stats below. */ |