Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 315057
b: refs/heads/master
c: 2419221
h: refs/heads/master
i:
  315055: d69b08a
v: v3
  • Loading branch information
Francois Romieu committed Jul 9, 2012
1 parent c5edddf commit 8dba44c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5598bfe5191d09cdd622aeac39badc42508b227f
refs/heads/master: 24192210a57a24a45b29dc3519dc42e073ea7b0a
46 changes: 26 additions & 20 deletions trunk/drivers/net/ethernet/realtek/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ struct rtl8169_private {
u16 event_slow;

struct mdio_ops {
void (*write)(void __iomem *, int, int);
int (*read)(void __iomem *, int);
void (*write)(struct rtl8169_private *, int, int);
int (*read)(struct rtl8169_private *, int);
} mdio_ops;

struct pll_power_ops {
Expand Down Expand Up @@ -919,11 +919,12 @@ static int r8168dp_check_dash(struct rtl8169_private *tp)
return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0;
}

static void r8169_mdio_write(void __iomem *ioaddr, int reg_addr, int value)
static void r8169_mdio_write(struct rtl8169_private *tp, int reg, int value)
{
void __iomem *ioaddr = tp->mmio_addr;
int i;

RTL_W32(PHYAR, 0x80000000 | (reg_addr & 0x1f) << 16 | (value & 0xffff));
RTL_W32(PHYAR, 0x80000000 | (reg & 0x1f) << 16 | (value & 0xffff));

for (i = 20; i > 0; i--) {
/*
Expand All @@ -941,11 +942,12 @@ static void r8169_mdio_write(void __iomem *ioaddr, int reg_addr, int value)
udelay(20);
}

static int r8169_mdio_read(void __iomem *ioaddr, int reg_addr)
static int r8169_mdio_read(struct rtl8169_private *tp, int reg)
{
void __iomem *ioaddr = tp->mmio_addr;
int i, value = -1;

RTL_W32(PHYAR, 0x0 | (reg_addr & 0x1f) << 16);
RTL_W32(PHYAR, 0x0 | (reg & 0x1f) << 16);

for (i = 20; i > 0; i--) {
/*
Expand All @@ -967,12 +969,12 @@ static int r8169_mdio_read(void __iomem *ioaddr, int reg_addr)
return value;
}

static void r8168dp_1_mdio_access(void __iomem *ioaddr, int reg_addr, u32 data)
static void r8168dp_1_mdio_access(struct rtl8169_private *tp, int reg, u32 data)
{
void __iomem *ioaddr = tp->mmio_addr;
int i;

RTL_W32(OCPDR, data |
((reg_addr & OCPDR_REG_MASK) << OCPDR_GPHY_REG_SHIFT));
RTL_W32(OCPDR, data | ((reg & OCPDR_REG_MASK) << OCPDR_GPHY_REG_SHIFT));
RTL_W32(OCPAR, OCPAR_GPHY_WRITE_CMD);
RTL_W32(EPHY_RXER_NUM, 0);

Expand All @@ -983,17 +985,18 @@ static void r8168dp_1_mdio_access(void __iomem *ioaddr, int reg_addr, u32 data)
}
}

static void r8168dp_1_mdio_write(void __iomem *ioaddr, int reg_addr, int value)
static void r8168dp_1_mdio_write(struct rtl8169_private *tp, int reg, int value)
{
r8168dp_1_mdio_access(ioaddr, reg_addr, OCPDR_WRITE_CMD |
(value & OCPDR_DATA_MASK));
r8168dp_1_mdio_access(tp, reg,
OCPDR_WRITE_CMD | (value & OCPDR_DATA_MASK));
}

static int r8168dp_1_mdio_read(void __iomem *ioaddr, int reg_addr)
static int r8168dp_1_mdio_read(struct rtl8169_private *tp, int reg)
{
void __iomem *ioaddr = tp->mmio_addr;
int i;

r8168dp_1_mdio_access(ioaddr, reg_addr, OCPDR_READ_CMD);
r8168dp_1_mdio_access(tp, reg, OCPDR_READ_CMD);

mdelay(1);
RTL_W32(OCPAR, OCPAR_GPHY_READ_CMD);
Expand All @@ -1020,22 +1023,25 @@ static void r8168dp_2_mdio_stop(void __iomem *ioaddr)
RTL_W32(0xd0, RTL_R32(0xd0) | R8168DP_1_MDIO_ACCESS_BIT);
}

static void r8168dp_2_mdio_write(void __iomem *ioaddr, int reg_addr, int value)
static void r8168dp_2_mdio_write(struct rtl8169_private *tp, int reg, int value)
{
void __iomem *ioaddr = tp->mmio_addr;

r8168dp_2_mdio_start(ioaddr);

r8169_mdio_write(ioaddr, reg_addr, value);
r8169_mdio_write(tp, reg, value);

r8168dp_2_mdio_stop(ioaddr);
}

static int r8168dp_2_mdio_read(void __iomem *ioaddr, int reg_addr)
static int r8168dp_2_mdio_read(struct rtl8169_private *tp, int reg)
{
void __iomem *ioaddr = tp->mmio_addr;
int value;

r8168dp_2_mdio_start(ioaddr);

value = r8169_mdio_read(ioaddr, reg_addr);
value = r8169_mdio_read(tp, reg);

r8168dp_2_mdio_stop(ioaddr);

Expand All @@ -1044,12 +1050,12 @@ static int r8168dp_2_mdio_read(void __iomem *ioaddr, int reg_addr)

static void rtl_writephy(struct rtl8169_private *tp, int location, u32 val)
{
tp->mdio_ops.write(tp->mmio_addr, location, val);
tp->mdio_ops.write(tp, location, val);
}

static int rtl_readphy(struct rtl8169_private *tp, int location)
{
return tp->mdio_ops.read(tp->mmio_addr, location);
return tp->mdio_ops.read(tp, location);
}

static void rtl_patchphy(struct rtl8169_private *tp, int reg_addr, int value)
Expand Down

0 comments on commit 8dba44c

Please sign in to comment.