|
|
@ -13,6 +13,7 @@ |
|
|
|
#include <command.h> |
|
|
|
#include <command.h> |
|
|
|
#include <malloc.h> |
|
|
|
#include <malloc.h> |
|
|
|
#include <miiphy.h> |
|
|
|
#include <miiphy.h> |
|
|
|
|
|
|
|
#include <linux/mdio.h> |
|
|
|
#include <linux/mii.h> |
|
|
|
#include <linux/mii.h> |
|
|
|
|
|
|
|
|
|
|
|
#include <asm/blackfin.h> |
|
|
|
#include <asm/blackfin.h> |
|
|
@ -126,6 +127,8 @@ int bfin_EMAC_initialize(bd_t *bis) |
|
|
|
retval = mdio_register(mdiodev); |
|
|
|
retval = mdio_register(mdiodev); |
|
|
|
if (retval < 0) |
|
|
|
if (retval < 0) |
|
|
|
return retval; |
|
|
|
return retval; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dev->priv = mdiodev; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
@ -234,8 +237,9 @@ static int bfin_EMAC_recv(struct eth_device *dev) |
|
|
|
static int bfin_miiphy_init(struct eth_device *dev, int *opmode) |
|
|
|
static int bfin_miiphy_init(struct eth_device *dev, int *opmode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const unsigned short pins[] = CONFIG_BFIN_MAC_PINS; |
|
|
|
const unsigned short pins[] = CONFIG_BFIN_MAC_PINS; |
|
|
|
u16 phydat; |
|
|
|
int phydat; |
|
|
|
size_t count; |
|
|
|
size_t count; |
|
|
|
|
|
|
|
struct mii_dev *mdiodev = dev->priv; |
|
|
|
|
|
|
|
|
|
|
|
/* Enable PHY output */ |
|
|
|
/* Enable PHY output */ |
|
|
|
bfin_write_VR_CTL(bfin_read_VR_CTL() | CLKBUFOE); |
|
|
|
bfin_write_VR_CTL(bfin_read_VR_CTL() | CLKBUFOE); |
|
|
@ -248,12 +252,15 @@ static int bfin_miiphy_init(struct eth_device *dev, int *opmode) |
|
|
|
bfin_write_EMAC_SYSCTL(RXDWA | RXCKS | SET_MDCDIV(MDC_FREQ_TO_DIV(CONFIG_PHY_CLOCK_FREQ))); |
|
|
|
bfin_write_EMAC_SYSCTL(RXDWA | RXCKS | SET_MDCDIV(MDC_FREQ_TO_DIV(CONFIG_PHY_CLOCK_FREQ))); |
|
|
|
|
|
|
|
|
|
|
|
/* turn on auto-negotiation and wait for link to come up */ |
|
|
|
/* turn on auto-negotiation and wait for link to come up */ |
|
|
|
bfin_miiphy_write(dev->name, CONFIG_PHY_ADDR, MII_BMCR, BMCR_ANENABLE); |
|
|
|
bfin_miiphy_write(mdiodev, CONFIG_PHY_ADDR, MDIO_DEVAD_NONE, MII_BMCR, |
|
|
|
|
|
|
|
BMCR_ANENABLE); |
|
|
|
count = 0; |
|
|
|
count = 0; |
|
|
|
while (1) { |
|
|
|
while (1) { |
|
|
|
++count; |
|
|
|
++count; |
|
|
|
if (bfin_miiphy_read(dev->name, CONFIG_PHY_ADDR, MII_BMSR, &phydat)) |
|
|
|
phydat = bfin_miiphy_read(mdiodev, CONFIG_PHY_ADDR, |
|
|
|
return -1; |
|
|
|
MDIO_DEVAD_NONE, MII_BMSR); |
|
|
|
|
|
|
|
if (phydat < 0) |
|
|
|
|
|
|
|
return phydat; |
|
|
|
if (phydat & BMSR_LSTATUS) |
|
|
|
if (phydat & BMSR_LSTATUS) |
|
|
|
break; |
|
|
|
break; |
|
|
|
if (count > 30000) { |
|
|
|
if (count > 30000) { |
|
|
@ -264,8 +271,10 @@ static int bfin_miiphy_init(struct eth_device *dev, int *opmode) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* see what kind of link we have */ |
|
|
|
/* see what kind of link we have */ |
|
|
|
if (bfin_miiphy_read(dev->name, CONFIG_PHY_ADDR, MII_LPA, &phydat)) |
|
|
|
phydat = bfin_miiphy_read(mdiodev, CONFIG_PHY_ADDR, MDIO_DEVAD_NONE, |
|
|
|
return -1; |
|
|
|
MII_LPA); |
|
|
|
|
|
|
|
if (phydat < 0) |
|
|
|
|
|
|
|
return phydat; |
|
|
|
if (phydat & LPA_DUPLEX) |
|
|
|
if (phydat & LPA_DUPLEX) |
|
|
|
*opmode = FDMODE; |
|
|
|
*opmode = FDMODE; |
|
|
|
else |
|
|
|
else |
|
|
|