From 04d2779b5cbe7185f3e841545ae4cb51bffc5acb Mon Sep 17 00:00:00 2001 From: yongari Date: Tue, 14 Aug 2007 02:00:04 +0000 Subject: Make sure to take PHY out of power down mode in device attach. Without this the PHY wouldn't work as expected. This should fix dual-boot Windows XP machine where RealTek Windows drivers put the PHY in power down mode during shutdown. The magic PHY register accesses come from RealTek driver. No datasheets mention the magic PHY registers. In general, the PHY wakeup code should go into PHY driver. However it seems that it only apply to RTL8169S single chip and it would be another hack if we have rgephy(4) check what parent driver/chip model is attached. Reported by: lofi, Laurens Timmermans ( laurens AT timkapel DOT nl ) Tested by: lofi Obtained from: RealTek FreeBSD driver Approved by: re (Ken Smith) --- sys/dev/re/if_re.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sys') diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c index 4f6a9da..4360014 100644 --- a/sys/dev/re/if_re.c +++ b/sys/dev/re/if_re.c @@ -1301,6 +1301,28 @@ re_attach(dev) goto fail; } + /* Take PHY out of power down mode. */ + if (sc->rl_type == RL_8169) { + uint32_t rev; + + rev = CSR_READ_4(sc, RL_TXCFG); + /* HWVERID 0, 1 and 2 : bit26-30, bit23 */ + rev &= 0x7c800000; + if (rev != 0) { + /* RTL8169S single chip */ + switch (rev) { + case RL_HWREV_8169_8110SB: + case RL_HWREV_8169_8110SC: + case RL_HWREV_8168_SPIN2: + re_gmii_writereg(dev, 1, 0x1f, 0); + re_gmii_writereg(dev, 1, 0x0e, 0); + break; + default: + break; + } + } + } + ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; -- cgit v1.1