aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/realtek/r8169.c
diff options
context:
space:
mode:
authorChun-Hao Lin <hau@realtek.com>2014-10-01 11:17:20 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-01 15:33:18 -0400
commit2a9b4d9670e71784896d95c41c9b0acd50db1dbb (patch)
tree5473cc4ebc9ef683486006989d68871bb8ff94e7 /drivers/net/ethernet/realtek/r8169.c
parent2f8c040ce6791ef0477e6d59768ee3d5fd0df0fd (diff)
r8169:modify the behavior of function "rtl8168_oob_notify"
In function "rtl8168_oob_notify", using function "rtl_eri_write" to access eri register 0xe8, instead of using MAC register "ERIDR" and "ERIAR" to access it. For using function "rtl_eri_write" in function "rtl8168_oob_notify", need to move down "rtl8168_oob_notify" related functions under the function "rtl_eri_write". Signed-off-by: Chun-Hao Lin <hau@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/realtek/r8169.c')
-rw-r--r--drivers/net/ethernet/realtek/r8169.c99
1 files changed, 46 insertions, 53 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index d84605a3c2e3..305f3b48d36f 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -969,59 +969,6 @@ DECLARE_RTL_COND(rtl_eriar_cond)
969 return RTL_R32(ERIAR) & ERIAR_FLAG; 969 return RTL_R32(ERIAR) & ERIAR_FLAG;
970} 970}
971 971
972static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd)
973{
974 void __iomem *ioaddr = tp->mmio_addr;
975
976 RTL_W8(ERIDR, cmd);
977 RTL_W32(ERIAR, 0x800010e8);
978 msleep(2);
979
980 if (!rtl_udelay_loop_wait_low(tp, &rtl_eriar_cond, 100, 5))
981 return;
982
983 ocp_write(tp, 0x1, 0x30, 0x00000001);
984}
985
986#define OOB_CMD_RESET 0x00
987#define OOB_CMD_DRIVER_START 0x05
988#define OOB_CMD_DRIVER_STOP 0x06
989
990static u16 rtl8168_get_ocp_reg(struct rtl8169_private *tp)
991{
992 return (tp->mac_version == RTL_GIGA_MAC_VER_31) ? 0xb8 : 0x10;
993}
994
995DECLARE_RTL_COND(rtl_ocp_read_cond)
996{
997 u16 reg;
998
999 reg = rtl8168_get_ocp_reg(tp);
1000
1001 return ocp_read(tp, 0x0f, reg) & 0x00000800;
1002}
1003
1004static void rtl8168_driver_start(struct rtl8169_private *tp)
1005{
1006 rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START);
1007
1008 rtl_msleep_loop_wait_high(tp, &rtl_ocp_read_cond, 10, 10);
1009}
1010
1011static void rtl8168_driver_stop(struct rtl8169_private *tp)
1012{
1013 rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP);
1014
1015 rtl_msleep_loop_wait_low(tp, &rtl_ocp_read_cond, 10, 10);
1016}
1017
1018static int r8168_check_dash(struct rtl8169_private *tp)
1019{
1020 u16 reg = rtl8168_get_ocp_reg(tp);
1021
1022 return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0;
1023}
1024
1025static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg) 972static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg)
1026{ 973{
1027 if (reg & 0xffff0001) { 974 if (reg & 0xffff0001) {
@@ -1329,6 +1276,52 @@ static void rtl_w0w1_eri(struct rtl8169_private *tp, int addr, u32 mask, u32 p,
1329 rtl_eri_write(tp, addr, mask, (val & ~m) | p, type); 1276 rtl_eri_write(tp, addr, mask, (val & ~m) | p, type);
1330} 1277}
1331 1278
1279static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd)
1280{
1281 rtl_eri_write(tp, 0xe8, ERIAR_MASK_0001, cmd, ERIAR_EXGMAC);
1282
1283 ocp_write(tp, 0x1, 0x30, 0x00000001);
1284}
1285
1286#define OOB_CMD_RESET 0x00
1287#define OOB_CMD_DRIVER_START 0x05
1288#define OOB_CMD_DRIVER_STOP 0x06
1289
1290static u16 rtl8168_get_ocp_reg(struct rtl8169_private *tp)
1291{
1292 return (tp->mac_version == RTL_GIGA_MAC_VER_31) ? 0xb8 : 0x10;
1293}
1294
1295DECLARE_RTL_COND(rtl_ocp_read_cond)
1296{
1297 u16 reg;
1298
1299 reg = rtl8168_get_ocp_reg(tp);
1300
1301 return ocp_read(tp, 0x0f, reg) & 0x00000800;
1302}
1303
1304static void rtl8168_driver_start(struct rtl8169_private *tp)
1305{
1306 rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START);
1307
1308 rtl_msleep_loop_wait_high(tp, &rtl_ocp_read_cond, 10, 10);
1309}
1310
1311static void rtl8168_driver_stop(struct rtl8169_private *tp)
1312{
1313 rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP);
1314
1315 rtl_msleep_loop_wait_low(tp, &rtl_ocp_read_cond, 10, 10);
1316}
1317
1318static int r8168_check_dash(struct rtl8169_private *tp)
1319{
1320 u16 reg = rtl8168_get_ocp_reg(tp);
1321
1322 return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0;
1323}
1324
1332struct exgmac_reg { 1325struct exgmac_reg {
1333 u16 addr; 1326 u16 addr;
1334 u16 mask; 1327 u16 mask;