aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2012-03-13 06:14:17 -0400
committerFrancois Romieu <romieu@fr.zoreil.com>2012-04-07 05:47:18 -0400
commit57d6d456cfb89264f87d24f52640ede23fdf12bd (patch)
tree6c89206bf6d1aedf67c87ff2737eba8021733cda /drivers/net
parent5820e97a299e502e71dd5587ed2bf63a75d4f4f7 (diff)
sis900: stop using net_device.{base_addr, irq} and convert to __iomem.
- pci_resource_start() can be removed from sis900_get_mac_addr() because the IO range is maped and stored into the device private struct early in the device probe function. - the driver contains a few direct accesses to low IO ports that forbid to re(#)define the usual out{l, w, b} macros. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Cc: Daniele Venzano <venza@brownhat.org>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/sis/sis900.c375
1 files changed, 201 insertions, 174 deletions
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
index 5ccf02e7e3ad..203d9c6ec23a 100644
--- a/drivers/net/ethernet/sis/sis900.c
+++ b/drivers/net/ethernet/sis/sis900.c
@@ -168,6 +168,8 @@ struct sis900_private {
168 unsigned int cur_phy; 168 unsigned int cur_phy;
169 struct mii_if_info mii_info; 169 struct mii_if_info mii_info;
170 170
171 void __iomem *ioaddr;
172
171 struct timer_list timer; /* Link status detection timer. */ 173 struct timer_list timer; /* Link status detection timer. */
172 u8 autong_complete; /* 1: auto-negotiate complete */ 174 u8 autong_complete; /* 1: auto-negotiate complete */
173 175
@@ -201,13 +203,18 @@ MODULE_PARM_DESC(multicast_filter_limit, "SiS 900/7016 maximum number of filtere
201MODULE_PARM_DESC(max_interrupt_work, "SiS 900/7016 maximum events handled per interrupt"); 203MODULE_PARM_DESC(max_interrupt_work, "SiS 900/7016 maximum events handled per interrupt");
202MODULE_PARM_DESC(sis900_debug, "SiS 900/7016 bitmapped debugging message level"); 204MODULE_PARM_DESC(sis900_debug, "SiS 900/7016 bitmapped debugging message level");
203 205
206#define sw32(reg, val) iowrite32(val, ioaddr + (reg))
207#define sw8(reg, val) iowrite8(val, ioaddr + (reg))
208#define sr32(reg) ioread32(ioaddr + (reg))
209#define sr16(reg) ioread16(ioaddr + (reg))
210
204#ifdef CONFIG_NET_POLL_CONTROLLER 211#ifdef CONFIG_NET_POLL_CONTROLLER
205static void sis900_poll(struct net_device *dev); 212static void sis900_poll(struct net_device *dev);
206#endif 213#endif
207static int sis900_open(struct net_device *net_dev); 214static int sis900_open(struct net_device *net_dev);
208static int sis900_mii_probe (struct net_device * net_dev); 215static int sis900_mii_probe (struct net_device * net_dev);
209static void sis900_init_rxfilter (struct net_device * net_dev); 216static void sis900_init_rxfilter (struct net_device * net_dev);
210static u16 read_eeprom(long ioaddr, int location); 217static u16 read_eeprom(void __iomem *ioaddr, int location);
211static int mdio_read(struct net_device *net_dev, int phy_id, int location); 218static int mdio_read(struct net_device *net_dev, int phy_id, int location);
212static void mdio_write(struct net_device *net_dev, int phy_id, int location, int val); 219static void mdio_write(struct net_device *net_dev, int phy_id, int location, int val);
213static void sis900_timer(unsigned long data); 220static void sis900_timer(unsigned long data);
@@ -231,7 +238,7 @@ static u16 sis900_default_phy(struct net_device * net_dev);
231static void sis900_set_capability( struct net_device *net_dev ,struct mii_phy *phy); 238static void sis900_set_capability( struct net_device *net_dev ,struct mii_phy *phy);
232static u16 sis900_reset_phy(struct net_device *net_dev, int phy_addr); 239static u16 sis900_reset_phy(struct net_device *net_dev, int phy_addr);
233static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr); 240static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr);
234static void sis900_set_mode (long ioaddr, int speed, int duplex); 241static void sis900_set_mode(struct sis900_private *, int speed, int duplex);
235static const struct ethtool_ops sis900_ethtool_ops; 242static const struct ethtool_ops sis900_ethtool_ops;
236 243
237/** 244/**
@@ -246,7 +253,8 @@ static const struct ethtool_ops sis900_ethtool_ops;
246 253
247static int __devinit sis900_get_mac_addr(struct pci_dev * pci_dev, struct net_device *net_dev) 254static int __devinit sis900_get_mac_addr(struct pci_dev * pci_dev, struct net_device *net_dev)
248{ 255{
249 long ioaddr = pci_resource_start(pci_dev, 0); 256 struct sis900_private *sis_priv = netdev_priv(net_dev);
257 void __iomem *ioaddr = sis_priv->ioaddr;
250 u16 signature; 258 u16 signature;
251 int i; 259 int i;
252 260
@@ -325,29 +333,30 @@ static int __devinit sis630e_get_mac_addr(struct pci_dev * pci_dev,
325static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev, 333static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev,
326 struct net_device *net_dev) 334 struct net_device *net_dev)
327{ 335{
328 long ioaddr = net_dev->base_addr; 336 struct sis900_private *sis_priv = netdev_priv(net_dev);
337 void __iomem *ioaddr = sis_priv->ioaddr;
329 u32 rfcrSave; 338 u32 rfcrSave;
330 u32 i; 339 u32 i;
331 340
332 rfcrSave = inl(rfcr + ioaddr); 341 rfcrSave = sr32(rfcr);
333 342
334 outl(rfcrSave | RELOAD, ioaddr + cr); 343 sw32(cr, rfcrSave | RELOAD);
335 outl(0, ioaddr + cr); 344 sw32(cr, 0);
336 345
337 /* disable packet filtering before setting filter */ 346 /* disable packet filtering before setting filter */
338 outl(rfcrSave & ~RFEN, rfcr + ioaddr); 347 sw32(rfcr, rfcrSave & ~RFEN);
339 348
340 /* load MAC addr to filter data register */ 349 /* load MAC addr to filter data register */
341 for (i = 0 ; i < 3 ; i++) { 350 for (i = 0 ; i < 3 ; i++) {
342 outl((i << RFADDR_shift), ioaddr + rfcr); 351 sw32(rfcr, (i << RFADDR_shift));
343 *( ((u16 *)net_dev->dev_addr) + i) = inw(ioaddr + rfdr); 352 *( ((u16 *)net_dev->dev_addr) + i) = sr16(rfdr);
344 } 353 }
345 354
346 /* Store MAC Address in perm_addr */ 355 /* Store MAC Address in perm_addr */
347 memcpy(net_dev->perm_addr, net_dev->dev_addr, ETH_ALEN); 356 memcpy(net_dev->perm_addr, net_dev->dev_addr, ETH_ALEN);
348 357
349 /* enable packet filtering */ 358 /* enable packet filtering */
350 outl(rfcrSave | RFEN, rfcr + ioaddr); 359 sw32(rfcr, rfcrSave | RFEN);
351 360
352 return 1; 361 return 1;
353} 362}
@@ -371,31 +380,30 @@ static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev,
371static int __devinit sis96x_get_mac_addr(struct pci_dev * pci_dev, 380static int __devinit sis96x_get_mac_addr(struct pci_dev * pci_dev,
372 struct net_device *net_dev) 381 struct net_device *net_dev)
373{ 382{
374 long ioaddr = net_dev->base_addr; 383 struct sis900_private *sis_priv = netdev_priv(net_dev);
375 long ee_addr = ioaddr + mear; 384 void __iomem *ioaddr = sis_priv->ioaddr;
376 u32 waittime = 0; 385 int wait, rc = 0;
377 int i;
378 386
379 outl(EEREQ, ee_addr); 387 sw32(mear, EEREQ);
380 while(waittime < 2000) { 388 for (wait = 0; wait < 2000; wait++) {
381 if(inl(ee_addr) & EEGNT) { 389 if (sr32(mear) & EEGNT) {
390 u16 *mac = (u16 *)net_dev->dev_addr;
391 int i;
382 392
383 /* get MAC address from EEPROM */ 393 /* get MAC address from EEPROM */
384 for (i = 0; i < 3; i++) 394 for (i = 0; i < 3; i++)
385 ((u16 *)(net_dev->dev_addr))[i] = read_eeprom(ioaddr, i+EEPROMMACAddr); 395 mac[i] = read_eeprom(ioaddr, i + EEPROMMACAddr);
386 396
387 /* Store MAC Address in perm_addr */ 397 /* Store MAC Address in perm_addr */
388 memcpy(net_dev->perm_addr, net_dev->dev_addr, ETH_ALEN); 398 memcpy(net_dev->perm_addr, net_dev->dev_addr, ETH_ALEN);
389 399
390 outl(EEDONE, ee_addr); 400 rc = 1;
391 return 1; 401 break;
392 } else {
393 udelay(1);
394 waittime ++;
395 } 402 }
403 udelay(1);
396 } 404 }
397 outl(EEDONE, ee_addr); 405 sw32(mear, EEDONE);
398 return 0; 406 return rc;
399} 407}
400 408
401static const struct net_device_ops sis900_netdev_ops = { 409static const struct net_device_ops sis900_netdev_ops = {
@@ -433,7 +441,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
433 struct pci_dev *dev; 441 struct pci_dev *dev;
434 dma_addr_t ring_dma; 442 dma_addr_t ring_dma;
435 void *ring_space; 443 void *ring_space;
436 long ioaddr; 444 void __iomem *ioaddr;
437 int i, ret; 445 int i, ret;
438 const char *card_name = card_names[pci_id->driver_data]; 446 const char *card_name = card_names[pci_id->driver_data];
439 const char *dev_name = pci_name(pci_dev); 447 const char *dev_name = pci_name(pci_dev);
@@ -464,14 +472,17 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
464 SET_NETDEV_DEV(net_dev, &pci_dev->dev); 472 SET_NETDEV_DEV(net_dev, &pci_dev->dev);
465 473
466 /* We do a request_region() to register /proc/ioports info. */ 474 /* We do a request_region() to register /proc/ioports info. */
467 ioaddr = pci_resource_start(pci_dev, 0);
468 ret = pci_request_regions(pci_dev, "sis900"); 475 ret = pci_request_regions(pci_dev, "sis900");
469 if (ret) 476 if (ret)
470 goto err_out; 477 goto err_out;
471 478
479 /* IO region. */
480 ioaddr = pci_iomap(pci_dev, 0, 0);
481 if (!ioaddr)
482 goto err_out_cleardev;
483
472 sis_priv = netdev_priv(net_dev); 484 sis_priv = netdev_priv(net_dev);
473 net_dev->base_addr = ioaddr; 485 sis_priv->ioaddr = ioaddr;
474 net_dev->irq = pci_dev->irq;
475 sis_priv->pci_dev = pci_dev; 486 sis_priv->pci_dev = pci_dev;
476 spin_lock_init(&sis_priv->lock); 487 spin_lock_init(&sis_priv->lock);
477 488
@@ -480,7 +491,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
480 ring_space = pci_alloc_consistent(pci_dev, TX_TOTAL_SIZE, &ring_dma); 491 ring_space = pci_alloc_consistent(pci_dev, TX_TOTAL_SIZE, &ring_dma);
481 if (!ring_space) { 492 if (!ring_space) {
482 ret = -ENOMEM; 493 ret = -ENOMEM;
483 goto err_out_cleardev; 494 goto err_out_unmap;
484 } 495 }
485 sis_priv->tx_ring = ring_space; 496 sis_priv->tx_ring = ring_space;
486 sis_priv->tx_ring_dma = ring_dma; 497 sis_priv->tx_ring_dma = ring_dma;
@@ -534,7 +545,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
534 545
535 /* 630ET : set the mii access mode as software-mode */ 546 /* 630ET : set the mii access mode as software-mode */
536 if (sis_priv->chipset_rev == SIS630ET_900_REV) 547 if (sis_priv->chipset_rev == SIS630ET_900_REV)
537 outl(ACCESSMODE | inl(ioaddr + cr), ioaddr + cr); 548 sw32(cr, ACCESSMODE | sr32(cr));
538 549
539 /* probe for mii transceiver */ 550 /* probe for mii transceiver */
540 if (sis900_mii_probe(net_dev) == 0) { 551 if (sis900_mii_probe(net_dev) == 0) {
@@ -556,25 +567,27 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
556 goto err_unmap_rx; 567 goto err_unmap_rx;
557 568
558 /* print some information about our NIC */ 569 /* print some information about our NIC */
559 printk(KERN_INFO "%s: %s at %#lx, IRQ %d, %pM\n", 570 printk(KERN_INFO "%s: %s at 0x%p, IRQ %d, %pM\n",
560 net_dev->name, card_name, ioaddr, net_dev->irq, 571 net_dev->name, card_name, ioaddr, pci_dev->irq,
561 net_dev->dev_addr); 572 net_dev->dev_addr);
562 573
563 /* Detect Wake on Lan support */ 574 /* Detect Wake on Lan support */
564 ret = (inl(net_dev->base_addr + CFGPMC) & PMESP) >> 27; 575 ret = (sr32(CFGPMC) & PMESP) >> 27;
565 if (netif_msg_probe(sis_priv) && (ret & PME_D3C) == 0) 576 if (netif_msg_probe(sis_priv) && (ret & PME_D3C) == 0)
566 printk(KERN_INFO "%s: Wake on LAN only available from suspend to RAM.", net_dev->name); 577 printk(KERN_INFO "%s: Wake on LAN only available from suspend to RAM.", net_dev->name);
567 578
568 return 0; 579 return 0;
569 580
570 err_unmap_rx: 581err_unmap_rx:
571 pci_free_consistent(pci_dev, RX_TOTAL_SIZE, sis_priv->rx_ring, 582 pci_free_consistent(pci_dev, RX_TOTAL_SIZE, sis_priv->rx_ring,
572 sis_priv->rx_ring_dma); 583 sis_priv->rx_ring_dma);
573 err_unmap_tx: 584err_unmap_tx:
574 pci_free_consistent(pci_dev, TX_TOTAL_SIZE, sis_priv->tx_ring, 585 pci_free_consistent(pci_dev, TX_TOTAL_SIZE, sis_priv->tx_ring,
575 sis_priv->tx_ring_dma); 586 sis_priv->tx_ring_dma);
576 err_out_cleardev: 587err_out_unmap:
577 pci_set_drvdata(pci_dev, NULL); 588 pci_iounmap(pci_dev, ioaddr);
589err_out_cleardev:
590 pci_set_drvdata(pci_dev, NULL);
578 pci_release_regions(pci_dev); 591 pci_release_regions(pci_dev);
579 err_out: 592 err_out:
580 free_netdev(net_dev); 593 free_netdev(net_dev);
@@ -798,7 +811,7 @@ static void sis900_set_capability(struct net_device *net_dev, struct mii_phy *ph
798 811
799 812
800/* Delay between EEPROM clock transitions. */ 813/* Delay between EEPROM clock transitions. */
801#define eeprom_delay() inl(ee_addr) 814#define eeprom_delay() sr32(mear)
802 815
803/** 816/**
804 * read_eeprom - Read Serial EEPROM 817 * read_eeprom - Read Serial EEPROM
@@ -809,41 +822,41 @@ static void sis900_set_capability(struct net_device *net_dev, struct mii_phy *ph
809 * Note that location is in word (16 bits) unit 822 * Note that location is in word (16 bits) unit
810 */ 823 */
811 824
812static u16 __devinit read_eeprom(long ioaddr, int location) 825static u16 __devinit read_eeprom(void __iomem *ioaddr, int location)
813{ 826{
827 u32 read_cmd = location | EEread;
814 int i; 828 int i;
815 u16 retval = 0; 829 u16 retval = 0;
816 long ee_addr = ioaddr + mear;
817 u32 read_cmd = location | EEread;
818 830
819 outl(0, ee_addr); 831 sw32(mear, 0);
820 eeprom_delay(); 832 eeprom_delay();
821 outl(EECS, ee_addr); 833 sw32(mear, EECS);
822 eeprom_delay(); 834 eeprom_delay();
823 835
824 /* Shift the read command (9) bits out. */ 836 /* Shift the read command (9) bits out. */
825 for (i = 8; i >= 0; i--) { 837 for (i = 8; i >= 0; i--) {
826 u32 dataval = (read_cmd & (1 << i)) ? EEDI | EECS : EECS; 838 u32 dataval = (read_cmd & (1 << i)) ? EEDI | EECS : EECS;
827 outl(dataval, ee_addr); 839
840 sw32(mear, dataval);
828 eeprom_delay(); 841 eeprom_delay();
829 outl(dataval | EECLK, ee_addr); 842 sw32(mear, dataval | EECLK);
830 eeprom_delay(); 843 eeprom_delay();
831 } 844 }
832 outl(EECS, ee_addr); 845 sw32(mear, EECS);
833 eeprom_delay(); 846 eeprom_delay();
834 847
835 /* read the 16-bits data in */ 848 /* read the 16-bits data in */
836 for (i = 16; i > 0; i--) { 849 for (i = 16; i > 0; i--) {
837 outl(EECS, ee_addr); 850 sw32(mear, EECS);
838 eeprom_delay(); 851 eeprom_delay();
839 outl(EECS | EECLK, ee_addr); 852 sw32(mear, EECS | EECLK);
840 eeprom_delay(); 853 eeprom_delay();
841 retval = (retval << 1) | ((inl(ee_addr) & EEDO) ? 1 : 0); 854 retval = (retval << 1) | ((sr32(mear) & EEDO) ? 1 : 0);
842 eeprom_delay(); 855 eeprom_delay();
843 } 856 }
844 857
845 /* Terminate the EEPROM access. */ 858 /* Terminate the EEPROM access. */
846 outl(0, ee_addr); 859 sw32(mear, 0);
847 eeprom_delay(); 860 eeprom_delay();
848 861
849 return retval; 862 return retval;
@@ -852,24 +865,27 @@ static u16 __devinit read_eeprom(long ioaddr, int location)
852/* Read and write the MII management registers using software-generated 865/* Read and write the MII management registers using software-generated
853 serial MDIO protocol. Note that the command bits and data bits are 866 serial MDIO protocol. Note that the command bits and data bits are
854 send out separately */ 867 send out separately */
855#define mdio_delay() inl(mdio_addr) 868#define mdio_delay() sr32(mear)
856 869
857static void mdio_idle(long mdio_addr) 870static void mdio_idle(struct sis900_private *sp)
858{ 871{
859 outl(MDIO | MDDIR, mdio_addr); 872 void __iomem *ioaddr = sp->ioaddr;
873
874 sw32(mear, MDIO | MDDIR);
860 mdio_delay(); 875 mdio_delay();
861 outl(MDIO | MDDIR | MDC, mdio_addr); 876 sw32(mear, MDIO | MDDIR | MDC);
862} 877}
863 878
864/* Syncronize the MII management interface by shifting 32 one bits out. */ 879/* Synchronize the MII management interface by shifting 32 one bits out. */
865static void mdio_reset(long mdio_addr) 880static void mdio_reset(struct sis900_private *sp)
866{ 881{
882 void __iomem *ioaddr = sp->ioaddr;
867 int i; 883 int i;
868 884
869 for (i = 31; i >= 0; i--) { 885 for (i = 31; i >= 0; i--) {
870 outl(MDDIR | MDIO, mdio_addr); 886 sw32(mear, MDDIR | MDIO);
871 mdio_delay(); 887 mdio_delay();
872 outl(MDDIR | MDIO | MDC, mdio_addr); 888 sw32(mear, MDDIR | MDIO | MDC);
873 mdio_delay(); 889 mdio_delay();
874 } 890 }
875} 891}
@@ -887,31 +903,33 @@ static void mdio_reset(long mdio_addr)
887 903
888static int mdio_read(struct net_device *net_dev, int phy_id, int location) 904static int mdio_read(struct net_device *net_dev, int phy_id, int location)
889{ 905{
890 long mdio_addr = net_dev->base_addr + mear;
891 int mii_cmd = MIIread|(phy_id<<MIIpmdShift)|(location<<MIIregShift); 906 int mii_cmd = MIIread|(phy_id<<MIIpmdShift)|(location<<MIIregShift);
907 struct sis900_private *sp = netdev_priv(net_dev);
908 void __iomem *ioaddr = sp->ioaddr;
892 u16 retval = 0; 909 u16 retval = 0;
893 int i; 910 int i;
894 911
895 mdio_reset(mdio_addr); 912 mdio_reset(sp);
896 mdio_idle(mdio_addr); 913 mdio_idle(sp);
897 914
898 for (i = 15; i >= 0; i--) { 915 for (i = 15; i >= 0; i--) {
899 int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR; 916 int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR;
900 outl(dataval, mdio_addr); 917
918 sw32(mear, dataval);
901 mdio_delay(); 919 mdio_delay();
902 outl(dataval | MDC, mdio_addr); 920 sw32(mear, dataval | MDC);
903 mdio_delay(); 921 mdio_delay();
904 } 922 }
905 923
906 /* Read the 16 data bits. */ 924 /* Read the 16 data bits. */
907 for (i = 16; i > 0; i--) { 925 for (i = 16; i > 0; i--) {
908 outl(0, mdio_addr); 926 sw32(mear, 0);
909 mdio_delay(); 927 mdio_delay();
910 retval = (retval << 1) | ((inl(mdio_addr) & MDIO) ? 1 : 0); 928 retval = (retval << 1) | ((sr32(mear) & MDIO) ? 1 : 0);
911 outl(MDC, mdio_addr); 929 sw32(mear, MDC);
912 mdio_delay(); 930 mdio_delay();
913 } 931 }
914 outl(0x00, mdio_addr); 932 sw32(mear, 0x00);
915 933
916 return retval; 934 return retval;
917} 935}
@@ -931,19 +949,21 @@ static int mdio_read(struct net_device *net_dev, int phy_id, int location)
931static void mdio_write(struct net_device *net_dev, int phy_id, int location, 949static void mdio_write(struct net_device *net_dev, int phy_id, int location,
932 int value) 950 int value)
933{ 951{
934 long mdio_addr = net_dev->base_addr + mear;
935 int mii_cmd = MIIwrite|(phy_id<<MIIpmdShift)|(location<<MIIregShift); 952 int mii_cmd = MIIwrite|(phy_id<<MIIpmdShift)|(location<<MIIregShift);
953 struct sis900_private *sp = netdev_priv(net_dev);
954 void __iomem *ioaddr = sp->ioaddr;
936 int i; 955 int i;
937 956
938 mdio_reset(mdio_addr); 957 mdio_reset(sp);
939 mdio_idle(mdio_addr); 958 mdio_idle(sp);
940 959
941 /* Shift the command bits out. */ 960 /* Shift the command bits out. */
942 for (i = 15; i >= 0; i--) { 961 for (i = 15; i >= 0; i--) {
943 int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR; 962 int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR;
944 outb(dataval, mdio_addr); 963
964 sw8(mear, dataval);
945 mdio_delay(); 965 mdio_delay();
946 outb(dataval | MDC, mdio_addr); 966 sw8(mear, dataval | MDC);
947 mdio_delay(); 967 mdio_delay();
948 } 968 }
949 mdio_delay(); 969 mdio_delay();
@@ -951,21 +971,22 @@ static void mdio_write(struct net_device *net_dev, int phy_id, int location,
951 /* Shift the value bits out. */ 971 /* Shift the value bits out. */
952 for (i = 15; i >= 0; i--) { 972 for (i = 15; i >= 0; i--) {
953 int dataval = (value & (1 << i)) ? MDDIR | MDIO : MDDIR; 973 int dataval = (value & (1 << i)) ? MDDIR | MDIO : MDDIR;
954 outl(dataval, mdio_addr); 974
975 sw32(mear, dataval);
955 mdio_delay(); 976 mdio_delay();
956 outl(dataval | MDC, mdio_addr); 977 sw32(mear, dataval | MDC);
957 mdio_delay(); 978 mdio_delay();
958 } 979 }
959 mdio_delay(); 980 mdio_delay();
960 981
961 /* Clear out extra bits. */ 982 /* Clear out extra bits. */
962 for (i = 2; i > 0; i--) { 983 for (i = 2; i > 0; i--) {
963 outb(0, mdio_addr); 984 sw8(mear, 0);
964 mdio_delay(); 985 mdio_delay();
965 outb(MDC, mdio_addr); 986 sw8(mear, MDC);
966 mdio_delay(); 987 mdio_delay();
967 } 988 }
968 outl(0x00, mdio_addr); 989 sw32(mear, 0x00);
969} 990}
970 991
971 992
@@ -1000,9 +1021,12 @@ static u16 sis900_reset_phy(struct net_device *net_dev, int phy_addr)
1000*/ 1021*/
1001static void sis900_poll(struct net_device *dev) 1022static void sis900_poll(struct net_device *dev)
1002{ 1023{
1003 disable_irq(dev->irq); 1024 struct sis900_private *sp = netdev_priv(dev);
1004 sis900_interrupt(dev->irq, dev); 1025 const int irq = sp->pci_dev->irq;
1005 enable_irq(dev->irq); 1026
1027 disable_irq(irq);
1028 sis900_interrupt(irq, dev);
1029 enable_irq(irq);
1006} 1030}
1007#endif 1031#endif
1008 1032
@@ -1018,7 +1042,7 @@ static int
1018sis900_open(struct net_device *net_dev) 1042sis900_open(struct net_device *net_dev)
1019{ 1043{
1020 struct sis900_private *sis_priv = netdev_priv(net_dev); 1044 struct sis900_private *sis_priv = netdev_priv(net_dev);
1021 long ioaddr = net_dev->base_addr; 1045 void __iomem *ioaddr = sis_priv->ioaddr;
1022 int ret; 1046 int ret;
1023 1047
1024 /* Soft reset the chip. */ 1048 /* Soft reset the chip. */
@@ -1027,8 +1051,8 @@ sis900_open(struct net_device *net_dev)
1027 /* Equalizer workaround Rule */ 1051 /* Equalizer workaround Rule */
1028 sis630_set_eq(net_dev, sis_priv->chipset_rev); 1052 sis630_set_eq(net_dev, sis_priv->chipset_rev);
1029 1053
1030 ret = request_irq(net_dev->irq, sis900_interrupt, IRQF_SHARED, 1054 ret = request_irq(sis_priv->pci_dev->irq, sis900_interrupt, IRQF_SHARED,
1031 net_dev->name, net_dev); 1055 net_dev->name, net_dev);
1032 if (ret) 1056 if (ret)
1033 return ret; 1057 return ret;
1034 1058
@@ -1042,12 +1066,12 @@ sis900_open(struct net_device *net_dev)
1042 netif_start_queue(net_dev); 1066 netif_start_queue(net_dev);
1043 1067
1044 /* Workaround for EDB */ 1068 /* Workaround for EDB */
1045 sis900_set_mode(ioaddr, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED); 1069 sis900_set_mode(sis_priv, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED);
1046 1070
1047 /* Enable all known interrupts by setting the interrupt mask. */ 1071 /* Enable all known interrupts by setting the interrupt mask. */
1048 outl((RxSOVR|RxORN|RxERR|RxOK|TxURN|TxERR|TxIDLE), ioaddr + imr); 1072 sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE);
1049 outl(RxENA | inl(ioaddr + cr), ioaddr + cr); 1073 sw32(cr, RxENA | sr32(cr));
1050 outl(IE, ioaddr + ier); 1074 sw32(ier, IE);
1051 1075
1052 sis900_check_mode(net_dev, sis_priv->mii); 1076 sis900_check_mode(net_dev, sis_priv->mii);
1053 1077
@@ -1074,31 +1098,30 @@ static void
1074sis900_init_rxfilter (struct net_device * net_dev) 1098sis900_init_rxfilter (struct net_device * net_dev)
1075{ 1099{
1076 struct sis900_private *sis_priv = netdev_priv(net_dev); 1100 struct sis900_private *sis_priv = netdev_priv(net_dev);
1077 long ioaddr = net_dev->base_addr; 1101 void __iomem *ioaddr = sis_priv->ioaddr;
1078 u32 rfcrSave; 1102 u32 rfcrSave;
1079 u32 i; 1103 u32 i;
1080 1104
1081 rfcrSave = inl(rfcr + ioaddr); 1105 rfcrSave = sr32(rfcr);
1082 1106
1083 /* disable packet filtering before setting filter */ 1107 /* disable packet filtering before setting filter */
1084 outl(rfcrSave & ~RFEN, rfcr + ioaddr); 1108 sw32(rfcr, rfcrSave & ~RFEN);
1085 1109
1086 /* load MAC addr to filter data register */ 1110 /* load MAC addr to filter data register */
1087 for (i = 0 ; i < 3 ; i++) { 1111 for (i = 0 ; i < 3 ; i++) {
1088 u32 w; 1112 u32 w = (u32) *((u16 *)(net_dev->dev_addr)+i);
1089 1113
1090 w = (u32) *((u16 *)(net_dev->dev_addr)+i); 1114 sw32(rfcr, i << RFADDR_shift);
1091 outl((i << RFADDR_shift), ioaddr + rfcr); 1115 sw32(rfdr, w);
1092 outl(w, ioaddr + rfdr);
1093 1116
1094 if (netif_msg_hw(sis_priv)) { 1117 if (netif_msg_hw(sis_priv)) {
1095 printk(KERN_DEBUG "%s: Receive Filter Addrss[%d]=%x\n", 1118 printk(KERN_DEBUG "%s: Receive Filter Addrss[%d]=%x\n",
1096 net_dev->name, i, inl(ioaddr + rfdr)); 1119 net_dev->name, i, sr32(rfdr));
1097 } 1120 }
1098 } 1121 }
1099 1122
1100 /* enable packet filtering */ 1123 /* enable packet filtering */
1101 outl(rfcrSave | RFEN, rfcr + ioaddr); 1124 sw32(rfcr, rfcrSave | RFEN);
1102} 1125}
1103 1126
1104/** 1127/**
@@ -1112,7 +1135,7 @@ static void
1112sis900_init_tx_ring(struct net_device *net_dev) 1135sis900_init_tx_ring(struct net_device *net_dev)
1113{ 1136{
1114 struct sis900_private *sis_priv = netdev_priv(net_dev); 1137 struct sis900_private *sis_priv = netdev_priv(net_dev);
1115 long ioaddr = net_dev->base_addr; 1138 void __iomem *ioaddr = sis_priv->ioaddr;
1116 int i; 1139 int i;
1117 1140
1118 sis_priv->tx_full = 0; 1141 sis_priv->tx_full = 0;
@@ -1128,10 +1151,10 @@ sis900_init_tx_ring(struct net_device *net_dev)
1128 } 1151 }
1129 1152
1130 /* load Transmit Descriptor Register */ 1153 /* load Transmit Descriptor Register */
1131 outl(sis_priv->tx_ring_dma, ioaddr + txdp); 1154 sw32(txdp, sis_priv->tx_ring_dma);
1132 if (netif_msg_hw(sis_priv)) 1155 if (netif_msg_hw(sis_priv))
1133 printk(KERN_DEBUG "%s: TX descriptor register loaded with: %8.8x\n", 1156 printk(KERN_DEBUG "%s: TX descriptor register loaded with: %8.8x\n",
1134 net_dev->name, inl(ioaddr + txdp)); 1157 net_dev->name, sr32(txdp));
1135} 1158}
1136 1159
1137/** 1160/**
@@ -1146,7 +1169,7 @@ static void
1146sis900_init_rx_ring(struct net_device *net_dev) 1169sis900_init_rx_ring(struct net_device *net_dev)
1147{ 1170{
1148 struct sis900_private *sis_priv = netdev_priv(net_dev); 1171 struct sis900_private *sis_priv = netdev_priv(net_dev);
1149 long ioaddr = net_dev->base_addr; 1172 void __iomem *ioaddr = sis_priv->ioaddr;
1150 int i; 1173 int i;
1151 1174
1152 sis_priv->cur_rx = 0; 1175 sis_priv->cur_rx = 0;
@@ -1181,10 +1204,10 @@ sis900_init_rx_ring(struct net_device *net_dev)
1181 sis_priv->dirty_rx = (unsigned int) (i - NUM_RX_DESC); 1204 sis_priv->dirty_rx = (unsigned int) (i - NUM_RX_DESC);
1182 1205
1183 /* load Receive Descriptor Register */ 1206 /* load Receive Descriptor Register */
1184 outl(sis_priv->rx_ring_dma, ioaddr + rxdp); 1207 sw32(rxdp, sis_priv->rx_ring_dma);
1185 if (netif_msg_hw(sis_priv)) 1208 if (netif_msg_hw(sis_priv))
1186 printk(KERN_DEBUG "%s: RX descriptor register loaded with: %8.8x\n", 1209 printk(KERN_DEBUG "%s: RX descriptor register loaded with: %8.8x\n",
1187 net_dev->name, inl(ioaddr + rxdp)); 1210 net_dev->name, sr32(rxdp));
1188} 1211}
1189 1212
1190/** 1213/**
@@ -1298,7 +1321,7 @@ static void sis900_timer(unsigned long data)
1298 1321
1299 sis900_read_mode(net_dev, &speed, &duplex); 1322 sis900_read_mode(net_dev, &speed, &duplex);
1300 if (duplex){ 1323 if (duplex){
1301 sis900_set_mode(net_dev->base_addr, speed, duplex); 1324 sis900_set_mode(sis_priv, speed, duplex);
1302 sis630_set_eq(net_dev, sis_priv->chipset_rev); 1325 sis630_set_eq(net_dev, sis_priv->chipset_rev);
1303 netif_start_queue(net_dev); 1326 netif_start_queue(net_dev);
1304 } 1327 }
@@ -1359,25 +1382,25 @@ static void sis900_timer(unsigned long data)
1359static void sis900_check_mode(struct net_device *net_dev, struct mii_phy *mii_phy) 1382static void sis900_check_mode(struct net_device *net_dev, struct mii_phy *mii_phy)
1360{ 1383{
1361 struct sis900_private *sis_priv = netdev_priv(net_dev); 1384 struct sis900_private *sis_priv = netdev_priv(net_dev);
1362 long ioaddr = net_dev->base_addr; 1385 void __iomem *ioaddr = sis_priv->ioaddr;
1363 int speed, duplex; 1386 int speed, duplex;
1364 1387
1365 if (mii_phy->phy_types == LAN) { 1388 if (mii_phy->phy_types == LAN) {
1366 outl(~EXD & inl(ioaddr + cfg), ioaddr + cfg); 1389 sw32(cfg, ~EXD & sr32(cfg));
1367 sis900_set_capability(net_dev , mii_phy); 1390 sis900_set_capability(net_dev , mii_phy);
1368 sis900_auto_negotiate(net_dev, sis_priv->cur_phy); 1391 sis900_auto_negotiate(net_dev, sis_priv->cur_phy);
1369 } else { 1392 } else {
1370 outl(EXD | inl(ioaddr + cfg), ioaddr + cfg); 1393 sw32(cfg, EXD | sr32(cfg));
1371 speed = HW_SPEED_HOME; 1394 speed = HW_SPEED_HOME;
1372 duplex = FDX_CAPABLE_HALF_SELECTED; 1395 duplex = FDX_CAPABLE_HALF_SELECTED;
1373 sis900_set_mode(ioaddr, speed, duplex); 1396 sis900_set_mode(sis_priv, speed, duplex);
1374 sis_priv->autong_complete = 1; 1397 sis_priv->autong_complete = 1;
1375 } 1398 }
1376} 1399}
1377 1400
1378/** 1401/**
1379 * sis900_set_mode - Set the media mode of mac register. 1402 * sis900_set_mode - Set the media mode of mac register.
1380 * @ioaddr: the address of the device 1403 * @sp: the device private data
1381 * @speed : the transmit speed to be determined 1404 * @speed : the transmit speed to be determined
1382 * @duplex: the duplex mode to be determined 1405 * @duplex: the duplex mode to be determined
1383 * 1406 *
@@ -1388,11 +1411,12 @@ static void sis900_check_mode(struct net_device *net_dev, struct mii_phy *mii_ph
1388 * double words. 1411 * double words.
1389 */ 1412 */
1390 1413
1391static void sis900_set_mode (long ioaddr, int speed, int duplex) 1414static void sis900_set_mode(struct sis900_private *sp, int speed, int duplex)
1392{ 1415{
1416 void __iomem *ioaddr = sp->ioaddr;
1393 u32 tx_flags = 0, rx_flags = 0; 1417 u32 tx_flags = 0, rx_flags = 0;
1394 1418
1395 if (inl(ioaddr + cfg) & EDB_MASTER_EN) { 1419 if (sr32( cfg) & EDB_MASTER_EN) {
1396 tx_flags = TxATP | (DMA_BURST_64 << TxMXDMA_shift) | 1420 tx_flags = TxATP | (DMA_BURST_64 << TxMXDMA_shift) |
1397 (TX_FILL_THRESH << TxFILLT_shift); 1421 (TX_FILL_THRESH << TxFILLT_shift);
1398 rx_flags = DMA_BURST_64 << RxMXDMA_shift; 1422 rx_flags = DMA_BURST_64 << RxMXDMA_shift;
@@ -1420,8 +1444,8 @@ static void sis900_set_mode (long ioaddr, int speed, int duplex)
1420 rx_flags |= RxAJAB; 1444 rx_flags |= RxAJAB;
1421#endif 1445#endif
1422 1446
1423 outl (tx_flags, ioaddr + txcfg); 1447 sw32(txcfg, tx_flags);
1424 outl (rx_flags, ioaddr + rxcfg); 1448 sw32(rxcfg, rx_flags);
1425} 1449}
1426 1450
1427/** 1451/**
@@ -1528,16 +1552,17 @@ static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex
1528static void sis900_tx_timeout(struct net_device *net_dev) 1552static void sis900_tx_timeout(struct net_device *net_dev)
1529{ 1553{
1530 struct sis900_private *sis_priv = netdev_priv(net_dev); 1554 struct sis900_private *sis_priv = netdev_priv(net_dev);
1531 long ioaddr = net_dev->base_addr; 1555 void __iomem *ioaddr = sis_priv->ioaddr;
1532 unsigned long flags; 1556 unsigned long flags;
1533 int i; 1557 int i;
1534 1558
1535 if(netif_msg_tx_err(sis_priv)) 1559 if (netif_msg_tx_err(sis_priv)) {
1536 printk(KERN_INFO "%s: Transmit timeout, status %8.8x %8.8x\n", 1560 printk(KERN_INFO "%s: Transmit timeout, status %8.8x %8.8x\n",
1537 net_dev->name, inl(ioaddr + cr), inl(ioaddr + isr)); 1561 net_dev->name, sr32(cr), sr32(isr));
1562 }
1538 1563
1539 /* Disable interrupts by clearing the interrupt mask. */ 1564 /* Disable interrupts by clearing the interrupt mask. */
1540 outl(0x0000, ioaddr + imr); 1565 sw32(imr, 0x0000);
1541 1566
1542 /* use spinlock to prevent interrupt handler accessing buffer ring */ 1567 /* use spinlock to prevent interrupt handler accessing buffer ring */
1543 spin_lock_irqsave(&sis_priv->lock, flags); 1568 spin_lock_irqsave(&sis_priv->lock, flags);
@@ -1566,10 +1591,10 @@ static void sis900_tx_timeout(struct net_device *net_dev)
1566 net_dev->trans_start = jiffies; /* prevent tx timeout */ 1591 net_dev->trans_start = jiffies; /* prevent tx timeout */
1567 1592
1568 /* load Transmit Descriptor Register */ 1593 /* load Transmit Descriptor Register */
1569 outl(sis_priv->tx_ring_dma, ioaddr + txdp); 1594 sw32(txdp, sis_priv->tx_ring_dma);
1570 1595
1571 /* Enable all known interrupts by setting the interrupt mask. */ 1596 /* Enable all known interrupts by setting the interrupt mask. */
1572 outl((RxSOVR|RxORN|RxERR|RxOK|TxURN|TxERR|TxIDLE), ioaddr + imr); 1597 sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE);
1573} 1598}
1574 1599
1575/** 1600/**
@@ -1586,7 +1611,7 @@ static netdev_tx_t
1586sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev) 1611sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
1587{ 1612{
1588 struct sis900_private *sis_priv = netdev_priv(net_dev); 1613 struct sis900_private *sis_priv = netdev_priv(net_dev);
1589 long ioaddr = net_dev->base_addr; 1614 void __iomem *ioaddr = sis_priv->ioaddr;
1590 unsigned int entry; 1615 unsigned int entry;
1591 unsigned long flags; 1616 unsigned long flags;
1592 unsigned int index_cur_tx, index_dirty_tx; 1617 unsigned int index_cur_tx, index_dirty_tx;
@@ -1608,7 +1633,7 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
1608 sis_priv->tx_ring[entry].bufptr = pci_map_single(sis_priv->pci_dev, 1633 sis_priv->tx_ring[entry].bufptr = pci_map_single(sis_priv->pci_dev,
1609 skb->data, skb->len, PCI_DMA_TODEVICE); 1634 skb->data, skb->len, PCI_DMA_TODEVICE);
1610 sis_priv->tx_ring[entry].cmdsts = (OWN | skb->len); 1635 sis_priv->tx_ring[entry].cmdsts = (OWN | skb->len);
1611 outl(TxENA | inl(ioaddr + cr), ioaddr + cr); 1636 sw32(cr, TxENA | sr32(cr));
1612 1637
1613 sis_priv->cur_tx ++; 1638 sis_priv->cur_tx ++;
1614 index_cur_tx = sis_priv->cur_tx; 1639 index_cur_tx = sis_priv->cur_tx;
@@ -1654,14 +1679,14 @@ static irqreturn_t sis900_interrupt(int irq, void *dev_instance)
1654 struct net_device *net_dev = dev_instance; 1679 struct net_device *net_dev = dev_instance;
1655 struct sis900_private *sis_priv = netdev_priv(net_dev); 1680 struct sis900_private *sis_priv = netdev_priv(net_dev);
1656 int boguscnt = max_interrupt_work; 1681 int boguscnt = max_interrupt_work;
1657 long ioaddr = net_dev->base_addr; 1682 void __iomem *ioaddr = sis_priv->ioaddr;
1658 u32 status; 1683 u32 status;
1659 unsigned int handled = 0; 1684 unsigned int handled = 0;
1660 1685
1661 spin_lock (&sis_priv->lock); 1686 spin_lock (&sis_priv->lock);
1662 1687
1663 do { 1688 do {
1664 status = inl(ioaddr + isr); 1689 status = sr32(isr);
1665 1690
1666 if ((status & (HIBERR|TxURN|TxERR|TxIDLE|RxORN|RxERR|RxOK)) == 0) 1691 if ((status & (HIBERR|TxURN|TxERR|TxIDLE|RxORN|RxERR|RxOK)) == 0)
1667 /* nothing intresting happened */ 1692 /* nothing intresting happened */
@@ -1696,7 +1721,7 @@ static irqreturn_t sis900_interrupt(int irq, void *dev_instance)
1696 if(netif_msg_intr(sis_priv)) 1721 if(netif_msg_intr(sis_priv))
1697 printk(KERN_DEBUG "%s: exiting interrupt, " 1722 printk(KERN_DEBUG "%s: exiting interrupt, "
1698 "interrupt status = 0x%#8.8x.\n", 1723 "interrupt status = 0x%#8.8x.\n",
1699 net_dev->name, inl(ioaddr + isr)); 1724 net_dev->name, sr32(isr));
1700 1725
1701 spin_unlock (&sis_priv->lock); 1726 spin_unlock (&sis_priv->lock);
1702 return IRQ_RETVAL(handled); 1727 return IRQ_RETVAL(handled);
@@ -1715,7 +1740,7 @@ static irqreturn_t sis900_interrupt(int irq, void *dev_instance)
1715static int sis900_rx(struct net_device *net_dev) 1740static int sis900_rx(struct net_device *net_dev)
1716{ 1741{
1717 struct sis900_private *sis_priv = netdev_priv(net_dev); 1742 struct sis900_private *sis_priv = netdev_priv(net_dev);
1718 long ioaddr = net_dev->base_addr; 1743 void __iomem *ioaddr = sis_priv->ioaddr;
1719 unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC; 1744 unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC;
1720 u32 rx_status = sis_priv->rx_ring[entry].cmdsts; 1745 u32 rx_status = sis_priv->rx_ring[entry].cmdsts;
1721 int rx_work_limit; 1746 int rx_work_limit;
@@ -1847,7 +1872,7 @@ refill_rx_ring:
1847 } 1872 }
1848 } 1873 }
1849 /* re-enable the potentially idle receive state matchine */ 1874 /* re-enable the potentially idle receive state matchine */
1850 outl(RxENA | inl(ioaddr + cr), ioaddr + cr ); 1875 sw32(cr , RxENA | sr32(cr));
1851 1876
1852 return 0; 1877 return 0;
1853} 1878}
@@ -1932,31 +1957,31 @@ static void sis900_finish_xmit (struct net_device *net_dev)
1932 1957
1933static int sis900_close(struct net_device *net_dev) 1958static int sis900_close(struct net_device *net_dev)
1934{ 1959{
1935 long ioaddr = net_dev->base_addr;
1936 struct sis900_private *sis_priv = netdev_priv(net_dev); 1960 struct sis900_private *sis_priv = netdev_priv(net_dev);
1961 struct pci_dev *pdev = sis_priv->pci_dev;
1962 void __iomem *ioaddr = sis_priv->ioaddr;
1937 struct sk_buff *skb; 1963 struct sk_buff *skb;
1938 int i; 1964 int i;
1939 1965
1940 netif_stop_queue(net_dev); 1966 netif_stop_queue(net_dev);
1941 1967
1942 /* Disable interrupts by clearing the interrupt mask. */ 1968 /* Disable interrupts by clearing the interrupt mask. */
1943 outl(0x0000, ioaddr + imr); 1969 sw32(imr, 0x0000);
1944 outl(0x0000, ioaddr + ier); 1970 sw32(ier, 0x0000);
1945 1971
1946 /* Stop the chip's Tx and Rx Status Machine */ 1972 /* Stop the chip's Tx and Rx Status Machine */
1947 outl(RxDIS | TxDIS | inl(ioaddr + cr), ioaddr + cr); 1973 sw32(cr, RxDIS | TxDIS | sr32(cr));
1948 1974
1949 del_timer(&sis_priv->timer); 1975 del_timer(&sis_priv->timer);
1950 1976
1951 free_irq(net_dev->irq, net_dev); 1977 free_irq(pdev->irq, net_dev);
1952 1978
1953 /* Free Tx and RX skbuff */ 1979 /* Free Tx and RX skbuff */
1954 for (i = 0; i < NUM_RX_DESC; i++) { 1980 for (i = 0; i < NUM_RX_DESC; i++) {
1955 skb = sis_priv->rx_skbuff[i]; 1981 skb = sis_priv->rx_skbuff[i];
1956 if (skb) { 1982 if (skb) {
1957 pci_unmap_single(sis_priv->pci_dev, 1983 pci_unmap_single(pdev, sis_priv->rx_ring[i].bufptr,
1958 sis_priv->rx_ring[i].bufptr, 1984 RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
1959 RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
1960 dev_kfree_skb(skb); 1985 dev_kfree_skb(skb);
1961 sis_priv->rx_skbuff[i] = NULL; 1986 sis_priv->rx_skbuff[i] = NULL;
1962 } 1987 }
@@ -1964,9 +1989,8 @@ static int sis900_close(struct net_device *net_dev)
1964 for (i = 0; i < NUM_TX_DESC; i++) { 1989 for (i = 0; i < NUM_TX_DESC; i++) {
1965 skb = sis_priv->tx_skbuff[i]; 1990 skb = sis_priv->tx_skbuff[i];
1966 if (skb) { 1991 if (skb) {
1967 pci_unmap_single(sis_priv->pci_dev, 1992 pci_unmap_single(pdev, sis_priv->tx_ring[i].bufptr,
1968 sis_priv->tx_ring[i].bufptr, skb->len, 1993 skb->len, PCI_DMA_TODEVICE);
1969 PCI_DMA_TODEVICE);
1970 dev_kfree_skb(skb); 1994 dev_kfree_skb(skb);
1971 sis_priv->tx_skbuff[i] = NULL; 1995 sis_priv->tx_skbuff[i] = NULL;
1972 } 1996 }
@@ -2055,14 +2079,14 @@ static int sis900_nway_reset(struct net_device *net_dev)
2055static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol) 2079static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
2056{ 2080{
2057 struct sis900_private *sis_priv = netdev_priv(net_dev); 2081 struct sis900_private *sis_priv = netdev_priv(net_dev);
2058 long pmctrl_addr = net_dev->base_addr + pmctrl; 2082 void __iomem *ioaddr = sis_priv->ioaddr;
2059 u32 cfgpmcsr = 0, pmctrl_bits = 0; 2083 u32 cfgpmcsr = 0, pmctrl_bits = 0;
2060 2084
2061 if (wol->wolopts == 0) { 2085 if (wol->wolopts == 0) {
2062 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr); 2086 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
2063 cfgpmcsr &= ~PME_EN; 2087 cfgpmcsr &= ~PME_EN;
2064 pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr); 2088 pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr);
2065 outl(pmctrl_bits, pmctrl_addr); 2089 sw32(pmctrl, pmctrl_bits);
2066 if (netif_msg_wol(sis_priv)) 2090 if (netif_msg_wol(sis_priv))
2067 printk(KERN_DEBUG "%s: Wake on LAN disabled\n", net_dev->name); 2091 printk(KERN_DEBUG "%s: Wake on LAN disabled\n", net_dev->name);
2068 return 0; 2092 return 0;
@@ -2077,7 +2101,7 @@ static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wo
2077 if (wol->wolopts & WAKE_PHY) 2101 if (wol->wolopts & WAKE_PHY)
2078 pmctrl_bits |= LINKON; 2102 pmctrl_bits |= LINKON;
2079 2103
2080 outl(pmctrl_bits, pmctrl_addr); 2104 sw32(pmctrl, pmctrl_bits);
2081 2105
2082 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr); 2106 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
2083 cfgpmcsr |= PME_EN; 2107 cfgpmcsr |= PME_EN;
@@ -2090,10 +2114,11 @@ static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wo
2090 2114
2091static void sis900_get_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol) 2115static void sis900_get_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
2092{ 2116{
2093 long pmctrl_addr = net_dev->base_addr + pmctrl; 2117 struct sis900_private *sp = netdev_priv(net_dev);
2118 void __iomem *ioaddr = sp->ioaddr;
2094 u32 pmctrl_bits; 2119 u32 pmctrl_bits;
2095 2120
2096 pmctrl_bits = inl(pmctrl_addr); 2121 pmctrl_bits = sr32(pmctrl);
2097 if (pmctrl_bits & MAGICPKT) 2122 if (pmctrl_bits & MAGICPKT)
2098 wol->wolopts |= WAKE_MAGIC; 2123 wol->wolopts |= WAKE_MAGIC;
2099 if (pmctrl_bits & LINKON) 2124 if (pmctrl_bits & LINKON)
@@ -2279,8 +2304,8 @@ static inline u16 sis900_mcast_bitnr(u8 *addr, u8 revision)
2279 2304
2280static void set_rx_mode(struct net_device *net_dev) 2305static void set_rx_mode(struct net_device *net_dev)
2281{ 2306{
2282 long ioaddr = net_dev->base_addr;
2283 struct sis900_private *sis_priv = netdev_priv(net_dev); 2307 struct sis900_private *sis_priv = netdev_priv(net_dev);
2308 void __iomem *ioaddr = sis_priv->ioaddr;
2284 u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */ 2309 u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */
2285 int i, table_entries; 2310 int i, table_entries;
2286 u32 rx_mode; 2311 u32 rx_mode;
@@ -2322,24 +2347,24 @@ static void set_rx_mode(struct net_device *net_dev)
2322 /* update Multicast Hash Table in Receive Filter */ 2347 /* update Multicast Hash Table in Receive Filter */
2323 for (i = 0; i < table_entries; i++) { 2348 for (i = 0; i < table_entries; i++) {
2324 /* why plus 0x04 ??, That makes the correct value for hash table. */ 2349 /* why plus 0x04 ??, That makes the correct value for hash table. */
2325 outl((u32)(0x00000004+i) << RFADDR_shift, ioaddr + rfcr); 2350 sw32(rfcr, (u32)(0x00000004 + i) << RFADDR_shift);
2326 outl(mc_filter[i], ioaddr + rfdr); 2351 sw32(rfdr, mc_filter[i]);
2327 } 2352 }
2328 2353
2329 outl(RFEN | rx_mode, ioaddr + rfcr); 2354 sw32(rfcr, RFEN | rx_mode);
2330 2355
2331 /* sis900 is capable of looping back packets at MAC level for 2356 /* sis900 is capable of looping back packets at MAC level for
2332 * debugging purpose */ 2357 * debugging purpose */
2333 if (net_dev->flags & IFF_LOOPBACK) { 2358 if (net_dev->flags & IFF_LOOPBACK) {
2334 u32 cr_saved; 2359 u32 cr_saved;
2335 /* We must disable Tx/Rx before setting loopback mode */ 2360 /* We must disable Tx/Rx before setting loopback mode */
2336 cr_saved = inl(ioaddr + cr); 2361 cr_saved = sr32(cr);
2337 outl(cr_saved | TxDIS | RxDIS, ioaddr + cr); 2362 sw32(cr, cr_saved | TxDIS | RxDIS);
2338 /* enable loopback */ 2363 /* enable loopback */
2339 outl(inl(ioaddr + txcfg) | TxMLB, ioaddr + txcfg); 2364 sw32(txcfg, sr32(txcfg) | TxMLB);
2340 outl(inl(ioaddr + rxcfg) | RxATX, ioaddr + rxcfg); 2365 sw32(rxcfg, sr32(rxcfg) | RxATX);
2341 /* restore cr */ 2366 /* restore cr */
2342 outl(cr_saved, ioaddr + cr); 2367 sw32(cr, cr_saved);
2343 } 2368 }
2344} 2369}
2345 2370
@@ -2355,26 +2380,25 @@ static void set_rx_mode(struct net_device *net_dev)
2355static void sis900_reset(struct net_device *net_dev) 2380static void sis900_reset(struct net_device *net_dev)
2356{ 2381{
2357 struct sis900_private *sis_priv = netdev_priv(net_dev); 2382 struct sis900_private *sis_priv = netdev_priv(net_dev);
2358 long ioaddr = net_dev->base_addr; 2383 void __iomem *ioaddr = sis_priv->ioaddr;
2359 int i = 0;
2360 u32 status = TxRCMP | RxRCMP; 2384 u32 status = TxRCMP | RxRCMP;
2385 int i;
2361 2386
2362 outl(0, ioaddr + ier); 2387 sw32(ier, 0);
2363 outl(0, ioaddr + imr); 2388 sw32(imr, 0);
2364 outl(0, ioaddr + rfcr); 2389 sw32(rfcr, 0);
2365 2390
2366 outl(RxRESET | TxRESET | RESET | inl(ioaddr + cr), ioaddr + cr); 2391 sw32(cr, RxRESET | TxRESET | RESET | sr32(cr));
2367 2392
2368 /* Check that the chip has finished the reset. */ 2393 /* Check that the chip has finished the reset. */
2369 while (status && (i++ < 1000)) { 2394 for (i = 0; status && (i < 1000); i++)
2370 status ^= (inl(isr + ioaddr) & status); 2395 status ^= sr32(isr) & status;
2371 }
2372 2396
2373 if( (sis_priv->chipset_rev >= SIS635A_900_REV) || 2397 if (sis_priv->chipset_rev >= SIS635A_900_REV ||
2374 (sis_priv->chipset_rev == SIS900B_900_REV) ) 2398 sis_priv->chipset_rev == SIS900B_900_REV)
2375 outl(PESEL | RND_CNT, ioaddr + cfg); 2399 sw32(cfg, PESEL | RND_CNT);
2376 else 2400 else
2377 outl(PESEL, ioaddr + cfg); 2401 sw32(cfg, PESEL);
2378} 2402}
2379 2403
2380/** 2404/**
@@ -2388,10 +2412,12 @@ static void __devexit sis900_remove(struct pci_dev *pci_dev)
2388{ 2412{
2389 struct net_device *net_dev = pci_get_drvdata(pci_dev); 2413 struct net_device *net_dev = pci_get_drvdata(pci_dev);
2390 struct sis900_private *sis_priv = netdev_priv(net_dev); 2414 struct sis900_private *sis_priv = netdev_priv(net_dev);
2391 struct mii_phy *phy = NULL; 2415
2416 unregister_netdev(net_dev);
2392 2417
2393 while (sis_priv->first_mii) { 2418 while (sis_priv->first_mii) {
2394 phy = sis_priv->first_mii; 2419 struct mii_phy *phy = sis_priv->first_mii;
2420
2395 sis_priv->first_mii = phy->next; 2421 sis_priv->first_mii = phy->next;
2396 kfree(phy); 2422 kfree(phy);
2397 } 2423 }
@@ -2400,7 +2426,7 @@ static void __devexit sis900_remove(struct pci_dev *pci_dev)
2400 sis_priv->rx_ring_dma); 2426 sis_priv->rx_ring_dma);
2401 pci_free_consistent(pci_dev, TX_TOTAL_SIZE, sis_priv->tx_ring, 2427 pci_free_consistent(pci_dev, TX_TOTAL_SIZE, sis_priv->tx_ring,
2402 sis_priv->tx_ring_dma); 2428 sis_priv->tx_ring_dma);
2403 unregister_netdev(net_dev); 2429 pci_iounmap(pci_dev, sis_priv->ioaddr);
2404 free_netdev(net_dev); 2430 free_netdev(net_dev);
2405 pci_release_regions(pci_dev); 2431 pci_release_regions(pci_dev);
2406 pci_set_drvdata(pci_dev, NULL); 2432 pci_set_drvdata(pci_dev, NULL);
@@ -2411,7 +2437,8 @@ static void __devexit sis900_remove(struct pci_dev *pci_dev)
2411static int sis900_suspend(struct pci_dev *pci_dev, pm_message_t state) 2437static int sis900_suspend(struct pci_dev *pci_dev, pm_message_t state)
2412{ 2438{
2413 struct net_device *net_dev = pci_get_drvdata(pci_dev); 2439 struct net_device *net_dev = pci_get_drvdata(pci_dev);
2414 long ioaddr = net_dev->base_addr; 2440 struct sis900_private *sis_priv = netdev_priv(net_dev);
2441 void __iomem *ioaddr = sis_priv->ioaddr;
2415 2442
2416 if(!netif_running(net_dev)) 2443 if(!netif_running(net_dev))
2417 return 0; 2444 return 0;
@@ -2420,7 +2447,7 @@ static int sis900_suspend(struct pci_dev *pci_dev, pm_message_t state)
2420 netif_device_detach(net_dev); 2447 netif_device_detach(net_dev);
2421 2448
2422 /* Stop the chip's Tx and Rx Status Machine */ 2449 /* Stop the chip's Tx and Rx Status Machine */
2423 outl(RxDIS | TxDIS | inl(ioaddr + cr), ioaddr + cr); 2450 sw32(cr, RxDIS | TxDIS | sr32(cr));
2424 2451
2425 pci_set_power_state(pci_dev, PCI_D3hot); 2452 pci_set_power_state(pci_dev, PCI_D3hot);
2426 pci_save_state(pci_dev); 2453 pci_save_state(pci_dev);
@@ -2432,7 +2459,7 @@ static int sis900_resume(struct pci_dev *pci_dev)
2432{ 2459{
2433 struct net_device *net_dev = pci_get_drvdata(pci_dev); 2460 struct net_device *net_dev = pci_get_drvdata(pci_dev);
2434 struct sis900_private *sis_priv = netdev_priv(net_dev); 2461 struct sis900_private *sis_priv = netdev_priv(net_dev);
2435 long ioaddr = net_dev->base_addr; 2462 void __iomem *ioaddr = sis_priv->ioaddr;
2436 2463
2437 if(!netif_running(net_dev)) 2464 if(!netif_running(net_dev))
2438 return 0; 2465 return 0;
@@ -2453,9 +2480,9 @@ static int sis900_resume(struct pci_dev *pci_dev)
2453 sis900_set_mode(ioaddr, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED); 2480 sis900_set_mode(ioaddr, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED);
2454 2481
2455 /* Enable all known interrupts by setting the interrupt mask. */ 2482 /* Enable all known interrupts by setting the interrupt mask. */
2456 outl((RxSOVR|RxORN|RxERR|RxOK|TxURN|TxERR|TxIDLE), ioaddr + imr); 2483 sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE);
2457 outl(RxENA | inl(ioaddr + cr), ioaddr + cr); 2484 sw32(cr, RxENA | sr32(cr));
2458 outl(IE, ioaddr + ier); 2485 sw32(ier, IE);
2459 2486
2460 sis900_check_mode(net_dev, sis_priv->mii); 2487 sis900_check_mode(net_dev, sis_priv->mii);
2461 2488