aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/r8169.c
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2007-08-17 11:50:46 -0400
committerFrancois Romieu <romieu@fr.zoreil.com>2007-10-18 15:25:46 -0400
commit5615d9f1b9f5221d5b69dfa3722c16918c896cdd (patch)
treee1313642f0b6041f45aaf2f2eab4a62e2151aec3 /drivers/net/r8169.c
parente179bb7b437f4bd726e9ea9b08aff2fa4a530c1a (diff)
r8169: make room for more phy init changes
The code is reworked to easily add phy-dependant init changes. No change of behavior should be noticed. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Cc: Edward Hsu <edward_hsu@realtek.com.tw>
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r--drivers/net/r8169.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 3a3ba79da43e..aed36b7e38b3 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1168,10 +1168,8 @@ static void rtl8169_print_mac_version(struct rtl8169_private *tp)
1168 dprintk("mac_version = 0x%02x\n", tp->mac_version); 1168 dprintk("mac_version = 0x%02x\n", tp->mac_version);
1169} 1169}
1170 1170
1171static void rtl8169_hw_phy_config(struct net_device *dev) 1171static void rtl8169s_hw_phy_config(void __iomem *ioaddr)
1172{ 1172{
1173 struct rtl8169_private *tp = netdev_priv(dev);
1174 void __iomem *ioaddr = tp->mmio_addr;
1175 struct { 1173 struct {
1176 u16 regs[5]; /* Beware of bit-sign propagation */ 1174 u16 regs[5]; /* Beware of bit-sign propagation */
1177 } phy_magic[5] = { { 1175 } phy_magic[5] = { {
@@ -1204,27 +1202,6 @@ static void rtl8169_hw_phy_config(struct net_device *dev)
1204 }, *p = phy_magic; 1202 }, *p = phy_magic;
1205 unsigned int i; 1203 unsigned int i;
1206 1204
1207 rtl8169_print_mac_version(tp);
1208
1209 if (tp->mac_version <= RTL_GIGA_MAC_VER_01)
1210 return;
1211
1212 dprintk("MAC version != 0 && PHY version == 0 or 1\n");
1213 dprintk("Do final_reg2.cfg\n");
1214
1215 /* Shazam ! */
1216
1217 if (tp->mac_version == RTL_GIGA_MAC_VER_04) {
1218 mdio_write(ioaddr, 31, 0x0002);
1219 mdio_write(ioaddr, 1, 0x90d0);
1220 mdio_write(ioaddr, 31, 0x0000);
1221 return;
1222 }
1223
1224 if ((tp->mac_version != RTL_GIGA_MAC_VER_02) &&
1225 (tp->mac_version != RTL_GIGA_MAC_VER_03))
1226 return;
1227
1228 mdio_write(ioaddr, 31, 0x0001); //w 31 2 0 1 1205 mdio_write(ioaddr, 31, 0x0001); //w 31 2 0 1
1229 mdio_write(ioaddr, 21, 0x1000); //w 21 15 0 1000 1206 mdio_write(ioaddr, 21, 0x1000); //w 21 15 0 1000
1230 mdio_write(ioaddr, 24, 0x65c7); //w 24 15 0 65c7 1207 mdio_write(ioaddr, 24, 0x65c7); //w 24 15 0 65c7
@@ -1243,6 +1220,35 @@ static void rtl8169_hw_phy_config(struct net_device *dev)
1243 mdio_write(ioaddr, 31, 0x0000); //w 31 2 0 0 1220 mdio_write(ioaddr, 31, 0x0000); //w 31 2 0 0
1244} 1221}
1245 1222
1223static void rtl8169sb_hw_phy_config(void __iomem *ioaddr)
1224{
1225 mdio_write(ioaddr, 31, 0x0002);
1226 mdio_write(ioaddr, 1, 0x90d0);
1227 mdio_write(ioaddr, 31, 0x0000);
1228}
1229
1230static void rtl_hw_phy_config(struct net_device *dev)
1231{
1232 struct rtl8169_private *tp = netdev_priv(dev);
1233 void __iomem *ioaddr = tp->mmio_addr;
1234
1235 rtl8169_print_mac_version(tp);
1236
1237 switch (tp->mac_version) {
1238 case RTL_GIGA_MAC_VER_01:
1239 break;
1240 case RTL_GIGA_MAC_VER_02:
1241 case RTL_GIGA_MAC_VER_03:
1242 rtl8169s_hw_phy_config(ioaddr);
1243 break;
1244 case RTL_GIGA_MAC_VER_04:
1245 rtl8169sb_hw_phy_config(ioaddr);
1246 break;
1247 default:
1248 break;
1249 }
1250}
1251
1246static void rtl8169_phy_timer(unsigned long __opaque) 1252static void rtl8169_phy_timer(unsigned long __opaque)
1247{ 1253{
1248 struct net_device *dev = (struct net_device *)__opaque; 1254 struct net_device *dev = (struct net_device *)__opaque;
@@ -1349,7 +1355,7 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
1349{ 1355{
1350 void __iomem *ioaddr = tp->mmio_addr; 1356 void __iomem *ioaddr = tp->mmio_addr;
1351 1357
1352 rtl8169_hw_phy_config(dev); 1358 rtl_hw_phy_config(dev);
1353 1359
1354 dprintk("Set MAC Reg C+CR Offset 0x82h = 0x01h\n"); 1360 dprintk("Set MAC Reg C+CR Offset 0x82h = 0x01h\n");
1355 RTL_W8(0x82, 0x01); 1361 RTL_W8(0x82, 0x01);