summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeng Zhaoming <b32542@freescale.com>2010-12-21 08:49:59 +0800
committerZeng Zhaoming <b32542@freescale.com>2010-12-22 03:17:05 +0800
commit4cf53cfc4948a5e00b895fbe4dbe175fefaf2c40 (patch)
tree9b1510c0c057ffe5c00581f6cbb86161b0960fda
parent3b667325bf959716cd04b3161c8f31bde24ad4f8 (diff)
ENGR00137130 Fec: Can't bootup from NFS when eth0 and eth1 all linkedrel_imx_2.6.35_10.12.01_RC3
This reverts commit d4b2153e87aa2d35b5f830744c14a04e386b3adb. "fec: use interrupt for MDIO completion indication" In IMX28, eth0 and eth1 shared MDIO, using interrupt to indicate mdio read or write complete makes eth1 not working. since mdio_read() can only access eth0 reg space, getting/setting eth1 phy state by writing management frame to eth0 reg space, will trigger eth1 mdio complete indication interrupt. But eth1 EIR register will not updated. Signed-off-by: Zeng Zhaoming <b32542@freescale.com>
-rw-r--r--drivers/net/fec.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index d0e2e690b66e..c49e64e8abcc 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -119,10 +119,10 @@
#define FEC_ENET_TS_TIMER ((uint)0x00008000)
#if defined(CONFIG_FEC_1588) && defined(CONFIG_ARCH_MX28)
-#define FEC_DEFAULT_IMASK (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII | \
+#define FEC_DEFAULT_IMASK (FEC_ENET_TXF | FEC_ENET_RXF | \
FEC_ENET_TS_AVAIL | FEC_ENET_TS_TIMER)
#else
-#define FEC_DEFAULT_IMASK (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII)
+#define FEC_DEFAULT_IMASK (FEC_ENET_TXF | FEC_ENET_RXF)
#endif
/* The FEC stores dest/src/type, data, and checksum for receive packets.
@@ -195,7 +195,6 @@ struct fec_enet_private {
int index;
int link;
int full_duplex;
- struct completion mdio_done;
struct fec_ptp_private *ptp_priv;
uint ptimer_present;
@@ -223,7 +222,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 1000
+#define FEC_MII_TIMEOUT 10000
/* Transmitter timeout */
#define TX_TIMEOUT (2 * HZ)
@@ -390,10 +389,6 @@ fec_enet_interrupt(int irq, void * dev_id)
fpp->prtc++;
}
- if (int_events & FEC_ENET_MII) {
- ret = IRQ_HANDLED;
- complete(&fep->mdio_done);
- }
} while (int_events);
return ret;
@@ -710,13 +705,18 @@ spin_unlock:
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;
- unsigned long time_left;
+ int timeout = FEC_MII_TIMEOUT;
fep->mii_timeout = 0;
- init_completion(&fep->mdio_done);
+
+ /* clear MII end of transfer bit*/
+ writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
/* start a read op */
writel(FEC_MMFR_ST | FEC_MMFR_OP_READ |
@@ -724,12 +724,13 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
FEC_MMFR_TA, fep->hwp + FEC_MII_DATA);
/* wait for end of transfer */
- 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;
+ 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;
+ }
}
/* return value */
return FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));
@@ -739,10 +740,12 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
u16 value)
{
struct fec_enet_private *fep = bus->priv;
- unsigned long time_left;
+ int timeout = FEC_MII_TIMEOUT;
fep->mii_timeout = 0;
- init_completion(&fep->mdio_done);
+
+ /* clear MII end of transfer bit*/
+ writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
/* start a write op */
writel(FEC_MMFR_ST | FEC_MMFR_OP_WRITE |
@@ -751,12 +754,13 @@ 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 */
- 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;
+ 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;
+ }
}
return 0;
@@ -1409,6 +1413,9 @@ 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);
+
#ifdef CONFIG_ARCH_MXS
/* Check MII or RMII */
if (fep->phy_interface == PHY_INTERFACE_MODE_RMII)