Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 203482
b: refs/heads/master
c: 97b72e4
h: refs/heads/master
v: v3
  • Loading branch information
Baruch Siach authored and David S. Miller committed Jul 13, 2010
1 parent 0b5c625 commit 39faac8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 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: 15fd0cd9a2ad24a78fbee369dec8ca660979d57e
refs/heads/master: 97b72e4320a9aaa4a7f1592ee7d2da7e2c9bd349
55 changes: 25 additions & 30 deletions trunk/drivers/net/fec.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ struct fec_enet_private {
int index;
int link;
int full_duplex;
struct completion mdio_done;
};

static irqreturn_t fec_enet_interrupt(int irq, void * dev_id);
Expand All @@ -205,7 +206,7 @@ static void fec_stop(struct net_device *dev);
#define FEC_MMFR_TA (2 << 16)
#define FEC_MMFR_DATA(v) (v & 0xffff)

#define FEC_MII_TIMEOUT 10000
#define FEC_MII_TIMEOUT 1000 /* us */

/* Transmitter timeout */
#define TX_TIMEOUT (2 * HZ)
Expand Down Expand Up @@ -334,6 +335,11 @@ fec_enet_interrupt(int irq, void * dev_id)
ret = IRQ_HANDLED;
fec_enet_tx(dev);
}

if (int_events & FEC_ENET_MII) {
ret = IRQ_HANDLED;
complete(&fep->mdio_done);
}
} while (int_events);

return ret;
Expand Down Expand Up @@ -608,32 +614,26 @@ static void fec_enet_adjust_link(struct net_device *dev)
phy_print_status(phy_dev);
}

/*
* NOTE: a MII transaction is during around 25 us, so polling it...
*/
static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
{
struct fec_enet_private *fep = bus->priv;
int timeout = FEC_MII_TIMEOUT;
unsigned long time_left;

fep->mii_timeout = 0;

/* clear MII end of transfer bit*/
writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
init_completion(&fep->mdio_done);

/* start a read op */
writel(FEC_MMFR_ST | FEC_MMFR_OP_READ |
FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) |
FEC_MMFR_TA, fep->hwp + FEC_MII_DATA);

/* wait for end of transfer */
while (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_MII)) {
cpu_relax();
if (timeout-- < 0) {
fep->mii_timeout = 1;
printk(KERN_ERR "FEC: MDIO read timeout\n");
return -ETIMEDOUT;
}
time_left = wait_for_completion_timeout(&fep->mdio_done,
usecs_to_jiffies(FEC_MII_TIMEOUT));
if (time_left == 0) {
fep->mii_timeout = 1;
printk(KERN_ERR "FEC: MDIO read timeout\n");
return -ETIMEDOUT;
}

/* return value */
Expand All @@ -644,12 +644,10 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
u16 value)
{
struct fec_enet_private *fep = bus->priv;
int timeout = FEC_MII_TIMEOUT;
unsigned long time_left;

fep->mii_timeout = 0;

/* clear MII end of transfer bit*/
writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
init_completion(&fep->mdio_done);

/* start a read op */
writel(FEC_MMFR_ST | FEC_MMFR_OP_READ |
Expand All @@ -658,13 +656,12 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
fep->hwp + FEC_MII_DATA);

/* wait for end of transfer */
while (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_MII)) {
cpu_relax();
if (timeout-- < 0) {
fep->mii_timeout = 1;
printk(KERN_ERR "FEC: MDIO write timeout\n");
return -ETIMEDOUT;
}
time_left = wait_for_completion_timeout(&fep->mdio_done,
usecs_to_jiffies(FEC_MII_TIMEOUT));
if (time_left == 0) {
fep->mii_timeout = 1;
printk(KERN_ERR "FEC: MDIO write timeout\n");
return -ETIMEDOUT;
}

return 0;
Expand Down Expand Up @@ -1216,7 +1213,8 @@ fec_restart(struct net_device *dev, int duplex)
writel(0, fep->hwp + FEC_R_DES_ACTIVE);

/* Enable interrupts we wish to service */
writel(FEC_ENET_TXF | FEC_ENET_RXF, fep->hwp + FEC_IMASK);
writel(FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII,
fep->hwp + FEC_IMASK);
}

static void
Expand All @@ -1236,9 +1234,6 @@ fec_stop(struct net_device *dev)
writel(1, fep->hwp + FEC_ECNTRL);
udelay(10);

/* Clear outstanding MII command interrupts. */
writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);

writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
}

Expand Down

0 comments on commit 39faac8

Please sign in to comment.