diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2012-03-13 07:04:26 -0400 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2012-04-07 05:47:18 -0400 |
commit | aae9bc302de493ad62102e7cdb1e123648057b66 (patch) | |
tree | d60e1a64ca9fff1a1540acf7ef5220f2be31bd71 /drivers/net/ethernet/smsc | |
parent | 3acf4b5cde8123a7a243d9dcd63f3e6990c8e5bb (diff) |
epic100: stop using net_device.{base_addr, irq} and convert to __iomem.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'drivers/net/ethernet/smsc')
-rw-r--r-- | drivers/net/ethernet/smsc/epic100.c | 403 |
1 files changed, 201 insertions, 202 deletions
diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c index 2a662e6112e9..d01e59c348ad 100644 --- a/drivers/net/ethernet/smsc/epic100.c +++ b/drivers/net/ethernet/smsc/epic100.c | |||
@@ -146,6 +146,12 @@ enum chip_capability_flags { MII_PWRDWN=1, TYPE2_INTR=2, NO_MII=4 }; | |||
146 | #define EPIC_TOTAL_SIZE 0x100 | 146 | #define EPIC_TOTAL_SIZE 0x100 |
147 | #define USE_IO_OPS 1 | 147 | #define USE_IO_OPS 1 |
148 | 148 | ||
149 | #ifdef USE_IO_OPS | ||
150 | #define EPIC_BAR 0 | ||
151 | #else | ||
152 | #define EPIC_BAR 1 | ||
153 | #endif | ||
154 | |||
149 | typedef enum { | 155 | typedef enum { |
150 | SMSC_83C170_0, | 156 | SMSC_83C170_0, |
151 | SMSC_83C170, | 157 | SMSC_83C170, |
@@ -176,21 +182,11 @@ static DEFINE_PCI_DEVICE_TABLE(epic_pci_tbl) = { | |||
176 | }; | 182 | }; |
177 | MODULE_DEVICE_TABLE (pci, epic_pci_tbl); | 183 | MODULE_DEVICE_TABLE (pci, epic_pci_tbl); |
178 | 184 | ||
179 | 185 | #define ew16(reg, val) iowrite16(val, ioaddr + (reg)) | |
180 | #ifndef USE_IO_OPS | 186 | #define ew32(reg, val) iowrite32(val, ioaddr + (reg)) |
181 | #undef inb | 187 | #define er8(reg) ioread8(ioaddr + (reg)) |
182 | #undef inw | 188 | #define er16(reg) ioread16(ioaddr + (reg)) |
183 | #undef inl | 189 | #define er32(reg) ioread32(ioaddr + (reg)) |
184 | #undef outb | ||
185 | #undef outw | ||
186 | #undef outl | ||
187 | #define inb readb | ||
188 | #define inw readw | ||
189 | #define inl readl | ||
190 | #define outb writeb | ||
191 | #define outw writew | ||
192 | #define outl writel | ||
193 | #endif | ||
194 | 190 | ||
195 | /* Offsets to registers, using the (ugh) SMC names. */ | 191 | /* Offsets to registers, using the (ugh) SMC names. */ |
196 | enum epic_registers { | 192 | enum epic_registers { |
@@ -275,6 +271,7 @@ struct epic_private { | |||
275 | u32 irq_mask; | 271 | u32 irq_mask; |
276 | unsigned int rx_buf_sz; /* Based on MTU+slack. */ | 272 | unsigned int rx_buf_sz; /* Based on MTU+slack. */ |
277 | 273 | ||
274 | void __iomem *ioaddr; | ||
278 | struct pci_dev *pci_dev; /* PCI bus location. */ | 275 | struct pci_dev *pci_dev; /* PCI bus location. */ |
279 | int chip_id, chip_flags; | 276 | int chip_id, chip_flags; |
280 | 277 | ||
@@ -290,7 +287,7 @@ struct epic_private { | |||
290 | }; | 287 | }; |
291 | 288 | ||
292 | static int epic_open(struct net_device *dev); | 289 | static int epic_open(struct net_device *dev); |
293 | static int read_eeprom(long ioaddr, int location); | 290 | static int read_eeprom(struct epic_private *, int); |
294 | static int mdio_read(struct net_device *dev, int phy_id, int location); | 291 | static int mdio_read(struct net_device *dev, int phy_id, int location); |
295 | static void mdio_write(struct net_device *dev, int phy_id, int loc, int val); | 292 | static void mdio_write(struct net_device *dev, int phy_id, int loc, int val); |
296 | static void epic_restart(struct net_device *dev); | 293 | static void epic_restart(struct net_device *dev); |
@@ -321,11 +318,11 @@ static const struct net_device_ops epic_netdev_ops = { | |||
321 | .ndo_validate_addr = eth_validate_addr, | 318 | .ndo_validate_addr = eth_validate_addr, |
322 | }; | 319 | }; |
323 | 320 | ||
324 | static int __devinit epic_init_one (struct pci_dev *pdev, | 321 | static int __devinit epic_init_one(struct pci_dev *pdev, |
325 | const struct pci_device_id *ent) | 322 | const struct pci_device_id *ent) |
326 | { | 323 | { |
327 | static int card_idx = -1; | 324 | static int card_idx = -1; |
328 | long ioaddr; | 325 | void __iomem *ioaddr; |
329 | int chip_idx = (int) ent->driver_data; | 326 | int chip_idx = (int) ent->driver_data; |
330 | int irq; | 327 | int irq; |
331 | struct net_device *dev; | 328 | struct net_device *dev; |
@@ -368,19 +365,15 @@ static int __devinit epic_init_one (struct pci_dev *pdev, | |||
368 | 365 | ||
369 | SET_NETDEV_DEV(dev, &pdev->dev); | 366 | SET_NETDEV_DEV(dev, &pdev->dev); |
370 | 367 | ||
371 | #ifdef USE_IO_OPS | 368 | ioaddr = pci_iomap(pdev, EPIC_BAR, 0); |
372 | ioaddr = pci_resource_start (pdev, 0); | ||
373 | #else | ||
374 | ioaddr = pci_resource_start (pdev, 1); | ||
375 | ioaddr = (long) pci_ioremap_bar(pdev, 1); | ||
376 | if (!ioaddr) { | 369 | if (!ioaddr) { |
377 | dev_err(&pdev->dev, "ioremap failed\n"); | 370 | dev_err(&pdev->dev, "ioremap failed\n"); |
378 | goto err_out_free_netdev; | 371 | goto err_out_free_netdev; |
379 | } | 372 | } |
380 | #endif | ||
381 | 373 | ||
382 | pci_set_drvdata(pdev, dev); | 374 | pci_set_drvdata(pdev, dev); |
383 | ep = netdev_priv(dev); | 375 | ep = netdev_priv(dev); |
376 | ep->ioaddr = ioaddr; | ||
384 | ep->mii.dev = dev; | 377 | ep->mii.dev = dev; |
385 | ep->mii.mdio_read = mdio_read; | 378 | ep->mii.mdio_read = mdio_read; |
386 | ep->mii.mdio_write = mdio_write; | 379 | ep->mii.mdio_write = mdio_write; |
@@ -409,34 +402,31 @@ static int __devinit epic_init_one (struct pci_dev *pdev, | |||
409 | duplex = full_duplex[card_idx]; | 402 | duplex = full_duplex[card_idx]; |
410 | } | 403 | } |
411 | 404 | ||
412 | dev->base_addr = ioaddr; | ||
413 | dev->irq = irq; | ||
414 | |||
415 | spin_lock_init(&ep->lock); | 405 | spin_lock_init(&ep->lock); |
416 | spin_lock_init(&ep->napi_lock); | 406 | spin_lock_init(&ep->napi_lock); |
417 | ep->reschedule_in_poll = 0; | 407 | ep->reschedule_in_poll = 0; |
418 | 408 | ||
419 | /* Bring the chip out of low-power mode. */ | 409 | /* Bring the chip out of low-power mode. */ |
420 | outl(0x4200, ioaddr + GENCTL); | 410 | ew32(GENCTL, 0x4200); |
421 | /* Magic?! If we don't set this bit the MII interface won't work. */ | 411 | /* Magic?! If we don't set this bit the MII interface won't work. */ |
422 | /* This magic is documented in SMSC app note 7.15 */ | 412 | /* This magic is documented in SMSC app note 7.15 */ |
423 | for (i = 16; i > 0; i--) | 413 | for (i = 16; i > 0; i--) |
424 | outl(0x0008, ioaddr + TEST1); | 414 | ew32(TEST1, 0x0008); |
425 | 415 | ||
426 | /* Turn on the MII transceiver. */ | 416 | /* Turn on the MII transceiver. */ |
427 | outl(0x12, ioaddr + MIICfg); | 417 | ew32(MIICfg, 0x12); |
428 | if (chip_idx == 1) | 418 | if (chip_idx == 1) |
429 | outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL); | 419 | ew32(NVCTL, (er32(NVCTL) & ~0x003c) | 0x4800); |
430 | outl(0x0200, ioaddr + GENCTL); | 420 | ew32(GENCTL, 0x0200); |
431 | 421 | ||
432 | /* Note: the '175 does not have a serial EEPROM. */ | 422 | /* Note: the '175 does not have a serial EEPROM. */ |
433 | for (i = 0; i < 3; i++) | 423 | for (i = 0; i < 3; i++) |
434 | ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(inw(ioaddr + LAN0 + i*4)); | 424 | ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(er16(LAN0 + i*4)); |
435 | 425 | ||
436 | if (debug > 2) { | 426 | if (debug > 2) { |
437 | dev_printk(KERN_DEBUG, &pdev->dev, "EEPROM contents:\n"); | 427 | dev_printk(KERN_DEBUG, &pdev->dev, "EEPROM contents:\n"); |
438 | for (i = 0; i < 64; i++) | 428 | for (i = 0; i < 64; i++) |
439 | printk(" %4.4x%s", read_eeprom(ioaddr, i), | 429 | printk(" %4.4x%s", read_eeprom(ep, i), |
440 | i % 16 == 15 ? "\n" : ""); | 430 | i % 16 == 15 ? "\n" : ""); |
441 | } | 431 | } |
442 | 432 | ||
@@ -481,8 +471,8 @@ static int __devinit epic_init_one (struct pci_dev *pdev, | |||
481 | 471 | ||
482 | /* Turn off the MII xcvr (175 only!), leave the chip in low-power mode. */ | 472 | /* Turn off the MII xcvr (175 only!), leave the chip in low-power mode. */ |
483 | if (ep->chip_flags & MII_PWRDWN) | 473 | if (ep->chip_flags & MII_PWRDWN) |
484 | outl(inl(ioaddr + NVCTL) & ~0x483C, ioaddr + NVCTL); | 474 | ew32(NVCTL, er32(NVCTL) & ~0x483c); |
485 | outl(0x0008, ioaddr + GENCTL); | 475 | ew32(GENCTL, 0x0008); |
486 | 476 | ||
487 | /* The lower four bits are the media type. */ | 477 | /* The lower four bits are the media type. */ |
488 | if (duplex) { | 478 | if (duplex) { |
@@ -501,8 +491,9 @@ static int __devinit epic_init_one (struct pci_dev *pdev, | |||
501 | if (ret < 0) | 491 | if (ret < 0) |
502 | goto err_out_unmap_rx; | 492 | goto err_out_unmap_rx; |
503 | 493 | ||
504 | printk(KERN_INFO "%s: %s at %#lx, IRQ %d, %pM\n", | 494 | printk(KERN_INFO "%s: %s at %lx, IRQ %d, %pM\n", |
505 | dev->name, pci_id_tbl[chip_idx].name, ioaddr, dev->irq, | 495 | dev->name, pci_id_tbl[chip_idx].name, |
496 | (long)pci_resource_start(pdev, EPIC_BAR), pdev->irq, | ||
506 | dev->dev_addr); | 497 | dev->dev_addr); |
507 | 498 | ||
508 | out: | 499 | out: |
@@ -513,10 +504,8 @@ err_out_unmap_rx: | |||
513 | err_out_unmap_tx: | 504 | err_out_unmap_tx: |
514 | pci_free_consistent(pdev, TX_TOTAL_SIZE, ep->tx_ring, ep->tx_ring_dma); | 505 | pci_free_consistent(pdev, TX_TOTAL_SIZE, ep->tx_ring, ep->tx_ring_dma); |
515 | err_out_iounmap: | 506 | err_out_iounmap: |
516 | #ifndef USE_IO_OPS | 507 | pci_iounmap(pdev, ioaddr); |
517 | iounmap(ioaddr); | ||
518 | err_out_free_netdev: | 508 | err_out_free_netdev: |
519 | #endif | ||
520 | free_netdev(dev); | 509 | free_netdev(dev); |
521 | err_out_free_res: | 510 | err_out_free_res: |
522 | pci_release_regions(pdev); | 511 | pci_release_regions(pdev); |
@@ -540,7 +529,7 @@ err_out_disable: | |||
540 | This serves to flush the operation to the PCI bus. | 529 | This serves to flush the operation to the PCI bus. |
541 | */ | 530 | */ |
542 | 531 | ||
543 | #define eeprom_delay() inl(ee_addr) | 532 | #define eeprom_delay() er32(EECTL) |
544 | 533 | ||
545 | /* The EEPROM commands include the alway-set leading bit. */ | 534 | /* The EEPROM commands include the alway-set leading bit. */ |
546 | #define EE_WRITE_CMD (5 << 6) | 535 | #define EE_WRITE_CMD (5 << 6) |
@@ -550,67 +539,67 @@ err_out_disable: | |||
550 | 539 | ||
551 | static void epic_disable_int(struct net_device *dev, struct epic_private *ep) | 540 | static void epic_disable_int(struct net_device *dev, struct epic_private *ep) |
552 | { | 541 | { |
553 | long ioaddr = dev->base_addr; | 542 | void __iomem *ioaddr = ep->ioaddr; |
554 | 543 | ||
555 | outl(0x00000000, ioaddr + INTMASK); | 544 | ew32(INTMASK, 0x00000000); |
556 | } | 545 | } |
557 | 546 | ||
558 | static inline void __epic_pci_commit(long ioaddr) | 547 | static inline void __epic_pci_commit(void __iomem *ioaddr) |
559 | { | 548 | { |
560 | #ifndef USE_IO_OPS | 549 | #ifndef USE_IO_OPS |
561 | inl(ioaddr + INTMASK); | 550 | er32(INTMASK); |
562 | #endif | 551 | #endif |
563 | } | 552 | } |
564 | 553 | ||
565 | static inline void epic_napi_irq_off(struct net_device *dev, | 554 | static inline void epic_napi_irq_off(struct net_device *dev, |
566 | struct epic_private *ep) | 555 | struct epic_private *ep) |
567 | { | 556 | { |
568 | long ioaddr = dev->base_addr; | 557 | void __iomem *ioaddr = ep->ioaddr; |
569 | 558 | ||
570 | outl(ep->irq_mask & ~EpicNapiEvent, ioaddr + INTMASK); | 559 | ew32(INTMASK, ep->irq_mask & ~EpicNapiEvent); |
571 | __epic_pci_commit(ioaddr); | 560 | __epic_pci_commit(ioaddr); |
572 | } | 561 | } |
573 | 562 | ||
574 | static inline void epic_napi_irq_on(struct net_device *dev, | 563 | static inline void epic_napi_irq_on(struct net_device *dev, |
575 | struct epic_private *ep) | 564 | struct epic_private *ep) |
576 | { | 565 | { |
577 | long ioaddr = dev->base_addr; | 566 | void __iomem *ioaddr = ep->ioaddr; |
578 | 567 | ||
579 | /* No need to commit possible posted write */ | 568 | /* No need to commit possible posted write */ |
580 | outl(ep->irq_mask | EpicNapiEvent, ioaddr + INTMASK); | 569 | ew32(INTMASK, ep->irq_mask | EpicNapiEvent); |
581 | } | 570 | } |
582 | 571 | ||
583 | static int __devinit read_eeprom(long ioaddr, int location) | 572 | static int __devinit read_eeprom(struct epic_private *ep, int location) |
584 | { | 573 | { |
574 | void __iomem *ioaddr = ep->ioaddr; | ||
585 | int i; | 575 | int i; |
586 | int retval = 0; | 576 | int retval = 0; |
587 | long ee_addr = ioaddr + EECTL; | ||
588 | int read_cmd = location | | 577 | int read_cmd = location | |
589 | (inl(ee_addr) & 0x40 ? EE_READ64_CMD : EE_READ256_CMD); | 578 | (er32(EECTL) & 0x40 ? EE_READ64_CMD : EE_READ256_CMD); |
590 | 579 | ||
591 | outl(EE_ENB & ~EE_CS, ee_addr); | 580 | ew32(EECTL, EE_ENB & ~EE_CS); |
592 | outl(EE_ENB, ee_addr); | 581 | ew32(EECTL, EE_ENB); |
593 | 582 | ||
594 | /* Shift the read command bits out. */ | 583 | /* Shift the read command bits out. */ |
595 | for (i = 12; i >= 0; i--) { | 584 | for (i = 12; i >= 0; i--) { |
596 | short dataval = (read_cmd & (1 << i)) ? EE_WRITE_1 : EE_WRITE_0; | 585 | short dataval = (read_cmd & (1 << i)) ? EE_WRITE_1 : EE_WRITE_0; |
597 | outl(EE_ENB | dataval, ee_addr); | 586 | ew32(EECTL, EE_ENB | dataval); |
598 | eeprom_delay(); | 587 | eeprom_delay(); |
599 | outl(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr); | 588 | ew32(EECTL, EE_ENB | dataval | EE_SHIFT_CLK); |
600 | eeprom_delay(); | 589 | eeprom_delay(); |
601 | } | 590 | } |
602 | outl(EE_ENB, ee_addr); | 591 | ew32(EECTL, EE_ENB); |
603 | 592 | ||
604 | for (i = 16; i > 0; i--) { | 593 | for (i = 16; i > 0; i--) { |
605 | outl(EE_ENB | EE_SHIFT_CLK, ee_addr); | 594 | ew32(EECTL, EE_ENB | EE_SHIFT_CLK); |
606 | eeprom_delay(); | 595 | eeprom_delay(); |
607 | retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0); | 596 | retval = (retval << 1) | ((er32(EECTL) & EE_DATA_READ) ? 1 : 0); |
608 | outl(EE_ENB, ee_addr); | 597 | ew32(EECTL, EE_ENB); |
609 | eeprom_delay(); | 598 | eeprom_delay(); |
610 | } | 599 | } |
611 | 600 | ||
612 | /* Terminate the EEPROM access. */ | 601 | /* Terminate the EEPROM access. */ |
613 | outl(EE_ENB & ~EE_CS, ee_addr); | 602 | ew32(EECTL, EE_ENB & ~EE_CS); |
614 | return retval; | 603 | return retval; |
615 | } | 604 | } |
616 | 605 | ||
@@ -618,22 +607,23 @@ static int __devinit read_eeprom(long ioaddr, int location) | |||
618 | #define MII_WRITEOP 2 | 607 | #define MII_WRITEOP 2 |
619 | static int mdio_read(struct net_device *dev, int phy_id, int location) | 608 | static int mdio_read(struct net_device *dev, int phy_id, int location) |
620 | { | 609 | { |
621 | long ioaddr = dev->base_addr; | 610 | struct epic_private *ep = netdev_priv(dev); |
611 | void __iomem *ioaddr = ep->ioaddr; | ||
622 | int read_cmd = (phy_id << 9) | (location << 4) | MII_READOP; | 612 | int read_cmd = (phy_id << 9) | (location << 4) | MII_READOP; |
623 | int i; | 613 | int i; |
624 | 614 | ||
625 | outl(read_cmd, ioaddr + MIICtrl); | 615 | ew32(MIICtrl, read_cmd); |
626 | /* Typical operation takes 25 loops. */ | 616 | /* Typical operation takes 25 loops. */ |
627 | for (i = 400; i > 0; i--) { | 617 | for (i = 400; i > 0; i--) { |
628 | barrier(); | 618 | barrier(); |
629 | if ((inl(ioaddr + MIICtrl) & MII_READOP) == 0) { | 619 | if ((er32(MIICtrl) & MII_READOP) == 0) { |
630 | /* Work around read failure bug. */ | 620 | /* Work around read failure bug. */ |
631 | if (phy_id == 1 && location < 6 && | 621 | if (phy_id == 1 && location < 6 && |
632 | inw(ioaddr + MIIData) == 0xffff) { | 622 | er16(MIIData) == 0xffff) { |
633 | outl(read_cmd, ioaddr + MIICtrl); | 623 | ew32(MIICtrl, read_cmd); |
634 | continue; | 624 | continue; |
635 | } | 625 | } |
636 | return inw(ioaddr + MIIData); | 626 | return er16(MIIData); |
637 | } | 627 | } |
638 | } | 628 | } |
639 | return 0xffff; | 629 | return 0xffff; |
@@ -641,14 +631,15 @@ static int mdio_read(struct net_device *dev, int phy_id, int location) | |||
641 | 631 | ||
642 | static void mdio_write(struct net_device *dev, int phy_id, int loc, int value) | 632 | static void mdio_write(struct net_device *dev, int phy_id, int loc, int value) |
643 | { | 633 | { |
644 | long ioaddr = dev->base_addr; | 634 | struct epic_private *ep = netdev_priv(dev); |
635 | void __iomem *ioaddr = ep->ioaddr; | ||
645 | int i; | 636 | int i; |
646 | 637 | ||
647 | outw(value, ioaddr + MIIData); | 638 | ew16(MIIData, value); |
648 | outl((phy_id << 9) | (loc << 4) | MII_WRITEOP, ioaddr + MIICtrl); | 639 | ew32(MIICtrl, (phy_id << 9) | (loc << 4) | MII_WRITEOP); |
649 | for (i = 10000; i > 0; i--) { | 640 | for (i = 10000; i > 0; i--) { |
650 | barrier(); | 641 | barrier(); |
651 | if ((inl(ioaddr + MIICtrl) & MII_WRITEOP) == 0) | 642 | if ((er32(MIICtrl) & MII_WRITEOP) == 0) |
652 | break; | 643 | break; |
653 | } | 644 | } |
654 | } | 645 | } |
@@ -657,25 +648,26 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int value) | |||
657 | static int epic_open(struct net_device *dev) | 648 | static int epic_open(struct net_device *dev) |
658 | { | 649 | { |
659 | struct epic_private *ep = netdev_priv(dev); | 650 | struct epic_private *ep = netdev_priv(dev); |
660 | long ioaddr = dev->base_addr; | 651 | void __iomem *ioaddr = ep->ioaddr; |
661 | int i; | 652 | const int irq = ep->pci_dev->irq; |
662 | int retval; | 653 | int rc, i; |
663 | 654 | ||
664 | /* Soft reset the chip. */ | 655 | /* Soft reset the chip. */ |
665 | outl(0x4001, ioaddr + GENCTL); | 656 | ew32(GENCTL, 0x4001); |
666 | 657 | ||
667 | napi_enable(&ep->napi); | 658 | napi_enable(&ep->napi); |
668 | if ((retval = request_irq(dev->irq, epic_interrupt, IRQF_SHARED, dev->name, dev))) { | 659 | rc = request_irq(irq, epic_interrupt, IRQF_SHARED, dev->name, dev); |
660 | if (rc) { | ||
669 | napi_disable(&ep->napi); | 661 | napi_disable(&ep->napi); |
670 | return retval; | 662 | return rc; |
671 | } | 663 | } |
672 | 664 | ||
673 | epic_init_ring(dev); | 665 | epic_init_ring(dev); |
674 | 666 | ||
675 | outl(0x4000, ioaddr + GENCTL); | 667 | ew32(GENCTL, 0x4000); |
676 | /* This magic is documented in SMSC app note 7.15 */ | 668 | /* This magic is documented in SMSC app note 7.15 */ |
677 | for (i = 16; i > 0; i--) | 669 | for (i = 16; i > 0; i--) |
678 | outl(0x0008, ioaddr + TEST1); | 670 | ew32(TEST1, 0x0008); |
679 | 671 | ||
680 | /* Pull the chip out of low-power mode, enable interrupts, and set for | 672 | /* Pull the chip out of low-power mode, enable interrupts, and set for |
681 | PCI read multiple. The MIIcfg setting and strange write order are | 673 | PCI read multiple. The MIIcfg setting and strange write order are |
@@ -683,29 +675,29 @@ static int epic_open(struct net_device *dev) | |||
683 | wiring on the Ositech CardBus card. | 675 | wiring on the Ositech CardBus card. |
684 | */ | 676 | */ |
685 | #if 0 | 677 | #if 0 |
686 | outl(dev->if_port == 1 ? 0x13 : 0x12, ioaddr + MIICfg); | 678 | ew32(MIICfg, dev->if_port == 1 ? 0x13 : 0x12); |
687 | #endif | 679 | #endif |
688 | if (ep->chip_flags & MII_PWRDWN) | 680 | if (ep->chip_flags & MII_PWRDWN) |
689 | outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL); | 681 | ew32(NVCTL, (er32(NVCTL) & ~0x003c) | 0x4800); |
690 | 682 | ||
691 | /* Tell the chip to byteswap descriptors on big-endian hosts */ | 683 | /* Tell the chip to byteswap descriptors on big-endian hosts */ |
692 | #ifdef __BIG_ENDIAN | 684 | #ifdef __BIG_ENDIAN |
693 | outl(0x4432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); | 685 | ew32(GENCTL, 0x4432 | (RX_FIFO_THRESH << 8)); |
694 | inl(ioaddr + GENCTL); | 686 | er32(GENCTL); |
695 | outl(0x0432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); | 687 | ew32(GENCTL, 0x0432 | (RX_FIFO_THRESH << 8)); |
696 | #else | 688 | #else |
697 | outl(0x4412 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); | 689 | ew32(GENCTL, 0x4412 | (RX_FIFO_THRESH << 8)); |
698 | inl(ioaddr + GENCTL); | 690 | er32(GENCTL); |
699 | outl(0x0412 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); | 691 | ew32(GENCTL, 0x0412 | (RX_FIFO_THRESH << 8)); |
700 | #endif | 692 | #endif |
701 | 693 | ||
702 | udelay(20); /* Looks like EPII needs that if you want reliable RX init. FIXME: pci posting bug? */ | 694 | udelay(20); /* Looks like EPII needs that if you want reliable RX init. FIXME: pci posting bug? */ |
703 | 695 | ||
704 | for (i = 0; i < 3; i++) | 696 | for (i = 0; i < 3; i++) |
705 | outl(le16_to_cpu(((__le16*)dev->dev_addr)[i]), ioaddr + LAN0 + i*4); | 697 | ew32(LAN0 + i*4, le16_to_cpu(((__le16*)dev->dev_addr)[i])); |
706 | 698 | ||
707 | ep->tx_threshold = TX_FIFO_THRESH; | 699 | ep->tx_threshold = TX_FIFO_THRESH; |
708 | outl(ep->tx_threshold, ioaddr + TxThresh); | 700 | ew32(TxThresh, ep->tx_threshold); |
709 | 701 | ||
710 | if (media2miictl[dev->if_port & 15]) { | 702 | if (media2miictl[dev->if_port & 15]) { |
711 | if (ep->mii_phy_cnt) | 703 | if (ep->mii_phy_cnt) |
@@ -731,26 +723,27 @@ static int epic_open(struct net_device *dev) | |||
731 | } | 723 | } |
732 | } | 724 | } |
733 | 725 | ||
734 | outl(ep->mii.full_duplex ? 0x7F : 0x79, ioaddr + TxCtrl); | 726 | ew32(TxCtrl, ep->mii.full_duplex ? 0x7f : 0x79); |
735 | outl(ep->rx_ring_dma, ioaddr + PRxCDAR); | 727 | ew32(PRxCDAR, ep->rx_ring_dma); |
736 | outl(ep->tx_ring_dma, ioaddr + PTxCDAR); | 728 | ew32(PTxCDAR, ep->tx_ring_dma); |
737 | 729 | ||
738 | /* Start the chip's Rx process. */ | 730 | /* Start the chip's Rx process. */ |
739 | set_rx_mode(dev); | 731 | set_rx_mode(dev); |
740 | outl(StartRx | RxQueued, ioaddr + COMMAND); | 732 | ew32(COMMAND, StartRx | RxQueued); |
741 | 733 | ||
742 | netif_start_queue(dev); | 734 | netif_start_queue(dev); |
743 | 735 | ||
744 | /* Enable interrupts by setting the interrupt mask. */ | 736 | /* Enable interrupts by setting the interrupt mask. */ |
745 | outl((ep->chip_flags & TYPE2_INTR ? PCIBusErr175 : PCIBusErr170) | 737 | ew32(INTMASK, RxError | RxHeader | EpicNapiEvent | CntFull | |
746 | | CntFull | TxUnderrun | 738 | ((ep->chip_flags & TYPE2_INTR) ? PCIBusErr175 : PCIBusErr170) | |
747 | | RxError | RxHeader | EpicNapiEvent, ioaddr + INTMASK); | 739 | TxUnderrun); |
748 | 740 | ||
749 | if (debug > 1) | 741 | if (debug > 1) { |
750 | printk(KERN_DEBUG "%s: epic_open() ioaddr %lx IRQ %d status %4.4x " | 742 | printk(KERN_DEBUG "%s: epic_open() ioaddr %p IRQ %d " |
751 | "%s-duplex.\n", | 743 | "status %4.4x %s-duplex.\n", |
752 | dev->name, ioaddr, dev->irq, (int)inl(ioaddr + GENCTL), | 744 | dev->name, ioaddr, irq, er32(GENCTL), |
753 | ep->mii.full_duplex ? "full" : "half"); | 745 | ep->mii.full_duplex ? "full" : "half"); |
746 | } | ||
754 | 747 | ||
755 | /* Set the timer to switch to check for link beat and perhaps switch | 748 | /* Set the timer to switch to check for link beat and perhaps switch |
756 | to an alternate media type. */ | 749 | to an alternate media type. */ |
@@ -760,27 +753,29 @@ static int epic_open(struct net_device *dev) | |||
760 | ep->timer.function = epic_timer; /* timer handler */ | 753 | ep->timer.function = epic_timer; /* timer handler */ |
761 | add_timer(&ep->timer); | 754 | add_timer(&ep->timer); |
762 | 755 | ||
763 | return 0; | 756 | return rc; |
764 | } | 757 | } |
765 | 758 | ||
766 | /* Reset the chip to recover from a PCI transaction error. | 759 | /* Reset the chip to recover from a PCI transaction error. |
767 | This may occur at interrupt time. */ | 760 | This may occur at interrupt time. */ |
768 | static void epic_pause(struct net_device *dev) | 761 | static void epic_pause(struct net_device *dev) |
769 | { | 762 | { |
770 | long ioaddr = dev->base_addr; | 763 | struct net_device_stats *stats = &dev->stats; |
764 | struct epic_private *ep = netdev_priv(dev); | ||
765 | void __iomem *ioaddr = ep->ioaddr; | ||
771 | 766 | ||
772 | netif_stop_queue (dev); | 767 | netif_stop_queue (dev); |
773 | 768 | ||
774 | /* Disable interrupts by clearing the interrupt mask. */ | 769 | /* Disable interrupts by clearing the interrupt mask. */ |
775 | outl(0x00000000, ioaddr + INTMASK); | 770 | ew32(INTMASK, 0x00000000); |
776 | /* Stop the chip's Tx and Rx DMA processes. */ | 771 | /* Stop the chip's Tx and Rx DMA processes. */ |
777 | outw(StopRx | StopTxDMA | StopRxDMA, ioaddr + COMMAND); | 772 | ew16(COMMAND, StopRx | StopTxDMA | StopRxDMA); |
778 | 773 | ||
779 | /* Update the error counts. */ | 774 | /* Update the error counts. */ |
780 | if (inw(ioaddr + COMMAND) != 0xffff) { | 775 | if (er16(COMMAND) != 0xffff) { |
781 | dev->stats.rx_missed_errors += inb(ioaddr + MPCNT); | 776 | stats->rx_missed_errors += er8(MPCNT); |
782 | dev->stats.rx_frame_errors += inb(ioaddr + ALICNT); | 777 | stats->rx_frame_errors += er8(ALICNT); |
783 | dev->stats.rx_crc_errors += inb(ioaddr + CRCCNT); | 778 | stats->rx_crc_errors += er8(CRCCNT); |
784 | } | 779 | } |
785 | 780 | ||
786 | /* Remove the packets on the Rx queue. */ | 781 | /* Remove the packets on the Rx queue. */ |
@@ -789,12 +784,12 @@ static void epic_pause(struct net_device *dev) | |||
789 | 784 | ||
790 | static void epic_restart(struct net_device *dev) | 785 | static void epic_restart(struct net_device *dev) |
791 | { | 786 | { |
792 | long ioaddr = dev->base_addr; | ||
793 | struct epic_private *ep = netdev_priv(dev); | 787 | struct epic_private *ep = netdev_priv(dev); |
788 | void __iomem *ioaddr = ep->ioaddr; | ||
794 | int i; | 789 | int i; |
795 | 790 | ||
796 | /* Soft reset the chip. */ | 791 | /* Soft reset the chip. */ |
797 | outl(0x4001, ioaddr + GENCTL); | 792 | ew32(GENCTL, 0x4001); |
798 | 793 | ||
799 | printk(KERN_DEBUG "%s: Restarting the EPIC chip, Rx %d/%d Tx %d/%d.\n", | 794 | printk(KERN_DEBUG "%s: Restarting the EPIC chip, Rx %d/%d Tx %d/%d.\n", |
800 | dev->name, ep->cur_rx, ep->dirty_rx, ep->dirty_tx, ep->cur_tx); | 795 | dev->name, ep->cur_rx, ep->dirty_rx, ep->dirty_tx, ep->cur_tx); |
@@ -802,47 +797,46 @@ static void epic_restart(struct net_device *dev) | |||
802 | 797 | ||
803 | /* This magic is documented in SMSC app note 7.15 */ | 798 | /* This magic is documented in SMSC app note 7.15 */ |
804 | for (i = 16; i > 0; i--) | 799 | for (i = 16; i > 0; i--) |
805 | outl(0x0008, ioaddr + TEST1); | 800 | ew32(TEST1, 0x0008); |
806 | 801 | ||
807 | #ifdef __BIG_ENDIAN | 802 | #ifdef __BIG_ENDIAN |
808 | outl(0x0432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); | 803 | ew32(GENCTL, 0x0432 | (RX_FIFO_THRESH << 8)); |
809 | #else | 804 | #else |
810 | outl(0x0412 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); | 805 | ew32(GENCTL, 0x0412 | (RX_FIFO_THRESH << 8)); |
811 | #endif | 806 | #endif |
812 | outl(dev->if_port == 1 ? 0x13 : 0x12, ioaddr + MIICfg); | 807 | ew32(MIICfg, dev->if_port == 1 ? 0x13 : 0x12); |
813 | if (ep->chip_flags & MII_PWRDWN) | 808 | if (ep->chip_flags & MII_PWRDWN) |
814 | outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL); | 809 | ew32(NVCTL, (er32(NVCTL) & ~0x003c) | 0x4800); |
815 | 810 | ||
816 | for (i = 0; i < 3; i++) | 811 | for (i = 0; i < 3; i++) |
817 | outl(le16_to_cpu(((__le16*)dev->dev_addr)[i]), ioaddr + LAN0 + i*4); | 812 | ew32(LAN0 + i*4, le16_to_cpu(((__le16*)dev->dev_addr)[i])); |
818 | 813 | ||
819 | ep->tx_threshold = TX_FIFO_THRESH; | 814 | ep->tx_threshold = TX_FIFO_THRESH; |
820 | outl(ep->tx_threshold, ioaddr + TxThresh); | 815 | ew32(TxThresh, ep->tx_threshold); |
821 | outl(ep->mii.full_duplex ? 0x7F : 0x79, ioaddr + TxCtrl); | 816 | ew32(TxCtrl, ep->mii.full_duplex ? 0x7f : 0x79); |
822 | outl(ep->rx_ring_dma + (ep->cur_rx%RX_RING_SIZE)* | 817 | ew32(PRxCDAR, ep->rx_ring_dma + |
823 | sizeof(struct epic_rx_desc), ioaddr + PRxCDAR); | 818 | (ep->cur_rx % RX_RING_SIZE) * sizeof(struct epic_rx_desc)); |
824 | outl(ep->tx_ring_dma + (ep->dirty_tx%TX_RING_SIZE)* | 819 | ew32(PTxCDAR, ep->tx_ring_dma + |
825 | sizeof(struct epic_tx_desc), ioaddr + PTxCDAR); | 820 | (ep->dirty_tx % TX_RING_SIZE) * sizeof(struct epic_tx_desc)); |
826 | 821 | ||
827 | /* Start the chip's Rx process. */ | 822 | /* Start the chip's Rx process. */ |
828 | set_rx_mode(dev); | 823 | set_rx_mode(dev); |
829 | outl(StartRx | RxQueued, ioaddr + COMMAND); | 824 | ew32(COMMAND, StartRx | RxQueued); |
830 | 825 | ||
831 | /* Enable interrupts by setting the interrupt mask. */ | 826 | /* Enable interrupts by setting the interrupt mask. */ |
832 | outl((ep->chip_flags & TYPE2_INTR ? PCIBusErr175 : PCIBusErr170) | 827 | ew32(INTMASK, RxError | RxHeader | EpicNapiEvent | CntFull | |
833 | | CntFull | TxUnderrun | 828 | ((ep->chip_flags & TYPE2_INTR) ? PCIBusErr175 : PCIBusErr170) | |
834 | | RxError | RxHeader | EpicNapiEvent, ioaddr + INTMASK); | 829 | TxUnderrun); |
835 | 830 | ||
836 | printk(KERN_DEBUG "%s: epic_restart() done, cmd status %4.4x, ctl %4.4x" | 831 | printk(KERN_DEBUG "%s: epic_restart() done, cmd status %4.4x, ctl %4.4x" |
837 | " interrupt %4.4x.\n", | 832 | " interrupt %4.4x.\n", |
838 | dev->name, (int)inl(ioaddr + COMMAND), (int)inl(ioaddr + GENCTL), | 833 | dev->name, er32(COMMAND), er32(GENCTL), er32(INTSTAT)); |
839 | (int)inl(ioaddr + INTSTAT)); | ||
840 | } | 834 | } |
841 | 835 | ||
842 | static void check_media(struct net_device *dev) | 836 | static void check_media(struct net_device *dev) |
843 | { | 837 | { |
844 | struct epic_private *ep = netdev_priv(dev); | 838 | struct epic_private *ep = netdev_priv(dev); |
845 | long ioaddr = dev->base_addr; | 839 | void __iomem *ioaddr = ep->ioaddr; |
846 | int mii_lpa = ep->mii_phy_cnt ? mdio_read(dev, ep->phys[0], MII_LPA) : 0; | 840 | int mii_lpa = ep->mii_phy_cnt ? mdio_read(dev, ep->phys[0], MII_LPA) : 0; |
847 | int negotiated = mii_lpa & ep->mii.advertising; | 841 | int negotiated = mii_lpa & ep->mii.advertising; |
848 | int duplex = (negotiated & 0x0100) || (negotiated & 0x01C0) == 0x0040; | 842 | int duplex = (negotiated & 0x0100) || (negotiated & 0x01C0) == 0x0040; |
@@ -856,7 +850,7 @@ static void check_media(struct net_device *dev) | |||
856 | printk(KERN_INFO "%s: Setting %s-duplex based on MII #%d link" | 850 | printk(KERN_INFO "%s: Setting %s-duplex based on MII #%d link" |
857 | " partner capability of %4.4x.\n", dev->name, | 851 | " partner capability of %4.4x.\n", dev->name, |
858 | ep->mii.full_duplex ? "full" : "half", ep->phys[0], mii_lpa); | 852 | ep->mii.full_duplex ? "full" : "half", ep->phys[0], mii_lpa); |
859 | outl(ep->mii.full_duplex ? 0x7F : 0x79, ioaddr + TxCtrl); | 853 | ew32(TxCtrl, ep->mii.full_duplex ? 0x7F : 0x79); |
860 | } | 854 | } |
861 | } | 855 | } |
862 | 856 | ||
@@ -864,16 +858,15 @@ static void epic_timer(unsigned long data) | |||
864 | { | 858 | { |
865 | struct net_device *dev = (struct net_device *)data; | 859 | struct net_device *dev = (struct net_device *)data; |
866 | struct epic_private *ep = netdev_priv(dev); | 860 | struct epic_private *ep = netdev_priv(dev); |
867 | long ioaddr = dev->base_addr; | 861 | void __iomem *ioaddr = ep->ioaddr; |
868 | int next_tick = 5*HZ; | 862 | int next_tick = 5*HZ; |
869 | 863 | ||
870 | if (debug > 3) { | 864 | if (debug > 3) { |
871 | printk(KERN_DEBUG "%s: Media monitor tick, Tx status %8.8x.\n", | 865 | printk(KERN_DEBUG "%s: Media monitor tick, Tx status %8.8x.\n", |
872 | dev->name, (int)inl(ioaddr + TxSTAT)); | 866 | dev->name, er32(TxSTAT)); |
873 | printk(KERN_DEBUG "%s: Other registers are IntMask %4.4x " | 867 | printk(KERN_DEBUG "%s: Other registers are IntMask %4.4x " |
874 | "IntStatus %4.4x RxStatus %4.4x.\n", | 868 | "IntStatus %4.4x RxStatus %4.4x.\n", dev->name, |
875 | dev->name, (int)inl(ioaddr + INTMASK), | 869 | er32(INTMASK), er32(INTSTAT), er32(RxSTAT)); |
876 | (int)inl(ioaddr + INTSTAT), (int)inl(ioaddr + RxSTAT)); | ||
877 | } | 870 | } |
878 | 871 | ||
879 | check_media(dev); | 872 | check_media(dev); |
@@ -885,23 +878,22 @@ static void epic_timer(unsigned long data) | |||
885 | static void epic_tx_timeout(struct net_device *dev) | 878 | static void epic_tx_timeout(struct net_device *dev) |
886 | { | 879 | { |
887 | struct epic_private *ep = netdev_priv(dev); | 880 | struct epic_private *ep = netdev_priv(dev); |
888 | long ioaddr = dev->base_addr; | 881 | void __iomem *ioaddr = ep->ioaddr; |
889 | 882 | ||
890 | if (debug > 0) { | 883 | if (debug > 0) { |
891 | printk(KERN_WARNING "%s: Transmit timeout using MII device, " | 884 | printk(KERN_WARNING "%s: Transmit timeout using MII device, " |
892 | "Tx status %4.4x.\n", | 885 | "Tx status %4.4x.\n", dev->name, er16(TxSTAT)); |
893 | dev->name, (int)inw(ioaddr + TxSTAT)); | ||
894 | if (debug > 1) { | 886 | if (debug > 1) { |
895 | printk(KERN_DEBUG "%s: Tx indices: dirty_tx %d, cur_tx %d.\n", | 887 | printk(KERN_DEBUG "%s: Tx indices: dirty_tx %d, cur_tx %d.\n", |
896 | dev->name, ep->dirty_tx, ep->cur_tx); | 888 | dev->name, ep->dirty_tx, ep->cur_tx); |
897 | } | 889 | } |
898 | } | 890 | } |
899 | if (inw(ioaddr + TxSTAT) & 0x10) { /* Tx FIFO underflow. */ | 891 | if (er16(TxSTAT) & 0x10) { /* Tx FIFO underflow. */ |
900 | dev->stats.tx_fifo_errors++; | 892 | dev->stats.tx_fifo_errors++; |
901 | outl(RestartTx, ioaddr + COMMAND); | 893 | ew32(COMMAND, RestartTx); |
902 | } else { | 894 | } else { |
903 | epic_restart(dev); | 895 | epic_restart(dev); |
904 | outl(TxQueued, dev->base_addr + COMMAND); | 896 | ew32(COMMAND, TxQueued); |
905 | } | 897 | } |
906 | 898 | ||
907 | dev->trans_start = jiffies; /* prevent tx timeout */ | 899 | dev->trans_start = jiffies; /* prevent tx timeout */ |
@@ -959,6 +951,7 @@ static void epic_init_ring(struct net_device *dev) | |||
959 | static netdev_tx_t epic_start_xmit(struct sk_buff *skb, struct net_device *dev) | 951 | static netdev_tx_t epic_start_xmit(struct sk_buff *skb, struct net_device *dev) |
960 | { | 952 | { |
961 | struct epic_private *ep = netdev_priv(dev); | 953 | struct epic_private *ep = netdev_priv(dev); |
954 | void __iomem *ioaddr = ep->ioaddr; | ||
962 | int entry, free_count; | 955 | int entry, free_count; |
963 | u32 ctrl_word; | 956 | u32 ctrl_word; |
964 | unsigned long flags; | 957 | unsigned long flags; |
@@ -999,13 +992,12 @@ static netdev_tx_t epic_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
999 | 992 | ||
1000 | spin_unlock_irqrestore(&ep->lock, flags); | 993 | spin_unlock_irqrestore(&ep->lock, flags); |
1001 | /* Trigger an immediate transmit demand. */ | 994 | /* Trigger an immediate transmit demand. */ |
1002 | outl(TxQueued, dev->base_addr + COMMAND); | 995 | ew32(COMMAND, TxQueued); |
1003 | 996 | ||
1004 | if (debug > 4) | 997 | if (debug > 4) |
1005 | printk(KERN_DEBUG "%s: Queued Tx packet size %d to slot %d, " | 998 | printk(KERN_DEBUG "%s: Queued Tx packet size %d to slot %d, " |
1006 | "flag %2.2x Tx status %8.8x.\n", | 999 | "flag %2.2x Tx status %8.8x.\n", dev->name, skb->len, |
1007 | dev->name, (int)skb->len, entry, ctrl_word, | 1000 | entry, ctrl_word, er32(TxSTAT)); |
1008 | (int)inl(dev->base_addr + TxSTAT)); | ||
1009 | 1001 | ||
1010 | return NETDEV_TX_OK; | 1002 | return NETDEV_TX_OK; |
1011 | } | 1003 | } |
@@ -1086,18 +1078,17 @@ static irqreturn_t epic_interrupt(int irq, void *dev_instance) | |||
1086 | { | 1078 | { |
1087 | struct net_device *dev = dev_instance; | 1079 | struct net_device *dev = dev_instance; |
1088 | struct epic_private *ep = netdev_priv(dev); | 1080 | struct epic_private *ep = netdev_priv(dev); |
1089 | long ioaddr = dev->base_addr; | 1081 | void __iomem *ioaddr = ep->ioaddr; |
1090 | unsigned int handled = 0; | 1082 | unsigned int handled = 0; |
1091 | int status; | 1083 | int status; |
1092 | 1084 | ||
1093 | status = inl(ioaddr + INTSTAT); | 1085 | status = er32(INTSTAT); |
1094 | /* Acknowledge all of the current interrupt sources ASAP. */ | 1086 | /* Acknowledge all of the current interrupt sources ASAP. */ |
1095 | outl(status & EpicNormalEvent, ioaddr + INTSTAT); | 1087 | ew32(INTSTAT, status & EpicNormalEvent); |
1096 | 1088 | ||
1097 | if (debug > 4) { | 1089 | if (debug > 4) { |
1098 | printk(KERN_DEBUG "%s: Interrupt, status=%#8.8x new " | 1090 | printk(KERN_DEBUG "%s: Interrupt, status=%#8.8x new " |
1099 | "intstat=%#8.8x.\n", dev->name, status, | 1091 | "intstat=%#8.8x.\n", dev->name, status, er32(INTSTAT)); |
1100 | (int)inl(ioaddr + INTSTAT)); | ||
1101 | } | 1092 | } |
1102 | 1093 | ||
1103 | if ((status & IntrSummary) == 0) | 1094 | if ((status & IntrSummary) == 0) |
@@ -1118,19 +1109,21 @@ static irqreturn_t epic_interrupt(int irq, void *dev_instance) | |||
1118 | 1109 | ||
1119 | /* Check uncommon events all at once. */ | 1110 | /* Check uncommon events all at once. */ |
1120 | if (status & (CntFull | TxUnderrun | PCIBusErr170 | PCIBusErr175)) { | 1111 | if (status & (CntFull | TxUnderrun | PCIBusErr170 | PCIBusErr175)) { |
1112 | struct net_device_stats *stats = &dev->stats; | ||
1113 | |||
1121 | if (status == EpicRemoved) | 1114 | if (status == EpicRemoved) |
1122 | goto out; | 1115 | goto out; |
1123 | 1116 | ||
1124 | /* Always update the error counts to avoid overhead later. */ | 1117 | /* Always update the error counts to avoid overhead later. */ |
1125 | dev->stats.rx_missed_errors += inb(ioaddr + MPCNT); | 1118 | stats->rx_missed_errors += er8(MPCNT); |
1126 | dev->stats.rx_frame_errors += inb(ioaddr + ALICNT); | 1119 | stats->rx_frame_errors += er8(ALICNT); |
1127 | dev->stats.rx_crc_errors += inb(ioaddr + CRCCNT); | 1120 | stats->rx_crc_errors += er8(CRCCNT); |
1128 | 1121 | ||
1129 | if (status & TxUnderrun) { /* Tx FIFO underflow. */ | 1122 | if (status & TxUnderrun) { /* Tx FIFO underflow. */ |
1130 | dev->stats.tx_fifo_errors++; | 1123 | stats->tx_fifo_errors++; |
1131 | outl(ep->tx_threshold += 128, ioaddr + TxThresh); | 1124 | ew32(TxThresh, ep->tx_threshold += 128); |
1132 | /* Restart the transmit process. */ | 1125 | /* Restart the transmit process. */ |
1133 | outl(RestartTx, ioaddr + COMMAND); | 1126 | ew32(COMMAND, RestartTx); |
1134 | } | 1127 | } |
1135 | if (status & PCIBusErr170) { | 1128 | if (status & PCIBusErr170) { |
1136 | printk(KERN_ERR "%s: PCI Bus Error! status %4.4x.\n", | 1129 | printk(KERN_ERR "%s: PCI Bus Error! status %4.4x.\n", |
@@ -1139,7 +1132,7 @@ static irqreturn_t epic_interrupt(int irq, void *dev_instance) | |||
1139 | epic_restart(dev); | 1132 | epic_restart(dev); |
1140 | } | 1133 | } |
1141 | /* Clear all error sources. */ | 1134 | /* Clear all error sources. */ |
1142 | outl(status & 0x7f18, ioaddr + INTSTAT); | 1135 | ew32(INTSTAT, status & 0x7f18); |
1143 | } | 1136 | } |
1144 | 1137 | ||
1145 | out: | 1138 | out: |
@@ -1248,17 +1241,17 @@ static int epic_rx(struct net_device *dev, int budget) | |||
1248 | 1241 | ||
1249 | static void epic_rx_err(struct net_device *dev, struct epic_private *ep) | 1242 | static void epic_rx_err(struct net_device *dev, struct epic_private *ep) |
1250 | { | 1243 | { |
1251 | long ioaddr = dev->base_addr; | 1244 | void __iomem *ioaddr = ep->ioaddr; |
1252 | int status; | 1245 | int status; |
1253 | 1246 | ||
1254 | status = inl(ioaddr + INTSTAT); | 1247 | status = er32(INTSTAT); |
1255 | 1248 | ||
1256 | if (status == EpicRemoved) | 1249 | if (status == EpicRemoved) |
1257 | return; | 1250 | return; |
1258 | if (status & RxOverflow) /* Missed a Rx frame. */ | 1251 | if (status & RxOverflow) /* Missed a Rx frame. */ |
1259 | dev->stats.rx_errors++; | 1252 | dev->stats.rx_errors++; |
1260 | if (status & (RxOverflow | RxFull)) | 1253 | if (status & (RxOverflow | RxFull)) |
1261 | outw(RxQueued, ioaddr + COMMAND); | 1254 | ew16(COMMAND, RxQueued); |
1262 | } | 1255 | } |
1263 | 1256 | ||
1264 | static int epic_poll(struct napi_struct *napi, int budget) | 1257 | static int epic_poll(struct napi_struct *napi, int budget) |
@@ -1266,7 +1259,7 @@ static int epic_poll(struct napi_struct *napi, int budget) | |||
1266 | struct epic_private *ep = container_of(napi, struct epic_private, napi); | 1259 | struct epic_private *ep = container_of(napi, struct epic_private, napi); |
1267 | struct net_device *dev = ep->mii.dev; | 1260 | struct net_device *dev = ep->mii.dev; |
1268 | int work_done = 0; | 1261 | int work_done = 0; |
1269 | long ioaddr = dev->base_addr; | 1262 | void __iomem *ioaddr = ep->ioaddr; |
1270 | 1263 | ||
1271 | rx_action: | 1264 | rx_action: |
1272 | 1265 | ||
@@ -1287,7 +1280,7 @@ rx_action: | |||
1287 | more = ep->reschedule_in_poll; | 1280 | more = ep->reschedule_in_poll; |
1288 | if (!more) { | 1281 | if (!more) { |
1289 | __napi_complete(napi); | 1282 | __napi_complete(napi); |
1290 | outl(EpicNapiEvent, ioaddr + INTSTAT); | 1283 | ew32(INTSTAT, EpicNapiEvent); |
1291 | epic_napi_irq_on(dev, ep); | 1284 | epic_napi_irq_on(dev, ep); |
1292 | } else | 1285 | } else |
1293 | ep->reschedule_in_poll--; | 1286 | ep->reschedule_in_poll--; |
@@ -1303,8 +1296,9 @@ rx_action: | |||
1303 | 1296 | ||
1304 | static int epic_close(struct net_device *dev) | 1297 | static int epic_close(struct net_device *dev) |
1305 | { | 1298 | { |
1306 | long ioaddr = dev->base_addr; | ||
1307 | struct epic_private *ep = netdev_priv(dev); | 1299 | struct epic_private *ep = netdev_priv(dev); |
1300 | struct pci_dev *pdev = ep->pci_dev; | ||
1301 | void __iomem *ioaddr = ep->ioaddr; | ||
1308 | struct sk_buff *skb; | 1302 | struct sk_buff *skb; |
1309 | int i; | 1303 | int i; |
1310 | 1304 | ||
@@ -1313,13 +1307,13 @@ static int epic_close(struct net_device *dev) | |||
1313 | 1307 | ||
1314 | if (debug > 1) | 1308 | if (debug > 1) |
1315 | printk(KERN_DEBUG "%s: Shutting down ethercard, status was %2.2x.\n", | 1309 | printk(KERN_DEBUG "%s: Shutting down ethercard, status was %2.2x.\n", |
1316 | dev->name, (int)inl(ioaddr + INTSTAT)); | 1310 | dev->name, er32(INTSTAT)); |
1317 | 1311 | ||
1318 | del_timer_sync(&ep->timer); | 1312 | del_timer_sync(&ep->timer); |
1319 | 1313 | ||
1320 | epic_disable_int(dev, ep); | 1314 | epic_disable_int(dev, ep); |
1321 | 1315 | ||
1322 | free_irq(dev->irq, dev); | 1316 | free_irq(pdev->irq, dev); |
1323 | 1317 | ||
1324 | epic_pause(dev); | 1318 | epic_pause(dev); |
1325 | 1319 | ||
@@ -1330,7 +1324,7 @@ static int epic_close(struct net_device *dev) | |||
1330 | ep->rx_ring[i].rxstatus = 0; /* Not owned by Epic chip. */ | 1324 | ep->rx_ring[i].rxstatus = 0; /* Not owned by Epic chip. */ |
1331 | ep->rx_ring[i].buflength = 0; | 1325 | ep->rx_ring[i].buflength = 0; |
1332 | if (skb) { | 1326 | if (skb) { |
1333 | pci_unmap_single(ep->pci_dev, ep->rx_ring[i].bufaddr, | 1327 | pci_unmap_single(pdev, ep->rx_ring[i].bufaddr, |
1334 | ep->rx_buf_sz, PCI_DMA_FROMDEVICE); | 1328 | ep->rx_buf_sz, PCI_DMA_FROMDEVICE); |
1335 | dev_kfree_skb(skb); | 1329 | dev_kfree_skb(skb); |
1336 | } | 1330 | } |
@@ -1341,26 +1335,28 @@ static int epic_close(struct net_device *dev) | |||
1341 | ep->tx_skbuff[i] = NULL; | 1335 | ep->tx_skbuff[i] = NULL; |
1342 | if (!skb) | 1336 | if (!skb) |
1343 | continue; | 1337 | continue; |
1344 | pci_unmap_single(ep->pci_dev, ep->tx_ring[i].bufaddr, | 1338 | pci_unmap_single(pdev, ep->tx_ring[i].bufaddr, skb->len, |
1345 | skb->len, PCI_DMA_TODEVICE); | 1339 | PCI_DMA_TODEVICE); |
1346 | dev_kfree_skb(skb); | 1340 | dev_kfree_skb(skb); |
1347 | } | 1341 | } |
1348 | 1342 | ||
1349 | /* Green! Leave the chip in low-power mode. */ | 1343 | /* Green! Leave the chip in low-power mode. */ |
1350 | outl(0x0008, ioaddr + GENCTL); | 1344 | ew32(GENCTL, 0x0008); |
1351 | 1345 | ||
1352 | return 0; | 1346 | return 0; |
1353 | } | 1347 | } |
1354 | 1348 | ||
1355 | static struct net_device_stats *epic_get_stats(struct net_device *dev) | 1349 | static struct net_device_stats *epic_get_stats(struct net_device *dev) |
1356 | { | 1350 | { |
1357 | long ioaddr = dev->base_addr; | 1351 | struct epic_private *ep = netdev_priv(dev); |
1352 | void __iomem *ioaddr = ep->ioaddr; | ||
1358 | 1353 | ||
1359 | if (netif_running(dev)) { | 1354 | if (netif_running(dev)) { |
1360 | /* Update the error counts. */ | 1355 | struct net_device_stats *stats = &dev->stats; |
1361 | dev->stats.rx_missed_errors += inb(ioaddr + MPCNT); | 1356 | |
1362 | dev->stats.rx_frame_errors += inb(ioaddr + ALICNT); | 1357 | stats->rx_missed_errors += er8(MPCNT); |
1363 | dev->stats.rx_crc_errors += inb(ioaddr + CRCCNT); | 1358 | stats->rx_frame_errors += er8(ALICNT); |
1359 | stats->rx_crc_errors += er8(CRCCNT); | ||
1364 | } | 1360 | } |
1365 | 1361 | ||
1366 | return &dev->stats; | 1362 | return &dev->stats; |
@@ -1373,13 +1369,13 @@ static struct net_device_stats *epic_get_stats(struct net_device *dev) | |||
1373 | 1369 | ||
1374 | static void set_rx_mode(struct net_device *dev) | 1370 | static void set_rx_mode(struct net_device *dev) |
1375 | { | 1371 | { |
1376 | long ioaddr = dev->base_addr; | ||
1377 | struct epic_private *ep = netdev_priv(dev); | 1372 | struct epic_private *ep = netdev_priv(dev); |
1373 | void __iomem *ioaddr = ep->ioaddr; | ||
1378 | unsigned char mc_filter[8]; /* Multicast hash filter */ | 1374 | unsigned char mc_filter[8]; /* Multicast hash filter */ |
1379 | int i; | 1375 | int i; |
1380 | 1376 | ||
1381 | if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ | 1377 | if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ |
1382 | outl(0x002C, ioaddr + RxCtrl); | 1378 | ew32(RxCtrl, 0x002c); |
1383 | /* Unconditionally log net taps. */ | 1379 | /* Unconditionally log net taps. */ |
1384 | memset(mc_filter, 0xff, sizeof(mc_filter)); | 1380 | memset(mc_filter, 0xff, sizeof(mc_filter)); |
1385 | } else if ((!netdev_mc_empty(dev)) || (dev->flags & IFF_ALLMULTI)) { | 1381 | } else if ((!netdev_mc_empty(dev)) || (dev->flags & IFF_ALLMULTI)) { |
@@ -1387,9 +1383,9 @@ static void set_rx_mode(struct net_device *dev) | |||
1387 | is never enabled. */ | 1383 | is never enabled. */ |
1388 | /* Too many to filter perfectly -- accept all multicasts. */ | 1384 | /* Too many to filter perfectly -- accept all multicasts. */ |
1389 | memset(mc_filter, 0xff, sizeof(mc_filter)); | 1385 | memset(mc_filter, 0xff, sizeof(mc_filter)); |
1390 | outl(0x000C, ioaddr + RxCtrl); | 1386 | ew32(RxCtrl, 0x000c); |
1391 | } else if (netdev_mc_empty(dev)) { | 1387 | } else if (netdev_mc_empty(dev)) { |
1392 | outl(0x0004, ioaddr + RxCtrl); | 1388 | ew32(RxCtrl, 0x0004); |
1393 | return; | 1389 | return; |
1394 | } else { /* Never executed, for now. */ | 1390 | } else { /* Never executed, for now. */ |
1395 | struct netdev_hw_addr *ha; | 1391 | struct netdev_hw_addr *ha; |
@@ -1404,7 +1400,7 @@ static void set_rx_mode(struct net_device *dev) | |||
1404 | /* ToDo: perhaps we need to stop the Tx and Rx process here? */ | 1400 | /* ToDo: perhaps we need to stop the Tx and Rx process here? */ |
1405 | if (memcmp(mc_filter, ep->mc_filter, sizeof(mc_filter))) { | 1401 | if (memcmp(mc_filter, ep->mc_filter, sizeof(mc_filter))) { |
1406 | for (i = 0; i < 4; i++) | 1402 | for (i = 0; i < 4; i++) |
1407 | outw(((u16 *)mc_filter)[i], ioaddr + MC0 + i*4); | 1403 | ew16(MC0 + i*4, ((u16 *)mc_filter)[i]); |
1408 | memcpy(ep->mc_filter, mc_filter, sizeof(mc_filter)); | 1404 | memcpy(ep->mc_filter, mc_filter, sizeof(mc_filter)); |
1409 | } | 1405 | } |
1410 | } | 1406 | } |
@@ -1466,22 +1462,26 @@ static void netdev_set_msglevel(struct net_device *dev, u32 value) | |||
1466 | 1462 | ||
1467 | static int ethtool_begin(struct net_device *dev) | 1463 | static int ethtool_begin(struct net_device *dev) |
1468 | { | 1464 | { |
1469 | unsigned long ioaddr = dev->base_addr; | 1465 | struct epic_private *ep = netdev_priv(dev); |
1466 | void __iomem *ioaddr = ep->ioaddr; | ||
1467 | |||
1470 | /* power-up, if interface is down */ | 1468 | /* power-up, if interface is down */ |
1471 | if (! netif_running(dev)) { | 1469 | if (!netif_running(dev)) { |
1472 | outl(0x0200, ioaddr + GENCTL); | 1470 | ew32(GENCTL, 0x0200); |
1473 | outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL); | 1471 | ew32(NVCTL, (er32(NVCTL) & ~0x003c) | 0x4800); |
1474 | } | 1472 | } |
1475 | return 0; | 1473 | return 0; |
1476 | } | 1474 | } |
1477 | 1475 | ||
1478 | static void ethtool_complete(struct net_device *dev) | 1476 | static void ethtool_complete(struct net_device *dev) |
1479 | { | 1477 | { |
1480 | unsigned long ioaddr = dev->base_addr; | 1478 | struct epic_private *ep = netdev_priv(dev); |
1479 | void __iomem *ioaddr = ep->ioaddr; | ||
1480 | |||
1481 | /* power-down, if interface is down */ | 1481 | /* power-down, if interface is down */ |
1482 | if (! netif_running(dev)) { | 1482 | if (!netif_running(dev)) { |
1483 | outl(0x0008, ioaddr + GENCTL); | 1483 | ew32(GENCTL, 0x0008); |
1484 | outl((inl(ioaddr + NVCTL) & ~0x483C) | 0x0000, ioaddr + NVCTL); | 1484 | ew32(NVCTL, (er32(NVCTL) & ~0x483c) | 0x0000); |
1485 | } | 1485 | } |
1486 | } | 1486 | } |
1487 | 1487 | ||
@@ -1500,14 +1500,14 @@ static const struct ethtool_ops netdev_ethtool_ops = { | |||
1500 | static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | 1500 | static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
1501 | { | 1501 | { |
1502 | struct epic_private *np = netdev_priv(dev); | 1502 | struct epic_private *np = netdev_priv(dev); |
1503 | long ioaddr = dev->base_addr; | 1503 | void __iomem *ioaddr = np->ioaddr; |
1504 | struct mii_ioctl_data *data = if_mii(rq); | 1504 | struct mii_ioctl_data *data = if_mii(rq); |
1505 | int rc; | 1505 | int rc; |
1506 | 1506 | ||
1507 | /* power-up, if interface is down */ | 1507 | /* power-up, if interface is down */ |
1508 | if (! netif_running(dev)) { | 1508 | if (! netif_running(dev)) { |
1509 | outl(0x0200, ioaddr + GENCTL); | 1509 | ew32(GENCTL, 0x0200); |
1510 | outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL); | 1510 | ew32(NVCTL, (er32(NVCTL) & ~0x003c) | 0x4800); |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | /* all non-ethtool ioctls (the SIOC[GS]MIIxxx ioctls) */ | 1513 | /* all non-ethtool ioctls (the SIOC[GS]MIIxxx ioctls) */ |
@@ -1517,14 +1517,14 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
1517 | 1517 | ||
1518 | /* power-down, if interface is down */ | 1518 | /* power-down, if interface is down */ |
1519 | if (! netif_running(dev)) { | 1519 | if (! netif_running(dev)) { |
1520 | outl(0x0008, ioaddr + GENCTL); | 1520 | ew32(GENCTL, 0x0008); |
1521 | outl((inl(ioaddr + NVCTL) & ~0x483C) | 0x0000, ioaddr + NVCTL); | 1521 | ew32(NVCTL, (er32(NVCTL) & ~0x483c) | 0x0000); |
1522 | } | 1522 | } |
1523 | return rc; | 1523 | return rc; |
1524 | } | 1524 | } |
1525 | 1525 | ||
1526 | 1526 | ||
1527 | static void __devexit epic_remove_one (struct pci_dev *pdev) | 1527 | static void __devexit epic_remove_one(struct pci_dev *pdev) |
1528 | { | 1528 | { |
1529 | struct net_device *dev = pci_get_drvdata(pdev); | 1529 | struct net_device *dev = pci_get_drvdata(pdev); |
1530 | struct epic_private *ep = netdev_priv(dev); | 1530 | struct epic_private *ep = netdev_priv(dev); |
@@ -1532,9 +1532,7 @@ static void __devexit epic_remove_one (struct pci_dev *pdev) | |||
1532 | pci_free_consistent(pdev, TX_TOTAL_SIZE, ep->tx_ring, ep->tx_ring_dma); | 1532 | pci_free_consistent(pdev, TX_TOTAL_SIZE, ep->tx_ring, ep->tx_ring_dma); |
1533 | pci_free_consistent(pdev, RX_TOTAL_SIZE, ep->rx_ring, ep->rx_ring_dma); | 1533 | pci_free_consistent(pdev, RX_TOTAL_SIZE, ep->rx_ring, ep->rx_ring_dma); |
1534 | unregister_netdev(dev); | 1534 | unregister_netdev(dev); |
1535 | #ifndef USE_IO_OPS | 1535 | pci_iounmap(pdev, ep->ioaddr); |
1536 | iounmap((void*) dev->base_addr); | ||
1537 | #endif | ||
1538 | pci_release_regions(pdev); | 1536 | pci_release_regions(pdev); |
1539 | free_netdev(dev); | 1537 | free_netdev(dev); |
1540 | pci_disable_device(pdev); | 1538 | pci_disable_device(pdev); |
@@ -1548,13 +1546,14 @@ static void __devexit epic_remove_one (struct pci_dev *pdev) | |||
1548 | static int epic_suspend (struct pci_dev *pdev, pm_message_t state) | 1546 | static int epic_suspend (struct pci_dev *pdev, pm_message_t state) |
1549 | { | 1547 | { |
1550 | struct net_device *dev = pci_get_drvdata(pdev); | 1548 | struct net_device *dev = pci_get_drvdata(pdev); |
1551 | long ioaddr = dev->base_addr; | 1549 | struct epic_private *ep = netdev_priv(dev); |
1550 | void __iomem *ioaddr = ep->ioaddr; | ||
1552 | 1551 | ||
1553 | if (!netif_running(dev)) | 1552 | if (!netif_running(dev)) |
1554 | return 0; | 1553 | return 0; |
1555 | epic_pause(dev); | 1554 | epic_pause(dev); |
1556 | /* Put the chip into low-power mode. */ | 1555 | /* Put the chip into low-power mode. */ |
1557 | outl(0x0008, ioaddr + GENCTL); | 1556 | ew32(GENCTL, 0x0008); |
1558 | /* pci_power_off(pdev, -1); */ | 1557 | /* pci_power_off(pdev, -1); */ |
1559 | return 0; | 1558 | return 0; |
1560 | } | 1559 | } |