Skip to content

Commit

Permalink
r8169: make room for more phy init changes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Francois Romieu committed Oct 18, 2007
1 parent e179bb7 commit 5615d9f
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions drivers/net/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,10 +1168,8 @@ static void rtl8169_print_mac_version(struct rtl8169_private *tp)
dprintk("mac_version = 0x%02x\n", tp->mac_version);
}

static void rtl8169_hw_phy_config(struct net_device *dev)
static void rtl8169s_hw_phy_config(void __iomem *ioaddr)
{
struct rtl8169_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
struct {
u16 regs[5]; /* Beware of bit-sign propagation */
} phy_magic[5] = { {
Expand Down Expand Up @@ -1204,27 +1202,6 @@ static void rtl8169_hw_phy_config(struct net_device *dev)
}, *p = phy_magic;
unsigned int i;

rtl8169_print_mac_version(tp);

if (tp->mac_version <= RTL_GIGA_MAC_VER_01)
return;

dprintk("MAC version != 0 && PHY version == 0 or 1\n");
dprintk("Do final_reg2.cfg\n");

/* Shazam ! */

if (tp->mac_version == RTL_GIGA_MAC_VER_04) {
mdio_write(ioaddr, 31, 0x0002);
mdio_write(ioaddr, 1, 0x90d0);
mdio_write(ioaddr, 31, 0x0000);
return;
}

if ((tp->mac_version != RTL_GIGA_MAC_VER_02) &&
(tp->mac_version != RTL_GIGA_MAC_VER_03))
return;

mdio_write(ioaddr, 31, 0x0001); //w 31 2 0 1
mdio_write(ioaddr, 21, 0x1000); //w 21 15 0 1000
mdio_write(ioaddr, 24, 0x65c7); //w 24 15 0 65c7
Expand All @@ -1243,6 +1220,35 @@ static void rtl8169_hw_phy_config(struct net_device *dev)
mdio_write(ioaddr, 31, 0x0000); //w 31 2 0 0
}

static void rtl8169sb_hw_phy_config(void __iomem *ioaddr)
{
mdio_write(ioaddr, 31, 0x0002);
mdio_write(ioaddr, 1, 0x90d0);
mdio_write(ioaddr, 31, 0x0000);
}

static void rtl_hw_phy_config(struct net_device *dev)
{
struct rtl8169_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;

rtl8169_print_mac_version(tp);

switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_01:
break;
case RTL_GIGA_MAC_VER_02:
case RTL_GIGA_MAC_VER_03:
rtl8169s_hw_phy_config(ioaddr);
break;
case RTL_GIGA_MAC_VER_04:
rtl8169sb_hw_phy_config(ioaddr);
break;
default:
break;
}
}

static void rtl8169_phy_timer(unsigned long __opaque)
{
struct net_device *dev = (struct net_device *)__opaque;
Expand Down Expand Up @@ -1349,7 +1355,7 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;

rtl8169_hw_phy_config(dev);
rtl_hw_phy_config(dev);

dprintk("Set MAC Reg C+CR Offset 0x82h = 0x01h\n");
RTL_W8(0x82, 0x01);
Expand Down

0 comments on commit 5615d9f

Please sign in to comment.