Lines Matching refs:tp
76 #define TX_SLOTS_AVAIL(tp) \ argument
77 (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx)
80 #define TX_FRAGS_READY_FOR(tp,nr_frags) \ argument
81 (TX_SLOTS_AVAIL(tp) >= (nr_frags + 1))
810 void (*phy_reset_enable)(struct rtl8169_private *tp);
812 unsigned int (*phy_reset_pending)(struct rtl8169_private *tp);
814 int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd);
875 static void rtl_lock_work(struct rtl8169_private *tp) in rtl_lock_work() argument
877 mutex_lock(&tp->wk.mutex); in rtl_lock_work()
880 static void rtl_unlock_work(struct rtl8169_private *tp) in rtl_unlock_work() argument
882 mutex_unlock(&tp->wk.mutex); in rtl_unlock_work()
901 static bool rtl_loop_wait(struct rtl8169_private *tp, const struct rtl_cond *c, in rtl_loop_wait() argument
909 if (c->check(tp) == high) in rtl_loop_wait()
912 netif_err(tp, drv, tp->dev, "%s == %d (loop: %d, delay: %d).\n", in rtl_loop_wait()
917 static bool rtl_udelay_loop_wait_high(struct rtl8169_private *tp, in rtl_udelay_loop_wait_high() argument
921 return rtl_loop_wait(tp, c, rtl_udelay, d, n, true); in rtl_udelay_loop_wait_high()
924 static bool rtl_udelay_loop_wait_low(struct rtl8169_private *tp, in rtl_udelay_loop_wait_low() argument
928 return rtl_loop_wait(tp, c, rtl_udelay, d, n, false); in rtl_udelay_loop_wait_low()
931 static bool rtl_msleep_loop_wait_high(struct rtl8169_private *tp, in rtl_msleep_loop_wait_high() argument
935 return rtl_loop_wait(tp, c, msleep, d, n, true); in rtl_msleep_loop_wait_high()
938 static bool rtl_msleep_loop_wait_low(struct rtl8169_private *tp, in rtl_msleep_loop_wait_low() argument
942 return rtl_loop_wait(tp, c, msleep, d, n, false); in rtl_msleep_loop_wait_low()
953 static bool name ## _check(struct rtl8169_private *tp)
955 static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg) in rtl_ocp_reg_failure() argument
958 netif_err(tp, drv, tp->dev, "Invalid ocp reg %x!\n", reg); in rtl_ocp_reg_failure()
966 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
971 static void r8168_phy_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data) in r8168_phy_ocp_write() argument
973 void __iomem *ioaddr = tp->mmio_addr; in r8168_phy_ocp_write()
975 if (rtl_ocp_reg_failure(tp, reg)) in r8168_phy_ocp_write()
980 rtl_udelay_loop_wait_low(tp, &rtl_ocp_gphy_cond, 25, 10); in r8168_phy_ocp_write()
983 static u16 r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg) in r8168_phy_ocp_read() argument
985 void __iomem *ioaddr = tp->mmio_addr; in r8168_phy_ocp_read()
987 if (rtl_ocp_reg_failure(tp, reg)) in r8168_phy_ocp_read()
992 return rtl_udelay_loop_wait_high(tp, &rtl_ocp_gphy_cond, 25, 10) ? in r8168_phy_ocp_read()
996 static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data) in r8168_mac_ocp_write() argument
998 void __iomem *ioaddr = tp->mmio_addr; in r8168_mac_ocp_write()
1000 if (rtl_ocp_reg_failure(tp, reg)) in r8168_mac_ocp_write()
1006 static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg) in r8168_mac_ocp_read() argument
1008 void __iomem *ioaddr = tp->mmio_addr; in r8168_mac_ocp_read()
1010 if (rtl_ocp_reg_failure(tp, reg)) in r8168_mac_ocp_read()
1020 static void r8168g_mdio_write(struct rtl8169_private *tp, int reg, int value) in r8168g_mdio_write() argument
1023 tp->ocp_base = value ? value << 4 : OCP_STD_PHY_BASE; in r8168g_mdio_write()
1027 if (tp->ocp_base != OCP_STD_PHY_BASE) in r8168g_mdio_write()
1030 r8168_phy_ocp_write(tp, tp->ocp_base + reg * 2, value); in r8168g_mdio_write()
1033 static int r8168g_mdio_read(struct rtl8169_private *tp, int reg) in r8168g_mdio_read() argument
1035 if (tp->ocp_base != OCP_STD_PHY_BASE) in r8168g_mdio_read()
1038 return r8168_phy_ocp_read(tp, tp->ocp_base + reg * 2); in r8168g_mdio_read()
1041 static void mac_mcu_write(struct rtl8169_private *tp, int reg, int value) in mac_mcu_write() argument
1044 tp->ocp_base = value << 4; in mac_mcu_write()
1048 r8168_mac_ocp_write(tp, tp->ocp_base + reg, value); in mac_mcu_write()
1051 static int mac_mcu_read(struct rtl8169_private *tp, int reg) in mac_mcu_read() argument
1053 return r8168_mac_ocp_read(tp, tp->ocp_base + reg); in mac_mcu_read()
1058 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
1063 static void r8169_mdio_write(struct rtl8169_private *tp, int reg, int value) in r8169_mdio_write() argument
1065 void __iomem *ioaddr = tp->mmio_addr; in r8169_mdio_write()
1069 rtl_udelay_loop_wait_low(tp, &rtl_phyar_cond, 25, 20); in r8169_mdio_write()
1077 static int r8169_mdio_read(struct rtl8169_private *tp, int reg) in r8169_mdio_read() argument
1079 void __iomem *ioaddr = tp->mmio_addr; in r8169_mdio_read()
1084 value = rtl_udelay_loop_wait_high(tp, &rtl_phyar_cond, 25, 20) ? in r8169_mdio_read()
1098 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
1103 static void r8168dp_1_mdio_access(struct rtl8169_private *tp, int reg, u32 data) in r8168dp_1_mdio_access() argument
1105 void __iomem *ioaddr = tp->mmio_addr; in r8168dp_1_mdio_access()
1111 rtl_udelay_loop_wait_low(tp, &rtl_ocpar_cond, 1000, 100); in r8168dp_1_mdio_access()
1114 static void r8168dp_1_mdio_write(struct rtl8169_private *tp, int reg, int value) in r8168dp_1_mdio_write() argument
1116 r8168dp_1_mdio_access(tp, reg, in r8168dp_1_mdio_write()
1120 static int r8168dp_1_mdio_read(struct rtl8169_private *tp, int reg) in r8168dp_1_mdio_read() argument
1122 void __iomem *ioaddr = tp->mmio_addr; in r8168dp_1_mdio_read()
1124 r8168dp_1_mdio_access(tp, reg, OCPDR_READ_CMD); in r8168dp_1_mdio_read()
1130 return rtl_udelay_loop_wait_high(tp, &rtl_ocpar_cond, 1000, 100) ? in r8168dp_1_mdio_read()
1146 static void r8168dp_2_mdio_write(struct rtl8169_private *tp, int reg, int value) in r8168dp_2_mdio_write() argument
1148 void __iomem *ioaddr = tp->mmio_addr; in r8168dp_2_mdio_write()
1152 r8169_mdio_write(tp, reg, value); in r8168dp_2_mdio_write()
1157 static int r8168dp_2_mdio_read(struct rtl8169_private *tp, int reg) in r8168dp_2_mdio_read() argument
1159 void __iomem *ioaddr = tp->mmio_addr; in r8168dp_2_mdio_read()
1164 value = r8169_mdio_read(tp, reg); in r8168dp_2_mdio_read()
1171 static void rtl_writephy(struct rtl8169_private *tp, int location, u32 val) in rtl_writephy() argument
1173 tp->mdio_ops.write(tp, location, val); in rtl_writephy()
1176 static int rtl_readphy(struct rtl8169_private *tp, int location) in rtl_readphy() argument
1178 return tp->mdio_ops.read(tp, location); in rtl_readphy()
1181 static void rtl_patchphy(struct rtl8169_private *tp, int reg_addr, int value) in rtl_patchphy() argument
1183 rtl_writephy(tp, reg_addr, rtl_readphy(tp, reg_addr) | value); in rtl_patchphy()
1186 static void rtl_w0w1_phy(struct rtl8169_private *tp, int reg_addr, int p, int m) in rtl_w0w1_phy() argument
1190 val = rtl_readphy(tp, reg_addr); in rtl_w0w1_phy()
1191 rtl_writephy(tp, reg_addr, (val & ~m) | p); in rtl_w0w1_phy()
1197 struct rtl8169_private *tp = netdev_priv(dev); in rtl_mdio_write() local
1199 rtl_writephy(tp, location, val); in rtl_mdio_write()
1204 struct rtl8169_private *tp = netdev_priv(dev); in rtl_mdio_read() local
1206 return rtl_readphy(tp, location); in rtl_mdio_read()
1211 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
1216 static void rtl_ephy_write(struct rtl8169_private *tp, int reg_addr, int value) in rtl_ephy_write() argument
1218 void __iomem *ioaddr = tp->mmio_addr; in rtl_ephy_write()
1223 rtl_udelay_loop_wait_low(tp, &rtl_ephyar_cond, 10, 100); in rtl_ephy_write()
1228 static u16 rtl_ephy_read(struct rtl8169_private *tp, int reg_addr) in rtl_ephy_read() argument
1230 void __iomem *ioaddr = tp->mmio_addr; in rtl_ephy_read()
1234 return rtl_udelay_loop_wait_high(tp, &rtl_ephyar_cond, 10, 100) ? in rtl_ephy_read()
1240 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
1245 static void rtl_eri_write(struct rtl8169_private *tp, int addr, u32 mask, in rtl_eri_write() argument
1248 void __iomem *ioaddr = tp->mmio_addr; in rtl_eri_write()
1254 rtl_udelay_loop_wait_low(tp, &rtl_eriar_cond, 100, 100); in rtl_eri_write()
1257 static u32 rtl_eri_read(struct rtl8169_private *tp, int addr, int type) in rtl_eri_read() argument
1259 void __iomem *ioaddr = tp->mmio_addr; in rtl_eri_read()
1263 return rtl_udelay_loop_wait_high(tp, &rtl_eriar_cond, 100, 100) ? in rtl_eri_read()
1267 static void rtl_w0w1_eri(struct rtl8169_private *tp, int addr, u32 mask, u32 p, in rtl_w0w1_eri() argument
1272 val = rtl_eri_read(tp, addr, type); in rtl_w0w1_eri()
1273 rtl_eri_write(tp, addr, mask, (val & ~m) | p, type); in rtl_w0w1_eri()
1276 static u32 r8168dp_ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg) in r8168dp_ocp_read() argument
1278 void __iomem *ioaddr = tp->mmio_addr; in r8168dp_ocp_read()
1281 return rtl_udelay_loop_wait_high(tp, &rtl_ocpar_cond, 100, 20) ? in r8168dp_ocp_read()
1285 static u32 r8168ep_ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg) in r8168ep_ocp_read() argument
1287 return rtl_eri_read(tp, reg, ERIAR_OOB); in r8168ep_ocp_read()
1290 static u32 ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg) in ocp_read() argument
1292 switch (tp->mac_version) { in ocp_read()
1296 return r8168dp_ocp_read(tp, mask, reg); in ocp_read()
1300 return r8168ep_ocp_read(tp, mask, reg); in ocp_read()
1307 static void r8168dp_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, in r8168dp_ocp_write() argument
1310 void __iomem *ioaddr = tp->mmio_addr; in r8168dp_ocp_write()
1314 rtl_udelay_loop_wait_low(tp, &rtl_ocpar_cond, 100, 20); in r8168dp_ocp_write()
1317 static void r8168ep_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, in r8168ep_ocp_write() argument
1320 rtl_eri_write(tp, reg, ((u32)mask & 0x0f) << ERIAR_MASK_SHIFT, in r8168ep_ocp_write()
1324 static void ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, u32 data) in ocp_write() argument
1326 switch (tp->mac_version) { in ocp_write()
1330 r8168dp_ocp_write(tp, mask, reg, data); in ocp_write()
1335 r8168ep_ocp_write(tp, mask, reg, data); in ocp_write()
1343 static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd) in rtl8168_oob_notify() argument
1345 rtl_eri_write(tp, 0xe8, ERIAR_MASK_0001, cmd, ERIAR_EXGMAC); in rtl8168_oob_notify()
1347 ocp_write(tp, 0x1, 0x30, 0x00000001); in rtl8168_oob_notify()
1354 static u16 rtl8168_get_ocp_reg(struct rtl8169_private *tp) in rtl8168_get_ocp_reg() argument
1356 return (tp->mac_version == RTL_GIGA_MAC_VER_31) ? 0xb8 : 0x10; in rtl8168_get_ocp_reg()
1363 reg = rtl8168_get_ocp_reg(tp); in DECLARE_RTL_COND()
1365 return ocp_read(tp, 0x0f, reg) & 0x00000800; in DECLARE_RTL_COND()
1370 return ocp_read(tp, 0x0f, 0x124) & 0x00000001; in DECLARE_RTL_COND()
1375 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
1380 static void rtl8168ep_stop_cmac(struct rtl8169_private *tp) in rtl8168ep_stop_cmac() argument
1382 void __iomem *ioaddr = tp->mmio_addr; in rtl8168ep_stop_cmac()
1385 rtl_msleep_loop_wait_low(tp, &rtl_ocp_tx_cond, 50, 2000); in rtl8168ep_stop_cmac()
1390 static void rtl8168dp_driver_start(struct rtl8169_private *tp) in rtl8168dp_driver_start() argument
1392 rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START); in rtl8168dp_driver_start()
1393 rtl_msleep_loop_wait_high(tp, &rtl_ocp_read_cond, 10, 10); in rtl8168dp_driver_start()
1396 static void rtl8168ep_driver_start(struct rtl8169_private *tp) in rtl8168ep_driver_start() argument
1398 ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_START); in rtl8168ep_driver_start()
1399 ocp_write(tp, 0x01, 0x30, ocp_read(tp, 0x01, 0x30) | 0x01); in rtl8168ep_driver_start()
1400 rtl_msleep_loop_wait_high(tp, &rtl_ep_ocp_read_cond, 10, 10); in rtl8168ep_driver_start()
1403 static void rtl8168_driver_start(struct rtl8169_private *tp) in rtl8168_driver_start() argument
1405 switch (tp->mac_version) { in rtl8168_driver_start()
1409 rtl8168dp_driver_start(tp); in rtl8168_driver_start()
1414 rtl8168ep_driver_start(tp); in rtl8168_driver_start()
1422 static void rtl8168dp_driver_stop(struct rtl8169_private *tp) in rtl8168dp_driver_stop() argument
1424 rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP); in rtl8168dp_driver_stop()
1425 rtl_msleep_loop_wait_low(tp, &rtl_ocp_read_cond, 10, 10); in rtl8168dp_driver_stop()
1428 static void rtl8168ep_driver_stop(struct rtl8169_private *tp) in rtl8168ep_driver_stop() argument
1430 rtl8168ep_stop_cmac(tp); in rtl8168ep_driver_stop()
1431 ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_STOP); in rtl8168ep_driver_stop()
1432 ocp_write(tp, 0x01, 0x30, ocp_read(tp, 0x01, 0x30) | 0x01); in rtl8168ep_driver_stop()
1433 rtl_msleep_loop_wait_low(tp, &rtl_ep_ocp_read_cond, 10, 10); in rtl8168ep_driver_stop()
1436 static void rtl8168_driver_stop(struct rtl8169_private *tp) in rtl8168_driver_stop() argument
1438 switch (tp->mac_version) { in rtl8168_driver_stop()
1442 rtl8168dp_driver_stop(tp); in rtl8168_driver_stop()
1447 rtl8168ep_driver_stop(tp); in rtl8168_driver_stop()
1455 static int r8168dp_check_dash(struct rtl8169_private *tp) in r8168dp_check_dash() argument
1457 u16 reg = rtl8168_get_ocp_reg(tp); in r8168dp_check_dash()
1459 return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0; in r8168dp_check_dash()
1462 static int r8168ep_check_dash(struct rtl8169_private *tp) in r8168ep_check_dash() argument
1464 return (ocp_read(tp, 0x0f, 0x128) & 0x00000001) ? 1 : 0; in r8168ep_check_dash()
1467 static int r8168_check_dash(struct rtl8169_private *tp) in r8168_check_dash() argument
1469 switch (tp->mac_version) { in r8168_check_dash()
1473 return r8168dp_check_dash(tp); in r8168_check_dash()
1477 return r8168ep_check_dash(tp); in r8168_check_dash()
1489 static void rtl_write_exgmac_batch(struct rtl8169_private *tp, in rtl_write_exgmac_batch() argument
1493 rtl_eri_write(tp, r->addr, r->mask, r->val, ERIAR_EXGMAC); in rtl_write_exgmac_batch()
1500 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
1505 static u8 rtl8168d_efuse_read(struct rtl8169_private *tp, int reg_addr) in rtl8168d_efuse_read() argument
1507 void __iomem *ioaddr = tp->mmio_addr; in rtl8168d_efuse_read()
1511 return rtl_udelay_loop_wait_high(tp, &rtl_efusear_cond, 100, 300) ? in rtl8168d_efuse_read()
1515 static u16 rtl_get_events(struct rtl8169_private *tp) in rtl_get_events() argument
1517 void __iomem *ioaddr = tp->mmio_addr; in rtl_get_events()
1522 static void rtl_ack_events(struct rtl8169_private *tp, u16 bits) in rtl_ack_events() argument
1524 void __iomem *ioaddr = tp->mmio_addr; in rtl_ack_events()
1530 static void rtl_irq_disable(struct rtl8169_private *tp) in rtl_irq_disable() argument
1532 void __iomem *ioaddr = tp->mmio_addr; in rtl_irq_disable()
1538 static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits) in rtl_irq_enable() argument
1540 void __iomem *ioaddr = tp->mmio_addr; in rtl_irq_enable()
1549 static void rtl_irq_enable_all(struct rtl8169_private *tp) in rtl_irq_enable_all() argument
1551 rtl_irq_enable(tp, RTL_EVENT_NAPI | tp->event_slow); in rtl_irq_enable_all()
1554 static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp) in rtl8169_irq_mask_and_ack() argument
1556 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_irq_mask_and_ack()
1558 rtl_irq_disable(tp); in rtl8169_irq_mask_and_ack()
1559 rtl_ack_events(tp, RTL_EVENT_NAPI | tp->event_slow); in rtl8169_irq_mask_and_ack()
1563 static unsigned int rtl8169_tbi_reset_pending(struct rtl8169_private *tp) in rtl8169_tbi_reset_pending() argument
1565 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_tbi_reset_pending()
1570 static unsigned int rtl8169_xmii_reset_pending(struct rtl8169_private *tp) in rtl8169_xmii_reset_pending() argument
1572 return rtl_readphy(tp, MII_BMCR) & BMCR_RESET; in rtl8169_xmii_reset_pending()
1585 static void rtl8169_tbi_reset_enable(struct rtl8169_private *tp) in rtl8169_tbi_reset_enable() argument
1587 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_tbi_reset_enable()
1592 static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp) in rtl8169_xmii_reset_enable() argument
1596 val = rtl_readphy(tp, MII_BMCR) | BMCR_RESET; in rtl8169_xmii_reset_enable()
1597 rtl_writephy(tp, MII_BMCR, val & 0xffff); in rtl8169_xmii_reset_enable()
1600 static void rtl_link_chg_patch(struct rtl8169_private *tp) in rtl_link_chg_patch() argument
1602 void __iomem *ioaddr = tp->mmio_addr; in rtl_link_chg_patch()
1603 struct net_device *dev = tp->dev; in rtl_link_chg_patch()
1608 if (tp->mac_version == RTL_GIGA_MAC_VER_34 || in rtl_link_chg_patch()
1609 tp->mac_version == RTL_GIGA_MAC_VER_38) { in rtl_link_chg_patch()
1611 rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011, in rtl_link_chg_patch()
1613 rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005, in rtl_link_chg_patch()
1616 rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x0000001f, in rtl_link_chg_patch()
1618 rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005, in rtl_link_chg_patch()
1621 rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x0000001f, in rtl_link_chg_patch()
1623 rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x0000003f, in rtl_link_chg_patch()
1627 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, in rtl_link_chg_patch()
1629 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, in rtl_link_chg_patch()
1631 } else if (tp->mac_version == RTL_GIGA_MAC_VER_35 || in rtl_link_chg_patch()
1632 tp->mac_version == RTL_GIGA_MAC_VER_36) { in rtl_link_chg_patch()
1634 rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011, in rtl_link_chg_patch()
1636 rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005, in rtl_link_chg_patch()
1639 rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x0000001f, in rtl_link_chg_patch()
1641 rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x0000003f, in rtl_link_chg_patch()
1644 } else if (tp->mac_version == RTL_GIGA_MAC_VER_37) { in rtl_link_chg_patch()
1646 rtl_eri_write(tp, 0x1d0, ERIAR_MASK_0011, 0x4d02, in rtl_link_chg_patch()
1648 rtl_eri_write(tp, 0x1dc, ERIAR_MASK_0011, 0x0060, in rtl_link_chg_patch()
1651 rtl_eri_write(tp, 0x1d0, ERIAR_MASK_0011, 0x0000, in rtl_link_chg_patch()
1658 struct rtl8169_private *tp, in __rtl8169_check_link_status() argument
1661 if (tp->link_ok(ioaddr)) { in __rtl8169_check_link_status()
1662 rtl_link_chg_patch(tp); in __rtl8169_check_link_status()
1665 pm_request_resume(&tp->pci_dev->dev); in __rtl8169_check_link_status()
1668 netif_info(tp, ifup, dev, "link up\n"); in __rtl8169_check_link_status()
1671 netif_info(tp, ifdown, dev, "link down\n"); in __rtl8169_check_link_status()
1673 pm_schedule_suspend(&tp->pci_dev->dev, 5000); in __rtl8169_check_link_status()
1678 struct rtl8169_private *tp, in rtl8169_check_link_status() argument
1681 __rtl8169_check_link_status(dev, tp, ioaddr, false); in rtl8169_check_link_status()
1686 static u32 __rtl8169_get_wol(struct rtl8169_private *tp) in __rtl8169_get_wol() argument
1688 void __iomem *ioaddr = tp->mmio_addr; in __rtl8169_get_wol()
1699 switch (tp->mac_version) { in __rtl8169_get_wol()
1717 if (rtl_eri_read(tp, 0xdc, ERIAR_EXGMAC) & MagicPacket_v2) in __rtl8169_get_wol()
1739 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_get_wol() local
1741 rtl_lock_work(tp); in rtl8169_get_wol()
1744 wol->wolopts = __rtl8169_get_wol(tp); in rtl8169_get_wol()
1746 rtl_unlock_work(tp); in rtl8169_get_wol()
1749 static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) in __rtl8169_set_wol() argument
1751 void __iomem *ioaddr = tp->mmio_addr; in __rtl8169_set_wol()
1769 switch (tp->mac_version) { in __rtl8169_set_wol()
1789 rtl_w0w1_eri(tp, in __rtl8169_set_wol()
1796 rtl_w0w1_eri(tp, in __rtl8169_set_wol()
1815 switch (tp->mac_version) { in __rtl8169_set_wol()
1835 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_set_wol() local
1837 rtl_lock_work(tp); in rtl8169_set_wol()
1840 tp->features |= RTL_FEATURE_WOL; in rtl8169_set_wol()
1842 tp->features &= ~RTL_FEATURE_WOL; in rtl8169_set_wol()
1843 __rtl8169_set_wol(tp, wol->wolopts); in rtl8169_set_wol()
1845 rtl_unlock_work(tp); in rtl8169_set_wol()
1847 device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts); in rtl8169_set_wol()
1852 static const char *rtl_lookup_firmware_name(struct rtl8169_private *tp) in rtl_lookup_firmware_name() argument
1854 return rtl_chip_infos[tp->mac_version].fw_name; in rtl_lookup_firmware_name()
1860 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_get_drvinfo() local
1861 struct rtl_fw *rtl_fw = tp->rtl_fw; in rtl8169_get_drvinfo()
1865 strlcpy(info->bus_info, pci_name(tp->pci_dev), sizeof(info->bus_info)); in rtl8169_get_drvinfo()
1880 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_set_speed_tbi() local
1881 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_set_speed_tbi()
1892 netif_warn(tp, link, dev, in rtl8169_set_speed_tbi()
1903 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_set_speed_xmii() local
1907 rtl_writephy(tp, 0x1f, 0x0000); in rtl8169_set_speed_xmii()
1912 auto_nego = rtl_readphy(tp, MII_ADVERTISE); in rtl8169_set_speed_xmii()
1927 giga_ctrl = rtl_readphy(tp, MII_CTRL1000); in rtl8169_set_speed_xmii()
1931 if (tp->mii.supports_gmii) { in rtl8169_set_speed_xmii()
1938 netif_info(tp, link, dev, in rtl8169_set_speed_xmii()
1945 rtl_writephy(tp, MII_ADVERTISE, auto_nego); in rtl8169_set_speed_xmii()
1946 rtl_writephy(tp, MII_CTRL1000, giga_ctrl); in rtl8169_set_speed_xmii()
1961 rtl_writephy(tp, MII_BMCR, bmcr); in rtl8169_set_speed_xmii()
1963 if (tp->mac_version == RTL_GIGA_MAC_VER_02 || in rtl8169_set_speed_xmii()
1964 tp->mac_version == RTL_GIGA_MAC_VER_03) { in rtl8169_set_speed_xmii()
1966 rtl_writephy(tp, 0x17, 0x2138); in rtl8169_set_speed_xmii()
1967 rtl_writephy(tp, 0x0e, 0x0260); in rtl8169_set_speed_xmii()
1969 rtl_writephy(tp, 0x17, 0x2108); in rtl8169_set_speed_xmii()
1970 rtl_writephy(tp, 0x0e, 0x0000); in rtl8169_set_speed_xmii()
1982 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_set_speed() local
1985 ret = tp->set_speed(dev, autoneg, speed, duplex, advertising); in rtl8169_set_speed()
1991 mod_timer(&tp->timer, jiffies + RTL8169_PHY_TIMEOUT); in rtl8169_set_speed()
1999 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_set_settings() local
2002 del_timer_sync(&tp->timer); in rtl8169_set_settings()
2004 rtl_lock_work(tp); in rtl8169_set_settings()
2007 rtl_unlock_work(tp); in rtl8169_set_settings()
2015 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_fix_features() local
2021 !rtl_chip_infos[tp->mac_version].jumbo_tx_csum) in rtl8169_fix_features()
2030 struct rtl8169_private *tp = netdev_priv(dev); in __rtl8169_set_features() local
2031 void __iomem *ioaddr = tp->mmio_addr; in __rtl8169_set_features()
2043 tp->cp_cmd |= RxChkSum; in __rtl8169_set_features()
2045 tp->cp_cmd &= ~RxChkSum; in __rtl8169_set_features()
2048 tp->cp_cmd |= RxVlan; in __rtl8169_set_features()
2050 tp->cp_cmd &= ~RxVlan; in __rtl8169_set_features()
2052 tp->cp_cmd |= RTL_R16(CPlusCmd) & ~(RxVlan | RxChkSum); in __rtl8169_set_features()
2054 RTL_W16(CPlusCmd, tp->cp_cmd); in __rtl8169_set_features()
2061 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_set_features() local
2065 rtl_lock_work(tp); in rtl8169_set_features()
2068 rtl_unlock_work(tp); in rtl8169_set_features()
2090 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_gset_tbi() local
2091 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_gset_tbi()
2111 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_gset_xmii() local
2113 return mii_ethtool_gset(&tp->mii, cmd); in rtl8169_gset_xmii()
2118 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_get_settings() local
2121 rtl_lock_work(tp); in rtl8169_get_settings()
2122 rc = tp->get_settings(dev, cmd); in rtl8169_get_settings()
2123 rtl_unlock_work(tp); in rtl8169_get_settings()
2131 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_get_regs() local
2132 u32 __iomem *data = tp->mmio_addr; in rtl8169_get_regs()
2136 rtl_lock_work(tp); in rtl8169_get_regs()
2139 rtl_unlock_work(tp); in rtl8169_get_regs()
2144 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_get_msglevel() local
2146 return tp->msg_enable; in rtl8169_get_msglevel()
2151 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_set_msglevel() local
2153 tp->msg_enable = value; in rtl8169_set_msglevel()
2184 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
2191 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_update_counters() local
2192 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_update_counters()
2193 struct device *d = &tp->pci_dev->dev; in rtl8169_update_counters()
2214 if (rtl_udelay_loop_wait_low(tp, &rtl_counters_cond, 10, 1000)) in rtl8169_update_counters()
2215 memcpy(&tp->counters, counters, sizeof(*counters)); in rtl8169_update_counters()
2226 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_get_ethtool_stats() local
2232 data[0] = le64_to_cpu(tp->counters.tx_packets); in rtl8169_get_ethtool_stats()
2233 data[1] = le64_to_cpu(tp->counters.rx_packets); in rtl8169_get_ethtool_stats()
2234 data[2] = le64_to_cpu(tp->counters.tx_errors); in rtl8169_get_ethtool_stats()
2235 data[3] = le32_to_cpu(tp->counters.rx_errors); in rtl8169_get_ethtool_stats()
2236 data[4] = le16_to_cpu(tp->counters.rx_missed); in rtl8169_get_ethtool_stats()
2237 data[5] = le16_to_cpu(tp->counters.align_errors); in rtl8169_get_ethtool_stats()
2238 data[6] = le32_to_cpu(tp->counters.tx_one_collision); in rtl8169_get_ethtool_stats()
2239 data[7] = le32_to_cpu(tp->counters.tx_multi_collision); in rtl8169_get_ethtool_stats()
2240 data[8] = le64_to_cpu(tp->counters.rx_unicast); in rtl8169_get_ethtool_stats()
2241 data[9] = le64_to_cpu(tp->counters.rx_broadcast); in rtl8169_get_ethtool_stats()
2242 data[10] = le32_to_cpu(tp->counters.rx_multicast); in rtl8169_get_ethtool_stats()
2243 data[11] = le16_to_cpu(tp->counters.tx_aborted); in rtl8169_get_ethtool_stats()
2244 data[12] = le16_to_cpu(tp->counters.tx_underun); in rtl8169_get_ethtool_stats()
2273 static void rtl8169_get_mac_version(struct rtl8169_private *tp, in rtl8169_get_mac_version() argument
2276 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_get_mac_version()
2387 tp->mac_version = p->mac_version; in rtl8169_get_mac_version()
2389 if (tp->mac_version == RTL_GIGA_MAC_NONE) { in rtl8169_get_mac_version()
2390 netif_notice(tp, probe, dev, in rtl8169_get_mac_version()
2392 tp->mac_version = default_version; in rtl8169_get_mac_version()
2393 } else if (tp->mac_version == RTL_GIGA_MAC_VER_42) { in rtl8169_get_mac_version()
2394 tp->mac_version = tp->mii.supports_gmii ? in rtl8169_get_mac_version()
2397 } else if (tp->mac_version == RTL_GIGA_MAC_VER_45) { in rtl8169_get_mac_version()
2398 tp->mac_version = tp->mii.supports_gmii ? in rtl8169_get_mac_version()
2401 } else if (tp->mac_version == RTL_GIGA_MAC_VER_46) { in rtl8169_get_mac_version()
2402 tp->mac_version = tp->mii.supports_gmii ? in rtl8169_get_mac_version()
2408 static void rtl8169_print_mac_version(struct rtl8169_private *tp) in rtl8169_print_mac_version() argument
2410 dprintk("mac_version = 0x%02x\n", tp->mac_version); in rtl8169_print_mac_version()
2418 static void rtl_writephy_batch(struct rtl8169_private *tp, in rtl_writephy_batch() argument
2422 rtl_writephy(tp, regs->reg, regs->val); in rtl_writephy_batch()
2451 static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw) in rtl_fw_format_ok() argument
2490 strlcpy(version, rtl_lookup_firmware_name(tp), RTL_VER_SIZE); in rtl_fw_format_ok()
2502 static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev, in rtl_fw_data_ok() argument
2525 netif_err(tp, ifup, tp->dev, in rtl_fw_data_ok()
2532 netif_err(tp, ifup, tp->dev, in rtl_fw_data_ok()
2541 netif_err(tp, ifup, tp->dev, in rtl_fw_data_ok()
2548 netif_err(tp, ifup, tp->dev, in rtl_fw_data_ok()
2558 static int rtl_check_firmware(struct rtl8169_private *tp, struct rtl_fw *rtl_fw) in rtl_check_firmware() argument
2560 struct net_device *dev = tp->dev; in rtl_check_firmware()
2563 if (!rtl_fw_format_ok(tp, rtl_fw)) { in rtl_check_firmware()
2564 netif_err(tp, ifup, dev, "invalid firmware\n"); in rtl_check_firmware()
2568 if (rtl_fw_data_ok(tp, dev, &rtl_fw->phy_action)) in rtl_check_firmware()
2574 static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw) in rtl_phy_write_fw() argument
2577 struct mdio_ops org, *ops = &tp->mdio_ops; in rtl_phy_write_fw()
2595 predata = rtl_readphy(tp, regno); in rtl_phy_write_fw()
2626 rtl_writephy(tp, regno, data); in rtl_phy_write_fw()
2643 rtl_writephy(tp, regno, predata); in rtl_phy_write_fw()
2663 static void rtl_release_firmware(struct rtl8169_private *tp) in rtl_release_firmware() argument
2665 if (!IS_ERR_OR_NULL(tp->rtl_fw)) { in rtl_release_firmware()
2666 release_firmware(tp->rtl_fw->fw); in rtl_release_firmware()
2667 kfree(tp->rtl_fw); in rtl_release_firmware()
2669 tp->rtl_fw = RTL_FIRMWARE_UNKNOWN; in rtl_release_firmware()
2672 static void rtl_apply_firmware(struct rtl8169_private *tp) in rtl_apply_firmware() argument
2674 struct rtl_fw *rtl_fw = tp->rtl_fw; in rtl_apply_firmware()
2678 rtl_phy_write_fw(tp, rtl_fw); in rtl_apply_firmware()
2681 static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val) in rtl_apply_firmware_cond() argument
2683 if (rtl_readphy(tp, reg) != val) in rtl_apply_firmware_cond()
2684 netif_warn(tp, hw, tp->dev, "chipset not ready for firmware\n"); in rtl_apply_firmware_cond()
2686 rtl_apply_firmware(tp); in rtl_apply_firmware_cond()
2689 static void rtl8169s_hw_phy_config(struct rtl8169_private *tp) in rtl8169s_hw_phy_config() argument
2753 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8169s_hw_phy_config()
2756 static void rtl8169sb_hw_phy_config(struct rtl8169_private *tp) in rtl8169sb_hw_phy_config() argument
2764 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8169sb_hw_phy_config()
2767 static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp) in rtl8169scd_hw_phy_config_quirk() argument
2769 struct pci_dev *pdev = tp->pci_dev; in rtl8169scd_hw_phy_config_quirk()
2775 rtl_writephy(tp, 0x1f, 0x0001); in rtl8169scd_hw_phy_config_quirk()
2776 rtl_writephy(tp, 0x10, 0xf01b); in rtl8169scd_hw_phy_config_quirk()
2777 rtl_writephy(tp, 0x1f, 0x0000); in rtl8169scd_hw_phy_config_quirk()
2780 static void rtl8169scd_hw_phy_config(struct rtl8169_private *tp) in rtl8169scd_hw_phy_config() argument
2822 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8169scd_hw_phy_config()
2824 rtl8169scd_hw_phy_config_quirk(tp); in rtl8169scd_hw_phy_config()
2827 static void rtl8169sce_hw_phy_config(struct rtl8169_private *tp) in rtl8169sce_hw_phy_config() argument
2877 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8169sce_hw_phy_config()
2880 static void rtl8168bb_hw_phy_config(struct rtl8169_private *tp) in rtl8168bb_hw_phy_config() argument
2887 rtl_writephy(tp, 0x1f, 0x0001); in rtl8168bb_hw_phy_config()
2888 rtl_patchphy(tp, 0x16, 1 << 0); in rtl8168bb_hw_phy_config()
2890 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168bb_hw_phy_config()
2893 static void rtl8168bef_hw_phy_config(struct rtl8169_private *tp) in rtl8168bef_hw_phy_config() argument
2901 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168bef_hw_phy_config()
2904 static void rtl8168cp_1_hw_phy_config(struct rtl8169_private *tp) in rtl8168cp_1_hw_phy_config() argument
2914 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168cp_1_hw_phy_config()
2917 static void rtl8168cp_2_hw_phy_config(struct rtl8169_private *tp) in rtl8168cp_2_hw_phy_config() argument
2925 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168cp_2_hw_phy_config()
2926 rtl_patchphy(tp, 0x14, 1 << 5); in rtl8168cp_2_hw_phy_config()
2927 rtl_patchphy(tp, 0x0d, 1 << 5); in rtl8168cp_2_hw_phy_config()
2929 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168cp_2_hw_phy_config()
2932 static void rtl8168c_1_hw_phy_config(struct rtl8169_private *tp) in rtl8168c_1_hw_phy_config() argument
2954 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168c_1_hw_phy_config()
2956 rtl_patchphy(tp, 0x14, 1 << 5); in rtl8168c_1_hw_phy_config()
2957 rtl_patchphy(tp, 0x0d, 1 << 5); in rtl8168c_1_hw_phy_config()
2958 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168c_1_hw_phy_config()
2961 static void rtl8168c_2_hw_phy_config(struct rtl8169_private *tp) in rtl8168c_2_hw_phy_config() argument
2981 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168c_2_hw_phy_config()
2983 rtl_patchphy(tp, 0x16, 1 << 0); in rtl8168c_2_hw_phy_config()
2984 rtl_patchphy(tp, 0x14, 1 << 5); in rtl8168c_2_hw_phy_config()
2985 rtl_patchphy(tp, 0x0d, 1 << 5); in rtl8168c_2_hw_phy_config()
2986 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168c_2_hw_phy_config()
2989 static void rtl8168c_3_hw_phy_config(struct rtl8169_private *tp) in rtl8168c_3_hw_phy_config() argument
3003 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168c_3_hw_phy_config()
3005 rtl_patchphy(tp, 0x16, 1 << 0); in rtl8168c_3_hw_phy_config()
3006 rtl_patchphy(tp, 0x14, 1 << 5); in rtl8168c_3_hw_phy_config()
3007 rtl_patchphy(tp, 0x0d, 1 << 5); in rtl8168c_3_hw_phy_config()
3008 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168c_3_hw_phy_config()
3011 static void rtl8168c_4_hw_phy_config(struct rtl8169_private *tp) in rtl8168c_4_hw_phy_config() argument
3013 rtl8168c_3_hw_phy_config(tp); in rtl8168c_4_hw_phy_config()
3016 static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp) in rtl8168d_1_hw_phy_config() argument
3059 rtl_writephy_batch(tp, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); in rtl8168d_1_hw_phy_config()
3065 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168d_1_hw_phy_config()
3066 rtl_w0w1_phy(tp, 0x0b, 0x0010, 0x00ef); in rtl8168d_1_hw_phy_config()
3067 rtl_w0w1_phy(tp, 0x0c, 0xa200, 0x5d00); in rtl8168d_1_hw_phy_config()
3069 if (rtl8168d_efuse_read(tp, 0x01) == 0xb1) { in rtl8168d_1_hw_phy_config()
3080 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168d_1_hw_phy_config()
3082 val = rtl_readphy(tp, 0x0d); in rtl8168d_1_hw_phy_config()
3091 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168d_1_hw_phy_config()
3095 rtl_writephy(tp, 0x0d, val | set[i]); in rtl8168d_1_hw_phy_config()
3106 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168d_1_hw_phy_config()
3110 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168d_1_hw_phy_config()
3111 rtl_patchphy(tp, 0x0d, 0x0300); in rtl8168d_1_hw_phy_config()
3112 rtl_patchphy(tp, 0x0f, 0x0010); in rtl8168d_1_hw_phy_config()
3115 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168d_1_hw_phy_config()
3116 rtl_w0w1_phy(tp, 0x02, 0x0100, 0x0600); in rtl8168d_1_hw_phy_config()
3117 rtl_w0w1_phy(tp, 0x03, 0x0000, 0xe000); in rtl8168d_1_hw_phy_config()
3119 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168d_1_hw_phy_config()
3120 rtl_writephy(tp, 0x05, 0x001b); in rtl8168d_1_hw_phy_config()
3122 rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xbf00); in rtl8168d_1_hw_phy_config()
3124 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168d_1_hw_phy_config()
3127 static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp) in rtl8168d_2_hw_phy_config() argument
3170 rtl_writephy_batch(tp, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); in rtl8168d_2_hw_phy_config()
3172 if (rtl8168d_efuse_read(tp, 0x01) == 0xb1) { in rtl8168d_2_hw_phy_config()
3184 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168d_2_hw_phy_config()
3186 val = rtl_readphy(tp, 0x0d); in rtl8168d_2_hw_phy_config()
3194 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168d_2_hw_phy_config()
3198 rtl_writephy(tp, 0x0d, val | set[i]); in rtl8168d_2_hw_phy_config()
3209 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168d_2_hw_phy_config()
3213 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168d_2_hw_phy_config()
3214 rtl_w0w1_phy(tp, 0x02, 0x0100, 0x0600); in rtl8168d_2_hw_phy_config()
3215 rtl_w0w1_phy(tp, 0x03, 0x0000, 0xe000); in rtl8168d_2_hw_phy_config()
3218 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168d_2_hw_phy_config()
3219 rtl_patchphy(tp, 0x0f, 0x0017); in rtl8168d_2_hw_phy_config()
3221 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168d_2_hw_phy_config()
3222 rtl_writephy(tp, 0x05, 0x001b); in rtl8168d_2_hw_phy_config()
3224 rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xb300); in rtl8168d_2_hw_phy_config()
3226 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168d_2_hw_phy_config()
3229 static void rtl8168d_3_hw_phy_config(struct rtl8169_private *tp) in rtl8168d_3_hw_phy_config() argument
3287 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168d_3_hw_phy_config()
3290 static void rtl8168d_4_hw_phy_config(struct rtl8169_private *tp) in rtl8168d_4_hw_phy_config() argument
3302 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168d_4_hw_phy_config()
3303 rtl_patchphy(tp, 0x0d, 1 << 5); in rtl8168d_4_hw_phy_config()
3306 static void rtl8168e_1_hw_phy_config(struct rtl8169_private *tp) in rtl8168e_1_hw_phy_config() argument
3336 rtl_apply_firmware(tp); in rtl8168e_1_hw_phy_config()
3338 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168e_1_hw_phy_config()
3341 rtl_writephy(tp, 0x1f, 0x0007); in rtl8168e_1_hw_phy_config()
3342 rtl_writephy(tp, 0x1e, 0x0023); in rtl8168e_1_hw_phy_config()
3343 rtl_w0w1_phy(tp, 0x17, 0x0006, 0x0000); in rtl8168e_1_hw_phy_config()
3344 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_1_hw_phy_config()
3347 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168e_1_hw_phy_config()
3348 rtl_w0w1_phy(tp, 0x08, 0x8000, 0x7f00); in rtl8168e_1_hw_phy_config()
3349 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_1_hw_phy_config()
3352 rtl_writephy(tp, 0x1f, 0x0007); in rtl8168e_1_hw_phy_config()
3353 rtl_writephy(tp, 0x1e, 0x002d); in rtl8168e_1_hw_phy_config()
3354 rtl_w0w1_phy(tp, 0x18, 0x0050, 0x0000); in rtl8168e_1_hw_phy_config()
3355 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_1_hw_phy_config()
3356 rtl_w0w1_phy(tp, 0x14, 0x8000, 0x0000); in rtl8168e_1_hw_phy_config()
3358 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168e_1_hw_phy_config()
3359 rtl_writephy(tp, 0x05, 0x8b86); in rtl8168e_1_hw_phy_config()
3360 rtl_w0w1_phy(tp, 0x06, 0x0001, 0x0000); in rtl8168e_1_hw_phy_config()
3361 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_1_hw_phy_config()
3363 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168e_1_hw_phy_config()
3364 rtl_writephy(tp, 0x05, 0x8b85); in rtl8168e_1_hw_phy_config()
3365 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x2000); in rtl8168e_1_hw_phy_config()
3366 rtl_writephy(tp, 0x1f, 0x0007); in rtl8168e_1_hw_phy_config()
3367 rtl_writephy(tp, 0x1e, 0x0020); in rtl8168e_1_hw_phy_config()
3368 rtl_w0w1_phy(tp, 0x15, 0x0000, 0x1100); in rtl8168e_1_hw_phy_config()
3369 rtl_writephy(tp, 0x1f, 0x0006); in rtl8168e_1_hw_phy_config()
3370 rtl_writephy(tp, 0x00, 0x5a00); in rtl8168e_1_hw_phy_config()
3371 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_1_hw_phy_config()
3372 rtl_writephy(tp, 0x0d, 0x0007); in rtl8168e_1_hw_phy_config()
3373 rtl_writephy(tp, 0x0e, 0x003c); in rtl8168e_1_hw_phy_config()
3374 rtl_writephy(tp, 0x0d, 0x4007); in rtl8168e_1_hw_phy_config()
3375 rtl_writephy(tp, 0x0e, 0x0000); in rtl8168e_1_hw_phy_config()
3376 rtl_writephy(tp, 0x0d, 0x0000); in rtl8168e_1_hw_phy_config()
3379 static void rtl_rar_exgmac_set(struct rtl8169_private *tp, u8 *addr) in rtl_rar_exgmac_set() argument
3393 rtl_write_exgmac_batch(tp, e, ARRAY_SIZE(e)); in rtl_rar_exgmac_set()
3396 static void rtl8168e_2_hw_phy_config(struct rtl8169_private *tp) in rtl8168e_2_hw_phy_config() argument
3425 rtl_apply_firmware(tp); in rtl8168e_2_hw_phy_config()
3427 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168e_2_hw_phy_config()
3430 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168e_2_hw_phy_config()
3431 rtl_writephy(tp, 0x05, 0x8b80); in rtl8168e_2_hw_phy_config()
3432 rtl_w0w1_phy(tp, 0x17, 0x0006, 0x0000); in rtl8168e_2_hw_phy_config()
3433 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_2_hw_phy_config()
3436 rtl_writephy(tp, 0x1f, 0x0004); in rtl8168e_2_hw_phy_config()
3437 rtl_writephy(tp, 0x1f, 0x0007); in rtl8168e_2_hw_phy_config()
3438 rtl_writephy(tp, 0x1e, 0x002d); in rtl8168e_2_hw_phy_config()
3439 rtl_w0w1_phy(tp, 0x18, 0x0010, 0x0000); in rtl8168e_2_hw_phy_config()
3440 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168e_2_hw_phy_config()
3441 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_2_hw_phy_config()
3442 rtl_w0w1_phy(tp, 0x14, 0x8000, 0x0000); in rtl8168e_2_hw_phy_config()
3445 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168e_2_hw_phy_config()
3446 rtl_writephy(tp, 0x05, 0x8b86); in rtl8168e_2_hw_phy_config()
3447 rtl_w0w1_phy(tp, 0x06, 0x0001, 0x0000); in rtl8168e_2_hw_phy_config()
3448 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_2_hw_phy_config()
3451 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168e_2_hw_phy_config()
3452 rtl_writephy(tp, 0x05, 0x8b85); in rtl8168e_2_hw_phy_config()
3453 rtl_w0w1_phy(tp, 0x06, 0x4000, 0x0000); in rtl8168e_2_hw_phy_config()
3454 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_2_hw_phy_config()
3457 rtl_w0w1_eri(tp, 0x1b0, ERIAR_MASK_1111, 0x0000, 0x0003, ERIAR_EXGMAC); in rtl8168e_2_hw_phy_config()
3458 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168e_2_hw_phy_config()
3459 rtl_writephy(tp, 0x05, 0x8b85); in rtl8168e_2_hw_phy_config()
3460 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x2000); in rtl8168e_2_hw_phy_config()
3461 rtl_writephy(tp, 0x1f, 0x0004); in rtl8168e_2_hw_phy_config()
3462 rtl_writephy(tp, 0x1f, 0x0007); in rtl8168e_2_hw_phy_config()
3463 rtl_writephy(tp, 0x1e, 0x0020); in rtl8168e_2_hw_phy_config()
3464 rtl_w0w1_phy(tp, 0x15, 0x0000, 0x0100); in rtl8168e_2_hw_phy_config()
3465 rtl_writephy(tp, 0x1f, 0x0002); in rtl8168e_2_hw_phy_config()
3466 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_2_hw_phy_config()
3467 rtl_writephy(tp, 0x0d, 0x0007); in rtl8168e_2_hw_phy_config()
3468 rtl_writephy(tp, 0x0e, 0x003c); in rtl8168e_2_hw_phy_config()
3469 rtl_writephy(tp, 0x0d, 0x4007); in rtl8168e_2_hw_phy_config()
3470 rtl_writephy(tp, 0x0e, 0x0000); in rtl8168e_2_hw_phy_config()
3471 rtl_writephy(tp, 0x0d, 0x0000); in rtl8168e_2_hw_phy_config()
3474 rtl_writephy(tp, 0x1f, 0x0003); in rtl8168e_2_hw_phy_config()
3475 rtl_w0w1_phy(tp, 0x19, 0x0000, 0x0001); in rtl8168e_2_hw_phy_config()
3476 rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0400); in rtl8168e_2_hw_phy_config()
3477 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168e_2_hw_phy_config()
3480 rtl_rar_exgmac_set(tp, tp->dev->dev_addr); in rtl8168e_2_hw_phy_config()
3483 static void rtl8168f_hw_phy_config(struct rtl8169_private *tp) in rtl8168f_hw_phy_config() argument
3486 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168f_hw_phy_config()
3487 rtl_writephy(tp, 0x05, 0x8b80); in rtl8168f_hw_phy_config()
3488 rtl_w0w1_phy(tp, 0x06, 0x0006, 0x0000); in rtl8168f_hw_phy_config()
3489 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168f_hw_phy_config()
3492 rtl_writephy(tp, 0x1f, 0x0007); in rtl8168f_hw_phy_config()
3493 rtl_writephy(tp, 0x1e, 0x002d); in rtl8168f_hw_phy_config()
3494 rtl_w0w1_phy(tp, 0x18, 0x0010, 0x0000); in rtl8168f_hw_phy_config()
3495 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168f_hw_phy_config()
3496 rtl_w0w1_phy(tp, 0x14, 0x8000, 0x0000); in rtl8168f_hw_phy_config()
3499 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168f_hw_phy_config()
3500 rtl_writephy(tp, 0x05, 0x8b86); in rtl8168f_hw_phy_config()
3501 rtl_w0w1_phy(tp, 0x06, 0x0001, 0x0000); in rtl8168f_hw_phy_config()
3502 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168f_hw_phy_config()
3505 static void rtl8168f_1_hw_phy_config(struct rtl8169_private *tp) in rtl8168f_1_hw_phy_config() argument
3542 rtl_apply_firmware(tp); in rtl8168f_1_hw_phy_config()
3544 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8168f_1_hw_phy_config()
3546 rtl8168f_hw_phy_config(tp); in rtl8168f_1_hw_phy_config()
3549 rtl_writephy(tp, 0x1f, 0x0005); in rtl8168f_1_hw_phy_config()
3550 rtl_writephy(tp, 0x05, 0x8b85); in rtl8168f_1_hw_phy_config()
3551 rtl_w0w1_phy(tp, 0x06, 0x4000, 0x0000); in rtl8168f_1_hw_phy_config()
3552 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168f_1_hw_phy_config()
3555 static void rtl8168f_2_hw_phy_config(struct rtl8169_private *tp) in rtl8168f_2_hw_phy_config() argument
3557 rtl_apply_firmware(tp); in rtl8168f_2_hw_phy_config()
3559 rtl8168f_hw_phy_config(tp); in rtl8168f_2_hw_phy_config()
3562 static void rtl8411_hw_phy_config(struct rtl8169_private *tp) in rtl8411_hw_phy_config() argument
3600 rtl_apply_firmware(tp); in rtl8411_hw_phy_config()
3602 rtl8168f_hw_phy_config(tp); in rtl8411_hw_phy_config()
3605 rtl_writephy(tp, 0x1f, 0x0005); in rtl8411_hw_phy_config()
3606 rtl_writephy(tp, 0x05, 0x8b85); in rtl8411_hw_phy_config()
3607 rtl_w0w1_phy(tp, 0x06, 0x4000, 0x0000); in rtl8411_hw_phy_config()
3608 rtl_writephy(tp, 0x1f, 0x0000); in rtl8411_hw_phy_config()
3610 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8411_hw_phy_config()
3613 rtl_writephy(tp, 0x1f, 0x0005); in rtl8411_hw_phy_config()
3614 rtl_writephy(tp, 0x05, 0x8b54); in rtl8411_hw_phy_config()
3615 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x0800); in rtl8411_hw_phy_config()
3616 rtl_writephy(tp, 0x05, 0x8b5d); in rtl8411_hw_phy_config()
3617 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x0800); in rtl8411_hw_phy_config()
3618 rtl_writephy(tp, 0x05, 0x8a7c); in rtl8411_hw_phy_config()
3619 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x0100); in rtl8411_hw_phy_config()
3620 rtl_writephy(tp, 0x05, 0x8a7f); in rtl8411_hw_phy_config()
3621 rtl_w0w1_phy(tp, 0x06, 0x0100, 0x0000); in rtl8411_hw_phy_config()
3622 rtl_writephy(tp, 0x05, 0x8a82); in rtl8411_hw_phy_config()
3623 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x0100); in rtl8411_hw_phy_config()
3624 rtl_writephy(tp, 0x05, 0x8a85); in rtl8411_hw_phy_config()
3625 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x0100); in rtl8411_hw_phy_config()
3626 rtl_writephy(tp, 0x05, 0x8a88); in rtl8411_hw_phy_config()
3627 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x0100); in rtl8411_hw_phy_config()
3628 rtl_writephy(tp, 0x1f, 0x0000); in rtl8411_hw_phy_config()
3631 rtl_writephy(tp, 0x1f, 0x0005); in rtl8411_hw_phy_config()
3632 rtl_writephy(tp, 0x05, 0x8b85); in rtl8411_hw_phy_config()
3633 rtl_w0w1_phy(tp, 0x06, 0x8000, 0x0000); in rtl8411_hw_phy_config()
3634 rtl_writephy(tp, 0x1f, 0x0000); in rtl8411_hw_phy_config()
3637 rtl_w0w1_eri(tp, 0x1b0, ERIAR_MASK_0001, 0x00, 0x03, ERIAR_EXGMAC); in rtl8411_hw_phy_config()
3638 rtl_writephy(tp, 0x1f, 0x0005); in rtl8411_hw_phy_config()
3639 rtl_writephy(tp, 0x05, 0x8b85); in rtl8411_hw_phy_config()
3640 rtl_w0w1_phy(tp, 0x06, 0x0000, 0x2000); in rtl8411_hw_phy_config()
3641 rtl_writephy(tp, 0x1f, 0x0004); in rtl8411_hw_phy_config()
3642 rtl_writephy(tp, 0x1f, 0x0007); in rtl8411_hw_phy_config()
3643 rtl_writephy(tp, 0x1e, 0x0020); in rtl8411_hw_phy_config()
3644 rtl_w0w1_phy(tp, 0x15, 0x0000, 0x0100); in rtl8411_hw_phy_config()
3645 rtl_writephy(tp, 0x1f, 0x0000); in rtl8411_hw_phy_config()
3646 rtl_writephy(tp, 0x0d, 0x0007); in rtl8411_hw_phy_config()
3647 rtl_writephy(tp, 0x0e, 0x003c); in rtl8411_hw_phy_config()
3648 rtl_writephy(tp, 0x0d, 0x4007); in rtl8411_hw_phy_config()
3649 rtl_writephy(tp, 0x0e, 0x0000); in rtl8411_hw_phy_config()
3650 rtl_writephy(tp, 0x0d, 0x0000); in rtl8411_hw_phy_config()
3653 rtl_writephy(tp, 0x1f, 0x0003); in rtl8411_hw_phy_config()
3654 rtl_w0w1_phy(tp, 0x19, 0x0000, 0x0001); in rtl8411_hw_phy_config()
3655 rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0400); in rtl8411_hw_phy_config()
3656 rtl_writephy(tp, 0x1f, 0x0000); in rtl8411_hw_phy_config()
3659 static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp) in rtl8168g_1_hw_phy_config() argument
3661 rtl_apply_firmware(tp); in rtl8168g_1_hw_phy_config()
3663 rtl_writephy(tp, 0x1f, 0x0a46); in rtl8168g_1_hw_phy_config()
3664 if (rtl_readphy(tp, 0x10) & 0x0100) { in rtl8168g_1_hw_phy_config()
3665 rtl_writephy(tp, 0x1f, 0x0bcc); in rtl8168g_1_hw_phy_config()
3666 rtl_w0w1_phy(tp, 0x12, 0x0000, 0x8000); in rtl8168g_1_hw_phy_config()
3668 rtl_writephy(tp, 0x1f, 0x0bcc); in rtl8168g_1_hw_phy_config()
3669 rtl_w0w1_phy(tp, 0x12, 0x8000, 0x0000); in rtl8168g_1_hw_phy_config()
3672 rtl_writephy(tp, 0x1f, 0x0a46); in rtl8168g_1_hw_phy_config()
3673 if (rtl_readphy(tp, 0x13) & 0x0100) { in rtl8168g_1_hw_phy_config()
3674 rtl_writephy(tp, 0x1f, 0x0c41); in rtl8168g_1_hw_phy_config()
3675 rtl_w0w1_phy(tp, 0x15, 0x0002, 0x0000); in rtl8168g_1_hw_phy_config()
3677 rtl_writephy(tp, 0x1f, 0x0c41); in rtl8168g_1_hw_phy_config()
3678 rtl_w0w1_phy(tp, 0x15, 0x0000, 0x0002); in rtl8168g_1_hw_phy_config()
3682 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168g_1_hw_phy_config()
3683 rtl_w0w1_phy(tp, 0x11, 0x000c, 0x0000); in rtl8168g_1_hw_phy_config()
3685 rtl_writephy(tp, 0x1f, 0x0bcc); in rtl8168g_1_hw_phy_config()
3686 rtl_w0w1_phy(tp, 0x14, 0x0100, 0x0000); in rtl8168g_1_hw_phy_config()
3687 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168g_1_hw_phy_config()
3688 rtl_w0w1_phy(tp, 0x11, 0x00c0, 0x0000); in rtl8168g_1_hw_phy_config()
3689 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168g_1_hw_phy_config()
3690 rtl_writephy(tp, 0x13, 0x8084); in rtl8168g_1_hw_phy_config()
3691 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x6000); in rtl8168g_1_hw_phy_config()
3692 rtl_w0w1_phy(tp, 0x10, 0x1003, 0x0000); in rtl8168g_1_hw_phy_config()
3695 rtl_writephy(tp, 0x1f, 0x0a4b); in rtl8168g_1_hw_phy_config()
3696 rtl_w0w1_phy(tp, 0x11, 0x0004, 0x0000); in rtl8168g_1_hw_phy_config()
3699 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168g_1_hw_phy_config()
3700 rtl_writephy(tp, 0x13, 0x8012); in rtl8168g_1_hw_phy_config()
3701 rtl_w0w1_phy(tp, 0x14, 0x8000, 0x0000); in rtl8168g_1_hw_phy_config()
3703 rtl_writephy(tp, 0x1f, 0x0c42); in rtl8168g_1_hw_phy_config()
3704 rtl_w0w1_phy(tp, 0x11, 0x4000, 0x2000); in rtl8168g_1_hw_phy_config()
3707 rtl_writephy(tp, 0x1f, 0x0bcd); in rtl8168g_1_hw_phy_config()
3708 rtl_writephy(tp, 0x14, 0x5065); in rtl8168g_1_hw_phy_config()
3709 rtl_writephy(tp, 0x14, 0xd065); in rtl8168g_1_hw_phy_config()
3710 rtl_writephy(tp, 0x1f, 0x0bc8); in rtl8168g_1_hw_phy_config()
3711 rtl_writephy(tp, 0x11, 0x5655); in rtl8168g_1_hw_phy_config()
3712 rtl_writephy(tp, 0x1f, 0x0bcd); in rtl8168g_1_hw_phy_config()
3713 rtl_writephy(tp, 0x14, 0x1065); in rtl8168g_1_hw_phy_config()
3714 rtl_writephy(tp, 0x14, 0x9065); in rtl8168g_1_hw_phy_config()
3715 rtl_writephy(tp, 0x14, 0x1065); in rtl8168g_1_hw_phy_config()
3718 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168g_1_hw_phy_config()
3719 if (rtl_readphy(tp, 0x10) & 0x0004) in rtl8168g_1_hw_phy_config()
3720 rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); in rtl8168g_1_hw_phy_config()
3722 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168g_1_hw_phy_config()
3725 static void rtl8168g_2_hw_phy_config(struct rtl8169_private *tp) in rtl8168g_2_hw_phy_config() argument
3727 rtl_apply_firmware(tp); in rtl8168g_2_hw_phy_config()
3730 static void rtl8168h_1_hw_phy_config(struct rtl8169_private *tp) in rtl8168h_1_hw_phy_config() argument
3735 rtl_apply_firmware(tp); in rtl8168h_1_hw_phy_config()
3738 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_1_hw_phy_config()
3739 rtl_writephy(tp, 0x13, 0x809b); in rtl8168h_1_hw_phy_config()
3740 rtl_w0w1_phy(tp, 0x14, 0x8000, 0xf800); in rtl8168h_1_hw_phy_config()
3741 rtl_writephy(tp, 0x13, 0x80a2); in rtl8168h_1_hw_phy_config()
3742 rtl_w0w1_phy(tp, 0x14, 0x8000, 0xff00); in rtl8168h_1_hw_phy_config()
3743 rtl_writephy(tp, 0x13, 0x80a4); in rtl8168h_1_hw_phy_config()
3744 rtl_w0w1_phy(tp, 0x14, 0x8500, 0xff00); in rtl8168h_1_hw_phy_config()
3745 rtl_writephy(tp, 0x13, 0x809c); in rtl8168h_1_hw_phy_config()
3746 rtl_w0w1_phy(tp, 0x14, 0xbd00, 0xff00); in rtl8168h_1_hw_phy_config()
3747 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3750 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_1_hw_phy_config()
3751 rtl_writephy(tp, 0x13, 0x80ad); in rtl8168h_1_hw_phy_config()
3752 rtl_w0w1_phy(tp, 0x14, 0x7000, 0xf800); in rtl8168h_1_hw_phy_config()
3753 rtl_writephy(tp, 0x13, 0x80b4); in rtl8168h_1_hw_phy_config()
3754 rtl_w0w1_phy(tp, 0x14, 0x5000, 0xff00); in rtl8168h_1_hw_phy_config()
3755 rtl_writephy(tp, 0x13, 0x80ac); in rtl8168h_1_hw_phy_config()
3756 rtl_w0w1_phy(tp, 0x14, 0x4000, 0xff00); in rtl8168h_1_hw_phy_config()
3757 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3760 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_1_hw_phy_config()
3761 rtl_writephy(tp, 0x13, 0x808e); in rtl8168h_1_hw_phy_config()
3762 rtl_w0w1_phy(tp, 0x14, 0x1200, 0xff00); in rtl8168h_1_hw_phy_config()
3763 rtl_writephy(tp, 0x13, 0x8090); in rtl8168h_1_hw_phy_config()
3764 rtl_w0w1_phy(tp, 0x14, 0xe500, 0xff00); in rtl8168h_1_hw_phy_config()
3765 rtl_writephy(tp, 0x13, 0x8092); in rtl8168h_1_hw_phy_config()
3766 rtl_w0w1_phy(tp, 0x14, 0x9f00, 0xff00); in rtl8168h_1_hw_phy_config()
3767 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3771 rtl_writephy(tp, 0x1f, 0x0a46); in rtl8168h_1_hw_phy_config()
3772 data = rtl_readphy(tp, 0x13); in rtl8168h_1_hw_phy_config()
3776 data = rtl_readphy(tp, 0x12); in rtl8168h_1_hw_phy_config()
3783 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_1_hw_phy_config()
3784 rtl_writephy(tp, 0x13, 0x827a); in rtl8168h_1_hw_phy_config()
3785 rtl_w0w1_phy(tp, 0x14, dout_tapbin, 0xf000); in rtl8168h_1_hw_phy_config()
3786 rtl_writephy(tp, 0x13, 0x827b); in rtl8168h_1_hw_phy_config()
3787 rtl_w0w1_phy(tp, 0x14, dout_tapbin, 0xf000); in rtl8168h_1_hw_phy_config()
3788 rtl_writephy(tp, 0x13, 0x827c); in rtl8168h_1_hw_phy_config()
3789 rtl_w0w1_phy(tp, 0x14, dout_tapbin, 0xf000); in rtl8168h_1_hw_phy_config()
3790 rtl_writephy(tp, 0x13, 0x827d); in rtl8168h_1_hw_phy_config()
3791 rtl_w0w1_phy(tp, 0x14, dout_tapbin, 0xf000); in rtl8168h_1_hw_phy_config()
3793 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_1_hw_phy_config()
3794 rtl_writephy(tp, 0x13, 0x0811); in rtl8168h_1_hw_phy_config()
3795 rtl_w0w1_phy(tp, 0x14, 0x0800, 0x0000); in rtl8168h_1_hw_phy_config()
3796 rtl_writephy(tp, 0x1f, 0x0a42); in rtl8168h_1_hw_phy_config()
3797 rtl_w0w1_phy(tp, 0x16, 0x0002, 0x0000); in rtl8168h_1_hw_phy_config()
3798 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3801 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168h_1_hw_phy_config()
3802 rtl_w0w1_phy(tp, 0x11, 0x0800, 0x0000); in rtl8168h_1_hw_phy_config()
3803 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3806 rtl_writephy(tp, 0x1f, 0x0bca); in rtl8168h_1_hw_phy_config()
3807 rtl_w0w1_phy(tp, 0x17, 0x4000, 0x3000); in rtl8168h_1_hw_phy_config()
3808 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3810 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_1_hw_phy_config()
3811 rtl_writephy(tp, 0x13, 0x803f); in rtl8168h_1_hw_phy_config()
3812 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x3000); in rtl8168h_1_hw_phy_config()
3813 rtl_writephy(tp, 0x13, 0x8047); in rtl8168h_1_hw_phy_config()
3814 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x3000); in rtl8168h_1_hw_phy_config()
3815 rtl_writephy(tp, 0x13, 0x804f); in rtl8168h_1_hw_phy_config()
3816 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x3000); in rtl8168h_1_hw_phy_config()
3817 rtl_writephy(tp, 0x13, 0x8057); in rtl8168h_1_hw_phy_config()
3818 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x3000); in rtl8168h_1_hw_phy_config()
3819 rtl_writephy(tp, 0x13, 0x805f); in rtl8168h_1_hw_phy_config()
3820 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x3000); in rtl8168h_1_hw_phy_config()
3821 rtl_writephy(tp, 0x13, 0x8067); in rtl8168h_1_hw_phy_config()
3822 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x3000); in rtl8168h_1_hw_phy_config()
3823 rtl_writephy(tp, 0x13, 0x806f); in rtl8168h_1_hw_phy_config()
3824 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x3000); in rtl8168h_1_hw_phy_config()
3825 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3828 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168h_1_hw_phy_config()
3829 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x0080); in rtl8168h_1_hw_phy_config()
3830 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3833 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_1_hw_phy_config()
3834 if (rtl_readphy(tp, 0x10) & 0x0004) in rtl8168h_1_hw_phy_config()
3835 rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); in rtl8168h_1_hw_phy_config()
3837 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_1_hw_phy_config()
3840 static void rtl8168h_2_hw_phy_config(struct rtl8169_private *tp) in rtl8168h_2_hw_phy_config() argument
3846 rtl_apply_firmware(tp); in rtl8168h_2_hw_phy_config()
3849 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_2_hw_phy_config()
3850 rtl_writephy(tp, 0x13, 0x808a); in rtl8168h_2_hw_phy_config()
3851 rtl_w0w1_phy(tp, 0x14, 0x000a, 0x003f); in rtl8168h_2_hw_phy_config()
3852 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_2_hw_phy_config()
3855 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_2_hw_phy_config()
3856 rtl_writephy(tp, 0x13, 0x0811); in rtl8168h_2_hw_phy_config()
3857 rtl_w0w1_phy(tp, 0x14, 0x0800, 0x0000); in rtl8168h_2_hw_phy_config()
3858 rtl_writephy(tp, 0x1f, 0x0a42); in rtl8168h_2_hw_phy_config()
3859 rtl_w0w1_phy(tp, 0x16, 0x0002, 0x0000); in rtl8168h_2_hw_phy_config()
3860 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_2_hw_phy_config()
3863 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168h_2_hw_phy_config()
3864 rtl_w0w1_phy(tp, 0x11, 0x0800, 0x0000); in rtl8168h_2_hw_phy_config()
3865 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_2_hw_phy_config()
3867 r8168_mac_ocp_write(tp, 0xdd02, 0x807d); in rtl8168h_2_hw_phy_config()
3868 data = r8168_mac_ocp_read(tp, 0xdd02); in rtl8168h_2_hw_phy_config()
3872 data = r8168_mac_ocp_read(tp, 0xdd00); in rtl8168h_2_hw_phy_config()
3883 rtl_writephy(tp, 0x1f, 0x0bcf); in rtl8168h_2_hw_phy_config()
3884 rtl_writephy(tp, 0x16, data); in rtl8168h_2_hw_phy_config()
3885 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_2_hw_phy_config()
3889 rtl_writephy(tp, 0x1f, 0x0bcd); in rtl8168h_2_hw_phy_config()
3890 data = rtl_readphy(tp, 0x16); in rtl8168h_2_hw_phy_config()
3896 rtl_writephy(tp, 0x17, data); in rtl8168h_2_hw_phy_config()
3897 rtl_writephy(tp, 0x1f, 0x0bcd); in rtl8168h_2_hw_phy_config()
3898 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_2_hw_phy_config()
3901 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168h_2_hw_phy_config()
3902 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x0080); in rtl8168h_2_hw_phy_config()
3903 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_2_hw_phy_config()
3906 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168h_2_hw_phy_config()
3907 if (rtl_readphy(tp, 0x10) & 0x0004) in rtl8168h_2_hw_phy_config()
3908 rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); in rtl8168h_2_hw_phy_config()
3910 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168h_2_hw_phy_config()
3913 static void rtl8168ep_1_hw_phy_config(struct rtl8169_private *tp) in rtl8168ep_1_hw_phy_config() argument
3916 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168ep_1_hw_phy_config()
3917 rtl_w0w1_phy(tp, 0x11, 0x000c, 0x0000); in rtl8168ep_1_hw_phy_config()
3918 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_1_hw_phy_config()
3921 rtl_writephy(tp, 0x1f, 0x0bcc); in rtl8168ep_1_hw_phy_config()
3922 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x0100); in rtl8168ep_1_hw_phy_config()
3923 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168ep_1_hw_phy_config()
3924 rtl_w0w1_phy(tp, 0x11, 0x00c0, 0x0000); in rtl8168ep_1_hw_phy_config()
3925 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_1_hw_phy_config()
3926 rtl_writephy(tp, 0x13, 0x8084); in rtl8168ep_1_hw_phy_config()
3927 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x6000); in rtl8168ep_1_hw_phy_config()
3928 rtl_w0w1_phy(tp, 0x10, 0x1003, 0x0000); in rtl8168ep_1_hw_phy_config()
3929 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_1_hw_phy_config()
3932 rtl_writephy(tp, 0x1f, 0x0a4b); in rtl8168ep_1_hw_phy_config()
3933 rtl_w0w1_phy(tp, 0x11, 0x0004, 0x0000); in rtl8168ep_1_hw_phy_config()
3934 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_1_hw_phy_config()
3937 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_1_hw_phy_config()
3938 rtl_writephy(tp, 0x13, 0x8012); in rtl8168ep_1_hw_phy_config()
3939 rtl_w0w1_phy(tp, 0x14, 0x8000, 0x0000); in rtl8168ep_1_hw_phy_config()
3940 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_1_hw_phy_config()
3943 rtl_writephy(tp, 0x1f, 0x0c42); in rtl8168ep_1_hw_phy_config()
3944 rtl_w0w1_phy(tp, 0x11, 0x4000, 0x2000); in rtl8168ep_1_hw_phy_config()
3945 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_1_hw_phy_config()
3948 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_1_hw_phy_config()
3949 if (rtl_readphy(tp, 0x10) & 0x0004) in rtl8168ep_1_hw_phy_config()
3950 rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); in rtl8168ep_1_hw_phy_config()
3952 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_1_hw_phy_config()
3955 static void rtl8168ep_2_hw_phy_config(struct rtl8169_private *tp) in rtl8168ep_2_hw_phy_config() argument
3958 rtl_writephy(tp, 0x1f, 0x0bcc); in rtl8168ep_2_hw_phy_config()
3959 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x0100); in rtl8168ep_2_hw_phy_config()
3960 rtl_writephy(tp, 0x1f, 0x0a44); in rtl8168ep_2_hw_phy_config()
3961 rtl_w0w1_phy(tp, 0x11, 0x00c0, 0x0000); in rtl8168ep_2_hw_phy_config()
3962 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_2_hw_phy_config()
3963 rtl_writephy(tp, 0x13, 0x8084); in rtl8168ep_2_hw_phy_config()
3964 rtl_w0w1_phy(tp, 0x14, 0x0000, 0x6000); in rtl8168ep_2_hw_phy_config()
3965 rtl_w0w1_phy(tp, 0x10, 0x1003, 0x0000); in rtl8168ep_2_hw_phy_config()
3966 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_2_hw_phy_config()
3969 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_2_hw_phy_config()
3970 rtl_writephy(tp, 0x13, 0x8012); in rtl8168ep_2_hw_phy_config()
3971 rtl_w0w1_phy(tp, 0x14, 0x8000, 0x0000); in rtl8168ep_2_hw_phy_config()
3972 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_2_hw_phy_config()
3975 rtl_writephy(tp, 0x1f, 0x0c42); in rtl8168ep_2_hw_phy_config()
3976 rtl_w0w1_phy(tp, 0x11, 0x4000, 0x2000); in rtl8168ep_2_hw_phy_config()
3977 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_2_hw_phy_config()
3980 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_2_hw_phy_config()
3981 rtl_writephy(tp, 0x13, 0x80f3); in rtl8168ep_2_hw_phy_config()
3982 rtl_w0w1_phy(tp, 0x14, 0x8b00, ~0x8bff); in rtl8168ep_2_hw_phy_config()
3983 rtl_writephy(tp, 0x13, 0x80f0); in rtl8168ep_2_hw_phy_config()
3984 rtl_w0w1_phy(tp, 0x14, 0x3a00, ~0x3aff); in rtl8168ep_2_hw_phy_config()
3985 rtl_writephy(tp, 0x13, 0x80ef); in rtl8168ep_2_hw_phy_config()
3986 rtl_w0w1_phy(tp, 0x14, 0x0500, ~0x05ff); in rtl8168ep_2_hw_phy_config()
3987 rtl_writephy(tp, 0x13, 0x80f6); in rtl8168ep_2_hw_phy_config()
3988 rtl_w0w1_phy(tp, 0x14, 0x6e00, ~0x6eff); in rtl8168ep_2_hw_phy_config()
3989 rtl_writephy(tp, 0x13, 0x80ec); in rtl8168ep_2_hw_phy_config()
3990 rtl_w0w1_phy(tp, 0x14, 0x6800, ~0x68ff); in rtl8168ep_2_hw_phy_config()
3991 rtl_writephy(tp, 0x13, 0x80ed); in rtl8168ep_2_hw_phy_config()
3992 rtl_w0w1_phy(tp, 0x14, 0x7c00, ~0x7cff); in rtl8168ep_2_hw_phy_config()
3993 rtl_writephy(tp, 0x13, 0x80f2); in rtl8168ep_2_hw_phy_config()
3994 rtl_w0w1_phy(tp, 0x14, 0xf400, ~0xf4ff); in rtl8168ep_2_hw_phy_config()
3995 rtl_writephy(tp, 0x13, 0x80f4); in rtl8168ep_2_hw_phy_config()
3996 rtl_w0w1_phy(tp, 0x14, 0x8500, ~0x85ff); in rtl8168ep_2_hw_phy_config()
3997 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_2_hw_phy_config()
3998 rtl_writephy(tp, 0x13, 0x8110); in rtl8168ep_2_hw_phy_config()
3999 rtl_w0w1_phy(tp, 0x14, 0xa800, ~0xa8ff); in rtl8168ep_2_hw_phy_config()
4000 rtl_writephy(tp, 0x13, 0x810f); in rtl8168ep_2_hw_phy_config()
4001 rtl_w0w1_phy(tp, 0x14, 0x1d00, ~0x1dff); in rtl8168ep_2_hw_phy_config()
4002 rtl_writephy(tp, 0x13, 0x8111); in rtl8168ep_2_hw_phy_config()
4003 rtl_w0w1_phy(tp, 0x14, 0xf500, ~0xf5ff); in rtl8168ep_2_hw_phy_config()
4004 rtl_writephy(tp, 0x13, 0x8113); in rtl8168ep_2_hw_phy_config()
4005 rtl_w0w1_phy(tp, 0x14, 0x6100, ~0x61ff); in rtl8168ep_2_hw_phy_config()
4006 rtl_writephy(tp, 0x13, 0x8115); in rtl8168ep_2_hw_phy_config()
4007 rtl_w0w1_phy(tp, 0x14, 0x9200, ~0x92ff); in rtl8168ep_2_hw_phy_config()
4008 rtl_writephy(tp, 0x13, 0x810e); in rtl8168ep_2_hw_phy_config()
4009 rtl_w0w1_phy(tp, 0x14, 0x0400, ~0x04ff); in rtl8168ep_2_hw_phy_config()
4010 rtl_writephy(tp, 0x13, 0x810c); in rtl8168ep_2_hw_phy_config()
4011 rtl_w0w1_phy(tp, 0x14, 0x7c00, ~0x7cff); in rtl8168ep_2_hw_phy_config()
4012 rtl_writephy(tp, 0x13, 0x810b); in rtl8168ep_2_hw_phy_config()
4013 rtl_w0w1_phy(tp, 0x14, 0x5a00, ~0x5aff); in rtl8168ep_2_hw_phy_config()
4014 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_2_hw_phy_config()
4015 rtl_writephy(tp, 0x13, 0x80d1); in rtl8168ep_2_hw_phy_config()
4016 rtl_w0w1_phy(tp, 0x14, 0xff00, ~0xffff); in rtl8168ep_2_hw_phy_config()
4017 rtl_writephy(tp, 0x13, 0x80cd); in rtl8168ep_2_hw_phy_config()
4018 rtl_w0w1_phy(tp, 0x14, 0x9e00, ~0x9eff); in rtl8168ep_2_hw_phy_config()
4019 rtl_writephy(tp, 0x13, 0x80d3); in rtl8168ep_2_hw_phy_config()
4020 rtl_w0w1_phy(tp, 0x14, 0x0e00, ~0x0eff); in rtl8168ep_2_hw_phy_config()
4021 rtl_writephy(tp, 0x13, 0x80d5); in rtl8168ep_2_hw_phy_config()
4022 rtl_w0w1_phy(tp, 0x14, 0xca00, ~0xcaff); in rtl8168ep_2_hw_phy_config()
4023 rtl_writephy(tp, 0x13, 0x80d7); in rtl8168ep_2_hw_phy_config()
4024 rtl_w0w1_phy(tp, 0x14, 0x8400, ~0x84ff); in rtl8168ep_2_hw_phy_config()
4027 rtl_writephy(tp, 0x1f, 0x0bcd); in rtl8168ep_2_hw_phy_config()
4028 rtl_writephy(tp, 0x14, 0x5065); in rtl8168ep_2_hw_phy_config()
4029 rtl_writephy(tp, 0x14, 0xd065); in rtl8168ep_2_hw_phy_config()
4030 rtl_writephy(tp, 0x1f, 0x0bc8); in rtl8168ep_2_hw_phy_config()
4031 rtl_writephy(tp, 0x12, 0x00ed); in rtl8168ep_2_hw_phy_config()
4032 rtl_writephy(tp, 0x1f, 0x0bcd); in rtl8168ep_2_hw_phy_config()
4033 rtl_writephy(tp, 0x14, 0x1065); in rtl8168ep_2_hw_phy_config()
4034 rtl_writephy(tp, 0x14, 0x9065); in rtl8168ep_2_hw_phy_config()
4035 rtl_writephy(tp, 0x14, 0x1065); in rtl8168ep_2_hw_phy_config()
4036 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_2_hw_phy_config()
4039 rtl_writephy(tp, 0x1f, 0x0a43); in rtl8168ep_2_hw_phy_config()
4040 if (rtl_readphy(tp, 0x10) & 0x0004) in rtl8168ep_2_hw_phy_config()
4041 rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); in rtl8168ep_2_hw_phy_config()
4043 rtl_writephy(tp, 0x1f, 0x0000); in rtl8168ep_2_hw_phy_config()
4046 static void rtl8102e_hw_phy_config(struct rtl8169_private *tp) in rtl8102e_hw_phy_config() argument
4055 rtl_writephy(tp, 0x1f, 0x0000); in rtl8102e_hw_phy_config()
4056 rtl_patchphy(tp, 0x11, 1 << 12); in rtl8102e_hw_phy_config()
4057 rtl_patchphy(tp, 0x19, 1 << 13); in rtl8102e_hw_phy_config()
4058 rtl_patchphy(tp, 0x10, 1 << 15); in rtl8102e_hw_phy_config()
4060 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8102e_hw_phy_config()
4063 static void rtl8105e_hw_phy_config(struct rtl8169_private *tp) in rtl8105e_hw_phy_config() argument
4080 rtl_writephy(tp, 0x1f, 0x0000); in rtl8105e_hw_phy_config()
4081 rtl_writephy(tp, 0x18, 0x0310); in rtl8105e_hw_phy_config()
4084 rtl_apply_firmware(tp); in rtl8105e_hw_phy_config()
4086 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8105e_hw_phy_config()
4089 static void rtl8402_hw_phy_config(struct rtl8169_private *tp) in rtl8402_hw_phy_config() argument
4092 rtl_writephy(tp, 0x1f, 0x0000); in rtl8402_hw_phy_config()
4093 rtl_writephy(tp, 0x18, 0x0310); in rtl8402_hw_phy_config()
4096 rtl_apply_firmware(tp); in rtl8402_hw_phy_config()
4099 rtl_eri_write(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl8402_hw_phy_config()
4100 rtl_writephy(tp, 0x1f, 0x0004); in rtl8402_hw_phy_config()
4101 rtl_writephy(tp, 0x10, 0x401f); in rtl8402_hw_phy_config()
4102 rtl_writephy(tp, 0x19, 0x7030); in rtl8402_hw_phy_config()
4103 rtl_writephy(tp, 0x1f, 0x0000); in rtl8402_hw_phy_config()
4106 static void rtl8106e_hw_phy_config(struct rtl8169_private *tp) in rtl8106e_hw_phy_config() argument
4116 rtl_writephy(tp, 0x1f, 0x0000); in rtl8106e_hw_phy_config()
4117 rtl_writephy(tp, 0x18, 0x0310); in rtl8106e_hw_phy_config()
4120 rtl_apply_firmware(tp); in rtl8106e_hw_phy_config()
4122 rtl_eri_write(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl8106e_hw_phy_config()
4123 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); in rtl8106e_hw_phy_config()
4125 rtl_eri_write(tp, 0x1d0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl8106e_hw_phy_config()
4130 struct rtl8169_private *tp = netdev_priv(dev); in rtl_hw_phy_config() local
4132 rtl8169_print_mac_version(tp); in rtl_hw_phy_config()
4134 switch (tp->mac_version) { in rtl_hw_phy_config()
4139 rtl8169s_hw_phy_config(tp); in rtl_hw_phy_config()
4142 rtl8169sb_hw_phy_config(tp); in rtl_hw_phy_config()
4145 rtl8169scd_hw_phy_config(tp); in rtl_hw_phy_config()
4148 rtl8169sce_hw_phy_config(tp); in rtl_hw_phy_config()
4153 rtl8102e_hw_phy_config(tp); in rtl_hw_phy_config()
4156 rtl8168bb_hw_phy_config(tp); in rtl_hw_phy_config()
4159 rtl8168bef_hw_phy_config(tp); in rtl_hw_phy_config()
4162 rtl8168bef_hw_phy_config(tp); in rtl_hw_phy_config()
4165 rtl8168cp_1_hw_phy_config(tp); in rtl_hw_phy_config()
4168 rtl8168c_1_hw_phy_config(tp); in rtl_hw_phy_config()
4171 rtl8168c_2_hw_phy_config(tp); in rtl_hw_phy_config()
4174 rtl8168c_3_hw_phy_config(tp); in rtl_hw_phy_config()
4177 rtl8168c_4_hw_phy_config(tp); in rtl_hw_phy_config()
4181 rtl8168cp_2_hw_phy_config(tp); in rtl_hw_phy_config()
4184 rtl8168d_1_hw_phy_config(tp); in rtl_hw_phy_config()
4187 rtl8168d_2_hw_phy_config(tp); in rtl_hw_phy_config()
4190 rtl8168d_3_hw_phy_config(tp); in rtl_hw_phy_config()
4193 rtl8168d_4_hw_phy_config(tp); in rtl_hw_phy_config()
4197 rtl8105e_hw_phy_config(tp); in rtl_hw_phy_config()
4204 rtl8168e_1_hw_phy_config(tp); in rtl_hw_phy_config()
4207 rtl8168e_2_hw_phy_config(tp); in rtl_hw_phy_config()
4210 rtl8168f_1_hw_phy_config(tp); in rtl_hw_phy_config()
4213 rtl8168f_2_hw_phy_config(tp); in rtl_hw_phy_config()
4217 rtl8402_hw_phy_config(tp); in rtl_hw_phy_config()
4221 rtl8411_hw_phy_config(tp); in rtl_hw_phy_config()
4225 rtl8106e_hw_phy_config(tp); in rtl_hw_phy_config()
4229 rtl8168g_1_hw_phy_config(tp); in rtl_hw_phy_config()
4234 rtl8168g_2_hw_phy_config(tp); in rtl_hw_phy_config()
4238 rtl8168h_1_hw_phy_config(tp); in rtl_hw_phy_config()
4242 rtl8168h_2_hw_phy_config(tp); in rtl_hw_phy_config()
4246 rtl8168ep_1_hw_phy_config(tp); in rtl_hw_phy_config()
4250 rtl8168ep_2_hw_phy_config(tp); in rtl_hw_phy_config()
4259 static void rtl_phy_work(struct rtl8169_private *tp) in rtl_phy_work() argument
4261 struct timer_list *timer = &tp->timer; in rtl_phy_work()
4262 void __iomem *ioaddr = tp->mmio_addr; in rtl_phy_work()
4265 assert(tp->mac_version > RTL_GIGA_MAC_VER_01); in rtl_phy_work()
4267 if (tp->phy_reset_pending(tp)) { in rtl_phy_work()
4276 if (tp->link_ok(ioaddr)) in rtl_phy_work()
4279 netif_dbg(tp, link, tp->dev, "PHY reset until link up\n"); in rtl_phy_work()
4281 tp->phy_reset_enable(tp); in rtl_phy_work()
4287 static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag) in rtl_schedule_task() argument
4289 if (!test_and_set_bit(flag, tp->wk.flags)) in rtl_schedule_task()
4290 schedule_work(&tp->wk.work); in rtl_schedule_task()
4296 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_phy_timer() local
4298 rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING); in rtl8169_phy_timer()
4313 return tp->phy_reset_pending(tp); in DECLARE_RTL_COND()
4317 struct rtl8169_private *tp) in rtl8169_phy_reset() argument
4319 tp->phy_reset_enable(tp); in rtl8169_phy_reset()
4320 rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100); in rtl8169_phy_reset()
4323 static bool rtl_tbi_enabled(struct rtl8169_private *tp) in rtl_tbi_enabled() argument
4325 void __iomem *ioaddr = tp->mmio_addr; in rtl_tbi_enabled()
4327 return (tp->mac_version == RTL_GIGA_MAC_VER_01) && in rtl_tbi_enabled()
4331 static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) in rtl8169_init_phy() argument
4333 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_init_phy()
4337 if (tp->mac_version <= RTL_GIGA_MAC_VER_06) { in rtl8169_init_phy()
4342 pci_write_config_byte(tp->pci_dev, PCI_LATENCY_TIMER, 0x40); in rtl8169_init_phy()
4344 if (tp->mac_version <= RTL_GIGA_MAC_VER_06) in rtl8169_init_phy()
4345 pci_write_config_byte(tp->pci_dev, PCI_CACHE_LINE_SIZE, 0x08); in rtl8169_init_phy()
4347 if (tp->mac_version == RTL_GIGA_MAC_VER_02) { in rtl8169_init_phy()
4351 rtl_writephy(tp, 0x0b, 0x0000); //w 0x0b 15 0 0 in rtl8169_init_phy()
4354 rtl8169_phy_reset(dev, tp); in rtl8169_init_phy()
4359 (tp->mii.supports_gmii ? in rtl8169_init_phy()
4363 if (rtl_tbi_enabled(tp)) in rtl8169_init_phy()
4364 netif_info(tp, link, dev, "TBI auto-negotiating\n"); in rtl8169_init_phy()
4367 static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) in rtl_rar_set() argument
4369 void __iomem *ioaddr = tp->mmio_addr; in rtl_rar_set()
4371 rtl_lock_work(tp); in rtl_rar_set()
4381 if (tp->mac_version == RTL_GIGA_MAC_VER_34) in rtl_rar_set()
4382 rtl_rar_exgmac_set(tp, addr); in rtl_rar_set()
4386 rtl_unlock_work(tp); in rtl_rar_set()
4391 struct rtl8169_private *tp = netdev_priv(dev); in rtl_set_mac_address() local
4399 rtl_rar_set(tp, dev->dev_addr); in rtl_set_mac_address()
4406 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_ioctl() local
4409 return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV; in rtl8169_ioctl()
4412 static int rtl_xmii_ioctl(struct rtl8169_private *tp, in rtl_xmii_ioctl() argument
4421 data->val_out = rtl_readphy(tp, data->reg_num & 0x1f); in rtl_xmii_ioctl()
4425 rtl_writephy(tp, data->reg_num & 0x1f, data->val_in); in rtl_xmii_ioctl()
4431 static int rtl_tbi_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd) in rtl_tbi_ioctl() argument
4436 static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp) in rtl_disable_msi() argument
4438 if (tp->features & RTL_FEATURE_MSI) { in rtl_disable_msi()
4440 tp->features &= ~RTL_FEATURE_MSI; in rtl_disable_msi()
4444 static void rtl_init_mdio_ops(struct rtl8169_private *tp) in rtl_init_mdio_ops() argument
4446 struct mdio_ops *ops = &tp->mdio_ops; in rtl_init_mdio_ops()
4448 switch (tp->mac_version) { in rtl_init_mdio_ops()
4480 static void rtl_speed_down(struct rtl8169_private *tp) in rtl_speed_down() argument
4485 rtl_writephy(tp, 0x1f, 0x0000); in rtl_speed_down()
4486 lpa = rtl_readphy(tp, MII_LPA); in rtl_speed_down()
4496 (tp->mii.supports_gmii ? in rtl_speed_down()
4500 rtl8169_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL, in rtl_speed_down()
4504 static void rtl_wol_suspend_quirk(struct rtl8169_private *tp) in rtl_wol_suspend_quirk() argument
4506 void __iomem *ioaddr = tp->mmio_addr; in rtl_wol_suspend_quirk()
4508 switch (tp->mac_version) { in rtl_wol_suspend_quirk()
4539 static bool rtl_wol_pll_power_down(struct rtl8169_private *tp) in rtl_wol_pll_power_down() argument
4541 if (!(__rtl8169_get_wol(tp) & WAKE_ANY)) in rtl_wol_pll_power_down()
4544 rtl_speed_down(tp); in rtl_wol_pll_power_down()
4545 rtl_wol_suspend_quirk(tp); in rtl_wol_pll_power_down()
4550 static void r810x_phy_power_down(struct rtl8169_private *tp) in r810x_phy_power_down() argument
4552 rtl_writephy(tp, 0x1f, 0x0000); in r810x_phy_power_down()
4553 rtl_writephy(tp, MII_BMCR, BMCR_PDOWN); in r810x_phy_power_down()
4556 static void r810x_phy_power_up(struct rtl8169_private *tp) in r810x_phy_power_up() argument
4558 rtl_writephy(tp, 0x1f, 0x0000); in r810x_phy_power_up()
4559 rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE); in r810x_phy_power_up()
4562 static void r810x_pll_power_down(struct rtl8169_private *tp) in r810x_pll_power_down() argument
4564 void __iomem *ioaddr = tp->mmio_addr; in r810x_pll_power_down()
4566 if (rtl_wol_pll_power_down(tp)) in r810x_pll_power_down()
4569 r810x_phy_power_down(tp); in r810x_pll_power_down()
4571 switch (tp->mac_version) { in r810x_pll_power_down()
4585 static void r810x_pll_power_up(struct rtl8169_private *tp) in r810x_pll_power_up() argument
4587 void __iomem *ioaddr = tp->mmio_addr; in r810x_pll_power_up()
4589 r810x_phy_power_up(tp); in r810x_pll_power_up()
4591 switch (tp->mac_version) { in r810x_pll_power_up()
4609 static void r8168_phy_power_up(struct rtl8169_private *tp) in r8168_phy_power_up() argument
4611 rtl_writephy(tp, 0x1f, 0x0000); in r8168_phy_power_up()
4612 switch (tp->mac_version) { in r8168_phy_power_up()
4628 rtl_writephy(tp, 0x0e, 0x0000); in r8168_phy_power_up()
4633 rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE); in r8168_phy_power_up()
4636 static void r8168_phy_power_down(struct rtl8169_private *tp) in r8168_phy_power_down() argument
4638 rtl_writephy(tp, 0x1f, 0x0000); in r8168_phy_power_down()
4639 switch (tp->mac_version) { in r8168_phy_power_down()
4644 rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE | BMCR_PDOWN); in r8168_phy_power_down()
4662 rtl_writephy(tp, 0x0e, 0x0200); in r8168_phy_power_down()
4664 rtl_writephy(tp, MII_BMCR, BMCR_PDOWN); in r8168_phy_power_down()
4669 static void r8168_pll_power_down(struct rtl8169_private *tp) in r8168_pll_power_down() argument
4671 void __iomem *ioaddr = tp->mmio_addr; in r8168_pll_power_down()
4673 if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || in r8168_pll_power_down()
4674 tp->mac_version == RTL_GIGA_MAC_VER_28 || in r8168_pll_power_down()
4675 tp->mac_version == RTL_GIGA_MAC_VER_31 || in r8168_pll_power_down()
4676 tp->mac_version == RTL_GIGA_MAC_VER_49 || in r8168_pll_power_down()
4677 tp->mac_version == RTL_GIGA_MAC_VER_50 || in r8168_pll_power_down()
4678 tp->mac_version == RTL_GIGA_MAC_VER_51) && in r8168_pll_power_down()
4679 r8168_check_dash(tp)) { in r8168_pll_power_down()
4683 if ((tp->mac_version == RTL_GIGA_MAC_VER_23 || in r8168_pll_power_down()
4684 tp->mac_version == RTL_GIGA_MAC_VER_24) && in r8168_pll_power_down()
4689 if (tp->mac_version == RTL_GIGA_MAC_VER_32 || in r8168_pll_power_down()
4690 tp->mac_version == RTL_GIGA_MAC_VER_33) in r8168_pll_power_down()
4691 rtl_ephy_write(tp, 0x19, 0xff64); in r8168_pll_power_down()
4693 if (rtl_wol_pll_power_down(tp)) in r8168_pll_power_down()
4696 r8168_phy_power_down(tp); in r8168_pll_power_down()
4698 switch (tp->mac_version) { in r8168_pll_power_down()
4716 rtl_w0w1_eri(tp, 0x1a8, ERIAR_MASK_1111, 0x00000000, in r8168_pll_power_down()
4723 static void r8168_pll_power_up(struct rtl8169_private *tp) in r8168_pll_power_up() argument
4725 void __iomem *ioaddr = tp->mmio_addr; in r8168_pll_power_up()
4727 switch (tp->mac_version) { in r8168_pll_power_up()
4748 rtl_w0w1_eri(tp, 0x1a8, ERIAR_MASK_1111, 0xfc000000, in r8168_pll_power_up()
4753 r8168_phy_power_up(tp); in r8168_pll_power_up()
4756 static void rtl_generic_op(struct rtl8169_private *tp, in rtl_generic_op() argument
4760 op(tp); in rtl_generic_op()
4763 static void rtl_pll_power_down(struct rtl8169_private *tp) in rtl_pll_power_down() argument
4765 rtl_generic_op(tp, tp->pll_power_ops.down); in rtl_pll_power_down()
4768 static void rtl_pll_power_up(struct rtl8169_private *tp) in rtl_pll_power_up() argument
4770 rtl_generic_op(tp, tp->pll_power_ops.up); in rtl_pll_power_up()
4773 static void rtl_init_pll_power_ops(struct rtl8169_private *tp) in rtl_init_pll_power_ops() argument
4775 struct pll_power_ops *ops = &tp->pll_power_ops; in rtl_init_pll_power_ops()
4777 switch (tp->mac_version) { in rtl_init_pll_power_ops()
4835 static void rtl_init_rxcfg(struct rtl8169_private *tp) in rtl_init_rxcfg() argument
4837 void __iomem *ioaddr = tp->mmio_addr; in rtl_init_rxcfg()
4839 switch (tp->mac_version) { in rtl_init_rxcfg()
4889 static void rtl8169_init_ring_indexes(struct rtl8169_private *tp) in rtl8169_init_ring_indexes() argument
4891 tp->dirty_tx = tp->cur_tx = tp->cur_rx = 0; in rtl8169_init_ring_indexes()
4894 static void rtl_hw_jumbo_enable(struct rtl8169_private *tp) in rtl_hw_jumbo_enable() argument
4896 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_jumbo_enable()
4899 rtl_generic_op(tp, tp->jumbo_ops.enable); in rtl_hw_jumbo_enable()
4903 static void rtl_hw_jumbo_disable(struct rtl8169_private *tp) in rtl_hw_jumbo_disable() argument
4905 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_jumbo_disable()
4908 rtl_generic_op(tp, tp->jumbo_ops.disable); in rtl_hw_jumbo_disable()
4912 static void r8168c_hw_jumbo_enable(struct rtl8169_private *tp) in r8168c_hw_jumbo_enable() argument
4914 void __iomem *ioaddr = tp->mmio_addr; in r8168c_hw_jumbo_enable()
4918 rtl_tx_performance_tweak(tp->pci_dev, PCI_EXP_DEVCTL_READRQ_512B); in r8168c_hw_jumbo_enable()
4921 static void r8168c_hw_jumbo_disable(struct rtl8169_private *tp) in r8168c_hw_jumbo_disable() argument
4923 void __iomem *ioaddr = tp->mmio_addr; in r8168c_hw_jumbo_disable()
4927 rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT); in r8168c_hw_jumbo_disable()
4930 static void r8168dp_hw_jumbo_enable(struct rtl8169_private *tp) in r8168dp_hw_jumbo_enable() argument
4932 void __iomem *ioaddr = tp->mmio_addr; in r8168dp_hw_jumbo_enable()
4937 static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp) in r8168dp_hw_jumbo_disable() argument
4939 void __iomem *ioaddr = tp->mmio_addr; in r8168dp_hw_jumbo_disable()
4944 static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp) in r8168e_hw_jumbo_enable() argument
4946 void __iomem *ioaddr = tp->mmio_addr; in r8168e_hw_jumbo_enable()
4951 rtl_tx_performance_tweak(tp->pci_dev, PCI_EXP_DEVCTL_READRQ_512B); in r8168e_hw_jumbo_enable()
4954 static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp) in r8168e_hw_jumbo_disable() argument
4956 void __iomem *ioaddr = tp->mmio_addr; in r8168e_hw_jumbo_disable()
4961 rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT); in r8168e_hw_jumbo_disable()
4964 static void r8168b_0_hw_jumbo_enable(struct rtl8169_private *tp) in r8168b_0_hw_jumbo_enable() argument
4966 rtl_tx_performance_tweak(tp->pci_dev, in r8168b_0_hw_jumbo_enable()
4970 static void r8168b_0_hw_jumbo_disable(struct rtl8169_private *tp) in r8168b_0_hw_jumbo_disable() argument
4972 rtl_tx_performance_tweak(tp->pci_dev, in r8168b_0_hw_jumbo_disable()
4976 static void r8168b_1_hw_jumbo_enable(struct rtl8169_private *tp) in r8168b_1_hw_jumbo_enable() argument
4978 void __iomem *ioaddr = tp->mmio_addr; in r8168b_1_hw_jumbo_enable()
4980 r8168b_0_hw_jumbo_enable(tp); in r8168b_1_hw_jumbo_enable()
4985 static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp) in r8168b_1_hw_jumbo_disable() argument
4987 void __iomem *ioaddr = tp->mmio_addr; in r8168b_1_hw_jumbo_disable()
4989 r8168b_0_hw_jumbo_disable(tp); in r8168b_1_hw_jumbo_disable()
4994 static void rtl_init_jumbo_ops(struct rtl8169_private *tp) in rtl_init_jumbo_ops() argument
4996 struct jumbo_ops *ops = &tp->jumbo_ops; in rtl_init_jumbo_ops()
4998 switch (tp->mac_version) { in rtl_init_jumbo_ops()
5058 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
5063 static void rtl_hw_reset(struct rtl8169_private *tp) in rtl_hw_reset() argument
5065 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_reset()
5069 rtl_udelay_loop_wait_low(tp, &rtl_chipcmd_cond, 100, 100); in rtl_hw_reset()
5072 static void rtl_request_uncached_firmware(struct rtl8169_private *tp) in rtl_request_uncached_firmware() argument
5078 name = rtl_lookup_firmware_name(tp); in rtl_request_uncached_firmware()
5086 rc = request_firmware(&rtl_fw->fw, name, &tp->pci_dev->dev); in rtl_request_uncached_firmware()
5090 rc = rtl_check_firmware(tp, rtl_fw); in rtl_request_uncached_firmware()
5094 tp->rtl_fw = rtl_fw; in rtl_request_uncached_firmware()
5103 netif_warn(tp, ifup, tp->dev, "unable to load firmware patch %s (%d)\n", in rtl_request_uncached_firmware()
5106 tp->rtl_fw = NULL; in rtl_request_uncached_firmware()
5110 static void rtl_request_firmware(struct rtl8169_private *tp) in rtl_request_firmware() argument
5112 if (IS_ERR(tp->rtl_fw)) in rtl_request_firmware()
5113 rtl_request_uncached_firmware(tp); in rtl_request_firmware()
5116 static void rtl_rx_close(struct rtl8169_private *tp) in rtl_rx_close() argument
5118 void __iomem *ioaddr = tp->mmio_addr; in rtl_rx_close()
5125 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
5132 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
5137 static void rtl8169_hw_reset(struct rtl8169_private *tp) in rtl8169_hw_reset() argument
5139 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_hw_reset()
5142 rtl8169_irq_mask_and_ack(tp); in rtl8169_hw_reset()
5144 rtl_rx_close(tp); in rtl8169_hw_reset()
5146 if (tp->mac_version == RTL_GIGA_MAC_VER_27 || in rtl8169_hw_reset()
5147 tp->mac_version == RTL_GIGA_MAC_VER_28 || in rtl8169_hw_reset()
5148 tp->mac_version == RTL_GIGA_MAC_VER_31) { in rtl8169_hw_reset()
5149 rtl_udelay_loop_wait_low(tp, &rtl_npq_cond, 20, 42*42); in rtl8169_hw_reset()
5150 } else if (tp->mac_version == RTL_GIGA_MAC_VER_34 || in rtl8169_hw_reset()
5151 tp->mac_version == RTL_GIGA_MAC_VER_35 || in rtl8169_hw_reset()
5152 tp->mac_version == RTL_GIGA_MAC_VER_36 || in rtl8169_hw_reset()
5153 tp->mac_version == RTL_GIGA_MAC_VER_37 || in rtl8169_hw_reset()
5154 tp->mac_version == RTL_GIGA_MAC_VER_38 || in rtl8169_hw_reset()
5155 tp->mac_version == RTL_GIGA_MAC_VER_40 || in rtl8169_hw_reset()
5156 tp->mac_version == RTL_GIGA_MAC_VER_41 || in rtl8169_hw_reset()
5157 tp->mac_version == RTL_GIGA_MAC_VER_42 || in rtl8169_hw_reset()
5158 tp->mac_version == RTL_GIGA_MAC_VER_43 || in rtl8169_hw_reset()
5159 tp->mac_version == RTL_GIGA_MAC_VER_44 || in rtl8169_hw_reset()
5160 tp->mac_version == RTL_GIGA_MAC_VER_45 || in rtl8169_hw_reset()
5161 tp->mac_version == RTL_GIGA_MAC_VER_46 || in rtl8169_hw_reset()
5162 tp->mac_version == RTL_GIGA_MAC_VER_47 || in rtl8169_hw_reset()
5163 tp->mac_version == RTL_GIGA_MAC_VER_48 || in rtl8169_hw_reset()
5164 tp->mac_version == RTL_GIGA_MAC_VER_49 || in rtl8169_hw_reset()
5165 tp->mac_version == RTL_GIGA_MAC_VER_50 || in rtl8169_hw_reset()
5166 tp->mac_version == RTL_GIGA_MAC_VER_51) { in rtl8169_hw_reset()
5168 rtl_udelay_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666); in rtl8169_hw_reset()
5174 rtl_hw_reset(tp); in rtl8169_hw_reset()
5177 static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp) in rtl_set_rx_tx_config_registers() argument
5179 void __iomem *ioaddr = tp->mmio_addr; in rtl_set_rx_tx_config_registers()
5188 struct rtl8169_private *tp = netdev_priv(dev); in rtl_hw_start() local
5190 tp->hw_start(dev); in rtl_hw_start()
5192 rtl_irq_enable_all(tp); in rtl_hw_start()
5195 static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp, in rtl_set_rx_tx_desc_registers() argument
5203 RTL_W32(TxDescStartAddrHigh, ((u64) tp->TxPhyAddr) >> 32); in rtl_set_rx_tx_desc_registers()
5204 RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr) & DMA_BIT_MASK(32)); in rtl_set_rx_tx_desc_registers()
5205 RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr) >> 32); in rtl_set_rx_tx_desc_registers()
5206 RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr) & DMA_BIT_MASK(32)); in rtl_set_rx_tx_desc_registers()
5251 struct rtl8169_private *tp = netdev_priv(dev); in rtl_set_rx_mode() local
5252 void __iomem *ioaddr = tp->mmio_addr; in rtl_set_rx_mode()
5259 netif_notice(tp, link, dev, "Promiscuous mode enabled\n"); in rtl_set_rx_mode()
5286 if (tp->mac_version > RTL_GIGA_MAC_VER_06) { in rtl_set_rx_mode()
5293 if (tp->mac_version == RTL_GIGA_MAC_VER_35) in rtl_set_rx_mode()
5304 struct rtl8169_private *tp = netdev_priv(dev); in rtl_hw_start_8169() local
5305 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8169()
5306 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8169()
5308 if (tp->mac_version == RTL_GIGA_MAC_VER_05) { in rtl_hw_start_8169()
5314 if (tp->mac_version == RTL_GIGA_MAC_VER_01 || in rtl_hw_start_8169()
5315 tp->mac_version == RTL_GIGA_MAC_VER_02 || in rtl_hw_start_8169()
5316 tp->mac_version == RTL_GIGA_MAC_VER_03 || in rtl_hw_start_8169()
5317 tp->mac_version == RTL_GIGA_MAC_VER_04) in rtl_hw_start_8169()
5320 rtl_init_rxcfg(tp); in rtl_hw_start_8169()
5326 if (tp->mac_version == RTL_GIGA_MAC_VER_01 || in rtl_hw_start_8169()
5327 tp->mac_version == RTL_GIGA_MAC_VER_02 || in rtl_hw_start_8169()
5328 tp->mac_version == RTL_GIGA_MAC_VER_03 || in rtl_hw_start_8169()
5329 tp->mac_version == RTL_GIGA_MAC_VER_04) in rtl_hw_start_8169()
5330 rtl_set_rx_tx_config_registers(tp); in rtl_hw_start_8169()
5332 tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; in rtl_hw_start_8169()
5334 if (tp->mac_version == RTL_GIGA_MAC_VER_02 || in rtl_hw_start_8169()
5335 tp->mac_version == RTL_GIGA_MAC_VER_03) { in rtl_hw_start_8169()
5338 tp->cp_cmd |= (1 << 14); in rtl_hw_start_8169()
5341 RTL_W16(CPlusCmd, tp->cp_cmd); in rtl_hw_start_8169()
5343 rtl8169_set_magic_reg(ioaddr, tp->mac_version); in rtl_hw_start_8169()
5351 rtl_set_rx_tx_desc_registers(tp, ioaddr); in rtl_hw_start_8169()
5353 if (tp->mac_version != RTL_GIGA_MAC_VER_01 && in rtl_hw_start_8169()
5354 tp->mac_version != RTL_GIGA_MAC_VER_02 && in rtl_hw_start_8169()
5355 tp->mac_version != RTL_GIGA_MAC_VER_03 && in rtl_hw_start_8169()
5356 tp->mac_version != RTL_GIGA_MAC_VER_04) { in rtl_hw_start_8169()
5358 rtl_set_rx_tx_config_registers(tp); in rtl_hw_start_8169()
5374 static void rtl_csi_write(struct rtl8169_private *tp, int addr, int value) in rtl_csi_write() argument
5376 if (tp->csi_ops.write) in rtl_csi_write()
5377 tp->csi_ops.write(tp, addr, value); in rtl_csi_write()
5380 static u32 rtl_csi_read(struct rtl8169_private *tp, int addr) in rtl_csi_read() argument
5382 return tp->csi_ops.read ? tp->csi_ops.read(tp, addr) : ~0; in rtl_csi_read()
5385 static void rtl_csi_access_enable(struct rtl8169_private *tp, u32 bits) in rtl_csi_access_enable() argument
5389 csi = rtl_csi_read(tp, 0x070c) & 0x00ffffff; in rtl_csi_access_enable()
5390 rtl_csi_write(tp, 0x070c, csi | bits); in rtl_csi_access_enable()
5393 static void rtl_csi_access_enable_1(struct rtl8169_private *tp) in rtl_csi_access_enable_1() argument
5395 rtl_csi_access_enable(tp, 0x17000000); in rtl_csi_access_enable_1()
5398 static void rtl_csi_access_enable_2(struct rtl8169_private *tp) in rtl_csi_access_enable_2() argument
5400 rtl_csi_access_enable(tp, 0x27000000); in rtl_csi_access_enable_2()
5405 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
5410 static void r8169_csi_write(struct rtl8169_private *tp, int addr, int value) in r8169_csi_write() argument
5412 void __iomem *ioaddr = tp->mmio_addr; in r8169_csi_write()
5418 rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100); in r8169_csi_write()
5421 static u32 r8169_csi_read(struct rtl8169_private *tp, int addr) in r8169_csi_read() argument
5423 void __iomem *ioaddr = tp->mmio_addr; in r8169_csi_read()
5428 return rtl_udelay_loop_wait_high(tp, &rtl_csiar_cond, 10, 100) ? in r8169_csi_read()
5432 static void r8402_csi_write(struct rtl8169_private *tp, int addr, int value) in r8402_csi_write() argument
5434 void __iomem *ioaddr = tp->mmio_addr; in r8402_csi_write()
5441 rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100); in r8402_csi_write()
5444 static u32 r8402_csi_read(struct rtl8169_private *tp, int addr) in r8402_csi_read() argument
5446 void __iomem *ioaddr = tp->mmio_addr; in r8402_csi_read()
5451 return rtl_udelay_loop_wait_high(tp, &rtl_csiar_cond, 10, 100) ? in r8402_csi_read()
5455 static void r8411_csi_write(struct rtl8169_private *tp, int addr, int value) in r8411_csi_write() argument
5457 void __iomem *ioaddr = tp->mmio_addr; in r8411_csi_write()
5464 rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100); in r8411_csi_write()
5467 static u32 r8411_csi_read(struct rtl8169_private *tp, int addr) in r8411_csi_read() argument
5469 void __iomem *ioaddr = tp->mmio_addr; in r8411_csi_read()
5474 return rtl_udelay_loop_wait_high(tp, &rtl_csiar_cond, 10, 100) ? in r8411_csi_read()
5478 static void rtl_init_csi_ops(struct rtl8169_private *tp) in rtl_init_csi_ops() argument
5480 struct csi_ops *ops = &tp->csi_ops; in rtl_init_csi_ops()
5482 switch (tp->mac_version) { in rtl_init_csi_ops()
5525 static void rtl_ephy_init(struct rtl8169_private *tp, const struct ephy_info *e, in rtl_ephy_init() argument
5531 w = (rtl_ephy_read(tp, e->offset) & ~e->mask) | e->bits; in rtl_ephy_init()
5532 rtl_ephy_write(tp, e->offset, w); in rtl_ephy_init()
5549 static void rtl_pcie_state_l2l3_enable(struct rtl8169_private *tp, bool enable) in rtl_pcie_state_l2l3_enable() argument
5551 void __iomem *ioaddr = tp->mmio_addr; in rtl_pcie_state_l2l3_enable()
5575 static void rtl_hw_start_8168bb(struct rtl8169_private *tp) in rtl_hw_start_8168bb() argument
5577 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168bb()
5578 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168bb()
5584 if (tp->dev->mtu <= ETH_DATA_LEN) { in rtl_hw_start_8168bb()
5590 static void rtl_hw_start_8168bef(struct rtl8169_private *tp) in rtl_hw_start_8168bef() argument
5592 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168bef()
5594 rtl_hw_start_8168bb(tp); in rtl_hw_start_8168bef()
5601 static void __rtl_hw_start_8168cp(struct rtl8169_private *tp) in __rtl_hw_start_8168cp() argument
5603 void __iomem *ioaddr = tp->mmio_addr; in __rtl_hw_start_8168cp()
5604 struct pci_dev *pdev = tp->pci_dev; in __rtl_hw_start_8168cp()
5610 if (tp->dev->mtu <= ETH_DATA_LEN) in __rtl_hw_start_8168cp()
5618 static void rtl_hw_start_8168cp_1(struct rtl8169_private *tp) in rtl_hw_start_8168cp_1() argument
5628 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168cp_1()
5630 rtl_ephy_init(tp, e_info_8168cp, ARRAY_SIZE(e_info_8168cp)); in rtl_hw_start_8168cp_1()
5632 __rtl_hw_start_8168cp(tp); in rtl_hw_start_8168cp_1()
5635 static void rtl_hw_start_8168cp_2(struct rtl8169_private *tp) in rtl_hw_start_8168cp_2() argument
5637 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168cp_2()
5638 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168cp_2()
5640 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168cp_2()
5644 if (tp->dev->mtu <= ETH_DATA_LEN) in rtl_hw_start_8168cp_2()
5650 static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp) in rtl_hw_start_8168cp_3() argument
5652 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168cp_3()
5653 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168cp_3()
5655 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168cp_3()
5664 if (tp->dev->mtu <= ETH_DATA_LEN) in rtl_hw_start_8168cp_3()
5670 static void rtl_hw_start_8168c_1(struct rtl8169_private *tp) in rtl_hw_start_8168c_1() argument
5672 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168c_1()
5679 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168c_1()
5683 rtl_ephy_init(tp, e_info_8168c_1, ARRAY_SIZE(e_info_8168c_1)); in rtl_hw_start_8168c_1()
5685 __rtl_hw_start_8168cp(tp); in rtl_hw_start_8168c_1()
5688 static void rtl_hw_start_8168c_2(struct rtl8169_private *tp) in rtl_hw_start_8168c_2() argument
5695 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168c_2()
5697 rtl_ephy_init(tp, e_info_8168c_2, ARRAY_SIZE(e_info_8168c_2)); in rtl_hw_start_8168c_2()
5699 __rtl_hw_start_8168cp(tp); in rtl_hw_start_8168c_2()
5702 static void rtl_hw_start_8168c_3(struct rtl8169_private *tp) in rtl_hw_start_8168c_3() argument
5704 rtl_hw_start_8168c_2(tp); in rtl_hw_start_8168c_3()
5707 static void rtl_hw_start_8168c_4(struct rtl8169_private *tp) in rtl_hw_start_8168c_4() argument
5709 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168c_4()
5711 __rtl_hw_start_8168cp(tp); in rtl_hw_start_8168c_4()
5714 static void rtl_hw_start_8168d(struct rtl8169_private *tp) in rtl_hw_start_8168d() argument
5716 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168d()
5717 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168d()
5719 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168d()
5725 if (tp->dev->mtu <= ETH_DATA_LEN) in rtl_hw_start_8168d()
5731 static void rtl_hw_start_8168dp(struct rtl8169_private *tp) in rtl_hw_start_8168dp() argument
5733 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168dp()
5734 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168dp()
5736 rtl_csi_access_enable_1(tp); in rtl_hw_start_8168dp()
5738 if (tp->dev->mtu <= ETH_DATA_LEN) in rtl_hw_start_8168dp()
5746 static void rtl_hw_start_8168d_4(struct rtl8169_private *tp) in rtl_hw_start_8168d_4() argument
5748 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168d_4()
5749 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168d_4()
5757 rtl_csi_access_enable_1(tp); in rtl_hw_start_8168d_4()
5767 w = rtl_ephy_read(tp, e->offset); in rtl_hw_start_8168d_4()
5768 rtl_ephy_write(tp, 0x03, (w & e->mask) | e->bits); in rtl_hw_start_8168d_4()
5774 static void rtl_hw_start_8168e_1(struct rtl8169_private *tp) in rtl_hw_start_8168e_1() argument
5776 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168e_1()
5777 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168e_1()
5794 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168e_1()
5796 rtl_ephy_init(tp, e_info_8168e_1, ARRAY_SIZE(e_info_8168e_1)); in rtl_hw_start_8168e_1()
5798 if (tp->dev->mtu <= ETH_DATA_LEN) in rtl_hw_start_8168e_1()
5812 static void rtl_hw_start_8168e_2(struct rtl8169_private *tp) in rtl_hw_start_8168e_2() argument
5814 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168e_2()
5815 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168e_2()
5821 rtl_csi_access_enable_1(tp); in rtl_hw_start_8168e_2()
5823 rtl_ephy_init(tp, e_info_8168e_2, ARRAY_SIZE(e_info_8168e_2)); in rtl_hw_start_8168e_2()
5825 if (tp->dev->mtu <= ETH_DATA_LEN) in rtl_hw_start_8168e_2()
5828 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168e_2()
5829 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168e_2()
5830 rtl_eri_write(tp, 0xc8, ERIAR_MASK_1111, 0x00100002, ERIAR_EXGMAC); in rtl_hw_start_8168e_2()
5831 rtl_eri_write(tp, 0xe8, ERIAR_MASK_1111, 0x00100006, ERIAR_EXGMAC); in rtl_hw_start_8168e_2()
5832 rtl_eri_write(tp, 0xcc, ERIAR_MASK_1111, 0x00000050, ERIAR_EXGMAC); in rtl_hw_start_8168e_2()
5833 rtl_eri_write(tp, 0xd0, ERIAR_MASK_1111, 0x07ff0060, ERIAR_EXGMAC); in rtl_hw_start_8168e_2()
5834 rtl_w0w1_eri(tp, 0x1b0, ERIAR_MASK_0001, 0x10, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168e_2()
5835 rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0xff00, ERIAR_EXGMAC); in rtl_hw_start_8168e_2()
5852 static void rtl_hw_start_8168f(struct rtl8169_private *tp) in rtl_hw_start_8168f() argument
5854 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168f()
5855 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168f()
5857 rtl_csi_access_enable_2(tp); in rtl_hw_start_8168f()
5861 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5862 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5863 rtl_eri_write(tp, 0xc8, ERIAR_MASK_1111, 0x00100002, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5864 rtl_eri_write(tp, 0xe8, ERIAR_MASK_1111, 0x00100006, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5865 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5866 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5867 rtl_w0w1_eri(tp, 0x1b0, ERIAR_MASK_0001, 0x10, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5868 rtl_w0w1_eri(tp, 0x1d0, ERIAR_MASK_0001, 0x10, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5869 rtl_eri_write(tp, 0xcc, ERIAR_MASK_1111, 0x00000050, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5870 rtl_eri_write(tp, 0xd0, ERIAR_MASK_1111, 0x00000060, ERIAR_EXGMAC); in rtl_hw_start_8168f()
5883 static void rtl_hw_start_8168f_1(struct rtl8169_private *tp) in rtl_hw_start_8168f_1() argument
5885 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168f_1()
5893 rtl_hw_start_8168f(tp); in rtl_hw_start_8168f_1()
5895 rtl_ephy_init(tp, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1)); in rtl_hw_start_8168f_1()
5897 rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0xff00, ERIAR_EXGMAC); in rtl_hw_start_8168f_1()
5903 static void rtl_hw_start_8411(struct rtl8169_private *tp) in rtl_hw_start_8411() argument
5912 rtl_hw_start_8168f(tp); in rtl_hw_start_8411()
5913 rtl_pcie_state_l2l3_enable(tp, false); in rtl_hw_start_8411()
5915 rtl_ephy_init(tp, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1)); in rtl_hw_start_8411()
5917 rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8411()
5920 static void rtl_hw_start_8168g(struct rtl8169_private *tp) in rtl_hw_start_8168g() argument
5922 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168g()
5923 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168g()
5927 rtl_eri_write(tp, 0xc8, ERIAR_MASK_0101, 0x080002, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5928 rtl_eri_write(tp, 0xcc, ERIAR_MASK_0001, 0x38, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5929 rtl_eri_write(tp, 0xd0, ERIAR_MASK_0001, 0x48, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5930 rtl_eri_write(tp, 0xe8, ERIAR_MASK_1111, 0x00100006, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5932 rtl_csi_access_enable_1(tp); in rtl_hw_start_8168g()
5936 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5937 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5938 rtl_eri_write(tp, 0x2f8, ERIAR_MASK_0011, 0x1d8f, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5943 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5944 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5949 rtl_w0w1_eri(tp, 0x2fc, ERIAR_MASK_0001, 0x01, 0x06, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5950 rtl_w0w1_eri(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, 0x1000, ERIAR_EXGMAC); in rtl_hw_start_8168g()
5952 rtl_pcie_state_l2l3_enable(tp, false); in rtl_hw_start_8168g()
5955 static void rtl_hw_start_8168g_1(struct rtl8169_private *tp) in rtl_hw_start_8168g_1() argument
5957 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168g_1()
5965 rtl_hw_start_8168g(tp); in rtl_hw_start_8168g_1()
5970 rtl_ephy_init(tp, e_info_8168g_1, ARRAY_SIZE(e_info_8168g_1)); in rtl_hw_start_8168g_1()
5973 static void rtl_hw_start_8168g_2(struct rtl8169_private *tp) in rtl_hw_start_8168g_2() argument
5975 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168g_2()
5983 rtl_hw_start_8168g(tp); in rtl_hw_start_8168g_2()
5988 rtl_ephy_init(tp, e_info_8168g_2, ARRAY_SIZE(e_info_8168g_2)); in rtl_hw_start_8168g_2()
5991 static void rtl_hw_start_8411_2(struct rtl8169_private *tp) in rtl_hw_start_8411_2() argument
5993 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8411_2()
6002 rtl_hw_start_8168g(tp); in rtl_hw_start_8411_2()
6007 rtl_ephy_init(tp, e_info_8411_2, ARRAY_SIZE(e_info_8411_2)); in rtl_hw_start_8411_2()
6010 static void rtl_hw_start_8168h_1(struct rtl8169_private *tp) in rtl_hw_start_8168h_1() argument
6012 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168h_1()
6013 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168h_1()
6028 rtl_ephy_init(tp, e_info_8168h_1, ARRAY_SIZE(e_info_8168h_1)); in rtl_hw_start_8168h_1()
6032 rtl_eri_write(tp, 0xc8, ERIAR_MASK_0101, 0x00080002, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6033 rtl_eri_write(tp, 0xcc, ERIAR_MASK_0001, 0x38, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6034 rtl_eri_write(tp, 0xd0, ERIAR_MASK_0001, 0x48, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6035 rtl_eri_write(tp, 0xe8, ERIAR_MASK_1111, 0x00100006, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6037 rtl_csi_access_enable_1(tp); in rtl_hw_start_8168h_1()
6041 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6042 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6044 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_1111, 0x0010, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6046 rtl_w0w1_eri(tp, 0xd4, ERIAR_MASK_1111, 0x1f00, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6048 rtl_eri_write(tp, 0x5f0, ERIAR_MASK_0011, 0x4f87, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6053 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6054 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6064 rtl_w0w1_eri(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, 0x1000, ERIAR_EXGMAC); in rtl_hw_start_8168h_1()
6066 rtl_pcie_state_l2l3_enable(tp, false); in rtl_hw_start_8168h_1()
6068 rtl_writephy(tp, 0x1f, 0x0c42); in rtl_hw_start_8168h_1()
6069 rg_saw_cnt = rtl_readphy(tp, 0x13); in rtl_hw_start_8168h_1()
6070 rtl_writephy(tp, 0x1f, 0x0000); in rtl_hw_start_8168h_1()
6076 data = r8168_mac_ocp_read(tp, 0xd412); in rtl_hw_start_8168h_1()
6079 r8168_mac_ocp_write(tp, 0xd412, data); in rtl_hw_start_8168h_1()
6082 data = r8168_mac_ocp_read(tp, 0xe056); in rtl_hw_start_8168h_1()
6085 r8168_mac_ocp_write(tp, 0xe056, data); in rtl_hw_start_8168h_1()
6087 data = r8168_mac_ocp_read(tp, 0xe052); in rtl_hw_start_8168h_1()
6090 r8168_mac_ocp_write(tp, 0xe052, data); in rtl_hw_start_8168h_1()
6092 data = r8168_mac_ocp_read(tp, 0xe0d6); in rtl_hw_start_8168h_1()
6095 r8168_mac_ocp_write(tp, 0xe0d6, data); in rtl_hw_start_8168h_1()
6097 data = r8168_mac_ocp_read(tp, 0xd420); in rtl_hw_start_8168h_1()
6100 r8168_mac_ocp_write(tp, 0xd420, data); in rtl_hw_start_8168h_1()
6102 r8168_mac_ocp_write(tp, 0xe63e, 0x0001); in rtl_hw_start_8168h_1()
6103 r8168_mac_ocp_write(tp, 0xe63e, 0x0000); in rtl_hw_start_8168h_1()
6104 r8168_mac_ocp_write(tp, 0xc094, 0x0000); in rtl_hw_start_8168h_1()
6105 r8168_mac_ocp_write(tp, 0xc09e, 0x0000); in rtl_hw_start_8168h_1()
6108 static void rtl_hw_start_8168ep(struct rtl8169_private *tp) in rtl_hw_start_8168ep() argument
6110 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168ep()
6111 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8168ep()
6113 rtl8168ep_stop_cmac(tp); in rtl_hw_start_8168ep()
6117 rtl_eri_write(tp, 0xc8, ERIAR_MASK_0101, 0x00080002, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6118 rtl_eri_write(tp, 0xcc, ERIAR_MASK_0001, 0x2f, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6119 rtl_eri_write(tp, 0xd0, ERIAR_MASK_0001, 0x5f, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6120 rtl_eri_write(tp, 0xe8, ERIAR_MASK_1111, 0x00100006, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6122 rtl_csi_access_enable_1(tp); in rtl_hw_start_8168ep()
6126 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6127 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6129 rtl_w0w1_eri(tp, 0xd4, ERIAR_MASK_1111, 0x1f80, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6131 rtl_eri_write(tp, 0x5f0, ERIAR_MASK_0011, 0x4f87, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6136 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6137 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6142 rtl_w0w1_eri(tp, 0x2fc, ERIAR_MASK_0001, 0x01, 0x06, ERIAR_EXGMAC); in rtl_hw_start_8168ep()
6146 rtl_pcie_state_l2l3_enable(tp, false); in rtl_hw_start_8168ep()
6149 static void rtl_hw_start_8168ep_1(struct rtl8169_private *tp) in rtl_hw_start_8168ep_1() argument
6151 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168ep_1()
6163 rtl_ephy_init(tp, e_info_8168ep_1, ARRAY_SIZE(e_info_8168ep_1)); in rtl_hw_start_8168ep_1()
6165 rtl_hw_start_8168ep(tp); in rtl_hw_start_8168ep_1()
6168 static void rtl_hw_start_8168ep_2(struct rtl8169_private *tp) in rtl_hw_start_8168ep_2() argument
6170 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168ep_2()
6180 rtl_ephy_init(tp, e_info_8168ep_2, ARRAY_SIZE(e_info_8168ep_2)); in rtl_hw_start_8168ep_2()
6182 rtl_hw_start_8168ep(tp); in rtl_hw_start_8168ep_2()
6188 static void rtl_hw_start_8168ep_3(struct rtl8169_private *tp) in rtl_hw_start_8168ep_3() argument
6190 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168ep_3()
6202 rtl_ephy_init(tp, e_info_8168ep_3, ARRAY_SIZE(e_info_8168ep_3)); in rtl_hw_start_8168ep_3()
6204 rtl_hw_start_8168ep(tp); in rtl_hw_start_8168ep_3()
6209 data = r8168_mac_ocp_read(tp, 0xd3e2); in rtl_hw_start_8168ep_3()
6212 r8168_mac_ocp_write(tp, 0xd3e2, data); in rtl_hw_start_8168ep_3()
6214 data = r8168_mac_ocp_read(tp, 0xd3e4); in rtl_hw_start_8168ep_3()
6216 r8168_mac_ocp_write(tp, 0xd3e4, data); in rtl_hw_start_8168ep_3()
6218 data = r8168_mac_ocp_read(tp, 0xe860); in rtl_hw_start_8168ep_3()
6220 r8168_mac_ocp_write(tp, 0xe860, data); in rtl_hw_start_8168ep_3()
6225 struct rtl8169_private *tp = netdev_priv(dev); in rtl_hw_start_8168() local
6226 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8168()
6234 tp->cp_cmd |= RTL_R16(CPlusCmd) | PktCntrDisable | INTT_1; in rtl_hw_start_8168()
6236 RTL_W16(CPlusCmd, tp->cp_cmd); in rtl_hw_start_8168()
6241 if (tp->mac_version == RTL_GIGA_MAC_VER_11) { in rtl_hw_start_8168()
6242 tp->event_slow |= RxFIFOOver | PCSTimeout; in rtl_hw_start_8168()
6243 tp->event_slow &= ~RxOverflow; in rtl_hw_start_8168()
6246 rtl_set_rx_tx_desc_registers(tp, ioaddr); in rtl_hw_start_8168()
6248 rtl_set_rx_tx_config_registers(tp); in rtl_hw_start_8168()
6252 switch (tp->mac_version) { in rtl_hw_start_8168()
6254 rtl_hw_start_8168bb(tp); in rtl_hw_start_8168()
6259 rtl_hw_start_8168bef(tp); in rtl_hw_start_8168()
6263 rtl_hw_start_8168cp_1(tp); in rtl_hw_start_8168()
6267 rtl_hw_start_8168c_1(tp); in rtl_hw_start_8168()
6271 rtl_hw_start_8168c_2(tp); in rtl_hw_start_8168()
6275 rtl_hw_start_8168c_3(tp); in rtl_hw_start_8168()
6279 rtl_hw_start_8168c_4(tp); in rtl_hw_start_8168()
6283 rtl_hw_start_8168cp_2(tp); in rtl_hw_start_8168()
6287 rtl_hw_start_8168cp_3(tp); in rtl_hw_start_8168()
6293 rtl_hw_start_8168d(tp); in rtl_hw_start_8168()
6297 rtl_hw_start_8168d_4(tp); in rtl_hw_start_8168()
6301 rtl_hw_start_8168dp(tp); in rtl_hw_start_8168()
6306 rtl_hw_start_8168e_1(tp); in rtl_hw_start_8168()
6309 rtl_hw_start_8168e_2(tp); in rtl_hw_start_8168()
6314 rtl_hw_start_8168f_1(tp); in rtl_hw_start_8168()
6318 rtl_hw_start_8411(tp); in rtl_hw_start_8168()
6323 rtl_hw_start_8168g_1(tp); in rtl_hw_start_8168()
6326 rtl_hw_start_8168g_2(tp); in rtl_hw_start_8168()
6330 rtl_hw_start_8411_2(tp); in rtl_hw_start_8168()
6335 rtl_hw_start_8168h_1(tp); in rtl_hw_start_8168()
6339 rtl_hw_start_8168ep_1(tp); in rtl_hw_start_8168()
6343 rtl_hw_start_8168ep_2(tp); in rtl_hw_start_8168()
6347 rtl_hw_start_8168ep_3(tp); in rtl_hw_start_8168()
6352 dev->name, tp->mac_version); in rtl_hw_start_8168()
6376 static void rtl_hw_start_8102e_1(struct rtl8169_private *tp) in rtl_hw_start_8102e_1() argument
6378 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8102e_1()
6379 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8102e_1()
6392 rtl_csi_access_enable_2(tp); in rtl_hw_start_8102e_1()
6406 rtl_ephy_init(tp, e_info_8102e_1, ARRAY_SIZE(e_info_8102e_1)); in rtl_hw_start_8102e_1()
6409 static void rtl_hw_start_8102e_2(struct rtl8169_private *tp) in rtl_hw_start_8102e_2() argument
6411 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8102e_2()
6412 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8102e_2()
6414 rtl_csi_access_enable_2(tp); in rtl_hw_start_8102e_2()
6422 static void rtl_hw_start_8102e_3(struct rtl8169_private *tp) in rtl_hw_start_8102e_3() argument
6424 rtl_hw_start_8102e_2(tp); in rtl_hw_start_8102e_3()
6426 rtl_ephy_write(tp, 0x03, 0xc2f9); in rtl_hw_start_8102e_3()
6429 static void rtl_hw_start_8105e_1(struct rtl8169_private *tp) in rtl_hw_start_8105e_1() argument
6431 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8105e_1()
6452 rtl_ephy_init(tp, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1)); in rtl_hw_start_8105e_1()
6454 rtl_pcie_state_l2l3_enable(tp, false); in rtl_hw_start_8105e_1()
6457 static void rtl_hw_start_8105e_2(struct rtl8169_private *tp) in rtl_hw_start_8105e_2() argument
6459 rtl_hw_start_8105e_1(tp); in rtl_hw_start_8105e_2()
6460 rtl_ephy_write(tp, 0x1e, rtl_ephy_read(tp, 0x1e) | 0x8000); in rtl_hw_start_8105e_2()
6463 static void rtl_hw_start_8402(struct rtl8169_private *tp) in rtl_hw_start_8402() argument
6465 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8402()
6471 rtl_csi_access_enable_2(tp); in rtl_hw_start_8402()
6479 rtl_ephy_init(tp, e_info_8402, ARRAY_SIZE(e_info_8402)); in rtl_hw_start_8402()
6481 rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT); in rtl_hw_start_8402()
6483 rtl_eri_write(tp, 0xc8, ERIAR_MASK_1111, 0x00000002, ERIAR_EXGMAC); in rtl_hw_start_8402()
6484 rtl_eri_write(tp, 0xe8, ERIAR_MASK_1111, 0x00000006, ERIAR_EXGMAC); in rtl_hw_start_8402()
6485 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, ERIAR_EXGMAC); in rtl_hw_start_8402()
6486 rtl_w0w1_eri(tp, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, ERIAR_EXGMAC); in rtl_hw_start_8402()
6487 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8402()
6488 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); in rtl_hw_start_8402()
6489 rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0e00, 0xff00, ERIAR_EXGMAC); in rtl_hw_start_8402()
6491 rtl_pcie_state_l2l3_enable(tp, false); in rtl_hw_start_8402()
6494 static void rtl_hw_start_8106(struct rtl8169_private *tp) in rtl_hw_start_8106() argument
6496 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8106()
6505 rtl_pcie_state_l2l3_enable(tp, false); in rtl_hw_start_8106()
6510 struct rtl8169_private *tp = netdev_priv(dev); in rtl_hw_start_8101() local
6511 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_start_8101()
6512 struct pci_dev *pdev = tp->pci_dev; in rtl_hw_start_8101()
6514 if (tp->mac_version >= RTL_GIGA_MAC_VER_30) in rtl_hw_start_8101()
6515 tp->event_slow &= ~RxFIFOOver; in rtl_hw_start_8101()
6517 if (tp->mac_version == RTL_GIGA_MAC_VER_13 || in rtl_hw_start_8101()
6518 tp->mac_version == RTL_GIGA_MAC_VER_16) in rtl_hw_start_8101()
6528 tp->cp_cmd &= ~R810X_CPCMD_QUIRK_MASK; in rtl_hw_start_8101()
6529 RTL_W16(CPlusCmd, tp->cp_cmd); in rtl_hw_start_8101()
6531 rtl_set_rx_tx_desc_registers(tp, ioaddr); in rtl_hw_start_8101()
6533 rtl_set_rx_tx_config_registers(tp); in rtl_hw_start_8101()
6535 switch (tp->mac_version) { in rtl_hw_start_8101()
6537 rtl_hw_start_8102e_1(tp); in rtl_hw_start_8101()
6541 rtl_hw_start_8102e_3(tp); in rtl_hw_start_8101()
6545 rtl_hw_start_8102e_2(tp); in rtl_hw_start_8101()
6549 rtl_hw_start_8105e_1(tp); in rtl_hw_start_8101()
6552 rtl_hw_start_8105e_2(tp); in rtl_hw_start_8101()
6556 rtl_hw_start_8402(tp); in rtl_hw_start_8101()
6560 rtl_hw_start_8106(tp); in rtl_hw_start_8101()
6563 rtl_hw_start_8168g_2(tp); in rtl_hw_start_8101()
6567 rtl_hw_start_8168h_1(tp); in rtl_hw_start_8101()
6586 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_change_mtu() local
6589 new_mtu > rtl_chip_infos[tp->mac_version].jumbo_max) in rtl8169_change_mtu()
6593 rtl_hw_jumbo_enable(tp); in rtl8169_change_mtu()
6595 rtl_hw_jumbo_disable(tp); in rtl8169_change_mtu()
6609 static void rtl8169_free_rx_databuff(struct rtl8169_private *tp, in rtl8169_free_rx_databuff() argument
6612 dma_unmap_single(&tp->pci_dev->dev, le64_to_cpu(desc->addr), rx_buf_sz, in rtl8169_free_rx_databuff()
6642 static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp, in rtl8169_alloc_rx_data() argument
6647 struct device *d = &tp->pci_dev->dev; in rtl8169_alloc_rx_data()
6648 struct net_device *dev = tp->dev; in rtl8169_alloc_rx_data()
6666 netif_err(tp, drv, tp->dev, "Failed to map RX DMA!\n"); in rtl8169_alloc_rx_data()
6678 static void rtl8169_rx_clear(struct rtl8169_private *tp) in rtl8169_rx_clear() argument
6683 if (tp->Rx_databuff[i]) { in rtl8169_rx_clear()
6684 rtl8169_free_rx_databuff(tp, tp->Rx_databuff + i, in rtl8169_rx_clear()
6685 tp->RxDescArray + i); in rtl8169_rx_clear()
6695 static int rtl8169_rx_fill(struct rtl8169_private *tp) in rtl8169_rx_fill() argument
6702 if (tp->Rx_databuff[i]) in rtl8169_rx_fill()
6705 data = rtl8169_alloc_rx_data(tp, tp->RxDescArray + i); in rtl8169_rx_fill()
6707 rtl8169_make_unusable_by_asic(tp->RxDescArray + i); in rtl8169_rx_fill()
6710 tp->Rx_databuff[i] = data; in rtl8169_rx_fill()
6713 rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1); in rtl8169_rx_fill()
6717 rtl8169_rx_clear(tp); in rtl8169_rx_fill()
6723 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_init_ring() local
6725 rtl8169_init_ring_indexes(tp); in rtl8169_init_ring()
6727 memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info)); in rtl8169_init_ring()
6728 memset(tp->Rx_databuff, 0x0, NUM_RX_DESC * sizeof(void *)); in rtl8169_init_ring()
6730 return rtl8169_rx_fill(tp); in rtl8169_init_ring()
6746 static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start, in rtl8169_tx_clear_range() argument
6753 struct ring_info *tx_skb = tp->tx_skb + entry; in rtl8169_tx_clear_range()
6759 rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb, in rtl8169_tx_clear_range()
6760 tp->TxDescArray + entry); in rtl8169_tx_clear_range()
6762 tp->dev->stats.tx_dropped++; in rtl8169_tx_clear_range()
6770 static void rtl8169_tx_clear(struct rtl8169_private *tp) in rtl8169_tx_clear() argument
6772 rtl8169_tx_clear_range(tp, tp->dirty_tx, NUM_TX_DESC); in rtl8169_tx_clear()
6773 tp->cur_tx = tp->dirty_tx = 0; in rtl8169_tx_clear()
6776 static void rtl_reset_work(struct rtl8169_private *tp) in rtl_reset_work() argument
6778 struct net_device *dev = tp->dev; in rtl_reset_work()
6781 napi_disable(&tp->napi); in rtl_reset_work()
6785 rtl8169_hw_reset(tp); in rtl_reset_work()
6788 rtl8169_mark_to_asic(tp->RxDescArray + i, rx_buf_sz); in rtl_reset_work()
6790 rtl8169_tx_clear(tp); in rtl_reset_work()
6791 rtl8169_init_ring_indexes(tp); in rtl_reset_work()
6793 napi_enable(&tp->napi); in rtl_reset_work()
6796 rtl8169_check_link_status(dev, tp, tp->mmio_addr); in rtl_reset_work()
6801 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_tx_timeout() local
6803 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); in rtl8169_tx_timeout()
6806 static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb, in rtl8169_xmit_frags() argument
6812 struct device *d = &tp->pci_dev->dev; in rtl8169_xmit_frags()
6814 entry = tp->cur_tx; in rtl8169_xmit_frags()
6823 txd = tp->TxDescArray + entry; in rtl8169_xmit_frags()
6829 netif_err(tp, drv, tp->dev, in rtl8169_xmit_frags()
6842 tp->tx_skb[entry].len = len; in rtl8169_xmit_frags()
6846 tp->tx_skb[entry].skb = skb; in rtl8169_xmit_frags()
6853 rtl8169_tx_clear_range(tp, tp->cur_tx + 1, cur_frag); in rtl8169_xmit_frags()
6857 static bool rtl_test_hw_pad_bug(struct rtl8169_private *tp, struct sk_buff *skb) in rtl_test_hw_pad_bug() argument
6859 return skb->len < ETH_ZLEN && tp->mac_version == RTL_GIGA_MAC_VER_34; in rtl_test_hw_pad_bug()
6868 static void r8169_csum_workaround(struct rtl8169_private *tp, in r8169_csum_workaround() argument
6872 netdev_features_t features = tp->dev->features; in r8169_csum_workaround()
6884 rtl8169_start_xmit(nskb, tp->dev); in r8169_csum_workaround()
6892 rtl8169_start_xmit(skb, tp->dev); in r8169_csum_workaround()
6897 stats = &tp->dev->stats; in r8169_csum_workaround()
6938 static bool rtl8169_tso_csum_v1(struct rtl8169_private *tp, in rtl8169_tso_csum_v1() argument
6960 static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp, in rtl8169_tso_csum_v2() argument
6968 netif_warn(tp, tx_err, tp->dev, in rtl8169_tso_csum_v2()
6996 if (unlikely(rtl_test_hw_pad_bug(tp, skb))) in rtl8169_tso_csum_v2()
7000 netif_warn(tp, tx_err, tp->dev, in rtl8169_tso_csum_v2()
7031 if (unlikely(rtl_test_hw_pad_bug(tp, skb))) in rtl8169_tso_csum_v2()
7041 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_start_xmit() local
7042 unsigned int entry = tp->cur_tx % NUM_TX_DESC; in rtl8169_start_xmit()
7043 struct TxDesc *txd = tp->TxDescArray + entry; in rtl8169_start_xmit()
7044 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_start_xmit()
7045 struct device *d = &tp->pci_dev->dev; in rtl8169_start_xmit()
7051 if (unlikely(!TX_FRAGS_READY_FOR(tp, skb_shinfo(skb)->nr_frags))) { in rtl8169_start_xmit()
7052 netif_err(tp, drv, dev, "BUG! Tx Ring full when queue awake!\n"); in rtl8169_start_xmit()
7062 if (!tp->tso_csum(tp, skb, opts)) { in rtl8169_start_xmit()
7063 r8169_csum_workaround(tp, skb); in rtl8169_start_xmit()
7071 netif_err(tp, drv, dev, "Failed to map TX DMA!\n"); in rtl8169_start_xmit()
7075 tp->tx_skb[entry].len = len; in rtl8169_start_xmit()
7078 frags = rtl8169_xmit_frags(tp, skb, opts); in rtl8169_start_xmit()
7085 tp->tx_skb[entry].skb = skb; in rtl8169_start_xmit()
7102 tp->cur_tx += frags + 1; in rtl8169_start_xmit()
7108 if (!TX_FRAGS_READY_FOR(tp, MAX_SKB_FRAGS)) { in rtl8169_start_xmit()
7122 if (TX_FRAGS_READY_FOR(tp, MAX_SKB_FRAGS)) in rtl8169_start_xmit()
7129 rtl8169_unmap_tx_skb(d, tp->tx_skb + entry, txd); in rtl8169_start_xmit()
7143 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_pcierr_interrupt() local
7144 struct pci_dev *pdev = tp->pci_dev; in rtl8169_pcierr_interrupt()
7150 netif_err(tp, intr, dev, "PCI error (cmd = 0x%04x, status = 0x%04x)\n", in rtl8169_pcierr_interrupt()
7174 if ((tp->cp_cmd & PCIDAC) && !tp->cur_rx) { in rtl8169_pcierr_interrupt()
7175 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_pcierr_interrupt()
7177 netif_info(tp, intr, dev, "disabling PCI DAC\n"); in rtl8169_pcierr_interrupt()
7178 tp->cp_cmd &= ~PCIDAC; in rtl8169_pcierr_interrupt()
7179 RTL_W16(CPlusCmd, tp->cp_cmd); in rtl8169_pcierr_interrupt()
7183 rtl8169_hw_reset(tp); in rtl8169_pcierr_interrupt()
7185 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); in rtl8169_pcierr_interrupt()
7188 static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp) in rtl_tx() argument
7192 dirty_tx = tp->dirty_tx; in rtl_tx()
7194 tx_left = tp->cur_tx - dirty_tx; in rtl_tx()
7198 struct ring_info *tx_skb = tp->tx_skb + entry; in rtl_tx()
7201 status = le32_to_cpu(tp->TxDescArray[entry].opts1); in rtl_tx()
7211 rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb, in rtl_tx()
7212 tp->TxDescArray + entry); in rtl_tx()
7214 u64_stats_update_begin(&tp->tx_stats.syncp); in rtl_tx()
7215 tp->tx_stats.packets++; in rtl_tx()
7216 tp->tx_stats.bytes += tx_skb->skb->len; in rtl_tx()
7217 u64_stats_update_end(&tp->tx_stats.syncp); in rtl_tx()
7225 if (tp->dirty_tx != dirty_tx) { in rtl_tx()
7226 tp->dirty_tx = dirty_tx; in rtl_tx()
7236 TX_FRAGS_READY_FOR(tp, MAX_SKB_FRAGS)) { in rtl_tx()
7245 if (tp->cur_tx != dirty_tx) { in rtl_tx()
7246 void __iomem *ioaddr = tp->mmio_addr; in rtl_tx()
7270 struct rtl8169_private *tp, in rtl8169_try_rx_copy() argument
7275 struct device *d = &tp->pci_dev->dev; in rtl8169_try_rx_copy()
7280 skb = napi_alloc_skb(&tp->napi, pkt_size); in rtl8169_try_rx_copy()
7288 static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget) in rtl_rx() argument
7293 cur_rx = tp->cur_rx; in rtl_rx()
7297 struct RxDesc *desc = tp->RxDescArray + entry; in rtl_rx()
7300 status = le32_to_cpu(desc->opts1) & tp->opts1_mask; in rtl_rx()
7311 netif_info(tp, rx_err, dev, "Rx ERROR. status = %08x\n", in rtl_rx()
7319 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); in rtl_rx()
7349 skb = rtl8169_try_rx_copy(tp->Rx_databuff[entry], in rtl_rx()
7350 tp, pkt_size, addr); in rtl_rx()
7362 napi_gro_receive(&tp->napi, skb); in rtl_rx()
7364 u64_stats_update_begin(&tp->rx_stats.syncp); in rtl_rx()
7365 tp->rx_stats.packets++; in rtl_rx()
7366 tp->rx_stats.bytes += pkt_size; in rtl_rx()
7367 u64_stats_update_end(&tp->rx_stats.syncp); in rtl_rx()
7374 count = cur_rx - tp->cur_rx; in rtl_rx()
7375 tp->cur_rx = cur_rx; in rtl_rx()
7383 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_interrupt() local
7387 status = rtl_get_events(tp); in rtl8169_interrupt()
7389 status &= RTL_EVENT_NAPI | tp->event_slow; in rtl8169_interrupt()
7393 rtl_irq_disable(tp); in rtl8169_interrupt()
7394 napi_schedule(&tp->napi); in rtl8169_interrupt()
7403 static void rtl_slow_event_work(struct rtl8169_private *tp) in rtl_slow_event_work() argument
7405 struct net_device *dev = tp->dev; in rtl_slow_event_work()
7408 status = rtl_get_events(tp) & tp->event_slow; in rtl_slow_event_work()
7409 rtl_ack_events(tp, status); in rtl_slow_event_work()
7412 switch (tp->mac_version) { in rtl_slow_event_work()
7417 set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags); in rtl_slow_event_work()
7427 __rtl8169_check_link_status(dev, tp, tp->mmio_addr, true); in rtl_slow_event_work()
7429 rtl_irq_enable_all(tp); in rtl_slow_event_work()
7443 struct rtl8169_private *tp = in rtl_task() local
7445 struct net_device *dev = tp->dev; in rtl_task()
7448 rtl_lock_work(tp); in rtl_task()
7451 !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags)) in rtl_task()
7457 pending = test_and_clear_bit(rtl_work[i].bitnr, tp->wk.flags); in rtl_task()
7459 rtl_work[i].action(tp); in rtl_task()
7463 rtl_unlock_work(tp); in rtl_task()
7468 struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi); in rtl8169_poll() local
7469 struct net_device *dev = tp->dev; in rtl8169_poll()
7470 u16 enable_mask = RTL_EVENT_NAPI | tp->event_slow; in rtl8169_poll()
7474 status = rtl_get_events(tp); in rtl8169_poll()
7475 rtl_ack_events(tp, status & ~tp->event_slow); in rtl8169_poll()
7478 work_done = rtl_rx(dev, tp, (u32) budget); in rtl8169_poll()
7481 rtl_tx(dev, tp); in rtl8169_poll()
7483 if (status & tp->event_slow) { in rtl8169_poll()
7484 enable_mask &= ~tp->event_slow; in rtl8169_poll()
7486 rtl_schedule_task(tp, RTL_FLAG_TASK_SLOW_PENDING); in rtl8169_poll()
7492 rtl_irq_enable(tp, enable_mask); in rtl8169_poll()
7501 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_rx_missed() local
7503 if (tp->mac_version > RTL_GIGA_MAC_VER_06) in rtl8169_rx_missed()
7512 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_down() local
7513 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_down()
7515 del_timer_sync(&tp->timer); in rtl8169_down()
7517 napi_disable(&tp->napi); in rtl8169_down()
7520 rtl8169_hw_reset(tp); in rtl8169_down()
7531 rtl8169_tx_clear(tp); in rtl8169_down()
7533 rtl8169_rx_clear(tp); in rtl8169_down()
7535 rtl_pll_power_down(tp); in rtl8169_down()
7540 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_close() local
7541 struct pci_dev *pdev = tp->pci_dev; in rtl8169_close()
7548 rtl_lock_work(tp); in rtl8169_close()
7549 clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); in rtl8169_close()
7552 rtl_unlock_work(tp); in rtl8169_close()
7554 cancel_work_sync(&tp->wk.work); in rtl8169_close()
7558 dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, in rtl8169_close()
7559 tp->RxPhyAddr); in rtl8169_close()
7560 dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray, in rtl8169_close()
7561 tp->TxPhyAddr); in rtl8169_close()
7562 tp->TxDescArray = NULL; in rtl8169_close()
7563 tp->RxDescArray = NULL; in rtl8169_close()
7573 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_netpoll() local
7575 rtl8169_interrupt(tp->pci_dev->irq, dev); in rtl8169_netpoll()
7581 struct rtl8169_private *tp = netdev_priv(dev); in rtl_open() local
7582 void __iomem *ioaddr = tp->mmio_addr; in rtl_open()
7583 struct pci_dev *pdev = tp->pci_dev; in rtl_open()
7592 tp->TxDescArray = dma_alloc_coherent(&pdev->dev, R8169_TX_RING_BYTES, in rtl_open()
7593 &tp->TxPhyAddr, GFP_KERNEL); in rtl_open()
7594 if (!tp->TxDescArray) in rtl_open()
7597 tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8169_RX_RING_BYTES, in rtl_open()
7598 &tp->RxPhyAddr, GFP_KERNEL); in rtl_open()
7599 if (!tp->RxDescArray) in rtl_open()
7606 INIT_WORK(&tp->wk.work, rtl_task); in rtl_open()
7610 rtl_request_firmware(tp); in rtl_open()
7613 (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, in rtl_open()
7618 rtl_lock_work(tp); in rtl_open()
7620 set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); in rtl_open()
7622 napi_enable(&tp->napi); in rtl_open()
7624 rtl8169_init_phy(dev, tp); in rtl_open()
7628 rtl_pll_power_up(tp); in rtl_open()
7634 rtl_unlock_work(tp); in rtl_open()
7636 tp->saved_wolopts = 0; in rtl_open()
7639 rtl8169_check_link_status(dev, tp, ioaddr); in rtl_open()
7644 rtl_release_firmware(tp); in rtl_open()
7645 rtl8169_rx_clear(tp); in rtl_open()
7647 dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, in rtl_open()
7648 tp->RxPhyAddr); in rtl_open()
7649 tp->RxDescArray = NULL; in rtl_open()
7651 dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray, in rtl_open()
7652 tp->TxPhyAddr); in rtl_open()
7653 tp->TxDescArray = NULL; in rtl_open()
7662 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_get_stats64() local
7663 void __iomem *ioaddr = tp->mmio_addr; in rtl8169_get_stats64()
7670 start = u64_stats_fetch_begin_irq(&tp->rx_stats.syncp); in rtl8169_get_stats64()
7671 stats->rx_packets = tp->rx_stats.packets; in rtl8169_get_stats64()
7672 stats->rx_bytes = tp->rx_stats.bytes; in rtl8169_get_stats64()
7673 } while (u64_stats_fetch_retry_irq(&tp->rx_stats.syncp, start)); in rtl8169_get_stats64()
7677 start = u64_stats_fetch_begin_irq(&tp->tx_stats.syncp); in rtl8169_get_stats64()
7678 stats->tx_packets = tp->tx_stats.packets; in rtl8169_get_stats64()
7679 stats->tx_bytes = tp->tx_stats.bytes; in rtl8169_get_stats64()
7680 } while (u64_stats_fetch_retry_irq(&tp->tx_stats.syncp, start)); in rtl8169_get_stats64()
7695 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_net_suspend() local
7703 rtl_lock_work(tp); in rtl8169_net_suspend()
7704 napi_disable(&tp->napi); in rtl8169_net_suspend()
7705 clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); in rtl8169_net_suspend()
7706 rtl_unlock_work(tp); in rtl8169_net_suspend()
7708 rtl_pll_power_down(tp); in rtl8169_net_suspend()
7725 struct rtl8169_private *tp = netdev_priv(dev); in __rtl8169_resume() local
7729 rtl_pll_power_up(tp); in __rtl8169_resume()
7731 rtl_lock_work(tp); in __rtl8169_resume()
7732 napi_enable(&tp->napi); in __rtl8169_resume()
7733 set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); in __rtl8169_resume()
7734 rtl_unlock_work(tp); in __rtl8169_resume()
7736 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); in __rtl8169_resume()
7743 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_resume() local
7745 rtl8169_init_phy(dev, tp); in rtl8169_resume()
7757 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_runtime_suspend() local
7759 if (!tp->TxDescArray) in rtl8169_runtime_suspend()
7762 rtl_lock_work(tp); in rtl8169_runtime_suspend()
7763 tp->saved_wolopts = __rtl8169_get_wol(tp); in rtl8169_runtime_suspend()
7764 __rtl8169_set_wol(tp, WAKE_ANY); in rtl8169_runtime_suspend()
7765 rtl_unlock_work(tp); in rtl8169_runtime_suspend()
7776 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_runtime_resume() local
7778 if (!tp->TxDescArray) in rtl8169_runtime_resume()
7781 rtl_lock_work(tp); in rtl8169_runtime_resume()
7782 __rtl8169_set_wol(tp, tp->saved_wolopts); in rtl8169_runtime_resume()
7783 tp->saved_wolopts = 0; in rtl8169_runtime_resume()
7784 rtl_unlock_work(tp); in rtl8169_runtime_resume()
7786 rtl8169_init_phy(dev, tp); in rtl8169_runtime_resume()
7797 struct rtl8169_private *tp = netdev_priv(dev); in rtl8169_runtime_idle() local
7799 return tp->TxDescArray ? -EBUSY : 0; in rtl8169_runtime_idle()
7822 static void rtl_wol_shutdown_quirk(struct rtl8169_private *tp) in rtl_wol_shutdown_quirk() argument
7824 void __iomem *ioaddr = tp->mmio_addr; in rtl_wol_shutdown_quirk()
7827 switch (tp->mac_version) { in rtl_wol_shutdown_quirk()
7831 pci_clear_master(tp->pci_dev); in rtl_wol_shutdown_quirk()
7845 struct rtl8169_private *tp = netdev_priv(dev); in rtl_shutdown() local
7853 rtl_rar_set(tp, dev->perm_addr); in rtl_shutdown()
7855 rtl8169_hw_reset(tp); in rtl_shutdown()
7858 if (__rtl8169_get_wol(tp) & WAKE_ANY) { in rtl_shutdown()
7859 rtl_wol_suspend_quirk(tp); in rtl_shutdown()
7860 rtl_wol_shutdown_quirk(tp); in rtl_shutdown()
7873 struct rtl8169_private *tp = netdev_priv(dev); in rtl_remove_one() local
7875 if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || in rtl_remove_one()
7876 tp->mac_version == RTL_GIGA_MAC_VER_28 || in rtl_remove_one()
7877 tp->mac_version == RTL_GIGA_MAC_VER_31 || in rtl_remove_one()
7878 tp->mac_version == RTL_GIGA_MAC_VER_49 || in rtl_remove_one()
7879 tp->mac_version == RTL_GIGA_MAC_VER_50 || in rtl_remove_one()
7880 tp->mac_version == RTL_GIGA_MAC_VER_51) && in rtl_remove_one()
7881 r8168_check_dash(tp)) { in rtl_remove_one()
7882 rtl8168_driver_stop(tp); in rtl_remove_one()
7885 netif_napi_del(&tp->napi); in rtl_remove_one()
7889 rtl_release_firmware(tp); in rtl_remove_one()
7895 rtl_rar_set(tp, dev->perm_addr); in rtl_remove_one()
7897 rtl_disable_msi(pdev, tp); in rtl_remove_one()
7898 rtl8169_release_board(pdev, dev, tp->mmio_addr); in rtl_remove_one()
7956 static unsigned rtl_try_msi(struct rtl8169_private *tp, in rtl_try_msi() argument
7959 void __iomem *ioaddr = tp->mmio_addr; in rtl_try_msi()
7965 if (pci_enable_msi(tp->pci_dev)) { in rtl_try_msi()
7966 netif_info(tp, hw, tp->dev, "no MSI. Back to INTx.\n"); in rtl_try_msi()
7972 if (tp->mac_version <= RTL_GIGA_MAC_VER_06) in rtl_try_msi()
7979 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
7986 void __iomem *ioaddr = tp->mmio_addr; in DECLARE_RTL_COND()
7991 static void rtl_hw_init_8168g(struct rtl8169_private *tp) in rtl_hw_init_8168g() argument
7993 void __iomem *ioaddr = tp->mmio_addr; in rtl_hw_init_8168g()
7996 tp->ocp_base = OCP_STD_PHY_BASE; in rtl_hw_init_8168g()
8000 if (!rtl_udelay_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 42)) in rtl_hw_init_8168g()
8003 if (!rtl_udelay_loop_wait_high(tp, &rtl_rxtx_empty_cond, 100, 42)) in rtl_hw_init_8168g()
8010 data = r8168_mac_ocp_read(tp, 0xe8de); in rtl_hw_init_8168g()
8012 r8168_mac_ocp_write(tp, 0xe8de, data); in rtl_hw_init_8168g()
8014 if (!rtl_udelay_loop_wait_high(tp, &rtl_link_list_ready_cond, 100, 42)) in rtl_hw_init_8168g()
8017 data = r8168_mac_ocp_read(tp, 0xe8de); in rtl_hw_init_8168g()
8019 r8168_mac_ocp_write(tp, 0xe8de, data); in rtl_hw_init_8168g()
8021 if (!rtl_udelay_loop_wait_high(tp, &rtl_link_list_ready_cond, 100, 42)) in rtl_hw_init_8168g()
8025 static void rtl_hw_init_8168ep(struct rtl8169_private *tp) in rtl_hw_init_8168ep() argument
8027 rtl8168ep_stop_cmac(tp); in rtl_hw_init_8168ep()
8028 rtl_hw_init_8168g(tp); in rtl_hw_init_8168ep()
8031 static void rtl_hw_initialize(struct rtl8169_private *tp) in rtl_hw_initialize() argument
8033 switch (tp->mac_version) { in rtl_hw_initialize()
8043 rtl_hw_init_8168g(tp); in rtl_hw_initialize()
8048 rtl_hw_init_8168ep(tp); in rtl_hw_initialize()
8059 struct rtl8169_private *tp; in rtl_init_one() local
8071 dev = alloc_etherdev(sizeof (*tp)); in rtl_init_one()
8079 tp = netdev_priv(dev); in rtl_init_one()
8080 tp->dev = dev; in rtl_init_one()
8081 tp->pci_dev = pdev; in rtl_init_one()
8082 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT); in rtl_init_one()
8084 mii = &tp->mii; in rtl_init_one()
8100 netif_err(tp, probe, dev, "enable failure\n"); in rtl_init_one()
8105 netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n"); in rtl_init_one()
8109 netif_err(tp, probe, dev, in rtl_init_one()
8118 netif_err(tp, probe, dev, in rtl_init_one()
8126 netif_err(tp, probe, dev, "could not request regions\n"); in rtl_init_one()
8130 tp->cp_cmd = 0; in rtl_init_one()
8134 tp->cp_cmd |= PCIDAC; in rtl_init_one()
8139 netif_err(tp, probe, dev, "DMA configuration failed\n"); in rtl_init_one()
8147 netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); in rtl_init_one()
8151 tp->mmio_addr = ioaddr; in rtl_init_one()
8154 netif_info(tp, probe, dev, "not PCI Express\n"); in rtl_init_one()
8157 rtl8169_get_mac_version(tp, dev, cfg->default_ver); in rtl_init_one()
8159 rtl_init_rxcfg(tp); in rtl_init_one()
8161 rtl_irq_disable(tp); in rtl_init_one()
8163 rtl_hw_initialize(tp); in rtl_init_one()
8165 rtl_hw_reset(tp); in rtl_init_one()
8167 rtl_ack_events(tp, 0xffff); in rtl_init_one()
8171 rtl_init_mdio_ops(tp); in rtl_init_one()
8172 rtl_init_pll_power_ops(tp); in rtl_init_one()
8173 rtl_init_jumbo_ops(tp); in rtl_init_one()
8174 rtl_init_csi_ops(tp); in rtl_init_one()
8176 rtl8169_print_mac_version(tp); in rtl_init_one()
8178 chipset = tp->mac_version; in rtl_init_one()
8179 tp->txd_version = rtl_chip_infos[chipset].txd_version; in rtl_init_one()
8184 switch (tp->mac_version) { in rtl_init_one()
8202 if (rtl_eri_read(tp, 0xdc, ERIAR_EXGMAC) & MagicPacket_v2) in rtl_init_one()
8203 tp->features |= RTL_FEATURE_WOL; in rtl_init_one()
8205 tp->features |= RTL_FEATURE_WOL; in rtl_init_one()
8209 tp->features |= RTL_FEATURE_WOL; in rtl_init_one()
8213 tp->features |= RTL_FEATURE_WOL; in rtl_init_one()
8214 tp->features |= rtl_try_msi(tp, cfg); in rtl_init_one()
8217 if (rtl_tbi_enabled(tp)) { in rtl_init_one()
8218 tp->set_speed = rtl8169_set_speed_tbi; in rtl_init_one()
8219 tp->get_settings = rtl8169_gset_tbi; in rtl_init_one()
8220 tp->phy_reset_enable = rtl8169_tbi_reset_enable; in rtl_init_one()
8221 tp->phy_reset_pending = rtl8169_tbi_reset_pending; in rtl_init_one()
8222 tp->link_ok = rtl8169_tbi_link_ok; in rtl_init_one()
8223 tp->do_ioctl = rtl_tbi_ioctl; in rtl_init_one()
8225 tp->set_speed = rtl8169_set_speed_xmii; in rtl_init_one()
8226 tp->get_settings = rtl8169_gset_xmii; in rtl_init_one()
8227 tp->phy_reset_enable = rtl8169_xmii_reset_enable; in rtl_init_one()
8228 tp->phy_reset_pending = rtl8169_xmii_reset_pending; in rtl_init_one()
8229 tp->link_ok = rtl8169_xmii_link_ok; in rtl_init_one()
8230 tp->do_ioctl = rtl_xmii_ioctl; in rtl_init_one()
8233 mutex_init(&tp->wk.mutex); in rtl_init_one()
8234 u64_stats_init(&tp->rx_stats.syncp); in rtl_init_one()
8235 u64_stats_init(&tp->tx_stats.syncp); in rtl_init_one()
8238 if (tp->mac_version == RTL_GIGA_MAC_VER_35 || in rtl_init_one()
8239 tp->mac_version == RTL_GIGA_MAC_VER_36 || in rtl_init_one()
8240 tp->mac_version == RTL_GIGA_MAC_VER_37 || in rtl_init_one()
8241 tp->mac_version == RTL_GIGA_MAC_VER_38 || in rtl_init_one()
8242 tp->mac_version == RTL_GIGA_MAC_VER_40 || in rtl_init_one()
8243 tp->mac_version == RTL_GIGA_MAC_VER_41 || in rtl_init_one()
8244 tp->mac_version == RTL_GIGA_MAC_VER_42 || in rtl_init_one()
8245 tp->mac_version == RTL_GIGA_MAC_VER_43 || in rtl_init_one()
8246 tp->mac_version == RTL_GIGA_MAC_VER_44 || in rtl_init_one()
8247 tp->mac_version == RTL_GIGA_MAC_VER_45 || in rtl_init_one()
8248 tp->mac_version == RTL_GIGA_MAC_VER_46 || in rtl_init_one()
8249 tp->mac_version == RTL_GIGA_MAC_VER_47 || in rtl_init_one()
8250 tp->mac_version == RTL_GIGA_MAC_VER_48 || in rtl_init_one()
8251 tp->mac_version == RTL_GIGA_MAC_VER_49 || in rtl_init_one()
8252 tp->mac_version == RTL_GIGA_MAC_VER_50 || in rtl_init_one()
8253 tp->mac_version == RTL_GIGA_MAC_VER_51) { in rtl_init_one()
8256 *(u32 *)&mac_addr[0] = rtl_eri_read(tp, 0xe0, ERIAR_EXGMAC); in rtl_init_one()
8257 *(u16 *)&mac_addr[2] = rtl_eri_read(tp, 0xe4, ERIAR_EXGMAC); in rtl_init_one()
8260 rtl_rar_set(tp, (u8 *)mac_addr); in rtl_init_one()
8268 netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); in rtl_init_one()
8281 tp->cp_cmd |= RxChkSum | RxVlan; in rtl_init_one()
8287 if (tp->mac_version == RTL_GIGA_MAC_VER_05) in rtl_init_one()
8291 if (tp->txd_version == RTL_TD_0) in rtl_init_one()
8292 tp->tso_csum = rtl8169_tso_csum_v1; in rtl_init_one()
8293 else if (tp->txd_version == RTL_TD_1) { in rtl_init_one()
8294 tp->tso_csum = rtl8169_tso_csum_v2; in rtl_init_one()
8302 tp->hw_start = cfg->hw_start; in rtl_init_one()
8303 tp->event_slow = cfg->event_slow; in rtl_init_one()
8305 tp->opts1_mask = (tp->mac_version != RTL_GIGA_MAC_VER_01) ? in rtl_init_one()
8308 init_timer(&tp->timer); in rtl_init_one()
8309 tp->timer.data = (unsigned long) dev; in rtl_init_one()
8310 tp->timer.function = rtl8169_phy_timer; in rtl_init_one()
8312 tp->rtl_fw = RTL_FIRMWARE_UNKNOWN; in rtl_init_one()
8320 netif_info(tp, probe, dev, "%s at 0x%p, %pM, XID %08x IRQ %d\n", in rtl_init_one()
8324 netif_info(tp, probe, dev, "jumbo features [frames: %d bytes, " in rtl_init_one()
8330 if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || in rtl_init_one()
8331 tp->mac_version == RTL_GIGA_MAC_VER_28 || in rtl_init_one()
8332 tp->mac_version == RTL_GIGA_MAC_VER_31 || in rtl_init_one()
8333 tp->mac_version == RTL_GIGA_MAC_VER_49 || in rtl_init_one()
8334 tp->mac_version == RTL_GIGA_MAC_VER_50 || in rtl_init_one()
8335 tp->mac_version == RTL_GIGA_MAC_VER_51) && in rtl_init_one()
8336 r8168_check_dash(tp)) { in rtl_init_one()
8337 rtl8168_driver_start(tp); in rtl_init_one()
8340 device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL); in rtl_init_one()
8351 netif_napi_del(&tp->napi); in rtl_init_one()
8352 rtl_disable_msi(pdev, tp); in rtl_init_one()