IXP NPE: add support for fixed-speed MII ports

Signed-off-by: Michael Schwingen <michael@schwingen.org>
This commit is contained in:
Michael Schwingen 2011-05-23 00:00:08 +02:00 committed by Albert ARIBAUD
parent 080b7643fb
commit d697d79f8d
1 changed files with 41 additions and 24 deletions

View File

@ -359,36 +359,53 @@ static int npe_init(struct eth_device *dev, bd_t * bis)
debug("%s: 1\n", __FUNCTION__); debug("%s: 1\n", __FUNCTION__);
miiphy_read (dev->name, p_npe->phy_no, MII_BMSR, &reg_short); #ifdef CONFIG_MII_NPE0_FIXEDLINK
if (0 == p_npe->eth_id) {
speed = CONFIG_MII_NPE0_SPEED;
duplex = CONFIG_MII_NPE0_FULLDUPLEX ? FULL : HALF;
} else
#endif
#ifdef CONFIG_MII_NPE1_FIXEDLINK
if (1 == p_npe->eth_id) {
speed = CONFIG_MII_NPE1_SPEED;
duplex = CONFIG_MII_NPE1_FULLDUPLEX ? FULL : HALF;
} else
#endif
{
miiphy_read(dev->name, p_npe->phy_no, MII_BMSR, &reg_short);
/* /*
* Wait if PHY is capable of autonegotiation and autonegotiation is not complete * Wait if PHY is capable of autonegotiation and
*/ * autonegotiation is not complete
if ((reg_short & BMSR_ANEGCAPABLE) && !(reg_short & BMSR_ANEGCOMPLETE)) { */
puts ("Waiting for PHY auto negotiation to complete"); if ((reg_short & BMSR_ANEGCAPABLE) &&
i = 0; !(reg_short & BMSR_ANEGCOMPLETE)) {
while (!(reg_short & BMSR_ANEGCOMPLETE)) { puts("Waiting for PHY auto negotiation to complete");
/* i = 0;
* Timeout reached ? while (!(reg_short & BMSR_ANEGCOMPLETE)) {
*/ /*
if (i > PHY_AUTONEGOTIATE_TIMEOUT) { * Timeout reached ?
puts (" TIMEOUT !\n"); */
break; if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
} puts(" TIMEOUT !\n");
break;
}
if ((i++ % 1000) == 0) { if ((i++ % 1000) == 0) {
putc ('.'); putc('.');
miiphy_read (dev->name, p_npe->phy_no, MII_BMSR, &reg_short); miiphy_read(dev->name, p_npe->phy_no,
MII_BMSR, &reg_short);
}
udelay(1000); /* 1 ms */
} }
udelay (1000); /* 1 ms */ puts(" done\n");
/* another 500 ms (results in faster booting) */
udelay(500000);
} }
puts (" done\n"); speed = miiphy_speed(dev->name, p_npe->phy_no);
udelay (500000); /* another 500 ms (results in faster booting) */ duplex = miiphy_duplex(dev->name, p_npe->phy_no);
} }
speed = miiphy_speed (dev->name, p_npe->phy_no);
duplex = miiphy_duplex (dev->name, p_npe->phy_no);
if (p_npe->print_speed) { if (p_npe->print_speed) {
p_npe->print_speed = 0; p_npe->print_speed = 0;
printf ("ENET Speed is %d Mbps - %s duplex connection\n", printf ("ENET Speed is %d Mbps - %s duplex connection\n",