aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/pcnet_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/pcmcia/pcnet_cs.c')
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c91
1 files changed, 43 insertions, 48 deletions
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 8ed6a410ea10..9f41355e6beb 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -103,8 +103,8 @@ module_param_array(hw_addr, int, NULL, 0);
103/*====================================================================*/ 103/*====================================================================*/
104 104
105static void mii_phy_probe(struct net_device *dev); 105static void mii_phy_probe(struct net_device *dev);
106static void pcnet_config(dev_link_t *link); 106static void pcnet_config(struct pcmcia_device *link);
107static void pcnet_release(dev_link_t *link); 107static void pcnet_release(struct pcmcia_device *link);
108static int pcnet_open(struct net_device *dev); 108static int pcnet_open(struct net_device *dev);
109static int pcnet_close(struct net_device *dev); 109static int pcnet_close(struct net_device *dev);
110static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 110static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -113,9 +113,9 @@ static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
113static void ei_watchdog(u_long arg); 113static void ei_watchdog(u_long arg);
114static void pcnet_reset_8390(struct net_device *dev); 114static void pcnet_reset_8390(struct net_device *dev);
115static int set_config(struct net_device *dev, struct ifmap *map); 115static int set_config(struct net_device *dev, struct ifmap *map);
116static int setup_shmem_window(dev_link_t *link, int start_pg, 116static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
117 int stop_pg, int cm_offset); 117 int stop_pg, int cm_offset);
118static int setup_dma_config(dev_link_t *link, int start_pg, 118static int setup_dma_config(struct pcmcia_device *link, int start_pg,
119 int stop_pg); 119 int stop_pg);
120 120
121static void pcnet_detach(struct pcmcia_device *p_dev); 121static void pcnet_detach(struct pcmcia_device *p_dev);
@@ -240,11 +240,10 @@ static inline pcnet_dev_t *PRIV(struct net_device *dev)
240 240
241======================================================================*/ 241======================================================================*/
242 242
243static int pcnet_probe(struct pcmcia_device *p_dev) 243static int pcnet_probe(struct pcmcia_device *link)
244{ 244{
245 pcnet_dev_t *info; 245 pcnet_dev_t *info;
246 struct net_device *dev; 246 struct net_device *dev;
247 dev_link_t *link = dev_to_instance(p_dev);
248 247
249 DEBUG(0, "pcnet_attach()\n"); 248 DEBUG(0, "pcnet_attach()\n");
250 249
@@ -252,7 +251,7 @@ static int pcnet_probe(struct pcmcia_device *p_dev)
252 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); 251 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t));
253 if (!dev) return -ENOMEM; 252 if (!dev) return -ENOMEM;
254 info = PRIV(dev); 253 info = PRIV(dev);
255 info->p_dev = p_dev; 254 info->p_dev = link;
256 link->priv = dev; 255 link->priv = dev;
257 256
258 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 257 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
@@ -280,9 +279,8 @@ static int pcnet_probe(struct pcmcia_device *p_dev)
280 279
281======================================================================*/ 280======================================================================*/
282 281
283static void pcnet_detach(struct pcmcia_device *p_dev) 282static void pcnet_detach(struct pcmcia_device *link)
284{ 283{
285 dev_link_t *link = dev_to_instance(p_dev);
286 struct net_device *dev = link->priv; 284 struct net_device *dev = link->priv;
287 285
288 DEBUG(0, "pcnet_detach(0x%p)\n", link); 286 DEBUG(0, "pcnet_detach(0x%p)\n", link);
@@ -303,7 +301,7 @@ static void pcnet_detach(struct pcmcia_device *p_dev)
303 301
304======================================================================*/ 302======================================================================*/
305 303
306static hw_info_t *get_hwinfo(dev_link_t *link) 304static hw_info_t *get_hwinfo(struct pcmcia_device *link)
307{ 305{
308 struct net_device *dev = link->priv; 306 struct net_device *dev = link->priv;
309 win_req_t req; 307 win_req_t req;
@@ -315,9 +313,9 @@ static hw_info_t *get_hwinfo(dev_link_t *link)
315 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 313 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
316 req.Base = 0; req.Size = 0; 314 req.Base = 0; req.Size = 0;
317 req.AccessSpeed = 0; 315 req.AccessSpeed = 0;
318 i = pcmcia_request_window(&link->handle, &req, &link->win); 316 i = pcmcia_request_window(&link, &req, &link->win);
319 if (i != CS_SUCCESS) { 317 if (i != CS_SUCCESS) {
320 cs_error(link->handle, RequestWindow, i); 318 cs_error(link, RequestWindow, i);
321 return NULL; 319 return NULL;
322 } 320 }
323 321
@@ -340,7 +338,7 @@ static hw_info_t *get_hwinfo(dev_link_t *link)
340 iounmap(virt); 338 iounmap(virt);
341 j = pcmcia_release_window(link->win); 339 j = pcmcia_release_window(link->win);
342 if (j != CS_SUCCESS) 340 if (j != CS_SUCCESS)
343 cs_error(link->handle, ReleaseWindow, j); 341 cs_error(link, ReleaseWindow, j);
344 return (i < NR_INFO) ? hw_info+i : NULL; 342 return (i < NR_INFO) ? hw_info+i : NULL;
345} /* get_hwinfo */ 343} /* get_hwinfo */
346 344
@@ -352,7 +350,7 @@ static hw_info_t *get_hwinfo(dev_link_t *link)
352 350
353======================================================================*/ 351======================================================================*/
354 352
355static hw_info_t *get_prom(dev_link_t *link) 353static hw_info_t *get_prom(struct pcmcia_device *link)
356{ 354{
357 struct net_device *dev = link->priv; 355 struct net_device *dev = link->priv;
358 kio_addr_t ioaddr = dev->base_addr; 356 kio_addr_t ioaddr = dev->base_addr;
@@ -406,7 +404,7 @@ static hw_info_t *get_prom(dev_link_t *link)
406 404
407======================================================================*/ 405======================================================================*/
408 406
409static hw_info_t *get_dl10019(dev_link_t *link) 407static hw_info_t *get_dl10019(struct pcmcia_device *link)
410{ 408{
411 struct net_device *dev = link->priv; 409 struct net_device *dev = link->priv;
412 int i; 410 int i;
@@ -428,7 +426,7 @@ static hw_info_t *get_dl10019(dev_link_t *link)
428 426
429======================================================================*/ 427======================================================================*/
430 428
431static hw_info_t *get_ax88190(dev_link_t *link) 429static hw_info_t *get_ax88190(struct pcmcia_device *link)
432{ 430{
433 struct net_device *dev = link->priv; 431 struct net_device *dev = link->priv;
434 kio_addr_t ioaddr = dev->base_addr; 432 kio_addr_t ioaddr = dev->base_addr;
@@ -461,7 +459,7 @@ static hw_info_t *get_ax88190(dev_link_t *link)
461 459
462======================================================================*/ 460======================================================================*/
463 461
464static hw_info_t *get_hwired(dev_link_t *link) 462static hw_info_t *get_hwired(struct pcmcia_device *link)
465{ 463{
466 struct net_device *dev = link->priv; 464 struct net_device *dev = link->priv;
467 int i; 465 int i;
@@ -488,7 +486,7 @@ static hw_info_t *get_hwired(dev_link_t *link)
488#define CS_CHECK(fn, ret) \ 486#define CS_CHECK(fn, ret) \
489do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 487do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
490 488
491static int try_io_port(dev_link_t *link) 489static int try_io_port(struct pcmcia_device *link)
492{ 490{
493 int j, ret; 491 int j, ret;
494 if (link->io.NumPorts1 == 32) { 492 if (link->io.NumPorts1 == 32) {
@@ -509,18 +507,17 @@ static int try_io_port(dev_link_t *link)
509 for (j = 0; j < 0x400; j += 0x20) { 507 for (j = 0; j < 0x400; j += 0x20) {
510 link->io.BasePort1 = j ^ 0x300; 508 link->io.BasePort1 = j ^ 0x300;
511 link->io.BasePort2 = (j ^ 0x300) + 0x10; 509 link->io.BasePort2 = (j ^ 0x300) + 0x10;
512 ret = pcmcia_request_io(link->handle, &link->io); 510 ret = pcmcia_request_io(link, &link->io);
513 if (ret == CS_SUCCESS) return ret; 511 if (ret == CS_SUCCESS) return ret;
514 } 512 }
515 return ret; 513 return ret;
516 } else { 514 } else {
517 return pcmcia_request_io(link->handle, &link->io); 515 return pcmcia_request_io(link, &link->io);
518 } 516 }
519} 517}
520 518
521static void pcnet_config(dev_link_t *link) 519static void pcnet_config(struct pcmcia_device *link)
522{ 520{
523 client_handle_t handle = link->handle;
524 struct net_device *dev = link->priv; 521 struct net_device *dev = link->priv;
525 pcnet_dev_t *info = PRIV(dev); 522 pcnet_dev_t *info = PRIV(dev);
526 tuple_t tuple; 523 tuple_t tuple;
@@ -537,9 +534,9 @@ static void pcnet_config(dev_link_t *link)
537 tuple.TupleDataMax = sizeof(buf); 534 tuple.TupleDataMax = sizeof(buf);
538 tuple.TupleOffset = 0; 535 tuple.TupleOffset = 0;
539 tuple.DesiredTuple = CISTPL_CONFIG; 536 tuple.DesiredTuple = CISTPL_CONFIG;
540 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 537 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
541 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 538 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
542 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 539 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
543 link->conf.ConfigBase = parse.config.base; 540 link->conf.ConfigBase = parse.config.base;
544 link->conf.Present = parse.config.rmask[0]; 541 link->conf.Present = parse.config.rmask[0];
545 542
@@ -548,21 +545,21 @@ static void pcnet_config(dev_link_t *link)
548 545
549 tuple.DesiredTuple = CISTPL_MANFID; 546 tuple.DesiredTuple = CISTPL_MANFID;
550 tuple.Attributes = TUPLE_RETURN_COMMON; 547 tuple.Attributes = TUPLE_RETURN_COMMON;
551 if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) && 548 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) &&
552 (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) { 549 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) {
553 manfid = le16_to_cpu(buf[0]); 550 manfid = le16_to_cpu(buf[0]);
554 prodid = le16_to_cpu(buf[1]); 551 prodid = le16_to_cpu(buf[1]);
555 } 552 }
556 553
557 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 554 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
558 tuple.Attributes = 0; 555 tuple.Attributes = 0;
559 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 556 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
560 while (last_ret == CS_SUCCESS) { 557 while (last_ret == CS_SUCCESS) {
561 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 558 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
562 cistpl_io_t *io = &(parse.cftable_entry.io); 559 cistpl_io_t *io = &(parse.cftable_entry.io);
563 560
564 if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 561 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
565 pcmcia_parse_tuple(handle, &tuple, &parse) != 0 || 562 pcmcia_parse_tuple(link, &tuple, &parse) != 0 ||
566 cfg->index == 0 || cfg->io.nwin == 0) 563 cfg->index == 0 || cfg->io.nwin == 0)
567 goto next_entry; 564 goto next_entry;
568 565
@@ -586,14 +583,14 @@ static void pcnet_config(dev_link_t *link)
586 if (last_ret == CS_SUCCESS) break; 583 if (last_ret == CS_SUCCESS) break;
587 } 584 }
588 next_entry: 585 next_entry:
589 last_ret = pcmcia_get_next_tuple(handle, &tuple); 586 last_ret = pcmcia_get_next_tuple(link, &tuple);
590 } 587 }
591 if (last_ret != CS_SUCCESS) { 588 if (last_ret != CS_SUCCESS) {
592 cs_error(handle, RequestIO, last_ret); 589 cs_error(link, RequestIO, last_ret);
593 goto failed; 590 goto failed;
594 } 591 }
595 592
596 CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 593 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
597 594
598 if (link->io.NumPorts2 == 8) { 595 if (link->io.NumPorts2 == 8) {
599 link->conf.Attributes |= CONF_ENABLE_SPKR; 596 link->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -603,7 +600,7 @@ static void pcnet_config(dev_link_t *link)
603 (prodid == PRODID_IBM_HOME_AND_AWAY)) 600 (prodid == PRODID_IBM_HOME_AND_AWAY))
604 link->conf.ConfigIndex |= 0x10; 601 link->conf.ConfigIndex |= 0x10;
605 602
606 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 603 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
607 dev->irq = link->irq.AssignedIRQ; 604 dev->irq = link->irq.AssignedIRQ;
608 dev->base_addr = link->io.BasePort1; 605 dev->base_addr = link->io.BasePort1;
609 if (info->flags & HAS_MISC_REG) { 606 if (info->flags & HAS_MISC_REG) {
@@ -673,7 +670,7 @@ static void pcnet_config(dev_link_t *link)
673 670
674 link->dev_node = &info->node; 671 link->dev_node = &info->node;
675 link->state &= ~DEV_CONFIG_PENDING; 672 link->state &= ~DEV_CONFIG_PENDING;
676 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 673 SET_NETDEV_DEV(dev, &handle_to_dev(link));
677 674
678#ifdef CONFIG_NET_POLL_CONTROLLER 675#ifdef CONFIG_NET_POLL_CONTROLLER
679 dev->poll_controller = ei_poll; 676 dev->poll_controller = ei_poll;
@@ -707,7 +704,7 @@ static void pcnet_config(dev_link_t *link)
707 return; 704 return;
708 705
709cs_failed: 706cs_failed:
710 cs_error(link->handle, last_fn, last_ret); 707 cs_error(link, last_fn, last_ret);
711failed: 708failed:
712 pcnet_release(link); 709 pcnet_release(link);
713 link->state &= ~DEV_CONFIG_PENDING; 710 link->state &= ~DEV_CONFIG_PENDING;
@@ -722,7 +719,7 @@ failed:
722 719
723======================================================================*/ 720======================================================================*/
724 721
725static void pcnet_release(dev_link_t *link) 722static void pcnet_release(struct pcmcia_device *link)
726{ 723{
727 pcnet_dev_t *info = PRIV(link->priv); 724 pcnet_dev_t *info = PRIV(link->priv);
728 725
@@ -731,7 +728,7 @@ static void pcnet_release(dev_link_t *link)
731 if (info->flags & USE_SHMEM) 728 if (info->flags & USE_SHMEM)
732 iounmap(info->base); 729 iounmap(info->base);
733 730
734 pcmcia_disable_device(link->handle); 731 pcmcia_disable_device(link);
735} 732}
736 733
737/*====================================================================== 734/*======================================================================
@@ -743,9 +740,8 @@ static void pcnet_release(dev_link_t *link)
743 740
744======================================================================*/ 741======================================================================*/
745 742
746static int pcnet_suspend(struct pcmcia_device *p_dev) 743static int pcnet_suspend(struct pcmcia_device *link)
747{ 744{
748 dev_link_t *link = dev_to_instance(p_dev);
749 struct net_device *dev = link->priv; 745 struct net_device *dev = link->priv;
750 746
751 if ((link->state & DEV_CONFIG) && (link->open)) 747 if ((link->state & DEV_CONFIG) && (link->open))
@@ -754,9 +750,8 @@ static int pcnet_suspend(struct pcmcia_device *p_dev)
754 return 0; 750 return 0;
755} 751}
756 752
757static int pcnet_resume(struct pcmcia_device *p_dev) 753static int pcnet_resume(struct pcmcia_device *link)
758{ 754{
759 dev_link_t *link = dev_to_instance(p_dev);
760 struct net_device *dev = link->priv; 755 struct net_device *dev = link->priv;
761 756
762 if ((link->state & DEV_CONFIG) && (link->open)) { 757 if ((link->state & DEV_CONFIG) && (link->open)) {
@@ -1002,7 +997,7 @@ static void mii_phy_probe(struct net_device *dev)
1002static int pcnet_open(struct net_device *dev) 997static int pcnet_open(struct net_device *dev)
1003{ 998{
1004 pcnet_dev_t *info = PRIV(dev); 999 pcnet_dev_t *info = PRIV(dev);
1005 dev_link_t *link = info->p_dev; 1000 struct pcmcia_device *link = info->p_dev;
1006 1001
1007 DEBUG(2, "pcnet_open('%s')\n", dev->name); 1002 DEBUG(2, "pcnet_open('%s')\n", dev->name);
1008 1003
@@ -1030,7 +1025,7 @@ static int pcnet_open(struct net_device *dev)
1030static int pcnet_close(struct net_device *dev) 1025static int pcnet_close(struct net_device *dev)
1031{ 1026{
1032 pcnet_dev_t *info = PRIV(dev); 1027 pcnet_dev_t *info = PRIV(dev);
1033 dev_link_t *link = info->p_dev; 1028 struct pcmcia_device *link = info->p_dev;
1034 1029
1035 DEBUG(2, "pcnet_close('%s')\n", dev->name); 1030 DEBUG(2, "pcnet_close('%s')\n", dev->name);
1036 1031
@@ -1408,7 +1403,7 @@ static void dma_block_output(struct net_device *dev, int count,
1408 1403
1409/*====================================================================*/ 1404/*====================================================================*/
1410 1405
1411static int setup_dma_config(dev_link_t *link, int start_pg, 1406static int setup_dma_config(struct pcmcia_device *link, int start_pg,
1412 int stop_pg) 1407 int stop_pg)
1413{ 1408{
1414 struct net_device *dev = link->priv; 1409 struct net_device *dev = link->priv;
@@ -1511,7 +1506,7 @@ static void shmem_block_output(struct net_device *dev, int count,
1511 1506
1512/*====================================================================*/ 1507/*====================================================================*/
1513 1508
1514static int setup_shmem_window(dev_link_t *link, int start_pg, 1509static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1515 int stop_pg, int cm_offset) 1510 int stop_pg, int cm_offset)
1516{ 1511{
1517 struct net_device *dev = link->priv; 1512 struct net_device *dev = link->priv;
@@ -1533,7 +1528,7 @@ static int setup_shmem_window(dev_link_t *link, int start_pg,
1533 req.Attributes |= WIN_USE_WAIT; 1528 req.Attributes |= WIN_USE_WAIT;
1534 req.Base = 0; req.Size = window_size; 1529 req.Base = 0; req.Size = window_size;
1535 req.AccessSpeed = mem_speed; 1530 req.AccessSpeed = mem_speed;
1536 CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 1531 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win));
1537 1532
1538 mem.CardOffset = (start_pg << 8) + cm_offset; 1533 mem.CardOffset = (start_pg << 8) + cm_offset;
1539 offset = mem.CardOffset % window_size; 1534 offset = mem.CardOffset % window_size;
@@ -1574,7 +1569,7 @@ static int setup_shmem_window(dev_link_t *link, int start_pg,
1574 return 0; 1569 return 0;
1575 1570
1576cs_failed: 1571cs_failed:
1577 cs_error(link->handle, last_fn, last_ret); 1572 cs_error(link, last_fn, last_ret);
1578failed: 1573failed:
1579 return 1; 1574 return 1;
1580} 1575}