Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195156
b: refs/heads/master
c: 2bfa0f0
h: refs/heads/master
v: v3
  • Loading branch information
Mike Frysinger authored and David S. Miller committed May 18, 2010
1 parent 5353891 commit 20ccb22
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 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: c0da776bde79e5d5e2c955ff37a8a09fe05433b2
refs/heads/master: 2bfa0f0c9a37460ee69128da411f6d310c1c983d
53 changes: 34 additions & 19 deletions trunk/drivers/net/bfin_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ static u16 pin_req[] = P_RMII0;
static u16 pin_req[] = P_MII0;
#endif

static void bfin_mac_disable(void);
static void bfin_mac_enable(void);

static void desc_list_free(void)
{
struct net_dma_desc_rx *r;
Expand Down Expand Up @@ -260,7 +257,7 @@ static int desc_list_init(void)
* MII operations
*/
/* Wait until the previous MDC/MDIO transaction has completed */
static void bfin_mdio_poll(void)
static int bfin_mdio_poll(void)
{
int timeout_cnt = MAX_TIMEOUT_CNT;

Expand All @@ -270,22 +267,30 @@ static void bfin_mdio_poll(void)
if (timeout_cnt-- < 0) {
printk(KERN_ERR DRV_NAME
": wait MDC/MDIO transaction to complete timeout\n");
break;
return -ETIMEDOUT;
}
}

return 0;
}

/* Read an off-chip register in a PHY through the MDC/MDIO port */
static int bfin_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
{
bfin_mdio_poll();
int ret;

ret = bfin_mdio_poll();
if (ret)
return ret;

/* read mode */
bfin_write_EMAC_STAADD(SET_PHYAD((u16) phy_addr) |
SET_REGAD((u16) regnum) |
STABUSY);

bfin_mdio_poll();
ret = bfin_mdio_poll();
if (ret)
return ret;

return (int) bfin_read_EMAC_STADAT();
}
Expand All @@ -294,7 +299,11 @@ static int bfin_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
static int bfin_mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
u16 value)
{
bfin_mdio_poll();
int ret;

ret = bfin_mdio_poll();
if (ret)
return ret;

bfin_write_EMAC_STADAT((u32) value);

Expand All @@ -304,9 +313,7 @@ static int bfin_mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
STAOP |
STABUSY);

bfin_mdio_poll();

return 0;
return bfin_mdio_poll();
}

static int bfin_mdiobus_reset(struct mii_bus *bus)
Expand Down Expand Up @@ -1180,8 +1187,9 @@ static void bfin_mac_disable(void)
/*
* Enable Interrupts, Receive, and Transmit
*/
static void bfin_mac_enable(void)
static int bfin_mac_enable(void)
{
int ret;
u32 opmode;

pr_debug("%s: %s\n", DRV_NAME, __func__);
Expand All @@ -1191,7 +1199,9 @@ static void bfin_mac_enable(void)
bfin_write_DMA1_CONFIG(rx_list_head->desc_a.config);

/* Wait MII done */
bfin_mdio_poll();
ret = bfin_mdio_poll();
if (ret)
return ret;

/* We enable only RX here */
/* ASTP : Enable Automatic Pad Stripping
Expand All @@ -1215,6 +1225,8 @@ static void bfin_mac_enable(void)
#endif
/* Turn on the EMAC rx */
bfin_write_EMAC_OPMODE(opmode);

return 0;
}

/* Our watchdog timed out. Called by the networking layer */
Expand Down Expand Up @@ -1327,7 +1339,7 @@ static void bfin_mac_shutdown(struct net_device *dev)
static int bfin_mac_open(struct net_device *dev)
{
struct bfin_mac_local *lp = netdev_priv(dev);
int retval;
int ret;
pr_debug("%s: %s\n", dev->name, __func__);

/*
Expand All @@ -1341,18 +1353,21 @@ static int bfin_mac_open(struct net_device *dev)
}

/* initial rx and tx list */
retval = desc_list_init();

if (retval)
return retval;
ret = desc_list_init();
if (ret)
return ret;

phy_start(lp->phydev);
phy_write(lp->phydev, MII_BMCR, BMCR_RESET);
setup_system_regs(dev);
setup_mac_addr(dev->dev_addr);

bfin_mac_disable();
bfin_mac_enable();
ret = bfin_mac_enable();
if (ret)
return ret;
pr_debug("hardware init finished\n");

netif_start_queue(dev);
netif_carrier_on(dev);

Expand Down

0 comments on commit 20ccb22

Please sign in to comment.