Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

r8168-ck
Saturday, April 14th, 2012 at 10:39:59pm MDT 

  1. /*
  2. ################################################################################
  3. #
  4. # r8168 is the Linux device driver released for RealTek RTL8168B/8111B,
  5. # RTL8168C/8111C, RTL8168CP/8111CP, RTL8168D/8111D, RTL8168DP/8111DP, and
  6. # RTL8168E/8111E Gigabit Ethernet controllers with PCI-Express interface.
  7. #
  8. # Copyright(c) 2012 Realtek Semiconductor Corp. All rights reserved.
  9. #
  10. # This program is free software; you can redistribute it and/or modify it
  11. # under the terms of the GNU General Public License as published by the Free
  12. # Software Foundation; either version 2 of the License, or (at your option)
  13. # any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful, but WITHOUT
  16. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  17. # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  18. # more details.
  19. #
  20. # You should have received a copy of the GNU General Public License along with
  21. # this program; if not, see <http://www.gnu.org/licenses/>.
  22. #
  23. # Author:
  24. # Realtek NIC software team <nicfae@realtek.com>
  25. # No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan
  26. #
  27. ################################################################################
  28. */
  29.  
  30. /*
  31.  *  This product is covered by one or more of the following patents:
  32.  *  US5,307,459, US5,434,872, US5,732,094, US6,570,884, US6,115,776, and US6,327,625.
  33.  */
  34.  
  35. /*
  36.  * This driver is modified from r8169.c in Linux kernel 2.6.18
  37.  */
  38.  
  39. #include <linux/module.h>
  40. #include <linux/version.h>
  41. #include <linux/pci.h>
  42. #include <linux/netdevice.h>
  43. #include <linux/etherdevice.h>
  44. #include <linux/delay.h>
  45. #include <linux/ethtool.h>
  46. #include <linux/mii.h>
  47. #include <linux/if_vlan.h>
  48. #include <linux/crc32.h>
  49. #include <linux/interrupt.h>
  50. #include <linux/in.h>
  51. #include <linux/ip.h>
  52. #include <linux/tcp.h>
  53. #include <linux/init.h>
  54. #include <linux/rtnetlink.h>
  55.  
  56. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
  57. #define dev_printk(A,B,fmt,args...)        printk(A fmt,##args)
  58. #else
  59. #include <linux/dma-mapping.h>
  60. #include <linux/moduleparam.h>
  61. #endif
  62.  
  63. #include <asm/io.h>
  64. #include <asm/irq.h>
  65. #include <asm/uaccess.h>
  66.  
  67. #include "r8168.h"
  68. #include "r8168_asf.h"
  69. #include "rtl_eeprom.h"
  70. #include "rtltool.h"
  71.  
  72. static int eee_enable = 0 ;
  73. module_param(eee_enable, int, S_IRUGO);
  74.  
  75. #ifdef CONFIG_DOWN_SPEED_100
  76. static int config_down_speed_100 = 1;
  77. #else
  78. static int config_down_speed_100 = 0;
  79. #endif
  80.  
  81. /* Maximum events (Rx packets, etc.) to handle at each interrupt. */
  82. static const int max_interrupt_work = 20;
  83.  
  84. /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
  85.    The RTL chips use a 64 element hash table based on the Ethernet CRC. */
  86. static const int multicast_filter_limit = 32;
  87.  
  88. #define _R(NAME,MAC,RCR,MASK, JumFrameSz) \
  89.         { .name = NAME, .mcfg = MAC, .RCR_Cfg = RCR, .RxConfigMask = MASK, .jumbo_frame_sz
  90. = JumFrameSz }
  91.  
  92. static const struct {
  93.         const char *name;
  94.         u8 mcfg;
  95.         u32 RCR_Cfg;
  96.         u32 RxConfigMask;        /* Clears the bits supported by this chip */
  97.         u32 jumbo_frame_sz;
  98. } rtl_chip_info[] = {
  99.         _R("RTL8168B/8111B",
  100.            CFG_METHOD_1,
  101.            (Reserved2_data << Reserved2_shift) | (RX_DMA_BURST << RxCfgDMAShift),
  102.            0xff7e1880,
  103.            Jumbo_Frame_4k),
  104.  
  105.         _R("RTL8168B/8111B",
  106.            CFG_METHOD_2,
  107.            (Reserved2_data << Reserved2_shift) | (RX_DMA_BURST << RxCfgDMAShift),
  108.            0xff7e1880,
  109.            Jumbo_Frame_4k),
  110.  
  111.         _R("RTL8168B/8111B",
  112.            CFG_METHOD_3,
  113.            (Reserved2_data << Reserved2_shift) | (RX_DMA_BURST << RxCfgDMAShift),
  114.            0xff7e1880,
  115.            Jumbo_Frame_4k),
  116.  
  117.         _R("RTL8168C/8111C",
  118.            CFG_METHOD_4, RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST <<
  119. RxCfgDMAShift),
  120.            0xff7e1880,
  121.            Jumbo_Frame_6k),
  122.  
  123.         _R("RTL8168C/8111C",
  124.            CFG_METHOD_5,
  125.            RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST << RxCfgDMAShift),
  126.            0xff7e1880,
  127.            Jumbo_Frame_6k),
  128.  
  129.         _R("RTL8168C/8111C",
  130.            CFG_METHOD_6,
  131.            RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST << RxCfgDMAShift),
  132.            0xff7e1880,
  133.            Jumbo_Frame_6k),
  134.  
  135.         _R("RTL8168CP/8111CP",
  136.            CFG_METHOD_7,
  137.            RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST << RxCfgDMAShift),
  138.            0xff7e1880,
  139.            Jumbo_Frame_6k),
  140.  
  141.         _R("RTL8168CP/8111CP",
  142.            CFG_METHOD_8,
  143.            RxCfg_128_int_en | RxCfg_fet_multi_en | (RX_DMA_BURST << RxCfgDMAShift),
  144.            0xff7e1880,
  145.            Jumbo_Frame_6k),
  146.  
  147.         _R("RTL8168D/8111D",
  148.            CFG_METHOD_9,
  149.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  150.            0xff7e1880,
  151.            Jumbo_Frame_9k),
  152.  
  153.         _R("RTL8168D/8111D",
  154.            CFG_METHOD_10,
  155.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  156.            0xff7e1880,
  157.            Jumbo_Frame_9k),
  158.  
  159.         _R("RTL8168DP/8111DP",
  160.            CFG_METHOD_11,
  161.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  162.            0xff7e1880,
  163.            Jumbo_Frame_9k),
  164.  
  165.         _R("RTL8168DP/8111DP",
  166.            CFG_METHOD_12,
  167.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  168.            0xff7e1880,
  169.            Jumbo_Frame_9k),
  170.  
  171.         _R("RTL8168DP/8111DP",
  172.            CFG_METHOD_13,
  173.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  174.            0xff7e1880,
  175.            Jumbo_Frame_9k),
  176.  
  177.         _R("RTL8168E/8111E",
  178.            CFG_METHOD_14,
  179.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  180.            0xff7e1880,
  181.            Jumbo_Frame_9k),
  182.  
  183.         _R("RTL8168E/8111E",
  184.            CFG_METHOD_15,
  185.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  186.            0xff7e1880,
  187.            Jumbo_Frame_9k),
  188.  
  189.         _R("RTL8168E-VL/8111E-VL",
  190.            CFG_METHOD_16,
  191.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  192.            0xff7e0080,
  193.            Jumbo_Frame_9k),
  194.  
  195.         _R("RTL8168E-VL/8111E-VL",
  196.            CFG_METHOD_17,
  197.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  198.            0xff7e1880,
  199.            Jumbo_Frame_9k),
  200.  
  201.         _R("RTL8168F/8111F",
  202.            CFG_METHOD_18,
  203.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  204.            0xff7e1880,
  205.            Jumbo_Frame_9k),
  206.  
  207.         _R("RTL8168F/8111F",
  208.            CFG_METHOD_19,
  209.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  210.            0xff7e1880,
  211.            Jumbo_Frame_9k),
  212.  
  213.         _R("RTL8411",
  214.            CFG_METHOD_20,
  215.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  216.            0xff7e1880,
  217.            Jumbo_Frame_9k),
  218.  
  219.         _R("Unknown",
  220.            CFG_METHOD_DEFAULT,
  221.            RxCfg_128_int_en | (RX_DMA_BURST << RxCfgDMAShift),
  222.            0xff7e1880,
  223.            RX_BUF_SIZE)
  224. };
  225. #undef _R
  226.  
  227. #ifndef PCI_VENDOR_ID_DLINK
  228. #define PCI_VENDOR_ID_DLINK        0x1186
  229. #endif
  230.  
  231. static struct pci_device_id rtl8168_pci_tbl[] = {
  232.         { PCI_DEVICE(PCI_VENDOR_ID_REALTEK,        0x8168), },
  233.         { PCI_VENDOR_ID_DLINK, 0x4300, 0x1186, 0x4b10,},
  234.         {0,},
  235. };
  236.  
  237. MODULE_DEVICE_TABLE(pci, rtl8168_pci_tbl);
  238.  
  239. static int rx_copybreak = 200;
  240. static int use_dac;
  241. static struct {
  242.         u32 msg_enable;
  243. } debug = { -1 };
  244.  
  245. /* media options */
  246. #define MAX_UNITS 8
  247. static int speed[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
  248. static int duplex[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
  249. static int autoneg[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
  250.  
  251. MODULE_AUTHOR("Realtek and the Linux r8168 crew <netdev@vger.kernel.org>");
  252. MODULE_DESCRIPTION("RealTek RTL-8168 Gigabit Ethernet driver");
  253.  
  254. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
  255. MODULE_PARM(speed, "1-" __MODULE_STRING(MAX_UNITS) "i");
  256. MODULE_PARM(duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
  257. MODULE_PARM(autoneg, "1-" __MODULE_STRING(MAX_UNITS) "i");
  258. #else
  259. static int num_speed = 0;
  260. static int num_duplex = 0;
  261. static int num_autoneg = 0;
  262.  
  263. module_param_array(speed, int, &num_speed, 0);
  264. module_param_array(duplex, int, &num_duplex, 0);
  265. module_param_array(autoneg, int, &num_autoneg, 0);
  266. #endif
  267.  
  268. MODULE_PARM_DESC(speed, "force phy operation. Deprecated by ethtool (8).");
  269. MODULE_PARM_DESC(duplex, "force phy operation. Deprecated by ethtool (8).");
  270. MODULE_PARM_DESC(autoneg, "force phy operation. Deprecated by ethtool (8).");
  271.  
  272. module_param(rx_copybreak, int, 0);
  273. MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames");
  274. module_param(use_dac, int, 0);
  275. MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot.");
  276.  
  277. #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
  278. module_param_named(debug, debug.msg_enable, int, 0);
  279. MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
  280. #endif//LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
  281.  
  282. MODULE_LICENSE("GPL");
  283.  
  284. MODULE_VERSION(RTL8168_VERSION);
  285.  
  286. static void rtl8168_sleep_rx_enable(struct net_device *dev);
  287. static void rtl8168_dsm(struct net_device *dev, int dev_state);
  288.  
  289. static void rtl8168_esd_timer(unsigned long __opaque);
  290. static void rtl8168_link_timer(unsigned long __opaque);
  291. static void rtl8168_tx_clear(struct rtl8168_private *tp);
  292. static void rtl8168_rx_clear(struct rtl8168_private *tp);
  293.  
  294. static int rtl8168_open(struct net_device *dev);
  295. static int rtl8168_start_xmit(struct sk_buff *skb, struct net_device *dev);
  296. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
  297. static irqreturn_t rtl8168_interrupt(int irq, void *dev_instance, struct pt_regs
  298. *regs);
  299. #else
  300. static irqreturn_t rtl8168_interrupt(int irq, void *dev_instance);
  301. #endif
  302. static void rtl8168_rx_desc_offset0_init(struct rtl8168_private *, int);
  303. static int rtl8168_init_ring(struct net_device *dev);
  304. static void rtl8168_hw_start(struct net_device *dev);
  305. static int rtl8168_close(struct net_device *dev);
  306. static void rtl8168_set_rx_mode(struct net_device *dev);
  307. static void rtl8168_tx_timeout(struct net_device *dev);
  308. static struct net_device_stats *rtl8168_get_stats(struct net_device *dev);
  309. static int rtl8168_rx_interrupt(struct net_device *, struct rtl8168_private *, void
  310. __iomem *, u32 budget);
  311. static int rtl8168_change_mtu(struct net_device *dev, int new_mtu);
  312. static void rtl8168_down(struct net_device *dev);
  313.  
  314. static int rtl8168_set_mac_address(struct net_device *dev, void *p);
  315. void rtl8168_rar_set(struct rtl8168_private *tp, uint8_t *addr);
  316. static void rtl8168_tx_desc_init(struct rtl8168_private *tp);
  317. static void rtl8168_rx_desc_init(struct rtl8168_private *tp);
  318.  
  319. static void rtl8168_nic_reset(struct net_device *dev);
  320.  
  321. static void rtl8168_phy_power_up (struct net_device *dev);
  322. static void rtl8168_phy_power_down (struct net_device *dev);
  323. static int rtl8168_set_speed(struct net_device *dev, u8 autoneg,  u16 speed, u8
  324. duplex);
  325.  
  326. #ifdef CONFIG_R8168_NAPI
  327. static int rtl8168_poll(napi_ptr napi, napi_budget budget);
  328. #endif
  329.  
  330. static u16 rtl8168_intr_mask = SYSErr | LinkChg | RxDescUnavail | TxErr | TxOK |
  331. RxErr | RxOK;
  332. static const u16 rtl8168_napi_event =
  333.         RxOK | RxDescUnavail | RxFIFOOver | TxOK | TxErr;
  334.  
  335. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
  336. #undef ethtool_ops
  337. #define ethtool_ops _kc_ethtool_ops
  338.  
  339. struct _kc_ethtool_ops {
  340.         int  (*get_settings)(struct net_device *, struct ethtool_cmd *);
  341.         int  (*set_settings)(struct net_device *, struct ethtool_cmd *);
  342.         void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
  343.         int  (*get_regs_len)(struct net_device *);
  344.         void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
  345.         void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
  346.         int  (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
  347.         u32  (*get_msglevel)(struct net_device *);
  348.         void (*set_msglevel)(struct net_device *, u32);
  349.         int  (*nway_reset)(struct net_device *);
  350.         u32  (*get_link)(struct net_device *);
  351.         int  (*get_eeprom_len)(struct net_device *);
  352.         int  (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
  353.         int  (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
  354.         int  (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
  355.         int  (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
  356.         void (*get_ringparam)(struct net_device *, struct ethtool_ringparam *);
  357.         int  (*set_ringparam)(struct net_device *, struct ethtool_ringparam *);
  358.         void (*get_pauseparam)(struct net_device *,
  359.                                struct ethtool_pauseparam*);
  360.         int  (*set_pauseparam)(struct net_device *,
  361.                                struct ethtool_pauseparam*);
  362.         u32  (*get_rx_csum)(struct net_device *);
  363.         int  (*set_rx_csum)(struct net_device *, u32);
  364.         u32  (*get_tx_csum)(struct net_device *);
  365.         int  (*set_tx_csum)(struct net_device *, u32);
  366.         u32  (*get_sg)(struct net_device *);
  367.         int  (*set_sg)(struct net_device *, u32);
  368.         u32  (*get_tso)(struct net_device *);
  369.         int  (*set_tso)(struct net_device *, u32);
  370.         int  (*self_test_count)(struct net_device *);
  371.         void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
  372.         void (*get_strings)(struct net_device *, u32 stringset, u8 *);
  373.         int  (*phys_id)(struct net_device *, u32);
  374.         int  (*get_stats_count)(struct net_device *);
  375.         void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *,
  376.                                   u64 *);
  377. } *ethtool_ops = NULL;
  378.  
  379. #undef SET_ETHTOOL_OPS
  380. #define SET_ETHTOOL_OPS(netdev, ops) (ethtool_ops = (ops))
  381.  
  382. #endif //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
  383.  
  384.  
  385. //#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
  386. #ifndef netif_msg_init
  387. #define netif_msg_init _kc_netif_msg_init
  388. /* copied from linux kernel 2.6.20 include/linux/netdevice.h */
  389. static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
  390. {
  391.         /* use default */
  392.         if (debug_value < 0 || debug_value >= (sizeof(u32) * 8))
  393.                 return default_msg_enable_bits;
  394.         if (debug_value == 0)        /* no output */
  395.                 return 0;
  396.         /* set low N bits */
  397.         return (1 << debug_value) - 1;
  398. }
  399.  
  400. #endif //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
  401.  
  402. #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)
  403. static inline void eth_copy_and_sum (struct sk_buff *dest,
  404.                                      const unsigned char *src,
  405.                                      int len, int base)
  406. {
  407.         memcpy (dest->data, src, len);
  408. }
  409. #endif //LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)
  410.  
  411. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
  412. /* copied from linux kernel 2.6.20 /include/linux/time.h */
  413. /* Parameters used to convert the timespec values: */
  414. #define MSEC_PER_SEC        1000L
  415.  
  416. /* copied from linux kernel 2.6.20 /include/linux/jiffies.h */
  417. /*
  418.  * Change timeval to jiffies, trying to avoid the
  419.  * most obvious overflows..
  420.  *
  421.  * And some not so obvious.
  422.  *
  423.  * Note that we don't want to return MAX_LONG, because
  424.  * for various timeout reasons we often end up having
  425.  * to wait "jiffies+1" in order to guarantee that we wait
  426.  * at _least_ "jiffies" - so "jiffies+1" had better still
  427.  * be positive.
  428.  */
  429. #define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
  430.  
  431. /*
  432.  * Convert jiffies to milliseconds and back.
  433.  *
  434.  * Avoid unnecessary multiplications/divisions in the
  435.  * two most common HZ cases:
  436.  */
  437. static inline unsigned int _kc_jiffies_to_msecs(const unsigned long j)
  438. {
  439. #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
  440.         return (MSEC_PER_SEC / HZ) * j;
  441. #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
  442.         return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
  443. #else
  444.         return (j * MSEC_PER_SEC) / HZ;
  445. #endif
  446. }
  447.  
  448. static inline unsigned long _kc_msecs_to_jiffies(const unsigned int m)
  449. {
  450.         if (m > _kc_jiffies_to_msecs(MAX_JIFFY_OFFSET))
  451.                 return MAX_JIFFY_OFFSET;
  452. #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
  453.         return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
  454. #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
  455.         return m * (HZ / MSEC_PER_SEC);
  456. #else
  457.         return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC;
  458. #endif
  459. }
  460. #endif        //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
  461.  
  462.  
  463. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
  464.  
  465. /* copied from linux kernel 2.6.12.6 /include/linux/pm.h */
  466. typedef int __bitwise pci_power_t;
  467.  
  468. /* copied from linux kernel 2.6.12.6 /include/linux/pci.h */
  469. typedef u32 __bitwise pm_message_t;
  470.  
  471. #define PCI_D0        ((pci_power_t __force) 0)
  472. #define PCI_D1        ((pci_power_t __force) 1)
  473. #define PCI_D2        ((pci_power_t __force) 2)
  474. #define PCI_D3hot        ((pci_power_t __force) 3)
  475. #define PCI_D3cold        ((pci_power_t __force) 4)
  476. #define PCI_POWER_ERROR        ((pci_power_t __force) -1)
  477.  
  478. /* copied from linux kernel 2.6.12.6 /drivers/pci/pci.c */
  479. /**
  480.  * pci_choose_state - Choose the power state of a PCI device
  481.  * @dev: PCI device to be suspended
  482.  * @state: target sleep state for the whole system. This is the value
  483.  *        that is passed to suspend() function.
  484.  *
  485.  * Returns PCI power state suitable for given device and given system
  486.  * message.
  487.  */
  488.  
  489. pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
  490. {
  491.         if (!pci_find_capability(dev, PCI_CAP_ID_PM))
  492.                 return PCI_D0;
  493.  
  494.         switch (state) {
  495.         case 0: return PCI_D0;
  496.         case 3: return PCI_D3hot;
  497.         default:
  498.                 printk("They asked me for state %d\n", state);
  499. //                BUG();
  500.         }
  501.         return PCI_D0;
  502. }
  503. #endif        //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
  504.  
  505. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
  506. /**
  507.  * msleep_interruptible - sleep waiting for waitqueue interruptions
  508.  * @msecs: Time in milliseconds to sleep for
  509.  */
  510. #define msleep_interruptible _kc_msleep_interruptible
  511. unsigned long _kc_msleep_interruptible(unsigned int msecs)
  512. {
  513.         unsigned long timeout = _kc_msecs_to_jiffies(msecs);
  514.  
  515.         while (timeout && !signal_pending(current)) {
  516.                 set_current_state(TASK_INTERRUPTIBLE);
  517.                 timeout = schedule_timeout(timeout);
  518.         }
  519.         return _kc_jiffies_to_msecs(timeout);
  520. }
  521. #endif        //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
  522.  
  523. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
  524. /* copied from linux kernel 2.6.20 include/linux/sched.h */
  525. #ifndef __sched
  526. #define __sched                __attribute__((__section__(".sched.text")))
  527. #endif
  528.  
  529. /* copied from linux kernel 2.6.20 kernel/timer.c */
  530. signed long __sched schedule_timeout_uninterruptible(signed long timeout)
  531. {
  532.         __set_current_state(TASK_UNINTERRUPTIBLE);
  533.         return schedule_timeout(timeout);
  534. }
  535.  
  536. /* copied from linux kernel 2.6.20 include/linux/mii.h */
  537. #undef if_mii
  538. #define if_mii _kc_if_mii
  539. static inline struct mii_ioctl_data *if_mii(struct ifreq *rq)
  540. {
  541.         return (struct mii_ioctl_data *) &rq->ifr_ifru;
  542. }
  543. #endif        //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
  544.  
  545. void mdio_write(struct rtl8168_private *tp,
  546.            u32 RegAddr,
  547.            u32 value)
  548. {
  549.         void __iomem *ioaddr = tp->mmio_addr;
  550.         int i;
  551.  
  552.         if (tp->mcfg==CFG_METHOD_11)
  553.         {
  554.                 RTL_W32(OCPDR, OCPDR_Write |
  555.                         (RegAddr & OCPDR_Reg_Mask) << OCPDR_GPHY_Reg_shift |
  556.                         (value & OCPDR_Data_Mask));
  557.                 RTL_W32(OCPAR, OCPAR_GPHY_Write);
  558.                 RTL_W32(EPHY_RXER_NUM, 0);
  559.  
  560.                 for (i = 0; i < 100; i++)
  561.                 {
  562.                         mdelay(1);
  563.                         if (!(RTL_R32(OCPAR) & OCPAR_Flag))
  564.                                 break;
  565.                 }
  566.         }
  567.         else
  568.         {
  569.                 if (tp->mcfg == CFG_METHOD_12 || tp->mcfg == CFG_METHOD_13)
  570.                         RTL_W32(0xD0, RTL_R32(0xD0) & ~0x00020000);
  571.  
  572.                 RTL_W32(PHYAR, PHYAR_Write |
  573.                         (RegAddr & PHYAR_Reg_Mask) << PHYAR_Reg_shift |
  574.                         (value & PHYAR_Data_Mask));
  575.  
  576.                 for (i = 0; i < 10; i++) {
  577.                         udelay(100);
  578.  
  579.                         /* Check if the RTL8168 has completed writing to the specified MII register */
  580.                         if (!(RTL_R32(PHYAR) & PHYAR_Flag))
  581.                         {
  582.                                 udelay(20);
  583.                                 break;
  584.                         }
  585.                 }
  586.  
  587.                 if (tp->mcfg == CFG_METHOD_12 || tp->mcfg == CFG_METHOD_13)
  588.                         RTL_W32(0xD0, RTL_R32(0xD0) | 0x00020000);
  589.         }
  590. }
  591.  
  592. u32 mdio_read(struct rtl8168_private *tp,
  593.           u32 RegAddr)
  594. {
  595.         void __iomem *ioaddr = tp->mmio_addr;
  596.         int i, value = -1;
  597.  
  598.         if (tp->mcfg==CFG_METHOD_11)
  599.         {
  600.                 RTL_W32(OCPDR, OCPDR_Read |
  601.                         (RegAddr & OCPDR_Reg_Mask) << OCPDR_GPHY_Reg_shift);
  602.                 RTL_W32(OCPAR, OCPAR_GPHY_Write);
  603.                 RTL_W32(EPHY_RXER_NUM, 0);
  604.  
  605.                 for (i = 0; i < 100; i++)
  606.                 {
  607.                         mdelay(1);
  608.                         if (!(RTL_R32(OCPAR) & OCPAR_Flag))
  609.                                 break;
  610.                 }
  611.  
  612.                 mdelay(1);
  613.                 RTL_W32(OCPAR, OCPAR_GPHY_Read);
  614.                 RTL_W32(EPHY_RXER_NUM, 0);
  615.  
  616.                 for (i = 0; i < 100; i++)
  617.                 {
  618.                         mdelay(1);
  619.                         if (RTL_R32(OCPAR) & OCPAR_Flag)
  620.                                 break;
  621.                 }
  622.  
  623.                 value = (int) (RTL_R32(OCPDR) & OCPDR_Data_Mask);
  624.         }
  625.         else
  626.         {
  627.                 if (tp->mcfg == CFG_METHOD_12 || tp->mcfg == CFG_METHOD_13)
  628.                         RTL_W32(0xD0, RTL_R32(0xD0) & ~0x00020000);
  629.  
  630.                 RTL_W32(PHYAR,
  631.                         PHYAR_Read | (RegAddr & PHYAR_Reg_Mask) << PHYAR_Reg_shift);
  632.  
  633.                 for (i = 0; i < 10; i++) {
  634.                         udelay(100);
  635.  
  636.                         /* Check if the RTL8168 has completed retrieving data from the specified MII
  637. register */
  638.                         if (RTL_R32(PHYAR) & PHYAR_Flag) {
  639.                                 value = (int) (RTL_R32(PHYAR) & PHYAR_Data_Mask);
  640.                                 udelay(20);
  641.                                 break;
  642.                         }
  643.                 }
  644.  
  645.                 if (tp->mcfg == CFG_METHOD_12 || tp->mcfg == CFG_METHOD_13)
  646.                         RTL_W32(0xD0, RTL_R32(0xD0) | 0x00020000);
  647.         }
  648.  
  649.         return value;
  650. }
  651.  
  652. u32 OCP_read(struct rtl8168_private *tp, u8 mask, u16 Reg)
  653. {
  654.         void __iomem *ioaddr = tp->mmio_addr;
  655.         int        i;
  656.  
  657.         RTL_W32(OCPAR, ((u32)mask&0xF)<<12 | (Reg&0xFFF));
  658.         for (i=0;i<20;i++)
  659.         {
  660.                 udelay(100);
  661.                 if (RTL_R32(OCPAR) & OCPAR_Flag)
  662.                         break;
  663.         }
  664.         return RTL_R32(OCPDR);
  665. }
  666.  
  667. void OCP_write(struct rtl8168_private *tp, u8 mask, u16 Reg, u32 data)
  668. {
  669.         void __iomem *ioaddr = tp->mmio_addr;
  670.         int        i;
  671.  
  672.         RTL_W32(OCPDR, data);
  673.         RTL_W32(OCPAR, OCPAR_Flag | ((u32)mask&0xF)<<12 | (Reg&0xFFF));
  674.         for (i=0;i<20;i++)
  675.         {
  676.                 udelay(100);
  677.                 if ( (RTL_R32(OCPAR)&OCPAR_Flag) == 0)
  678.                         break;
  679.         }
  680. }
  681.  
  682. static void OOB_mutex_lock(struct rtl8168_private *tp)
  683. {
  684.         u32 reg;
  685.  
  686.         if (tp->mcfg == CFG_METHOD_13)
  687.                 reg = 0x04;
  688.         else
  689.                 reg = 0x14;
  690.  
  691.         OCP_write(tp, 0x8, reg, 0x01000000);
  692.  
  693.         while (OCP_read(tp, 0xF, reg) & 0x00FF0000) {
  694.                 if (OCP_read(tp, 0xF, 0x09C) & 0x000000FF) {
  695.                         OCP_write(tp, 0x8, reg, 0x00000000);
  696.  
  697.                         while (OCP_read(tp, 0xF, 0x09C) & 0x000000FF);
  698.  
  699.                         OCP_write(tp, 0x8, reg, 0x01000000);
  700.                 }
  701.         }
  702. }
  703.  
  704. static void OOB_mutex_unlock(struct rtl8168_private *tp)
  705. {
  706.         u32 reg;
  707.  
  708.         if (tp->mcfg == CFG_METHOD_13)
  709.                 reg = 0x04;
  710.         else
  711.                 reg = 0x14;
  712.  
  713.         OCP_write(tp, 0x1, 0x9C, 0x00000001);
  714.         OCP_write(tp, 0x8, reg, 0x00000000);
  715. }
  716.  
  717. void OOB_notify(struct rtl8168_private *tp, u8 cmd)
  718. {
  719.         void __iomem *ioaddr = tp->mmio_addr;
  720.         int        i;
  721.  
  722.         RTL_W8(ERIDR, cmd);
  723.         RTL_W32(ERIAR, 0x800010E8);
  724.         mdelay(2);
  725.         for (i = 0; i < 5; i++) {
  726.                 udelay(100);
  727.                 if ( !(RTL_R32(ERIAR) & ERIAR_Flag))
  728.                         break;
  729.         }
  730.  
  731.         OCP_write(tp, 0x1, 0x30, 0x00000001);
  732. }
  733.  
  734. static int rtl8168_check_dash(struct rtl8168_private *tp)
  735. {
  736.         u32 reg;
  737.  
  738.         if (tp->mcfg == CFG_METHOD_13)
  739.                 reg = 0xb8;
  740.         else
  741.                 reg = 0x10;
  742.  
  743.         if (OCP_read(tp, 0xF, reg) & 0x00008000)
  744.                 return 1;
  745.         else
  746.                 return 0;
  747. }
  748.  
  749. static void rtl8168_mac_loopback_test(struct rtl8168_private *tp)
  750. {
  751.         void __iomem *ioaddr = tp->mmio_addr;
  752.         struct net_device *dev = tp->dev;
  753.         struct sk_buff *skb, *rx_skb;
  754.         dma_addr_t mapping;
  755.         struct TxDesc *txd;
  756.         struct RxDesc *rxd;
  757.         void *tmpAddr;
  758.         u32 len, rx_len, rx_cmd;
  759.         u16 type;
  760.         u8 pattern;
  761.         int i;
  762.  
  763.         if (rtl8168_check_dash(tp))
  764.                 return;
  765.  
  766.         pattern = 0x5A;
  767.         len = 60;
  768.         type = htons(ETH_P_IP);
  769.         txd = tp->TxDescArray;
  770.         rxd = tp->RxDescArray;
  771.         rx_skb = tp->Rx_skbuff[0];
  772.         RTL_W32(TxConfig, (RTL_R32(TxConfig) & ~0x00060000) | 0x00020000);
  773.  
  774.         do {
  775.                 skb = dev_alloc_skb(len + RTK_RX_ALIGN);
  776.                 if (unlikely(!skb))
  777.                         dev_printk(KERN_NOTICE, &tp->pci_dev->dev, "-ENOMEM;\n");
  778.         } while (unlikely(skb == NULL));
  779.         skb_reserve(skb, RTK_RX_ALIGN);
  780.  
  781.         memcpy(skb_put(skb, dev->addr_len), dev->dev_addr, dev->addr_len);
  782.         memcpy(skb_put(skb, dev->addr_len), dev->dev_addr, dev->addr_len);
  783.         memcpy(skb_put(skb, sizeof(type)), &type, sizeof(type));
  784.         tmpAddr = skb_put(skb, len - 14);
  785.  
  786.         mapping = pci_map_single(tp->pci_dev, skb->data, len, PCI_DMA_TODEVICE);
  787.         pci_dma_sync_single_for_cpu(tp->pci_dev, le64_to_cpu(mapping),
  788.                                     len, PCI_DMA_TODEVICE);
  789.         txd->addr = cpu_to_le64(mapping);
  790.         txd->opts2 = 0;
  791.         while (1) {
  792.                 memset(tmpAddr, pattern++, len - 14);
  793.                 pci_dma_sync_single_for_device(tp->pci_dev,
  794.                                                le64_to_cpu(mapping),
  795.                                                len, PCI_DMA_TODEVICE);
  796.                 txd->opts1 = cpu_to_le32(DescOwn | FirstFrag | LastFrag | len);
  797.  
  798.                 RTL_W32(RxConfig, RTL_R32(RxConfig)  | AcceptMyPhys);
  799.  
  800.                 smp_wmb();
  801.                 RTL_W8(TxPoll, NPQ);        /* set polling bit */
  802.  
  803.                 for (i = 0; i < 50; i++) {
  804.                         udelay(200);
  805.                         rx_cmd = le32_to_cpu(rxd->opts1);
  806.                         if ((rx_cmd & DescOwn) == 0)
  807.                                 break;
  808.                 }
  809.  
  810.                 RTL_W32(RxConfig, RTL_R32(RxConfig) & ~(AcceptErr | AcceptRunt | AcceptBroadcast |
  811. AcceptMulticast | AcceptMyPhys |  AcceptAllPhys));
  812.  
  813.                 rx_len = rx_cmd & 0x3FFF;
  814.                 rx_len -= 4;
  815.                 rxd->opts1 = cpu_to_le32(DescOwn | tp->rx_buf_sz);
  816.  
  817.                 pci_dma_sync_single_for_cpu(tp->pci_dev, le64_to_cpu(mapping), len,
  818. PCI_DMA_TODEVICE);
  819.  
  820.                 if (rx_len == len) {
  821.                         pci_dma_sync_single_for_cpu(tp->pci_dev, le64_to_cpu(rxd->addr), tp->rx_buf_sz,
  822. PCI_DMA_FROMDEVICE);
  823.                         i = memcmp(skb->data, rx_skb->data, rx_len);
  824.                         pci_dma_sync_single_for_device(tp->pci_dev, le64_to_cpu(rxd->addr),
  825. tp->rx_buf_sz, PCI_DMA_FROMDEVICE);
  826.                         if (i == 0) {
  827. //                                dev_printk(KERN_INFO, &tp->pci_dev->dev, "loopback test finished\n",rx_len,len);
  828.                                 break;
  829.                         }
  830.                 }
  831.  
  832.                 rtl8168_nic_reset(dev);
  833.                 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
  834.         }
  835.         tp->dirty_tx++;
  836.         tp->dirty_rx++;
  837.         tp->cur_tx++;
  838.         tp->cur_rx++;
  839.         pci_unmap_single(tp->pci_dev, le64_to_cpu(mapping),
  840.                          len, PCI_DMA_TODEVICE);
  841.         RTL_W32(TxConfig, RTL_R32(TxConfig) & ~0x00060000);
  842.         dev_kfree_skb_any(skb);
  843.         RTL_W16(IntrStatus, 0xFFBF);
  844. }
  845.  
  846. static void rtl8168_driver_start(struct rtl8168_private *tp)
  847. {
  848.         int timeout;
  849.         u32 reg;
  850.  
  851.         OOB_notify(tp, OOB_CMD_DRIVER_START);
  852.  
  853.         if (tp->mcfg == CFG_METHOD_13)
  854.                 reg = 0xB8;
  855.         else
  856.                 reg = 0x10;
  857.  
  858.         for (timeout = 0; timeout < 10; timeout++) {
  859.                 mdelay(10);
  860.                 if (OCP_read(tp, 0xF, reg) & BIT_11)
  861.                         break;
  862.         }
  863. }
  864.  
  865. static void rtl8168_driver_stop(struct rtl8168_private *tp)
  866. {
  867.         int timeout;
  868.         u32 reg;
  869.  
  870.         OOB_notify(tp, OOB_CMD_DRIVER_STOP);
  871.  
  872.         if (tp->mcfg == CFG_METHOD_13)
  873.                 reg = 0xB8;
  874.         else
  875.                 reg = 0x10;
  876.  
  877.         for (timeout = 0; timeout < 10; timeout++) {
  878.                 mdelay(10);
  879.                 if ((OCP_read(tp, 0xF, reg) & BIT_11) == 0)
  880.                         break;
  881.         }
  882. }
  883.  
  884. void rtl8168_ephy_write(void __iomem *ioaddr, int RegAddr, int value)
  885. {
  886.         int i;
  887.  
  888.         RTL_W32(EPHYAR,
  889.                 EPHYAR_Write |
  890.                 (RegAddr & EPHYAR_Reg_Mask) << EPHYAR_Reg_shift |
  891.                 (value & EPHYAR_Data_Mask));
  892.  
  893.         for (i = 0; i < 10; i++) {
  894.                 udelay(100);
  895.  
  896.                 /* Check if the RTL8168 has completed EPHY write */
  897.                 if (!(RTL_R32(EPHYAR) & EPHYAR_Flag))
  898.                         break;
  899.         }
  900.  
  901.         udelay(20);
  902. }
  903.  
  904. u16 rtl8168_ephy_read(void __iomem *ioaddr, int RegAddr)
  905. {
  906.         int i;
  907.         u16 value = 0xffff;
  908.  
  909.         RTL_W32(EPHYAR,
  910.                 EPHYAR_Read | (RegAddr & EPHYAR_Reg_Mask) << EPHYAR_Reg_shift);
  911.  
  912.         for (i = 0; i < 10; i++) {
  913.                 udelay(100);
  914.  
  915.                 /* Check if the RTL8168 has completed EPHY read */
  916.                 if (RTL_R32(EPHYAR) & EPHYAR_Flag) {
  917.                         value = (u16) (RTL_R32(EPHYAR) & EPHYAR_Data_Mask);
  918.                         break;
  919.                 }
  920.         }
  921.  
  922.         udelay(20);
  923.  
  924.         return value;
  925. }
  926.  
  927. static void
  928. rtl8168_csi_write(struct rtl8168_private *tp,
  929.                    u32 addr,
  930.                    u32 value)
  931. {
  932.         void __iomem *ioaddr = tp->mmio_addr;
  933.         u32 cmd;
  934.         int i;
  935.  
  936.         RTL_W32(CSIDR, value);
  937.         cmd = CSIAR_Write | CSIAR_ByteEn << CSIAR_ByteEn_shift | (addr & CSIAR_Addr_Mask);
  938.         if (tp->mcfg == CFG_METHOD_20)
  939.                 cmd |= 0x00020000;
  940.         RTL_W32(CSIAR, cmd);
  941.  
  942.         for (i = 0; i < 10; i++) {
  943.                 udelay(100);
  944.  
  945.                 /* Check if the RTL8168 has completed CSI write */
  946.                 if (!(RTL_R32(CSIAR) & CSIAR_Flag))
  947.                         break;
  948.         }
  949.  
  950.         udelay(20);
  951. }
  952.  
  953. static int
  954. rtl8168_csi_read(struct rtl8168_private *tp,
  955.                  u32 addr)
  956. {
  957.         void __iomem *ioaddr = tp->mmio_addr;
  958.         u32 cmd;
  959.         int i, value = -1;
  960.  
  961.         cmd = CSIAR_Read | CSIAR_ByteEn << CSIAR_ByteEn_shift | (addr & CSIAR_Addr_Mask);
  962.  
  963.         if (tp->mcfg == CFG_METHOD_20)
  964.                 cmd |= 0x00020000;
  965.  
  966.         RTL_W32(CSIAR, cmd);
  967.  
  968.         for (i = 0; i < 10; i++) {
  969.                 udelay(100);
  970.  
  971.                 /* Check if the RTL8168 has completed CSI read */
  972.                 if (RTL_R32(CSIAR) & CSIAR_Flag) {
  973.                         value = (int)RTL_R32(CSIDR);
  974.                         break;
  975.                 }
  976.         }
  977.  
  978.         udelay(20);
  979.  
  980.         return value;
  981. }
  982.  
  983. u32 rtl8168_eri_read(void __iomem *ioaddr, int addr, int len, int type)
  984. {
  985.         int i, val_shift, shift = 0;
  986.         u32 value1 = 0, value2 = 0, mask;
  987.  
  988.         if (len > 4 || len <= 0)
  989.                 return -1;
  990.  
  991.         while (len > 0) {
  992.                 val_shift = addr % ERIAR_Addr_Align;
  993.                 addr = addr & ~0x3;
  994.  
  995.                 RTL_W32(ERIAR,
  996.                         ERIAR_Read |
  997.                         type << ERIAR_Type_shift |
  998.                         ERIAR_ByteEn << ERIAR_ByteEn_shift |
  999.                         addr);
  1000.  
  1001.                 for (i = 0; i < 10; i++) {
  1002.                         udelay(100);
  1003.  
  1004.                         /* Check if the RTL8168 has completed ERI read */
  1005.                         if (RTL_R32(ERIAR) & ERIAR_Flag)
  1006.                                 break;
  1007.                 }
  1008.  
  1009.                 if (len == 1)                mask = (0xFF << (val_shift * 8)) & 0xFFFFFFFF;
  1010.                 else if (len == 2)        mask = (0xFFFF << (val_shift * 8)) & 0xFFFFFFFF;
  1011.                 else if (len == 3)        mask = (0xFFFFFF << (val_shift * 8)) & 0xFFFFFFFF;
  1012.                 else                        mask = (0xFFFFFFFF << (val_shift * 8)) & 0xFFFFFFFF;
  1013.  
  1014.                 value1 = RTL_R32(ERIDR) & mask;
  1015.                 value2 |= (value1 >> val_shift * 8) << shift * 8;
  1016.  
  1017.                 if (len <= 4 - val_shift)
  1018.                         len = 0;
  1019.                 else {
  1020.                         len -= (4 - val_shift);
  1021.                         shift = 4 - val_shift;
  1022.                         addr += 4;
  1023.                 }
  1024.         }
  1025.  
  1026.         return value2;
  1027. }
  1028.  
  1029. int rtl8168_eri_write(void __iomem *ioaddr, int addr, int len, u32 value, int type)
  1030. {
  1031.  
  1032.         int i, val_shift, shift = 0;
  1033.         u32 value1 = 0, mask;
  1034.  
  1035.         if (len > 4 || len <= 0)
  1036.                 return -1;
  1037.  
  1038.         while (len > 0) {
  1039.                 val_shift = addr % ERIAR_Addr_Align;
  1040.                 addr = addr & ~0x3;
  1041.  
  1042.                 if (len == 1)                mask = (0xFF << (val_shift * 8)) & 0xFFFFFFFF;
  1043.                 else if (len == 2)        mask = (0xFFFF << (val_shift * 8)) & 0xFFFFFFFF;
  1044.                 else if (len == 3)        mask = (0xFFFFFF << (val_shift * 8)) & 0xFFFFFFFF;
  1045.                 else                        mask = (0xFFFFFFFF << (val_shift * 8)) & 0xFFFFFFFF;
  1046.  
  1047.                 value1 = rtl8168_eri_read(ioaddr, addr, 4, type) & ~mask;
  1048.                 value1 |= ((value << val_shift * 8) >> shift * 8);
  1049.  
  1050.                 RTL_W32(ERIDR, value1);
  1051.                 RTL_W32(ERIAR,
  1052.                         ERIAR_Write |
  1053.                         type << ERIAR_Type_shift |
  1054.                         ERIAR_ByteEn << ERIAR_ByteEn_shift |
  1055.                         addr);
  1056.  
  1057.                 for (i = 0; i < 10; i++) {
  1058.                         udelay(100);
  1059.  
  1060.                         /* Check if the RTL8168 has completed ERI write */
  1061.                         if (!(RTL_R32(ERIAR) & ERIAR_Flag))
  1062.                                 break;
  1063.                 }
  1064.  
  1065.                 if (len <= 4 - val_shift)
  1066.                         len = 0;
  1067.                 else {
  1068.                         len -= (4 - val_shift);
  1069.                         shift = 4 - val_shift;
  1070.                         addr += 4;
  1071.                 }
  1072.         }
  1073.  
  1074.         return 0;
  1075. }
  1076.  
  1077. static void
  1078. rtl8168_irq_mask_and_ack(void __iomem *ioaddr)
  1079. {
  1080.         RTL_W16(IntrMask, 0x0000);
  1081. }
  1082.  
  1083. static void
  1084. rtl8168_asic_down(struct net_device *dev)
  1085. {
  1086.         struct rtl8168_private *tp = netdev_priv(dev);
  1087.         void __iomem *ioaddr = tp->mmio_addr;
  1088.  
  1089.         rtl8168_irq_mask_and_ack(ioaddr);
  1090.         rtl8168_nic_reset(dev);
  1091. }
  1092.  
  1093. static void
  1094. rtl8168_nic_reset(struct net_device *dev)
  1095. {
  1096.         struct rtl8168_private *tp = netdev_priv(dev);
  1097.         void __iomem *ioaddr = tp->mmio_addr;
  1098.         int        i;
  1099.  
  1100.         RTL_W32(RxConfig, RTL_R32(RxConfig) &
  1101.                 ~(AcceptErr | AcceptRunt | AcceptBroadcast | AcceptMulticast |
  1102.                   AcceptMyPhys |  AcceptAllPhys));
  1103.  
  1104.         switch (tp->mcfg) {
  1105.         case CFG_METHOD_1:
  1106.         case CFG_METHOD_2:
  1107.         case CFG_METHOD_3:
  1108.                 break;
  1109.         case CFG_METHOD_4:
  1110.         case CFG_METHOD_5:
  1111.         case CFG_METHOD_6:
  1112.         case CFG_METHOD_7:
  1113.         case CFG_METHOD_8:
  1114.         case CFG_METHOD_9:
  1115.         case CFG_METHOD_10:
  1116.         case CFG_METHOD_14:
  1117.         case CFG_METHOD_15:
  1118.                 RTL_W8(ChipCmd, StopReq | CmdRxEnb | CmdTxEnb);
  1119.                 udelay(100);
  1120.                 break;
  1121.         case CFG_METHOD_11:
  1122.         case CFG_METHOD_12:
  1123.         case CFG_METHOD_13:
  1124.                 while (RTL_R8(TxPoll) & NPQ)
  1125.                         udelay(20);
  1126.                 break;
  1127.         default:
  1128.                 RTL_W8(ChipCmd, StopReq | CmdRxEnb | CmdTxEnb);
  1129.                 while (!(RTL_R32(TxConfig) & BIT_11)) udelay(100);
  1130.                 break;
  1131.         }
  1132.  
  1133.         /* Soft reset the chip. */
  1134.         RTL_W8(ChipCmd, CmdReset);
  1135.  
  1136.         /* Check that the chip has finished the reset. */
  1137.         for (i = 100; i > 0; i--) {
  1138.                 udelay(100);
  1139.                 if ((RTL_R8(ChipCmd) & CmdReset) == 0)
  1140.                         break;
  1141.         }
  1142.  
  1143.         if (tp->mcfg == CFG_METHOD_11)
  1144.         {
  1145.                 OOB_mutex_lock(tp);
  1146.                 OCP_write(tp, 0x3, 0x10, OCP_read(tp, 0xF, 0x010)&~0x00004000);
  1147.                 OOB_mutex_unlock(tp);
  1148.  
  1149.                 OOB_notify(tp, OOB_CMD_RESET);
  1150.  
  1151.                 for (i=0;i<10;i++)
  1152.                 {
  1153.                         mdelay(10);
  1154.                         if (OCP_read(tp, 0xF, 0x010)&0x00004000)
  1155.                                 break;
  1156.                 }
  1157.  
  1158.                 for (i=0;i<5;i++)
  1159.                 {
  1160.                         if ( (OCP_read(tp, 0xF, 0x034) & 0xFFFF) == 0)
  1161.                                 break;
  1162.                 }
  1163.         }
  1164. }
  1165.  
  1166. static unsigned int
  1167. rtl8168_xmii_reset_pending(struct net_device *dev)
  1168. {
  1169.         struct rtl8168_private *tp = netdev_priv(dev);
  1170.         unsigned long flags;
  1171.         unsigned int retval;
  1172.  
  1173.         spin_lock_irqsave(&tp->phy_lock, flags);
  1174.         mdio_write(tp, 0x1f, 0x0000);
  1175.         retval = mdio_read(tp, MII_BMCR) & BMCR_RESET;
  1176.         spin_unlock_irqrestore(&tp->phy_lock, flags);
  1177.  
  1178.         return retval;
  1179. }
  1180.  
  1181. static unsigned int
  1182. rtl8168_xmii_link_ok(struct net_device *dev)
  1183. {
  1184.         struct rtl8168_private *tp = netdev_priv(dev);
  1185.         void __iomem *ioaddr = tp->mmio_addr;
  1186.         unsigned int retval;
  1187.  
  1188.         retval = RTL_R8(PHYstatus) & LinkStatus;
  1189.  
  1190.         return retval;
  1191. }
  1192.  
  1193. static void
  1194. rtl8168_xmii_reset_enable(struct net_device *dev)
  1195. {
  1196.         struct rtl8168_private *tp = netdev_priv(dev);
  1197.         unsigned long flags;
  1198.         int i, val = 0;
  1199.  
  1200.         spin_lock_irqsave(&tp->phy_lock, flags);
  1201.         mdio_write(tp, 0x1f, 0x0000);
  1202.         mdio_write(tp, MII_BMCR, mdio_read(tp, MII_BMCR) | BMCR_RESET);
  1203.         spin_unlock_irqrestore(&tp->phy_lock, flags);
  1204.  
  1205.         for (i = 0; i < 2500; i++) {
  1206.                 spin_lock_irqsave(&tp->phy_lock, flags);
  1207.                 val = mdio_read(tp, MII_BMSR) & BMCR_RESET;
  1208.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  1209.  
  1210.                 if (!val)
  1211.                         return;
  1212.  
  1213.                 mdelay(1);
  1214.         }
  1215. }
  1216.  
  1217. static void
  1218. rtl8168dp_10mbps_gphy_para(struct net_device *dev)
  1219. {
  1220.         struct rtl8168_private *tp = netdev_priv(dev);
  1221.         void __iomem *ioaddr = tp->mmio_addr;
  1222.         u8 status = RTL_R8(PHYstatus);
  1223.         unsigned long flags;
  1224.  
  1225.         spin_lock_irqsave(&tp->phy_lock, flags);
  1226.         if ((status & LinkStatus) && (status & _10bps)) {
  1227.                 mdio_write(tp, 0x1f, 0x0000);
  1228.                 mdio_write(tp, 0x10, 0x04EE);
  1229.         } else {
  1230.                 mdio_write(tp, 0x1f, 0x0000);
  1231.                 mdio_write(tp, 0x10, 0x01EE);
  1232.         }
  1233.         spin_unlock_irqrestore(&tp->phy_lock, flags);
  1234. }
  1235.  
  1236. void rtl8168_init_ring_indexes(struct rtl8168_private *tp);
  1237. static void
  1238. rtl8168_check_link_status(struct net_device *dev,
  1239.                           struct rtl8168_private *tp,
  1240.                           void __iomem *ioaddr)
  1241. {
  1242.         unsigned long flags;
  1243.  
  1244.         if (tp->mcfg == CFG_METHOD_11)
  1245.         {
  1246.                 rtl8168dp_10mbps_gphy_para(dev);
  1247.         }
  1248.  
  1249.         spin_lock_irqsave(&tp->lock, flags);
  1250.         if (tp->link_ok(dev)) {
  1251.                 if (tp->mcfg == CFG_METHOD_18 || tp->mcfg == CFG_METHOD_19 || tp->mcfg ==
  1252. CFG_METHOD_20) {
  1253.                         if (RTL_R8(PHYstatus) & _1000bpsF) {
  1254.                                 rtl8168_eri_write(ioaddr, 0x1bc, 4, 0x00000011, ERIAR_ExGMAC);
  1255.                                 rtl8168_eri_write(ioaddr, 0x1dc, 4, 0x00000005, ERIAR_ExGMAC);
  1256.                         } else {
  1257.                                 rtl8168_eri_write(ioaddr, 0x1bc, 4, 0x0000001f, ERIAR_ExGMAC);
  1258.                                 rtl8168_eri_write(ioaddr, 0x1dc, 4, 0x0000003f, ERIAR_ExGMAC);
  1259.                         }
  1260.                         if (netif_running(dev) && (RTL_R8(ChipCmd) & (CmdRxEnb | CmdTxEnb))==0) {
  1261.                                 int timeout;
  1262.                                 for (timeout = 0; timeout < 10; timeout++) {
  1263.                                         if ((rtl8168_eri_read(ioaddr, 0x1AE, 4, ERIAR_ExGMAC) & BIT_13)==0)
  1264.                                                 break;
  1265.                                         mdelay(1);
  1266.                                 }
  1267.                                 rtl8168_init_ring_indexes(tp);
  1268.                                 RTL_W8(ChipCmd, CmdRxEnb | CmdTxEnb);
  1269.                         }
  1270.                 } else if ((tp->mcfg == CFG_METHOD_16 || tp->mcfg == CFG_METHOD_17) &&
  1271. netif_running(dev)) {
  1272.                         u32 eri_data;
  1273.                         if (tp->mcfg == CFG_METHOD_16 && (RTL_R8(PHYstatus) & _10bps))
  1274.                                 RTL_W32(RxConfig, RTL_R32(RxConfig) | AcceptAllPhys);
  1275.                         else if (tp->mcfg == CFG_METHOD_17) {
  1276.                                 if (RTL_R8(PHYstatus) & _1000bpsF) {
  1277.                                         rtl8168_eri_write(ioaddr, 0x1bc, 4, 0x00000011, ERIAR_ExGMAC);
  1278.                                         rtl8168_eri_write(ioaddr, 0x1dc, 4, 0x00000005, ERIAR_ExGMAC);
  1279.                                 } else if (RTL_R8(PHYstatus) & _100bps) {
  1280.                                         rtl8168_eri_write(ioaddr, 0x1bc, 4, 0x0000001f, ERIAR_ExGMAC);
  1281.                                         rtl8168_eri_write(ioaddr, 0x1dc, 4, 0x00000005, ERIAR_ExGMAC);
  1282.                                 } else {
  1283.                                         rtl8168_eri_write(ioaddr, 0x1bc, 4, 0x0000001f, ERIAR_ExGMAC);
  1284.                                         rtl8168_eri_write(ioaddr, 0x1dc, 4, 0x0000003f, ERIAR_ExGMAC);
  1285.                                 }
  1286.                         }
  1287.  
  1288.                         eri_data = rtl8168_eri_read(ioaddr, 0xDC, 1, ERIAR_ExGMAC);
  1289.                         eri_data &= ~BIT_0;
  1290.                         rtl8168_eri_write(ioaddr, 0xDC, 1, eri_data, ERIAR_ExGMAC);
  1291.                         eri_data |= BIT_0;
  1292.                         rtl8168_eri_write(ioaddr, 0xDC, 1, eri_data, ERIAR_ExGMAC);
  1293.                         if ((RTL_R8(ChipCmd) & (CmdRxEnb | CmdTxEnb))==0) {
  1294.                                 int timeout;
  1295.                                 for (timeout = 0; timeout < 10; timeout++) {
  1296.                                         if ((rtl8168_eri_read(ioaddr, 0x1AE, 4, ERIAR_ExGMAC) & BIT_13)==0)
  1297.                                                 break;
  1298.                                         mdelay(1);
  1299.                                 }
  1300.                                 rtl8168_init_ring_indexes(tp);
  1301.                                 RTL_W8(ChipCmd, CmdRxEnb | CmdTxEnb);
  1302.                         }
  1303.  
  1304.                 } else if ((tp->mcfg == CFG_METHOD_14 || tp->mcfg == CFG_METHOD_15) && eee_enable
  1305. ==1){
  1306.                         //Full -Duplex  mode
  1307.                         if (RTL_R8(PHYstatus)&FullDup){
  1308.                                 mdio_write(tp, 0x1F, 0x0006);
  1309.                                 mdio_write(tp, 0x00, 0x5a30);
  1310.                                 mdio_write(tp, 0x1F, 0x0000);
  1311.                         }else{
  1312.                                 mdio_write(tp, 0x1F, 0x0006);
  1313.                                 mdio_write(tp, 0x00, 0x5a00);
  1314.                                 mdio_write(tp, 0x1F, 0x0000);
  1315.                         }
  1316.                 }
  1317.  
  1318.                 netif_carrier_on(dev);
  1319.                 if (netif_msg_ifup(tp))
  1320.                         printk(KERN_INFO PFX "%s: link up\n", dev->name);
  1321.         } else {
  1322.                 if (netif_msg_ifdown(tp))
  1323.                         printk(KERN_INFO PFX "%s: link down\n", dev->name);
  1324.                 netif_carrier_off(dev);
  1325.         }
  1326.         spin_unlock_irqrestore(&tp->lock, flags);
  1327. }
  1328.  
  1329. static void
  1330. rtl8168_link_option(int idx,
  1331.                     u8 *aut,
  1332.                     u16 *spd,
  1333.                     u8 *dup)
  1334. {
  1335.         unsigned char opt_speed;
  1336.         unsigned char opt_duplex;
  1337.         unsigned char opt_autoneg;
  1338.  
  1339.         opt_speed = ((idx < MAX_UNITS) && (idx >= 0)) ? speed[idx] : 0xff;
  1340.         opt_duplex = ((idx < MAX_UNITS) && (idx >= 0)) ? duplex[idx] : 0xff;
  1341.         opt_autoneg = ((idx < MAX_UNITS) && (idx >= 0)) ? autoneg[idx] : 0xff;
  1342.  
  1343.         if ((opt_speed == 0xff) |
  1344.             (opt_duplex == 0xff) |
  1345.             (opt_autoneg == 0xff)) {
  1346.                 *spd = SPEED_1000;
  1347.                 *dup = DUPLEX_FULL;
  1348.                 *aut = AUTONEG_ENABLE;
  1349.         } else {
  1350.                 *spd = speed[idx];
  1351.                 *dup = duplex[idx];
  1352.                 *aut = autoneg[idx];
  1353.         }
  1354. }
  1355.  
  1356. static void
  1357. rtl8168_powerdown_pll(struct net_device *dev)
  1358. {
  1359.         struct rtl8168_private *tp = netdev_priv(dev);
  1360.         void __iomem *ioaddr = tp->mmio_addr;
  1361.         unsigned long flags;
  1362.         int auto_nego = 0;
  1363.         int giga_ctrl = 0;
  1364.  
  1365.         if ((tp->mcfg == CFG_METHOD_11 || tp->mcfg == CFG_METHOD_12 ||
  1366.              tp->mcfg == CFG_METHOD_13) && rtl8168_check_dash(tp))
  1367.                 return;
  1368.  
  1369.         if (((tp->mcfg == CFG_METHOD_7) || (tp->mcfg == CFG_METHOD_8)) &&
  1370. (RTL_R16(CPlusCmd) & ASF))
  1371.                 return;
  1372.  
  1373. //        if (tp->mcfg == CFG_METHOD_17) {
  1374. //                void __iomem *ioaddr = tp->mmio_addr;
  1375. //                unsigned long flags;
  1376. //                u32 data;
  1377.  
  1378. //                spin_lock_irqsave(&tp->phy_lock, flags);
  1379. //                mdio_write(tp, 0x1f, 0x0000);
  1380. //                data = mdio_read(tp, MII_CTRL1000);
  1381. //                data &=        ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);
  1382. //                mdio_write(tp, MII_CTRL1000, data);
  1383. //                mdio_write(tp, MII_BMCR, BMCR_RESET | BMCR_ANENABLE | BMCR_ANRESTART);
  1384. //                spin_unlock_irqrestore(&tp->phy_lock, flags);
  1385.  
  1386. //                ssleep(3);
  1387. //                RTL_W16(IntrStatus, RTL_R16(IntrStatus));
  1388. //                RTL_W32(MAR0, 0);
  1389. //                RTL_W32(MAR0 + 4, 0);
  1390. //                RTL_W16(RxMaxSize, 0x05f3);
  1391. //                RTL_W8(0xD3, RTL_R8(0xD3) | BIT_7);
  1392.  
  1393. //                data = rtl8168_eri_read(ioaddr, 0xDC, 1, ERIAR_ExGMAC);
  1394. //                data &= ~BIT_0;
  1395. //                rtl8168_eri_write(ioaddr, 0xDC, 1, data, ERIAR_ExGMAC);
  1396. //                data |= BIT_0;
  1397. //                rtl8168_eri_write(ioaddr, 0xDC, 1, data, ERIAR_ExGMAC);
  1398.  
  1399. //                RTL_W32(RxConfig, RTL_R32(RxConfig) | AcceptBroadcast | AcceptMulticast |
  1400. AcceptMyPhys);
  1401. //                return;
  1402. //        }
  1403.  
  1404.         if (tp->wol_enabled == WOL_ENABLED) {
  1405.                 spin_lock_irqsave(&tp->phy_lock, flags);
  1406.                 mdio_write(tp, 0x1F, 0x0000);
  1407.                 auto_nego = mdio_read(tp, MII_ADVERTISE);
  1408.                 auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL
  1409.                                 | ADVERTISE_100HALF | ADVERTISE_100FULL);
  1410.                 if (config_down_speed_100)
  1411.                         auto_nego |= ADVERTISE_100FULL;
  1412.                 else
  1413.                         auto_nego |= ADVERTISE_10HALF;
  1414.  
  1415.                 giga_ctrl = mdio_read(tp, MII_CTRL1000) & ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);
  1416.                 mdio_write(tp, MII_ADVERTISE, auto_nego);
  1417.                 mdio_write(tp, MII_CTRL1000, giga_ctrl);
  1418.                 mdio_write(tp, MII_BMCR, BMCR_RESET | BMCR_ANENABLE | BMCR_ANRESTART);
  1419.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  1420.                 RTL_W32(RxConfig, RTL_R32(RxConfig) | AcceptBroadcast | AcceptMulticast |
  1421. AcceptMyPhys);
  1422.                 return;
  1423.         }
  1424.  
  1425.         rtl8168_phy_power_down(dev);
  1426.  
  1427.         switch (tp->mcfg) {
  1428.         case CFG_METHOD_9:
  1429.         case CFG_METHOD_10:
  1430.         case CFG_METHOD_11:
  1431.         case CFG_METHOD_12:
  1432.         case CFG_METHOD_13:
  1433.         case CFG_METHOD_14:
  1434.         case CFG_METHOD_15:
  1435.                 RTL_W8(PMCH, RTL_R8(PMCH) & ~BIT_7);
  1436.                 break;
  1437.         }
  1438. }
  1439.  
  1440. static void rtl8168_powerup_pll(struct net_device *dev)
  1441. {
  1442.         struct rtl8168_private *tp = netdev_priv(dev);
  1443.         void __iomem *ioaddr = tp->mmio_addr;
  1444.  
  1445.         switch (tp->mcfg) {
  1446.         case CFG_METHOD_9:
  1447.         case CFG_METHOD_10:
  1448.         case CFG_METHOD_11:
  1449.         case CFG_METHOD_12:
  1450.         case CFG_METHOD_13:
  1451.         case CFG_METHOD_14:
  1452.         case CFG_METHOD_15:
  1453.                 RTL_W8(PMCH, RTL_R8(PMCH) | BIT_7);
  1454.                 break;
  1455.         }
  1456.  
  1457.         rtl8168_phy_power_up(dev);
  1458.         rtl8168_set_speed(dev, tp->autoneg, tp->speed, tp->duplex);
  1459. }
  1460.  
  1461. static void
  1462. rtl8168_get_wol(struct net_device *dev,
  1463.                 struct ethtool_wolinfo *wol)
  1464. {
  1465.         struct rtl8168_private *tp = netdev_priv(dev);
  1466.         void __iomem *ioaddr = tp->mmio_addr;
  1467.         u8 options;
  1468.         u32 csi_tmp;
  1469.  
  1470.         wol->wolopts = 0;
  1471.  
  1472. #define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
  1473.         if (tp->mcfg == CFG_METHOD_DEFAULT) {
  1474.                 wol->supported = 0;
  1475.                 return;
  1476.         } else {
  1477.         wol->supported = WAKE_ANY;
  1478.         }
  1479.  
  1480.         spin_lock_irq(&tp->lock);
  1481.  
  1482.         options = RTL_R8(Config1);
  1483.         if (!(options & PMEnable))
  1484.                 goto out_unlock;
  1485.  
  1486.         options = RTL_R8(Config3);
  1487.         if (options & LinkUp)
  1488.                 wol->wolopts |= WAKE_PHY;
  1489.         if (tp->mcfg == CFG_METHOD_16 || tp->mcfg == CFG_METHOD_17) {
  1490.                 csi_tmp = rtl8168_eri_read(ioaddr, 0xDE, 4, ERIAR_ExGMAC);
  1491.                 if (csi_tmp & BIT_0)
  1492.                         wol->wolopts |= WAKE_MAGIC;
  1493.         } else {
  1494.                 if (options & MagicPacket)
  1495.                         wol->wolopts |= WAKE_MAGIC;
  1496.         }
  1497.  
  1498.         options = RTL_R8(Config5);
  1499.         if (options & UWF)
  1500.                 wol->wolopts |= WAKE_UCAST;
  1501.         if (options & BWF)
  1502.                 wol->wolopts |= WAKE_BCAST;
  1503.         if (options & MWF)
  1504.                 wol->wolopts |= WAKE_MCAST;
  1505.  
  1506. out_unlock:
  1507.         spin_unlock_irq(&tp->lock);
  1508. }
  1509.  
  1510. static int
  1511. rtl8168_set_wol(struct net_device *dev,
  1512.                 struct ethtool_wolinfo *wol)
  1513. {
  1514.         struct rtl8168_private *tp = netdev_priv(dev);
  1515.         void __iomem *ioaddr = tp->mmio_addr;
  1516.         int i,tmp;
  1517.         u32 csi_tmp;
  1518.         static struct {
  1519.                 u32 opt;
  1520.                 u16 reg;
  1521.                 u8  mask;
  1522.         } cfg[] = {
  1523.                 { WAKE_ANY,   Config1, PMEnable },
  1524.                 { WAKE_PHY,   Config3, LinkUp },
  1525.                 { WAKE_UCAST, Config5, UWF },
  1526.                 { WAKE_BCAST, Config5, BWF },
  1527.                 { WAKE_MCAST, Config5, MWF },
  1528.                 { WAKE_ANY,   Config5, LanWake },
  1529.                 { WAKE_MAGIC, Config3, MagicPacket },
  1530.         };
  1531.  
  1532.         if (tp->mcfg == CFG_METHOD_DEFAULT)
  1533.                 return -EOPNOTSUPP;
  1534.  
  1535.         spin_lock_irq(&tp->lock);
  1536.  
  1537.         RTL_W8(Cfg9346, Cfg9346_Unlock);
  1538.  
  1539.         if (tp->mcfg == CFG_METHOD_16 || tp->mcfg == CFG_METHOD_17) {
  1540.                 tmp = ARRAY_SIZE(cfg) - 1;
  1541.  
  1542.                 csi_tmp = rtl8168_eri_read(ioaddr, 0xDE, 4, ERIAR_ExGMAC);
  1543.                 if (wol->wolopts & WAKE_MAGIC)
  1544.                         csi_tmp |= BIT_0;
  1545.                 else
  1546.                         csi_tmp &=~ BIT_0;
  1547.                 rtl8168_eri_write(ioaddr, 0xDE, 4, csi_tmp, ERIAR_ExGMAC);
  1548.         } else {
  1549.                 tmp = ARRAY_SIZE(cfg);
  1550.         }
  1551.  
  1552.         for (i = 0; i < tmp; i++) {
  1553.                 u8 options = RTL_R8(cfg[i].reg) & ~cfg[i].mask;
  1554.                 if (wol->wolopts & cfg[i].opt)
  1555.                         options |= cfg[i].mask;
  1556.                 RTL_W8(cfg[i].reg, options);
  1557.         }
  1558.  
  1559.         RTL_W8(Cfg9346, Cfg9346_Lock);
  1560.  
  1561.         tp->wol_enabled = (wol->wolopts) ? WOL_ENABLED : WOL_DISABLED;
  1562.  
  1563.         spin_unlock_irq(&tp->lock);
  1564.  
  1565.         return 0;
  1566. }
  1567.  
  1568. static void
  1569. rtl8168_get_drvinfo(struct net_device *dev,
  1570.                     struct ethtool_drvinfo *info)
  1571. {
  1572.         struct rtl8168_private *tp = netdev_priv(dev);
  1573.  
  1574.         strcpy(info->driver, MODULENAME);
  1575.         strcpy(info->version, RTL8168_VERSION);
  1576.         strcpy(info->bus_info, pci_name(tp->pci_dev));
  1577.         info->regdump_len = R8168_REGS_SIZE;
  1578.         info->eedump_len = tp->eeprom_len;
  1579. }
  1580.  
  1581. static int
  1582. rtl8168_get_regs_len(struct net_device *dev)
  1583. {
  1584.         return R8168_REGS_SIZE;
  1585. }
  1586.  
  1587. static int
  1588. rtl8168_set_speed_xmii(struct net_device *dev,
  1589.                        u8 autoneg,
  1590.                        u16 speed,
  1591.                        u8 duplex)
  1592. {
  1593.         struct rtl8168_private *tp = netdev_priv(dev);
  1594.         int auto_nego = 0;
  1595.         int giga_ctrl = 0;
  1596.         int bmcr_true_force = 0;
  1597.         unsigned long flags;
  1598.  
  1599.         if ((speed != SPEED_1000) &&
  1600.             (speed != SPEED_100) &&
  1601.             (speed != SPEED_10)) {
  1602.                 speed = SPEED_1000;
  1603.                 duplex = DUPLEX_FULL;
  1604.         }
  1605.  
  1606.         if ((autoneg == AUTONEG_ENABLE) || (speed == SPEED_1000)) {
  1607.                 /*n-way force*/
  1608.                 if ((speed == SPEED_10) && (duplex == DUPLEX_HALF)) {
  1609.                         auto_nego |= ADVERTISE_10HALF;
  1610.                 } else if ((speed == SPEED_10) && (duplex == DUPLEX_FULL)) {
  1611.                         auto_nego |= ADVERTISE_10HALF |
  1612.                                      ADVERTISE_10FULL;
  1613.                 } else if ((speed == SPEED_100) && (duplex == DUPLEX_HALF)) {
  1614.                         auto_nego |= ADVERTISE_100HALF |
  1615.                                      ADVERTISE_10HALF |
  1616.                                      ADVERTISE_10FULL;
  1617.                 } else if ((speed == SPEED_100) && (duplex == DUPLEX_FULL)) {
  1618.                         auto_nego |= ADVERTISE_100HALF |
  1619.                                      ADVERTISE_100FULL |
  1620.                                      ADVERTISE_10HALF |
  1621.                                      ADVERTISE_10FULL;
  1622.                 } else if (speed == SPEED_1000) {
  1623.                         giga_ctrl |= ADVERTISE_1000HALF |
  1624.                                      ADVERTISE_1000FULL;
  1625.  
  1626.                         auto_nego |= ADVERTISE_100HALF |
  1627.                                      ADVERTISE_100FULL |
  1628.                                      ADVERTISE_10HALF |
  1629.                                      ADVERTISE_10FULL;
  1630.                 }
  1631.  
  1632.                 //flow contorol
  1633.                 auto_nego |= ADVERTISE_PAUSE_CAP|ADVERTISE_PAUSE_ASYM;
  1634.  
  1635.                 tp->phy_auto_nego_reg = auto_nego;
  1636.                 tp->phy_1000_ctrl_reg = giga_ctrl;
  1637.  
  1638.                 tp->autoneg = autoneg;
  1639.                 tp->speed = speed;
  1640.                 tp->duplex = duplex;
  1641.  
  1642.                 spin_lock_irqsave(&tp->phy_lock, flags);
  1643.                 mdio_write(tp, 0x1f, 0x0000);
  1644.                 mdio_write(tp, MII_ADVERTISE, auto_nego);
  1645.                 mdio_write(tp, MII_CTRL1000, giga_ctrl);
  1646.                 mdio_write(tp, MII_BMCR, BMCR_RESET | BMCR_ANENABLE | BMCR_ANRESTART);
  1647.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  1648.                 mdelay(20);
  1649.         } else {
  1650.                 /*true force*/
  1651. #ifndef BMCR_SPEED100
  1652. #define BMCR_SPEED100        0x0040
  1653. #endif
  1654.  
  1655. #ifndef BMCR_SPEED10
  1656. #define BMCR_SPEED10        0x0000
  1657. #endif
  1658.                 if ((speed == SPEED_10) && (duplex == DUPLEX_HALF)) {
  1659.                         bmcr_true_force = BMCR_SPEED10;
  1660.                 } else if ((speed == SPEED_10) && (duplex == DUPLEX_FULL)) {
  1661.                         bmcr_true_force = BMCR_SPEED10 | BMCR_FULLDPLX;
  1662.                 } else if ((speed == SPEED_100) && (duplex == DUPLEX_HALF)) {
  1663.                         bmcr_true_force = BMCR_SPEED100;
  1664.                 } else if ((speed == SPEED_100) && (duplex == DUPLEX_FULL)) {
  1665.                         bmcr_true_force = BMCR_SPEED100 | BMCR_FULLDPLX;
  1666.                 }
  1667.  
  1668.                 spin_lock_irqsave(&tp->phy_lock, flags);
  1669.                 mdio_write(tp, 0x1f, 0x0000);
  1670.                 mdio_write(tp, MII_BMCR, bmcr_true_force);
  1671.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  1672.         }
  1673.  
  1674.         if (tp->mcfg == CFG_METHOD_11)
  1675.                 rtl8168dp_10mbps_gphy_para(dev);
  1676.  
  1677.         return 0;
  1678. }
  1679.  
  1680. static int
  1681. rtl8168_set_speed(struct net_device *dev,
  1682.                   u8 autoneg,
  1683.                   u16 speed,
  1684.                   u8 duplex)
  1685. {
  1686.         struct rtl8168_private *tp = netdev_priv(dev);
  1687.         int ret;
  1688.  
  1689.         ret = tp->set_speed(dev, autoneg, speed, duplex);
  1690.  
  1691.         return ret;
  1692. }
  1693.  
  1694. static int
  1695. rtl8168_set_settings(struct net_device *dev,
  1696.                      struct ethtool_cmd *cmd)
  1697. {
  1698.         struct rtl8168_private *tp = netdev_priv(dev);
  1699.         unsigned long flags;
  1700.         int ret;
  1701.  
  1702.         spin_lock_irqsave(&tp->lock, flags);
  1703.         ret = rtl8168_set_speed(dev, cmd->autoneg, cmd->speed, cmd->duplex);
  1704.         spin_unlock_irqrestore(&tp->lock, flags);
  1705.  
  1706.         return ret;
  1707. }
  1708.  
  1709. static u32
  1710. rtl8168_get_tx_csum(struct net_device *dev)
  1711. {
  1712.         return (dev->features & NETIF_F_IP_CSUM) != 0;
  1713. }
  1714.  
  1715. static u32
  1716. rtl8168_get_rx_csum(struct net_device *dev)
  1717. {
  1718.         struct rtl8168_private *tp = netdev_priv(dev);
  1719.  
  1720.         return tp->cp_cmd & RxChkSum;
  1721. }
  1722.  
  1723. static int
  1724. rtl8168_set_tx_csum(struct net_device *dev,
  1725.                     u32 data)
  1726. {
  1727.         struct rtl8168_private *tp = netdev_priv(dev);
  1728.        
  1729.         if (tp->mcfg == CFG_METHOD_DEFAULT)
  1730.                 return -EOPNOTSUPP;
  1731.  
  1732.         if (data)
  1733.                 dev->features |= NETIF_F_IP_CSUM;
  1734.         else
  1735.                 dev->features &= ~NETIF_F_IP_CSUM;
  1736.  
  1737.         return 0;
  1738. }
  1739.  
  1740. static int
  1741. rtl8168_set_rx_csum(struct net_device *dev,
  1742.                     u32 data)
  1743. {
  1744.         struct rtl8168_private *tp = netdev_priv(dev);
  1745.         void __iomem *ioaddr = tp->mmio_addr;
  1746.         unsigned long flags;
  1747.  
  1748.         if (tp->mcfg == CFG_METHOD_DEFAULT)
  1749.                 return -EOPNOTSUPP;
  1750.  
  1751.         spin_lock_irqsave(&tp->lock, flags);
  1752.  
  1753.         if (data)
  1754.                 tp->cp_cmd |= RxChkSum;
  1755.         else
  1756.                 tp->cp_cmd &= ~RxChkSum;
  1757.  
  1758.         RTL_W16(CPlusCmd, tp->cp_cmd);
  1759.  
  1760.         spin_unlock_irqrestore(&tp->lock, flags);
  1761.  
  1762.         return 0;
  1763. }
  1764.  
  1765. #ifdef CONFIG_R8168_VLAN
  1766.  
  1767. static inline u32
  1768. rtl8168_tx_vlan_tag(struct rtl8168_private *tp,
  1769.                     struct sk_buff *skb)
  1770. {
  1771. #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
  1772.         return (tp->vlgrp && vlan_tx_tag_present(skb)) ?
  1773. #else
  1774.         return (vlan_tx_tag_present(skb)) ?
  1775. #endif
  1776.                 TxVlanTag | swab16(vlan_tx_tag_get(skb)) : 0x00;
  1777. }
  1778.  
  1779. #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
  1780.  
  1781. static void
  1782. rtl8168_vlan_rx_register(struct net_device *dev,
  1783.                          struct vlan_group *grp)
  1784. {
  1785.         struct rtl8168_private *tp = netdev_priv(dev);
  1786.         void __iomem *ioaddr = tp->mmio_addr;
  1787.         unsigned long flags;
  1788.  
  1789.         spin_lock_irqsave(&tp->lock, flags);
  1790.         tp->vlgrp = grp;
  1791.         if (tp->vlgrp)
  1792.                 tp->cp_cmd |= RxVlan;
  1793.         else
  1794.                 tp->cp_cmd &= ~RxVlan;
  1795.         RTL_W16(CPlusCmd, tp->cp_cmd);
  1796.         RTL_R16(CPlusCmd);
  1797.         spin_unlock_irqrestore(&tp->lock, flags);
  1798. }
  1799.  
  1800. #endif
  1801.  
  1802. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
  1803. static void
  1804. rtl8168_vlan_rx_kill_vid(struct net_device *dev,
  1805.                          unsigned short vid)
  1806. {
  1807.         struct rtl8168_private *tp = netdev_priv(dev);
  1808.         unsigned long flags;
  1809.  
  1810.         spin_lock_irqsave(&tp->lock, flags);
  1811. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
  1812.         if (tp->vlgrp)
  1813.                 tp->vlgrp->vlan_devices[vid] = NULL;
  1814. #else
  1815.         vlan_group_set_device(tp->vlgrp, vid, NULL);
  1816. #endif //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
  1817.         spin_unlock_irqrestore(&tp->lock, flags);
  1818. }
  1819. #endif //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
  1820.  
  1821. static int
  1822. rtl8168_rx_vlan_skb(struct rtl8168_private *tp,
  1823.                     struct RxDesc *desc,
  1824.                     struct sk_buff *skb)
  1825. {
  1826.         u32 opts2 = le32_to_cpu(desc->opts2);
  1827.         int ret = -1;
  1828.  
  1829. #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
  1830.         if (tp->vlgrp && (opts2 & RxVlanTag)) {
  1831.                 rtl8168_rx_hwaccel_skb(skb, tp->vlgrp,
  1832.                                        swab16(opts2 & 0xffff));
  1833.                 ret = 0;
  1834.         }
  1835. #else
  1836.         if (opts2 & RxVlanTag)
  1837.                 __vlan_hwaccel_put_tag(skb, swab16(opts2 & 0xffff));
  1838. #endif
  1839.  
  1840.         desc->opts2 = 0;
  1841.         return ret;
  1842. }
  1843.  
  1844. #else /* !CONFIG_R8168_VLAN */
  1845.  
  1846. static inline u32
  1847. rtl8168_tx_vlan_tag(struct rtl8168_private *tp,
  1848.                     struct sk_buff *skb)
  1849. {
  1850.         return 0;
  1851. }
  1852.  
  1853. static int
  1854. rtl8168_rx_vlan_skb(struct rtl8168_private *tp,
  1855.                     struct RxDesc *desc,
  1856.                     struct sk_buff *skb)
  1857. {
  1858.         return -1;
  1859. }
  1860.  
  1861. #endif
  1862.  
  1863. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
  1864.  
  1865. static u32 rtl8168_fix_features(struct net_device *dev, u32 features)
  1866. {
  1867.         if (dev->mtu > MSSMask)
  1868.                 features &= ~NETIF_F_ALL_TSO;
  1869.  
  1870.         return features;
  1871. }
  1872.  
  1873. static int rtl8168_set_features(struct net_device *dev, u32 features)
  1874. {
  1875.         struct rtl8168_private *tp = netdev_priv(dev);
  1876.         void __iomem *ioaddr = tp->mmio_addr;
  1877.         unsigned long flags;
  1878.  
  1879.         spin_lock_irqsave(&tp->lock, flags);
  1880.  
  1881.         if (features & NETIF_F_RXCSUM)
  1882.                 tp->cp_cmd |= RxChkSum;
  1883.         else
  1884.                 tp->cp_cmd &= ~RxChkSum;
  1885.  
  1886.         if (dev->features & NETIF_F_HW_VLAN_RX)
  1887.                 tp->cp_cmd |= RxVlan;
  1888.         else
  1889.                 tp->cp_cmd &= ~RxVlan;
  1890.  
  1891.         RTL_W16(CPlusCmd, tp->cp_cmd);
  1892.         RTL_R16(CPlusCmd);
  1893.  
  1894.         spin_unlock_irqrestore(&tp->lock, flags);
  1895.  
  1896.         return 0;
  1897. }
  1898.  
  1899. #endif
  1900.  
  1901. static void rtl8168_gset_xmii(struct net_device *dev,
  1902.                   struct ethtool_cmd *cmd)
  1903. {
  1904.         struct rtl8168_private *tp = netdev_priv(dev);
  1905.         void __iomem *ioaddr = tp->mmio_addr;
  1906.         u8 status;
  1907.         unsigned long flags;
  1908.  
  1909.         cmd->supported = SUPPORTED_10baseT_Half |
  1910.                          SUPPORTED_10baseT_Full |
  1911.                          SUPPORTED_100baseT_Half |
  1912.                          SUPPORTED_100baseT_Full |
  1913.                          SUPPORTED_1000baseT_Full |
  1914.                          SUPPORTED_Autoneg |
  1915.                          SUPPORTED_TP;
  1916.  
  1917.         spin_lock_irqsave(&tp->phy_lock, flags);
  1918.         cmd->autoneg = (mdio_read(tp, MII_BMCR) & BMCR_ANENABLE) ? 1 : 0;
  1919.         spin_unlock_irqrestore(&tp->phy_lock, flags);
  1920.         cmd->advertising = ADVERTISED_TP | ADVERTISED_Autoneg;
  1921.  
  1922.         if (tp->phy_auto_nego_reg & ADVERTISE_10HALF)
  1923.                 cmd->advertising |= ADVERTISED_10baseT_Half;
  1924.         if (tp->phy_auto_nego_reg & ADVERTISE_10FULL)
  1925.                 cmd->advertising |= ADVERTISED_10baseT_Full;
  1926.         if (tp->phy_auto_nego_reg & ADVERTISE_100HALF)
  1927.                 cmd->advertising |= ADVERTISED_100baseT_Half;
  1928.         if (tp->phy_auto_nego_reg & ADVERTISE_100FULL)
  1929.                 cmd->advertising |= ADVERTISED_100baseT_Full;
  1930.         if (tp->phy_1000_ctrl_reg & ADVERTISE_1000FULL)
  1931.                 cmd->advertising |= ADVERTISED_1000baseT_Full;
  1932.  
  1933.         status = RTL_R8(PHYstatus);
  1934.  
  1935.         if (status & _1000bpsF)
  1936.                 cmd->speed = SPEED_1000;
  1937.         else if (status & _100bps)
  1938.                 cmd->speed = SPEED_100;
  1939.         else if (status & _10bps)
  1940.                 cmd->speed = SPEED_10;
  1941.  
  1942.         if (status & TxFlowCtrl)
  1943.                 cmd->advertising |= ADVERTISED_Asym_Pause;
  1944.  
  1945.         if (status & RxFlowCtrl)
  1946.                 cmd->advertising |= ADVERTISED_Pause;
  1947.  
  1948.         cmd->duplex = ((status & _1000bpsF) || (status & FullDup)) ?
  1949.                       DUPLEX_FULL : DUPLEX_HALF;
  1950.  
  1951.  
  1952. }
  1953.  
  1954. static int
  1955. rtl8168_get_settings(struct net_device *dev,
  1956.                      struct ethtool_cmd *cmd)
  1957. {
  1958.         struct rtl8168_private *tp = netdev_priv(dev);
  1959.         unsigned long flags;
  1960.  
  1961.         spin_lock_irqsave(&tp->lock, flags);
  1962.  
  1963.         tp->get_settings(dev, cmd);
  1964.  
  1965.         spin_unlock_irqrestore(&tp->lock, flags);
  1966.         return 0;
  1967. }
  1968.  
  1969. static void rtl8168_get_regs(struct net_device *dev, struct ethtool_regs *regs,
  1970.                              void *p)
  1971. {
  1972.         struct rtl8168_private *tp = netdev_priv(dev);
  1973.         unsigned long flags;
  1974.  
  1975.         if (regs->len > R8168_REGS_SIZE)
  1976.                 regs->len = R8168_REGS_SIZE;
  1977.  
  1978.         spin_lock_irqsave(&tp->lock, flags);
  1979.         memcpy_fromio(p, tp->mmio_addr, regs->len);
  1980.         spin_unlock_irqrestore(&tp->lock, flags);
  1981. }
  1982.  
  1983. static u32
  1984. rtl8168_get_msglevel(struct net_device *dev)
  1985. {
  1986.         struct rtl8168_private *tp = netdev_priv(dev);
  1987.  
  1988.         return tp->msg_enable;
  1989. }
  1990.  
  1991. static void
  1992. rtl8168_set_msglevel(struct net_device *dev,
  1993.                      u32 value)
  1994. {
  1995.         struct rtl8168_private *tp = netdev_priv(dev);
  1996.  
  1997.         tp->msg_enable = value;
  1998. }
  1999.  
  2000. static const char rtl8168_gstrings[][ETH_GSTRING_LEN] = {
  2001.         "tx_packets",
  2002.         "rx_packets",
  2003.         "tx_errors",
  2004.         "rx_errors",
  2005.         "rx_missed",
  2006.         "align_errors",
  2007.         "tx_single_collisions",
  2008.         "tx_multi_collisions",
  2009.         "unicast",
  2010.         "broadcast",
  2011.         "multicast",
  2012.         "tx_aborted",
  2013.         "tx_underrun",
  2014. };
  2015.  
  2016. struct rtl8168_counters {
  2017.         u64        tx_packets;
  2018.         u64        rx_packets;
  2019.         u64        tx_errors;
  2020.         u32        rx_errors;
  2021.         u16        rx_missed;
  2022.         u16        align_errors;
  2023.         u32        tx_one_collision;
  2024.         u32        tx_multi_collision;
  2025.         u64        rx_unicast;
  2026.         u64        rx_broadcast;
  2027.         u32        rx_multicast;
  2028.         u16        tx_aborted;
  2029.         u16        tx_underun;
  2030. };
  2031.  
  2032. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
  2033. static int rtl8168_get_stats_count(struct net_device *dev)
  2034. {
  2035.         return ARRAY_SIZE(rtl8168_gstrings);
  2036. }
  2037. #else
  2038. static int rtl8168_get_sset_count(struct net_device *dev, int sset)
  2039. {
  2040.         switch (sset) {
  2041.         case ETH_SS_STATS:
  2042.                 return ARRAY_SIZE(rtl8168_gstrings);
  2043.         default:
  2044.                 return -EOPNOTSUPP;
  2045.         }
  2046. }
  2047. #endif
  2048. static void
  2049. rtl8168_get_ethtool_stats(struct net_device *dev,
  2050.                           struct ethtool_stats *stats,
  2051.                           u64 *data)
  2052. {
  2053.         struct rtl8168_private *tp = netdev_priv(dev);
  2054.         void __iomem *ioaddr = tp->mmio_addr;
  2055.         struct rtl8168_counters *counters;
  2056.         dma_addr_t paddr;
  2057.         u32 cmd;
  2058.  
  2059.         ASSERT_RTNL();
  2060.  
  2061.         counters = pci_alloc_consistent(tp->pci_dev, sizeof(*counters), &paddr);
  2062.         if (!counters)
  2063.                 return;
  2064.  
  2065.         RTL_W32(CounterAddrHigh, (u64)paddr >> 32);
  2066.         cmd = (u64)paddr & DMA_BIT_MASK(32);
  2067.         RTL_W32(CounterAddrLow, cmd);
  2068.         RTL_W32(CounterAddrLow, cmd | CounterDump);
  2069.  
  2070.         while (RTL_R32(CounterAddrLow) & CounterDump) {
  2071.                 if (msleep_interruptible(1))
  2072.                         break;
  2073.         }
  2074.  
  2075.         RTL_W32(CounterAddrLow, 0);
  2076.         RTL_W32(CounterAddrHigh, 0);
  2077.  
  2078.         data[0]        = le64_to_cpu(counters->tx_packets);
  2079.         data[1] = le64_to_cpu(counters->rx_packets);
  2080.         data[2] = le64_to_cpu(counters->tx_errors);
  2081.         data[3] = le32_to_cpu(counters->rx_errors);
  2082.         data[4] = le16_to_cpu(counters->rx_missed);
  2083.         data[5] = le16_to_cpu(counters->align_errors);
  2084.         data[6] = le32_to_cpu(counters->tx_one_collision);
  2085.         data[7] = le32_to_cpu(counters->tx_multi_collision);
  2086.         data[8] = le64_to_cpu(counters->rx_unicast);
  2087.         data[9] = le64_to_cpu(counters->rx_broadcast);
  2088.         data[10] = le32_to_cpu(counters->rx_multicast);
  2089.         data[11] = le16_to_cpu(counters->tx_aborted);
  2090.         data[12] = le16_to_cpu(counters->tx_underun);
  2091.         pci_free_consistent(tp->pci_dev, sizeof(*counters), counters, paddr);
  2092. }
  2093.  
  2094. static void
  2095. rtl8168_get_strings(struct net_device *dev,
  2096.                     u32 stringset,
  2097.                     u8 *data)
  2098. {
  2099.         switch (stringset) {
  2100.         case ETH_SS_STATS:
  2101.                 memcpy(data, *rtl8168_gstrings, sizeof(rtl8168_gstrings));
  2102.                 break;
  2103.         }
  2104. }
  2105. static int rtl_get_eeprom_len(struct net_device *dev)
  2106. {
  2107.         struct rtl8168_private *tp = netdev_priv(dev);
  2108.  
  2109.         return tp->eeprom_len;
  2110. }
  2111.  
  2112. static int rtl_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8
  2113. *buf)
  2114. {
  2115.         struct rtl8168_private *tp = netdev_priv(dev);
  2116.         int        i,j,ret;
  2117.         int        start_w, end_w;
  2118.         int        VPD_addr, VPD_data;
  2119.         u32 *eeprom_buff;
  2120.         u16 tmp;
  2121.         void __iomem *ioaddr = tp->mmio_addr;
  2122.  
  2123.         if (tp->eeprom_type==EEPROM_TYPE_NONE)
  2124.         {
  2125.                 dev_printk(KERN_DEBUG, &tp->pci_dev->dev, "Detect none EEPROM\n");
  2126.                 return -EOPNOTSUPP;
  2127.         }
  2128.         else if (eeprom->len == 0 || (eeprom->offset+eeprom->len) > tp->eeprom_len)
  2129.         {
  2130.                 dev_printk(KERN_DEBUG, &tp->pci_dev->dev, "Invalid parameter\n");
  2131.                 return -EINVAL;
  2132.         }
  2133.  
  2134.         switch (tp->mcfg)
  2135.         {
  2136.                 case CFG_METHOD_9:
  2137.                 case CFG_METHOD_10:
  2138.                         VPD_addr = 0xCE;
  2139.                         VPD_data = 0xD0;
  2140.                         break;
  2141.  
  2142.                 case CFG_METHOD_4:
  2143.                 case CFG_METHOD_5:
  2144.                 case CFG_METHOD_6:
  2145.                 case CFG_METHOD_7:
  2146.                 case CFG_METHOD_8:
  2147.                 case CFG_METHOD_14:
  2148.                 case CFG_METHOD_15:
  2149.                         VPD_addr = 0xD2;
  2150.                         VPD_data = 0xD4;
  2151.                         break;
  2152.  
  2153.                 case CFG_METHOD_1:
  2154.                 case CFG_METHOD_2:
  2155.                 case CFG_METHOD_3:
  2156.                 default:
  2157.                         return -EOPNOTSUPP;
  2158.         }
  2159.  
  2160.         start_w = eeprom->offset >> 2;
  2161.         end_w = (eeprom->offset + eeprom->len - 1) >> 2;
  2162.  
  2163.         eeprom_buff = kmalloc(sizeof(u32)*(end_w - start_w + 1), GFP_KERNEL);
  2164.         if (!eeprom_buff)
  2165.         {
  2166.                 return -ENOMEM;
  2167.         }
  2168.  
  2169.         RTL_W8(Cfg9346, Cfg9346_Unlock);
  2170.         ret = -EFAULT;
  2171.         for (i=start_w; i<=end_w; i++)
  2172.         {
  2173.                 pci_write_config_word(tp->pci_dev, VPD_addr, (u16)i*4);
  2174.                 ret = -EFAULT;
  2175.                 for (j=0;j<10;j++)
  2176.                 {
  2177.                         udelay(400);
  2178.                         pci_read_config_word(tp->pci_dev, VPD_addr, &tmp);
  2179.                         if (tmp&0x8000)
  2180.                         {
  2181.                                 ret = 0;
  2182.                                 break;
  2183.                         }
  2184.                 }
  2185.  
  2186.                 if (ret)
  2187.                 {
  2188.                         break;
  2189.                 }
  2190.  
  2191.                 pci_read_config_dword(tp->pci_dev, VPD_data, &eeprom_buff[i-start_w]);
  2192.         }
  2193.         RTL_W8(Cfg9346, Cfg9346_Lock);
  2194.  
  2195.         if (!ret)
  2196.         {
  2197.                 memcpy(buf, (u8 *)eeprom_buff + (eeprom->offset & 3), eeprom->len);
  2198.         }
  2199.  
  2200.         kfree(eeprom_buff);
  2201.  
  2202.         return ret;
  2203. }
  2204.  
  2205. #undef ethtool_op_get_link
  2206. #define ethtool_op_get_link _kc_ethtool_op_get_link
  2207. u32 _kc_ethtool_op_get_link(struct net_device *dev)
  2208. {
  2209.         return netif_carrier_ok(dev) ? 1 : 0;
  2210. }
  2211.  
  2212. #undef ethtool_op_get_sg
  2213. #define ethtool_op_get_sg _kc_ethtool_op_get_sg
  2214. u32 _kc_ethtool_op_get_sg(struct net_device *dev)
  2215. {
  2216. #ifdef NETIF_F_SG
  2217.         return (dev->features & NETIF_F_SG) != 0;
  2218. #else
  2219.         return 0;
  2220. #endif
  2221. }
  2222.  
  2223. #undef ethtool_op_set_sg
  2224. #define ethtool_op_set_sg _kc_ethtool_op_set_sg
  2225. int _kc_ethtool_op_set_sg(struct net_device *dev, u32 data)
  2226. {
  2227.         struct rtl8168_private *tp = netdev_priv(dev);
  2228.        
  2229.         if (tp->mcfg == CFG_METHOD_DEFAULT)
  2230.                 return -EOPNOTSUPP;
  2231.  
  2232. #ifdef NETIF_F_SG
  2233.         if (data)
  2234.                 dev->features |= NETIF_F_SG;
  2235.         else
  2236.                 dev->features &= ~NETIF_F_SG;
  2237. #endif
  2238.  
  2239.         return 0;
  2240. }
  2241.  
  2242. static struct ethtool_ops rtl8168_ethtool_ops = {
  2243.         .get_drvinfo                = rtl8168_get_drvinfo,
  2244.         .get_regs_len                = rtl8168_get_regs_len,
  2245.         .get_link                = ethtool_op_get_link,
  2246.         .get_settings                = rtl8168_get_settings,
  2247.         .set_settings                = rtl8168_set_settings,
  2248.         .get_msglevel                = rtl8168_get_msglevel,
  2249.         .set_msglevel                = rtl8168_set_msglevel,
  2250.         //.get_rx_csum                = rtl8168_get_rx_csum,
  2251.         //.set_rx_csum                = rtl8168_set_rx_csum,
  2252.         //.get_tx_csum                = rtl8168_get_tx_csum,
  2253.         //.set_tx_csum                = rtl8168_set_tx_csum,
  2254.         //.get_sg                        = ethtool_op_get_sg,
  2255.         //.set_sg                        = ethtool_op_set_sg,
  2256. #ifdef NETIF_F_TSO
  2257.         //.get_tso                = ethtool_op_get_tso,
  2258.         //.set_tso                = ethtool_op_set_tso,
  2259. #endif
  2260.         .get_regs                = rtl8168_get_regs,
  2261.         .get_wol                = rtl8168_get_wol,
  2262.         .set_wol                = rtl8168_set_wol,
  2263.         .get_strings                = rtl8168_get_strings,
  2264. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
  2265.         .get_stats_count        = rtl8168_get_stats_count,
  2266. #else
  2267.         .get_sset_count                = rtl8168_get_sset_count,
  2268. #endif
  2269.         .get_ethtool_stats        = rtl8168_get_ethtool_stats,
  2270. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
  2271. #ifdef ETHTOOL_GPERMADDR
  2272.         .get_perm_addr                = ethtool_op_get_perm_addr,
  2273. #endif
  2274. #endif //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
  2275.         .get_eeprom                = rtl_get_eeprom,
  2276.         .get_eeprom_len                = rtl_get_eeprom_len,
  2277. };
  2278.  
  2279.  
  2280. static int rtl8168_enable_EEE(struct rtl8168_private *tp)
  2281. {
  2282.         void __iomem *ioaddr = tp->mmio_addr;
  2283.         int        ret;
  2284.         unsigned long flags;
  2285.         __u16        data;
  2286.  
  2287.         ret = 0;
  2288.         switch (tp->mcfg) {
  2289.         case CFG_METHOD_14:
  2290.         case CFG_METHOD_15:
  2291.                 spin_lock_irqsave(&tp->phy_lock, flags);
  2292.                 mdio_write(tp, 0x1F, 0x0007);
  2293.                 mdio_write(tp, 0x1E, 0x0020);
  2294.                 data = mdio_read(tp, 0x15) | 0x0100;
  2295.                 mdio_write(tp, 0x15, data);
  2296.                 mdio_write(tp, 0x1F, 0x0006);
  2297.                 mdio_write(tp, 0x00, 0x5A30);
  2298.                 mdio_write(tp, 0x1F, 0x0000);
  2299.                 mdio_write(tp, 0x0D, 0x0007);
  2300.                 mdio_write(tp, 0x0E, 0x003C);
  2301.                 mdio_write(tp, 0x0D, 0x4007);
  2302.                 mdio_write(tp, 0x0E, 0x0006);
  2303.                 mdio_write(tp, 0x0D, 0x0000);
  2304.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  2305.                 if((RTL_R8(Config4)&0x40) && (RTL_R8(0x6D) & BIT_7))
  2306.                 {
  2307.                         data = RTL_R16(CustomLED);
  2308.                         spin_lock_irqsave(&tp->phy_lock, flags);
  2309.                         mdio_write(tp, 0x1F, 0x0005);
  2310.                         mdio_write(tp, 0x05, 0x8AC8);
  2311.                         mdio_write(tp, 0x06, data);
  2312.                         mdio_write(tp, 0x05, 0x8B82);
  2313.                         data = mdio_read(tp, 0x06) | 0x0010;
  2314.                         mdio_write(tp, 0x05, 0x8B82);
  2315.                         mdio_write(tp, 0x06, data);
  2316.                         mdio_write(tp, 0x1F, 0x0000);
  2317.                         spin_unlock_irqrestore(&tp->phy_lock, flags);
  2318.                 }
  2319.                 break;
  2320.  
  2321.         case CFG_METHOD_16:
  2322.         case CFG_METHOD_17:
  2323.                 spin_lock_irqsave(&tp->phy_lock,flags);
  2324.                 data = rtl8168_eri_read(ioaddr,0x1B0 ,4,ERIAR_ExGMAC) | 0x0003;
  2325.                 rtl8168_eri_write(ioaddr, 0x1B0, 4, data, ERIAR_ExGMAC);
  2326.                 mdio_write(tp,0x1F , 0x0004);
  2327.                 mdio_write(tp,0x1F , 0x0007);
  2328.                 mdio_write(tp,0x1E , 0x0020);
  2329.                 data = mdio_read(tp, 0x15)|0x0100;
  2330.                 mdio_write(tp,0x15 , data);
  2331.                 mdio_write(tp,0x1F , 0x0002);
  2332.                 mdio_write(tp,0x1F , 0x0005);
  2333.                 mdio_write(tp,0x05 , 0x8B85);
  2334.                 data = mdio_read(tp, 0x06)|0x2000;
  2335.                 mdio_write(tp,0x06 , data);
  2336.                 mdio_write(tp,0x1F , 0x0000);
  2337.                 mdio_write(tp,0x0D , 0x0007);
  2338.                 mdio_write(tp,0x0E , 0x003C);
  2339.                 mdio_write(tp,0x0D , 0x4007);
  2340.                 mdio_write(tp,0x0E , 0x0006);
  2341.                 mdio_write(tp,0x1D , 0x0000);
  2342.                 spin_unlock_irqrestore(&tp->phy_lock,flags);
  2343.                 break;
  2344.  
  2345.         case CFG_METHOD_18:
  2346.         case CFG_METHOD_19:
  2347.         case CFG_METHOD_20:
  2348.                 spin_lock_irqsave(&tp->phy_lock,flags);
  2349.                 data = rtl8168_eri_read(ioaddr,0x1B0 ,4,ERIAR_ExGMAC);
  2350.                 data |= BIT_1 | BIT_0;
  2351.                 rtl8168_eri_write(ioaddr, 0x1B0, 4, data, ERIAR_ExGMAC);
  2352.                 mdio_write(tp, 0x1F, 0x0007);
  2353.                 mdio_write(tp, 0x1e, 0x0020);
  2354.                 data = mdio_read(tp, 0x15);
  2355.                 data |= BIT_8;
  2356.                 mdio_write(tp, 0x15, data);
  2357.                 mdio_write(tp, 0x1F, 0x0005);
  2358.                 mdio_write(tp, 0x05, 0x8B85);
  2359.                 data = mdio_read(tp, 0x06);
  2360.                 data |= BIT_13;
  2361.                 mdio_write(tp, 0x06, data);
  2362.                 mdio_write(tp, 0x1F, 0x0000);
  2363.                 mdio_write(tp, 0x0D, 0x0007);
  2364.                 mdio_write(tp, 0x0E, 0x003C);
  2365.                 mdio_write(tp, 0x0D, 0x4007);
  2366.                 mdio_write(tp, 0x0E, 0x0006);
  2367.                 mdio_write(tp, 0x0D, 0x0000);
  2368.                 spin_unlock_irqrestore(&tp->phy_lock,flags);
  2369.                 break;
  2370.  
  2371.         default:
  2372. //                dev_printk(KERN_DEBUG, &tp->pci_dev->dev, "Not Support EEE\n");
  2373.                 ret = -EOPNOTSUPP;
  2374.         }
  2375.  
  2376.         return ret;
  2377. }
  2378.  
  2379. static int rtl8168_disable_EEE(struct rtl8168_private *tp)
  2380. {
  2381.         void __iomem *ioaddr = tp->mmio_addr;
  2382.         int        ret;
  2383.         unsigned long flags;
  2384.         __u16        data;
  2385.  
  2386.         ret = 0;
  2387.         switch (tp->mcfg) {
  2388.         case CFG_METHOD_14:
  2389.         case CFG_METHOD_15:
  2390.                 spin_lock_irqsave(&tp->phy_lock, flags);
  2391.                 mdio_write(tp, 0x1F, 0x0007);
  2392.                 mdio_write(tp, 0x1E, 0x0020);
  2393.                 data = mdio_read(tp, 0x15) & ~0x0100;
  2394.                 mdio_write(tp, 0x15, data);
  2395.                 mdio_write(tp, 0x1F, 0x0006);
  2396.                 mdio_write(tp, 0x00, 0x5A00);
  2397.                 mdio_write(tp, 0x1F, 0x0000);
  2398.                 mdio_write(tp, 0x0D, 0x0007);
  2399.                 mdio_write(tp, 0x0E, 0x003C);
  2400.                 mdio_write(tp, 0x0D, 0x4007);
  2401.                 mdio_write(tp, 0x0E, 0x0000);
  2402.                 mdio_write(tp, 0x0D, 0x0000);
  2403.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  2404.                 if (RTL_R8(Config4) & 0x40)
  2405.                 {
  2406.                         data = RTL_R16(CustomLED);
  2407.                         spin_lock_irqsave(&tp->phy_lock, flags);
  2408.                         mdio_write(tp, 0x1F, 0x0005);
  2409.                         mdio_write(tp, 0x05, 0x8B82);
  2410.                         data = mdio_read(tp, 0x06) & ~0x0010;
  2411.                         mdio_write(tp, 0x05, 0x8B82);
  2412.                         mdio_write(tp, 0x06, data);
  2413.                         mdio_write(tp, 0x1F, 0x0000);
  2414.                         spin_unlock_irqrestore(&tp->phy_lock, flags);
  2415.                 }
  2416.                 break;
  2417.  
  2418.         case CFG_METHOD_16:
  2419.         case CFG_METHOD_17:
  2420.                 spin_lock_irqsave(&tp->phy_lock,flags);
  2421.                 data = rtl8168_eri_read(ioaddr,0x1B0 ,4,ERIAR_ExGMAC)& ~0x0003;
  2422.                 rtl8168_eri_write(ioaddr, 0x1B0, 4, data, ERIAR_ExGMAC);
  2423.                 mdio_write(tp, 0x1F, 0x0005);
  2424.                 mdio_write(tp, 0x05, 0x8B85);
  2425.                 data = mdio_read(tp, 0x06) & ~0x2000;
  2426.                 mdio_write(tp, 0x06, data);
  2427.                 mdio_write(tp, 0x1F, 0x0004);
  2428.                 mdio_write(tp, 0x1F, 0x0007);
  2429.                 mdio_write(tp, 0x1E, 0x0020);
  2430.                 data = mdio_read(tp, 0x15) & ~0x0100;
  2431.                 mdio_write(tp,0x15 , data);
  2432.                 mdio_write(tp, 0x1F, 0x0002);
  2433.                 mdio_write(tp, 0x1F, 0x0000);
  2434.                 mdio_write(tp, 0x0D, 0x0007);
  2435.                 mdio_write(tp, 0x0E, 0x003C);
  2436.                 mdio_write(tp, 0x0D, 0x4007);
  2437.                 mdio_write(tp, 0x0E, 0x0000);
  2438.                 mdio_write(tp, 0x0D, 0x0000);
  2439.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  2440.                 break;
  2441.  
  2442.         case CFG_METHOD_18:
  2443.         case CFG_METHOD_19:
  2444.         case CFG_METHOD_20:
  2445.                 spin_lock_irqsave(&tp->phy_lock,flags);
  2446.                 data = rtl8168_eri_read(ioaddr,0x1B0 ,4,ERIAR_ExGMAC);
  2447.                 data &= ~(BIT_1 | BIT_0);
  2448.                 rtl8168_eri_write(ioaddr, 0x1B0, 4, data, ERIAR_ExGMAC);
  2449.                 mdio_write(tp, 0x1F, 0x0005);
  2450.                 mdio_write(tp, 0x05, 0x8B85);
  2451.                 data = mdio_read(tp, 0x06);
  2452.                 data &= ~BIT_13;
  2453.                 mdio_write(tp, 0x06, data);
  2454.                 mdio_write(tp, 0x1F, 0x0007);
  2455.                 mdio_write(tp, 0x1e, 0x0020);
  2456.                 data = mdio_read(tp, 0x15);
  2457.                 data &= ~BIT_8;
  2458.                 mdio_write(tp, 0x15, data);
  2459.                 mdio_write(tp, 0x1F, 0x0000);
  2460.                 mdio_write(tp, 0x0D, 0x0007);
  2461.                 mdio_write(tp, 0x0E, 0x003C);
  2462.                 mdio_write(tp, 0x0D, 0x4007);
  2463.                 mdio_write(tp, 0x0E, 0x0000);
  2464.                 mdio_write(tp, 0x0D, 0x0000);
  2465.                 spin_unlock_irqrestore(&tp->phy_lock,flags);
  2466.                 break;
  2467.  
  2468.         default:
  2469. //                dev_printk(KERN_DEBUG, &tp->pci_dev->dev, "Not Support EEE\n");
  2470.                 ret = -EOPNOTSUPP;
  2471.                 break;
  2472.         }
  2473.  
  2474.         return ret;
  2475. }
  2476.  
  2477. static int rtl8168_green_table(struct rtl8168_private *tp)
  2478. {
  2479.         struct pci_dev *pdev = tp->pci_dev;
  2480.         unsigned long flags;
  2481.         u16 gphy_val;
  2482.         int i;
  2483.         static const u16 evl_phy_value[] = {
  2484.                 0x8B56, 0x8B5F, 0x8B68, 0x8B71,
  2485.                 0x8B7A, 0x8A7B, 0x8A7E, 0x8A81,
  2486.                 0x8A84, 0x8A87
  2487.         };
  2488.        
  2489.         switch (tp->mcfg) {
  2490.         case CFG_METHOD_16:
  2491.         case CFG_METHOD_17:
  2492.                 if (pdev->subsystem_vendor == 0x1043 &&
  2493.                     pdev->subsystem_device == 0x13F7) {
  2494.                         spin_lock_irqsave(&tp->phy_lock, flags);
  2495.                         mdio_write(tp, 0x1F, 0x0005);
  2496.                         for (i=0; i < ARRAY_SIZE(evl_phy_value); i++) {
  2497.                                 mdio_write(tp, 0x05, evl_phy_value[i]);
  2498.                                 gphy_val = (0xAA << 8) | (mdio_read(tp, 0x06) & 0xFF);
  2499.                                 mdio_write(tp, 0x06, gphy_val);
  2500.                         }
  2501.                         mdio_write(tp, 0x1F, 0x0007);
  2502.                         mdio_write(tp, 0x1E, 0x0078);
  2503.                         mdio_write(tp, 0x17, 0x51AA);               
  2504.                         mdio_write(tp, 0x1F, 0x0000);
  2505.                         spin_unlock_irqrestore(&tp->phy_lock, flags);                       
  2506.                 }
  2507.                 break;
  2508.         default:
  2509.                 break;
  2510.         }
  2511.  
  2512.         switch (tp->mcfg) {
  2513.         case CFG_METHOD_16:
  2514.         case CFG_METHOD_17:
  2515.         case CFG_METHOD_18:
  2516.         case CFG_METHOD_19:
  2517.         case CFG_METHOD_20:
  2518.                 spin_lock_irqsave(&tp->phy_lock, flags);
  2519.                 mdio_write(tp, 0x1f, 0x0005);
  2520.                 mdio_write(tp, 0x05, 0x8B54);
  2521.                 mdio_write(tp, 0x06, mdio_read(tp, 0x06) & BIT_11);
  2522.                 mdio_write(tp, 0x05, 0x8B5D);
  2523.                 mdio_write(tp, 0x06, mdio_read(tp, 0x06) & BIT_11);
  2524.                 mdio_write(tp, 0x05, 0x8A7C);
  2525.                 mdio_write(tp, 0x06, mdio_read(tp, 0x06) & BIT_8);
  2526.                 mdio_write(tp, 0x05, 0x8A7F);
  2527.                 mdio_write(tp, 0x06, mdio_read(tp, 0x06) | BIT_8);
  2528.                 mdio_write(tp, 0x05, 0x8A82);
  2529.                 mdio_write(tp, 0x06, mdio_read(tp, 0x06) & BIT_8);
  2530.                 mdio_write(tp, 0x05, 0x8A85);
  2531.                 mdio_write(tp, 0x06, mdio_read(tp, 0x06) & BIT_8);
  2532.                 mdio_write(tp, 0x05, 0x8A88);
  2533.                 mdio_write(tp, 0x06, mdio_read(tp, 0x06) & BIT_8);
  2534.                 mdio_write(tp, 0x1f, 0x0000);
  2535.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  2536.                 break;
  2537.         default:
  2538.                 break;
  2539.         }
  2540.  
  2541.         return 0;
  2542. }
  2543.  
  2544. #if 0
  2545.  
  2546. static int rtl8168_enable_green_feature(struct rtl8168_private *tp)
  2547. {
  2548.         unsigned long flags;
  2549.         u16 gphy_val;
  2550.  
  2551.         switch (tp->mcfg) {
  2552.         case CFG_METHOD_14:
  2553.         case CFG_METHOD_15:
  2554.                 spin_lock_irqsave(&tp->phy_lock, flags);
  2555.                 mdio_write(tp, 0x1F, 0x0003);
  2556.                 gphy_val = mdio_read(tp, 0x10) | 0x0400;
  2557.                 mdio_write(tp, 0x10, gphy_val);
  2558.                 gphy_val = mdio_read(tp, 0x19) | 0x0001;
  2559.                 mdio_write(tp, 0x19, gphy_val);
  2560.                 mdio_write(tp, 0x1F, 0x0005);
  2561.                 gphy_val = mdio_read(tp, 0x01) & ~0x0100;
  2562.                 mdio_write(tp, 0x01, gphy_val);
  2563.                 mdio_write(tp, 0x1F, 0x0000);
  2564.                 mdio_write(tp, 0x00, 0x9200);
  2565.                 mdelay(20);
  2566.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  2567.                 break;
  2568.  
  2569.         case CFG_METHOD_17:
  2570.         case CFG_METHOD_18:
  2571.         case CFG_METHOD_19:
  2572.         case CFG_METHOD_20:
  2573.                 spin_lock_irqsave(&tp->phy_lock, flags);
  2574.                 mdio_write(tp, 0x1f, 0x0003);
  2575.                 gphy_val = mdio_read(tp, 0x10);
  2576.                 gphy_val |= BIT_10;
  2577.                 mdio_write(tp, 0x10, gphy_val);
  2578.                 gphy_val = mdio_read(tp, 0x19);
  2579.                 gphy_val |= BIT_0;
  2580.                 mdio_write(tp, 0x19, gphy_val);
  2581.                 mdio_write(tp, 0x1F, 0x0005);
  2582.                 gphy_val = mdio_read(tp, 0x01);
  2583.                 gphy_val |= BIT_8;
  2584.                 mdio_write(tp, 0x01, gphy_val);
  2585.                 mdio_write(tp, 0x1f, 0x0000);
  2586.                 mdio_write(tp, 0x00, 0x9200);
  2587.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  2588.                 break;
  2589.  
  2590.         default:
  2591.                 dev_printk(KERN_DEBUG, &tp->pci_dev->dev, "Not Support Green Feature\n");
  2592.                 break;
  2593.         }
  2594.  
  2595.         return 0;
  2596. }
  2597.  
  2598. static int rtl8168_disable_green_feature(struct rtl8168_private *tp)
  2599. {
  2600.         unsigned long flags;
  2601.         u16 gphy_val;
  2602.  
  2603.         switch (tp->mcfg) {
  2604.         case CFG_METHOD_14:
  2605.         case CFG_METHOD_15:
  2606.                 spin_lock_irqsave(&tp->phy_lock, flags);
  2607.                 mdio_write(tp, 0x1F, 0x0005);
  2608.                 gphy_val = mdio_read(tp, 0x01) | 0x0100;
  2609.                 mdio_write(tp, 0x01, gphy_val);
  2610.                 mdio_write(tp, 0x1F, 0x0003);
  2611.                 gphy_val = mdio_read(tp, 0x10) & ~0x0400;
  2612.                 mdio_write(tp, 0x10, gphy_val);
  2613.                 gphy_val = mdio_read(tp, 0x19) & ~0x0001;
  2614.                 mdio_write(tp, 0x19, gphy_val);
  2615.                 mdio_write(tp, 0x1F, 0x0002);
  2616.                 gphy_val = mdio_read(tp, 0x06) & ~0x7000;
  2617.                 gphy_val |= 0x3000;
  2618.                 mdio_write(tp, 0x06, gphy_val);
  2619.                 gphy_val = mdio_read(tp, 0x0D) & 0x0700;
  2620.                 gphy_val |= 0x0500;
  2621.                 mdio_write(tp, 0x0D, gphy_val);
  2622.                 mdio_write(tp, 0x1F, 0x0000);
  2623.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  2624.                 break;
  2625.  
  2626.         case CFG_METHOD_17:
  2627.         case CFG_METHOD_18:
  2628.         case CFG_METHOD_19:
  2629.         case CFG_METHOD_20:
  2630.                 spin_lock_irqsave(&tp->phy_lock, flags);
  2631.                 mdio_write(tp, 0x1f, 0x0003);
  2632.                 gphy_val = mdio_read(tp, 0x19);
  2633.                 gphy_val &= ~BIT_0;
  2634.                 mdio_write(tp, 0x19, gphy_val);
  2635.                 gphy_val = mdio_read(tp, 0x10);
  2636.                 gphy_val &= ~BIT_10;
  2637.                 mdio_write(tp, 0x10, gphy_val);
  2638.                 mdio_write(tp, 0x1f, 0x0000);
  2639.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  2640.                 break;
  2641.  
  2642.         default:
  2643.                 dev_printk(KERN_DEBUG, &tp->pci_dev->dev, "Not Support Green Feature\n");
  2644.                 break;
  2645.         }
  2646.  
  2647.         return 0;
  2648. }
  2649.  
  2650. #endif
  2651.  
  2652. static void rtl8168_get_mac_version(struct rtl8168_private *tp, void __iomem *ioaddr)
  2653. {
  2654.         u32 reg,val32;
  2655.         u32 ICVerID;
  2656.  
  2657.         val32 = RTL_R32(TxConfig)  ;
  2658.         reg = val32 & 0x7c800000;
  2659.         ICVerID = val32 & 0x00700000;
  2660.  
  2661.         switch (reg) {
  2662.         case 0x30000000:
  2663.                 tp->mcfg = CFG_METHOD_1;
  2664.                 tp->efuse = EFUSE_NOT_SUPPORT;
  2665.                 break;
  2666.         case 0x38000000:
  2667.                 if (ICVerID == 0x00000000) {
  2668.                         tp->mcfg = CFG_METHOD_2;
  2669.                 } else if (ICVerID == 0x00500000) {
  2670.                         tp->mcfg = CFG_METHOD_3;
  2671.                 } else {
  2672.                         tp->mcfg = CFG_METHOD_3;
  2673.                 }
  2674.                 tp->efuse = EFUSE_NOT_SUPPORT;
  2675.                 break;
  2676.         case 0x3C000000:
  2677.                 if (ICVerID == 0x00000000) {
  2678.                         tp->mcfg = CFG_METHOD_4;
  2679.                 } else if (ICVerID == 0x00200000) {
  2680.                         tp->mcfg = CFG_METHOD_5;
  2681.                 } else if (ICVerID == 0x00400000) {
  2682.                         tp->mcfg = CFG_METHOD_6;
  2683.                 } else {
  2684.                         tp->mcfg = CFG_METHOD_6;
  2685.                 }
  2686.                 tp->efuse = EFUSE_NOT_SUPPORT;
  2687.                 break;
  2688.         case 0x3C800000:
  2689.                 if (ICVerID == 0x00100000){
  2690.                         tp->mcfg = CFG_METHOD_7;
  2691.                 } else if (ICVerID == 0x00300000){
  2692.                         tp->mcfg = CFG_METHOD_8;
  2693.                 } else {
  2694.                         tp->mcfg = CFG_METHOD_8;
  2695.                 }
  2696.                 tp->efuse = EFUSE_NOT_SUPPORT;
  2697.                 break;
  2698.         case 0x28000000:
  2699.                 if (ICVerID == 0x00100000) {
  2700.                         tp->mcfg = CFG_METHOD_9;
  2701.                 } else if (ICVerID == 0x00300000) {
  2702.                         tp->mcfg = CFG_METHOD_10;
  2703.                 } else {
  2704.                         tp->mcfg = CFG_METHOD_10;
  2705.                 }
  2706.                 tp->efuse = EFUSE_SUPPORT;
  2707.                 break;
  2708.         case 0x28800000:
  2709.                 if (ICVerID == 0x00000000)
  2710.                         tp->mcfg = CFG_METHOD_11;
  2711.                 else if (ICVerID == 0x00200000) {
  2712.                         tp->mcfg = CFG_METHOD_12;
  2713.                         RTL_W32(0xD0, RTL_R32(0xD0) | 0x00020000);
  2714.                 } else// if (ICVerID == 0x00300000)
  2715.                         tp->mcfg = CFG_METHOD_13;
  2716.                 tp->efuse = EFUSE_SUPPORT;
  2717.                 break;
  2718.         case 0x2C000000:
  2719.                 if (ICVerID == 0x00100000)
  2720.                         tp->mcfg = CFG_METHOD_14;
  2721.                 else if (ICVerID == 0x00200000)
  2722.                         tp->mcfg = CFG_METHOD_15;
  2723.                 tp->efuse = EFUSE_SUPPORT;
  2724.                 break;
  2725.         case 0x2C800000:
  2726.                 if (ICVerID == 0x00000000)
  2727.                         tp->mcfg = CFG_METHOD_16;
  2728.                 else if (ICVerID == 0x00100000)
  2729.                         tp->mcfg = CFG_METHOD_17;
  2730.                 tp->efuse = EFUSE_SUPPORT;
  2731.                 break;
  2732.         case 0x48000000:
  2733.                 if (ICVerID == 0x00000000)
  2734.                         tp->mcfg = CFG_METHOD_18;
  2735.                 else if (ICVerID == 0x00100000)
  2736.                         tp->mcfg = CFG_METHOD_19;
  2737.                 tp->efuse = EFUSE_SUPPORT;
  2738.                 break;
  2739.         case 0x48800000:
  2740.                 tp->mcfg = CFG_METHOD_20;
  2741.                 tp->efuse = EFUSE_SUPPORT;
  2742.                 break;
  2743.         default:
  2744.                 printk("unknown chip version (%x)\n",reg);
  2745.                 tp->mcfg = CFG_METHOD_DEFAULT;
  2746.                 tp->efuse = EFUSE_NOT_SUPPORT;
  2747.                 break;
  2748.         }
  2749. }
  2750.  
  2751. static void
  2752. rtl8168_print_mac_version(struct rtl8168_private *tp)
  2753. {
  2754.         int i;
  2755.         for (i = ARRAY_SIZE(rtl_chip_info) - 1; i >= 0; i--) {
  2756.                 if (tp->mcfg == rtl_chip_info[i].mcfg){
  2757.                         dprintk("mcfg == %s (%04d)\n", rtl_chip_info[i].name,
  2758.                                   rtl_chip_info[i].mcfg);
  2759.                         return;
  2760.                 }
  2761.         }
  2762.  
  2763.         dprintk("mac_version == Unknown\n");
  2764. }
  2765.  
  2766. static u8 rtl8168_efuse_read(struct rtl8168_private *tp, u16 reg)
  2767. {
  2768.         void __iomem *ioaddr = tp->mmio_addr;
  2769.         u8 efuse_data;
  2770.         u32 temp;
  2771.         int cnt;
  2772.  
  2773.         if (tp->efuse == EFUSE_NOT_SUPPORT)
  2774.                 return EFUSE_READ_FAIL;
  2775.  
  2776.         temp = EFUSE_READ | ((reg & EFUSE_Reg_Mask) << EFUSE_Reg_Shift);
  2777.         RTL_W32(EFUSEAR, temp);
  2778.  
  2779.         do {
  2780.                 udelay(100);
  2781.                 temp = RTL_R32(EFUSEAR);
  2782.                 cnt++;
  2783.         } while (!(temp & EFUSE_READ_OK) && (temp < EFUSE_Check_Cnt));
  2784.  
  2785.         if (temp == EFUSE_Check_Cnt)
  2786.                 efuse_data = EFUSE_READ_FAIL;
  2787.         else
  2788.                 efuse_data = (u8)(RTL_R32(EFUSEAR) & EFUSE_Data_Mask);
  2789.  
  2790.         return efuse_data;
  2791. }
  2792.  
  2793. static void
  2794. rtl8168_hw_phy_config(struct net_device *dev)
  2795. {
  2796.         struct rtl8168_private *tp = netdev_priv(dev);
  2797.         void __iomem *ioaddr = tp->mmio_addr;
  2798.         unsigned long flags;
  2799.         unsigned int gphy_val,i;
  2800.  
  2801.         spin_lock_irqsave(&tp->phy_lock, flags);
  2802.  
  2803.         if (tp->mcfg == CFG_METHOD_1) {
  2804.                 mdio_write(tp, 0x1F, 0x0001);
  2805.                 mdio_write(tp, 0x0B, 0x94B0);
  2806.  
  2807.                 mdio_write(tp, 0x1F, 0x0003);
  2808.                 mdio_write(tp, 0x12, 0x6096);
  2809.                 mdio_write(tp, 0x1F, 0x0000);
  2810.  
  2811.                 mdio_write(tp, 0x0D, 0xF8A0);
  2812.         } else if (tp->mcfg == CFG_METHOD_2) {
  2813.                 mdio_write(tp, 0x1F, 0x0001);
  2814.                 mdio_write(tp, 0x0B, 0x94B0);
  2815.  
  2816.                 mdio_write(tp, 0x1F, 0x0003);
  2817.                 mdio_write(tp, 0x12, 0x6096);
  2818.  
  2819.                 mdio_write(tp, 0x1F, 0x0000);
  2820.         } else if (tp->mcfg == CFG_METHOD_3) {
  2821.                 mdio_write(tp, 0x1F, 0x0001);
  2822.                 mdio_write(tp, 0x0B, 0x94B0);
  2823.  
  2824.                 mdio_write(tp, 0x1F, 0x0003);
  2825.                 mdio_write(tp, 0x12, 0x6096);
  2826.  
  2827.                 mdio_write(tp, 0x1F, 0x0000);
  2828.         } else if (tp->mcfg == CFG_METHOD_4) {
  2829.                 mdio_write(tp, 0x1F, 0x0001);
  2830.                 mdio_write(tp, 0x12, 0x2300);
  2831.                 mdio_write(tp, 0x1F, 0x0000);
  2832.                 mdio_write(tp, 0x1F, 0x0003);
  2833.                 mdio_write(tp, 0x16, 0x000A);
  2834.                 mdio_write(tp, 0x1F, 0x0000);
  2835.  
  2836.                 mdio_write(tp, 0x1F, 0x0003);
  2837.                 mdio_write(tp, 0x12, 0xC096);
  2838.                 mdio_write(tp, 0x1F, 0x0000);
  2839.  
  2840.                 mdio_write(tp, 0x1F, 0x0002);
  2841.                 mdio_write(tp, 0x00, 0x88DE);
  2842.                 mdio_write(tp, 0x01, 0x82B1);
  2843.                 mdio_write(tp, 0x1F, 0x0000);
  2844.  
  2845.                 mdio_write(tp, 0x1F, 0x0002);
  2846.                 mdio_write(tp, 0x08, 0x9E30);
  2847.                 mdio_write(tp, 0x09, 0x01F0);
  2848.                 mdio_write(tp, 0x1F, 0x0000);
  2849.  
  2850.                 mdio_write(tp, 0x1F, 0x0002);
  2851.                 mdio_write(tp, 0x0A, 0x5500);
  2852.                 mdio_write(tp, 0x1F, 0x0000);
  2853.  
  2854.                 mdio_write(tp, 0x1F, 0x0002);
  2855.                 mdio_write(tp, 0x03, 0x7002);
  2856.                 mdio_write(tp, 0x1F, 0x0000);
  2857.  
  2858.                 mdio_write(tp, 0x1F, 0x0002);
  2859.                 mdio_write(tp, 0x0C, 0x00C8);
  2860.                 mdio_write(tp, 0x1F, 0x0000);
  2861.  
  2862.                 mdio_write(tp, 0x1F, 0x0000);
  2863.                 mdio_write(tp, 0x14, mdio_read(tp, 0x14) | (1 << 5));
  2864.                 mdio_write(tp, 0x0D, mdio_read(tp, 0x0D) & ~(1 << 5));
  2865.         } else if (tp->mcfg == CFG_METHOD_5) {
  2866.                 mdio_write(tp, 0x1F, 0x0001);
  2867.                 mdio_write(tp, 0x12, 0x2300);
  2868.                 mdio_write(tp, 0x1F, 0x0003);
  2869.                 mdio_write(tp, 0x16, 0x0F0A);
  2870.                 mdio_write(tp, 0x1F, 0x0000);
  2871.  
  2872.                 mdio_write(tp, 0x1F, 0x0002);
  2873.                 mdio_write(tp, 0x00, 0x88DE);
  2874.                 mdio_write(tp, 0x01, 0x82B1);
  2875.                 mdio_write(tp, 0x1F, 0x0000);
  2876.  
  2877.                 mdio_write(tp, 0x1F, 0x0002);
  2878.                 mdio_write(tp, 0x0C, 0x7EB8);
  2879.                 mdio_write(tp, 0x1F, 0x0000);
  2880.  
  2881.                 mdio_write(tp, 0x1F, 0x0002);
  2882.                 mdio_write(tp, 0x06, 0x0761);
  2883.                 mdio_write(tp, 0x1F, 0x0000);
  2884.  
  2885.                 mdio_write(tp, 0x1F, 0x0001);
  2886.                 mdio_write(tp, 0x03, 0x802F);
  2887.                 mdio_write(tp, 0x02, 0x4F02);
  2888.                 mdio_write(tp, 0x01, 0x0409);
  2889.                 mdio_write(tp, 0x00, 0xF099);
  2890.                 mdio_write(tp, 0x04, 0x9800);
  2891.                 mdio_write(tp, 0x04, 0x9000);
  2892.                 mdio_write(tp, 0x1F, 0x0000);
  2893.  
  2894.                 mdio_write(tp, 0x1F, 0x0000);
  2895.                 mdio_write(tp, 0x16, mdio_read(tp, 0x16) | (1 << 0));
  2896.  
  2897.                 mdio_write(tp, 0x1F, 0x0000);
  2898.                 mdio_write(tp, 0x14, mdio_read(tp, 0x14) | (1 << 5));
  2899.                 mdio_write(tp, 0x0D, mdio_read(tp, 0x0D) & ~(1 << 5));
  2900.  
  2901.                 mdio_write(tp, 0x1F, 0x0001);
  2902.                 mdio_write(tp, 0x1D, 0x3D98);
  2903.                 mdio_write(tp, 0x1F, 0x0000);
  2904.  
  2905.                 mdio_write(tp, 0x1F, 0x0001);
  2906.                 mdio_write(tp, 0x17, 0x0CC0);
  2907.                 mdio_write(tp, 0x1F, 0x0000);
  2908.         } else if (tp->mcfg == CFG_METHOD_6) {
  2909.                 mdio_write(tp, 0x1F, 0x0001);
  2910.                 mdio_write(tp, 0x12, 0x2300);
  2911.                 mdio_write(tp, 0x1F, 0x0003);
  2912.                 mdio_write(tp, 0x16, 0x0F0A);
  2913.                 mdio_write(tp, 0x1F, 0x0000);
  2914.  
  2915.                 mdio_write(tp, 0x1F, 0x0002);
  2916.                 mdio_write(tp, 0x00, 0x88DE);
  2917.                 mdio_write(tp, 0x01, 0x82B1);
  2918.                 mdio_write(tp, 0x1F, 0x0000);
  2919.  
  2920.                 mdio_write(tp, 0x1F, 0x0002);
  2921.                 mdio_write(tp, 0x0C, 0x7EB8);
  2922.                 mdio_write(tp, 0x1F, 0x0000);
  2923.  
  2924.                 mdio_write(tp, 0x1F, 0x0002);
  2925.                 mdio_write(tp, 0x06, 0x5461);
  2926.                 mdio_write(tp, 0x1F, 0x0000);
  2927.  
  2928.                 mdio_write(tp, 0x1F, 0x0002);
  2929.                 mdio_write(tp, 0x06, 0x5461);
  2930.                 mdio_write(tp, 0x1F, 0x0000);
  2931.  
  2932.                 mdio_write(tp, 0x1F, 0x0000);
  2933.                 mdio_write(tp, 0x16, mdio_read(tp, 0x16) | (1 << 0));
  2934.  
  2935.                 mdio_write(tp, 0x1F, 0x0000);
  2936.                 mdio_write(tp, 0x14, mdio_read(tp, 0x14) | (1 << 5));
  2937.                 mdio_write(tp, 0x0D, mdio_read(tp, 0x0D) & ~(1 << 5));
  2938.  
  2939.                 mdio_write(tp, 0x1F, 0x0001);
  2940.                 mdio_write(tp, 0x1D, 0x3D98);
  2941.                 mdio_write(tp, 0x1F, 0x0000);
  2942.  
  2943.                 mdio_write(tp, 0x1f, 0x0001);
  2944.                 mdio_write(tp, 0x17, 0x0CC0);
  2945.                 mdio_write(tp, 0x1F, 0x0000);
  2946.         } else if (tp->mcfg == CFG_METHOD_7) {
  2947.                 mdio_write(tp, 0x1F, 0x0000);
  2948.                 mdio_write(tp, 0x14, mdio_read(tp, 0x14) | (1 << 5));
  2949.                 mdio_write(tp, 0x0D, mdio_read(tp, 0x0D) & ~(1 << 5));
  2950.  
  2951.                 mdio_write(tp, 0x1F, 0x0001);
  2952.                 mdio_write(tp, 0x1D, 0x3D98);
  2953.  
  2954.                 mdio_write(tp, 0x1F, 0x0001);
  2955.                 mdio_write(tp, 0x14, 0xCAA3);
  2956.                 mdio_write(tp, 0x1C, 0x000A);
  2957.                 mdio_write(tp, 0x18, 0x65D0);
  2958.  
  2959.                 mdio_write(tp, 0x1F, 0x0003);
  2960.                 mdio_write(tp, 0x17, 0xB580);
  2961.                 mdio_write(tp, 0x18, 0xFF54);
  2962.                 mdio_write(tp, 0x19, 0x3954);
  2963.  
  2964.                 mdio_write(tp, 0x1F, 0x0002);
  2965.                 mdio_write(tp, 0x0D, 0x310C);
  2966.                 mdio_write(tp, 0x0E, 0x310C);
  2967.                 mdio_write(tp, 0x0F, 0x311C);
  2968.                 mdio_write(tp, 0x06, 0x0761);
  2969.  
  2970.                 mdio_write(tp, 0x1F, 0x0003);
  2971.                 mdio_write(tp, 0x18, 0xFF55);
  2972.                 mdio_write(tp, 0x19, 0x3955);
  2973.                 mdio_write(tp, 0x18, 0xFF54);
  2974.                 mdio_write(tp, 0x19, 0x3954);
  2975.  
  2976.                 mdio_write(tp, 0x1F, 0x0001);
  2977.                 mdio_write(tp, 0x17, 0x0CC0);
  2978.  
  2979.                 mdio_write(tp, 0x1F, 0x0000);
  2980.         } else if (tp->mcfg == CFG_METHOD_8) {
  2981.                 mdio_write(tp, 0x1F, 0x0000);
  2982.                 mdio_write(tp, 0x14, mdio_read(tp, 0x14) | (1 << 5));
  2983.                 mdio_write(tp, 0x0D, mdio_read(tp, 0x0D) & ~(1 << 5));
  2984.  
  2985.                 mdio_write(tp, 0x1F, 0x0001);
  2986.                 mdio_write(tp, 0x14, 0xCAA3);
  2987.                 mdio_write(tp, 0x1C, 0x000A);
  2988.                 mdio_write(tp, 0x18, 0x65D0);
  2989.  
  2990.                 mdio_write(tp, 0x1F, 0x0003);
  2991.                 mdio_write(tp, 0x17, 0xB580);
  2992.                 mdio_write(tp, 0x18, 0xFF54);
  2993.                 mdio_write(tp, 0x19, 0x3954);
  2994.  
  2995.                 mdio_write(tp, 0x1F, 0x0002);
  2996.                 mdio_write(tp, 0x0D, 0x310C);
  2997.                 mdio_write(tp, 0x0E, 0x310C);
  2998.                 mdio_write(tp, 0x0F, 0x311C);
  2999.                 mdio_write(tp, 0x06, 0x0761);
  3000.  
  3001.                 mdio_write(tp, 0x1F, 0x0003);
  3002.                 mdio_write(tp, 0x18, 0xFF55);
  3003.                 mdio_write(tp, 0x19, 0x3955);
  3004.                 mdio_write(tp, 0x18, 0xFF54);
  3005.                 mdio_write(tp, 0x19, 0x3954);
  3006.  
  3007.                 mdio_write(tp, 0x1F, 0x0001);
  3008.                 mdio_write(tp, 0x17, 0x0CC0);
  3009.  
  3010.                 mdio_write(tp, 0x1F, 0x0000);
  3011.                 mdio_write(tp, 0x16, mdio_read(tp, 0x16) | (1 << 0));
  3012.  
  3013.                 mdio_write(tp, 0x1F, 0x0000);
  3014.         } else if (tp->mcfg == CFG_METHOD_9) {
  3015.                 mdio_write(tp, 0x1F, 0x0001);
  3016.                 mdio_write(tp, 0x06, 0x4064);
  3017.                 mdio_write(tp, 0x07, 0x2863);
  3018.                 mdio_write(tp, 0x08, 0x059C);
  3019.                 mdio_write(tp, 0x09, 0x26B4);
  3020.                 mdio_write(tp, 0x0A, 0x6A19);
  3021.                 mdio_write(tp, 0x0B, 0xDCC8);
  3022.                 mdio_write(tp, 0x10, 0xF06D);
  3023.                 mdio_write(tp, 0x14, 0x7F68);
  3024.                 mdio_write(tp, 0x18, 0x7FD9);
  3025.                 mdio_write(tp, 0x1C, 0xF0FF);
  3026.                 mdio_write(tp, 0x1D, 0x3D9C);
  3027.                 mdio_write(tp, 0x1F, 0x0003);
  3028.                 mdio_write(tp, 0x12, 0xF49F);
  3029.                 mdio_write(tp, 0x13, 0x070B);
  3030.                 mdio_write(tp, 0x1A, 0x05AD);
  3031.                 mdio_write(tp, 0x14, 0x94C0);
  3032.  
  3033.                 mdio_write(tp, 0x1F, 0x0002);
  3034.                 gphy_val = mdio_read(tp, 0x0B) & 0xFF00;
  3035.                 gphy_val |= 0x10;
  3036.                 mdio_write(tp, 0x0B, gphy_val);
  3037.                 gphy_val = mdio_read(tp, 0x0C) & 0x00FF;
  3038.                 gphy_val |= 0xA200;
  3039.                 mdio_write(tp, 0x0C, gphy_val);
  3040.  
  3041.                 mdio_write(tp, 0x1F, 0x0002);
  3042.                 mdio_write(tp, 0x06, 0x5561);
  3043.                 mdio_write(tp, 0x1F, 0x0005);
  3044.                 mdio_write(tp, 0x05, 0x8332);
  3045.                 mdio_write(tp, 0x06, 0x5561);
  3046.  
  3047.                 if (rtl8168_efuse_read(tp, 0x01) == 0xb1) {
  3048.                         mdio_write(tp, 0x1F, 0x0002);
  3049.                         mdio_write(tp, 0x05, 0x669A);
  3050.                         mdio_write(tp, 0x1F, 0x0005);
  3051.                         mdio_write(tp, 0x05, 0x8330);
  3052.                         mdio_write(tp, 0x06, 0x669A);
  3053.  
  3054.                         mdio_write(tp, 0x1F, 0x0002);
  3055.                         gphy_val = mdio_read(tp, 0x0D);
  3056.                         if ((gphy_val & 0x00FF) != 0x006C) {
  3057.                                 gphy_val &= 0xFF00;
  3058.                                 mdio_write(tp, 0x1F, 0x0002);
  3059.                                 mdio_write(tp, 0x0D, gphy_val | 0x0065);
  3060.                                 mdio_write(tp, 0x0D, gphy_val | 0x0066);
  3061.                                 mdio_write(tp, 0x0D, gphy_val | 0x0067);
  3062.                                 mdio_write(tp, 0x0D, gphy_val | 0x0068);
  3063.                                 mdio_write(tp, 0x0D, gphy_val | 0x0069);
  3064.                                 mdio_write(tp, 0x0D, gphy_val | 0x006A);
  3065.                                 mdio_write(tp, 0x0D, gphy_val | 0x006B);
  3066.                                 mdio_write(tp, 0x0D, gphy_val | 0x006C);
  3067.                         }
  3068.                 } else {
  3069.                         mdio_write(tp, 0x1F, 0x0002);
  3070.                         mdio_write(tp, 0x05, 0x6662);
  3071.                         mdio_write(tp, 0x1F, 0x0005);
  3072.                         mdio_write(tp, 0x05, 0x8330);
  3073.                         mdio_write(tp, 0x06, 0x6662);
  3074.                 }
  3075.  
  3076.                 mdio_write(tp, 0x1F, 0x0002);
  3077.                 gphy_val = mdio_read(tp, 0x0D);
  3078.                 gphy_val |= BIT_9;
  3079.                 gphy_val |= BIT_8;
  3080.                 mdio_write(tp, 0x0D, gphy_val);
  3081.                 gphy_val = mdio_read(tp, 0x0F);
  3082.                 gphy_val |= BIT_4;
  3083.                 mdio_write(tp, 0x0F, gphy_val);
  3084.  
  3085.                 mdio_write(tp, 0x1F, 0x0002);
  3086.                 gphy_val = mdio_read(tp, 0x02);
  3087.                 gphy_val &= ~BIT_10;
  3088.                 gphy_val &= ~BIT_9;
  3089.                 gphy_val |= BIT_8;
  3090.                 mdio_write(tp, 0x02, gphy_val);
  3091.                 gphy_val = mdio_read(tp, 0x03);
  3092.                 gphy_val &= ~BIT_15;
  3093.                 gphy_val &= ~BIT_14;
  3094.                 gphy_val &= ~BIT_13;
  3095.                 mdio_write(tp, 0x03, gphy_val);
  3096.  
  3097.                 mdio_write(tp, 0x1F, 0x0001);
  3098.                 mdio_write(tp, 0x17, 0x0CC0);
  3099.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  3100.  
  3101.                 spin_lock_irqsave(&tp->phy_lock, flags);
  3102.                 mdio_write(tp, 0x1F, 0x0005);
  3103.                 mdio_write(tp, 0x05, 0x001B);
  3104.                 if (mdio_read(tp, 0x06) == 0xBF00) {
  3105.                         mdio_write(tp, 0x1f, 0x0005);
  3106.                         mdio_write(tp, 0x05, 0xfff6);
  3107.                         mdio_write(tp, 0x06, 0x0080);
  3108.                         mdio_write(tp, 0x05, 0x8000);
  3109.                         mdio_write(tp, 0x06, 0xf8f9);
  3110.                         mdio_write(tp, 0x06, 0xfaef);
  3111.                         mdio_write(tp, 0x06, 0x59ee);
  3112.                         mdio_write(tp, 0x06, 0xf8ea);
  3113.                         mdio_write(tp, 0x06, 0x00ee);
  3114.                         mdio_write(tp, 0x06, 0xf8eb);
  3115.                         mdio_write(tp, 0x06, 0x00e0);
  3116.                         mdio_write(tp, 0x06, 0xf87c);
  3117.                         mdio_write(tp, 0x06, 0xe1f8);
  3118.                         mdio_write(tp, 0x06, 0x7d59);
  3119.                         mdio_write(tp, 0x06, 0x0fef);
  3120.                         mdio_write(tp, 0x06, 0x0139);
  3121.                         mdio_write(tp, 0x06, 0x029e);
  3122.                         mdio_write(tp, 0x06, 0x06ef);
  3123.                         mdio_write(tp, 0x06, 0x1039);
  3124.                         mdio_write(tp, 0x06, 0x089f);
  3125.                         mdio_write(tp, 0x06, 0x2aee);
  3126.                         mdio_write(tp, 0x06, 0xf8ea);
  3127.                         mdio_write(tp, 0x06, 0x00ee);
  3128.                         mdio_write(tp, 0x06, 0xf8eb);
  3129.                         mdio_write(tp, 0x06, 0x01e0);
  3130.                         mdio_write(tp, 0x06, 0xf87c);
  3131.                         mdio_write(tp, 0x06, 0xe1f8);
  3132.                         mdio_write(tp, 0x06, 0x7d58);
  3133.                         mdio_write(tp, 0x06, 0x409e);
  3134.                         mdio_write(tp, 0x06, 0x0f39);
  3135.                         mdio_write(tp, 0x06, 0x46aa);
  3136.                         mdio_write(tp, 0x06, 0x0bbf);
  3137.                         mdio_write(tp, 0x06, 0x8290);
  3138.                         mdio_write(tp, 0x06, 0xd682);
  3139.                         mdio_write(tp, 0x06, 0x9802);
  3140.                         mdio_write(tp, 0x06, 0x014f);
  3141.                         mdio_write(tp, 0x06, 0xae09);
  3142.                         mdio_write(tp, 0x06, 0xbf82);
  3143.                         mdio_write(tp, 0x06, 0x98d6);
  3144.                         mdio_write(tp, 0x06, 0x82a0);
  3145.                         mdio_write(tp, 0x06, 0x0201);
  3146.                         mdio_write(tp, 0x06, 0x4fef);
  3147.                         mdio_write(tp, 0x06, 0x95fe);
  3148.                         mdio_write(tp, 0x06, 0xfdfc);
  3149.                         mdio_write(tp, 0x06, 0x05f8);
  3150.                         mdio_write(tp, 0x06, 0xf9fa);
  3151.                         mdio_write(tp, 0x06, 0xeef8);
  3152.                         mdio_write(tp, 0x06, 0xea00);
  3153.                         mdio_write(tp, 0x06, 0xeef8);
  3154.                         mdio_write(tp, 0x06, 0xeb00);
  3155.                         mdio_write(tp, 0x06, 0xe2f8);
  3156.                         mdio_write(tp, 0x06, 0x7ce3);
  3157.                         mdio_write(tp, 0x06, 0xf87d);
  3158.                         mdio_write(tp, 0x06, 0xa511);
  3159.                         mdio_write(tp, 0x06, 0x1112);
  3160.                         mdio_write(tp, 0x06, 0xd240);
  3161.                         mdio_write(tp, 0x06, 0xd644);
  3162.                         mdio_write(tp, 0x06, 0x4402);
  3163.                         mdio_write(tp, 0x06, 0x8217);
  3164.                         mdio_write(tp, 0x06, 0xd2a0);
  3165.                         mdio_write(tp, 0x06, 0xd6aa);
  3166.                         mdio_write(tp, 0x06, 0xaa02);
  3167.                         mdio_write(tp, 0x06, 0x8217);
  3168.                         mdio_write(tp, 0x06, 0xae0f);
  3169.                         mdio_write(tp, 0x06, 0xa544);
  3170.                         mdio_write(tp, 0x06, 0x4402);
  3171.                         mdio_write(tp, 0x06, 0xae4d);
  3172.                         mdio_write(tp, 0x06, 0xa5aa);
  3173.                         mdio_write(tp, 0x06, 0xaa02);
  3174.                         mdio_write(tp, 0x06, 0xae47);
  3175.                         mdio_write(tp, 0x06, 0xaf82);
  3176.                         mdio_write(tp, 0x06, 0x13ee);
  3177.                         mdio_write(tp, 0x06, 0x834e);
  3178.                         mdio_write(tp, 0x06, 0x00ee);
  3179.                         mdio_write(tp, 0x06, 0x834d);
  3180.                         mdio_write(tp, 0x06, 0x0fee);
  3181.                         mdio_write(tp, 0x06, 0x834c);
  3182.                         mdio_write(tp, 0x06, 0x0fee);
  3183.                         mdio_write(tp, 0x06, 0x834f);
  3184.                         mdio_write(tp, 0x06, 0x00ee);
  3185.                         mdio_write(tp, 0x06, 0x8351);
  3186.                         mdio_write(tp, 0x06, 0x00ee);
  3187.                         mdio_write(tp, 0x06, 0x834a);
  3188.                         mdio_write(tp, 0x06, 0xffee);
  3189.                         mdio_write(tp, 0x06, 0x834b);
  3190.                         mdio_write(tp, 0x06, 0xffe0);
  3191.                         mdio_write(tp, 0x06, 0x8330);
  3192.                         mdio_write(tp, 0x06, 0xe183);
  3193.                         mdio_write(tp, 0x06, 0x3158);
  3194.                         mdio_write(tp, 0x06, 0xfee4);
  3195.                         mdio_write(tp, 0x06, 0xf88a);
  3196.                         mdio_write(tp, 0x06, 0xe5f8);
  3197.                         mdio_write(tp, 0x06, 0x8be0);
  3198.                         mdio_write(tp, 0x06, 0x8332);
  3199.                         mdio_write(tp, 0x06, 0xe183);
  3200.                         mdio_write(tp, 0x06, 0x3359);
  3201.                         mdio_write(tp, 0x06, 0x0fe2);
  3202.                         mdio_write(tp, 0x06, 0x834d);
  3203.                         mdio_write(tp, 0x06, 0x0c24);
  3204.                         mdio_write(tp, 0x06, 0x5af0);
  3205.                         mdio_write(tp, 0x06, 0x1e12);
  3206.                         mdio_write(tp, 0x06, 0xe4f8);
  3207.                         mdio_write(tp, 0x06, 0x8ce5);
  3208.                         mdio_write(tp, 0x06, 0xf88d);
  3209.                         mdio_write(tp, 0x06, 0xaf82);
  3210.                         mdio_write(tp, 0x06, 0x13e0);
  3211.                         mdio_write(tp, 0x06, 0x834f);
  3212.                         mdio_write(tp, 0x06, 0x10e4);
  3213.                         mdio_write(tp, 0x06, 0x834f);
  3214.                         mdio_write(tp, 0x06, 0xe083);
  3215.                         mdio_write(tp, 0x06, 0x4e78);
  3216.                         mdio_write(tp, 0x06, 0x009f);
  3217.                         mdio_write(tp, 0x06, 0x0ae0);
  3218.                         mdio_write(tp, 0x06, 0x834f);
  3219.                         mdio_write(tp, 0x06, 0xa010);
  3220.                         mdio_write(tp, 0x06, 0xa5ee);
  3221.                         mdio_write(tp, 0x06, 0x834e);
  3222.                         mdio_write(tp, 0x06, 0x01e0);
  3223.                         mdio_write(tp, 0x06, 0x834e);
  3224.                         mdio_write(tp, 0x06, 0x7805);
  3225.                         mdio_write(tp, 0x06, 0x9e9a);
  3226.                         mdio_write(tp, 0x06, 0xe083);
  3227.                         mdio_write(tp, 0x06, 0x4e78);
  3228.                         mdio_write(tp, 0x06, 0x049e);
  3229.                         mdio_write(tp, 0x06, 0x10e0);
  3230.                         mdio_write(tp, 0x06, 0x834e);
  3231.                         mdio_write(tp, 0x06, 0x7803);
  3232.                         mdio_write(tp, 0x06, 0x9e0f);
  3233.                         mdio_write(tp, 0x06, 0xe083);
  3234.                         mdio_write(tp, 0x06, 0x4e78);
  3235.                         mdio_write(tp, 0x06, 0x019e);
  3236.                         mdio_write(tp, 0x06, 0x05ae);
  3237.                         mdio_write(tp, 0x06, 0x0caf);
  3238.                         mdio_write(tp, 0x06, 0x81f8);
  3239.                         mdio_write(tp, 0x06, 0xaf81);
  3240.                         mdio_write(tp, 0x06, 0xa3af);
  3241.                         mdio_write(tp, 0x06, 0x81dc);
  3242.                         mdio_write(tp, 0x06, 0xaf82);
  3243.                         mdio_write(tp, 0x06, 0x13ee);
  3244.                         mdio_write(tp, 0x06, 0x8348);
  3245.                         mdio_write(tp, 0x06, 0x00ee);
  3246.                         mdio_write(tp, 0x06, 0x8349);
  3247.                         mdio_write(tp, 0x06, 0x00e0);
  3248.                         mdio_write(tp, 0x06, 0x8351);
  3249.                         mdio_write(tp, 0x06, 0x10e4);
  3250.                         mdio_write(tp, 0x06, 0x8351);
  3251.                         mdio_write(tp, 0x06, 0x5801);
  3252.                         mdio_write(tp, 0x06, 0x9fea);
  3253.                         mdio_write(tp, 0x06, 0xd000);
  3254.                         mdio_write(tp, 0x06, 0xd180);
  3255.                         mdio_write(tp, 0x06, 0x1f66);
  3256.                         mdio_write(tp, 0x06, 0xe2f8);
  3257.                         mdio_write(tp, 0x06, 0xeae3);
  3258.                         mdio_write(tp, 0x06, 0xf8eb);
  3259.                         mdio_write(tp, 0x06, 0x5af8);
  3260.                         mdio_write(tp, 0x06, 0x1e20);
  3261.                         mdio_write(tp, 0x06, 0xe6f8);
  3262.                         mdio_write(tp, 0x06, 0xeae5);
  3263.                         mdio_write(tp, 0x06, 0xf8eb);
  3264.                         mdio_write(tp, 0x06, 0xd302);
  3265.                         mdio_write(tp, 0x06, 0xb3fe);
  3266.                         mdio_write(tp, 0x06, 0xe2f8);
  3267.                         mdio_write(tp, 0x06, 0x7cef);
  3268.                         mdio_write(tp, 0x06, 0x325b);
  3269.                         mdio_write(tp, 0x06, 0x80e3);
  3270.                         mdio_write(tp, 0x06, 0xf87d);
  3271.                         mdio_write(tp, 0x06, 0x9e03);
  3272.                         mdio_write(tp, 0x06, 0x7dff);
  3273.                         mdio_write(tp, 0x06, 0xff0d);
  3274.                         mdio_write(tp, 0x06, 0x581c);
  3275.                         mdio_write(tp, 0x06, 0x551a);
  3276.                         mdio_write(tp, 0x06, 0x6511);
  3277.                         mdio_write(tp, 0x06, 0xa190);
  3278.                         mdio_write(tp, 0x06, 0xd3e2);
  3279.                         mdio_write(tp, 0x06, 0x8348);
  3280.                         mdio_write(tp, 0x06, 0xe383);
  3281.                         mdio_write(tp, 0x06, 0x491b);
  3282.                         mdio_write(tp, 0x06, 0x56ab);
  3283.                         mdio_write(tp, 0x06, 0x08ef);
  3284.                         mdio_write(tp, 0x06, 0x56e6);
  3285.                         mdio_write(tp, 0x06, 0x8348);
  3286.                         mdio_write(tp, 0x06, 0xe783);
  3287.                         mdio_write(tp, 0x06, 0x4910);
  3288.                         mdio_write(tp, 0x06, 0xd180);
  3289.                         mdio_write(tp, 0x06, 0x1f66);
  3290.                         mdio_write(tp, 0x06, 0xa004);
  3291.                         mdio_write(tp, 0x06, 0xb9e2);
  3292.                         mdio_write(tp, 0x06, 0x8348);
  3293.                         mdio_write(tp, 0x06, 0xe383);
  3294.                         mdio_write(tp, 0x06, 0x49ef);
  3295.                         mdio_write(tp, 0x06, 0x65e2);
  3296.                         mdio_write(tp, 0x06, 0x834a);
  3297.                         mdio_write(tp, 0x06, 0xe383);
  3298.                         mdio_write(tp, 0x06, 0x4b1b);
  3299.                         mdio_write(tp, 0x06, 0x56aa);
  3300.                         mdio_write(tp, 0x06, 0x0eef);
  3301.                         mdio_write(tp, 0x06, 0x56e6);
  3302.                         mdio_write(tp, 0x06, 0x834a);
  3303.                         mdio_write(tp, 0x06, 0xe783);
  3304.                         mdio_write(tp, 0x06, 0x4be2);
  3305.                         mdio_write(tp, 0x06, 0x834d);
  3306.                         mdio_write(tp, 0x06, 0xe683);
  3307.                         mdio_write(tp, 0x06, 0x4ce0);
  3308.                         mdio_write(tp, 0x06, 0x834d);
  3309.                         mdio_write(tp, 0x06, 0xa000);
  3310.                         mdio_write(tp, 0x06, 0x0caf);
  3311.                         mdio_write(tp, 0x06, 0x81dc);
  3312.                         mdio_write(tp, 0x06, 0xe083);
  3313.                         mdio_write(tp, 0x06, 0x4d10);
  3314.                         mdio_write(tp, 0x06, 0xe483);
  3315.                         mdio_write(tp, 0x06, 0x4dae);
  3316.                         mdio_write(tp, 0x06, 0x0480);
  3317.                         mdio_write(tp, 0x06, 0xe483);
  3318.                         mdio_write(tp, 0x06, 0x4de0);
  3319.                         mdio_write(tp, 0x06, 0x834e);
  3320.                         mdio_write(tp, 0x06, 0x7803);
  3321.                         mdio_write(tp, 0x06, 0x9e0b);
  3322.                         mdio_write(tp, 0x06, 0xe083);
  3323.                         mdio_write(tp, 0x06, 0x4e78);
  3324.                         mdio_write(tp, 0x06, 0x049e);
  3325.                         mdio_write(tp, 0x06, 0x04ee);
  3326.                         mdio_write(tp, 0x06, 0x834e);
  3327.                         mdio_write(tp, 0x06, 0x02e0);
  3328.                         mdio_write(tp, 0x06, 0x8332);
  3329.                         mdio_write(tp, 0x06, 0xe183);
  3330.                         mdio_write(tp, 0x06, 0x3359);
  3331.                         mdio_write(tp, 0x06, 0x0fe2);
  3332.                         mdio_write(tp, 0x06, 0x834d);
  3333.                         mdio_write(tp, 0x06, 0x0c24);
  3334.                         mdio_write(tp, 0x06, 0x5af0);
  3335.                         mdio_write(tp, 0x06, 0x1e12);
  3336.                         mdio_write(tp, 0x06, 0xe4f8);
  3337.                         mdio_write(tp, 0x06, 0x8ce5);
  3338.                         mdio_write(tp, 0x06, 0xf88d);
  3339.                         mdio_write(tp, 0x06, 0xe083);
  3340.                         mdio_write(tp, 0x06, 0x30e1);
  3341.                         mdio_write(tp, 0x06, 0x8331);
  3342.                         mdio_write(tp, 0x06, 0x6801);
  3343.                         mdio_write(tp, 0x06, 0xe4f8);
  3344.                         mdio_write(tp, 0x06, 0x8ae5);
  3345.                         mdio_write(tp, 0x06, 0xf88b);
  3346.                         mdio_write(tp, 0x06, 0xae37);
  3347.                         mdio_write(tp, 0x06, 0xee83);
  3348.                         mdio_write(tp, 0x06, 0x4e03);
  3349.                         mdio_write(tp, 0x06, 0xe083);
  3350.                         mdio_write(tp, 0x06, 0x4ce1);
  3351.                         mdio_write(tp, 0x06, 0x834d);
  3352.                         mdio_write(tp, 0x06, 0x1b01);
  3353.                         mdio_write(tp, 0x06, 0x9e04);
  3354.                         mdio_write(tp, 0x06, 0xaaa1);
  3355.                         mdio_write(tp, 0x06, 0xaea8);
  3356.                         mdio_write(tp, 0x06, 0xee83);
  3357.                         mdio_write(tp, 0x06, 0x4e04);
  3358.                         mdio_write(tp, 0x06, 0xee83);
  3359.                         mdio_write(tp, 0x06, 0x4f00);
  3360.                         mdio_write(tp, 0x06, 0xaeab);
  3361.                         mdio_write(tp, 0x06, 0xe083);
  3362.                         mdio_write(tp, 0x06, 0x4f78);
  3363.                         mdio_write(tp, 0x06, 0x039f);
  3364.                         mdio_write(tp, 0x06, 0x14ee);
  3365.                         mdio_write(tp, 0x06, 0x834e);
  3366.                         mdio_write(tp, 0x06, 0x05d2);
  3367.                         mdio_write(tp, 0x06, 0x40d6);
  3368.                         mdio_write(tp, 0x06, 0x5554);
  3369.                         mdio_write(tp, 0x06, 0x0282);
  3370.                         mdio_write(tp, 0x06, 0x17d2);
  3371.                         mdio_write(tp, 0x06, 0xa0d6);
  3372.                         mdio_write(tp, 0x06, 0xba00);
  3373.                         mdio_write(tp, 0x06, 0x0282);
  3374.                         mdio_write(tp, 0x06, 0x17fe);
  3375.                         mdio_write(tp, 0x06, 0xfdfc);
  3376.                         mdio_write(tp, 0x06, 0x05f8);
  3377.                         mdio_write(tp, 0x06, 0xe0f8);
  3378.                         mdio_write(tp, 0x06, 0x60e1);
  3379.                         mdio_write(tp, 0x06, 0xf861);
  3380.                         mdio_write(tp, 0x06, 0x6802);
  3381.                         mdio_write(tp, 0x06, 0xe4f8);
  3382.                         mdio_write(tp, 0x06, 0x60e5);
  3383.                         mdio_write(tp, 0x06, 0xf861);
  3384.                         mdio_write(tp, 0x06, 0xe0f8);
  3385.                         mdio_write(tp, 0x06, 0x48e1);
  3386.                         mdio_write(tp, 0x06, 0xf849);
  3387.                         mdio_write(tp, 0x06, 0x580f);
  3388.                         mdio_write(tp, 0x06, 0x1e02);
  3389.                         mdio_write(tp, 0x06, 0xe4f8);
  3390.                         mdio_write(tp, 0x06, 0x48e5);
  3391.                         mdio_write(tp, 0x06, 0xf849);
  3392.                         mdio_write(tp, 0x06, 0xd000);
  3393.                         mdio_write(tp, 0x06, 0x0282);
  3394.                         mdio_write(tp, 0x06, 0x5bbf);
  3395.                         mdio_write(tp, 0x06, 0x8350);
  3396.                         mdio_write(tp, 0x06, 0xef46);
  3397.                         mdio_write(tp, 0x06, 0xdc19);
  3398.                         mdio_write(tp, 0x06, 0xddd0);
  3399.                         mdio_write(tp, 0x06, 0x0102);
  3400.                         mdio_write(tp, 0x06, 0x825b);
  3401.                         mdio_write(tp, 0x06, 0x0282);
  3402.                         mdio_write(tp, 0x06, 0x77e0);
  3403.                         mdio_write(tp, 0x06, 0xf860);
  3404.                         mdio_write(tp, 0x06, 0xe1f8);
  3405.                         mdio_write(tp, 0x06, 0x6158);
  3406.                         mdio_write(tp, 0x06, 0xfde4);
  3407.                         mdio_write(tp, 0x06, 0xf860);
  3408.                         mdio_write(tp, 0x06, 0xe5f8);
  3409.                         mdio_write(tp, 0x06, 0x61fc);
  3410.                         mdio_write(tp, 0x06, 0x04f9);
  3411.                         mdio_write(tp, 0x06, 0xfafb);
  3412.                         mdio_write(tp, 0x06, 0xc6bf);
  3413.                         mdio_write(tp, 0x06, 0xf840);
  3414.                         mdio_write(tp, 0x06, 0xbe83);
  3415.                         mdio_write(tp, 0x06, 0x50a0);
  3416.                         mdio_write(tp, 0x06, 0x0101);
  3417.                         mdio_write(tp, 0x06, 0x071b);
  3418.                         mdio_write(tp, 0x06, 0x89cf);
  3419.                         mdio_write(tp, 0x06, 0xd208);
  3420.                         mdio_write(tp, 0x06, 0xebdb);
  3421.                         mdio_write(tp, 0x06, 0x19b2);
  3422.                         mdio_write(tp, 0x06, 0xfbff);
  3423.                         mdio_write(tp, 0x06, 0xfefd);
  3424.                         mdio_write(tp, 0x06, 0x04f8);
  3425.                         mdio_write(tp, 0x06, 0xe0f8);
  3426.                         mdio_write(tp, 0x06, 0x48e1);
  3427.                         mdio_write(tp, 0x06, 0xf849);
  3428.                         mdio_write(tp, 0x06, 0x6808);
  3429.                         mdio_write(tp, 0x06, 0xe4f8);
  3430.                         mdio_write(tp, 0x06, 0x48e5);
  3431.                         mdio_write(tp, 0x06, 0xf849);
  3432.                         mdio_write(tp, 0x06, 0x58f7);
  3433.                         mdio_write(tp, 0x06, 0xe4f8);
  3434.                         mdio_write(tp, 0x06, 0x48e5);
  3435.                         mdio_write(tp, 0x06, 0xf849);
  3436.                         mdio_write(tp, 0x06, 0xfc04);
  3437.                         mdio_write(tp, 0x06, 0x4d20);
  3438.                         mdio_write(tp, 0x06, 0x0002);
  3439.                         mdio_write(tp, 0x06, 0x4e22);
  3440.                         mdio_write(tp, 0x06, 0x0002);
  3441.                         mdio_write(tp, 0x06, 0x4ddf);
  3442.                         mdio_write(tp, 0x06, 0xff01);
  3443.                         mdio_write(tp, 0x06, 0x4edd);
  3444.                         mdio_write(tp, 0x06, 0xff01);
  3445.                         mdio_write(tp, 0x06, 0xf8fa);
  3446.                         mdio_write(tp, 0x06, 0xfbef);
  3447.                         mdio_write(tp, 0x06, 0x79bf);
  3448.                         mdio_write(tp, 0x06, 0xf822);
  3449.                         mdio_write(tp, 0x06, 0xd819);
  3450.                         mdio_write(tp, 0x06, 0xd958);
  3451.                         mdio_write(tp, 0x06, 0x849f);
  3452.                         mdio_write(tp, 0x06, 0x09bf);
  3453.                         mdio_write(tp, 0x06, 0x82be);
  3454.                         mdio_write(tp, 0x06, 0xd682);
  3455.                         mdio_write(tp, 0x06, 0xc602);
  3456.                         mdio_write(tp, 0x06, 0x014f);
  3457.                         mdio_write(tp, 0x06, 0xef97);
  3458.                         mdio_write(tp, 0x06, 0xfffe);
  3459.                         mdio_write(tp, 0x06, 0xfc05);
  3460.                         mdio_write(tp, 0x06, 0x17ff);
  3461.                         mdio_write(tp, 0x06, 0xfe01);
  3462.                         mdio_write(tp, 0x06, 0x1700);
  3463.                         mdio_write(tp, 0x06, 0x0102);
  3464.                         mdio_write(tp, 0x05, 0x83d8);
  3465.                         mdio_write(tp, 0x06, 0x8051);
  3466.                         mdio_write(tp, 0x05, 0x83d6);
  3467.                         mdio_write(tp, 0x06, 0x82a0);
  3468.                         mdio_write(tp, 0x05, 0x83d4);
  3469.                         mdio_write(tp, 0x06, 0x8000);
  3470.                         mdio_write(tp, 0x02, 0x2010);
  3471.                         mdio_write(tp, 0x03, 0xdc00);
  3472.                         mdio_write(tp, 0x1f, 0x0000);
  3473.                         mdio_write(tp, 0x0b, 0x0600);
  3474.                         mdio_write(tp, 0x1f, 0x0005);
  3475.                         mdio_write(tp, 0x05, 0xfff6);
  3476.                         mdio_write(tp, 0x06, 0x00fc);
  3477.                         mdio_write(tp, 0x1f, 0x0000);
  3478.                 }
  3479.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  3480.  
  3481.                 spin_lock_irqsave(&tp->phy_lock, flags);
  3482.                 mdio_write(tp, 0x1F, 0x0000);
  3483.                 mdio_write(tp, 0x0D, 0xF880);
  3484.                 mdio_write(tp, 0x1F, 0x0000);
  3485.         } else if (tp->mcfg == CFG_METHOD_10) {
  3486.                 mdio_write(tp, 0x1F, 0x0001);
  3487.                 mdio_write(tp, 0x06, 0x4064);
  3488.                 mdio_write(tp, 0x07, 0x2863);
  3489.                 mdio_write(tp, 0x08, 0x059C);
  3490.                 mdio_write(tp, 0x09, 0x26B4);
  3491.                 mdio_write(tp, 0x0A, 0x6A19);
  3492.                 mdio_write(tp, 0x0B, 0xDCC8);
  3493.                 mdio_write(tp, 0x10, 0xF06D);
  3494.                 mdio_write(tp, 0x14, 0x7F68);
  3495.                 mdio_write(tp, 0x18, 0x7FD9);
  3496.                 mdio_write(tp, 0x1C, 0xF0FF);
  3497.                 mdio_write(tp, 0x1D, 0x3D9C);
  3498.                 mdio_write(tp, 0x1F, 0x0003);
  3499.                 mdio_write(tp, 0x12, 0xF49F);
  3500.                 mdio_write(tp, 0x13, 0x070B);
  3501.                 mdio_write(tp, 0x1A, 0x05AD);
  3502.                 mdio_write(tp, 0x14, 0x94C0);
  3503.  
  3504.                 mdio_write(tp, 0x1F, 0x0002);
  3505.                 mdio_write(tp, 0x06, 0x5561);
  3506.                 mdio_write(tp, 0x1F, 0x0005);
  3507.                 mdio_write(tp, 0x05, 0x8332);
  3508.                 mdio_write(tp, 0x06, 0x5561);
  3509.  
  3510.                 if (rtl8168_efuse_read(tp, 0x01) == 0xb1) {
  3511.                         mdio_write(tp, 0x1F, 0x0002);
  3512.                         mdio_write(tp, 0x05, 0x669A);
  3513.                         mdio_write(tp, 0x1F, 0x0005);
  3514.                         mdio_write(tp, 0x05, 0x8330);
  3515.                         mdio_write(tp, 0x06, 0x669A);
  3516.  
  3517.                         mdio_write(tp, 0x1F, 0x0002);
  3518.                         gphy_val = mdio_read(tp, 0x0D);
  3519.                         if ((gphy_val & 0x00FF) != 0x006C) {
  3520.                                 gphy_val &= 0xFF00;
  3521.                                 mdio_write(tp, 0x1F, 0x0002);
  3522.                                 mdio_write(tp, 0x0D, gphy_val | 0x0065);
  3523.                                 mdio_write(tp, 0x0D, gphy_val | 0x0066);
  3524.                                 mdio_write(tp, 0x0D, gphy_val | 0x0067);
  3525.                                 mdio_write(tp, 0x0D, gphy_val | 0x0068);
  3526.                                 mdio_write(tp, 0x0D, gphy_val | 0x0069);
  3527.                                 mdio_write(tp, 0x0D, gphy_val | 0x006A);
  3528.                                 mdio_write(tp, 0x0D, gphy_val | 0x006B);
  3529.                                 mdio_write(tp, 0x0D, gphy_val | 0x006C);
  3530.                         }
  3531.                 } else {
  3532.                         mdio_write(tp, 0x1F, 0x0002);
  3533.                         mdio_write(tp, 0x05, 0x2642);
  3534.                         mdio_write(tp, 0x1F, 0x0005);
  3535.                         mdio_write(tp, 0x05, 0x8330);
  3536.                         mdio_write(tp, 0x06, 0x2642);
  3537.                 }
  3538.  
  3539.                 if (rtl8168_efuse_read(tp, 0x30) == 0x98) {
  3540.                         mdio_write(tp, 0x1F, 0x0000);
  3541.                         mdio_write(tp, 0x11, mdio_read(tp, 0x11) & ~BIT_1);
  3542.                         mdio_write(tp, 0x1F, 0x0005);
  3543.                         mdio_write(tp, 0x01, mdio_read(tp, 0x01) | BIT_9);
  3544.                 } else if (rtl8168_efuse_read(tp, 0x30) == 0x90) {
  3545.                         mdio_write(tp, 0x1F, 0x0005);
  3546.                         mdio_write(tp, 0x01, mdio_read(tp, 0x01) & ~BIT_9);
  3547.                         mdio_write(tp, 0x1F, 0x0000);
  3548.                         mdio_write(tp, 0x16, 0x5101);
  3549.                 }
  3550.  
  3551.                 mdio_write(tp, 0x1F, 0x0002);
  3552.                 gphy_val = mdio_read(tp, 0x02);
  3553.                 gphy_val &= ~BIT_10;
  3554.                 gphy_val &= ~BIT_9;
  3555.                 gphy_val |= BIT_8;
  3556.                 mdio_write(tp, 0x02, gphy_val);
  3557.                 gphy_val = mdio_read(tp, 0x03);
  3558.                 gphy_val &= ~BIT_15;
  3559.                 gphy_val &= ~BIT_14;
  3560.                 gphy_val &= ~BIT_13;
  3561.                 mdio_write(tp, 0x03, gphy_val);
  3562.  
  3563.                 mdio_write(tp, 0x1F, 0x0001);
  3564.                 mdio_write(tp, 0x17, 0x0CC0);
  3565.  
  3566.                 mdio_write(tp, 0x1F, 0x0002);
  3567.                 gphy_val = mdio_read(tp, 0x0F);
  3568.                 gphy_val |= BIT_4;
  3569.                 gphy_val |= BIT_2;
  3570.                 gphy_val |= BIT_1;
  3571.                 gphy_val |= BIT_0;
  3572.                 mdio_write(tp, 0x0F, gphy_val);
  3573.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  3574.  
  3575.                 spin_lock_irqsave(&tp->phy_lock, flags);
  3576.                 mdio_write(tp, 0x1F, 0x0005);
  3577.                 mdio_write(tp, 0x05, 0x001B);
  3578.                 if (mdio_read(tp, 0x06) == 0xB300) {
  3579.                         mdio_write(tp, 0x1f, 0x0005);
  3580.                         mdio_write(tp, 0x05, 0xfff6);
  3581.                         mdio_write(tp, 0x06, 0x0080);
  3582.                         mdio_write(tp, 0x05, 0x8000);
  3583.                         mdio_write(tp, 0x06, 0xf8f9);
  3584.                         mdio_write(tp, 0x06, 0xfaee);
  3585.                         mdio_write(tp, 0x06, 0xf8ea);
  3586.                         mdio_write(tp, 0x06, 0x00ee);
  3587.                         mdio_write(tp, 0x06, 0xf8eb);
  3588.                         mdio_write(tp, 0x06, 0x00e2);
  3589.                         mdio_write(tp, 0x06, 0xf87c);
  3590.                         mdio_write(tp, 0x06, 0xe3f8);
  3591.                         mdio_write(tp, 0x06, 0x7da5);
  3592.                         mdio_write(tp, 0x06, 0x1111);
  3593.                         mdio_write(tp, 0x06, 0x12d2);
  3594.                         mdio_write(tp, 0x06, 0x40d6);
  3595.                         mdio_write(tp, 0x06, 0x4444);
  3596.                         mdio_write(tp, 0x06, 0x0281);
  3597.                         mdio_write(tp, 0x06, 0xc6d2);
  3598.                         mdio_write(tp, 0x06, 0xa0d6);
  3599.                         mdio_write(tp, 0x06, 0xaaaa);
  3600.                         mdio_write(tp, 0x06, 0x0281);
  3601.                         mdio_write(tp, 0x06, 0xc6ae);
  3602.                         mdio_write(tp, 0x06, 0x0fa5);
  3603.                         mdio_write(tp, 0x06, 0x4444);
  3604.                         mdio_write(tp, 0x06, 0x02ae);
  3605.                         mdio_write(tp, 0x06, 0x4da5);
  3606.                         mdio_write(tp, 0x06, 0xaaaa);
  3607.                         mdio_write(tp, 0x06, 0x02ae);
  3608.                         mdio_write(tp, 0x06, 0x47af);
  3609.                         mdio_write(tp, 0x06, 0x81c2);
  3610.                         mdio_write(tp, 0x06, 0xee83);
  3611.                         mdio_write(tp, 0x06, 0x4e00);
  3612.                         mdio_write(tp, 0x06, 0xee83);
  3613.                         mdio_write(tp, 0x06, 0x4d0f);
  3614.                         mdio_write(tp, 0x06, 0xee83);
  3615.                         mdio_write(tp, 0x06, 0x4c0f);
  3616.                         mdio_write(tp, 0x06, 0xee83);
  3617.                         mdio_write(tp, 0x06, 0x4f00);
  3618.                         mdio_write(tp, 0x06, 0xee83);
  3619.                         mdio_write(tp, 0x06, 0x5100);
  3620.                         mdio_write(tp, 0x06, 0xee83);
  3621.                         mdio_write(tp, 0x06, 0x4aff);
  3622.                         mdio_write(tp, 0x06, 0xee83);
  3623.                         mdio_write(tp, 0x06, 0x4bff);
  3624.                         mdio_write(tp, 0x06, 0xe083);
  3625.                         mdio_write(tp, 0x06, 0x30e1);
  3626.                         mdio_write(tp, 0x06, 0x8331);
  3627.                         mdio_write(tp, 0x06, 0x58fe);
  3628.                         mdio_write(tp, 0x06, 0xe4f8);
  3629.                         mdio_write(tp, 0x06, 0x8ae5);
  3630.                         mdio_write(tp, 0x06, 0xf88b);
  3631.                         mdio_write(tp, 0x06, 0xe083);
  3632.                         mdio_write(tp, 0x06, 0x32e1);
  3633.                         mdio_write(tp, 0x06, 0x8333);
  3634.                         mdio_write(tp, 0x06, 0x590f);
  3635.                         mdio_write(tp, 0x06, 0xe283);
  3636.                         mdio_write(tp, 0x06, 0x4d0c);
  3637.                         mdio_write(tp, 0x06, 0x245a);
  3638.                         mdio_write(tp, 0x06, 0xf01e);
  3639.                         mdio_write(tp, 0x06, 0x12e4);
  3640.                         mdio_write(tp, 0x06, 0xf88c);
  3641.                         mdio_write(tp, 0x06, 0xe5f8);
  3642.                         mdio_write(tp, 0x06, 0x8daf);
  3643.                         mdio_write(tp, 0x06, 0x81c2);
  3644.                         mdio_write(tp, 0x06, 0xe083);
  3645.                         mdio_write(tp, 0x06, 0x4f10);
  3646.                         mdio_write(tp, 0x06, 0xe483);
  3647.                         mdio_write(tp, 0x06, 0x4fe0);
  3648.                         mdio_write(tp, 0x06, 0x834e);
  3649.                         mdio_write(tp, 0x06, 0x7800);
  3650.                         mdio_write(tp, 0x06, 0x9f0a);
  3651.                         mdio_write(tp, 0x06, 0xe083);
  3652.                         mdio_write(tp, 0x06, 0x4fa0);
  3653.                         mdio_write(tp, 0x06, 0x10a5);
  3654.                         mdio_write(tp, 0x06, 0xee83);
  3655.                         mdio_write(tp, 0x06, 0x4e01);
  3656.                         mdio_write(tp, 0x06, 0xe083);
  3657.                         mdio_write(tp, 0x06, 0x4e78);
  3658.                         mdio_write(tp, 0x06, 0x059e);
  3659.                         mdio_write(tp, 0x06, 0x9ae0);
  3660.                         mdio_write(tp, 0x06, 0x834e);
  3661.                         mdio_write(tp, 0x06, 0x7804);
  3662.                         mdio_write(tp, 0x06, 0x9e10);
  3663.                         mdio_write(tp, 0x06, 0xe083);
  3664.                         mdio_write(tp, 0x06, 0x4e78);
  3665.                         mdio_write(tp, 0x06, 0x039e);
  3666.                         mdio_write(tp, 0x06, 0x0fe0);
  3667.                         mdio_write(tp, 0x06, 0x834e);
  3668.                         mdio_write(tp, 0x06, 0x7801);
  3669.                         mdio_write(tp, 0x06, 0x9e05);
  3670.                         mdio_write(tp, 0x06, 0xae0c);
  3671.                         mdio_write(tp, 0x06, 0xaf81);
  3672.                         mdio_write(tp, 0x06, 0xa7af);
  3673.                         mdio_write(tp, 0x06, 0x8152);
  3674.                         mdio_write(tp, 0x06, 0xaf81);
  3675.                         mdio_write(tp, 0x06, 0x8baf);
  3676.                         mdio_write(tp, 0x06, 0x81c2);
  3677.                         mdio_write(tp, 0x06, 0xee83);
  3678.                         mdio_write(tp, 0x06, 0x4800);
  3679.                         mdio_write(tp, 0x06, 0xee83);
  3680.                         mdio_write(tp, 0x06, 0x4900);
  3681.                         mdio_write(tp, 0x06, 0xe083);
  3682.                         mdio_write(tp, 0x06, 0x5110);
  3683.                         mdio_write(tp, 0x06, 0xe483);
  3684.                         mdio_write(tp, 0x06, 0x5158);
  3685.                         mdio_write(tp, 0x06, 0x019f);
  3686.                         mdio_write(tp, 0x06, 0xead0);
  3687.                         mdio_write(tp, 0x06, 0x00d1);
  3688.                         mdio_write(tp, 0x06, 0x801f);
  3689.                         mdio_write(tp, 0x06, 0x66e2);
  3690.                         mdio_write(tp, 0x06, 0xf8ea);
  3691.                         mdio_write(tp, 0x06, 0xe3f8);
  3692.                         mdio_write(tp, 0x06, 0xeb5a);
  3693.                         mdio_write(tp, 0x06, 0xf81e);
  3694.                         mdio_write(tp, 0x06, 0x20e6);
  3695.                         mdio_write(tp, 0x06, 0xf8ea);
  3696.                         mdio_write(tp, 0x06, 0xe5f8);
  3697.                         mdio_write(tp, 0x06, 0xebd3);
  3698.                         mdio_write(tp, 0x06, 0x02b3);
  3699.                         mdio_write(tp, 0x06, 0xfee2);
  3700.                         mdio_write(tp, 0x06, 0xf87c);
  3701.                         mdio_write(tp, 0x06, 0xef32);
  3702.                         mdio_write(tp, 0x06, 0x5b80);
  3703.                         mdio_write(tp, 0x06, 0xe3f8);
  3704.                         mdio_write(tp, 0x06, 0x7d9e);
  3705.                         mdio_write(tp, 0x06, 0x037d);
  3706.                         mdio_write(tp, 0x06, 0xffff);
  3707.                         mdio_write(tp, 0x06, 0x0d58);
  3708.                         mdio_write(tp, 0x06, 0x1c55);
  3709.                         mdio_write(tp, 0x06, 0x1a65);
  3710.                         mdio_write(tp, 0x06, 0x11a1);
  3711.                         mdio_write(tp, 0x06, 0x90d3);
  3712.                         mdio_write(tp, 0x06, 0xe283);
  3713.                         mdio_write(tp, 0x06, 0x48e3);
  3714.                         mdio_write(tp, 0x06, 0x8349);
  3715.                         mdio_write(tp, 0x06, 0x1b56);
  3716.                         mdio_write(tp, 0x06, 0xab08);
  3717.                         mdio_write(tp, 0x06, 0xef56);
  3718.                         mdio_write(tp, 0x06, 0xe683);
  3719.                         mdio_write(tp, 0x06, 0x48e7);
  3720.                         mdio_write(tp, 0x06, 0x8349);
  3721.                         mdio_write(tp, 0x06, 0x10d1);
  3722.                         mdio_write(tp, 0x06, 0x801f);
  3723.                         mdio_write(tp, 0x06, 0x66a0);
  3724.                         mdio_write(tp, 0x06, 0x04b9);
  3725.                         mdio_write(tp, 0x06, 0xe283);
  3726.                         mdio_write(tp, 0x06, 0x48e3);
  3727.                         mdio_write(tp, 0x06, 0x8349);
  3728.                         mdio_write(tp, 0x06, 0xef65);
  3729.                         mdio_write(tp, 0x06, 0xe283);
  3730.                         mdio_write(tp, 0x06, 0x4ae3);
  3731.                         mdio_write(tp, 0x06, 0x834b);
  3732.                         mdio_write(tp, 0x06, 0x1b56);
  3733.                         mdio_write(tp, 0x06, 0xaa0e);
  3734.                         mdio_write(tp, 0x06, 0xef56);
  3735.                         mdio_write(tp, 0x06, 0xe683);
  3736.                         mdio_write(tp, 0x06, 0x4ae7);
  3737.                         mdio_write(tp, 0x06, 0x834b);
  3738.                         mdio_write(tp, 0x06, 0xe283);
  3739.                         mdio_write(tp, 0x06, 0x4de6);
  3740.                         mdio_write(tp, 0x06, 0x834c);
  3741.                         mdio_write(tp, 0x06, 0xe083);
  3742.                         mdio_write(tp, 0x06, 0x4da0);
  3743.                         mdio_write(tp, 0x06, 0x000c);
  3744.                         mdio_write(tp, 0x06, 0xaf81);
  3745.                         mdio_write(tp, 0x06, 0x8be0);
  3746.                         mdio_write(tp, 0x06, 0x834d);
  3747.                         mdio_write(tp, 0x06, 0x10e4);
  3748.                         mdio_write(tp, 0x06, 0x834d);
  3749.                         mdio_write(tp, 0x06, 0xae04);
  3750.                         mdio_write(tp, 0x06, 0x80e4);
  3751.                         mdio_write(tp, 0x06, 0x834d);
  3752.                         mdio_write(tp, 0x06, 0xe083);
  3753.                         mdio_write(tp, 0x06, 0x4e78);
  3754.                         mdio_write(tp, 0x06, 0x039e);
  3755.                         mdio_write(tp, 0x06, 0x0be0);
  3756.                         mdio_write(tp, 0x06, 0x834e);
  3757.                         mdio_write(tp, 0x06, 0x7804);
  3758.                         mdio_write(tp, 0x06, 0x9e04);
  3759.                         mdio_write(tp, 0x06, 0xee83);
  3760.                         mdio_write(tp, 0x06, 0x4e02);
  3761.                         mdio_write(tp, 0x06, 0xe083);
  3762.                         mdio_write(tp, 0x06, 0x32e1);
  3763.                         mdio_write(tp, 0x06, 0x8333);
  3764.                         mdio_write(tp, 0x06, 0x590f);
  3765.                         mdio_write(tp, 0x06, 0xe283);
  3766.                         mdio_write(tp, 0x06, 0x4d0c);
  3767.                         mdio_write(tp, 0x06, 0x245a);
  3768.                         mdio_write(tp, 0x06, 0xf01e);
  3769.                         mdio_write(tp, 0x06, 0x12e4);
  3770.                         mdio_write(tp, 0x06, 0xf88c);
  3771.                         mdio_write(tp, 0x06, 0xe5f8);
  3772.                         mdio_write(tp, 0x06, 0x8de0);
  3773.                         mdio_write(tp, 0x06, 0x8330);
  3774.                         mdio_write(tp, 0x06, 0xe183);
  3775.                         mdio_write(tp, 0x06, 0x3168);
  3776.                         mdio_write(tp, 0x06, 0x01e4);
  3777.                         mdio_write(tp, 0x06, 0xf88a);
  3778.                         mdio_write(tp, 0x06, 0xe5f8);
  3779.                         mdio_write(tp, 0x06, 0x8bae);
  3780.                         mdio_write(tp, 0x06, 0x37ee);
  3781.                         mdio_write(tp, 0x06, 0x834e);
  3782.                         mdio_write(tp, 0x06, 0x03e0);
  3783.                         mdio_write(tp, 0x06, 0x834c);
  3784.                         mdio_write(tp, 0x06, 0xe183);
  3785.                         mdio_write(tp, 0x06, 0x4d1b);
  3786.                         mdio_write(tp, 0x06, 0x019e);
  3787.                         mdio_write(tp, 0x06, 0x04aa);
  3788.                         mdio_write(tp, 0x06, 0xa1ae);
  3789.                         mdio_write(tp, 0x06, 0xa8ee);
  3790.                         mdio_write(tp, 0x06, 0x834e);
  3791.                         mdio_write(tp, 0x06, 0x04ee);
  3792.                         mdio_write(tp, 0x06, 0x834f);
  3793.                         mdio_write(tp, 0x06, 0x00ae);
  3794.                         mdio_write(tp, 0x06, 0xabe0);
  3795.                         mdio_write(tp, 0x06, 0x834f);
  3796.                         mdio_write(tp, 0x06, 0x7803);
  3797.                         mdio_write(tp, 0x06, 0x9f14);
  3798.                         mdio_write(tp, 0x06, 0xee83);
  3799.                         mdio_write(tp, 0x06, 0x4e05);
  3800.                         mdio_write(tp, 0x06, 0xd240);
  3801.                         mdio_write(tp, 0x06, 0xd655);
  3802.                         mdio_write(tp, 0x06, 0x5402);
  3803.                         mdio_write(tp, 0x06, 0x81c6);
  3804.                         mdio_write(tp, 0x06, 0xd2a0);
  3805.                         mdio_write(tp, 0x06, 0xd6ba);
  3806.                         mdio_write(tp, 0x06, 0x0002);
  3807.                         mdio_write(tp, 0x06, 0x81c6);
  3808.                         mdio_write(tp, 0x06, 0xfefd);
  3809.                         mdio_write(tp, 0x06, 0xfc05);
  3810.                         mdio_write(tp, 0x06, 0xf8e0);
  3811.                         mdio_write(tp, 0x06, 0xf860);
  3812.                         mdio_write(tp, 0x06, 0xe1f8);
  3813.                         mdio_write(tp, 0x06, 0x6168);
  3814.                         mdio_write(tp, 0x06, 0x02e4);
  3815.                         mdio_write(tp, 0x06, 0xf860);
  3816.                         mdio_write(tp, 0x06, 0xe5f8);
  3817.                         mdio_write(tp, 0x06, 0x61e0);
  3818.                         mdio_write(tp, 0x06, 0xf848);
  3819.                         mdio_write(tp, 0x06, 0xe1f8);
  3820.                         mdio_write(tp, 0x06, 0x4958);
  3821.                         mdio_write(tp, 0x06, 0x0f1e);
  3822.                         mdio_write(tp, 0x06, 0x02e4);
  3823.                         mdio_write(tp, 0x06, 0xf848);
  3824.                         mdio_write(tp, 0x06, 0xe5f8);
  3825.                         mdio_write(tp, 0x06, 0x49d0);
  3826.                         mdio_write(tp, 0x06, 0x0002);
  3827.                         mdio_write(tp, 0x06, 0x820a);
  3828.                         mdio_write(tp, 0x06, 0xbf83);
  3829.                         mdio_write(tp, 0x06, 0x50ef);
  3830.                         mdio_write(tp, 0x06, 0x46dc);
  3831.                         mdio_write(tp, 0x06, 0x19dd);
  3832.                         mdio_write(tp, 0x06, 0xd001);
  3833.                         mdio_write(tp, 0x06, 0x0282);
  3834.                         mdio_write(tp, 0x06, 0x0a02);
  3835.                         mdio_write(tp, 0x06, 0x8226);
  3836.                         mdio_write(tp, 0x06, 0xe0f8);
  3837.                         mdio_write(tp, 0x06, 0x60e1);
  3838.                         mdio_write(tp, 0x06, 0xf861);
  3839.                         mdio_write(tp, 0x06, 0x58fd);
  3840.                         mdio_write(tp, 0x06, 0xe4f8);
  3841.                         mdio_write(tp, 0x06, 0x60e5);
  3842.                         mdio_write(tp, 0x06, 0xf861);
  3843.                         mdio_write(tp, 0x06, 0xfc04);
  3844.                         mdio_write(tp, 0x06, 0xf9fa);
  3845.                         mdio_write(tp, 0x06, 0xfbc6);
  3846.                         mdio_write(tp, 0x06, 0xbff8);
  3847.                         mdio_write(tp, 0x06, 0x40be);
  3848.                         mdio_write(tp, 0x06, 0x8350);
  3849.                         mdio_write(tp, 0x06, 0xa001);
  3850.                         mdio_write(tp, 0x06, 0x0107);
  3851.                         mdio_write(tp, 0x06, 0x1b89);
  3852.                         mdio_write(tp, 0x06, 0xcfd2);
  3853.                         mdio_write(tp, 0x06, 0x08eb);
  3854.                         mdio_write(tp, 0x06, 0xdb19);
  3855.                         mdio_write(tp, 0x06, 0xb2fb);
  3856.                         mdio_write(tp, 0x06, 0xfffe);
  3857.                         mdio_write(tp, 0x06, 0xfd04);
  3858.                         mdio_write(tp, 0x06, 0xf8e0);
  3859.                         mdio_write(tp, 0x06, 0xf848);
  3860.                         mdio_write(tp, 0x06, 0xe1f8);
  3861.                         mdio_write(tp, 0x06, 0x4968);
  3862.                         mdio_write(tp, 0x06, 0x08e4);
  3863.                         mdio_write(tp, 0x06, 0xf848);
  3864.                         mdio_write(tp, 0x06, 0xe5f8);
  3865.                         mdio_write(tp, 0x06, 0x4958);
  3866.                         mdio_write(tp, 0x06, 0xf7e4);
  3867.                         mdio_write(tp, 0x06, 0xf848);
  3868.                         mdio_write(tp, 0x06, 0xe5f8);
  3869.                         mdio_write(tp, 0x06, 0x49fc);
  3870.                         mdio_write(tp, 0x06, 0x044d);
  3871.                         mdio_write(tp, 0x06, 0x2000);
  3872.                         mdio_write(tp, 0x06, 0x024e);
  3873.                         mdio_write(tp, 0x06, 0x2200);
  3874.                         mdio_write(tp, 0x06, 0x024d);
  3875.                         mdio_write(tp, 0x06, 0xdfff);
  3876.                         mdio_write(tp, 0x06, 0x014e);
  3877.                         mdio_write(tp, 0x06, 0xddff);
  3878.                         mdio_write(tp, 0x06, 0x01f8);
  3879.                         mdio_write(tp, 0x06, 0xfafb);
  3880.                         mdio_write(tp, 0x06, 0xef79);
  3881.                         mdio_write(tp, 0x06, 0xbff8);
  3882.                         mdio_write(tp, 0x06, 0x22d8);
  3883.                         mdio_write(tp, 0x06, 0x19d9);
  3884.                         mdio_write(tp, 0x06, 0x5884);
  3885.                         mdio_write(tp, 0x06, 0x9f09);
  3886.                         mdio_write(tp, 0x06, 0xbf82);
  3887.                         mdio_write(tp, 0x06, 0x6dd6);
  3888.                         mdio_write(tp, 0x06, 0x8275);
  3889.                         mdio_write(tp, 0x06, 0x0201);
  3890.                         mdio_write(tp, 0x06, 0x4fef);
  3891.                         mdio_write(tp, 0x06, 0x97ff);
  3892.                         mdio_write(tp, 0x06, 0xfefc);
  3893.                         mdio_write(tp, 0x06, 0x0517);
  3894.                         mdio_write(tp, 0x06, 0xfffe);
  3895.                         mdio_write(tp, 0x06, 0x0117);
  3896.                         mdio_write(tp, 0x06, 0x0001);
  3897.                         mdio_write(tp, 0x06, 0x0200);
  3898.                         mdio_write(tp, 0x05, 0x83d8);
  3899.                         mdio_write(tp, 0x06, 0x8000);
  3900.                         mdio_write(tp, 0x05, 0x83d6);
  3901.                         mdio_write(tp, 0x06, 0x824f);
  3902.                         mdio_write(tp, 0x02, 0x2010);
  3903.                         mdio_write(tp, 0x03, 0xdc00);
  3904.                         mdio_write(tp, 0x1f, 0x0000);
  3905.                         mdio_write(tp, 0x0b, 0x0600);
  3906.                         mdio_write(tp, 0x1f, 0x0005);
  3907.                         mdio_write(tp, 0x05, 0xfff6);
  3908.                         mdio_write(tp, 0x06, 0x00fc);
  3909.                         mdio_write(tp, 0x1f, 0x0000);
  3910.                 }
  3911.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  3912.  
  3913.                 spin_lock_irqsave(&tp->phy_lock, flags);
  3914.                 mdio_write(tp, 0x1F, 0x0000);
  3915.                 mdio_write(tp, 0x0D, 0xF880);
  3916.                 mdio_write(tp, 0x1F, 0x0000);
  3917.         } else if (tp->mcfg == CFG_METHOD_11) {
  3918.                 mdio_write(tp, 0x1F, 0x0002);
  3919.                 mdio_write(tp, 0x10, 0x0008);
  3920.                 mdio_write(tp, 0x0D, 0x006C);
  3921.  
  3922.                 mdio_write(tp, 0x1F, 0x0001);
  3923.                 mdio_write(tp, 0x17, 0x0CC0);
  3924.  
  3925.                 mdio_write(tp, 0x1F, 0x0001);
  3926.                 mdio_write(tp, 0x0B, 0xA4D8);
  3927.                 mdio_write(tp, 0x09, 0x281C);
  3928.                 mdio_write(tp, 0x07, 0x2883);
  3929.                 mdio_write(tp, 0x0A, 0x6B35);
  3930.                 mdio_write(tp, 0x1D, 0x3DA4);
  3931.                 mdio_write(tp, 0x1C, 0xEFFD);
  3932.                 mdio_write(tp, 0x14, 0x7F52);
  3933.                 mdio_write(tp, 0x18, 0x7FC6);
  3934.                 mdio_write(tp, 0x08, 0x0601);
  3935.                 mdio_write(tp, 0x06, 0x4063);
  3936.                 mdio_write(tp, 0x10, 0xF074);
  3937.                 mdio_write(tp, 0x1F, 0x0003);
  3938.                 mdio_write(tp, 0x13, 0x0789);
  3939.                 mdio_write(tp, 0x12, 0xF4BD);
  3940.                 mdio_write(tp, 0x1A, 0x04FD);
  3941.                 mdio_write(tp, 0x14, 0x84B0);
  3942.                 mdio_write(tp, 0x1F, 0x0000);
  3943.                 mdio_write(tp, 0x00, 0x9200);
  3944.  
  3945.                 mdio_write(tp, 0x1F, 0x0005);
  3946.                 mdio_write(tp, 0x01, 0x0340);
  3947.                 mdio_write(tp, 0x1F, 0x0001);
  3948.                 mdio_write(tp, 0x04, 0x4000);
  3949.                 mdio_write(tp, 0x03, 0x1D21);
  3950.                 mdio_write(tp, 0x02, 0x0C32);
  3951.                 mdio_write(tp, 0x01, 0x0200);
  3952.                 mdio_write(tp, 0x00, 0x5554);
  3953.                 mdio_write(tp, 0x04, 0x4800);
  3954.                 mdio_write(tp, 0x04, 0x4000);
  3955.                 mdio_write(tp, 0x04, 0xF000);
  3956.                 mdio_write(tp, 0x03, 0xDF01);
  3957.                 mdio_write(tp, 0x02, 0xDF20);
  3958.                 mdio_write(tp, 0x01, 0x101A);
  3959.                 mdio_write(tp, 0x00, 0xA0FF);
  3960.                 mdio_write(tp, 0x04, 0xF800);
  3961.                 mdio_write(tp, 0x04, 0xF000);
  3962.                 mdio_write(tp, 0x1F, 0x0000);
  3963.  
  3964.                 mdio_write(tp, 0x1F, 0x0007);
  3965.                 mdio_write(tp, 0x1E, 0x0023);
  3966.                 mdio_write(tp, 0x16, 0x0000);
  3967.                 mdio_write(tp, 0x1F, 0x0000);
  3968.  
  3969.                 gphy_val = mdio_read(tp, 0x0D);
  3970.                 gphy_val |= BIT_5;
  3971.                 mdio_write(tp, 0x0D, gphy_val);
  3972.         } else if (tp->mcfg == CFG_METHOD_12 || tp->mcfg == CFG_METHOD_13) {
  3973.                 // TO DO:
  3974.                 mdio_write(tp, 0x1F, 0x0001);
  3975.                 mdio_write(tp, 0x17, 0x0CC0);
  3976.  
  3977.                 mdio_write(tp, 0x1F, 0x0007);
  3978.                 mdio_write(tp, 0x1E, 0x002D);
  3979.                 mdio_write(tp, 0x18, 0x0040);
  3980.  
  3981.                 mdio_write(tp, 0x1F, 0x0000);
  3982.                 gphy_val = mdio_read(tp, 0x0D);
  3983.                 gphy_val |= BIT_5;
  3984.                 mdio_write(tp, 0x0D, gphy_val);
  3985.  
  3986.                 mdio_write(tp, 0x1F, 0x0002);
  3987.                 gphy_val = mdio_read(tp, 0x0C);
  3988.                 gphy_val |= BIT_10;
  3989.                 mdio_write(tp, 0x0C, gphy_val);
  3990.         } else if (tp->mcfg == CFG_METHOD_14 || tp->mcfg == CFG_METHOD_15) {
  3991.                 struct pci_dev *pdev = tp->pci_dev;
  3992.  
  3993.                 spin_unlock_irqrestore(&tp->phy_lock, flags);
  3994.  
  3995.                 RTL_W8(0xF3, RTL_R8(0xF3) | BIT_2);
  3996.  
  3997.                 if (tp->mcfg == CFG_METHOD_14) {
  3998.                         spin_lock_irqsave(&tp->phy_lock, flags);
  3999.                         mdio_write(tp, 0x1f, 0x0000);
  4000.                         mdio_write(tp, 0x00, 0x1800);
  4001.                         mdio_write(tp, 0x1f, 0x0007);
  4002.                         mdio_write(tp, 0x1e, 0x0023);
  4003.                         mdio_write(tp, 0x17, 0x0117);
  4004.                         mdio_write(tp, 0x1f, 0x0007);
  4005.                         mdio_write(tp, 0x1E, 0x002C);
  4006.                         mdio_write(tp, 0x1B, 0x5000);
  4007.                         mdio_write(tp, 0x1f, 0x0000);
  4008.                         mdio_write(tp, 0x16, 0x4104);
  4009.                         for (i = 0; i < 200; i++) {
  4010.                                 udelay(100);
  4011.                                 gphy_val = mdio_read(tp, 0x1E);
  4012.                                 gphy_val &= 0x03FF;
  4013.                                 if (gphy_val == 0x000C)
  4014.                                         break;
  4015.                         }
  4016.                         mdio_write(tp, 0x1f, 0x0005);
  4017.                         for (i = 0; i < 200; i++) {
  4018.                                 udelay(100);
  4019.                                 gphy_val = mdio_read(tp, 0x07);
  4020.                                 if ((gphy_val & BIT_5) == 0)
  4021.                                         break;
  4022.                         }
  4023.                         gphy_val = mdio_read(tp, 0x07);
  4024.                         if (gphy_val & BIT_5) {
  4025.                                 mdio_write(tp, 0x1f, 0x0007);
  4026.                                 mdio_write(tp, 0x1e, 0x00a1);
  4027.                                 mdio_write(tp, 0x17, 0x1000);
  4028.                                 mdio_write(tp, 0x17, 0x0000);
  4029.                                 mdio_write(tp, 0x17, 0x2000);
  4030.                                 mdio_write(tp, 0x1e, 0x002f);
  4031.                                 mdio_write(tp, 0x18, 0x9bfb);
  4032.                                 mdio_write(tp, 0x1f, 0x0005);
  4033.                                 mdio_write(tp, 0x07, 0x0000);
  4034.                                 mdio_write(tp, 0x1f, 0x0000);
  4035.                         }
  4036.                         mdio_write(tp, 0x1f, 0x0005);
  4037.                         mdio_write(tp, 0x05, 0xfff6);
  4038.                         mdio_write(tp, 0x06, 0x0080);
  4039.                         gphy_val = mdio_read(tp, 0x00);
  4040.                         gphy_val &= ~(BIT_7);
  4041.                         mdio_write(tp, 0x00, gphy_val);
  4042.                         mdio_write(tp, 0x1f, 0x0002);
  4043.                         gphy_val = mdio_read(tp, 0x08);
  4044.                         gphy_val &= ~(BIT_7);
  4045.                         mdio_write(tp, 0x08, gphy_val);
  4046.                         mdio_write(tp, 0x1f, 0x0000);
  4047.                         mdio_write(tp, 0x1f, 0x0007);
  4048.                         mdio_write(tp, 0x1e, 0x0023);
  4049.                         mdio_write(tp, 0x16, 0x0306);
  4050.                         mdio_write(tp, 0x16, 0x0307);
  4051.                         mdio_write(tp, 0x15, 0x000e);
  4052.                         mdio_write(tp, 0x19, 0x000a);
  4053.                         mdio_write(tp, 0x15, 0x0010);
  4054.                         mdio_write(tp, 0x19, 0x0008);
  4055.                         mdio_write(tp, 0x15, 0x0018);
  4056.                         mdio_write(tp, 0x19, 0x4801);
  4057.                         mdio_write(tp, 0x15, 0x0019);
  4058.                         mdio_write(tp, 0x19, 0x6801);
  4059.                         mdio_write(tp, 0x15, 0x001a);
  4060.                         mdio_write(tp, 0x19, 0x66a1);
  4061.                         mdio_write(tp, 0x15, 0x001f);
  4062.                         mdio_write(tp, 0x19, 0x0000);
  4063.                         mdio_write(tp, 0x15, 0x0020);
  4064.                         mdio_write(tp, 0x19, 0x0000);
  4065.                         mdio_write(tp, 0x15, 0x0021);
  4066.                         mdio_write(tp, 0x19, 0x0000);
  4067.                         mdio_write(tp, 0x15, 0x0022);
  4068.                         mdio_write(tp, 0x19, 0x0000);
  4069.                         mdio_write(tp, 0x15, 0x0023);
  4070.                         mdio_write(tp, 0x19, 0x0000);
  4071.                         mdio_write(tp, 0x15, 0x0024);
  4072.                         mdio_write(tp, 0x19, 0x0000);
  4073.                         mdio_write(tp, 0x15, 0x0025);
  4074.                         mdio_write(tp, 0x19, 0x64a1);
  4075.                         mdio_write(tp, 0x15, 0x0026);
  4076.                         mdio_write(tp, 0x19, 0x40ea);
  4077.                         mdio_write(tp, 0x15, 0x0027);
  4078.                         mdio_write(tp, 0x19, 0x4503);
  4079.                         mdio_write(tp, 0x15, 0x0028);
  4080.                         mdio_write(tp, 0x19, 0x9f00);
  4081.                         mdio_write(tp, 0x15, 0x0029);
  4082.                         mdio_write(tp, 0x19, 0xa631);
  4083.                         mdio_write(tp, 0x15, 0x002a);
  4084.                         mdio_write(tp, 0x19, 0x9717);
  4085.                         mdio_write(tp, 0x15, 0x002b);
  4086.                         mdio_write(tp, 0x19, 0x302c);
  4087.                         mdio_write(tp, 0x15, 0x002c);
  4088.                         mdio_write(tp, 0x19, 0x4802);
  4089.                         mdio_write(tp, 0x15, 0x002d);
  4090.                         mdio_write(tp, 0x19, 0x58da);
  4091.                         mdio_write(tp, 0x15, 0x002e);
  4092.                         mdio_write(tp, 0x19, 0x400d);
  4093.                         mdio_write(tp, 0x15, 0x002f);
  4094.                         mdio_write(tp, 0x19, 0x4488);
  4095.                         mdio_write(tp, 0x15, 0x0030);
  4096.                         mdio_write(tp, 0x19, 0x9e00);
  4097.                         mdio_write(tp, 0x15, 0x0031);
  4098.                         mdio_write(tp, 0x19, 0x63c8);
  4099.                         mdio_write(tp, 0x15, 0x0032);
  4100.                         mdio_write(tp, 0x19, 0x6481);
  4101.                         mdio_write(tp, 0x15, 0x0033);
  4102.                         mdio_write(tp, 0x19, 0x0000);
  4103.                         mdio_write(tp, 0x15, 0x0034);
  4104.                         mdio_write(tp, 0x19, 0x0000);
  4105.                         mdio_write(tp, 0x15, 0x0035);
  4106.                         mdio_write(tp, 0x19, 0x0000);
  4107.                         mdio_write(tp, 0x15, 0x0036);
  4108.                         mdio_write(tp, 0x19, 0x0000);
  4109.                         mdio_write(tp, 0x15, 0x0037);
  4110.                         mdio_write(tp, 0x19, 0x0000);
  4111.                         mdio_write(tp, 0x15, 0x0038);
  4112.                         mdio_write(tp, 0x19, 0x0000);
  4113.                         mdio_write(tp, 0x15, 0x0039);
  4114.                         mdio_write(tp, 0x19, 0x0000);
  4115.                         mdio_write(tp, 0x15, 0x003a);
  4116.                         mdio_write(tp, 0x19, 0x0000);
  4117.                         mdio_write(tp, 0x15, 0x003b);
  4118.                         mdio_write(tp, 0x19, 0x63e8);
  4119.                         mdio_write(tp, 0x15, 0x003c);
  4120.                         mdio_write(tp, 0x19, 0x7d00);
  4121.                         mdio_write(tp, 0x15, 0x003d);
  4122.                         mdio_write(tp, 0x19, 0x59d4);
  4123.                         mdio_write(tp, 0x15, 0x003e);
  4124.                         mdio_write(tp, 0x19, 0x63f8);
  4125.                         mdio_write(tp, 0x15, 0x0040);
  4126.                         mdio_write(tp, 0x19, 0x64a1);
  4127.                         mdio_write(tp, 0x15, 0x0041);
  4128.                         mdio_write(tp, 0x19, 0x30de);
  4129.                         mdio_write(tp, 0x15, 0x0044);
  4130.                         mdio_write(tp, 0x19, 0x480f);
  4131.                         mdio_write(tp, 0x15, 0x0045);
  4132.                         mdio_write(tp, 0x19, 0x6800);
  4133.                         mdio_write(tp, 0x15, 0x0046);
  4134.                         mdio_write(tp, 0x19, 0x6680);
  4135.                         mdio_write(tp, 0x15, 0x0047);
  4136.                         mdio_write(tp, 0x19, 0x7c10);
  4137.                         mdio_write(tp, 0x15, 0x0048);
  4138.                         mdio_write(tp, 0x19, 0x63c8);
  4139.                         mdio_write(tp, 0x15, 0x0049);
  4140.                         mdio_write(tp, 0x19, 0x0000);
  4141.                         mdio_write(tp, 0x15, 0x004a);
  4142.                         mdio_write(tp, 0x19, 0x0000);
  4143.                         mdio_write(tp, 0x15, 0x004b);
  4144.                         mdio_write(tp, 0x19, 0x0000);
  4145.                         mdio_write(tp, 0x15, 0x004c);
  4146.                         mdio_write(tp, 0x19, 0x0000);
  4147.                         mdio_write(tp, 0x15, 0x004d);
  4148.                         mdio_write(tp, 0x19, 0x0000);
  4149.                         mdio_write(tp, 0x15, 0x004e);
  4150.                         mdio_write(tp, 0x19, 0x0000);
  4151.                         mdio_write(tp, 0x15, 0x004f);
  4152.                         mdio_write(tp, 0x19, 0x40ea);
  4153.                         mdio_write(tp, 0x15, 0x0050);
  4154.                         mdio_write(tp, 0x19, 0x4503);
  4155.                         mdio_write(tp, 0x15, 0x0051);
  4156.                         mdio_write(tp, 0x19, 0x58ca);
  4157.                         mdio_write(tp, 0x15, 0x0052);
  4158.                         mdio_write(tp, 0x19, 0x63c8);
  4159.                         mdio_write(tp, 0x15, 0x0053);
  4160.                         mdio_write(tp, 0x19, 0x63d8);
  4161.                         mdio_write(tp, 0x15, 0x0054);
  4162.                         mdio_write(tp, 0x19, 0x66a0);
  4163.                         mdio_write(tp, 0x15, 0x0055);
  4164.                         mdio_write(tp, 0x19, 0x9f00);
  4165.                         mdio_write(tp, 0x15, 0x0056);
  4166.                         mdio_write(tp, 0x19, 0x3000);
  4167.                         mdio_write(tp, 0x15, 0x006E);
  4168.                         mdio_write(tp, 0x19, 0x9afa);
  4169.                         mdio_write(tp, 0x15, 0x00a1);
  4170.                         mdio_write(tp, 0x19, 0x3044);
  4171.                         mdio_write(tp, 0x15, 0x00ab);
  4172.                         mdio_write(tp, 0x19, 0x5820);
  4173.                         mdio_write(tp, 0x15, 0x00ac);
  4174.                         mdio_write(tp, 0x19, 0x5e04);
  4175.                         mdio_write(tp, 0x15, 0x00ad);
  4176.                         mdio_write(tp, 0x19, 0xb60c);
  4177.                         mdio_write(tp, 0x15, 0x00af);
  4178.                         mdio_write(tp, 0x19, 0x000a);
  4179.                         mdio_write(tp, 0x15, 0x00b2);
  4180.                         mdio_write(tp, 0x19, 0x30b9);
  4181.                         mdio_write(tp, 0x15, 0x00b9);
  4182.                         mdio_write(tp, 0x19, 0x4408);
  4183.                         mdio_write(tp, 0x15, 0x00ba);
  4184.                         mdio_write(tp, 0x19, 0x480b);
  4185.                         mdio_write(tp, 0x15, 0x00bb);
  4186.                         mdio_write(tp, 0x19, 0x5e00);
  4187.                         mdio_write(tp, 0x15, 0x00bc);
  4188.                         mdio_write(tp, 0x19, 0x405f);
  4189.                         mdio_write(tp, 0x15, 0x00bd);
  4190.                         mdio_write(tp, 0x19, 0x4448);
  4191.                         mdio_write(tp, 0x15, 0x00be);
  4192.                         mdio_write(tp, 0x19, 0x4020);
  4193.                         mdio_write(tp, 0x15, 0x00bf);
  4194.                         mdio_write(tp, 0x19, 0x4468);
  4195.                         mdio_write(tp, 0x15, 0x00c0);
  4196.                         mdio_write(tp, 0x19, 0x9c02);
  4197.                         mdio_write(tp, 0x15, 0x00c1);
  4198.                         mdio_write(tp, 0x19, 0x58a0);
  4199.                         mdio_write(tp, 0x15, 0x00c2);
  4200.                         mdio_write(tp, 0x19, 0xb605);
  4201.                         mdio_write(tp, 0x15, 0x00c3);
  4202.                         mdio_write(tp, 0x19, 0xc0d3);
  4203.                         mdio_write(tp, 0x15, 0x00c4);
  4204.                         mdio_write(tp, 0x19, 0x00e6);
  4205.                         mdio_write(tp, 0x15, 0x00c5);
  4206.                         mdio_write(tp, 0x19, 0xdaec);
  4207.                         mdio_write(tp, 0x15, 0x00c6);
  4208.                         mdio_write(tp, 0x19, 0x00fa);
  4209.                         mdio_write(tp, 0x15, 0x00c7);
  4210.                         mdio_write(tp, 0x19, 0x9df9);
  4211.                         mdio_write(tp, 0x15, 0x00c8);
  4212.                         mdio_write(tp, 0x19, 0x307a);
  4213.                         mdio_write(tp, 0x15, 0x0112);
  4214.                         mdio_write(tp, 0x19, 0x6421);
  4215.                         mdio_write(tp, 0x15, 0x0113);
  4216.                         mdio_write(tp, 0x19, 0x7c08);
  4217.                         mdio_write(tp, 0x15, 0x0114);
  4218.                         mdio_write(tp, 0x19, 0x63f0);
  4219.                         mdio_write(tp, 0x15, 0x0115);
  4220.                         mdio_write(tp, 0x19, 0x4003);
  4221.                         mdio_write(tp, 0x15, 0x0116);
  4222.                         mdio_write(tp, 0x19, 0x4418);
  4223.                         mdio_write(tp, 0x15, 0x0117);
  4224.                         mdio_write(tp, 0x19, 0x9b00);
  4225.                         mdio_write(tp, 0x15, 0x0118);
  4226.                         mdio_write(tp, 0x19, 0x6461);
  4227.                         mdio_write(tp, 0x15, 0x0119);
  4228.                         mdio_write(tp, 0x19, 0x64e1);
  4229.                         mdio_write(tp, 0x15, 0x011a);
  4230.                         mdio_write(tp, 0x19, 0x0000);
  4231.                         mdio_write(tp, 0x15, 0x0150);
  4232.                         mdio_write(tp, 0x19, 0x7c80);
  4233.                         mdio_write(tp, 0x15, 0x0151);
  4234.                         mdio_write(tp, 0x19, 0x6461);
  4235.                         mdio_write(tp, 0x15, 0x0152);
  4236.                         mdio_write(tp, 0x19, 0x4003);
  4237.                         mdio_write(tp, 0x15, 0x0153);
  4238.                         mdio_write(tp, 0x19, 0x4540);
  4239.                         mdio_write(tp, 0x15, 0x0154);
  4240.                         mdio_write(tp, 0x19, 0x9f00);
  4241.                         mdio_write(tp, 0x15, 0x0155);
  4242.                         mdio_write(tp, 0x19, 0x9d00);
  4243.                         mdio_write(tp, 0x15, 0x0156);
  4244.                         mdio_write(tp, 0x19, 0x7c40);
  4245.                         mdio_write(tp, 0x15, 0x0157);
  4246.                         mdio_write(tp, 0x19, 0x6421);
  4247.                         mdio_write(tp, 0x15, 0x0158);
  4248.                         mdio_write(tp, 0x19, 0x7c80);
  4249.                         mdio_write(tp, 0x15, 0x0159);
  4250.                         mdio_write(tp, 0x19, 0x64a1);
  4251.                         mdio_write(tp, 0x15, 0x015a);
  4252.                         mdio_write(tp, 0x19, 0x30fe);
  4253.                         mdio_write(tp, 0x15, 0x021e);
  4254.                         mdio_write(tp, 0x19, 0x5410);
  4255.                         mdio_write(tp, 0x15, 0x0225);
  4256.                         mdio_write(tp, 0x19, 0x5400);
  4257.                         mdio_write(tp, 0x15, 0x023D);
  4258.                         mdio_write(tp, 0x19, 0x4050);
  4259.                         mdio_write(tp, 0x15, 0x0295);
  4260.                         mdio_write(tp, 0x19, 0x6c08);
  4261.                         mdio_write(tp, 0x15, 0x02bd);
  4262.                         mdio_write(tp, 0x19, 0xa523);
  4263.                         mdio_write(tp, 0x15, 0x02be);
  4264.                         mdio_write(tp, 0x19, 0x32ca);
  4265.                         mdio_write(tp, 0x15, 0x02ca);
  4266.                         mdio_write(tp, 0x19, 0x48b3);
  4267.                         mdio_write(tp, 0x15, 0x02cb);
  4268.                         mdio_write(tp, 0x19, 0x4020);
  4269.                         mdio_write(tp, 0x15, 0x02cc);
  4270.                         mdio_write(tp, 0x19, 0x4823);
  4271.                         mdio_write(tp, 0x15, 0x02cd);
  4272.                         mdio_write(tp, 0x19, 0x4510);
  4273.                         mdio_write(tp, 0x15, 0x02ce);
  4274.                         mdio_write(tp, 0x19, 0xb63a);
  4275.                         mdio_write(tp, 0x15, 0x02cf);
  4276.                         mdio_write(tp, 0x19, 0x7dc8);
  4277.                         mdio_write(tp, 0x15, 0x02d6);
  4278.                         mdio_write(tp, 0x19, 0x9bf8);
  4279.                         mdio_write(tp, 0x15, 0x02d8);
  4280.                         mdio_write(tp, 0x19, 0x85f6);
  4281.                         mdio_write(tp, 0x15, 0x02d9);
  4282.                         mdio_write(tp, 0x19, 0x32e0);
  4283.                         mdio_write(tp, 0x15, 0x02e0);
  4284.                         mdio_write(tp, 0x19, 0x4834);
  4285.                         mdio_write(tp, 0x15, 0x02e1);
  4286.                         mdio_write(tp, 0x19, 0x6c08);
  4287.                         mdio_write(tp, 0x15, 0x02e2);
  4288.                         mdio_write(tp, 0x19, 0x4020);
  4289.                         mdio_write(tp, 0x15, 0x02e3);
  4290.                         mdio_write(tp, 0x19, 0x4824);
  4291.                         mdio_write(tp, 0x15, 0x02e4);
  4292.                         mdio_write(tp, 0x19, 0x4520);
  4293.                         mdio_write(tp, 0x15, 0x02e5);
  4294.                         mdio_write(tp, 0x19, 0x4008);
  4295.                         mdio_write(tp, 0x15, 0x02e6);
  4296.                         mdio_write(tp, 0x19, 0x4560);
  4297.                         mdio_write(tp, 0x15, 0x02e7);
  4298.                         mdio_write(tp, 0x19, 0x9d04);
  4299.                         mdio_write(tp, 0x15, 0x02e8);
  4300.                         mdio_write(tp, 0x19, 0x48c4);
  4301.                         mdio_write(tp, 0x15, 0x02e9);
  4302.                         mdio_write(tp, 0x19, 0x0000);
  4303.                         mdio_write(tp, 0x15, 0x02ea);
  4304.                         mdio_write(tp, 0x19, 0x4844);
  4305.                         mdio_write(tp, 0x15, 0x02eb);
  4306.                         mdio_write(tp, 0x19, 0x7dc8);
  4307.                         mdio_write(tp, 0x15, 0x02f0);
  4308.                         mdio_write(tp, 0x19, 0x9cf7);
  4309.                         mdio_write(tp, 0x15, 0x02f1);
  4310.                         mdio_write(tp, 0x19, 0xdf94);
  4311.                         mdio_write(tp, 0x15, 0x02f2);
  4312.                         mdio_write(tp, 0x19, 0x0002);
  4313.                         mdio_write(tp, 0x15, 0x02f3);
  4314.                         mdio_write(tp, 0x19, 0x6810);
  4315.                         mdio_write(tp, 0x15, 0x02f4);
  4316.                         mdio_write(tp, 0x19, 0xb614);
  4317.                         mdio_write(tp, 0x15, 0x02f5);
  4318.                         mdio_write(tp, 0x19, 0xc42b);
  4319.                         mdio_write(tp, 0x15, 0x02f6);
  4320.                         mdio_write(tp, 0x19, 0x00d4);
  4321.                         mdio_write(tp, 0x15, 0x02f7);
  4322.                         mdio_write(tp, 0x19, 0xc455);
  4323.                         mdio_write(tp, 0x15, 0x02f8);
  4324.                         mdio_write(tp, 0x19, 0x0093);
  4325.                         mdio_write(tp, 0x15, 0x02f9);
  4326.                         mdio_write(tp, 0x19, 0x92ee);
  4327.                         mdio_write(tp, 0x15, 0x02fa);
  4328.                         mdio_write(tp, 0x19, 0xefed);
  4329.                         mdio_write(tp, 0x15, 0x02fb);
  4330.                         mdio_write(tp, 0x19, 0x3312);
  4331.                         mdio_write(tp, 0x15, 0x0312);
  4332.                         mdio_write(tp, 0x19, 0x49b5);
  4333.                         mdio_write(tp, 0x15, 0x0313);
  4334.                         mdio_write(tp, 0x19, 0x7d00);
  4335.                         mdio_write(tp, 0x15, 0x0314);
  4336.                         mdio_write(tp, 0x19, 0x4d00);
  4337.                         mdio_write(tp, 0x15, 0x0315);
  4338.                         mdio_write(tp, 0x19, 0x6810);
  4339.                         mdio_write(tp, 0x15, 0x031e);
  4340.                         mdio_write(tp, 0x19, 0x404f);
  4341.                         mdio_write(tp, 0x15, 0x031f);
  4342.                         mdio_write(tp, 0x19, 0x44c8);
  4343.                         mdio_write(tp, 0x15, 0x0320);
  4344.                         mdio_write(tp, 0x19, 0xd64f);
  4345.                         mdio_write(tp, 0x15, 0x0321);
  4346.                         mdio_write(tp, 0x19, 0x00e7);
  4347.                         mdio_write(tp, 0x15, 0x0322);
  4348.                         mdio_write(tp, 0x19, 0x7c08);
  4349.                         mdio_write(tp, 0x15, 0x0323);
  4350.                         mdio_write(tp, 0x19, 0x8203);
  4351.                         mdio_write(tp, 0x15, 0x0324);
  4352.                         mdio_write(tp, 0x19, 0x4d48);
  4353.                         mdio_write(tp, 0x15, 0x0325);
  4354.                         mdio_write(tp, 0x19, 0x3327);
  4355.                         mdio_write(tp, 0x15, 0x0326);
  4356.                         mdio_write(tp, 0x19, 0x4d40);
  4357.                         mdio_write(tp, 0x15, 0x0327);
  4358.                         mdio_write(tp, 0x19, 0xc8d7);
  4359.                         mdio_write(tp, 0x15, 0x0328);
  4360.                         mdio_write(tp, 0x19, 0x0003);
  4361.                         mdio_write(tp, 0x15, 0x0329);
  4362.                         mdio_write(tp, 0x19, 0x7c20);
  4363.                         mdio_write(tp, 0x15, 0x032a);
  4364.                         mdio_write(tp, 0x19, 0x4c20);
  4365.                         mdio_write(tp, 0x15, 0x032b);
  4366.                         mdio_write(tp, 0x19, 0xc8ed);
  4367.                         mdio_write(tp, 0x15, 0x032c);
  4368.                         mdio_write(tp, 0x19, 0x00f4);
  4369.                         mdio_write(tp, 0x15, 0x032d);
  4370.                         mdio_write(tp, 0x19, 0x82b3);
  4371.                         mdio_write(tp, 0x15, 0x032e);
  4372.                         mdio_write(tp, 0x19, 0xd11d);
  4373.                         mdio_write(tp, 0x15, 0x032f);
  4374.                         mdio_write(tp, 0x19, 0x00b1);
  4375.                         mdio_write(tp, 0x15, 0x0330);
  4376.                         mdio_write(tp, 0x19, 0xde18);
  4377.                         mdio_write(tp, 0x15, 0x0331);
  4378.                         mdio_write(tp, 0x19, 0x0008);
  4379.                         mdio_write(tp, 0x15, 0x0332);
  4380.                         mdio_write(tp, 0x19, 0x91ee);
  4381.                         mdio_write(tp, 0x15, 0x0333);
  4382.                         mdio_write(tp, 0x19, 0x3339);
  4383.                         mdio_write(tp, 0x15, 0x033a);
  4384.                         mdio_write(tp, 0x19, 0x4064);
  4385.                         mdio_write(tp, 0x15, 0x0340);
  4386.                         mdio_write(tp, 0x19, 0x9e06);
  4387.                         mdio_write(tp, 0x15, 0x0341);
  4388.                         mdio_write(tp, 0x19, 0x7c08);
  4389.                         mdio_write(tp, 0x15, 0x0342);
  4390.                         mdio_write(tp, 0x19, 0x8203);
  4391.                         mdio_write(tp, 0x15, 0x0343);
  4392.                         mdio_write(tp, 0x19, 0x4d48);
  4393.                         mdio_write(tp, 0x15, 0x0344);
  4394.                         mdio_write(tp, 0x19, 0x3346);
  4395.                         mdio_write(tp, 0x15, 0x0345);
  4396.                         mdio_write(tp, 0x19, 0x4d40);
  4397.                         mdio_write(tp, 0x15, 0x0346);
  4398.                         mdio_write(tp, 0x19, 0xd11d);
  4399.                         mdio_write(tp, 0x15, 0x0347);
  4400.                         mdio_write(tp, 0x19, 0x0099);
  4401.                         mdio_write(tp, 0x15, 0x0348);
  4402.                         mdio_write(tp, 0x19, 0xbb17);
  4403.                         mdio_write(tp, 0x15, 0x0349);
  4404.                         mdio_write(tp, 0x19, 0x8102);
  4405.                         mdio_write(tp, 0x15, 0x034a);
  4406.                         mdio_write(tp, 0x19, 0x334d);
  4407.                         mdio_write(tp, 0x15, 0x034b);
  4408.                         mdio_write(tp, 0x19, 0xa22c);
  4409.                         mdio_write(tp, 0x15, 0x034c);
  4410.                         mdio_write(tp, 0x19, 0x3397);
  4411.                         mdio_write(tp, 0x15, 0x034d);
  4412.                         mdio_write(tp, 0x19, 0x91f2);
  4413.                         mdio_write(tp, 0x15, 0x034e);
  4414.                         mdio_write(tp, 0x19, 0xc218);
  4415.                         mdio_write(tp, 0x15, 0x034f);
  4416.                         mdio_write(tp, 0x19, 0x00f0);
  4417.                         mdio_write(tp, 0x15, 0x0350);
  4418.                         mdio_write(tp, 0x19, 0x3397);
  4419.                         mdio_write(tp, 0x15, 0x0351);
  4420.                         mdio_write(tp, 0x19, 0x0000);
  4421.                         mdio_write(tp, 0x15, 0x0364);
  4422.                         mdio_write(tp, 0x19, 0xbc05);
  4423.                         mdio_write(tp, 0x15, 0x0367);
  4424.                         mdio_write(tp, 0x19, 0xa1fc);
  4425.                         mdio_write(tp, 0x15, 0x0368);
  4426.                         mdio_write(tp, 0x19, 0x3377);
  4427.                         mdio_write(tp, 0x15, 0x0369);
  4428.                         mdio_write(tp, 0x19, 0x328b);
  4429.                         mdio_write(tp, 0x15, 0x036a);
  4430.                         mdio_write(tp, 0x19, 0x0000);
  4431.                         mdio_write(tp, 0x15, 0x0377);
  4432.                         mdio_write(tp, 0x19, 0x4b97);
  4433.                         mdio_write(tp, 0x15, 0x0378);
  4434.                         mdio_write(tp, 0x19, 0x6818);
  4435.                         mdio_write(tp, 0x15, 0x0379);
  4436.                         mdio_write(tp, 0x19, 0x4b07);
  4437.                         mdio_write(tp, 0x15, 0x037a);
  4438.                         mdio_write(tp, 0x19, 0x40ac);
  4439.                         mdio_write(tp, 0x15, 0x037b);
  4440.                         mdio_write(tp, 0x19, 0x4445);
  4441.                         mdio_write(tp, 0x15, 0x037c);
  4442.                         mdio_write(tp, 0x19, 0x404e);
  4443.                         mdio_write(tp, 0x15, 0x037d);
  4444.                         mdio_write(tp, 0x19, 0x4461);
  4445.                         mdio_write(tp, 0x15, 0x037e);
  4446.                         mdio_write(tp, 0x19, 0x9c09);
  4447.                         mdio_write(tp, 0x15, 0x037f);
  4448.                         mdio_write(tp, 0x19, 0x63da);
  4449.                         mdio_write(tp, 0x15, 0x0380);
  4450.                         mdio_write(tp, 0x19, 0x5440);
  4451.                         mdio_write(tp, 0x15, 0x0381);
  4452.                         mdio_write(tp, 0x19, 0x4b98);
  4453.                         mdio_write(tp, 0x15, 0x0382);
  4454.                         mdio_write(tp, 0x19, 0x7c60);
  4455.                         mdio_write(tp, 0x15, 0x0383);
  4456.                         mdio_write(tp, 0x19, 0x4c00);
  4457.                         mdio_write(tp, 0x15, 0x0384);
  4458.                         mdio_write(tp, 0x19, 0x4b08);
  4459.                         mdio_write(tp, 0x15, 0x0385);
  4460.                         mdio_write(tp, 0x19, 0x63d8);
  4461.                         mdio_write(tp, 0x15, 0x0386);
  4462.                         mdio_write(tp, 0x19, 0x338d);
  4463.                         mdio_write(tp, 0x15, 0x0387);
  4464.                         mdio_write(tp, 0x19, 0xd64f);
  4465.                         mdio_write(tp, 0x15, 0x0388);
  4466.                         mdio_write(tp, 0x19, 0x0080);
  4467.                         mdio_write(tp, 0x15, 0x0389);
  4468.                         mdio_write(tp, 0x19, 0x820c);
  4469.                         mdio_write(tp, 0x15, 0x038a);
  4470.                         mdio_write(tp, 0x19, 0xa10b);
  4471.                         mdio_write(tp, 0x15, 0x038b);
  4472.                         mdio_write(tp, 0x19, 0x9df3);
  4473.                         mdio_write(tp, 0x15, 0x038c);
  4474.                         mdio_write(tp, 0x19, 0x3395);
  4475.                         mdio_write(tp, 0x15, 0x038d);
  4476.                         mdio_write(tp, 0x19, 0xd64f);
  4477.                         mdio_write(tp, 0x15, 0x038e);
  4478.                         mdio_write(tp, 0x19, 0x00f9);
  4479.                         mdio_write(tp, 0x15, 0x038f);
  4480.                         mdio_write(tp, 0x19, 0xc017);
  4481.                         mdio_write(tp, 0x15, 0x0390);
  4482.                         mdio_write(tp, 0x19, 0x0005);
  4483.                         mdio_write(tp, 0x15, 0x0391);
  4484.                         mdio_write(tp, 0x19, 0x6c0b);
  4485.                         mdio_write(tp, 0x15, 0x0392);
  4486.                         mdio_write(tp, 0x19, 0xa103);
  4487.                         mdio_write(tp, 0x15, 0x0393);
  4488.                         mdio_write(tp, 0x19, 0x6c08);
  4489.                         mdio_write(tp, 0x15, 0x0394);
  4490.                         mdio_write(tp, 0x19, 0x9df9);
  4491.                         mdio_write(tp, 0x15, 0x0395);
  4492.                         mdio_write(tp, 0x19, 0x6c08);
  4493.                         mdio_write(tp, 0x15, 0x0396);
  4494.                         mdio_write(tp, 0x19, 0x3397);
  4495.                         mdio_write(tp, 0x15, 0x0399);
  4496.                         mdio_write(tp, 0x19, 0x6810);
  4497.                         mdio_write(tp, 0x15, 0x03a4);
  4498.                         mdio_write(tp, 0x19, 0x7c08);
  4499.                         mdio_write(tp, 0x15, 0x03a5);
  4500.                         mdio_write(tp, 0x19, 0x8203);
  4501.                         mdio_write(tp, 0x15, 0x03a6);
  4502.                         mdio_write(tp, 0x19, 0x4d08);
  4503.                         mdio_write(tp, 0x15, 0x03a7);
  4504.                         mdio_write(tp, 0x19, 0x33a9);
  4505.                         mdio_write(tp, 0x15, 0x03a8);
  4506.                         mdio_write(tp, 0x19, 0x4d00);
  4507.                         mdio_write(tp, 0x15, 0x03a9);
  4508.                         mdio_write(tp, 0x19, 0x9bfa);
  4509.                         mdio_write(tp, 0x15, 0x03aa);
  4510.                         mdio_write(tp, 0x19, 0x33b6);
  4511.                         mdio_write(tp, 0x15, 0x03bb);
  4512.                         mdio_write(tp, 0x19, 0x4056);
  4513.                         mdio_write(tp, 0x15, 0x03bc);
  4514.                         mdio_write(tp, 0x19, 0x44e9);
  4515.                         mdio_write(tp, 0x15, 0x03bd);
  4516.                         mdio_write(tp, 0x19, 0x405e);
  4517.                         mdio_write(tp, 0x15, 0x03be);
  4518.                         mdio_write(tp, 0x19, 0x44f8);
  4519.                         mdio_write(tp, 0x15, 0x03bf);
  4520.                         mdio_write(tp, 0x19, 0xd64f);
  4521.                         mdio_write(tp, 0x15, 0x03c0);
  4522.                         mdio_write(tp, 0x19, 0x0037);
  4523.                         mdio_write(tp, 0x15, 0x03c1);
  4524.                         mdio_write(tp, 0x19, 0xbd37);
  4525.                         mdio_write(tp, 0x15, 0x03c2);
  4526.                         mdio_write(tp, 0x19, 0x9cfd);
  4527.                         mdio_write(tp, 0x15, 0x03c3);
  4528.                         mdio_write(tp, 0x19, 0xc639);
  4529.                         mdio_write(tp, 0x15, 0x03c4);
  4530.                         mdio_write(tp, 0x19, 0x0011);
  4531.                         mdio_write(tp, 0x15, 0x03c5);
  4532.                         mdio_write(tp, 0x19, 0x9b03);
  4533.                         mdio_write(tp, 0x15, 0x03c6);
  4534.                         mdio_write(tp, 0x19, 0x7c01);
  4535.                         mdio_write(tp, 0x15, 0x03c7);
  4536.                         mdio_write(tp, 0x19, 0x4c01);
  4537.                         mdio_write(tp, 0x15, 0x03c8);
  4538.                         mdio_write(tp, 0x19, 0x9e03);
  4539.                         mdio_write(tp, 0x15, 0x03c9);
  4540.                         mdio_write(tp, 0x19, 0x7c20);
  4541.                         mdio_write(tp, 0x15, 0x03ca);
  4542.                         mdio_write(tp, 0x19, 0x4c20);
  4543.                         mdio_write(tp, 0x15, 0x03cb);
  4544.                         mdio_write(tp, 0x19, 0x9af4);
  4545.                         mdio_write(tp, 0x15, 0x03cc);
  4546.                         mdio_write(tp, 0x19, 0x7c12);
  4547.                         mdio_write(tp, 0x15, 0x03cd);
  4548.                         mdio_write(tp, 0x19, 0x4c52);
  4549.                         mdio_write(tp, 0x15, 0x03ce);
  4550.                         mdio_write(tp, 0x19, 0x4470);
  4551.                         mdio_write(tp, 0x15, 0x03cf);
  4552.                         mdio_write(tp, 0x19, 0x7c12);
  4553.                         mdio_write(tp, 0x15, 0x03d0);
  4554.                         mdio_write(tp, 0x19, 0x4c40);
  4555.                         mdio_write(tp, 0x15, 0x03d1);
  4556.                         mdio_write(tp, 0x19, 0x33bf);
  4557.                         mdio_write(tp, 0x15, 0x03d6);
  4558.                         mdio_write(tp, 0x19, 0x4047);
  4559.                         mdio_write(tp, 0x15, 0x03d7);
  4560.                         mdio_write(tp, 0x19, 0x4469);
  4561.                         mdio_write(tp, 0x15, 0x03d8);
  4562.                         mdio_write(tp, 0x19, 0x492b);
  4563.                         mdio_write(tp, 0x15, 0x03d9);
  4564.                         mdio_write(tp, 0x19, 0x4479);
  4565.                         mdio_write(tp, 0x15, 0x03da);
  4566.                         mdio_write(tp, 0x19, 0x7c09);
  4567.                         mdio_write(tp, 0x15, 0x03db);
  4568.                         mdio_write(tp, 0x19, 0x8203);
  4569.                         mdio_write(tp, 0x15, 0x03dc);
  4570.                         mdio_write(tp, 0x19, 0x4d48);
  4571.                         mdio_write(tp, 0x15, 0x03dd);
  4572.                         mdio_write(tp, 0x19, 0x33df);
  4573.                         mdio_write(tp, 0x15, 0x03de);
  4574.                         mdio_write(tp, 0x19, 0x4d40);
  4575.                         mdio_write(tp, 0x15, 0x03df);
  4576.                         mdio_write(tp, 0x19, 0xd64f);
  4577.                         mdio_write(tp, 0x15, 0x03e0);
  4578.                         mdio_write(tp, 0x19, 0x0017);
  4579.                         mdio_write(tp, 0x15, 0x03e1);
  4580.                         mdio_write(tp, 0x19, 0xbd17);
  4581.                         mdio_write(tp, 0x15, 0x03e2);
  4582.                         mdio_write(tp, 0x19, 0x9b03);
  4583.                         mdio_write(tp, 0x15, 0x03e3);
  4584.                         mdio_write(tp, 0x19, 0x7c20);
  4585.                         mdio_write(tp, 0x15, 0x03e4);
  4586.                         mdio_write(tp, 0x19, 0x4c20);
  4587.                         mdio_write(tp, 0x15, 0x03e5);
  4588.                         mdio_write(tp, 0x19, 0x88f5);
  4589.                         mdio_write(tp, 0x15, 0x03e6);
  4590.                         mdio_write(tp, 0x19, 0xc428);
  4591.                         mdio_write(tp, 0x15, 0x03e7);
  4592.                         mdio_write(tp, 0x19, 0x0008);
  4593.                         mdio_write(tp, 0x15, 0x03e8);
  4594.                         mdio_write(tp, 0x19, 0x9af2);
  4595.                         mdio_write(tp, 0x15, 0x03e9);
  4596.                         mdio_write(tp, 0x19, 0x7c12);
  4597.                         mdio_write(tp, 0x15, 0x03ea);
  4598.                         mdio_write(tp, 0x19, 0x4c52);
  4599.                         mdio_write(tp, 0x15, 0x03eb);
  4600.                         mdio_write(tp, 0x19, 0x4470);
  4601.                         mdio_write(tp, 0x15, 0x03ec);
  4602.                         mdio_write(tp, 0x19, 0x7c12);
  4603.                         mdio_write(tp, 0x15, 0x03ed);
  4604.                         mdio_write(tp, 0x19, 0x4c40);
  4605.                         mdio_write(tp, 0x15, 0x03ee);
  4606.                         mdio_write(tp, 0x19, 0x33da);
  4607.                         mdio_write(tp, 0x15, 0x03ef);
  4608.                         mdio_write(tp, 0x19, 0x3312);
  4609.                         mdio_write(tp, 0x16, 0x0306);
  4610.                         mdio_write(tp, 0x16, 0x0300);
  4611.                         mdio_write(tp, 0x1f, 0x0000);
  4612.                         mdio_write(tp, 0x17, 0x2179);
  4613.                         mdio_write(tp, 0x1f, 0x0007);
  4614.                         mdio_write(tp, 0x1e, 0x0040);
  4615.                         mdio_write(tp, 0x18, 0x0645);
  4616.                         mdio_write(tp, 0x19, 0xe200);
  4617.                         mdio_write(tp, 0x18, 0x0655);
  4618.                         mdio_write(tp, 0x19, 0x9000);
  4619.                         mdio_write(tp, 0x18, 0x0d05);
  4620.                         mdio_write(tp, 0x19, 0xbe00);
  4621.                         mdio_write(tp, 0x18, 0x0d15);
  4622.                         mdio_write(tp, 0x19, 0xd300);
  4623.                         mdio_write(tp, 0x18, 0x0d25);
  4624.                         mdio_write(tp, 0x19, 0xfe00);
  4625.                         mdio_write(tp, 0x18, 0x0d35);
  4626.                         mdio_write(tp, 0x19, 0x4000);
  4627.                         mdio_write(tp, 0x18, 0x0d45);
  4628.                         mdio_write(tp, 0x19, 0x7f00);
  4629.                         mdio_write(tp, 0x18, 0x0d55);
  4630.                         mdio_write(tp, 0x19, 0x1000);
  4631.                         mdio_write(tp, 0x18, 0x0d65);
  4632.                         mdio_write(tp, 0x19, 0x0000);
  4633.                         mdio_write(tp, 0x18, 0x0d75);
  4634.                         mdio_write(tp, 0x19, 0x8200);
  4635.                         mdio_write(tp, 0x18, 0x0d85);
  4636.                         mdio_write(tp, 0x19, 0x0000);
  4637.                         mdio_write(tp, 0x18, 0x0d95);
  4638.                         mdio_write(tp, 0x19, 0x7000);
  4639.                         mdio_write(tp, 0x18, 0x0da5);
  4640.                         mdio_write(tp, 0x19, 0x0f00);
  4641.                         mdio_write(tp, 0x18, 0x0db5);
  4642.                         mdio_write(tp, 0x19, 0x0100);
  4643.                         mdio_write(tp, 0x18, 0x0dc5);
  4644.                         mdio_write(tp, 0x19, 0x9b00);
  4645.                         mdio_write(tp, 0x18, 0x0dd5);
  4646.                         mdio_write(tp, 0x19, 0x7f00);
  4647.                         mdio_write(tp, 0x18, 0x0de5);
  4648.                         mdio_write(tp, 0x19, 0xe000);
  4649.                         mdio_write(tp, 0x18, 0x0df5);
  4650.                         mdio_write(tp, 0x19, 0xef00);
  4651.                         mdio_write(tp, 0x18, 0x16d5);
  4652.                         mdio_write(tp, 0x19, 0xe200);
  4653.                         mdio_write(tp, 0x18, 0x16e5);
  4654.                         mdio_write(tp, 0x19, 0xab00);
  4655.                         mdio_write(tp, 0x18, 0x2904);
  4656.                         mdio_write(tp, 0x19, 0x4000);
  4657.                         mdio_write(tp, 0x18, 0x2914);
  4658.                         mdio_write(tp, 0x19, 0x7f00);
  4659.                         mdio_write(tp, 0x18, 0x2924);
  4660.                         mdio_write(tp, 0x19, 0x0100);
  4661.                         mdio_write(tp, 0x18, 0x2934);
  4662.                         mdio_write(tp, 0x19, 0x2000);
  4663.                         mdio_write(tp, 0x18, 0x2944);
  4664.                         mdio_write(tp, 0x19, 0x0000);
  4665.                         mdio_write(tp, 0x18, 0x2954);
  4666.                         mdio_write(tp, 0x19, 0x4600);
  4667.                         mdio_write(tp, 0x18, 0x2964);
  4668.                         mdio_write(tp, 0x19, 0xfc00);
  4669.                         mdio_write(tp, 0x18, 0x2974);
  4670.                         mdio_write(tp, 0x19, 0x0000);
  4671.                         mdio_write(tp, 0x18, 0x2984);
  4672.                         mdio_write(tp, 0x19, 0x5000);
  4673.                         mdio_write(tp, 0x18, 0x2994);
  4674.                         mdio_write(tp, 0x19, 0x9d00);
  4675.                         mdio_write(tp, 0x18, 0x29a4);
  4676.                         mdio_write(tp, 0x19, 0xff00);
  4677.                         mdio_write(tp, 0x18, 0x29b4);
  4678.                         mdio_write(tp, 0x19, 0x4000);
  4679.                         mdio_write(tp, 0x18, 0x29c4);
  4680.                         mdio_write(tp, 0x19, 0x7f00);
  4681.                         mdio_write(tp, 0x18, 0x29d4);
  4682.                         mdio_write(tp, 0x19, 0x0000);
  4683.                         mdio_write(tp, 0x18, 0x29e4);
  4684.                         mdio_write(tp, 0x19, 0x2000);
  4685.                         mdio_write(tp, 0x18, 0x29f4);
  4686.                         mdio_write(tp, 0x19, 0x0000);
  4687.                         mdio_write(tp, 0x18, 0x2a04);
  4688.                         mdio_write(tp, 0x19, 0xe600);
  4689.                         mdio_write(tp, 0x18, 0x2a14);
  4690.                         mdio_write(tp, 0x19, 0xff00);
  4691.                         mdio_write(tp, 0x18, 0x2a24);
  4692.                         mdio_write(tp, 0x19, 0x0000);
  4693.                         mdio_write(tp, 0x18, 0x2a34);
  4694.                         mdio_write(tp, 0x19, 0x5000);
  4695.                         mdio_write(tp, 0x18, 0x2a44);
  4696.                         mdio_write(tp, 0x19, 0x8500);
  4697.                         mdio_write(tp, 0x18, 0x2a54);
  4698.                         mdio_write(tp, 0x19, 0x7f00);
  4699.                         mdio_write(tp, 0x18, 0x2a64);
  4700.                         mdio_write(tp, 0x19, 0xac00);
  4701.                         mdio_write(tp, 0x18, 0x2a74);
  4702.                         mdio_write(tp, 0x19, 0x0800);
  4703.                         mdio_write(tp, 0x18, 0x2a84);
  4704.                         mdio_write(tp, 0x19, 0xfc00);
  4705.                         mdio_write(tp, 0x18, 0x2a94);
  4706.                         mdio_write(tp, 0x19, 0xe000);
  4707.                         mdio_write(tp, 0x18, 0x2aa4);
  4708.                         mdio_write(tp, 0x19, 0x7400);
  4709.                         mdio_write(tp, 0x18, 0x2ab4);
  4710.                         mdio_write(tp, 0x19, 0x4000);
  4711.                         mdio_write(tp, 0x18, 0x2ac4);
  4712.                         mdio_write(tp, 0x19, 0x7f00);
  4713.                         mdio_write(tp, 0x18, 0x2ad4);
  4714.                         mdio_write(tp, 0x19, 0x0100);
  4715.                         mdio_write(tp, 0x18, 0x2ae4);
  4716.                         mdio_write(tp, 0x19, 0xff00);
  4717.                         mdio_write(tp, 0x18, 0x2af4);
  4718.                         mdio_write(tp, 0x19, 0x0000);
  4719.                         mdio_write(tp, 0x18, 0x2b04);
  4720.                         mdio_write(tp, 0x19, 0x4400);
  4721.                         mdio_write(tp, 0x18, 0x2b14);
  4722.                         mdio_write(tp, 0x19, 0xfc00);
  4723.                         mdio_write(tp, 0x18, 0x2b24);
  4724.                         mdio_write(tp, 0x19, 0x0000);
  4725.                         mdio_write(tp, 0x18, 0x2b34);
  4726.                         mdio_write(tp, 0x19, 0x4000);
  4727.                         mdio_write(tp, 0x18, 0x2b44);
  4728.                         mdio_write(tp, 0x19, 0x9d00);
  4729.                         mdio_write(tp, 0x18, 0x2b54);
  4730.                         mdio_write(tp, 0x19, 0xff00);
  4731.                         mdio_write(tp, 0x18, 0x2b64);
  4732.                         mdio_write(tp, 0x19, 0x4000);
  4733.                         mdio_write(tp, 0x18, 0x2b74);
  4734.                         mdio_write(tp, 0x19, 0x7f00);
  4735.                         mdio_write(tp, 0x18, 0x2b84);
  4736.                         mdio_write(tp, 0x19, 0x0000);
  4737.                         mdio_write(tp, 0x18, 0x2b94);
  4738.                         mdio_write(tp, 0x19, 0xff00);
  4739.                         mdio_write(tp, 0x18, 0x2ba4);
  4740.                         mdio_write(tp, 0x19, 0x0000);
  4741.                         mdio_write(tp, 0x18, 0x2bb4);
  4742.                         mdio_write(tp, 0x19, 0xfc00);
  4743.                         mdio_write(tp, 0x18, 0x2bc4);
  4744.                         mdio_write(tp, 0x19, 0xff00);
  4745.                         mdio_write(tp, 0x18, 0x2bd4);
  4746.                         mdio_write(tp, 0x19, 0x0000);
  4747.                         mdio_write(tp, 0x18, 0x2be4);
  4748.                         mdio_write(tp, 0x19, 0x4000);
  4749.                         mdio_write(tp, 0x18, 0x2bf4);
  4750.                         mdio_write(tp, 0x19, 0x8900);
  4751.                         mdio_write(tp, 0x18, 0x2c04);
  4752.                         mdio_write(tp, 0x19, 0x8300);
  4753.                         mdio_write(tp, 0x18, 0x2c14);
  4754.                         mdio_write(tp, 0x19, 0xe000);
  4755.                         mdio_write(tp, 0x18, 0x2c24);
  4756.                         mdio_write(tp, 0x19, 0x0000);
  4757.                         mdio_write(tp, 0x18, 0x2c34);
  4758.                         mdio_write(tp, 0x19, 0xac00);
  4759.                         mdio_write(tp, 0x18, 0x2c44);
  4760.                         mdio_write(tp, 0x19, 0x0800);
  4761.                         mdio_write(tp, 0x18, 0x2c54);
  4762.                         mdio_write(tp, 0x19, 0xfa00);
  4763.                         mdio_write(tp, 0x18, 0x2c64);
  4764.                         mdio_write(tp, 0x19, 0xe100);
  4765.                         mdio_write(tp, 0x18, 0x2c74);
  4766.                         mdio_write(tp, 0x19, 0x7f00);
  4767.                         mdio_write(tp, 0x18, 0x0001);
  4768.                         mdio_write(tp, 0x1f, 0x0000);
  4769.                         mdio_write(tp, 0x17, 0x2100);
  4770.                         mdio_write(tp, 0x1f, 0x0005);
  4771.                         mdio_write(tp, 0x05, 0xfff6);
  4772.                         mdio_write(tp, 0x06, 0x0080);
  4773.                         mdio_write(tp, 0x05, 0x8b88);
  4774.                         mdio_write(tp, 0x06, 0x0000);
  4775.                         mdio_write(tp, 0x06, 0x0000);
  4776.                         mdio_write(tp, 0x06, 0x0000);
  4777.                         mdio_write(tp, 0x06, 0x0000);
  4778.                         mdio_write(tp, 0x05, 0x8000);
  4779.                         mdio_write(tp, 0x06, 0xd480);
  4780.                         mdio_write(tp, 0x06, 0xc1e4);
  4781.                         mdio_write(tp, 0x06, 0x8b9a);
  4782.                         mdio_write(tp, 0x06, 0xe58b);
  4783.                         mdio_write(tp, 0x06, 0x9bee);
  4784.                         mdio_write(tp, 0x06, 0x8b83);
  4785.                         mdio_write(tp, 0x06, 0x41bf);
  4786.                         mdio_write(tp, 0x06, 0x8b88);
  4787.                         mdio_write(tp, 0x06, 0xec00);
  4788.                         mdio_write(tp, 0x06, 0x19a9);
  4789.                         mdio_write(tp, 0x06, 0x8b90);
  4790.                         mdio_write(tp, 0x06, 0xf9ee);
  4791.                         mdio_write(tp, 0x06, 0xfff6);
  4792.                         mdio_write(tp, 0x06, 0x00ee);
  4793.                         mdio_write(tp, 0x06, 0xfff7);
  4794.                         mdio_write(tp, 0x06, 0xffe0);
  4795.                         mdio_write(tp, 0x06, 0xe140);
  4796.                         mdio_write(tp, 0x06, 0xe1e1);
  4797.                         mdio_write(tp, 0x06, 0x41f7);
  4798.                         mdio_write(tp, 0x06, 0x2ff6);
  4799.                         mdio_write(tp, 0x06, 0x28e4);
  4800.                         mdio_write(tp, 0x06, 0xe140);
  4801.                         mdio_write(tp, 0x06, 0xe5e1);
  4802.                         mdio_write(tp, 0x06, 0x41f7);
  4803.                         mdio_write(tp, 0x06, 0x0002);
  4804.                         mdio_write(tp, 0x06, 0x020c);
  4805.                         mdio_write(tp, 0x06, 0x0202);
  4806.                         mdio_write(tp, 0x06, 0x1d02);
  4807.                         mdio_write(tp, 0x06, 0x0230);
  4808.                         mdio_write(tp, 0x06, 0x0202);
  4809.                         mdio_write(tp, 0x06, 0x4002);
  4810.                         mdio_write(tp, 0x06, 0x028b);
  4811.                         mdio_write(tp, 0x06, 0x0280);
  4812.                         mdio_write(tp, 0x06, 0x6c02);
  4813.                         mdio_write(tp, 0x06, 0x8085);
  4814.                         mdio_write(tp, 0x06, 0xe08b);
  4815.                         mdio_write(tp, 0x06, 0x88e1);
  4816.                         mdio_write(tp, 0x06, 0x8b89);
  4817.                         mdio_write(tp, 0x06, 0x1e01);
  4818.                         mdio_write(tp, 0x06, 0xe18b);
  4819.                         mdio_write(tp, 0x06, 0x8a1e);
  4820.                         mdio_write(tp, 0x06, 0x01e1);
  4821.                         mdio_write(tp, 0x06, 0x8b8b);
  4822.                         mdio_write(tp, 0x06, 0x1e01);
  4823.                         mdio_write(tp, 0x06, 0xe18b);
  4824.                         mdio_write(tp, 0x06, 0x8c1e);
  4825.                         mdio_write(tp, 0x06, 0x01e1);
  4826.                         mdio_write(tp, 0x06, 0x8b8d);
  4827.                         mdio_write(tp, 0x06, 0x1e01);
  4828.                         mdio_write(tp, 0x06, 0xe18b);
  4829.                         mdio_write(tp, 0x06, 0x8e1e);
  4830.                         mdio_write(tp, 0x06, 0x01a0);
  4831.                         mdio_write(tp, 0x06, 0x00c7);
  4832.                         mdio_write(tp, 0x06, 0xaec3);
  4833.                         mdio_write(tp, 0x06, 0xf8e0);
  4834.                         mdio_write(tp, 0x06, 0x8b8d);
  4835.                         mdio_write(tp, 0x06, 0xad20);
  4836.                         mdio_write(tp, 0x06, 0x10ee);
  4837.                         mdio_write(tp, 0x06, 0x8b8d);
  4838.                         mdio_write(tp, 0x06, 0x0002);
  4839.                         mdio_write(tp, 0x06, 0x1310);
  4840.                         mdio_write(tp, 0x06, 0x021f);
  4841.                         mdio_write(tp, 0x06, 0x9d02);
  4842.                         mdio_write(tp, 0x06, 0x1f0c);
  4843.                         mdio_write(tp, 0x06, 0x0227);
  4844.                         mdio_write(tp, 0x06, 0x49fc);
  4845.                         mdio_write(tp, 0x06, 0x04f8);
  4846.                         mdio_write(tp, 0x06, 0xe08b);
  4847.                         mdio_write(tp, 0x06, 0x8ead);
  4848.                         mdio_write(tp, 0x06, 0x200b);
  4849.                         mdio_write(tp, 0x06, 0xf620);
  4850.                         mdio_write(tp, 0x06, 0xe48b);
  4851.                         mdio_write(tp, 0x06, 0x8e02);
  4852.                         mdio_write(tp, 0x06, 0x830e);
  4853.                         mdio_write(tp, 0x06, 0x021b);
  4854.                         mdio_write(tp, 0x06, 0x67ad);
  4855.                         mdio_write(tp, 0x06, 0x2211);
  4856.                         mdio_write(tp, 0x06, 0xf622);
  4857.                         mdio_write(tp, 0x06, 0xe48b);
  4858.                         mdio_write(tp, 0x06, 0x8e02);
  4859.                         mdio_write(tp, 0x06, 0x2ba5);
  4860.                         mdio_write(tp, 0x06, 0x022a);
  4861.                         mdio_write(tp, 0x06, 0x2402);
  4862.                         mdio_write(tp, 0x06, 0x80c6);
  4863.                         mdio_write(tp, 0x06, 0x022a);
  4864.                         mdio_write(tp, 0x06, 0xf0ad);
  4865.                         mdio_write(tp, 0x06, 0x2511);
  4866.                         mdio_write(tp, 0x06, 0xf625);
  4867.                         mdio_write(tp, 0x06, 0xe48b);
  4868.                         mdio_write(tp, 0x06, 0x8e02);
  4869.                         mdio_write(tp, 0x06, 0x8226);
  4870.                         mdio_write(tp, 0x06, 0x0204);
  4871.                         mdio_write(tp, 0x06, 0x0302);
  4872.                         mdio_write(tp, 0x06, 0x19cc);
  4873.                         mdio_write(tp, 0x06, 0x022b);
  4874.                         mdio_write(tp, 0x06, 0x5bfc);
  4875.                         mdio_write(tp, 0x06, 0x04ee);
  4876.                         mdio_write(tp, 0x06, 0x8b8d);
  4877.                         mdio_write(tp, 0x06, 0x0105);
  4878.                         mdio_write(tp, 0x06, 0xf8e0);
  4879.                         mdio_write(tp, 0x06, 0x8b83);
  4880.                         mdio_write(tp, 0x06, 0xad24);
  4881.                         mdio_write(tp, 0x06, 0x44e0);
  4882.                         mdio_write(tp, 0x06, 0xe022);
  4883.                         mdio_write(tp, 0x06, 0xe1e0);
  4884.                         mdio_write(tp, 0x06, 0x23ad);
  4885.                         mdio_write(tp, 0x06, 0x223b);
  4886.                         mdio_write(tp, 0x06, 0xe08a);
  4887.                         mdio_write(tp, 0x06, 0xbea0);
  4888.                         mdio_write(tp, 0x06, 0x0005);
  4889.                         mdio_write(tp, 0x06, 0x0228);
  4890.                         mdio_write(tp, 0x06, 0xdeae);
  4891.                         mdio_write(tp, 0x06, 0x42a0);
  4892.                         mdio_write(tp, 0x06, 0x0105);
  4893.                         mdio_write(tp, 0x06, 0x0228);
  4894.                         mdio_write(tp, 0x06, 0xf1ae);
  4895.                         mdio_write(tp, 0x06, 0x3aa0);
  4896.                         mdio_write(tp, 0x06, 0x0205);
  4897.                         mdio_write(tp, 0x06, 0x0281);
  4898.                         mdio_write(tp, 0x06, 0x25ae);
  4899.                         mdio_write(tp, 0x06, 0x32a0);
  4900.                         mdio_write(tp, 0x06, 0x0305);
  4901.                         mdio_write(tp, 0x06, 0x0229);
  4902.                         mdio_write(tp, 0x06, 0x9aae);
  4903.                         mdio_write(tp, 0x06, 0x2aa0);
  4904.                         mdio_write(tp, 0x06, 0x0405);
  4905.                         mdio_write(tp, 0x06, 0x0229);
  4906.                         mdio_write(tp, 0x06, 0xaeae);
  4907.                         mdio_write(tp, 0x06, 0x22a0);
  4908.                         mdio_write(tp, 0x06, 0x0505);
  4909.                         mdio_write(tp, 0x06, 0x0229);
  4910.                         mdio_write(tp, 0x06, 0xd7ae);
  4911.                         mdio_write(tp, 0x06, 0x1aa0);
  4912.                         mdio_write(tp, 0x06, 0x0605);
  4913.                         mdio_write(tp, 0x06, 0x0229);
  4914.                         mdio_write(tp, 0x06, 0xfeae);
  4915.                         mdio_write(tp, 0x06, 0x12ee);
  4916.                         mdio_write(tp, 0x06, 0x8ac0);
  4917.                         mdio_write(tp, 0x06, 0x00ee);
  4918.                         mdio_write(tp, 0x06, 0x8ac1);
  4919.                         mdio_write(tp, 0x06, 0x00ee);
  4920.                         mdio_write(tp, 0x06, 0x8ac6);
  4921.                         mdio_write(tp, 0x06, 0x00ee);
  4922.                         mdio_write(tp, 0x06, 0x8abe);
  4923.                         mdio_write(tp, 0x06, 0x00ae);
  4924.                         mdio_write(tp, 0x06, 0x00fc);
  4925.                         mdio_write(tp, 0x06, 0x04f8);
  4926.                         mdio_write(tp, 0x06, 0x022a);
  4927.                         mdio_write(tp, 0x06, 0x67e0);
  4928.                         mdio_write(tp, 0x06, 0xe022);
  4929.                         mdio_write(tp, 0x06, 0xe1e0);
  4930.                         mdio_write(tp, 0x06, 0x230d);
  4931.                         mdio_write(tp, 0x06, 0x0658);
  4932.                         mdio_write(tp, 0x06, 0x03a0);
  4933.                         mdio_write(tp, 0x06, 0x0202);
  4934.                         mdio_write(tp, 0x06, 0xae2d);
  4935.                         mdio_write(tp, 0x06, 0xa001);
  4936.                         mdio_write(tp, 0x06, 0x02ae);
  4937.                         mdio_write(tp, 0x06, 0x2da0);
  4938.                         mdio_write(tp, 0x06, 0x004d);
  4939.                         mdio_write(tp, 0x06, 0xe0e2);
  4940.                         mdio_write(tp, 0x06, 0x00e1);
  4941.                         mdio_write(tp, 0x06, 0xe201);
  4942.                         mdio_write(tp, 0x06, 0xad24);
  4943.                         mdio_write(tp, 0x06, 0x44e0);
  4944.                         mdio_write(tp, 0x06, 0x8ac2);
  4945.                         mdio_write(tp, 0x06, 0xe48a);
  4946.                         mdio_write(tp, 0x06, 0xc4e0);
  4947.                         mdio_write(tp, 0x06, 0x8ac3);
  4948.                         mdio_write(tp, 0x06, 0xe48a);
  4949.                         mdio_write(tp, 0x06, 0xc5ee);
  4950.                         mdio_write(tp, 0x06, 0x8abe);
  4951.                         mdio_write(tp, 0x06, 0x03e0);
  4952.                         mdio_write(tp, 0x06, 0x8b83);
  4953.                         mdio_write(tp, 0x06, 0xad25);
  4954.                         mdio_write(tp, 0x06, 0x3aee);
  4955.                         mdio_write(tp, 0x06, 0x8abe);
  4956.                         mdio_write(tp, 0x06, 0x05ae);
  4957.                         mdio_write(tp, 0x06, 0x34e0);
  4958.                         mdio_write(tp, 0x06, 0x8ace);
  4959.                         mdio_write(tp, 0x06, 0xae03);
  4960.                         mdio_write(tp, 0x06, 0xe08a);
  4961.                         mdio_write(tp, 0x06, 0xcfe1);
  4962.                         mdio_write(tp, 0x06, 0x8ac2);
  4963.                         mdio_write(tp, 0x06, 0x4905);
  4964.                         mdio_write(tp, 0x06, 0xe58a);
  4965.                         mdio_write(tp, 0x06, 0xc4e1);
  4966.                         mdio_write(tp, 0x06, 0x8ac3);
  4967.                         mdio_write(tp, 0x06, 0x4905);
  4968.                         mdio_write(tp, 0x06, 0xe58a);
  4969.                         mdio_write(tp, 0x06, 0xc5ee);
  4970.                         mdio_write(tp, 0x06, 0x8abe);
  4971.                         mdio_write(tp, 0x06, 0x0502);
  4972.                         mdio_write(tp, 0x06, 0x2ab6);
  4973.                         mdio_write(tp, 0x06, 0xac20);
  4974.                         mdio_write(tp, 0x06, 0x1202);
  4975.                         mdio_write(tp, 0x06, 0x819b);
  4976.                         mdio_write(tp, 0x06, 0xac20);
  4977.                         mdio_write(tp, 0x06, 0x0cee);
  4978.                         mdio_write(tp, 0x06, 0x8ac1);
  4979.                         mdio_write(tp, 0x06, 0x00ee);
  4980.                         mdio_write(tp, 0x06, 0x8ac6);
  4981.                         mdio_write(tp, 0x06, 0x00ee);
  4982.                         mdio_write(tp, 0x06, 0x8abe);
  4983.                         mdio_write(tp, 0x06, 0x02fc);
  4984.                         mdio_write(tp, 0x06, 0x04d0);
  4985.                         mdio_write(tp, 0x06, 0x0002);
  4986.                         mdio_write(tp, 0x06, 0x81ad);
  4987.                         mdio_write(tp, 0x06, 0x590f);
  4988.                         mdio_write(tp, 0x06, 0x3902);
  4989.                         mdio_write(tp, 0x06, 0xaa04);
  4990.                         mdio_write(tp, 0x06, 0xd001);
  4991.                         mdio_write(tp, 0x06, 0xae02);
  4992.                         mdio_write(tp, 0x06, 0xd000);
  4993.                         mdio_write(tp, 0x06, 0x04f9);
  4994.                         mdio_write(tp, 0x06, 0xfae2);
  4995.                         mdio_write(tp, 0x06, 0xe2d2);
  4996.                         mdio_write(tp, 0x06, 0xe3e2);
  4997.                         mdio_write(tp, 0x06, 0xd3f9);
  4998.                         mdio_write(tp, 0x06, 0x5af7);
  4999.                         mdio_write(tp, 0x06, 0xe6e2);
  5000.                         mdio_write(tp, 0x06, 0xd2e7);
  5001.                         mdio_write(tp, 0x06, 0xe2d3);
  5002.                         mdio_write(tp, 0x06, 0xe2e0);
  5003.                         mdio_write(tp, 0x06, 0x2ce3);
  5004.                         mdio_write(tp, 0x06, 0xe02d);
  5005.                         mdio_write(tp, 0x06, 0xf95b);
  5006.                         mdio_write(tp, 0x06, 0xe01e);
  5007.                         mdio_write(tp, 0x06, 0x30e6);
  5008.                         mdio_write(tp, 0x06, 0xe02c);
  5009.                         mdio_write(tp, 0x06, 0xe7e0);
  5010.                         mdio_write(tp, 0x06, 0x2de2);
  5011.                         mdio_write(tp, 0x06, 0xe2cc);
  5012.                         mdio_write(tp, 0x06, 0xe3e2);
  5013.                         mdio_write(tp, 0x06, 0xcdf9);
  5014.                         mdio_write(tp, 0x06, 0x5a0f);
  5015.                         mdio_write(tp, 0x06, 0x6a50);
  5016.                         mdio_write(tp, 0x06, 0xe6e2);
  5017.                         mdio_write(tp, 0x06, 0xcce7);
  5018.                         mdio_write(tp, 0x06, 0xe2cd);
  5019.                         mdio_write(tp, 0x06, 0xe0e0);
  5020.                         mdio_write(tp, 0x06, 0x3ce1);
  5021.                         mdio_write(tp, 0x06, 0xe03d);
  5022.                         mdio_write(tp, 0x06, 0xef64);
  5023.                         mdio_write(tp, 0x06, 0xfde0);
  5024.                         mdio_write(tp, 0x06, 0xe2cc);
  5025.                         mdio_write(tp, 0x06, 0xe1e2);
  5026.                         mdio_write(tp, 0x06, 0xcd58);
  5027.                         mdio_write(tp, 0x06, 0x0f5a);
  5028.                         mdio_write(tp, 0x06, 0xf01e);
  5029.                         mdio_write(tp, 0x06, 0x02e4);
  5030.                         mdio_write(tp, 0x06, 0xe2cc);
  5031.                         mdio_write(tp, 0x06, 0xe5e2);
  5032.                         mdio_write(tp, 0x06, 0xcdfd);
  5033.                         mdio_write(tp, 0x06, 0xe0e0);
  5034.                         mdio_write(tp, 0x06, 0x2ce1);
  5035.                         mdio_write(tp, 0x06, 0xe02d);
  5036.                         mdio_write(tp, 0x06, 0x59e0);
  5037.                         mdio_write(tp, 0x06, 0x5b1f);
  5038.                         mdio_write(tp, 0x06, 0x1e13);
  5039.                         mdio_write(tp, 0x06, 0xe4e0);
  5040.                         mdio_write(tp, 0x06, 0x2ce5);
  5041.                         mdio_write(tp, 0x06, 0xe02d);
  5042.                         mdio_write(tp, 0x06, 0xfde0);
  5043.                         mdio_write(tp, 0x06, 0xe2d2);
  5044.                         mdio_write(tp, 0x06, 0xe1e2);
  5045.                         mdio_write(tp, 0x06, 0xd358);
  5046.                         mdio_write(tp, 0x06, 0xf75a);
  5047.                         mdio_write(tp, 0x06, 0x081e);
  5048.                         mdio_write(tp, 0x06, 0x02e4);
  5049.                         mdio_write(tp, 0x06, 0xe2d2);
  5050.                         mdio_write(tp, 0x06, 0xe5e2);
  5051.                         mdio_write(tp, 0x06, 0xd3ef);
  5052.                         mdio_write(tp, 0x06, 0x46fe);
  5053.                         mdio_write(tp, 0x06, 0xfd04);
  5054.                         mdio_write(tp, 0x06, 0xf8f9);
  5055.                         mdio_write(tp, 0x06, 0xfaef);
  5056.                         mdio_write(tp, 0x06, 0x69e0);
  5057.                         mdio_write(tp, 0x06, 0xe022);
  5058.                         mdio_write(tp, 0x06, 0xe1e0);
  5059.                         mdio_write(tp, 0x06, 0x2358);
  5060.                         mdio_write(tp, 0x06, 0xc4e1);
  5061.                         mdio_write(tp, 0x06, 0x8b6e);
  5062.                         mdio_write(tp, 0x06, 0x1f10);
  5063.                         mdio_write(tp, 0x06, 0x9e58);
  5064.                         mdio_write(tp, 0x06, 0xe48b);
  5065.                         mdio_write(tp, 0x06, 0x6ead);
  5066.                         mdio_write(tp, 0x06, 0x2222);
  5067.                         mdio_write(tp, 0x06, 0xac27);
  5068.                         mdio_write(tp, 0x06, 0x55ac);
  5069.                         mdio_write(tp, 0x06, 0x2602);
  5070.                         mdio_write(tp, 0x06, 0xae1a);
  5071.                         mdio_write(tp, 0x06, 0xd106);
  5072.                         mdio_write(tp, 0x06, 0xbf3b);
  5073.                         mdio_write(tp, 0x06, 0xba02);
  5074.                         mdio_write(tp, 0x06, 0x2dc1);
  5075.                         mdio_write(tp, 0x06, 0xd107);
  5076.                         mdio_write(tp, 0x06, 0xbf3b);
  5077.                         mdio_write(tp, 0x06, 0xbd02);
  5078.                         mdio_write(tp, 0x06, 0x2dc1);
  5079.                         mdio_write(tp, 0x06, 0xd107);
  5080.                         mdio_write(tp, 0x06, 0xbf3b);
  5081.                         mdio_write(tp, 0x06, 0xc002);
  5082.                         mdio_write(tp, 0x06, 0x2dc1);
  5083.                         mdio_write(tp, 0x06, 0xae30);
  5084.                         mdio_write(tp, 0x06, 0xd103);
  5085.                         mdio_write(tp, 0x06, 0xbf3b);
  5086.                         mdio_write(tp, 0x06, 0xc302);
  5087.                         mdio_write(tp, 0x06, 0x2dc1);
  5088.                         mdio_write(tp, 0x06, 0xd100);
  5089.                         mdio_write(tp, 0x06, 0xbf3b);
  5090.                         mdio_write(tp, 0x06, 0xc602);
  5091.                         mdio_write(tp, 0x06, 0x2dc1);
  5092.                         mdio_write(tp, 0x06, 0xd100);
  5093.                         mdio_write(tp, 0x06, 0xbf82);
  5094.                         mdio_write(tp, 0x06, 0xca02);
  5095.                         mdio_write(tp, 0x06, 0x2dc1);
  5096.                         mdio_write(tp, 0x06, 0xd10f);
  5097.                         mdio_write(tp, 0x06, 0xbf3b);
  5098.                         mdio_write(tp, 0x06, 0xba02);
  5099.                         mdio_write(tp, 0x06, 0x2dc1);
  5100.                         mdio_write(tp, 0x06, 0xd101);
  5101.                         mdio_write(tp, 0x06, 0xbf3b);
  5102.                         mdio_write(tp, 0x06, 0xbd02);
  5103.                         mdio_write(tp, 0x06, 0x2dc1);
  5104.                         mdio_write(tp, 0x06, 0xd101);
  5105.                         mdio_write(tp, 0x06, 0xbf3b);
  5106.                         mdio_write(tp, 0x06, 0xc002);
  5107.                         mdio_write(tp, 0x06, 0x2dc1);
  5108.                         mdio_write(tp, 0x06, 0xef96);
  5109.                         mdio_write(tp, 0x06, 0xfefd);
  5110.                         mdio_write(tp, 0x06, 0xfc04);
  5111.                         mdio_write(tp, 0x06, 0xd100);
  5112.                         mdio_write(tp, 0x06, 0xbf3b);
  5113.                         mdio_write(tp, 0x06, 0xc302);
  5114.                         mdio_write(tp, 0x06, 0x2dc1);
  5115.                         mdio_write(tp, 0x06, 0xd011);
  5116.                         mdio_write(tp, 0x06, 0x022b);
  5117.                         mdio_write(tp, 0x06, 0xfb59);
  5118.                         mdio_write(tp, 0x06, 0x03ef);
  5119.                         mdio_write(tp, 0x06, 0x01d1);
  5120.                         mdio_write(tp, 0x06, 0x00a0);
  5121.                         mdio_write(tp, 0x06, 0x0002);
  5122.                         mdio_write(tp, 0x06, 0xd101);
  5123.                         mdio_write(tp, 0x06, 0xbf3b);
  5124.                         mdio_write(tp, 0x06, 0xc602);
  5125.                         mdio_write(tp, 0x06, 0x2dc1);
  5126.                         mdio_write(tp, 0x06, 0xd111);
  5127.                         mdio_write(tp, 0x06, 0xad20);
  5128.                         mdio_write(tp, 0x06, 0x020c);
  5129.                         mdio_write(tp, 0x06, 0x11ad);
  5130.                         mdio_write(tp, 0x06, 0x2102);
  5131.                         mdio_write(tp, 0x06, 0x0c12);
  5132.                         mdio_write(tp, 0x06, 0xbf82);
  5133.                         mdio_write(tp, 0x06, 0xca02);
  5134.                         mdio_write(tp, 0x06, 0x2dc1);
  5135.                         mdio_write(tp, 0x06, 0xaec8);
  5136.                         mdio_write(tp, 0x06, 0x70e4);
  5137.                         mdio_write(tp, 0x06, 0x2602);
  5138.                         mdio_write(tp, 0x06, 0x82d1);
  5139.                         mdio_write(tp, 0x06, 0x05f8);
  5140.                         mdio_write(tp, 0x06, 0xfaef);
  5141.                         mdio_write(tp, 0x06, 0x69e0);
  5142.                         mdio_write(tp, 0x06, 0xe2fe);
  5143.                         mdio_write(tp, 0x06, 0xe1e2);
  5144.                         mdio_write(tp, 0x06, 0xffad);
  5145.                         mdio_write(tp, 0x06, 0x2d1a);
  5146.                         mdio_write(tp, 0x06, 0xe0e1);
  5147.                         mdio_write(tp, 0x06, 0x4ee1);
  5148.                         mdio_write(tp, 0x06, 0xe14f);
  5149.                         mdio_write(tp, 0x06, 0xac2d);
  5150.                         mdio_write(tp, 0x06, 0x22f6);
  5151.                         mdio_write(tp, 0x06, 0x0302);
  5152.                         mdio_write(tp, 0x06, 0x033b);
  5153.                         mdio_write(tp, 0x06, 0xf703);
  5154.                         mdio_write(tp, 0x06, 0xf706);
  5155.                         mdio_write(tp, 0x06, 0xbf84);
  5156.                         mdio_write(tp, 0x06, 0x4402);
  5157.                         mdio_write(tp, 0x06, 0x2d21);
  5158.                         mdio_write(tp, 0x06, 0xae11);
  5159.                         mdio_write(tp, 0x06, 0xe0e1);
  5160.                         mdio_write(tp, 0x06, 0x4ee1);
  5161.                         mdio_write(tp, 0x06, 0xe14f);
  5162.                         mdio_write(tp, 0x06, 0xad2d);
  5163.                         mdio_write(tp, 0x06, 0x08bf);
  5164.                         mdio_write(tp, 0x06, 0x844f);
  5165.                         mdio_write(tp, 0x06, 0x022d);
  5166.                         mdio_write(tp, 0x06, 0x21f6);
  5167.                         mdio_write(tp, 0x06, 0x06ef);
  5168.                         mdio_write(tp, 0x06, 0x96fe);
  5169.                         mdio_write(tp, 0x06, 0xfc04);
  5170.                         mdio_write(tp, 0x06, 0xf8fa);
  5171.                         mdio_write(tp, 0x06, 0xef69);
  5172.                         mdio_write(tp, 0x06, 0x0283);
  5173.                         mdio_write(tp, 0x06, 0x4502);
  5174.                         mdio_write(tp, 0x06, 0x83a2);
  5175.                         mdio_write(tp, 0x06, 0xe0e0);
  5176.                         mdio_write(tp, 0x06, 0x00e1);
  5177.                         mdio_write(tp, 0x06, 0xe001);
  5178.                         mdio_write(tp, 0x06, 0xad27);
  5179.                         mdio_write(tp, 0x06, 0x1fd1);
  5180.                         mdio_write(tp, 0x06, 0x01bf);
  5181.                         mdio_write(tp, 0x06, 0x843b);
  5182.                         mdio_write(tp, 0x06, 0x022d);
  5183.                         mdio_write(tp, 0x06, 0xc1e0);
  5184.                         mdio_write(tp, 0x06, 0xe020);
  5185.                         mdio_write(tp, 0x06, 0xe1e0);
  5186.                         mdio_write(tp, 0x06, 0x21ad);
  5187.                         mdio_write(tp, 0x06, 0x200e);
  5188.                         mdio_write(tp, 0x06, 0xd100);
  5189.                         mdio_write(tp, 0x06, 0xbf84);
  5190.                         mdio_write(tp, 0x06, 0x3b02);
  5191.                         mdio_write(tp, 0x06, 0x2dc1);
  5192.                         mdio_write(tp, 0x06, 0xbf3b);
  5193.                         mdio_write(tp, 0x06, 0x9602);
  5194.                         mdio_write(tp, 0x06, 0x2d21);
  5195.                         mdio_write(tp, 0x06, 0xef96);
  5196.                         mdio_write(tp, 0x06, 0xfefc);
  5197.                         mdio_write(tp, 0x06, 0x04f8);
  5198.                         mdio_write(tp, 0x06, 0xf9fa);
  5199.                         mdio_write(tp, 0x06, 0xef69);
  5200.                         mdio_write(tp, 0x06, 0xe08b);
  5201.                         mdio_write(tp, 0x06, 0x87ad);
  5202.                         mdio_write(tp, 0x06, 0x204c);
  5203.                         mdio_write(tp, 0x06, 0xd200);
  5204.                         mdio_write(tp, 0x06, 0xe0e2);
  5205.                         mdio_write(tp, 0x06, 0x0058);
  5206.                         mdio_write(tp, 0x06, 0x010c);
  5207.                         mdio_write(tp, 0x06, 0x021e);
  5208.                         mdio_write(tp, 0x06, 0x20e0);
  5209.                         mdio_write(tp, 0x06, 0xe000);
  5210.                         mdio_write(tp, 0x06, 0x5810);
  5211.                         mdio_write(tp, 0x06, 0x1e20);
  5212.                         mdio_write(tp, 0x06, 0xe0e0);
  5213.                         mdio_write(tp, 0x06, 0x3658);
  5214.                         mdio_write(tp, 0x06, 0x031e);
  5215.                         mdio_write(tp, 0x06, 0x20e0);
  5216.                         mdio_write(tp, 0x06, 0xe022);
  5217.                         mdio_write(tp, 0x06, 0xe1e0);
  5218.                         mdio_write(tp, 0x06, 0x2358);
  5219.                         mdio_write(tp, 0x06, 0xe01e);
  5220.                         mdio_write(tp, 0x06, 0x20e0);
  5221.                         mdio_write(tp, 0x06, 0x8b64);
  5222.                         mdio_write(tp, 0x06, 0x1f02);
  5223.                         mdio_write(tp, 0x06, 0x9e22);
  5224.                         mdio_write(tp, 0x06, 0xe68b);
  5225.                         mdio_write(tp, 0x06, 0x64ad);
  5226.                         mdio_write(tp, 0x06, 0x3214);
  5227.                         mdio_write(tp, 0x06, 0xad34);
  5228.                         mdio_write(tp, 0x06, 0x11ef);
  5229.                         mdio_write(tp, 0x06, 0x0258);
  5230.                         mdio_write(tp, 0x06, 0x039e);
  5231.                         mdio_write(tp, 0x06, 0x07ad);
  5232.                         mdio_write(tp, 0x06, 0x3508);
  5233.                         mdio_write(tp, 0x06, 0x5ac0);
  5234.                         mdio_write(tp, 0x06, 0x9f04);
  5235.                         mdio_write(tp, 0x06, 0xd101);
  5236.                         mdio_write(tp, 0x06, 0xae02);
  5237.                         mdio_write(tp, 0x06, 0xd100);
  5238.                         mdio_write(tp, 0x06, 0xbf84);
  5239.                         mdio_write(tp, 0x06, 0x3e02);
  5240.                         mdio_write(tp, 0x06, 0x2dc1);
  5241.                         mdio_write(tp, 0x06, 0xef96);
  5242.                         mdio_write(tp, 0x06, 0xfefd);
  5243.                         mdio_write(tp, 0x06, 0xfc04);
  5244.                         mdio_write(tp, 0x06, 0xf8f9);
  5245.                         mdio_write(tp, 0x06, 0xfbe0);
  5246.                         mdio_write(tp, 0x06, 0x8b85);
  5247.                         mdio_write(tp, 0x06, 0xad25);
  5248.                         mdio_write(tp, 0x06, 0x22e0);
  5249.                         mdio_write(tp, 0x06, 0xe022);
  5250.                         mdio_write(tp, 0x06, 0xe1e0);
  5251.                         mdio_write(tp, 0x06, 0x23e2);
  5252.                         mdio_write(tp, 0x06, 0xe036);
  5253.                         mdio_write(tp, 0x06, 0xe3e0);
  5254.                         mdio_write(tp, 0x06, 0x375a);
  5255.                         mdio_write(tp, 0x06, 0xc40d);
  5256.                         mdio_write(tp, 0x06, 0x0158);
  5257.                         mdio_write(tp, 0x06, 0x021e);
  5258.                         mdio_write(tp, 0x06, 0x20e3);
  5259.                         mdio_write(tp, 0x06, 0x8ae7);
  5260.                         mdio_write(tp, 0x06, 0xac31);
  5261.                         mdio_write(tp, 0x06, 0x60ac);
  5262.                         mdio_write(tp, 0x06, 0x3a08);
  5263.                         mdio_write(tp, 0x06, 0xac3e);
  5264.                         mdio_write(tp, 0x06, 0x26ae);
  5265.                         mdio_write(tp, 0x06, 0x67af);
  5266.                         mdio_write(tp, 0x06, 0x8437);
  5267.                         mdio_write(tp, 0x06, 0xad37);
  5268.                         mdio_write(tp, 0x06, 0x61e0);
  5269.                         mdio_write(tp, 0x06, 0x8ae8);
  5270.                         mdio_write(tp, 0x06, 0x10e4);
  5271.                         mdio_write(tp, 0x06, 0x8ae8);
  5272.                         mdio_write(tp, 0x06, 0xe18a);
  5273.                         mdio_write(tp, 0x06, 0xe91b);
  5274.                         mdio_write(tp, 0x06, 0x109e);
  5275.                         mdio_write(tp, 0x06, 0x02ae);
  5276.                         mdio_write(tp, 0x06, 0x51d1);
  5277.                         mdio_write(tp, 0x06, 0x00bf);
  5278.                         mdio_write(tp, 0x06, 0x8441);
  5279.                         mdio_write(tp, 0x06, 0x022d);
  5280.                         mdio_write(tp, 0x06, 0xc1ee);
  5281.                         mdio_write(tp, 0x06, 0x8ae8);
  5282.                         mdio_write(tp, 0x06, 0x00ae);
  5283.                         mdio_write(tp, 0x06, 0x43ad);
  5284.                         mdio_write(tp, 0x06, 0x3627);
  5285.                         mdio_write(tp, 0x06, 0xe08a);
  5286.                         mdio_write(tp, 0x06, 0xeee1);
  5287.                         mdio_write(tp, 0x06, 0x8aef);
  5288.                         mdio_write(tp, 0x06, 0xef74);
  5289.                         mdio_write(tp, 0x06, 0xe08a);
  5290.                         mdio_write(tp, 0x06, 0xeae1);
  5291.                         mdio_write(tp, 0x06, 0x8aeb);
  5292.                         mdio_write(tp, 0x06, 0x1b74);
  5293.                         mdio_write(tp, 0x06, 0x9e2e);
  5294.                         mdio_write(tp, 0x06, 0x14e4);
  5295.                         mdio_write(tp, 0x06, 0x8aea);
  5296.                         mdio_write(tp, 0x06, 0xe58a);
  5297.                         mdio_write(tp, 0x06, 0xebef);
  5298.                         mdio_write(tp, 0x06, 0x74e0);
  5299.                         mdio_write(tp, 0x06, 0x8aee);
  5300.                         mdio_write(tp, 0x06, 0xe18a);
  5301.                         mdio_write(tp, 0x06, 0xef1b);
  5302.                         mdio_write(tp, 0x06, 0x479e);
  5303.                         mdio_write(tp, 0x06, 0x0fae);
  5304.                         mdio_write(tp, 0x06, 0x19ee);
  5305.                         mdio_write(tp, 0x06, 0x8aea);
  5306.                         mdio_write(tp, 0x06, 0x00ee);
  5307.                         mdio_write(tp, 0x06, 0x8aeb);
  5308.                         mdio_write(tp, 0x06, 0x00ae);
  5309.                         mdio_write(tp, 0x06, 0x0fac);
  5310.                         mdio_write(tp, 0x06, 0x390c);
  5311.                         mdio_write(tp, 0x06, 0xd101);
  5312.                         mdio_write(tp, 0x06, 0xbf84);
  5313.                         mdio_write(tp, 0x06, 0x4102);
  5314.                         mdio_write(tp, 0x06, 0x2dc1);
  5315.                         mdio_write(tp, 0x06, 0xee8a);
  5316.                         mdio_write(tp, 0x06, 0xe800);
  5317.                         mdio_write(tp, 0x06, 0xe68a);
  5318.                         mdio_write(tp, 0x06, 0xe7ff);
  5319.                         mdio_write(tp, 0x06, 0xfdfc);
  5320.                         mdio_write(tp, 0x06, 0x0400);
  5321.                         mdio_write(tp, 0x06, 0xe234);
  5322.                         mdio_write(tp, 0x06, 0xcce2);
  5323.                         mdio_write(tp, 0x06, 0x0088);
  5324.                         mdio_write(tp, 0x06, 0xe200);
  5325.                         mdio_write(tp, 0x06, 0xa725);
  5326.                         mdio_write(tp, 0x06, 0xe50a);
  5327.                         mdio_write(tp, 0x06, 0x1de5);
  5328.                         mdio_write(tp, 0x06, 0x0a2c);
  5329.                         mdio_write(tp, 0x06, 0xe50a);
  5330.                         mdio_write(tp, 0x06, 0x6de5);
  5331.                         mdio_write(tp, 0x06, 0x0a1d);
  5332.                         mdio_write(tp, 0x06, 0xe50a);
  5333.                         mdio_write(tp, 0x06, 0x1ce5);
  5334.                         mdio_write(tp, 0x06, 0x0a2d);
  5335.                         mdio_write(tp, 0x06, 0xa755);
  5336.                         mdio_write(tp, 0x05, 0x8b64);
  5337.                         mdio_write(tp, 0x06, 0x0000);
  5338.                         mdio_write(tp, 0x05, 0x8b94);
  5339.                         mdio_write(tp, 0x06, 0x82cd);
  5340.                         mdio_write(tp, 0x05, 0x8b85);
  5341.                         mdio_write(tp, 0x06, 0x2000);
  5342.                         mdio_write(tp, 0x05, 0x8aee);
  5343.                         mdio_write(tp, 0x06, 0x03b8);
  5344.                         mdio_write(tp, 0x05, 0x8ae8);
  5345.                         mdio_write(tp, 0x06, 0x0002);
  5346.                         gphy_val = mdio_read(tp, 0x01);
  5347.                         gphy_val |= BIT_0;
  5348.                         mdio_write(tp, 0x01, gphy_val);
  5349.                         gphy_val = mdio_read(tp, 0x00);
  5350.                         gphy_val |= BIT_0;
  5351.                         mdio_write(tp, 0x00, gphy_val);
  5352.                         mdio_write(tp, 0x1f, 0x0000);
  5353.                         mdio_write(tp, 0x1f, 0x0005);
  5354.                         for (i = 0; i < 200; i++) {
  5355.                                 udelay(100);
  5356.                                 gphy_val = mdio_read(tp, 0x00);
  5357.                                 if (gphy_val & BIT_7)
  5358.                                         break;
  5359.                         }
  5360.                         mdio_write(tp, 0x1f, 0x0007);
  5361.                         mdio_write(tp, 0x1e, 0x0023);
  5362.                         gphy_val = mdio_read(tp, 0x17);
  5363.                         gphy_val &= ~(BIT_0);
  5364.                         if ((pdev->subsystem_vendor == 0x144d &&
  5365.                              pdev->subsystem_device == 0xc098) ||
  5366.                             (pdev->subsystem_vendor == 0x144d &&
  5367.                              pdev->subsystem_device == 0xc0b1)) {
  5368.                                 gphy_val &= ~(BIT_2);
  5369.                         }
  5370.                         mdio_write(tp, 0x17, gphy_val);
  5371.                         mdio_write(tp, 0x1f, 0x0007);
  5372.                         mdio_write(tp, 0x1e, 0x0028);
  5373.                         mdio_write(tp, 0x15, 0x0010);
  5374.                         mdio_write(tp, 0x1f, 0x0007);
  5375.                         mdio_write(tp, 0x1e, 0x0041);
  5376.                         mdio_write(tp, 0x15, 0x0802);
  5377.                         mdio_write(tp, 0x16, 0x2185);
  5378.                         mdio_write(tp, 0x1f, 0x0000);
  5379.                         spin_unlock_irqrestore(&tp->phy_lock, flags);
  5380.                 } else {
  5381.                         spin_lock_irqsave(&tp->phy_lock, flags);
  5382.                         mdio_write(tp, 0x1f, 0x0000);
  5383.                         mdio_write(tp, 0x00, 0x1800);
  5384.                         mdio_write(tp, 0x1f, 0x0007);
  5385.                         mdio_write(tp, 0x1e, 0x0023);
  5386.                         mdio_write(tp, 0x17, 0x0117);
  5387.                         mdio_write(tp, 0x1f, 0x0007);
  5388.                         mdio_write(tp, 0x1E, 0x002C);
  5389.                         mdio_write(tp, 0x1B, 0x5000);
  5390.                         mdio_write(tp, 0x1f, 0x0000);
  5391.                         mdio_write(tp, 0x16, 0x4104);
  5392.                         for (i = 0; i < 200; i++) {
  5393.                                 udelay(100);
  5394.                                 gphy_val = mdio_read(tp, 0x1E);
  5395.                                 gphy_val &= 0x03FF;
  5396.                                 if (gphy_val==0x000C)
  5397.                                         break;
  5398.                         }
  5399.                         mdio_write(tp, 0x1f, 0x0005);
  5400.                         for (i = 0; i < 200; i++) {
  5401.                                 udelay(100);
  5402.                                 gphy_val = mdio_read(tp, 0x07);
  5403.                                 if ((gphy_val & BIT_5) == 0)
  5404.                                         break;
  5405.                         }
  5406.                         gphy_val = mdio_read(tp, 0x07);
  5407.                         if (gphy_val & BIT_5) {
  5408.                                 mdio_write(tp, 0x1f, 0x0007);
  5409.                                 mdio_write(tp, 0x1e, 0x00a1);
  5410.                                 mdio_write(tp, 0x17, 0x1000);
  5411.                                 mdio_write(tp, 0x17, 0x0000);
  5412.                                 mdio_write(tp, 0x17, 0x2000);
  5413.                                 mdio_write(tp, 0x1e, 0x002f);
  5414.                                 mdio_write(tp, 0x18, 0x9bfb);
  5415.                                 mdio_write(tp, 0x1f, 0x0005);
  5416.                                 mdio_write(tp, 0x07, 0x0000);
  5417.                                 mdio_write(tp, 0x1f, 0x0000);
  5418.                         }
  5419.                         mdio_write(tp, 0x1f, 0x0005);
  5420.                         mdio_write(tp, 0x05, 0xfff6);
  5421.                         mdio_write(tp, 0x06, 0x0080);
  5422.                         gphy_val = mdio_read(tp, 0x00);
  5423.                         gphy_val &= ~(BIT_7);
  5424.                         mdio_write(tp, 0x00, gphy_val);
  5425.                         mdio_write(tp, 0x1f, 0x0002);
  5426.                         gphy_val = mdio_read(tp, 0x08);
  5427.                         gphy_val &= ~(BIT_7);
  5428.                         mdio_write(tp, 0x08, gphy_val);
  5429.                         mdio_write(tp, 0x1f, 0x0000);
  5430.                         mdio_write(tp, 0x1f, 0x0007);
  5431.                         mdio_write(tp, 0x1e, 0x0023);
  5432.                         mdio_write(tp, 0x16, 0x0306);
  5433.                         mdio_write(tp, 0x16, 0x0307);
  5434.                         mdio_write(tp, 0x15, 0x000e);
  5435.                         mdio_write(tp, 0x19, 0x000a);
  5436.                         mdio_write(tp, 0x15, 0x0010);
  5437.                         mdio_write(tp, 0x19, 0x0008);
  5438.                         mdio_write(tp, 0x15, 0x0018);
  5439.                         mdio_write(tp, 0x19, 0x4801);
  5440.                         mdio_write(tp, 0x15, 0x0019);
  5441.                         mdio_write(tp, 0x19, 0x6801);
  5442.                         mdio_write(tp, 0x15, 0x001a);
  5443.                         mdio_write(tp, 0x19, 0x66a1);
  5444.                         mdio_write(tp, 0x15, 0x001f);
  5445.                         mdio_write(tp, 0x19, 0x0000);
  5446.                         mdio_write(tp, 0x15, 0x0020);
  5447.                         mdio_write(tp, 0x19, 0x0000);
  5448.                         mdio_write(tp, 0x15, 0x0021);
  5449.                         mdio_write(tp, 0x19, 0x0000);
  5450.                         mdio_write(tp, 0x15, 0x0022);
  5451.                         mdio_write(tp, 0x19, 0x0000);
  5452.                         mdio_write(tp, 0x15, 0x0023);
  5453.                         mdio_write(tp, 0x19, 0x0000);
  5454.                         mdio_write(tp, 0x15, 0x0024);
  5455.                         mdio_write(tp, 0x19, 0x0000);
  5456.                         mdio_write(tp, 0x15, 0x0025);
  5457.                         mdio_write(tp, 0x19, 0x64a1);
  5458.                         mdio_write(tp, 0x15, 0x0026);
  5459.                         mdio_write(tp, 0x19, 0x40ea);
  5460.                         mdio_write(tp, 0x15, 0x0027);
  5461.                         mdio_write(tp, 0x19, 0x4503);
  5462.                         mdio_write(tp, 0x15, 0x0028);
  5463.                         mdio_write(tp, 0x19, 0x9f00);
  5464.                         mdio_write(tp, 0x15, 0x0029);
  5465.                         mdio_write(tp, 0x19, 0xa631);
  5466.                         mdio_write(tp, 0x15, 0x002a);
  5467.                         mdio_write(tp, 0x19, 0x9717);
  5468.                         mdio_write(tp, 0x15, 0x002b);
  5469.                         mdio_write(tp, 0x19, 0x302c);
  5470.                         mdio_write(tp, 0x15, 0x002c);
  5471.                         mdio_write(tp, 0x19, 0x4802);
  5472.                         mdio_write(tp, 0x15, 0x002d);
  5473.                         mdio_write(tp, 0x19, 0x58da);
  5474.                         mdio_write(tp, 0x15, 0x002e);
  5475.                         mdio_write(tp, 0x19, 0x400d);
  5476.                         mdio_write(tp, 0x15, 0x002f);
  5477.                         mdio_write(tp, 0x19, 0x4488);
  5478.                         mdio_write(tp, 0x15, 0x0030);
  5479.                         mdio_write(tp, 0x19, 0x9e00);
  5480.                         mdio_write(tp, 0x15, 0x0031);
  5481.                         mdio_write(tp, 0x19, 0x63c8);
  5482.                         mdio_write(tp, 0x15, 0x0032);
  5483.                         mdio_write(tp, 0x19, 0x6481);
  5484.                         mdio_write(tp, 0x15, 0x0033);
  5485.                         mdio_write(tp, 0x19, 0x0000);
  5486.                         mdio_write(tp, 0x15, 0x0034);
  5487.                         mdio_write(tp, 0x19, 0x0000);
  5488.                         mdio_write(tp, 0x15, 0x0035);
  5489.                         mdio_write(tp, 0x19, 0x0000);
  5490.                         mdio_write(tp, 0x15, 0x0036);
  5491.                         mdio_write(tp, 0x19, 0x0000);
  5492.                         mdio_write(tp, 0x15, 0x0037);
  5493.                         mdio_write(tp, 0x19, 0x0000);
  5494.                         mdio_write(tp, 0x15, 0x0038);
  5495.                         mdio_write(tp, 0x19, 0x0000);
  5496.                         mdio_write(tp, 0x15, 0x0039);
  5497.                         mdio_write(tp, 0x19, 0x0000);
  5498.                         mdio_write(tp, 0x15, 0x003a);
  5499.                         mdio_write(tp, 0x19, 0x0000);
  5500.                         mdio_write(tp, 0x15, 0x003b);
  5501.                         mdio_write(tp, 0x19, 0x63e8);
  5502.                         mdio_write(tp, 0x15, 0x003c);
  5503.                         mdio_write(tp, 0x19, 0x7d00);
  5504.                         mdio_write(tp, 0x15, 0x003d);
  5505.                         mdio_write(tp, 0x19, 0x59d4);
  5506.                         mdio_write(tp, 0x15, 0x003e);
  5507.                         mdio_write(tp, 0x19, 0x63f8);
  5508.                         mdio_write(tp, 0x15, 0x0040);
  5509.                         mdio_write(tp, 0x19, 0x64a1);
  5510.                         mdio_write(tp, 0x15, 0x0041);
  5511.                         mdio_write(tp, 0x19, 0x30de);
  5512.                         mdio_write(tp, 0x15, 0x0044);
  5513.                         mdio_write(tp, 0x19, 0x480f);
  5514.                         mdio_write(tp, 0x15, 0x0045);
  5515.                         mdio_write(tp, 0x19, 0x6800);
  5516.                         mdio_write(tp, 0x15, 0x0046);
  5517.                         mdio_write(tp, 0x19, 0x6680);
  5518.                         mdio_write(tp, 0x15, 0x0047);
  5519.                         mdio_write(tp, 0x19, 0x7c10);
  5520.                         mdio_write(tp, 0x15, 0x0048);
  5521.                         mdio_write(tp, 0x19, 0x63c8);
  5522.                         mdio_write(tp, 0x15, 0x0049);
  5523.                         mdio_write(tp, 0x19, 0x0000);
  5524.                         mdio_write(tp, 0x15, 0x004a);
  5525.                         mdio_write(tp, 0x19, 0x0000);
  5526.                         mdio_write(tp, 0x15, 0x004b);
  5527.                         mdio_write(tp, 0x19, 0x0000);
  5528.                         mdio_write(tp, 0x15, 0x004c);
  5529.                         mdio_write(tp, 0x19, 0x0000);
  5530.                         mdio_write(tp, 0x15, 0x004d);
  5531.                         mdio_write(tp, 0x19, 0x0000);
  5532.                         mdio_write(tp, 0x15, 0x004e);
  5533.                         mdio_write(tp, 0x19, 0x0000);
  5534.                         mdio_write(tp, 0x15, 0x004f);
  5535.                         mdio_write(tp, 0x19, 0x40ea);
  5536.                         mdio_write(tp, 0x15, 0x0050);
  5537.                         mdio_write(tp, 0x19, 0x4503);
  5538.                         mdio_write(tp, 0x15, 0x0051);
  5539.                         mdio_write(tp, 0x19, 0x58ca);
  5540.                         mdio_write(tp, 0x15, 0x0052);
  5541.                         mdio_write(tp, 0x19, 0x63c8);
  5542.                         mdio_write(tp, 0x15, 0x0053);
  5543.                         mdio_write(tp, 0x19, 0x63d8);
  5544.                         mdio_write(tp, 0x15, 0x0054);
  5545.                         mdio_write(tp, 0x19, 0x66a0);
  5546.                         mdio_write(tp, 0x15, 0x0055);
  5547.                         mdio_write(tp, 0x19, 0x9f00);
  5548.                         mdio_write(tp, 0x15, 0x0056);
  5549.                         mdio_write(tp, 0x19, 0x3000);
  5550.                         mdio_write(tp, 0x15, 0x00a1);
  5551.                         mdio_write(tp, 0x19, 0x3044);
  5552.                         mdio_write(tp, 0x15, 0x00ab);
  5553.                         mdio_write(tp, 0x19, 0x5820);
  5554.                         mdio_write(tp, 0x15, 0x00ac);
  5555.                         mdio_write(tp, 0x19, 0x5e04);
  5556.                         mdio_write(tp, 0x15, 0x00ad);
  5557.                         mdio_write(tp, 0x19, 0xb60c);
  5558.                         mdio_write(tp, 0x15, 0x00af);
  5559.                         mdio_write(tp, 0x19, 0x000a);
  5560.                         mdio_write(tp, 0x15, 0x00b2);
  5561.                         mdio_write(tp, 0x19, 0x30b9);
  5562.                         mdio_write(tp, 0x15, 0x00b9);
  5563.                         mdio_write(tp, 0x19, 0x4408);
  5564.                         mdio_write(tp, 0x15, 0x00ba);
  5565.                         mdio_write(tp, 0x19, 0x480b);
  5566.                         mdio_write(tp, 0x15, 0x00bb);
  5567.                         mdio_write(tp, 0x19, 0x5e00);
  5568.                         mdio_write(tp, 0x15, 0x00bc);
  5569.                         mdio_write(tp, 0x19, 0x405f);
  5570.                         mdio_write(tp, 0x15, 0x00bd);
  5571.                         mdio_write(tp, 0x19, 0x4448);
  5572.                         mdio_write(tp, 0x15, 0x00be);
  5573.                         mdio_write(tp, 0x19, 0x4020);
  5574.                         mdio_write(tp, 0x15, 0x00bf);
  5575.                         mdio_write(tp, 0x19, 0x4468);
  5576.                         mdio_write(tp, 0x15, 0x00c0);
  5577.                         mdio_write(tp, 0x19, 0x9c02);
  5578.                         mdio_write(tp, 0x15, 0x00c1);
  5579.                         mdio_write(tp, 0x19, 0x58a0);
  5580.                         mdio_write(tp, 0x15, 0x00c2);
  5581.                         mdio_write(tp, 0x19, 0xb605);
  5582.                         mdio_write(tp, 0x15, 0x00c3);
  5583.                         mdio_write(tp, 0x19, 0xc0d3);
  5584.                         mdio_write(tp, 0x15, 0x00c4);
  5585.                         mdio_write(tp, 0x19, 0x00e6);
  5586.                         mdio_write(tp, 0x15, 0x00c5);
  5587.                         mdio_write(tp, 0x19, 0xdaec);
  5588.                         mdio_write(tp, 0x15, 0x00c6);
  5589.                         mdio_write(tp, 0x19, 0x00fa);
  5590.                         mdio_write(tp, 0x15, 0x00c7);
  5591.                         mdio_write(tp, 0x19, 0x9df9);
  5592.                         mdio_write(tp, 0x15, 0x0112);
  5593.                         mdio_write(tp, 0x19, 0x6421);
  5594.                         mdio_write(tp, 0x15, 0x0113);
  5595.                         mdio_write(tp, 0x19, 0x7c08);
  5596.                         mdio_write(tp, 0x15, 0x0114);
  5597.                         mdio_write(tp, 0x19, 0x63f0);
  5598.                         mdio_write(tp, 0x15, 0x0115);
  5599.                         mdio_write(tp, 0x19, 0x4003);
  5600.                         mdio_write(tp, 0x15, 0x0116);
  5601.                         mdio_write(tp, 0x19, 0x4418);
  5602.                         mdio_write(tp, 0x15, 0x0117);
  5603.                         mdio_write(tp, 0x19, 0x9b00);
  5604.                         mdio_write(tp, 0x15, 0x0118);
  5605.                         mdio_write(tp, 0x19, 0x6461);
  5606.                         mdio_write(tp, 0x15, 0x0119);
  5607.                         mdio_write(tp, 0x19, 0x64e1);
  5608.                         mdio_write(tp, 0x15, 0x011a);
  5609.                         mdio_write(tp, 0x19, 0x0000);
  5610.                         mdio_write(tp, 0x15, 0x0150);
  5611.                         mdio_write(tp, 0x19, 0x7c80);
  5612.                         mdio_write(tp, 0x15, 0x0151);
  5613.                         mdio_write(tp, 0x19, 0x6461);
  5614.                         mdio_write(tp, 0x15, 0x0152);
  5615.                         mdio_write(tp, 0x19, 0x4003);
  5616.                         mdio_write(tp, 0x15, 0x0153);
  5617.                         mdio_write(tp, 0x19, 0x4540);
  5618.                         mdio_write(tp, 0x15, 0x0154);
  5619.                         mdio_write(tp, 0x19, 0x9f00);
  5620.                         mdio_write(tp, 0x15, 0x0155);
  5621.                         mdio_write(tp, 0x19, 0x9d00);
  5622.                         mdio_write(tp, 0x15, 0x0156);
  5623.                         mdio_write(tp, 0x19, 0x7c40);
  5624.                         mdio_write(tp, 0x15, 0x0157);
  5625.                         mdio_write(tp, 0x19, 0x6421);
  5626.                         mdio_write(tp, 0x15, 0x0158);
  5627.                         mdio_write(tp, 0x19, 0x7c80);
  5628.                         mdio_write(tp, 0x15, 0x0159);
  5629.                         mdio_write(tp, 0x19, 0x64a1);
  5630.                         mdio_write(tp, 0x15, 0x015a);
  5631.                         mdio_write(tp, 0x19, 0x30fe);
  5632.                         mdio_write(tp, 0x15, 0x02e7);
  5633.                         mdio_write(tp, 0x19, 0x0000);
  5634.                         mdio_write(tp, 0x15, 0x0329);
  5635.                         mdio_write(tp, 0x19, 0x7c00);
  5636.                         mdio_write(tp, 0x15, 0x0382);
  5637.                         mdio_write(tp, 0x19, 0x7c40);
  5638.                         mdio_write(tp, 0x15, 0x03bd);
  5639.                         mdio_write(tp, 0x19, 0x405e);
  5640.                         mdio_write(tp, 0x15, 0x03c9);
  5641.                         mdio_write(tp, 0x19, 0x7c00);
  5642.                         mdio_write(tp, 0x15, 0x03e3);
  5643.                         mdio_write(tp, 0x19, 0x7c00);
  5644.                         mdio_write(tp, 0x16, 0x0306);
  5645.                         mdio_write(tp, 0x16, 0x0300);
  5646.                         mdio_write(tp, 0x1f, 0x0005);
  5647.                         mdio_write(tp, 0x05, 0xfff6);
  5648.                         mdio_write(tp, 0x06, 0x0080);
  5649.                         mdio_write(tp, 0x05, 0x8000);
  5650.                         mdio_write(tp, 0x06, 0x0280);
  5651.                         mdio_write(tp, 0x06, 0x48f7);
  5652.                         mdio_write(tp, 0x06, 0x00e0);
  5653.                         mdio_write(tp, 0x06, 0xfff7);
  5654.                         mdio_write(tp, 0x06, 0xa080);
  5655.                         mdio_write(tp, 0x06, 0x02ae);
  5656.                         mdio_write(tp, 0x06, 0xf602);
  5657.                         mdio_write(tp, 0x06, 0x0200);
  5658.                         mdio_write(tp, 0x06, 0x0280);
  5659.                         mdio_write(tp, 0x06, 0x8c02);
  5660.                         mdio_write(tp, 0x06, 0x0224);
  5661.                         mdio_write(tp, 0x06, 0x0202);
  5662.                         mdio_write(tp, 0x06, 0x3402);
  5663.                         mdio_write(tp, 0x06, 0x027f);
  5664.                         mdio_write(tp, 0x06, 0x0280);
  5665.                         mdio_write(tp, 0x06, 0xa202);
  5666.                         mdio_write(tp, 0x06, 0x80bb);
  5667.                         mdio_write(tp, 0x06, 0xe08b);
  5668.                         mdio_write(tp, 0x06, 0x88e1);
  5669.                         mdio_write(tp, 0x06, 0x8b89);
  5670.                         mdio_write(tp, 0x06, 0x1e01);
  5671.                         mdio_write(tp, 0x06, 0xe18b);
  5672.                         mdio_write(tp, 0x06, 0x8a1e);
  5673.                         mdio_write(tp, 0x06, 0x01e1);
  5674.                         mdio_write(tp, 0x06, 0x8b8b);
  5675.                         mdio_write(tp, 0x06, 0x1e01);
  5676.                         mdio_write(tp, 0x06, 0xe18b);
  5677.                         mdio_write(tp, 0x06, 0x8c1e);
  5678.                         mdio_write(tp, 0x06, 0x01e1);
  5679.                         mdio_write(tp, 0x06, 0x8b8d);
  5680.                         mdio_write(tp, 0x06, 0x1e01);
  5681.                         mdio_write(tp, 0x06, 0xe18b);
  5682.                         mdio_write(tp, 0x06, 0x8e1e);
  5683.                         mdio_write(tp, 0x06, 0x01a0);
  5684.                         mdio_write(tp, 0x06, 0x00c7);
  5685.                         mdio_write(tp, 0x06, 0xaebb);
  5686.                         mdio_write(tp, 0x06, 0xee8a);
  5687.                         mdio_write(tp, 0x06, 0xe600);
  5688.                         mdio_write(tp, 0x06, 0xee8a);
  5689.                         mdio_write(tp, 0x06, 0xee03);
  5690.                         mdio_write(tp, 0x06, 0xee8a);
  5691.                         mdio_write(tp, 0x06, 0xefb8);
  5692.                         mdio_write(tp, 0x06, 0xee8a);
  5693.                         mdio_write(tp, 0x06, 0xe902);
  5694.                         mdio_write(tp, 0x06, 0xee8b);
  5695.                         mdio_write(tp, 0x06, 0x8520);
  5696.                         mdio_write(tp, 0x06, 0xee8b);
  5697.                         mdio_write(tp, 0x06, 0x8701);
  5698.                         mdio_write(tp, 0x06, 0xd481);
  5699.                         mdio_write(tp, 0x06, 0x31e4);
  5700.                         mdio_write(tp, 0x06, 0x8b94);
  5701.                         mdio_write(tp, 0x06, 0xe58b);
  5702.                         mdio_write(tp, 0x06, 0x95bf);
  5703.                         mdio_write(tp, 0x06, 0x8b88);
  5704.                         mdio_write(tp, 0x06, 0xec00);
  5705.                         mdio_write(tp, 0x06, 0x19a9);
  5706.                         mdio_write(tp, 0x06, 0x8b90);
  5707.                         mdio_write(tp, 0x06, 0xf9ee);
  5708.                         mdio_write(tp, 0x06, 0xfff6);
  5709.                         mdio_write(tp, 0x06, 0x00ee);
  5710.                         mdio_write(tp, 0x06, 0xfff7);
  5711.                         mdio_write(tp, 0x06, 0xffe0);
  5712.                         mdio_write(tp, 0x06, 0xe140);
  5713.                         mdio_write(tp, 0x06, 0xe1e1);
  5714.                         mdio_write(tp, 0x06, 0x41f7);
  5715.                         mdio_write(tp, 0x06, 0x2ff6);
  5716.                         mdio_write(tp, 0x06, 0x28e4);
  5717.                         mdio_write(tp, 0x06, 0xe140);
  5718.                         mdio_write(tp, 0x06, 0xe5e1);
  5719.                         mdio_write(tp, 0x06, 0x4104);
  5720.                         mdio_write(tp, 0x06, 0xf8e0);
  5721.                         mdio_write(tp, 0x06, 0x8b89);
  5722.                         mdio_write(tp, 0x06, 0xad20);
  5723.                         mdio_write(tp, 0x06, 0x0dee);
  5724.                         mdio_write(tp, 0x06, 0x8b89);
  5725.                         mdio_write(tp, 0x06, 0x0002);
  5726.                         mdio_write(tp, 0x06, 0x82ed);
  5727.                         mdio_write(tp, 0x06, 0x021f);
  5728.                         mdio_write(tp, 0x06, 0x4102);
  5729.                         mdio_write(tp, 0x06, 0x2812);
  5730.                         mdio_write(tp, 0x06, 0xfc04);
  5731.                         mdio_write(tp, 0x06, 0xf8e0);
  5732.                         mdio_write(tp, 0x06, 0x8b8d);
  5733.                         mdio_write(tp, 0x06, 0xad20);
  5734.                         mdio_write(tp, 0x06, 0x10ee);
  5735.                         mdio_write(tp, 0x06, 0x8b8d);
  5736.                         mdio_write(tp, 0x06, 0x0002);
  5737.                         mdio_write(tp, 0x06, 0x139d);
  5738.                         mdio_write(tp, 0x06, 0x0281);
  5739.                         mdio_write(tp, 0x06, 0xcf02);
  5740.                         mdio_write(tp, 0x06, 0x1f99);
  5741.                         mdio_write(tp, 0x06, 0x0227);
  5742.                         mdio_write(tp, 0x06, 0xeafc);
  5743.                         mdio_write(tp, 0x06, 0x04f8);
  5744.                         mdio_write(tp, 0x06, 0xe08b);
  5745.                         mdio_write(tp, 0x06, 0x8ead);
  5746.                         mdio_write(tp, 0x06, 0x2014);
  5747.                         mdio_write(tp, 0x06, 0xf620);
  5748.                         mdio_write(tp, 0x06, 0xe48b);
  5749.                         mdio_write(tp, 0x06, 0x8e02);
  5750.                         mdio_write(tp, 0x06, 0x8100);
  5751.                         mdio_write(tp, 0x06, 0x021b);
  5752.                         mdio_write(tp, 0x06, 0xf402);
  5753.                         mdio_write(tp, 0x06, 0x2c9c);
  5754.                         mdio_write(tp, 0x06, 0x0281);
  5755.                         mdio_write(tp, 0x06, 0x7202);
  5756.                         mdio_write(tp, 0x06, 0x843c);
  5757.                         mdio_write(tp, 0x06, 0xad22);
  5758.                         mdio_write(tp, 0x06, 0x11f6);
  5759.                         mdio_write(tp, 0x06, 0x22e4);
  5760.                         mdio_write(tp, 0x06, 0x8b8e);
  5761.                         mdio_write(tp, 0x06, 0x022c);
  5762.                         mdio_write(tp, 0x06, 0x4602);
  5763.                         mdio_write(tp, 0x06, 0x2ac5);
  5764.                         mdio_write(tp, 0x06, 0x0229);
  5765.                         mdio_write(tp, 0x06, 0x2002);
  5766.                         mdio_write(tp, 0x06, 0x2b91);
  5767.                         mdio_write(tp, 0x06, 0xad25);
  5768.                         mdio_write(tp, 0x06, 0x11f6);
  5769.                         mdio_write(tp, 0x06, 0x25e4);
  5770.                         mdio_write(tp, 0x06, 0x8b8e);
  5771.                         mdio_write(tp, 0x06, 0x0203);
  5772.                         mdio_write(tp, 0x06, 0x5a02);
  5773.                         mdio_write(tp, 0x06, 0x043a);
  5774.                         mdio_write(tp, 0x06, 0x021a);
  5775.                         mdio_write(tp, 0x06, 0x5902);
  5776.                         mdio_write(tp, 0x06, 0x2bfc);
  5777.                         mdio_write(tp, 0x06, 0xfc04);
  5778.                         mdio_write(tp, 0x06, 0xf8fa);
  5779.                         mdio_write(tp, 0x06, 0xef69);
  5780.                         mdio_write(tp, 0x06, 0xe0e0);
  5781.                         mdio_write(tp, 0x06, 0x00e1);
  5782.                         mdio_write(tp, 0x06, 0xe001);
  5783.                         mdio_write(tp, 0x06, 0xad27);
  5784.                         mdio_write(tp, 0x06, 0x1fd1);
  5785.                         mdio_write(tp, 0x06, 0x01bf);
  5786.                         mdio_write(tp, 0x06, 0x84eb);
  5787.                         mdio_write(tp, 0x06, 0x022f);
  5788.                         mdio_write(tp, 0x06, 0x50e0);
  5789.                         mdio_write(tp, 0x06, 0xe020);
  5790.                         mdio_write(tp, 0x06, 0xe1e0);
  5791.                         mdio_write(tp, 0x06, 0x21ad);
  5792.                         mdio_write(tp, 0x06, 0x200e);
  5793.                         mdio_write(tp, 0x06, 0xd100);
  5794.                         mdio_write(tp, 0x06, 0xbf84);
  5795.                         mdio_write(tp, 0x06, 0xeb02);
  5796.                         mdio_write(tp, 0x06, 0x2f50);
  5797.                         mdio_write(tp, 0x06, 0xbf3d);
  5798.                         mdio_write(tp, 0x06, 0x3902);
  5799.                         mdio_write(tp, 0x06, 0x2eb0);
  5800.                         mdio_write(tp, 0x06, 0xef96);
  5801.                         mdio_write(tp, 0x06, 0xfefc);
  5802.                         mdio_write(tp, 0x06, 0x0402);
  5803.                         mdio_write(tp, 0x06, 0x8135);
  5804.                         mdio_write(tp, 0x06, 0x05f8);
  5805.                         mdio_write(tp, 0x06, 0xfaef);
  5806.                         mdio_write(tp, 0x06, 0x69e0);
  5807.                         mdio_write(tp, 0x06, 0xe2fe);
  5808.                         mdio_write(tp, 0x06, 0xe1e2);
  5809.                         mdio_write(tp, 0x06, 0xffad);
  5810.                         mdio_write(tp, 0x06, 0x2d1a);
  5811.                         mdio_write(tp, 0x06, 0xe0e1);
  5812.                         mdio_write(tp, 0x06, 0x4ee1);
  5813.                         mdio_write(tp, 0x06, 0xe14f);
  5814.                         mdio_write(tp, 0x06, 0xac2d);
  5815.                         mdio_write(tp, 0x06, 0x22f6);
  5816.                         mdio_write(tp, 0x06, 0x0302);
  5817.                         mdio_write(tp, 0x06, 0x0336);
  5818.                         mdio_write(tp, 0x06, 0xf703);
  5819.                         mdio_write(tp, 0x06, 0xf706);
  5820.                         mdio_write(tp, 0x06, 0xbf84);
  5821.                         mdio_write(tp, 0x06, 0xd502);
  5822.                         mdio_write(tp, 0x06, 0x2eb0);
  5823.                         mdio_write(tp, 0x06, 0xae11);
  5824.                         mdio_write(tp, 0x06, 0xe0e1);
  5825.                         mdio_write(tp, 0x06, 0x4ee1);
  5826.                         mdio_write(tp, 0x06, 0xe14f);
  5827.                         mdio_write(tp, 0x06, 0xad2d);
  5828.                         mdio_write(tp, 0x06, 0x08bf);
  5829.                         mdio_write(tp, 0x06, 0x84e0);
  5830.                         mdio_write(tp, 0x06, 0x022e);
  5831.                         mdio_write(tp, 0x06, 0xb0f6);
  5832.                         mdio_write(tp, 0x06, 0x06ef);
  5833.                         mdio_write(tp, 0x06, 0x96fe);
  5834.                         mdio_write(tp, 0x06, 0xfc04);
  5835.                         mdio_write(tp, 0x06, 0xf8f9);
  5836.                         mdio_write(tp, 0x06, 0xfaef);
  5837.                         mdio_write(tp, 0x06, 0x69e0);
  5838.                         mdio_write(tp, 0x06, 0x8b87);
  5839.                         mdio_write(tp, 0x06, 0xad20);
  5840.                         mdio_write(tp, 0x06, 0x4cd2);
  5841.                         mdio_write(tp, 0x06, 0x00e0);
  5842.                         mdio_write(tp, 0x06, 0xe200);
  5843.                         mdio_write(tp, 0x06, 0x5801);
  5844.                         mdio_write(tp, 0x06, 0x0c02);
  5845.                         mdio_write(tp, 0x06, 0x1e20);
  5846.                         mdio_write(tp, 0x06, 0xe0e0);
  5847.