Commit 7cc8f381 authored by Bryan Wu's avatar Bryan Wu Committed by David S. Miller

EMAC driver: define MDC_CLK=2.5MHz and caculate mdc_div according to SCLK.

Signed-off-by: default avatarBryan Wu <bryan.wu@analog.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6db9e461
...@@ -412,20 +412,26 @@ static void bf537_adjust_link(struct net_device *dev) ...@@ -412,20 +412,26 @@ static void bf537_adjust_link(struct net_device *dev)
spin_unlock_irqrestore(&lp->lock, flags); spin_unlock_irqrestore(&lp->lock, flags);
} }
/* MDC = 2.5 MHz */
#define MDC_CLK 2500000
static int mii_probe(struct net_device *dev) static int mii_probe(struct net_device *dev)
{ {
struct bf537mac_local *lp = netdev_priv(dev); struct bf537mac_local *lp = netdev_priv(dev);
struct phy_device *phydev = NULL; struct phy_device *phydev = NULL;
unsigned short sysctl; unsigned short sysctl;
int i; int i;
u32 sclk, mdc_div;
/* Enable PHY output early */ /* Enable PHY output early */
if (!(bfin_read_VR_CTL() & PHYCLKOE)) if (!(bfin_read_VR_CTL() & PHYCLKOE))
bfin_write_VR_CTL(bfin_read_VR_CTL() | PHYCLKOE); bfin_write_VR_CTL(bfin_read_VR_CTL() | PHYCLKOE);
/* MDC = 2.5 MHz */ sclk = get_sclk();
mdc_div = ((sclk / MDC_CLK) / 2) - 1;
sysctl = bfin_read_EMAC_SYSCTL(); sysctl = bfin_read_EMAC_SYSCTL();
sysctl |= SET_MDCDIV(24); sysctl |= SET_MDCDIV(mdc_div);
bfin_write_EMAC_SYSCTL(sysctl); bfin_write_EMAC_SYSCTL(sysctl);
/* search for connect PHY device */ /* search for connect PHY device */
...@@ -477,8 +483,10 @@ static int mii_probe(struct net_device *dev) ...@@ -477,8 +483,10 @@ static int mii_probe(struct net_device *dev)
lp->phydev = phydev; lp->phydev = phydev;
printk(KERN_INFO "%s: attached PHY driver [%s] " printk(KERN_INFO "%s: attached PHY driver [%s] "
"(mii_bus:phy_addr=%s, irq=%d)\n", "(mii_bus:phy_addr=%s, irq=%d, mdc_clk=%dHz(mdc_div=%d)"
DRV_NAME, phydev->drv->name, phydev->dev.bus_id, phydev->irq); "@sclk=%dMHz)\n",
DRV_NAME, phydev->drv->name, phydev->dev.bus_id, phydev->irq,
MDC_CLK, mdc_div, sclk/1000000);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment