diff --git a/cpu/mcf52x2/fec.c b/cpu/mcf52x2/fec.c index b6540b5..a41db4f 100644 --- a/cpu/mcf52x2/fec.c +++ b/cpu/mcf52x2/fec.c @@ -71,7 +71,6 @@ static void mii_discover_phy (void); #define PKT_MINBUF_SIZE 64 #define PKT_MAXBLR_SIZE 1520 - static char txbuf[DBUF_LENGTH]; static uint rxIdx; /* index of the current RX buffer */ @@ -257,17 +256,15 @@ int eth_init (bd_t * bd) */ fecp->fec_ihash_table_high = 0; fecp->fec_ihash_table_low = 0; -#else - /* Clear multicast address hash table - */ -#ifdef CONFIG_M5282 +#elif defined(CONFIG_M5282) + fecp->fec_ghash_table_high = 0; + fecp->fec_ghash_table_low = 0; fecp->fec_ihash_table_high = 0; fecp->fec_ihash_table_low = 0; #else fecp->fec_hash_table_high = 0; fecp->fec_hash_table_low = 0; #endif -#endif /* Set maximum receive buffer size. */ @@ -333,8 +330,16 @@ int eth_init (bd_t * bd) fecp->fec_x_cntrl = 0; #endif /* Set MII speed */ +#ifdef CONFIG_M5282 + fecp->fec_mii_speed = (CFG_CLK / (2 * 2500000)); + fecp->fec_mii_speed *= 2; +#ifdef ET_DEBUG + printf ("fecp->fec_mii_speed: 0x%x\n",fecp->fec_mii_speed); +#endif +#else fecp->fec_mii_speed = (((CFG_CLK / 2) / (2500000 / 10)) + 5) / 10; fecp->fec_mii_speed *= 2; +#endif /* Configure port B for MII. */ @@ -404,19 +409,28 @@ static uint phytype; /* send command to phy using mii, wait for result */ static uint mii_send (uint mii_cmd) { + uint timeout; uint mii_reply; volatile fec_t *ep = (fec_t *) (FEC_ADDR); ep->fec_mii_data = mii_cmd; /* command to phy */ /* wait for mii complete */ - while (!(ep->fec_ievent & FEC_ENET_MII)); /* spin until done */ + timeout=50; + while (!(ep->fec_ievent & FEC_ENET_MII) && (timeout>0)) + { + udelay(2); +#ifdef ET_DEBUG + printf ("w"); +#endif + }; /* spin until done */ mii_reply = ep->fec_mii_data; /* result from phy */ ep->fec_ievent = FEC_ENET_MII; /* clear MII complete */ #ifdef ET_DEBUG printf ("%s[%d] %s: sent=0x%8.8x, reply=0x%8.8x\n", __FILE__, __LINE__, __FUNCTION__, mii_cmd, mii_reply); #endif + if (timeout ==0) return -1; return (mii_reply & 0xffff); /* data read from phy */ } #endif /* CFG_DISCOVER_PHY || (CONFIG_COMMANDS & CFG_CMD_MII) */ @@ -438,10 +452,10 @@ static void mii_discover_phy (void) */ udelay (10000); /* wait 10ms */ } - for (phyno = 1; phyno < 32 && phyaddr < 0; ++phyno) { + for (phyno = 0; phyno < 32 && phyaddr < 0; ++phyno) { phytype = mii_send (mk_mii_read (phyno, PHY_PHYIDR1)); #ifdef ET_DEBUG - printf ("PHY type 0x%x pass %d type ", phytype, pass); + printf ("PHY type 0x%x pass %d type \n", phytype, pass); #endif if (phytype != 0xffff) { phyaddr = phyno;