diff options
author | françois romieu <romieu@fr.zoreil.com> | 2009-08-10 15:44:56 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-13 01:13:23 -0400 |
commit | 0b9b571d246d1c2621a5e4e5a0fa5cb95e18365d (patch) | |
tree | 73073a847922245263eabb4a3c338ec5a46d7f1d /drivers | |
parent | 2e955856ff1212bd63dbbf403940c72eca5b4a8f (diff) |
r8169: phy init for the 8169s
Synced with Realtek's 6.011.00 r8169 driver.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Edward Hsu <edward_hsu@realtek.com.tw>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/r8169.c | 116 |
1 files changed, 60 insertions, 56 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 4470fefbe97e..93a87aa7a0e4 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -1222,17 +1222,6 @@ static const struct ethtool_ops rtl8169_ethtool_ops = { | |||
1222 | .get_ethtool_stats = rtl8169_get_ethtool_stats, | 1222 | .get_ethtool_stats = rtl8169_get_ethtool_stats, |
1223 | }; | 1223 | }; |
1224 | 1224 | ||
1225 | static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg, | ||
1226 | int bitnum, int bitval) | ||
1227 | { | ||
1228 | int val; | ||
1229 | |||
1230 | val = mdio_read(ioaddr, reg); | ||
1231 | val = (bitval == 1) ? | ||
1232 | val | (bitval << bitnum) : val & ~(0x0001 << bitnum); | ||
1233 | mdio_write(ioaddr, reg, val & 0xffff); | ||
1234 | } | ||
1235 | |||
1236 | static void rtl8169_get_mac_version(struct rtl8169_private *tp, | 1225 | static void rtl8169_get_mac_version(struct rtl8169_private *tp, |
1237 | void __iomem *ioaddr) | 1226 | void __iomem *ioaddr) |
1238 | { | 1227 | { |
@@ -1328,54 +1317,69 @@ static void rtl_phy_write(void __iomem *ioaddr, struct phy_reg *regs, int len) | |||
1328 | 1317 | ||
1329 | static void rtl8169s_hw_phy_config(void __iomem *ioaddr) | 1318 | static void rtl8169s_hw_phy_config(void __iomem *ioaddr) |
1330 | { | 1319 | { |
1331 | struct { | 1320 | struct phy_reg phy_reg_init[] = { |
1332 | u16 regs[5]; /* Beware of bit-sign propagation */ | 1321 | { 0x1f, 0x0001 }, |
1333 | } phy_magic[5] = { { | 1322 | { 0x06, 0x006e }, |
1334 | { 0x0000, //w 4 15 12 0 | 1323 | { 0x08, 0x0708 }, |
1335 | 0x00a1, //w 3 15 0 00a1 | 1324 | { 0x15, 0x4000 }, |
1336 | 0x0008, //w 2 15 0 0008 | 1325 | { 0x18, 0x65c7 }, |
1337 | 0x1020, //w 1 15 0 1020 | ||
1338 | 0x1000 } },{ //w 0 15 0 1000 | ||
1339 | { 0x7000, //w 4 15 12 7 | ||
1340 | 0xff41, //w 3 15 0 ff41 | ||
1341 | 0xde60, //w 2 15 0 de60 | ||
1342 | 0x0140, //w 1 15 0 0140 | ||
1343 | 0x0077 } },{ //w 0 15 0 0077 | ||
1344 | { 0xa000, //w 4 15 12 a | ||
1345 | 0xdf01, //w 3 15 0 df01 | ||
1346 | 0xdf20, //w 2 15 0 df20 | ||
1347 | 0xff95, //w 1 15 0 ff95 | ||
1348 | 0xfa00 } },{ //w 0 15 0 fa00 | ||
1349 | { 0xb000, //w 4 15 12 b | ||
1350 | 0xff41, //w 3 15 0 ff41 | ||
1351 | 0xde20, //w 2 15 0 de20 | ||
1352 | 0x0140, //w 1 15 0 0140 | ||
1353 | 0x00bb } },{ //w 0 15 0 00bb | ||
1354 | { 0xf000, //w 4 15 12 f | ||
1355 | 0xdf01, //w 3 15 0 df01 | ||
1356 | 0xdf20, //w 2 15 0 df20 | ||
1357 | 0xff95, //w 1 15 0 ff95 | ||
1358 | 0xbf00 } //w 0 15 0 bf00 | ||
1359 | } | ||
1360 | }, *p = phy_magic; | ||
1361 | unsigned int i; | ||
1362 | 1326 | ||
1363 | mdio_write(ioaddr, 0x1f, 0x0001); //w 31 2 0 1 | 1327 | { 0x1f, 0x0001 }, |
1364 | mdio_write(ioaddr, 0x15, 0x1000); //w 21 15 0 1000 | 1328 | { 0x03, 0x00a1 }, |
1365 | mdio_write(ioaddr, 0x18, 0x65c7); //w 24 15 0 65c7 | 1329 | { 0x02, 0x0008 }, |
1366 | rtl8169_write_gmii_reg_bit(ioaddr, 4, 11, 0); //w 4 11 11 0 | 1330 | { 0x01, 0x0120 }, |
1331 | { 0x00, 0x1000 }, | ||
1332 | { 0x04, 0x0800 }, | ||
1333 | { 0x04, 0x0000 }, | ||
1367 | 1334 | ||
1368 | for (i = 0; i < ARRAY_SIZE(phy_magic); i++, p++) { | 1335 | { 0x03, 0xff41 }, |
1369 | int val, pos = 4; | 1336 | { 0x02, 0xdf60 }, |
1337 | { 0x01, 0x0140 }, | ||
1338 | { 0x00, 0x0077 }, | ||
1339 | { 0x04, 0x7800 }, | ||
1340 | { 0x04, 0x7000 }, | ||
1370 | 1341 | ||
1371 | val = (mdio_read(ioaddr, pos) & 0x0fff) | (p->regs[0] & 0xffff); | 1342 | { 0x03, 0x802f }, |
1372 | mdio_write(ioaddr, pos, val); | 1343 | { 0x02, 0x4f02 }, |
1373 | while (--pos >= 0) | 1344 | { 0x01, 0x0409 }, |
1374 | mdio_write(ioaddr, pos, p->regs[4 - pos] & 0xffff); | 1345 | { 0x00, 0xf0f9 }, |
1375 | rtl8169_write_gmii_reg_bit(ioaddr, 4, 11, 1); //w 4 11 11 1 | 1346 | { 0x04, 0x9800 }, |
1376 | rtl8169_write_gmii_reg_bit(ioaddr, 4, 11, 0); //w 4 11 11 0 | 1347 | { 0x04, 0x9000 }, |
1377 | } | 1348 | |
1378 | mdio_write(ioaddr, 0x1f, 0x0000); //w 31 2 0 0 | 1349 | { 0x03, 0xdf01 }, |
1350 | { 0x02, 0xdf20 }, | ||
1351 | { 0x01, 0xff95 }, | ||
1352 | { 0x00, 0xba00 }, | ||
1353 | { 0x04, 0xa800 }, | ||
1354 | { 0x04, 0xa000 }, | ||
1355 | |||
1356 | { 0x03, 0xff41 }, | ||
1357 | { 0x02, 0xdf20 }, | ||
1358 | { 0x01, 0x0140 }, | ||
1359 | { 0x00, 0x00bb }, | ||
1360 | { 0x04, 0xb800 }, | ||
1361 | { 0x04, 0xb000 }, | ||
1362 | |||
1363 | { 0x03, 0xdf41 }, | ||
1364 | { 0x02, 0xdc60 }, | ||
1365 | { 0x01, 0x6340 }, | ||
1366 | { 0x00, 0x007d }, | ||
1367 | { 0x04, 0xd800 }, | ||
1368 | { 0x04, 0xd000 }, | ||
1369 | |||
1370 | { 0x03, 0xdf01 }, | ||
1371 | { 0x02, 0xdf20 }, | ||
1372 | { 0x01, 0x100a }, | ||
1373 | { 0x00, 0xa0ff }, | ||
1374 | { 0x04, 0xf800 }, | ||
1375 | { 0x04, 0xf000 }, | ||
1376 | |||
1377 | { 0x1f, 0x0000 }, | ||
1378 | { 0x0b, 0x0000 }, | ||
1379 | { 0x00, 0x9200 } | ||
1380 | }; | ||
1381 | |||
1382 | rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | ||
1379 | } | 1383 | } |
1380 | 1384 | ||
1381 | static void rtl8169sb_hw_phy_config(void __iomem *ioaddr) | 1385 | static void rtl8169sb_hw_phy_config(void __iomem *ioaddr) |