diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2011-04-01 04:21:07 -0400 |
---|---|---|
committer | Francois romieu <romieu@fr.zoreil.com> | 2011-05-09 15:02:55 -0400 |
commit | cecb5fd7c277c1bba161980bb41792a60b56df4a (patch) | |
tree | 304c80aabf91f7de41b1bcd49415802b0a9beb94 /drivers/net/r8169.c | |
parent | 706527280ec38fcdcd0466f10b607105fd23801b (diff) |
r8169: style cleanups.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Realtek linux nic maintainers <nic_swsd@realtek.com>
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r-- | drivers/net/r8169.c | 206 |
1 files changed, 98 insertions, 108 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index a8976a753814..c51515f53df1 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -345,7 +345,7 @@ enum rtl8168_registers { | |||
345 | #define OCPAR_GPHY_READ_CMD 0x0000f060 | 345 | #define OCPAR_GPHY_READ_CMD 0x0000f060 |
346 | RDSAR1 = 0xd0, /* 8168c only. Undocumented on 8168dp */ | 346 | RDSAR1 = 0xd0, /* 8168c only. Undocumented on 8168dp */ |
347 | MISC = 0xf0, /* 8168e only. */ | 347 | MISC = 0xf0, /* 8168e only. */ |
348 | txpla_rst = (1 << 29) | 348 | #define TXPLA_RST (1 << 29) |
349 | }; | 349 | }; |
350 | 350 | ||
351 | enum rtl_register_content { | 351 | enum rtl_register_content { |
@@ -423,7 +423,7 @@ enum rtl_register_content { | |||
423 | BWF = (1 << 6), /* Accept Broadcast wakeup frame */ | 423 | BWF = (1 << 6), /* Accept Broadcast wakeup frame */ |
424 | MWF = (1 << 5), /* Accept Multicast wakeup frame */ | 424 | MWF = (1 << 5), /* Accept Multicast wakeup frame */ |
425 | UWF = (1 << 4), /* Accept Unicast wakeup frame */ | 425 | UWF = (1 << 4), /* Accept Unicast wakeup frame */ |
426 | spi_en = (1 << 3), | 426 | Spi_en = (1 << 3), |
427 | LanWake = (1 << 1), /* LanWake enable/disable */ | 427 | LanWake = (1 << 1), /* LanWake enable/disable */ |
428 | PMEStatus = (1 << 0), /* PME status can be reset by PCI RST# */ | 428 | PMEStatus = (1 << 0), /* PME status can be reset by PCI RST# */ |
429 | 429 | ||
@@ -594,10 +594,10 @@ struct rtl8169_counters { | |||
594 | 594 | ||
595 | struct rtl8169_private { | 595 | struct rtl8169_private { |
596 | void __iomem *mmio_addr; /* memory map physical address */ | 596 | void __iomem *mmio_addr; /* memory map physical address */ |
597 | struct pci_dev *pci_dev; /* Index of PCI device */ | 597 | struct pci_dev *pci_dev; |
598 | struct net_device *dev; | 598 | struct net_device *dev; |
599 | struct napi_struct napi; | 599 | struct napi_struct napi; |
600 | spinlock_t lock; /* spin lock flag */ | 600 | spinlock_t lock; |
601 | u32 msg_enable; | 601 | u32 msg_enable; |
602 | u16 txd_version; | 602 | u16 txd_version; |
603 | u16 mac_version; | 603 | u16 mac_version; |
@@ -730,17 +730,19 @@ static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd) | |||
730 | #define OOB_CMD_DRIVER_START 0x05 | 730 | #define OOB_CMD_DRIVER_START 0x05 |
731 | #define OOB_CMD_DRIVER_STOP 0x06 | 731 | #define OOB_CMD_DRIVER_STOP 0x06 |
732 | 732 | ||
733 | static u16 rtl8168_get_ocp_reg(struct rtl8169_private *tp) | ||
734 | { | ||
735 | return (tp->mac_version == RTL_GIGA_MAC_VER_31) ? 0xb8 : 0x10; | ||
736 | } | ||
737 | |||
733 | static void rtl8168_driver_start(struct rtl8169_private *tp) | 738 | static void rtl8168_driver_start(struct rtl8169_private *tp) |
734 | { | 739 | { |
740 | u16 reg; | ||
735 | int i; | 741 | int i; |
736 | u32 reg; | ||
737 | 742 | ||
738 | rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START); | 743 | rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START); |
739 | 744 | ||
740 | if (tp->mac_version == RTL_GIGA_MAC_VER_31) | 745 | reg = rtl8168_get_ocp_reg(tp); |
741 | reg = 0xb8; | ||
742 | else | ||
743 | reg = 0x10; | ||
744 | 746 | ||
745 | for (i = 0; i < 10; i++) { | 747 | for (i = 0; i < 10; i++) { |
746 | msleep(10); | 748 | msleep(10); |
@@ -751,15 +753,12 @@ static void rtl8168_driver_start(struct rtl8169_private *tp) | |||
751 | 753 | ||
752 | static void rtl8168_driver_stop(struct rtl8169_private *tp) | 754 | static void rtl8168_driver_stop(struct rtl8169_private *tp) |
753 | { | 755 | { |
756 | u16 reg; | ||
754 | int i; | 757 | int i; |
755 | u32 reg; | ||
756 | 758 | ||
757 | rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP); | 759 | rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP); |
758 | 760 | ||
759 | if (tp->mac_version == RTL_GIGA_MAC_VER_31) | 761 | reg = rtl8168_get_ocp_reg(tp); |
760 | reg = 0xb8; | ||
761 | else | ||
762 | reg = 0x10; | ||
763 | 762 | ||
764 | for (i = 0; i < 10; i++) { | 763 | for (i = 0; i < 10; i++) { |
765 | msleep(10); | 764 | msleep(10); |
@@ -770,17 +769,9 @@ static void rtl8168_driver_stop(struct rtl8169_private *tp) | |||
770 | 769 | ||
771 | static int r8168dp_check_dash(struct rtl8169_private *tp) | 770 | static int r8168dp_check_dash(struct rtl8169_private *tp) |
772 | { | 771 | { |
773 | u32 reg; | 772 | u16 reg = rtl8168_get_ocp_reg(tp); |
774 | |||
775 | if (tp->mac_version == RTL_GIGA_MAC_VER_31) | ||
776 | reg = 0xb8; | ||
777 | else | ||
778 | reg = 0x10; | ||
779 | 773 | ||
780 | if (ocp_read(tp, 0xF, reg) & 0x00008000) | 774 | return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0; |
781 | return 1; | ||
782 | else | ||
783 | return 0; | ||
784 | } | 775 | } |
785 | 776 | ||
786 | static void r8169_mdio_write(void __iomem *ioaddr, int reg_addr, int value) | 777 | static void r8169_mdio_write(void __iomem *ioaddr, int reg_addr, int value) |
@@ -1080,9 +1071,8 @@ static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp) | |||
1080 | } | 1071 | } |
1081 | 1072 | ||
1082 | static void __rtl8169_check_link_status(struct net_device *dev, | 1073 | static void __rtl8169_check_link_status(struct net_device *dev, |
1083 | struct rtl8169_private *tp, | 1074 | struct rtl8169_private *tp, |
1084 | void __iomem *ioaddr, | 1075 | void __iomem *ioaddr, bool pm) |
1085 | bool pm) | ||
1086 | { | 1076 | { |
1087 | unsigned long flags; | 1077 | unsigned long flags; |
1088 | 1078 | ||
@@ -1268,16 +1258,16 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
1268 | giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); | 1258 | giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); |
1269 | 1259 | ||
1270 | /* The 8100e/8101e/8102e do Fast Ethernet only. */ | 1260 | /* The 8100e/8101e/8102e do Fast Ethernet only. */ |
1271 | if ((tp->mac_version != RTL_GIGA_MAC_VER_07) && | 1261 | if (tp->mac_version != RTL_GIGA_MAC_VER_07 && |
1272 | (tp->mac_version != RTL_GIGA_MAC_VER_08) && | 1262 | tp->mac_version != RTL_GIGA_MAC_VER_08 && |
1273 | (tp->mac_version != RTL_GIGA_MAC_VER_09) && | 1263 | tp->mac_version != RTL_GIGA_MAC_VER_09 && |
1274 | (tp->mac_version != RTL_GIGA_MAC_VER_10) && | 1264 | tp->mac_version != RTL_GIGA_MAC_VER_10 && |
1275 | (tp->mac_version != RTL_GIGA_MAC_VER_13) && | 1265 | tp->mac_version != RTL_GIGA_MAC_VER_13 && |
1276 | (tp->mac_version != RTL_GIGA_MAC_VER_14) && | 1266 | tp->mac_version != RTL_GIGA_MAC_VER_14 && |
1277 | (tp->mac_version != RTL_GIGA_MAC_VER_15) && | 1267 | tp->mac_version != RTL_GIGA_MAC_VER_15 && |
1278 | (tp->mac_version != RTL_GIGA_MAC_VER_16) && | 1268 | tp->mac_version != RTL_GIGA_MAC_VER_16 && |
1279 | (tp->mac_version != RTL_GIGA_MAC_VER_29) && | 1269 | tp->mac_version != RTL_GIGA_MAC_VER_29 && |
1280 | (tp->mac_version != RTL_GIGA_MAC_VER_30)) { | 1270 | tp->mac_version != RTL_GIGA_MAC_VER_30) { |
1281 | if (adv & ADVERTISED_1000baseT_Half) | 1271 | if (adv & ADVERTISED_1000baseT_Half) |
1282 | giga_ctrl |= ADVERTISE_1000HALF; | 1272 | giga_ctrl |= ADVERTISE_1000HALF; |
1283 | if (adv & ADVERTISED_1000baseT_Full) | 1273 | if (adv & ADVERTISED_1000baseT_Full) |
@@ -1311,8 +1301,8 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
1311 | 1301 | ||
1312 | rtl_writephy(tp, MII_BMCR, bmcr); | 1302 | rtl_writephy(tp, MII_BMCR, bmcr); |
1313 | 1303 | ||
1314 | if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || | 1304 | if (tp->mac_version == RTL_GIGA_MAC_VER_02 || |
1315 | (tp->mac_version == RTL_GIGA_MAC_VER_03)) { | 1305 | tp->mac_version == RTL_GIGA_MAC_VER_03) { |
1316 | if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) { | 1306 | if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) { |
1317 | rtl_writephy(tp, 0x17, 0x2138); | 1307 | rtl_writephy(tp, 0x17, 0x2138); |
1318 | rtl_writephy(tp, 0x0e, 0x0260); | 1308 | rtl_writephy(tp, 0x0e, 0x0260); |
@@ -1348,8 +1338,7 @@ static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1348 | int ret; | 1338 | int ret; |
1349 | 1339 | ||
1350 | spin_lock_irqsave(&tp->lock, flags); | 1340 | spin_lock_irqsave(&tp->lock, flags); |
1351 | ret = rtl8169_set_speed(dev, | 1341 | ret = rtl8169_set_speed(dev, cmd->autoneg, ethtool_cmd_speed(cmd), |
1352 | cmd->autoneg, ethtool_cmd_speed(cmd), | ||
1353 | cmd->duplex, cmd->advertising); | 1342 | cmd->duplex, cmd->advertising); |
1354 | spin_unlock_irqrestore(&tp->lock, flags); | 1343 | spin_unlock_irqrestore(&tp->lock, flags); |
1355 | 1344 | ||
@@ -1507,11 +1496,11 @@ static void rtl8169_update_counters(struct net_device *dev) | |||
1507 | { | 1496 | { |
1508 | struct rtl8169_private *tp = netdev_priv(dev); | 1497 | struct rtl8169_private *tp = netdev_priv(dev); |
1509 | void __iomem *ioaddr = tp->mmio_addr; | 1498 | void __iomem *ioaddr = tp->mmio_addr; |
1499 | struct device *d = &tp->pci_dev->dev; | ||
1510 | struct rtl8169_counters *counters; | 1500 | struct rtl8169_counters *counters; |
1511 | dma_addr_t paddr; | 1501 | dma_addr_t paddr; |
1512 | u32 cmd; | 1502 | u32 cmd; |
1513 | int wait = 1000; | 1503 | int wait = 1000; |
1514 | struct device *d = &tp->pci_dev->dev; | ||
1515 | 1504 | ||
1516 | /* | 1505 | /* |
1517 | * Some chips are unable to dump tally counters when the receiver | 1506 | * Some chips are unable to dump tally counters when the receiver |
@@ -1531,7 +1520,6 @@ static void rtl8169_update_counters(struct net_device *dev) | |||
1531 | 1520 | ||
1532 | while (wait--) { | 1521 | while (wait--) { |
1533 | if ((RTL_R32(CounterAddrLow) & CounterDump) == 0) { | 1522 | if ((RTL_R32(CounterAddrLow) & CounterDump) == 0) { |
1534 | /* copy updated counters */ | ||
1535 | memcpy(&tp->counters, counters, sizeof(*counters)); | 1523 | memcpy(&tp->counters, counters, sizeof(*counters)); |
1536 | break; | 1524 | break; |
1537 | } | 1525 | } |
@@ -1751,14 +1739,14 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1751 | case PHY_BJMPN: | 1739 | case PHY_BJMPN: |
1752 | if (regno > index) { | 1740 | if (regno > index) { |
1753 | netif_err(tp, probe, tp->dev, | 1741 | netif_err(tp, probe, tp->dev, |
1754 | "Out of range of firmware\n"); | 1742 | "Out of range of firmware\n"); |
1755 | return; | 1743 | return; |
1756 | } | 1744 | } |
1757 | break; | 1745 | break; |
1758 | case PHY_READCOUNT_EQ_SKIP: | 1746 | case PHY_READCOUNT_EQ_SKIP: |
1759 | if (index + 2 >= fw_size) { | 1747 | if (index + 2 >= fw_size) { |
1760 | netif_err(tp, probe, tp->dev, | 1748 | netif_err(tp, probe, tp->dev, |
1761 | "Out of range of firmware\n"); | 1749 | "Out of range of firmware\n"); |
1762 | return; | 1750 | return; |
1763 | } | 1751 | } |
1764 | break; | 1752 | break; |
@@ -1767,7 +1755,7 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1767 | case PHY_SKIPN: | 1755 | case PHY_SKIPN: |
1768 | if (index + 1 + regno >= fw_size) { | 1756 | if (index + 1 + regno >= fw_size) { |
1769 | netif_err(tp, probe, tp->dev, | 1757 | netif_err(tp, probe, tp->dev, |
1770 | "Out of range of firmware\n"); | 1758 | "Out of range of firmware\n"); |
1771 | return; | 1759 | return; |
1772 | } | 1760 | } |
1773 | break; | 1761 | break; |
@@ -1823,10 +1811,7 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1823 | index++; | 1811 | index++; |
1824 | break; | 1812 | break; |
1825 | case PHY_READCOUNT_EQ_SKIP: | 1813 | case PHY_READCOUNT_EQ_SKIP: |
1826 | if (count == data) | 1814 | index += (count == data) ? 2 : 1; |
1827 | index += 2; | ||
1828 | else | ||
1829 | index += 1; | ||
1830 | break; | 1815 | break; |
1831 | case PHY_COMP_EQ_SKIPN: | 1816 | case PHY_COMP_EQ_SKIPN: |
1832 | if (predata == data) | 1817 | if (predata == data) |
@@ -2237,7 +2222,7 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp) | |||
2237 | 2222 | ||
2238 | /* | 2223 | /* |
2239 | * Tx Error Issue | 2224 | * Tx Error Issue |
2240 | * enhance line driver power | 2225 | * Enhance line driver power |
2241 | */ | 2226 | */ |
2242 | { 0x1f, 0x0002 }, | 2227 | { 0x1f, 0x0002 }, |
2243 | { 0x06, 0x5561 }, | 2228 | { 0x06, 0x5561 }, |
@@ -2349,7 +2334,7 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp) | |||
2349 | 2334 | ||
2350 | /* | 2335 | /* |
2351 | * Tx Error Issue | 2336 | * Tx Error Issue |
2352 | * enhance line driver power | 2337 | * Enhance line driver power |
2353 | */ | 2338 | */ |
2354 | { 0x1f, 0x0002 }, | 2339 | { 0x1f, 0x0002 }, |
2355 | { 0x06, 0x5561 }, | 2340 | { 0x06, 0x5561 }, |
@@ -2548,7 +2533,7 @@ static void rtl8168e_hw_phy_config(struct rtl8169_private *tp) | |||
2548 | /* For impedance matching */ | 2533 | /* For impedance matching */ |
2549 | rtl_writephy(tp, 0x1f, 0x0002); | 2534 | rtl_writephy(tp, 0x1f, 0x0002); |
2550 | rtl_w1w0_phy(tp, 0x08, 0x8000, 0x7f00); | 2535 | rtl_w1w0_phy(tp, 0x08, 0x8000, 0x7f00); |
2551 | rtl_writephy(tp, 0x1F, 0x0000); | 2536 | rtl_writephy(tp, 0x1f, 0x0000); |
2552 | 2537 | ||
2553 | /* PHY auto speed down */ | 2538 | /* PHY auto speed down */ |
2554 | rtl_writephy(tp, 0x1f, 0x0007); | 2539 | rtl_writephy(tp, 0x1f, 0x0007); |
@@ -2692,6 +2677,9 @@ static void rtl_hw_phy_config(struct net_device *dev) | |||
2692 | case RTL_GIGA_MAC_VER_30: | 2677 | case RTL_GIGA_MAC_VER_30: |
2693 | rtl8105e_hw_phy_config(tp); | 2678 | rtl8105e_hw_phy_config(tp); |
2694 | break; | 2679 | break; |
2680 | case RTL_GIGA_MAC_VER_31: | ||
2681 | /* None. */ | ||
2682 | break; | ||
2695 | case RTL_GIGA_MAC_VER_32: | 2683 | case RTL_GIGA_MAC_VER_32: |
2696 | case RTL_GIGA_MAC_VER_33: | 2684 | case RTL_GIGA_MAC_VER_33: |
2697 | rtl8168e_hw_phy_config(tp); | 2685 | rtl8168e_hw_phy_config(tp); |
@@ -2828,11 +2816,11 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) | |||
2828 | rtl8169_phy_reset(dev, tp); | 2816 | rtl8169_phy_reset(dev, tp); |
2829 | 2817 | ||
2830 | rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL, | 2818 | rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL, |
2831 | ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | | 2819 | ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | |
2832 | ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | | 2820 | ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | |
2833 | (tp->mii.supports_gmii ? | 2821 | (tp->mii.supports_gmii ? |
2834 | ADVERTISED_1000baseT_Half | | 2822 | ADVERTISED_1000baseT_Half | |
2835 | ADVERTISED_1000baseT_Full : 0)); | 2823 | ADVERTISED_1000baseT_Full : 0)); |
2836 | 2824 | ||
2837 | if (RTL_R8(PHYstatus) & TBI_Enable) | 2825 | if (RTL_R8(PHYstatus) & TBI_Enable) |
2838 | netif_info(tp, link, dev, "TBI auto-negotiating\n"); | 2826 | netif_info(tp, link, dev, "TBI auto-negotiating\n"); |
@@ -2885,7 +2873,8 @@ static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
2885 | return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV; | 2873 | return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV; |
2886 | } | 2874 | } |
2887 | 2875 | ||
2888 | static int rtl_xmii_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd) | 2876 | static int rtl_xmii_ioctl(struct rtl8169_private *tp, |
2877 | struct mii_ioctl_data *data, int cmd) | ||
2889 | { | 2878 | { |
2890 | switch (cmd) { | 2879 | switch (cmd) { |
2891 | case SIOCGMIIPHY: | 2880 | case SIOCGMIIPHY: |
@@ -3107,15 +3096,15 @@ static void r8168_pll_power_down(struct rtl8169_private *tp) | |||
3107 | { | 3096 | { |
3108 | void __iomem *ioaddr = tp->mmio_addr; | 3097 | void __iomem *ioaddr = tp->mmio_addr; |
3109 | 3098 | ||
3110 | if (((tp->mac_version == RTL_GIGA_MAC_VER_27) || | 3099 | if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || |
3111 | (tp->mac_version == RTL_GIGA_MAC_VER_28) || | 3100 | tp->mac_version == RTL_GIGA_MAC_VER_28 || |
3112 | (tp->mac_version == RTL_GIGA_MAC_VER_31)) && | 3101 | tp->mac_version == RTL_GIGA_MAC_VER_31) && |
3113 | r8168dp_check_dash(tp)) { | 3102 | r8168dp_check_dash(tp)) { |
3114 | return; | 3103 | return; |
3115 | } | 3104 | } |
3116 | 3105 | ||
3117 | if (((tp->mac_version == RTL_GIGA_MAC_VER_23) || | 3106 | if ((tp->mac_version == RTL_GIGA_MAC_VER_23 || |
3118 | (tp->mac_version == RTL_GIGA_MAC_VER_24)) && | 3107 | tp->mac_version == RTL_GIGA_MAC_VER_24) && |
3119 | (RTL_R16(CPlusCmd) & ASF)) { | 3108 | (RTL_R16(CPlusCmd) & ASF)) { |
3120 | return; | 3109 | return; |
3121 | } | 3110 | } |
@@ -3152,9 +3141,9 @@ static void r8168_pll_power_up(struct rtl8169_private *tp) | |||
3152 | { | 3141 | { |
3153 | void __iomem *ioaddr = tp->mmio_addr; | 3142 | void __iomem *ioaddr = tp->mmio_addr; |
3154 | 3143 | ||
3155 | if (((tp->mac_version == RTL_GIGA_MAC_VER_27) || | 3144 | if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || |
3156 | (tp->mac_version == RTL_GIGA_MAC_VER_28) || | 3145 | tp->mac_version == RTL_GIGA_MAC_VER_28 || |
3157 | (tp->mac_version == RTL_GIGA_MAC_VER_31)) && | 3146 | tp->mac_version == RTL_GIGA_MAC_VER_31) && |
3158 | r8168dp_check_dash(tp)) { | 3147 | r8168dp_check_dash(tp)) { |
3159 | return; | 3148 | return; |
3160 | } | 3149 | } |
@@ -3469,9 +3458,9 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3469 | rtl_chip_info[chipset].name, dev->base_addr, dev->dev_addr, | 3458 | rtl_chip_info[chipset].name, dev->base_addr, dev->dev_addr, |
3470 | (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), dev->irq); | 3459 | (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), dev->irq); |
3471 | 3460 | ||
3472 | if ((tp->mac_version == RTL_GIGA_MAC_VER_27) || | 3461 | if (tp->mac_version == RTL_GIGA_MAC_VER_27 || |
3473 | (tp->mac_version == RTL_GIGA_MAC_VER_28) || | 3462 | tp->mac_version == RTL_GIGA_MAC_VER_28 || |
3474 | (tp->mac_version == RTL_GIGA_MAC_VER_31)) { | 3463 | tp->mac_version == RTL_GIGA_MAC_VER_31) { |
3475 | rtl8168_driver_start(tp); | 3464 | rtl8168_driver_start(tp); |
3476 | } | 3465 | } |
3477 | 3466 | ||
@@ -3503,9 +3492,9 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3503 | struct net_device *dev = pci_get_drvdata(pdev); | 3492 | struct net_device *dev = pci_get_drvdata(pdev); |
3504 | struct rtl8169_private *tp = netdev_priv(dev); | 3493 | struct rtl8169_private *tp = netdev_priv(dev); |
3505 | 3494 | ||
3506 | if ((tp->mac_version == RTL_GIGA_MAC_VER_27) || | 3495 | if (tp->mac_version == RTL_GIGA_MAC_VER_27 || |
3507 | (tp->mac_version == RTL_GIGA_MAC_VER_28) || | 3496 | tp->mac_version == RTL_GIGA_MAC_VER_28 || |
3508 | (tp->mac_version == RTL_GIGA_MAC_VER_31)) { | 3497 | tp->mac_version == RTL_GIGA_MAC_VER_31) { |
3509 | rtl8168_driver_stop(tp); | 3498 | rtl8168_driver_stop(tp); |
3510 | } | 3499 | } |
3511 | 3500 | ||
@@ -3753,26 +3742,26 @@ static void rtl_hw_start_8169(struct net_device *dev) | |||
3753 | } | 3742 | } |
3754 | 3743 | ||
3755 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 3744 | RTL_W8(Cfg9346, Cfg9346_Unlock); |
3756 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || | 3745 | if (tp->mac_version == RTL_GIGA_MAC_VER_01 || |
3757 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || | 3746 | tp->mac_version == RTL_GIGA_MAC_VER_02 || |
3758 | (tp->mac_version == RTL_GIGA_MAC_VER_03) || | 3747 | tp->mac_version == RTL_GIGA_MAC_VER_03 || |
3759 | (tp->mac_version == RTL_GIGA_MAC_VER_04)) | 3748 | tp->mac_version == RTL_GIGA_MAC_VER_04) |
3760 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 3749 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); |
3761 | 3750 | ||
3762 | RTL_W8(EarlyTxThres, NoEarlyTx); | 3751 | RTL_W8(EarlyTxThres, NoEarlyTx); |
3763 | 3752 | ||
3764 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); | 3753 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); |
3765 | 3754 | ||
3766 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || | 3755 | if (tp->mac_version == RTL_GIGA_MAC_VER_01 || |
3767 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || | 3756 | tp->mac_version == RTL_GIGA_MAC_VER_02 || |
3768 | (tp->mac_version == RTL_GIGA_MAC_VER_03) || | 3757 | tp->mac_version == RTL_GIGA_MAC_VER_03 || |
3769 | (tp->mac_version == RTL_GIGA_MAC_VER_04)) | 3758 | tp->mac_version == RTL_GIGA_MAC_VER_04) |
3770 | rtl_set_rx_tx_config_registers(tp); | 3759 | rtl_set_rx_tx_config_registers(tp); |
3771 | 3760 | ||
3772 | tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; | 3761 | tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; |
3773 | 3762 | ||
3774 | if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || | 3763 | if (tp->mac_version == RTL_GIGA_MAC_VER_02 || |
3775 | (tp->mac_version == RTL_GIGA_MAC_VER_03)) { | 3764 | tp->mac_version == RTL_GIGA_MAC_VER_03) { |
3776 | dprintk("Set MAC Reg C+CR Offset 0xE0. " | 3765 | dprintk("Set MAC Reg C+CR Offset 0xE0. " |
3777 | "Bit-3 and bit-14 MUST be 1\n"); | 3766 | "Bit-3 and bit-14 MUST be 1\n"); |
3778 | tp->cp_cmd |= (1 << 14); | 3767 | tp->cp_cmd |= (1 << 14); |
@@ -3790,10 +3779,10 @@ static void rtl_hw_start_8169(struct net_device *dev) | |||
3790 | 3779 | ||
3791 | rtl_set_rx_tx_desc_registers(tp, ioaddr); | 3780 | rtl_set_rx_tx_desc_registers(tp, ioaddr); |
3792 | 3781 | ||
3793 | if ((tp->mac_version != RTL_GIGA_MAC_VER_01) && | 3782 | if (tp->mac_version != RTL_GIGA_MAC_VER_01 && |
3794 | (tp->mac_version != RTL_GIGA_MAC_VER_02) && | 3783 | tp->mac_version != RTL_GIGA_MAC_VER_02 && |
3795 | (tp->mac_version != RTL_GIGA_MAC_VER_03) && | 3784 | tp->mac_version != RTL_GIGA_MAC_VER_03 && |
3796 | (tp->mac_version != RTL_GIGA_MAC_VER_04)) { | 3785 | tp->mac_version != RTL_GIGA_MAC_VER_04) { |
3797 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 3786 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); |
3798 | rtl_set_rx_tx_config_registers(tp); | 3787 | rtl_set_rx_tx_config_registers(tp); |
3799 | } | 3788 | } |
@@ -4103,10 +4092,10 @@ static void rtl_hw_start_8168e(void __iomem *ioaddr, struct pci_dev *pdev) | |||
4103 | rtl_disable_clock_request(pdev); | 4092 | rtl_disable_clock_request(pdev); |
4104 | 4093 | ||
4105 | /* Reset tx FIFO pointer */ | 4094 | /* Reset tx FIFO pointer */ |
4106 | RTL_W32(MISC, RTL_R32(MISC) | txpla_rst); | 4095 | RTL_W32(MISC, RTL_R32(MISC) | TXPLA_RST); |
4107 | RTL_W32(MISC, RTL_R32(MISC) & ~txpla_rst); | 4096 | RTL_W32(MISC, RTL_R32(MISC) & ~TXPLA_RST); |
4108 | 4097 | ||
4109 | RTL_W8(Config5, RTL_R8(Config5) & ~spi_en); | 4098 | RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en); |
4110 | } | 4099 | } |
4111 | 4100 | ||
4112 | static void rtl_hw_start_8168(struct net_device *dev) | 4101 | static void rtl_hw_start_8168(struct net_device *dev) |
@@ -4190,6 +4179,7 @@ static void rtl_hw_start_8168(struct net_device *dev) | |||
4190 | case RTL_GIGA_MAC_VER_28: | 4179 | case RTL_GIGA_MAC_VER_28: |
4191 | rtl_hw_start_8168d_4(ioaddr, pdev); | 4180 | rtl_hw_start_8168d_4(ioaddr, pdev); |
4192 | break; | 4181 | break; |
4182 | |||
4193 | case RTL_GIGA_MAC_VER_31: | 4183 | case RTL_GIGA_MAC_VER_31: |
4194 | rtl_hw_start_8168dp(ioaddr, pdev); | 4184 | rtl_hw_start_8168dp(ioaddr, pdev); |
4195 | break; | 4185 | break; |
@@ -4286,10 +4276,10 @@ static void rtl_hw_start_8105e_1(void __iomem *ioaddr, struct pci_dev *pdev) | |||
4286 | { 0x0a, 0, 0x0020 } | 4276 | { 0x0a, 0, 0x0020 } |
4287 | }; | 4277 | }; |
4288 | 4278 | ||
4289 | /* Force LAN exit from ASPM if Rx/Tx are not idel */ | 4279 | /* Force LAN exit from ASPM if Rx/Tx are not idle */ |
4290 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) | 0x002800); | 4280 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) | 0x002800); |
4291 | 4281 | ||
4292 | /* disable Early Tally Counter */ | 4282 | /* Disable Early Tally Counter */ |
4293 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) & ~0x010000); | 4283 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) & ~0x010000); |
4294 | 4284 | ||
4295 | RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); | 4285 | RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); |
@@ -4310,8 +4300,8 @@ static void rtl_hw_start_8101(struct net_device *dev) | |||
4310 | void __iomem *ioaddr = tp->mmio_addr; | 4300 | void __iomem *ioaddr = tp->mmio_addr; |
4311 | struct pci_dev *pdev = tp->pci_dev; | 4301 | struct pci_dev *pdev = tp->pci_dev; |
4312 | 4302 | ||
4313 | if ((tp->mac_version == RTL_GIGA_MAC_VER_13) || | 4303 | if (tp->mac_version == RTL_GIGA_MAC_VER_13 || |
4314 | (tp->mac_version == RTL_GIGA_MAC_VER_16)) { | 4304 | tp->mac_version == RTL_GIGA_MAC_VER_16) { |
4315 | int cap = tp->pcie_cap; | 4305 | int cap = tp->pcie_cap; |
4316 | 4306 | ||
4317 | if (cap) { | 4307 | if (cap) { |
@@ -4677,7 +4667,7 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb, | |||
4677 | goto err_out; | 4667 | goto err_out; |
4678 | } | 4668 | } |
4679 | 4669 | ||
4680 | /* anti gcc 2.95.3 bugware (sic) */ | 4670 | /* Anti gcc 2.95.3 bugware (sic) */ |
4681 | status = opts[0] | len | | 4671 | status = opts[0] | len | |
4682 | (RingEnd * !((entry + 1) % NUM_TX_DESC)); | 4672 | (RingEnd * !((entry + 1) % NUM_TX_DESC)); |
4683 | 4673 | ||
@@ -4773,7 +4763,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
4773 | 4763 | ||
4774 | wmb(); | 4764 | wmb(); |
4775 | 4765 | ||
4776 | /* anti gcc 2.95.3 bugware (sic) */ | 4766 | /* Anti gcc 2.95.3 bugware (sic) */ |
4777 | status = opts[0] | len | (RingEnd * !((entry + 1) % NUM_TX_DESC)); | 4767 | status = opts[0] | len | (RingEnd * !((entry + 1) % NUM_TX_DESC)); |
4778 | txd->opts1 = cpu_to_le32(status); | 4768 | txd->opts1 = cpu_to_le32(status); |
4779 | 4769 | ||
@@ -4781,7 +4771,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
4781 | 4771 | ||
4782 | wmb(); | 4772 | wmb(); |
4783 | 4773 | ||
4784 | RTL_W8(TxPoll, NPQ); /* set polling bit */ | 4774 | RTL_W8(TxPoll, NPQ); |
4785 | 4775 | ||
4786 | if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { | 4776 | if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { |
4787 | netif_stop_queue(dev); | 4777 | netif_stop_queue(dev); |
@@ -5207,7 +5197,7 @@ static int rtl8169_close(struct net_device *dev) | |||
5207 | 5197 | ||
5208 | pm_runtime_get_sync(&pdev->dev); | 5198 | pm_runtime_get_sync(&pdev->dev); |
5209 | 5199 | ||
5210 | /* update counters before going down */ | 5200 | /* Update counters before going down */ |
5211 | rtl8169_update_counters(dev); | 5201 | rtl8169_update_counters(dev); |
5212 | 5202 | ||
5213 | rtl8169_down(dev); | 5203 | rtl8169_down(dev); |
@@ -5400,15 +5390,15 @@ static int rtl8169_runtime_idle(struct device *device) | |||
5400 | } | 5390 | } |
5401 | 5391 | ||
5402 | static const struct dev_pm_ops rtl8169_pm_ops = { | 5392 | static const struct dev_pm_ops rtl8169_pm_ops = { |
5403 | .suspend = rtl8169_suspend, | 5393 | .suspend = rtl8169_suspend, |
5404 | .resume = rtl8169_resume, | 5394 | .resume = rtl8169_resume, |
5405 | .freeze = rtl8169_suspend, | 5395 | .freeze = rtl8169_suspend, |
5406 | .thaw = rtl8169_resume, | 5396 | .thaw = rtl8169_resume, |
5407 | .poweroff = rtl8169_suspend, | 5397 | .poweroff = rtl8169_suspend, |
5408 | .restore = rtl8169_resume, | 5398 | .restore = rtl8169_resume, |
5409 | .runtime_suspend = rtl8169_runtime_suspend, | 5399 | .runtime_suspend = rtl8169_runtime_suspend, |
5410 | .runtime_resume = rtl8169_runtime_resume, | 5400 | .runtime_resume = rtl8169_runtime_resume, |
5411 | .runtime_idle = rtl8169_runtime_idle, | 5401 | .runtime_idle = rtl8169_runtime_idle, |
5412 | }; | 5402 | }; |
5413 | 5403 | ||
5414 | #define RTL8169_PM_OPS (&rtl8169_pm_ops) | 5404 | #define RTL8169_PM_OPS (&rtl8169_pm_ops) |
@@ -5427,7 +5417,7 @@ static void rtl_shutdown(struct pci_dev *pdev) | |||
5427 | 5417 | ||
5428 | rtl8169_net_suspend(dev); | 5418 | rtl8169_net_suspend(dev); |
5429 | 5419 | ||
5430 | /* restore original MAC address */ | 5420 | /* Restore original MAC address */ |
5431 | rtl_rar_set(tp, dev->perm_addr); | 5421 | rtl_rar_set(tp, dev->perm_addr); |
5432 | 5422 | ||
5433 | spin_lock_irq(&tp->lock); | 5423 | spin_lock_irq(&tp->lock); |