aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrançois romieu <romieu@fr.zoreil.com>2011-01-03 10:07:31 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-04 12:48:31 -0500
commitbca03d5f32c8ee9b5cfa1d32640a63fded6cb3c0 (patch)
treefc9db1b0c22b69eaab96b0d92df1f0809f782ff9
parent42bb8d56953a06de50941d6d3df89dc3023bb92d (diff)
r8169: remove the firmware of RTL8111D.
The binary file of the firmware is moved to linux-firmware repository. The firmwares are rtl_nic/rtl8168d-1.fw and rtl_nic/rtl8168d-2.fw. The driver goes along if the firmware couldn't be found. However, it is suggested to be done with the suitable firmware. Some wrong PHY parameters are directly corrected in the driver. Simple firmware checking added per Ben Hutchings suggestion. Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Cc: Ben Hutchings <benh@debian.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/Kconfig1
-rw-r--r--drivers/net/r8169.c812
2 files changed, 134 insertions, 679 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 89be23340ee4..3fda24a28d2f 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2233,6 +2233,7 @@ config YELLOWFIN
2233config R8169 2233config R8169
2234 tristate "Realtek 8169 gigabit ethernet support" 2234 tristate "Realtek 8169 gigabit ethernet support"
2235 depends on PCI 2235 depends on PCI
2236 select FW_LOADER
2236 select CRC32 2237 select CRC32
2237 select MII 2238 select MII
2238 ---help--- 2239 ---help---
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index e165d96ec7df..312446234509 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/pm_runtime.h> 26#include <linux/pm_runtime.h>
27#include <linux/firmware.h>
27 28
28#include <asm/system.h> 29#include <asm/system.h>
29#include <asm/io.h> 30#include <asm/io.h>
@@ -33,6 +34,9 @@
33#define MODULENAME "r8169" 34#define MODULENAME "r8169"
34#define PFX MODULENAME ": " 35#define PFX MODULENAME ": "
35 36
37#define FIRMWARE_8168D_1 "rtl_nic/rtl8168d-1.fw"
38#define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw"
39
36#ifdef RTL8169_DEBUG 40#ifdef RTL8169_DEBUG
37#define assert(expr) \ 41#define assert(expr) \
38 if (!(expr)) { \ 42 if (!(expr)) { \
@@ -514,6 +518,8 @@ module_param_named(debug, debug.msg_enable, int, 0);
514MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); 518MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
515MODULE_LICENSE("GPL"); 519MODULE_LICENSE("GPL");
516MODULE_VERSION(RTL8169_VERSION); 520MODULE_VERSION(RTL8169_VERSION);
521MODULE_FIRMWARE(FIRMWARE_8168D_1);
522MODULE_FIRMWARE(FIRMWARE_8168D_2);
517 523
518static int rtl8169_open(struct net_device *dev); 524static int rtl8169_open(struct net_device *dev);
519static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, 525static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
@@ -1393,6 +1399,65 @@ static void rtl_phy_write(void __iomem *ioaddr, const struct phy_reg *regs, int
1393 } 1399 }
1394} 1400}
1395 1401
1402#define PHY_READ 0x00000000
1403#define PHY_DATA_OR 0x10000000
1404#define PHY_DATA_AND 0x20000000
1405#define PHY_BJMPN 0x30000000
1406#define PHY_READ_EFUSE 0x40000000
1407#define PHY_READ_MAC_BYTE 0x50000000
1408#define PHY_WRITE_MAC_BYTE 0x60000000
1409#define PHY_CLEAR_READCOUNT 0x70000000
1410#define PHY_WRITE 0x80000000
1411#define PHY_READCOUNT_EQ_SKIP 0x90000000
1412#define PHY_COMP_EQ_SKIPN 0xa0000000
1413#define PHY_COMP_NEQ_SKIPN 0xb0000000
1414#define PHY_WRITE_PREVIOUS 0xc0000000
1415#define PHY_SKIPN 0xd0000000
1416#define PHY_DELAY_MS 0xe0000000
1417#define PHY_WRITE_ERI_WORD 0xf0000000
1418
1419static void
1420rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
1421{
1422 void __iomem *ioaddr = tp->mmio_addr;
1423 __le32 *phytable = (__le32 *)fw->data;
1424 struct net_device *dev = tp->dev;
1425 size_t i;
1426
1427 if (fw->size % sizeof(*phytable)) {
1428 netif_err(tp, probe, dev, "odd sized firmware %zd\n", fw->size);
1429 return;
1430 }
1431
1432 for (i = 0; i < fw->size / sizeof(*phytable); i++) {
1433 u32 action = le32_to_cpu(phytable[i]);
1434
1435 if (!action)
1436 break;
1437
1438 if ((action & 0xf0000000) != PHY_WRITE) {
1439 netif_err(tp, probe, dev,
1440 "unknown action 0x%08x\n", action);
1441 return;
1442 }
1443 }
1444
1445 while (i-- != 0) {
1446 u32 action = le32_to_cpu(*phytable);
1447 u32 data = action & 0x0000ffff;
1448 u32 reg = (action & 0x0fff0000) >> 16;
1449
1450 switch(action & 0xf0000000) {
1451 case PHY_WRITE:
1452 mdio_write(ioaddr, reg, data);
1453 phytable++;
1454 break;
1455 default:
1456 BUG();
1457 }
1458 }
1459}
1460
1396static void rtl8169s_hw_phy_config(void __iomem *ioaddr) 1461static void rtl8169s_hw_phy_config(void __iomem *ioaddr)
1397{ 1462{
1398 static const struct phy_reg phy_reg_init[] = { 1463 static const struct phy_reg phy_reg_init[] = {
@@ -1725,9 +1790,10 @@ static void rtl8168c_4_hw_phy_config(void __iomem *ioaddr)
1725 rtl8168c_3_hw_phy_config(ioaddr); 1790 rtl8168c_3_hw_phy_config(ioaddr);
1726} 1791}
1727 1792
1728static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) 1793static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
1729{ 1794{
1730 static const struct phy_reg phy_reg_init_0[] = { 1795 static const struct phy_reg phy_reg_init_0[] = {
1796 /* Channel Estimation */
1731 { 0x1f, 0x0001 }, 1797 { 0x1f, 0x0001 },
1732 { 0x06, 0x4064 }, 1798 { 0x06, 0x4064 },
1733 { 0x07, 0x2863 }, 1799 { 0x07, 0x2863 },
@@ -1744,379 +1810,41 @@ static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr)
1744 { 0x12, 0xf49f }, 1810 { 0x12, 0xf49f },
1745 { 0x13, 0x070b }, 1811 { 0x13, 0x070b },
1746 { 0x1a, 0x05ad }, 1812 { 0x1a, 0x05ad },
1747 { 0x14, 0x94c0 } 1813 { 0x14, 0x94c0 },
1748 }; 1814
1749 static const struct phy_reg phy_reg_init_1[] = { 1815 /*
1816 * Tx Error Issue
1817 * enhance line driver power
1818 */
1750 { 0x1f, 0x0002 }, 1819 { 0x1f, 0x0002 },
1751 { 0x06, 0x5561 }, 1820 { 0x06, 0x5561 },
1752 { 0x1f, 0x0005 }, 1821 { 0x1f, 0x0005 },
1753 { 0x05, 0x8332 }, 1822 { 0x05, 0x8332 },
1754 { 0x06, 0x5561 } 1823 { 0x06, 0x5561 },
1755 }; 1824
1756 static const struct phy_reg phy_reg_init_2[] = { 1825 /*
1757 { 0x1f, 0x0005 }, 1826 * Can not link to 1Gbps with bad cable
1758 { 0x05, 0xffc2 }, 1827 * Decrease SNR threshold form 21.07dB to 19.04dB
1759 { 0x1f, 0x0005 }, 1828 */
1760 { 0x05, 0x8000 }, 1829 { 0x1f, 0x0001 },
1761 { 0x06, 0xf8f9 }, 1830 { 0x17, 0x0cc0 },
1762 { 0x06, 0xfaef },
1763 { 0x06, 0x59ee },
1764 { 0x06, 0xf8ea },
1765 { 0x06, 0x00ee },
1766 { 0x06, 0xf8eb },
1767 { 0x06, 0x00e0 },
1768 { 0x06, 0xf87c },
1769 { 0x06, 0xe1f8 },
1770 { 0x06, 0x7d59 },
1771 { 0x06, 0x0fef },
1772 { 0x06, 0x0139 },
1773 { 0x06, 0x029e },
1774 { 0x06, 0x06ef },
1775 { 0x06, 0x1039 },
1776 { 0x06, 0x089f },
1777 { 0x06, 0x2aee },
1778 { 0x06, 0xf8ea },
1779 { 0x06, 0x00ee },
1780 { 0x06, 0xf8eb },
1781 { 0x06, 0x01e0 },
1782 { 0x06, 0xf87c },
1783 { 0x06, 0xe1f8 },
1784 { 0x06, 0x7d58 },
1785 { 0x06, 0x409e },
1786 { 0x06, 0x0f39 },
1787 { 0x06, 0x46aa },
1788 { 0x06, 0x0bbf },
1789 { 0x06, 0x8290 },
1790 { 0x06, 0xd682 },
1791 { 0x06, 0x9802 },
1792 { 0x06, 0x014f },
1793 { 0x06, 0xae09 },
1794 { 0x06, 0xbf82 },
1795 { 0x06, 0x98d6 },
1796 { 0x06, 0x82a0 },
1797 { 0x06, 0x0201 },
1798 { 0x06, 0x4fef },
1799 { 0x06, 0x95fe },
1800 { 0x06, 0xfdfc },
1801 { 0x06, 0x05f8 },
1802 { 0x06, 0xf9fa },
1803 { 0x06, 0xeef8 },
1804 { 0x06, 0xea00 },
1805 { 0x06, 0xeef8 },
1806 { 0x06, 0xeb00 },
1807 { 0x06, 0xe2f8 },
1808 { 0x06, 0x7ce3 },
1809 { 0x06, 0xf87d },
1810 { 0x06, 0xa511 },
1811 { 0x06, 0x1112 },
1812 { 0x06, 0xd240 },
1813 { 0x06, 0xd644 },
1814 { 0x06, 0x4402 },
1815 { 0x06, 0x8217 },
1816 { 0x06, 0xd2a0 },
1817 { 0x06, 0xd6aa },
1818 { 0x06, 0xaa02 },
1819 { 0x06, 0x8217 },
1820 { 0x06, 0xae0f },
1821 { 0x06, 0xa544 },
1822 { 0x06, 0x4402 },
1823 { 0x06, 0xae4d },
1824 { 0x06, 0xa5aa },
1825 { 0x06, 0xaa02 },
1826 { 0x06, 0xae47 },
1827 { 0x06, 0xaf82 },
1828 { 0x06, 0x13ee },
1829 { 0x06, 0x834e },
1830 { 0x06, 0x00ee },
1831 { 0x06, 0x834d },
1832 { 0x06, 0x0fee },
1833 { 0x06, 0x834c },
1834 { 0x06, 0x0fee },
1835 { 0x06, 0x834f },
1836 { 0x06, 0x00ee },
1837 { 0x06, 0x8351 },
1838 { 0x06, 0x00ee },
1839 { 0x06, 0x834a },
1840 { 0x06, 0xffee },
1841 { 0x06, 0x834b },
1842 { 0x06, 0xffe0 },
1843 { 0x06, 0x8330 },
1844 { 0x06, 0xe183 },
1845 { 0x06, 0x3158 },
1846 { 0x06, 0xfee4 },
1847 { 0x06, 0xf88a },
1848 { 0x06, 0xe5f8 },
1849 { 0x06, 0x8be0 },
1850 { 0x06, 0x8332 },
1851 { 0x06, 0xe183 },
1852 { 0x06, 0x3359 },
1853 { 0x06, 0x0fe2 },
1854 { 0x06, 0x834d },
1855 { 0x06, 0x0c24 },
1856 { 0x06, 0x5af0 },
1857 { 0x06, 0x1e12 },
1858 { 0x06, 0xe4f8 },
1859 { 0x06, 0x8ce5 },
1860 { 0x06, 0xf88d },
1861 { 0x06, 0xaf82 },
1862 { 0x06, 0x13e0 },
1863 { 0x06, 0x834f },
1864 { 0x06, 0x10e4 },
1865 { 0x06, 0x834f },
1866 { 0x06, 0xe083 },
1867 { 0x06, 0x4e78 },
1868 { 0x06, 0x009f },
1869 { 0x06, 0x0ae0 },
1870 { 0x06, 0x834f },
1871 { 0x06, 0xa010 },
1872 { 0x06, 0xa5ee },
1873 { 0x06, 0x834e },
1874 { 0x06, 0x01e0 },
1875 { 0x06, 0x834e },
1876 { 0x06, 0x7805 },
1877 { 0x06, 0x9e9a },
1878 { 0x06, 0xe083 },
1879 { 0x06, 0x4e78 },
1880 { 0x06, 0x049e },
1881 { 0x06, 0x10e0 },
1882 { 0x06, 0x834e },
1883 { 0x06, 0x7803 },
1884 { 0x06, 0x9e0f },
1885 { 0x06, 0xe083 },
1886 { 0x06, 0x4e78 },
1887 { 0x06, 0x019e },
1888 { 0x06, 0x05ae },
1889 { 0x06, 0x0caf },
1890 { 0x06, 0x81f8 },
1891 { 0x06, 0xaf81 },
1892 { 0x06, 0xa3af },
1893 { 0x06, 0x81dc },
1894 { 0x06, 0xaf82 },
1895 { 0x06, 0x13ee },
1896 { 0x06, 0x8348 },
1897 { 0x06, 0x00ee },
1898 { 0x06, 0x8349 },
1899 { 0x06, 0x00e0 },
1900 { 0x06, 0x8351 },
1901 { 0x06, 0x10e4 },
1902 { 0x06, 0x8351 },
1903 { 0x06, 0x5801 },
1904 { 0x06, 0x9fea },
1905 { 0x06, 0xd000 },
1906 { 0x06, 0xd180 },
1907 { 0x06, 0x1f66 },
1908 { 0x06, 0xe2f8 },
1909 { 0x06, 0xeae3 },
1910 { 0x06, 0xf8eb },
1911 { 0x06, 0x5af8 },
1912 { 0x06, 0x1e20 },
1913 { 0x06, 0xe6f8 },
1914 { 0x06, 0xeae5 },
1915 { 0x06, 0xf8eb },
1916 { 0x06, 0xd302 },
1917 { 0x06, 0xb3fe },
1918 { 0x06, 0xe2f8 },
1919 { 0x06, 0x7cef },
1920 { 0x06, 0x325b },
1921 { 0x06, 0x80e3 },
1922 { 0x06, 0xf87d },
1923 { 0x06, 0x9e03 },
1924 { 0x06, 0x7dff },
1925 { 0x06, 0xff0d },
1926 { 0x06, 0x581c },
1927 { 0x06, 0x551a },
1928 { 0x06, 0x6511 },
1929 { 0x06, 0xa190 },
1930 { 0x06, 0xd3e2 },
1931 { 0x06, 0x8348 },
1932 { 0x06, 0xe383 },
1933 { 0x06, 0x491b },
1934 { 0x06, 0x56ab },
1935 { 0x06, 0x08ef },
1936 { 0x06, 0x56e6 },
1937 { 0x06, 0x8348 },
1938 { 0x06, 0xe783 },
1939 { 0x06, 0x4910 },
1940 { 0x06, 0xd180 },
1941 { 0x06, 0x1f66 },
1942 { 0x06, 0xa004 },
1943 { 0x06, 0xb9e2 },
1944 { 0x06, 0x8348 },
1945 { 0x06, 0xe383 },
1946 { 0x06, 0x49ef },
1947 { 0x06, 0x65e2 },
1948 { 0x06, 0x834a },
1949 { 0x06, 0xe383 },
1950 { 0x06, 0x4b1b },
1951 { 0x06, 0x56aa },
1952 { 0x06, 0x0eef },
1953 { 0x06, 0x56e6 },
1954 { 0x06, 0x834a },
1955 { 0x06, 0xe783 },
1956 { 0x06, 0x4be2 },
1957 { 0x06, 0x834d },
1958 { 0x06, 0xe683 },
1959 { 0x06, 0x4ce0 },
1960 { 0x06, 0x834d },
1961 { 0x06, 0xa000 },
1962 { 0x06, 0x0caf },
1963 { 0x06, 0x81dc },
1964 { 0x06, 0xe083 },
1965 { 0x06, 0x4d10 },
1966 { 0x06, 0xe483 },
1967 { 0x06, 0x4dae },
1968 { 0x06, 0x0480 },
1969 { 0x06, 0xe483 },
1970 { 0x06, 0x4de0 },
1971 { 0x06, 0x834e },
1972 { 0x06, 0x7803 },
1973 { 0x06, 0x9e0b },
1974 { 0x06, 0xe083 },
1975 { 0x06, 0x4e78 },
1976 { 0x06, 0x049e },
1977 { 0x06, 0x04ee },
1978 { 0x06, 0x834e },
1979 { 0x06, 0x02e0 },
1980 { 0x06, 0x8332 },
1981 { 0x06, 0xe183 },
1982 { 0x06, 0x3359 },
1983 { 0x06, 0x0fe2 },
1984 { 0x06, 0x834d },
1985 { 0x06, 0x0c24 },
1986 { 0x06, 0x5af0 },
1987 { 0x06, 0x1e12 },
1988 { 0x06, 0xe4f8 },
1989 { 0x06, 0x8ce5 },
1990 { 0x06, 0xf88d },
1991 { 0x06, 0xe083 },
1992 { 0x06, 0x30e1 },
1993 { 0x06, 0x8331 },
1994 { 0x06, 0x6801 },
1995 { 0x06, 0xe4f8 },
1996 { 0x06, 0x8ae5 },
1997 { 0x06, 0xf88b },
1998 { 0x06, 0xae37 },
1999 { 0x06, 0xee83 },
2000 { 0x06, 0x4e03 },
2001 { 0x06, 0xe083 },
2002 { 0x06, 0x4ce1 },
2003 { 0x06, 0x834d },
2004 { 0x06, 0x1b01 },
2005 { 0x06, 0x9e04 },
2006 { 0x06, 0xaaa1 },
2007 { 0x06, 0xaea8 },
2008 { 0x06, 0xee83 },
2009 { 0x06, 0x4e04 },
2010 { 0x06, 0xee83 },
2011 { 0x06, 0x4f00 },
2012 { 0x06, 0xaeab },
2013 { 0x06, 0xe083 },
2014 { 0x06, 0x4f78 },
2015 { 0x06, 0x039f },
2016 { 0x06, 0x14ee },
2017 { 0x06, 0x834e },
2018 { 0x06, 0x05d2 },
2019 { 0x06, 0x40d6 },
2020 { 0x06, 0x5554 },
2021 { 0x06, 0x0282 },
2022 { 0x06, 0x17d2 },
2023 { 0x06, 0xa0d6 },
2024 { 0x06, 0xba00 },
2025 { 0x06, 0x0282 },
2026 { 0x06, 0x17fe },
2027 { 0x06, 0xfdfc },
2028 { 0x06, 0x05f8 },
2029 { 0x06, 0xe0f8 },
2030 { 0x06, 0x60e1 },
2031 { 0x06, 0xf861 },
2032 { 0x06, 0x6802 },
2033 { 0x06, 0xe4f8 },
2034 { 0x06, 0x60e5 },
2035 { 0x06, 0xf861 },
2036 { 0x06, 0xe0f8 },
2037 { 0x06, 0x48e1 },
2038 { 0x06, 0xf849 },
2039 { 0x06, 0x580f },
2040 { 0x06, 0x1e02 },
2041 { 0x06, 0xe4f8 },
2042 { 0x06, 0x48e5 },
2043 { 0x06, 0xf849 },
2044 { 0x06, 0xd000 },
2045 { 0x06, 0x0282 },
2046 { 0x06, 0x5bbf },
2047 { 0x06, 0x8350 },
2048 { 0x06, 0xef46 },
2049 { 0x06, 0xdc19 },
2050 { 0x06, 0xddd0 },
2051 { 0x06, 0x0102 },
2052 { 0x06, 0x825b },
2053 { 0x06, 0x0282 },
2054 { 0x06, 0x77e0 },
2055 { 0x06, 0xf860 },
2056 { 0x06, 0xe1f8 },
2057 { 0x06, 0x6158 },
2058 { 0x06, 0xfde4 },
2059 { 0x06, 0xf860 },
2060 { 0x06, 0xe5f8 },
2061 { 0x06, 0x61fc },
2062 { 0x06, 0x04f9 },
2063 { 0x06, 0xfafb },
2064 { 0x06, 0xc6bf },
2065 { 0x06, 0xf840 },
2066 { 0x06, 0xbe83 },
2067 { 0x06, 0x50a0 },
2068 { 0x06, 0x0101 },
2069 { 0x06, 0x071b },
2070 { 0x06, 0x89cf },
2071 { 0x06, 0xd208 },
2072 { 0x06, 0xebdb },
2073 { 0x06, 0x19b2 },
2074 { 0x06, 0xfbff },
2075 { 0x06, 0xfefd },
2076 { 0x06, 0x04f8 },
2077 { 0x06, 0xe0f8 },
2078 { 0x06, 0x48e1 },
2079 { 0x06, 0xf849 },
2080 { 0x06, 0x6808 },
2081 { 0x06, 0xe4f8 },
2082 { 0x06, 0x48e5 },
2083 { 0x06, 0xf849 },
2084 { 0x06, 0x58f7 },
2085 { 0x06, 0xe4f8 },
2086 { 0x06, 0x48e5 },
2087 { 0x06, 0xf849 },
2088 { 0x06, 0xfc04 },
2089 { 0x06, 0x4d20 },
2090 { 0x06, 0x0002 },
2091 { 0x06, 0x4e22 },
2092 { 0x06, 0x0002 },
2093 { 0x06, 0x4ddf },
2094 { 0x06, 0xff01 },
2095 { 0x06, 0x4edd },
2096 { 0x06, 0xff01 },
2097 { 0x05, 0x83d4 },
2098 { 0x06, 0x8000 },
2099 { 0x05, 0x83d8 },
2100 { 0x06, 0x8051 },
2101 { 0x02, 0x6010 },
2102 { 0x03, 0xdc00 },
2103 { 0x05, 0xfff6 },
2104 { 0x06, 0x00fc },
2105 { 0x1f, 0x0000 },
2106 1831
2107 { 0x1f, 0x0000 }, 1832 { 0x1f, 0x0000 },
2108 { 0x0d, 0xf880 }, 1833 { 0x0d, 0xf880 }
2109 { 0x1f, 0x0000 }
2110 }; 1834 };
1835 void __iomem *ioaddr = tp->mmio_addr;
1836 const struct firmware *fw;
2111 1837
2112 rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); 1838 rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0));
2113 1839
1840 /*
1841 * Rx Error Issue
1842 * Fine Tune Switching regulator parameter
1843 */
2114 mdio_write(ioaddr, 0x1f, 0x0002); 1844 mdio_write(ioaddr, 0x1f, 0x0002);
2115 mdio_plus_minus(ioaddr, 0x0b, 0x0010, 0x00ef); 1845 mdio_plus_minus(ioaddr, 0x0b, 0x0010, 0x00ef);
2116 mdio_plus_minus(ioaddr, 0x0c, 0xa200, 0x5d00); 1846 mdio_plus_minus(ioaddr, 0x0c, 0xa200, 0x5d00);
2117 1847
2118 rtl_phy_write(ioaddr, phy_reg_init_1, ARRAY_SIZE(phy_reg_init_1));
2119
2120 if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { 1848 if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) {
2121 static const struct phy_reg phy_reg_init[] = { 1849 static const struct phy_reg phy_reg_init[] = {
2122 { 0x1f, 0x0002 }, 1850 { 0x1f, 0x0002 },
@@ -2157,20 +1885,33 @@ static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr)
2157 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1885 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init));
2158 } 1886 }
2159 1887
1888 /* RSET couple improve */
2160 mdio_write(ioaddr, 0x1f, 0x0002); 1889 mdio_write(ioaddr, 0x1f, 0x0002);
2161 mdio_patch(ioaddr, 0x0d, 0x0300); 1890 mdio_patch(ioaddr, 0x0d, 0x0300);
2162 mdio_patch(ioaddr, 0x0f, 0x0010); 1891 mdio_patch(ioaddr, 0x0f, 0x0010);
2163 1892
1893 /* Fine tune PLL performance */
2164 mdio_write(ioaddr, 0x1f, 0x0002); 1894 mdio_write(ioaddr, 0x1f, 0x0002);
2165 mdio_plus_minus(ioaddr, 0x02, 0x0100, 0x0600); 1895 mdio_plus_minus(ioaddr, 0x02, 0x0100, 0x0600);
2166 mdio_plus_minus(ioaddr, 0x03, 0x0000, 0xe000); 1896 mdio_plus_minus(ioaddr, 0x03, 0x0000, 0xe000);
2167 1897
2168 rtl_phy_write(ioaddr, phy_reg_init_2, ARRAY_SIZE(phy_reg_init_2)); 1898 mdio_write(ioaddr, 0x1f, 0x0005);
1899 mdio_write(ioaddr, 0x05, 0x001b);
1900 if (mdio_read(ioaddr, 0x06) == 0xbf00 &&
1901 request_firmware(&fw, FIRMWARE_8168D_1, &tp->pci_dev->dev) == 0) {
1902 rtl_phy_write_fw(tp, fw);
1903 release_firmware(fw);
1904 } else {
1905 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
1906 }
1907
1908 mdio_write(ioaddr, 0x1f, 0x0000);
2169} 1909}
2170 1910
2171static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr) 1911static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
2172{ 1912{
2173 static const struct phy_reg phy_reg_init_0[] = { 1913 static const struct phy_reg phy_reg_init_0[] = {
1914 /* Channel Estimation */
2174 { 0x1f, 0x0001 }, 1915 { 0x1f, 0x0001 },
2175 { 0x06, 0x4064 }, 1916 { 0x06, 0x4064 },
2176 { 0x07, 0x2863 }, 1917 { 0x07, 0x2863 },
@@ -2189,324 +1930,28 @@ static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr)
2189 { 0x1a, 0x05ad }, 1930 { 0x1a, 0x05ad },
2190 { 0x14, 0x94c0 }, 1931 { 0x14, 0x94c0 },
2191 1932
1933 /*
1934 * Tx Error Issue
1935 * enhance line driver power
1936 */
2192 { 0x1f, 0x0002 }, 1937 { 0x1f, 0x0002 },
2193 { 0x06, 0x5561 }, 1938 { 0x06, 0x5561 },
2194 { 0x1f, 0x0005 }, 1939 { 0x1f, 0x0005 },
2195 { 0x05, 0x8332 }, 1940 { 0x05, 0x8332 },
2196 { 0x06, 0x5561 } 1941 { 0x06, 0x5561 },
2197 }; 1942
2198 static const struct phy_reg phy_reg_init_1[] = { 1943 /*
2199 { 0x1f, 0x0005 }, 1944 * Can not link to 1Gbps with bad cable
2200 { 0x05, 0xffc2 }, 1945 * Decrease SNR threshold form 21.07dB to 19.04dB
2201 { 0x1f, 0x0005 }, 1946 */
2202 { 0x05, 0x8000 }, 1947 { 0x1f, 0x0001 },
2203 { 0x06, 0xf8f9 }, 1948 { 0x17, 0x0cc0 },
2204 { 0x06, 0xfaee },
2205 { 0x06, 0xf8ea },
2206 { 0x06, 0x00ee },
2207 { 0x06, 0xf8eb },
2208 { 0x06, 0x00e2 },
2209 { 0x06, 0xf87c },
2210 { 0x06, 0xe3f8 },
2211 { 0x06, 0x7da5 },
2212 { 0x06, 0x1111 },
2213 { 0x06, 0x12d2 },
2214 { 0x06, 0x40d6 },
2215 { 0x06, 0x4444 },
2216 { 0x06, 0x0281 },
2217 { 0x06, 0xc6d2 },
2218 { 0x06, 0xa0d6 },
2219 { 0x06, 0xaaaa },
2220 { 0x06, 0x0281 },
2221 { 0x06, 0xc6ae },
2222 { 0x06, 0x0fa5 },
2223 { 0x06, 0x4444 },
2224 { 0x06, 0x02ae },
2225 { 0x06, 0x4da5 },
2226 { 0x06, 0xaaaa },
2227 { 0x06, 0x02ae },
2228 { 0x06, 0x47af },
2229 { 0x06, 0x81c2 },
2230 { 0x06, 0xee83 },
2231 { 0x06, 0x4e00 },
2232 { 0x06, 0xee83 },
2233 { 0x06, 0x4d0f },
2234 { 0x06, 0xee83 },
2235 { 0x06, 0x4c0f },
2236 { 0x06, 0xee83 },
2237 { 0x06, 0x4f00 },
2238 { 0x06, 0xee83 },
2239 { 0x06, 0x5100 },
2240 { 0x06, 0xee83 },
2241 { 0x06, 0x4aff },
2242 { 0x06, 0xee83 },
2243 { 0x06, 0x4bff },
2244 { 0x06, 0xe083 },
2245 { 0x06, 0x30e1 },
2246 { 0x06, 0x8331 },
2247 { 0x06, 0x58fe },
2248 { 0x06, 0xe4f8 },
2249 { 0x06, 0x8ae5 },
2250 { 0x06, 0xf88b },
2251 { 0x06, 0xe083 },
2252 { 0x06, 0x32e1 },
2253 { 0x06, 0x8333 },
2254 { 0x06, 0x590f },
2255 { 0x06, 0xe283 },
2256 { 0x06, 0x4d0c },
2257 { 0x06, 0x245a },
2258 { 0x06, 0xf01e },
2259 { 0x06, 0x12e4 },
2260 { 0x06, 0xf88c },
2261 { 0x06, 0xe5f8 },
2262 { 0x06, 0x8daf },
2263 { 0x06, 0x81c2 },
2264 { 0x06, 0xe083 },
2265 { 0x06, 0x4f10 },
2266 { 0x06, 0xe483 },
2267 { 0x06, 0x4fe0 },
2268 { 0x06, 0x834e },
2269 { 0x06, 0x7800 },
2270 { 0x06, 0x9f0a },
2271 { 0x06, 0xe083 },
2272 { 0x06, 0x4fa0 },
2273 { 0x06, 0x10a5 },
2274 { 0x06, 0xee83 },
2275 { 0x06, 0x4e01 },
2276 { 0x06, 0xe083 },
2277 { 0x06, 0x4e78 },
2278 { 0x06, 0x059e },
2279 { 0x06, 0x9ae0 },
2280 { 0x06, 0x834e },
2281 { 0x06, 0x7804 },
2282 { 0x06, 0x9e10 },
2283 { 0x06, 0xe083 },
2284 { 0x06, 0x4e78 },
2285 { 0x06, 0x039e },
2286 { 0x06, 0x0fe0 },
2287 { 0x06, 0x834e },
2288 { 0x06, 0x7801 },
2289 { 0x06, 0x9e05 },
2290 { 0x06, 0xae0c },
2291 { 0x06, 0xaf81 },
2292 { 0x06, 0xa7af },
2293 { 0x06, 0x8152 },
2294 { 0x06, 0xaf81 },
2295 { 0x06, 0x8baf },
2296 { 0x06, 0x81c2 },
2297 { 0x06, 0xee83 },
2298 { 0x06, 0x4800 },
2299 { 0x06, 0xee83 },
2300 { 0x06, 0x4900 },
2301 { 0x06, 0xe083 },
2302 { 0x06, 0x5110 },
2303 { 0x06, 0xe483 },
2304 { 0x06, 0x5158 },
2305 { 0x06, 0x019f },
2306 { 0x06, 0xead0 },
2307 { 0x06, 0x00d1 },
2308 { 0x06, 0x801f },
2309 { 0x06, 0x66e2 },
2310 { 0x06, 0xf8ea },
2311 { 0x06, 0xe3f8 },
2312 { 0x06, 0xeb5a },
2313 { 0x06, 0xf81e },
2314 { 0x06, 0x20e6 },
2315 { 0x06, 0xf8ea },
2316 { 0x06, 0xe5f8 },
2317 { 0x06, 0xebd3 },
2318 { 0x06, 0x02b3 },
2319 { 0x06, 0xfee2 },
2320 { 0x06, 0xf87c },
2321 { 0x06, 0xef32 },
2322 { 0x06, 0x5b80 },
2323 { 0x06, 0xe3f8 },
2324 { 0x06, 0x7d9e },
2325 { 0x06, 0x037d },
2326 { 0x06, 0xffff },
2327 { 0x06, 0x0d58 },
2328 { 0x06, 0x1c55 },
2329 { 0x06, 0x1a65 },
2330 { 0x06, 0x11a1 },
2331 { 0x06, 0x90d3 },
2332 { 0x06, 0xe283 },
2333 { 0x06, 0x48e3 },
2334 { 0x06, 0x8349 },
2335 { 0x06, 0x1b56 },
2336 { 0x06, 0xab08 },
2337 { 0x06, 0xef56 },
2338 { 0x06, 0xe683 },
2339 { 0x06, 0x48e7 },
2340 { 0x06, 0x8349 },
2341 { 0x06, 0x10d1 },
2342 { 0x06, 0x801f },
2343 { 0x06, 0x66a0 },
2344 { 0x06, 0x04b9 },
2345 { 0x06, 0xe283 },
2346 { 0x06, 0x48e3 },
2347 { 0x06, 0x8349 },
2348 { 0x06, 0xef65 },
2349 { 0x06, 0xe283 },
2350 { 0x06, 0x4ae3 },
2351 { 0x06, 0x834b },
2352 { 0x06, 0x1b56 },
2353 { 0x06, 0xaa0e },
2354 { 0x06, 0xef56 },
2355 { 0x06, 0xe683 },
2356 { 0x06, 0x4ae7 },
2357 { 0x06, 0x834b },
2358 { 0x06, 0xe283 },
2359 { 0x06, 0x4de6 },
2360 { 0x06, 0x834c },
2361 { 0x06, 0xe083 },
2362 { 0x06, 0x4da0 },
2363 { 0x06, 0x000c },
2364 { 0x06, 0xaf81 },
2365 { 0x06, 0x8be0 },
2366 { 0x06, 0x834d },
2367 { 0x06, 0x10e4 },
2368 { 0x06, 0x834d },
2369 { 0x06, 0xae04 },
2370 { 0x06, 0x80e4 },
2371 { 0x06, 0x834d },
2372 { 0x06, 0xe083 },
2373 { 0x06, 0x4e78 },
2374 { 0x06, 0x039e },
2375 { 0x06, 0x0be0 },
2376 { 0x06, 0x834e },
2377 { 0x06, 0x7804 },
2378 { 0x06, 0x9e04 },
2379 { 0x06, 0xee83 },
2380 { 0x06, 0x4e02 },
2381 { 0x06, 0xe083 },
2382 { 0x06, 0x32e1 },
2383 { 0x06, 0x8333 },
2384 { 0x06, 0x590f },
2385 { 0x06, 0xe283 },
2386 { 0x06, 0x4d0c },
2387 { 0x06, 0x245a },
2388 { 0x06, 0xf01e },
2389 { 0x06, 0x12e4 },
2390 { 0x06, 0xf88c },
2391 { 0x06, 0xe5f8 },
2392 { 0x06, 0x8de0 },
2393 { 0x06, 0x8330 },
2394 { 0x06, 0xe183 },
2395 { 0x06, 0x3168 },
2396 { 0x06, 0x01e4 },
2397 { 0x06, 0xf88a },
2398 { 0x06, 0xe5f8 },
2399 { 0x06, 0x8bae },
2400 { 0x06, 0x37ee },
2401 { 0x06, 0x834e },
2402 { 0x06, 0x03e0 },
2403 { 0x06, 0x834c },
2404 { 0x06, 0xe183 },
2405 { 0x06, 0x4d1b },
2406 { 0x06, 0x019e },
2407 { 0x06, 0x04aa },
2408 { 0x06, 0xa1ae },
2409 { 0x06, 0xa8ee },
2410 { 0x06, 0x834e },
2411 { 0x06, 0x04ee },
2412 { 0x06, 0x834f },
2413 { 0x06, 0x00ae },
2414 { 0x06, 0xabe0 },
2415 { 0x06, 0x834f },
2416 { 0x06, 0x7803 },
2417 { 0x06, 0x9f14 },
2418 { 0x06, 0xee83 },
2419 { 0x06, 0x4e05 },
2420 { 0x06, 0xd240 },
2421 { 0x06, 0xd655 },
2422 { 0x06, 0x5402 },
2423 { 0x06, 0x81c6 },
2424 { 0x06, 0xd2a0 },
2425 { 0x06, 0xd6ba },
2426 { 0x06, 0x0002 },
2427 { 0x06, 0x81c6 },
2428 { 0x06, 0xfefd },
2429 { 0x06, 0xfc05 },
2430 { 0x06, 0xf8e0 },
2431 { 0x06, 0xf860 },
2432 { 0x06, 0xe1f8 },
2433 { 0x06, 0x6168 },
2434 { 0x06, 0x02e4 },
2435 { 0x06, 0xf860 },
2436 { 0x06, 0xe5f8 },
2437 { 0x06, 0x61e0 },
2438 { 0x06, 0xf848 },
2439 { 0x06, 0xe1f8 },
2440 { 0x06, 0x4958 },
2441 { 0x06, 0x0f1e },
2442 { 0x06, 0x02e4 },
2443 { 0x06, 0xf848 },
2444 { 0x06, 0xe5f8 },
2445 { 0x06, 0x49d0 },
2446 { 0x06, 0x0002 },
2447 { 0x06, 0x820a },
2448 { 0x06, 0xbf83 },
2449 { 0x06, 0x50ef },
2450 { 0x06, 0x46dc },
2451 { 0x06, 0x19dd },
2452 { 0x06, 0xd001 },
2453 { 0x06, 0x0282 },
2454 { 0x06, 0x0a02 },
2455 { 0x06, 0x8226 },
2456 { 0x06, 0xe0f8 },
2457 { 0x06, 0x60e1 },
2458 { 0x06, 0xf861 },
2459 { 0x06, 0x58fd },
2460 { 0x06, 0xe4f8 },
2461 { 0x06, 0x60e5 },
2462 { 0x06, 0xf861 },
2463 { 0x06, 0xfc04 },
2464 { 0x06, 0xf9fa },
2465 { 0x06, 0xfbc6 },
2466 { 0x06, 0xbff8 },
2467 { 0x06, 0x40be },
2468 { 0x06, 0x8350 },
2469 { 0x06, 0xa001 },
2470 { 0x06, 0x0107 },
2471 { 0x06, 0x1b89 },
2472 { 0x06, 0xcfd2 },
2473 { 0x06, 0x08eb },
2474 { 0x06, 0xdb19 },
2475 { 0x06, 0xb2fb },
2476 { 0x06, 0xfffe },
2477 { 0x06, 0xfd04 },
2478 { 0x06, 0xf8e0 },
2479 { 0x06, 0xf848 },
2480 { 0x06, 0xe1f8 },
2481 { 0x06, 0x4968 },
2482 { 0x06, 0x08e4 },
2483 { 0x06, 0xf848 },
2484 { 0x06, 0xe5f8 },
2485 { 0x06, 0x4958 },
2486 { 0x06, 0xf7e4 },
2487 { 0x06, 0xf848 },
2488 { 0x06, 0xe5f8 },
2489 { 0x06, 0x49fc },
2490 { 0x06, 0x044d },
2491 { 0x06, 0x2000 },
2492 { 0x06, 0x024e },
2493 { 0x06, 0x2200 },
2494 { 0x06, 0x024d },
2495 { 0x06, 0xdfff },
2496 { 0x06, 0x014e },
2497 { 0x06, 0xddff },
2498 { 0x06, 0x0100 },
2499 { 0x05, 0x83d8 },
2500 { 0x06, 0x8000 },
2501 { 0x03, 0xdc00 },
2502 { 0x05, 0xfff6 },
2503 { 0x06, 0x00fc },
2504 { 0x1f, 0x0000 },
2505 1949
2506 { 0x1f, 0x0000 }, 1950 { 0x1f, 0x0000 },
2507 { 0x0d, 0xf880 }, 1951 { 0x0d, 0xf880 }
2508 { 0x1f, 0x0000 }
2509 }; 1952 };
1953 void __iomem *ioaddr = tp->mmio_addr;
1954 const struct firmware *fw;
2510 1955
2511 rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); 1956 rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0));
2512 1957
@@ -2550,17 +1995,26 @@ static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr)
2550 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1995 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init));
2551 } 1996 }
2552 1997
1998 /* Fine tune PLL performance */
2553 mdio_write(ioaddr, 0x1f, 0x0002); 1999 mdio_write(ioaddr, 0x1f, 0x0002);
2554 mdio_plus_minus(ioaddr, 0x02, 0x0100, 0x0600); 2000 mdio_plus_minus(ioaddr, 0x02, 0x0100, 0x0600);
2555 mdio_plus_minus(ioaddr, 0x03, 0x0000, 0xe000); 2001 mdio_plus_minus(ioaddr, 0x03, 0x0000, 0xe000);
2556 2002
2557 mdio_write(ioaddr, 0x1f, 0x0001); 2003 /* Switching regulator Slew rate */
2558 mdio_write(ioaddr, 0x17, 0x0cc0);
2559
2560 mdio_write(ioaddr, 0x1f, 0x0002); 2004 mdio_write(ioaddr, 0x1f, 0x0002);
2561 mdio_patch(ioaddr, 0x0f, 0x0017); 2005 mdio_patch(ioaddr, 0x0f, 0x0017);
2562 2006
2563 rtl_phy_write(ioaddr, phy_reg_init_1, ARRAY_SIZE(phy_reg_init_1)); 2007 mdio_write(ioaddr, 0x1f, 0x0005);
2008 mdio_write(ioaddr, 0x05, 0x001b);
2009 if (mdio_read(ioaddr, 0x06) == 0xb300 &&
2010 request_firmware(&fw, FIRMWARE_8168D_2, &tp->pci_dev->dev) == 0) {
2011 rtl_phy_write_fw(tp, fw);
2012 release_firmware(fw);
2013 } else {
2014 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
2015 }
2016
2017 mdio_write(ioaddr, 0x1f, 0x0000);
2564} 2018}
2565 2019
2566static void rtl8168d_3_hw_phy_config(void __iomem *ioaddr) 2020static void rtl8168d_3_hw_phy_config(void __iomem *ioaddr)
@@ -2698,10 +2152,10 @@ static void rtl_hw_phy_config(struct net_device *dev)
2698 rtl8168cp_2_hw_phy_config(ioaddr); 2152 rtl8168cp_2_hw_phy_config(ioaddr);
2699 break; 2153 break;
2700 case RTL_GIGA_MAC_VER_25: 2154 case RTL_GIGA_MAC_VER_25:
2701 rtl8168d_1_hw_phy_config(ioaddr); 2155 rtl8168d_1_hw_phy_config(tp);
2702 break; 2156 break;
2703 case RTL_GIGA_MAC_VER_26: 2157 case RTL_GIGA_MAC_VER_26:
2704 rtl8168d_2_hw_phy_config(ioaddr); 2158 rtl8168d_2_hw_phy_config(tp);
2705 break; 2159 break;
2706 case RTL_GIGA_MAC_VER_27: 2160 case RTL_GIGA_MAC_VER_27:
2707 rtl8168d_3_hw_phy_config(ioaddr); 2161 rtl8168d_3_hw_phy_config(ioaddr);