aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/r8169.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r--drivers/net/r8169.c307
1 files changed, 157 insertions, 150 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 33c3fbf227f4..b5ced5ebb60e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -502,9 +502,9 @@ struct rtl8169_private {
502#endif 502#endif
503 int (*set_speed)(struct net_device *, u8 autoneg, u16 speed, u8 duplex); 503 int (*set_speed)(struct net_device *, u8 autoneg, u16 speed, u8 duplex);
504 int (*get_settings)(struct net_device *, struct ethtool_cmd *); 504 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
505 void (*phy_reset_enable)(void __iomem *); 505 void (*phy_reset_enable)(struct rtl8169_private *tp);
506 void (*hw_start)(struct net_device *); 506 void (*hw_start)(struct net_device *);
507 unsigned int (*phy_reset_pending)(void __iomem *); 507 unsigned int (*phy_reset_pending)(struct rtl8169_private *tp);
508 unsigned int (*link_ok)(void __iomem *); 508 unsigned int (*link_ok)(void __iomem *);
509 int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd); 509 int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd);
510 int pcie_cap; 510 int pcie_cap;
@@ -547,7 +547,7 @@ static int rtl8169_poll(struct napi_struct *napi, int budget);
547static const unsigned int rtl8169_rx_config = 547static const unsigned int rtl8169_rx_config =
548 (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); 548 (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift);
549 549
550static void mdio_write(void __iomem *ioaddr, int reg_addr, int value) 550static void r8169_mdio_write(void __iomem *ioaddr, int reg_addr, int value)
551{ 551{
552 int i; 552 int i;
553 553
@@ -569,7 +569,7 @@ static void mdio_write(void __iomem *ioaddr, int reg_addr, int value)
569 udelay(20); 569 udelay(20);
570} 570}
571 571
572static int mdio_read(void __iomem *ioaddr, int reg_addr) 572static int r8169_mdio_read(void __iomem *ioaddr, int reg_addr)
573{ 573{
574 int i, value = -1; 574 int i, value = -1;
575 575
@@ -595,34 +595,42 @@ static int mdio_read(void __iomem *ioaddr, int reg_addr)
595 return value; 595 return value;
596} 596}
597 597
598static void mdio_patch(void __iomem *ioaddr, int reg_addr, int value) 598static void rtl_writephy(struct rtl8169_private *tp, int location, u32 val)
599{ 599{
600 mdio_write(ioaddr, reg_addr, mdio_read(ioaddr, reg_addr) | value); 600 r8169_mdio_write(tp->mmio_addr, location, val);
601} 601}
602 602
603static void mdio_plus_minus(void __iomem *ioaddr, int reg_addr, int p, int m) 603static int rtl_readphy(struct rtl8169_private *tp, int location)
604{
605 return r8169_mdio_read(tp->mmio_addr, location);
606}
607
608static void rtl_patchphy(struct rtl8169_private *tp, int reg_addr, int value)
609{
610 rtl_writephy(tp, reg_addr, rtl_readphy(tp, reg_addr) | value);
611}
612
613static void rtl_w1w0_phy(struct rtl8169_private *tp, int reg_addr, int p, int m)
604{ 614{
605 int val; 615 int val;
606 616
607 val = mdio_read(ioaddr, reg_addr); 617 val = rtl_readphy(tp, reg_addr);
608 mdio_write(ioaddr, reg_addr, (val | p) & ~m); 618 rtl_writephy(tp, reg_addr, (val | p) & ~m);
609} 619}
610 620
611static void rtl_mdio_write(struct net_device *dev, int phy_id, int location, 621static void rtl_mdio_write(struct net_device *dev, int phy_id, int location,
612 int val) 622 int val)
613{ 623{
614 struct rtl8169_private *tp = netdev_priv(dev); 624 struct rtl8169_private *tp = netdev_priv(dev);
615 void __iomem *ioaddr = tp->mmio_addr;
616 625
617 mdio_write(ioaddr, location, val); 626 rtl_writephy(tp, location, val);
618} 627}
619 628
620static int rtl_mdio_read(struct net_device *dev, int phy_id, int location) 629static int rtl_mdio_read(struct net_device *dev, int phy_id, int location)
621{ 630{
622 struct rtl8169_private *tp = netdev_priv(dev); 631 struct rtl8169_private *tp = netdev_priv(dev);
623 void __iomem *ioaddr = tp->mmio_addr;
624 632
625 return mdio_read(ioaddr, location); 633 return rtl_readphy(tp, location);
626} 634}
627 635
628static void rtl_ephy_write(void __iomem *ioaddr, int reg_addr, int value) 636static void rtl_ephy_write(void __iomem *ioaddr, int reg_addr, int value)
@@ -723,14 +731,16 @@ static void rtl8169_asic_down(void __iomem *ioaddr)
723 RTL_R16(CPlusCmd); 731 RTL_R16(CPlusCmd);
724} 732}
725 733
726static unsigned int rtl8169_tbi_reset_pending(void __iomem *ioaddr) 734static unsigned int rtl8169_tbi_reset_pending(struct rtl8169_private *tp)
727{ 735{
736 void __iomem *ioaddr = tp->mmio_addr;
737
728 return RTL_R32(TBICSR) & TBIReset; 738 return RTL_R32(TBICSR) & TBIReset;
729} 739}
730 740
731static unsigned int rtl8169_xmii_reset_pending(void __iomem *ioaddr) 741static unsigned int rtl8169_xmii_reset_pending(struct rtl8169_private *tp)
732{ 742{
733 return mdio_read(ioaddr, MII_BMCR) & BMCR_RESET; 743 return rtl_readphy(tp, MII_BMCR) & BMCR_RESET;
734} 744}
735 745
736static unsigned int rtl8169_tbi_link_ok(void __iomem *ioaddr) 746static unsigned int rtl8169_tbi_link_ok(void __iomem *ioaddr)
@@ -743,17 +753,19 @@ static unsigned int rtl8169_xmii_link_ok(void __iomem *ioaddr)
743 return RTL_R8(PHYstatus) & LinkStatus; 753 return RTL_R8(PHYstatus) & LinkStatus;
744} 754}
745 755
746static void rtl8169_tbi_reset_enable(void __iomem *ioaddr) 756static void rtl8169_tbi_reset_enable(struct rtl8169_private *tp)
747{ 757{
758 void __iomem *ioaddr = tp->mmio_addr;
759
748 RTL_W32(TBICSR, RTL_R32(TBICSR) | TBIReset); 760 RTL_W32(TBICSR, RTL_R32(TBICSR) | TBIReset);
749} 761}
750 762
751static void rtl8169_xmii_reset_enable(void __iomem *ioaddr) 763static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp)
752{ 764{
753 unsigned int val; 765 unsigned int val;
754 766
755 val = mdio_read(ioaddr, MII_BMCR) | BMCR_RESET; 767 val = rtl_readphy(tp, MII_BMCR) | BMCR_RESET;
756 mdio_write(ioaddr, MII_BMCR, val & 0xffff); 768 rtl_writephy(tp, MII_BMCR, val & 0xffff);
757} 769}
758 770
759static void __rtl8169_check_link_status(struct net_device *dev, 771static void __rtl8169_check_link_status(struct net_device *dev,
@@ -917,18 +929,17 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
917 u8 autoneg, u16 speed, u8 duplex) 929 u8 autoneg, u16 speed, u8 duplex)
918{ 930{
919 struct rtl8169_private *tp = netdev_priv(dev); 931 struct rtl8169_private *tp = netdev_priv(dev);
920 void __iomem *ioaddr = tp->mmio_addr;
921 int giga_ctrl, bmcr; 932 int giga_ctrl, bmcr;
922 933
923 if (autoneg == AUTONEG_ENABLE) { 934 if (autoneg == AUTONEG_ENABLE) {
924 int auto_nego; 935 int auto_nego;
925 936
926 auto_nego = mdio_read(ioaddr, MII_ADVERTISE); 937 auto_nego = rtl_readphy(tp, MII_ADVERTISE);
927 auto_nego |= (ADVERTISE_10HALF | ADVERTISE_10FULL | 938 auto_nego |= (ADVERTISE_10HALF | ADVERTISE_10FULL |
928 ADVERTISE_100HALF | ADVERTISE_100FULL); 939 ADVERTISE_100HALF | ADVERTISE_100FULL);
929 auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM; 940 auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
930 941
931 giga_ctrl = mdio_read(ioaddr, MII_CTRL1000); 942 giga_ctrl = rtl_readphy(tp, MII_CTRL1000);
932 giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); 943 giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
933 944
934 /* The 8100e/8101e/8102e do Fast Ethernet only. */ 945 /* The 8100e/8101e/8102e do Fast Ethernet only. */
@@ -956,12 +967,12 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
956 * Vendor specific (0x1f) and reserved (0x0e) MII 967 * Vendor specific (0x1f) and reserved (0x0e) MII
957 * registers. 968 * registers.
958 */ 969 */
959 mdio_write(ioaddr, 0x1f, 0x0000); 970 rtl_writephy(tp, 0x1f, 0x0000);
960 mdio_write(ioaddr, 0x0e, 0x0000); 971 rtl_writephy(tp, 0x0e, 0x0000);
961 } 972 }
962 973
963 mdio_write(ioaddr, MII_ADVERTISE, auto_nego); 974 rtl_writephy(tp, MII_ADVERTISE, auto_nego);
964 mdio_write(ioaddr, MII_CTRL1000, giga_ctrl); 975 rtl_writephy(tp, MII_CTRL1000, giga_ctrl);
965 } else { 976 } else {
966 giga_ctrl = 0; 977 giga_ctrl = 0;
967 978
@@ -975,21 +986,21 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
975 if (duplex == DUPLEX_FULL) 986 if (duplex == DUPLEX_FULL)
976 bmcr |= BMCR_FULLDPLX; 987 bmcr |= BMCR_FULLDPLX;
977 988
978 mdio_write(ioaddr, 0x1f, 0x0000); 989 rtl_writephy(tp, 0x1f, 0x0000);
979 } 990 }
980 991
981 tp->phy_1000_ctrl_reg = giga_ctrl; 992 tp->phy_1000_ctrl_reg = giga_ctrl;
982 993
983 mdio_write(ioaddr, MII_BMCR, bmcr); 994 rtl_writephy(tp, MII_BMCR, bmcr);
984 995
985 if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || 996 if ((tp->mac_version == RTL_GIGA_MAC_VER_02) ||
986 (tp->mac_version == RTL_GIGA_MAC_VER_03)) { 997 (tp->mac_version == RTL_GIGA_MAC_VER_03)) {
987 if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) { 998 if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) {
988 mdio_write(ioaddr, 0x17, 0x2138); 999 rtl_writephy(tp, 0x17, 0x2138);
989 mdio_write(ioaddr, 0x0e, 0x0260); 1000 rtl_writephy(tp, 0x0e, 0x0260);
990 } else { 1001 } else {
991 mdio_write(ioaddr, 0x17, 0x2108); 1002 rtl_writephy(tp, 0x17, 0x2108);
992 mdio_write(ioaddr, 0x0e, 0x0000); 1003 rtl_writephy(tp, 0x0e, 0x0000);
993 } 1004 }
994 } 1005 }
995 1006
@@ -1397,10 +1408,11 @@ struct phy_reg {
1397 u16 val; 1408 u16 val;
1398}; 1409};
1399 1410
1400static void rtl_phy_write(void __iomem *ioaddr, const struct phy_reg *regs, int len) 1411static void rtl_writephy_batch(struct rtl8169_private *tp,
1412 const struct phy_reg *regs, int len)
1401{ 1413{
1402 while (len-- > 0) { 1414 while (len-- > 0) {
1403 mdio_write(ioaddr, regs->reg, regs->val); 1415 rtl_writephy(tp, regs->reg, regs->val);
1404 regs++; 1416 regs++;
1405 } 1417 }
1406} 1418}
@@ -1425,7 +1437,6 @@ static void rtl_phy_write(void __iomem *ioaddr, const struct phy_reg *regs, int
1425static void 1437static void
1426rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) 1438rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
1427{ 1439{
1428 void __iomem *ioaddr = tp->mmio_addr;
1429 __le32 *phytable = (__le32 *)fw->data; 1440 __le32 *phytable = (__le32 *)fw->data;
1430 struct net_device *dev = tp->dev; 1441 struct net_device *dev = tp->dev;
1431 size_t i; 1442 size_t i;
@@ -1455,7 +1466,7 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
1455 1466
1456 switch(action & 0xf0000000) { 1467 switch(action & 0xf0000000) {
1457 case PHY_WRITE: 1468 case PHY_WRITE:
1458 mdio_write(ioaddr, reg, data); 1469 rtl_writephy(tp, reg, data);
1459 phytable++; 1470 phytable++;
1460 break; 1471 break;
1461 default: 1472 default:
@@ -1464,7 +1475,7 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
1464 } 1475 }
1465} 1476}
1466 1477
1467static void rtl8169s_hw_phy_config(void __iomem *ioaddr) 1478static void rtl8169s_hw_phy_config(struct rtl8169_private *tp)
1468{ 1479{
1469 static const struct phy_reg phy_reg_init[] = { 1480 static const struct phy_reg phy_reg_init[] = {
1470 { 0x1f, 0x0001 }, 1481 { 0x1f, 0x0001 },
@@ -1528,10 +1539,10 @@ static void rtl8169s_hw_phy_config(void __iomem *ioaddr)
1528 { 0x00, 0x9200 } 1539 { 0x00, 0x9200 }
1529 }; 1540 };
1530 1541
1531 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1542 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1532} 1543}
1533 1544
1534static void rtl8169sb_hw_phy_config(void __iomem *ioaddr) 1545static void rtl8169sb_hw_phy_config(struct rtl8169_private *tp)
1535{ 1546{
1536 static const struct phy_reg phy_reg_init[] = { 1547 static const struct phy_reg phy_reg_init[] = {
1537 { 0x1f, 0x0002 }, 1548 { 0x1f, 0x0002 },
@@ -1539,11 +1550,10 @@ static void rtl8169sb_hw_phy_config(void __iomem *ioaddr)
1539 { 0x1f, 0x0000 } 1550 { 0x1f, 0x0000 }
1540 }; 1551 };
1541 1552
1542 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1553 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1543} 1554}
1544 1555
1545static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp, 1556static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp)
1546 void __iomem *ioaddr)
1547{ 1557{
1548 struct pci_dev *pdev = tp->pci_dev; 1558 struct pci_dev *pdev = tp->pci_dev;
1549 u16 vendor_id, device_id; 1559 u16 vendor_id, device_id;
@@ -1554,13 +1564,12 @@ static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp,
1554 if ((vendor_id != PCI_VENDOR_ID_GIGABYTE) || (device_id != 0xe000)) 1564 if ((vendor_id != PCI_VENDOR_ID_GIGABYTE) || (device_id != 0xe000))
1555 return; 1565 return;
1556 1566
1557 mdio_write(ioaddr, 0x1f, 0x0001); 1567 rtl_writephy(tp, 0x1f, 0x0001);
1558 mdio_write(ioaddr, 0x10, 0xf01b); 1568 rtl_writephy(tp, 0x10, 0xf01b);
1559 mdio_write(ioaddr, 0x1f, 0x0000); 1569 rtl_writephy(tp, 0x1f, 0x0000);
1560} 1570}
1561 1571
1562static void rtl8169scd_hw_phy_config(struct rtl8169_private *tp, 1572static void rtl8169scd_hw_phy_config(struct rtl8169_private *tp)
1563 void __iomem *ioaddr)
1564{ 1573{
1565 static const struct phy_reg phy_reg_init[] = { 1574 static const struct phy_reg phy_reg_init[] = {
1566 { 0x1f, 0x0001 }, 1575 { 0x1f, 0x0001 },
@@ -1602,12 +1611,12 @@ static void rtl8169scd_hw_phy_config(struct rtl8169_private *tp,
1602 { 0x1f, 0x0000 } 1611 { 0x1f, 0x0000 }
1603 }; 1612 };
1604 1613
1605 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1614 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1606 1615
1607 rtl8169scd_hw_phy_config_quirk(tp, ioaddr); 1616 rtl8169scd_hw_phy_config_quirk(tp);
1608} 1617}
1609 1618
1610static void rtl8169sce_hw_phy_config(void __iomem *ioaddr) 1619static void rtl8169sce_hw_phy_config(struct rtl8169_private *tp)
1611{ 1620{
1612 static const struct phy_reg phy_reg_init[] = { 1621 static const struct phy_reg phy_reg_init[] = {
1613 { 0x1f, 0x0001 }, 1622 { 0x1f, 0x0001 },
@@ -1657,23 +1666,23 @@ static void rtl8169sce_hw_phy_config(void __iomem *ioaddr)
1657 { 0x1f, 0x0000 } 1666 { 0x1f, 0x0000 }
1658 }; 1667 };
1659 1668
1660 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1669 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1661} 1670}
1662 1671
1663static void rtl8168bb_hw_phy_config(void __iomem *ioaddr) 1672static void rtl8168bb_hw_phy_config(struct rtl8169_private *tp)
1664{ 1673{
1665 static const struct phy_reg phy_reg_init[] = { 1674 static const struct phy_reg phy_reg_init[] = {
1666 { 0x10, 0xf41b }, 1675 { 0x10, 0xf41b },
1667 { 0x1f, 0x0000 } 1676 { 0x1f, 0x0000 }
1668 }; 1677 };
1669 1678
1670 mdio_write(ioaddr, 0x1f, 0x0001); 1679 rtl_writephy(tp, 0x1f, 0x0001);
1671 mdio_patch(ioaddr, 0x16, 1 << 0); 1680 rtl_patchphy(tp, 0x16, 1 << 0);
1672 1681
1673 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1682 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1674} 1683}
1675 1684
1676static void rtl8168bef_hw_phy_config(void __iomem *ioaddr) 1685static void rtl8168bef_hw_phy_config(struct rtl8169_private *tp)
1677{ 1686{
1678 static const struct phy_reg phy_reg_init[] = { 1687 static const struct phy_reg phy_reg_init[] = {
1679 { 0x1f, 0x0001 }, 1688 { 0x1f, 0x0001 },
@@ -1681,10 +1690,10 @@ static void rtl8168bef_hw_phy_config(void __iomem *ioaddr)
1681 { 0x1f, 0x0000 } 1690 { 0x1f, 0x0000 }
1682 }; 1691 };
1683 1692
1684 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1693 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1685} 1694}
1686 1695
1687static void rtl8168cp_1_hw_phy_config(void __iomem *ioaddr) 1696static void rtl8168cp_1_hw_phy_config(struct rtl8169_private *tp)
1688{ 1697{
1689 static const struct phy_reg phy_reg_init[] = { 1698 static const struct phy_reg phy_reg_init[] = {
1690 { 0x1f, 0x0000 }, 1699 { 0x1f, 0x0000 },
@@ -1694,10 +1703,10 @@ static void rtl8168cp_1_hw_phy_config(void __iomem *ioaddr)
1694 { 0x1f, 0x0000 } 1703 { 0x1f, 0x0000 }
1695 }; 1704 };
1696 1705
1697 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1706 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1698} 1707}
1699 1708
1700static void rtl8168cp_2_hw_phy_config(void __iomem *ioaddr) 1709static void rtl8168cp_2_hw_phy_config(struct rtl8169_private *tp)
1701{ 1710{
1702 static const struct phy_reg phy_reg_init[] = { 1711 static const struct phy_reg phy_reg_init[] = {
1703 { 0x1f, 0x0001 }, 1712 { 0x1f, 0x0001 },
@@ -1705,14 +1714,14 @@ static void rtl8168cp_2_hw_phy_config(void __iomem *ioaddr)
1705 { 0x1f, 0x0000 } 1714 { 0x1f, 0x0000 }
1706 }; 1715 };
1707 1716
1708 mdio_write(ioaddr, 0x1f, 0x0000); 1717 rtl_writephy(tp, 0x1f, 0x0000);
1709 mdio_patch(ioaddr, 0x14, 1 << 5); 1718 rtl_patchphy(tp, 0x14, 1 << 5);
1710 mdio_patch(ioaddr, 0x0d, 1 << 5); 1719 rtl_patchphy(tp, 0x0d, 1 << 5);
1711 1720
1712 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1721 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1713} 1722}
1714 1723
1715static void rtl8168c_1_hw_phy_config(void __iomem *ioaddr) 1724static void rtl8168c_1_hw_phy_config(struct rtl8169_private *tp)
1716{ 1725{
1717 static const struct phy_reg phy_reg_init[] = { 1726 static const struct phy_reg phy_reg_init[] = {
1718 { 0x1f, 0x0001 }, 1727 { 0x1f, 0x0001 },
@@ -1734,14 +1743,14 @@ static void rtl8168c_1_hw_phy_config(void __iomem *ioaddr)
1734 { 0x09, 0x0000 } 1743 { 0x09, 0x0000 }
1735 }; 1744 };
1736 1745
1737 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1746 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1738 1747
1739 mdio_patch(ioaddr, 0x14, 1 << 5); 1748 rtl_patchphy(tp, 0x14, 1 << 5);
1740 mdio_patch(ioaddr, 0x0d, 1 << 5); 1749 rtl_patchphy(tp, 0x0d, 1 << 5);
1741 mdio_write(ioaddr, 0x1f, 0x0000); 1750 rtl_writephy(tp, 0x1f, 0x0000);
1742} 1751}
1743 1752
1744static void rtl8168c_2_hw_phy_config(void __iomem *ioaddr) 1753static void rtl8168c_2_hw_phy_config(struct rtl8169_private *tp)
1745{ 1754{
1746 static const struct phy_reg phy_reg_init[] = { 1755 static const struct phy_reg phy_reg_init[] = {
1747 { 0x1f, 0x0001 }, 1756 { 0x1f, 0x0001 },
@@ -1761,15 +1770,15 @@ static void rtl8168c_2_hw_phy_config(void __iomem *ioaddr)
1761 { 0x1f, 0x0000 } 1770 { 0x1f, 0x0000 }
1762 }; 1771 };
1763 1772
1764 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1773 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1765 1774
1766 mdio_patch(ioaddr, 0x16, 1 << 0); 1775 rtl_patchphy(tp, 0x16, 1 << 0);
1767 mdio_patch(ioaddr, 0x14, 1 << 5); 1776 rtl_patchphy(tp, 0x14, 1 << 5);
1768 mdio_patch(ioaddr, 0x0d, 1 << 5); 1777 rtl_patchphy(tp, 0x0d, 1 << 5);
1769 mdio_write(ioaddr, 0x1f, 0x0000); 1778 rtl_writephy(tp, 0x1f, 0x0000);
1770} 1779}
1771 1780
1772static void rtl8168c_3_hw_phy_config(void __iomem *ioaddr) 1781static void rtl8168c_3_hw_phy_config(struct rtl8169_private *tp)
1773{ 1782{
1774 static const struct phy_reg phy_reg_init[] = { 1783 static const struct phy_reg phy_reg_init[] = {
1775 { 0x1f, 0x0001 }, 1784 { 0x1f, 0x0001 },
@@ -1783,17 +1792,17 @@ static void rtl8168c_3_hw_phy_config(void __iomem *ioaddr)
1783 { 0x1f, 0x0000 } 1792 { 0x1f, 0x0000 }
1784 }; 1793 };
1785 1794
1786 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1795 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1787 1796
1788 mdio_patch(ioaddr, 0x16, 1 << 0); 1797 rtl_patchphy(tp, 0x16, 1 << 0);
1789 mdio_patch(ioaddr, 0x14, 1 << 5); 1798 rtl_patchphy(tp, 0x14, 1 << 5);
1790 mdio_patch(ioaddr, 0x0d, 1 << 5); 1799 rtl_patchphy(tp, 0x0d, 1 << 5);
1791 mdio_write(ioaddr, 0x1f, 0x0000); 1800 rtl_writephy(tp, 0x1f, 0x0000);
1792} 1801}
1793 1802
1794static void rtl8168c_4_hw_phy_config(void __iomem *ioaddr) 1803static void rtl8168c_4_hw_phy_config(struct rtl8169_private *tp)
1795{ 1804{
1796 rtl8168c_3_hw_phy_config(ioaddr); 1805 rtl8168c_3_hw_phy_config(tp);
1797} 1806}
1798 1807
1799static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp) 1808static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
@@ -1841,15 +1850,15 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
1841 void __iomem *ioaddr = tp->mmio_addr; 1850 void __iomem *ioaddr = tp->mmio_addr;
1842 const struct firmware *fw; 1851 const struct firmware *fw;
1843 1852
1844 rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); 1853 rtl_writephy_batch(tp, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0));
1845 1854
1846 /* 1855 /*
1847 * Rx Error Issue 1856 * Rx Error Issue
1848 * Fine Tune Switching regulator parameter 1857 * Fine Tune Switching regulator parameter
1849 */ 1858 */
1850 mdio_write(ioaddr, 0x1f, 0x0002); 1859 rtl_writephy(tp, 0x1f, 0x0002);
1851 mdio_plus_minus(ioaddr, 0x0b, 0x0010, 0x00ef); 1860 rtl_w1w0_phy(tp, 0x0b, 0x0010, 0x00ef);
1852 mdio_plus_minus(ioaddr, 0x0c, 0xa200, 0x5d00); 1861 rtl_w1w0_phy(tp, 0x0c, 0xa200, 0x5d00);
1853 1862
1854 if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { 1863 if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) {
1855 static const struct phy_reg phy_reg_init[] = { 1864 static const struct phy_reg phy_reg_init[] = {
@@ -1862,9 +1871,9 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
1862 }; 1871 };
1863 int val; 1872 int val;
1864 1873
1865 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1874 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1866 1875
1867 val = mdio_read(ioaddr, 0x0d); 1876 val = rtl_readphy(tp, 0x0d);
1868 1877
1869 if ((val & 0x00ff) != 0x006c) { 1878 if ((val & 0x00ff) != 0x006c) {
1870 static const u32 set[] = { 1879 static const u32 set[] = {
@@ -1873,11 +1882,11 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
1873 }; 1882 };
1874 int i; 1883 int i;
1875 1884
1876 mdio_write(ioaddr, 0x1f, 0x0002); 1885 rtl_writephy(tp, 0x1f, 0x0002);
1877 1886
1878 val &= 0xff00; 1887 val &= 0xff00;
1879 for (i = 0; i < ARRAY_SIZE(set); i++) 1888 for (i = 0; i < ARRAY_SIZE(set); i++)
1880 mdio_write(ioaddr, 0x0d, val | set[i]); 1889 rtl_writephy(tp, 0x0d, val | set[i]);
1881 } 1890 }
1882 } else { 1891 } else {
1883 static const struct phy_reg phy_reg_init[] = { 1892 static const struct phy_reg phy_reg_init[] = {
@@ -1888,22 +1897,22 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
1888 { 0x06, 0x6662 } 1897 { 0x06, 0x6662 }
1889 }; 1898 };
1890 1899
1891 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1900 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1892 } 1901 }
1893 1902
1894 /* RSET couple improve */ 1903 /* RSET couple improve */
1895 mdio_write(ioaddr, 0x1f, 0x0002); 1904 rtl_writephy(tp, 0x1f, 0x0002);
1896 mdio_patch(ioaddr, 0x0d, 0x0300); 1905 rtl_patchphy(tp, 0x0d, 0x0300);
1897 mdio_patch(ioaddr, 0x0f, 0x0010); 1906 rtl_patchphy(tp, 0x0f, 0x0010);
1898 1907
1899 /* Fine tune PLL performance */ 1908 /* Fine tune PLL performance */
1900 mdio_write(ioaddr, 0x1f, 0x0002); 1909 rtl_writephy(tp, 0x1f, 0x0002);
1901 mdio_plus_minus(ioaddr, 0x02, 0x0100, 0x0600); 1910 rtl_w1w0_phy(tp, 0x02, 0x0100, 0x0600);
1902 mdio_plus_minus(ioaddr, 0x03, 0x0000, 0xe000); 1911 rtl_w1w0_phy(tp, 0x03, 0x0000, 0xe000);
1903 1912
1904 mdio_write(ioaddr, 0x1f, 0x0005); 1913 rtl_writephy(tp, 0x1f, 0x0005);
1905 mdio_write(ioaddr, 0x05, 0x001b); 1914 rtl_writephy(tp, 0x05, 0x001b);
1906 if (mdio_read(ioaddr, 0x06) == 0xbf00 && 1915 if (rtl_readphy(tp, 0x06) == 0xbf00 &&
1907 request_firmware(&fw, FIRMWARE_8168D_1, &tp->pci_dev->dev) == 0) { 1916 request_firmware(&fw, FIRMWARE_8168D_1, &tp->pci_dev->dev) == 0) {
1908 rtl_phy_write_fw(tp, fw); 1917 rtl_phy_write_fw(tp, fw);
1909 release_firmware(fw); 1918 release_firmware(fw);
@@ -1911,7 +1920,7 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
1911 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); 1920 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
1912 } 1921 }
1913 1922
1914 mdio_write(ioaddr, 0x1f, 0x0000); 1923 rtl_writephy(tp, 0x1f, 0x0000);
1915} 1924}
1916 1925
1917static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp) 1926static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
@@ -1959,7 +1968,7 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
1959 void __iomem *ioaddr = tp->mmio_addr; 1968 void __iomem *ioaddr = tp->mmio_addr;
1960 const struct firmware *fw; 1969 const struct firmware *fw;
1961 1970
1962 rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); 1971 rtl_writephy_batch(tp, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0));
1963 1972
1964 if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { 1973 if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) {
1965 static const struct phy_reg phy_reg_init[] = { 1974 static const struct phy_reg phy_reg_init[] = {
@@ -1973,9 +1982,9 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
1973 }; 1982 };
1974 int val; 1983 int val;
1975 1984
1976 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1985 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1977 1986
1978 val = mdio_read(ioaddr, 0x0d); 1987 val = rtl_readphy(tp, 0x0d);
1979 if ((val & 0x00ff) != 0x006c) { 1988 if ((val & 0x00ff) != 0x006c) {
1980 static const u32 set[] = { 1989 static const u32 set[] = {
1981 0x0065, 0x0066, 0x0067, 0x0068, 1990 0x0065, 0x0066, 0x0067, 0x0068,
@@ -1983,11 +1992,11 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
1983 }; 1992 };
1984 int i; 1993 int i;
1985 1994
1986 mdio_write(ioaddr, 0x1f, 0x0002); 1995 rtl_writephy(tp, 0x1f, 0x0002);
1987 1996
1988 val &= 0xff00; 1997 val &= 0xff00;
1989 for (i = 0; i < ARRAY_SIZE(set); i++) 1998 for (i = 0; i < ARRAY_SIZE(set); i++)
1990 mdio_write(ioaddr, 0x0d, val | set[i]); 1999 rtl_writephy(tp, 0x0d, val | set[i]);
1991 } 2000 }
1992 } else { 2001 } else {
1993 static const struct phy_reg phy_reg_init[] = { 2002 static const struct phy_reg phy_reg_init[] = {
@@ -1998,21 +2007,21 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
1998 { 0x06, 0x2642 } 2007 { 0x06, 0x2642 }
1999 }; 2008 };
2000 2009
2001 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 2010 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
2002 } 2011 }
2003 2012
2004 /* Fine tune PLL performance */ 2013 /* Fine tune PLL performance */
2005 mdio_write(ioaddr, 0x1f, 0x0002); 2014 rtl_writephy(tp, 0x1f, 0x0002);
2006 mdio_plus_minus(ioaddr, 0x02, 0x0100, 0x0600); 2015 rtl_w1w0_phy(tp, 0x02, 0x0100, 0x0600);
2007 mdio_plus_minus(ioaddr, 0x03, 0x0000, 0xe000); 2016 rtl_w1w0_phy(tp, 0x03, 0x0000, 0xe000);
2008 2017
2009 /* Switching regulator Slew rate */ 2018 /* Switching regulator Slew rate */
2010 mdio_write(ioaddr, 0x1f, 0x0002); 2019 rtl_writephy(tp, 0x1f, 0x0002);
2011 mdio_patch(ioaddr, 0x0f, 0x0017); 2020 rtl_patchphy(tp, 0x0f, 0x0017);
2012 2021
2013 mdio_write(ioaddr, 0x1f, 0x0005); 2022 rtl_writephy(tp, 0x1f, 0x0005);
2014 mdio_write(ioaddr, 0x05, 0x001b); 2023 rtl_writephy(tp, 0x05, 0x001b);
2015 if (mdio_read(ioaddr, 0x06) == 0xb300 && 2024 if (rtl_readphy(tp, 0x06) == 0xb300 &&
2016 request_firmware(&fw, FIRMWARE_8168D_2, &tp->pci_dev->dev) == 0) { 2025 request_firmware(&fw, FIRMWARE_8168D_2, &tp->pci_dev->dev) == 0) {
2017 rtl_phy_write_fw(tp, fw); 2026 rtl_phy_write_fw(tp, fw);
2018 release_firmware(fw); 2027 release_firmware(fw);
@@ -2020,10 +2029,10 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
2020 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); 2029 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
2021 } 2030 }
2022 2031
2023 mdio_write(ioaddr, 0x1f, 0x0000); 2032 rtl_writephy(tp, 0x1f, 0x0000);
2024} 2033}
2025 2034
2026static void rtl8168d_3_hw_phy_config(void __iomem *ioaddr) 2035static void rtl8168d_3_hw_phy_config(struct rtl8169_private *tp)
2027{ 2036{
2028 static const struct phy_reg phy_reg_init[] = { 2037 static const struct phy_reg phy_reg_init[] = {
2029 { 0x1f, 0x0002 }, 2038 { 0x1f, 0x0002 },
@@ -2081,10 +2090,10 @@ static void rtl8168d_3_hw_phy_config(void __iomem *ioaddr)
2081 { 0x1f, 0x0000 } 2090 { 0x1f, 0x0000 }
2082 }; 2091 };
2083 2092
2084 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 2093 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
2085} 2094}
2086 2095
2087static void rtl8102e_hw_phy_config(void __iomem *ioaddr) 2096static void rtl8102e_hw_phy_config(struct rtl8169_private *tp)
2088{ 2097{
2089 static const struct phy_reg phy_reg_init[] = { 2098 static const struct phy_reg phy_reg_init[] = {
2090 { 0x1f, 0x0003 }, 2099 { 0x1f, 0x0003 },
@@ -2093,18 +2102,17 @@ static void rtl8102e_hw_phy_config(void __iomem *ioaddr)
2093 { 0x1f, 0x0000 } 2102 { 0x1f, 0x0000 }
2094 }; 2103 };
2095 2104
2096 mdio_write(ioaddr, 0x1f, 0x0000); 2105 rtl_writephy(tp, 0x1f, 0x0000);
2097 mdio_patch(ioaddr, 0x11, 1 << 12); 2106 rtl_patchphy(tp, 0x11, 1 << 12);
2098 mdio_patch(ioaddr, 0x19, 1 << 13); 2107 rtl_patchphy(tp, 0x19, 1 << 13);
2099 mdio_patch(ioaddr, 0x10, 1 << 15); 2108 rtl_patchphy(tp, 0x10, 1 << 15);
2100 2109
2101 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 2110 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
2102} 2111}
2103 2112
2104static void rtl_hw_phy_config(struct net_device *dev) 2113static void rtl_hw_phy_config(struct net_device *dev)
2105{ 2114{
2106 struct rtl8169_private *tp = netdev_priv(dev); 2115 struct rtl8169_private *tp = netdev_priv(dev);
2107 void __iomem *ioaddr = tp->mmio_addr;
2108 2116
2109 rtl8169_print_mac_version(tp); 2117 rtl8169_print_mac_version(tp);
2110 2118
@@ -2113,49 +2121,49 @@ static void rtl_hw_phy_config(struct net_device *dev)
2113 break; 2121 break;
2114 case RTL_GIGA_MAC_VER_02: 2122 case RTL_GIGA_MAC_VER_02:
2115 case RTL_GIGA_MAC_VER_03: 2123 case RTL_GIGA_MAC_VER_03:
2116 rtl8169s_hw_phy_config(ioaddr); 2124 rtl8169s_hw_phy_config(tp);
2117 break; 2125 break;
2118 case RTL_GIGA_MAC_VER_04: 2126 case RTL_GIGA_MAC_VER_04:
2119 rtl8169sb_hw_phy_config(ioaddr); 2127 rtl8169sb_hw_phy_config(tp);
2120 break; 2128 break;
2121 case RTL_GIGA_MAC_VER_05: 2129 case RTL_GIGA_MAC_VER_05:
2122 rtl8169scd_hw_phy_config(tp, ioaddr); 2130 rtl8169scd_hw_phy_config(tp);
2123 break; 2131 break;
2124 case RTL_GIGA_MAC_VER_06: 2132 case RTL_GIGA_MAC_VER_06:
2125 rtl8169sce_hw_phy_config(ioaddr); 2133 rtl8169sce_hw_phy_config(tp);
2126 break; 2134 break;
2127 case RTL_GIGA_MAC_VER_07: 2135 case RTL_GIGA_MAC_VER_07:
2128 case RTL_GIGA_MAC_VER_08: 2136 case RTL_GIGA_MAC_VER_08:
2129 case RTL_GIGA_MAC_VER_09: 2137 case RTL_GIGA_MAC_VER_09:
2130 rtl8102e_hw_phy_config(ioaddr); 2138 rtl8102e_hw_phy_config(tp);
2131 break; 2139 break;
2132 case RTL_GIGA_MAC_VER_11: 2140 case RTL_GIGA_MAC_VER_11:
2133 rtl8168bb_hw_phy_config(ioaddr); 2141 rtl8168bb_hw_phy_config(tp);
2134 break; 2142 break;
2135 case RTL_GIGA_MAC_VER_12: 2143 case RTL_GIGA_MAC_VER_12:
2136 rtl8168bef_hw_phy_config(ioaddr); 2144 rtl8168bef_hw_phy_config(tp);
2137 break; 2145 break;
2138 case RTL_GIGA_MAC_VER_17: 2146 case RTL_GIGA_MAC_VER_17:
2139 rtl8168bef_hw_phy_config(ioaddr); 2147 rtl8168bef_hw_phy_config(tp);
2140 break; 2148 break;
2141 case RTL_GIGA_MAC_VER_18: 2149 case RTL_GIGA_MAC_VER_18:
2142 rtl8168cp_1_hw_phy_config(ioaddr); 2150 rtl8168cp_1_hw_phy_config(tp);
2143 break; 2151 break;
2144 case RTL_GIGA_MAC_VER_19: 2152 case RTL_GIGA_MAC_VER_19:
2145 rtl8168c_1_hw_phy_config(ioaddr); 2153 rtl8168c_1_hw_phy_config(tp);
2146 break; 2154 break;
2147 case RTL_GIGA_MAC_VER_20: 2155 case RTL_GIGA_MAC_VER_20:
2148 rtl8168c_2_hw_phy_config(ioaddr); 2156 rtl8168c_2_hw_phy_config(tp);
2149 break; 2157 break;
2150 case RTL_GIGA_MAC_VER_21: 2158 case RTL_GIGA_MAC_VER_21:
2151 rtl8168c_3_hw_phy_config(ioaddr); 2159 rtl8168c_3_hw_phy_config(tp);
2152 break; 2160 break;
2153 case RTL_GIGA_MAC_VER_22: 2161 case RTL_GIGA_MAC_VER_22:
2154 rtl8168c_4_hw_phy_config(ioaddr); 2162 rtl8168c_4_hw_phy_config(tp);
2155 break; 2163 break;
2156 case RTL_GIGA_MAC_VER_23: 2164 case RTL_GIGA_MAC_VER_23:
2157 case RTL_GIGA_MAC_VER_24: 2165 case RTL_GIGA_MAC_VER_24:
2158 rtl8168cp_2_hw_phy_config(ioaddr); 2166 rtl8168cp_2_hw_phy_config(tp);
2159 break; 2167 break;
2160 case RTL_GIGA_MAC_VER_25: 2168 case RTL_GIGA_MAC_VER_25:
2161 rtl8168d_1_hw_phy_config(tp); 2169 rtl8168d_1_hw_phy_config(tp);
@@ -2164,7 +2172,7 @@ static void rtl_hw_phy_config(struct net_device *dev)
2164 rtl8168d_2_hw_phy_config(tp); 2172 rtl8168d_2_hw_phy_config(tp);
2165 break; 2173 break;
2166 case RTL_GIGA_MAC_VER_27: 2174 case RTL_GIGA_MAC_VER_27:
2167 rtl8168d_3_hw_phy_config(ioaddr); 2175 rtl8168d_3_hw_phy_config(tp);
2168 break; 2176 break;
2169 2177
2170 default: 2178 default:
@@ -2187,7 +2195,7 @@ static void rtl8169_phy_timer(unsigned long __opaque)
2187 2195
2188 spin_lock_irq(&tp->lock); 2196 spin_lock_irq(&tp->lock);
2189 2197
2190 if (tp->phy_reset_pending(ioaddr)) { 2198 if (tp->phy_reset_pending(tp)) {
2191 /* 2199 /*
2192 * A busy loop could burn quite a few cycles on nowadays CPU. 2200 * A busy loop could burn quite a few cycles on nowadays CPU.
2193 * Let's delay the execution of the timer for a few ticks. 2201 * Let's delay the execution of the timer for a few ticks.
@@ -2201,7 +2209,7 @@ static void rtl8169_phy_timer(unsigned long __opaque)
2201 2209
2202 netif_warn(tp, link, dev, "PHY reset until link up\n"); 2210 netif_warn(tp, link, dev, "PHY reset until link up\n");
2203 2211
2204 tp->phy_reset_enable(ioaddr); 2212 tp->phy_reset_enable(tp);
2205 2213
2206out_mod_timer: 2214out_mod_timer:
2207 mod_timer(timer, jiffies + timeout); 2215 mod_timer(timer, jiffies + timeout);
@@ -2261,12 +2269,11 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
2261static void rtl8169_phy_reset(struct net_device *dev, 2269static void rtl8169_phy_reset(struct net_device *dev,
2262 struct rtl8169_private *tp) 2270 struct rtl8169_private *tp)
2263{ 2271{
2264 void __iomem *ioaddr = tp->mmio_addr;
2265 unsigned int i; 2272 unsigned int i;
2266 2273
2267 tp->phy_reset_enable(ioaddr); 2274 tp->phy_reset_enable(tp);
2268 for (i = 0; i < 100; i++) { 2275 for (i = 0; i < 100; i++) {
2269 if (!tp->phy_reset_pending(ioaddr)) 2276 if (!tp->phy_reset_pending(tp))
2270 return; 2277 return;
2271 msleep(1); 2278 msleep(1);
2272 } 2279 }
@@ -2293,7 +2300,7 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
2293 dprintk("Set MAC Reg C+CR Offset 0x82h = 0x01h\n"); 2300 dprintk("Set MAC Reg C+CR Offset 0x82h = 0x01h\n");
2294 RTL_W8(0x82, 0x01); 2301 RTL_W8(0x82, 0x01);
2295 dprintk("Set PHY Reg 0x0bh = 0x00h\n"); 2302 dprintk("Set PHY Reg 0x0bh = 0x00h\n");
2296 mdio_write(ioaddr, 0x0b, 0x0000); //w 0x0b 15 0 0 2303 rtl_writephy(tp, 0x0b, 0x0000); //w 0x0b 15 0 0
2297 } 2304 }
2298 2305
2299 rtl8169_phy_reset(dev, tp); 2306 rtl8169_phy_reset(dev, tp);
@@ -2363,11 +2370,11 @@ static int rtl_xmii_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *dat
2363 return 0; 2370 return 0;
2364 2371
2365 case SIOCGMIIREG: 2372 case SIOCGMIIREG:
2366 data->val_out = mdio_read(tp->mmio_addr, data->reg_num & 0x1f); 2373 data->val_out = rtl_readphy(tp, data->reg_num & 0x1f);
2367 return 0; 2374 return 0;
2368 2375
2369 case SIOCSMIIREG: 2376 case SIOCSMIIREG:
2370 mdio_write(tp->mmio_addr, data->reg_num & 0x1f, data->val_in); 2377 rtl_writephy(tp, data->reg_num & 0x1f, data->val_in);
2371 return 0; 2378 return 0;
2372 } 2379 }
2373 return -EOPNOTSUPP; 2380 return -EOPNOTSUPP;