[U-Boot-Users] PATCH: fix FEC problems on MPC5200

Hi everybody,
The attached patch fixes the FEC problems on my Lite5200 board. The network is working without any problems at 10 and 100Mb. The auto-negociation works too.
If CONFIG_FEC_10MBIT is defined, the FEC works at 10Mb with Half-Duplex. If CONFIG_FEC_10MBIT is undefined, the MII reads its configuration from hardware and uses the auto-negociation for determining network speed. The patch undefines CONFIG_FEC_10MBIT for the Lite5200.
Does it work for the other MPC5xxx boards ?
CHANGELOG: * Patch by Pierre Aubert 25 Mar 2004 Fix FEC problems on MPC5xxx: suppress timeouts on tftp.
Best regards
diff -Naur u-boot/cpu/mpc5xxx/fec.c u-boot-paub/cpu/mpc5xxx/fec.c --- u-boot/cpu/mpc5xxx/fec.c 2004-03-23 22:43:08.000000000 +0100 +++ u-boot-paub/cpu/mpc5xxx/fec.c 2004-03-25 09:03:19.000000000 +0100 @@ -276,26 +276,22 @@ */ if (fec->xcv_type == SEVENWIRE) { /* - * Frame length=1518; 7-wire mode + * Frame length=1518; FCE, 7-wire mode */ - fec->eth->r_cntrl = 0x05ee0020; /*0x05ee0000;FIXME */ + fec->eth->r_cntrl = 0x05ee0020; } else { /* - * Frame length=1518; MII mode; + * Frame length=1518; FCE, MII mode; */ - fec->eth->r_cntrl = 0x05ee0024; /*0x05ee0004;FIXME */ + fec->eth->r_cntrl = 0x05ee0024; }
- if (fec->xcv_type == SEVENWIRE) { - /* - * Set FEC-Lite transmit control register(X_CNTRL): - */ - /*fec->eth->x_cntrl = 0x00000002; */ /* half-duplex, heartbeat */ - fec->eth->x_cntrl = 0x00000000; /* half-duplex, heartbeat disabled */ - } else { - /*fec->eth->x_cntrl = 0x00000006; */ /* full-duplex, heartbeat */ - fec->eth->x_cntrl = 0x00000004; /* full-duplex, heartbeat disabled */ - + /* + * Set FEC-Lite transmit control register(X_CNTRL): + * Half-Duplex + */ + fec->eth->x_cntrl = 0x00000000; + if (fec->xcv_type != SEVENWIRE) { /* * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock * and do not drop the Preamble. @@ -379,7 +375,7 @@ *(int *)FEC_TBD_NEXT = (int)fec->tbdBase; *(int *)FEC_RBD_NEXT = (int)fec->rbdBase;
- if (fec->xcv_type != SEVENWIRE) { + if (fec->xcv_type == MII10) { /* * Initialize PHY(LXT971A): * @@ -410,87 +406,46 @@ miiphy_write(phyAddr, 0x0, 0x8000); udelay(1000);
- if (fec->xcv_type == MII10) { - /* - * Force 10Base-T, FDX operation - */ -#if (DEBUG & 0x2) - printf("Forcing 10 Mbps ethernet link... "); -#endif - miiphy_read(phyAddr, 0x1, &phyStatus); - /* - miiphy_write(fec, phyAddr, 0x0, 0x0100); - */ - miiphy_write(phyAddr, 0x0, 0x0180); - - timeout = 20; - do { /* wait for link status to go down */ - udelay(10000); - if ((timeout--) == 0) { -#if (DEBUG & 0x2) - printf("hmmm, should not have waited..."); -#endif - break; - } - miiphy_read(phyAddr, 0x1, &phyStatus); -#if (DEBUG & 0x2) - printf("="); -#endif - } while ((phyStatus & 0x0004)); /* !link up */ - - timeout = 1000; - do { /* wait for link status to come back up */ - udelay(10000); - if ((timeout--) == 0) { - printf("failed. Link is down.\n"); - break; - } - miiphy_read(phyAddr, 0x1, &phyStatus); + /* + * Force 10Base-T, FDX operation + */ #if (DEBUG & 0x2) - printf("+"); + printf("Forcing 10 Mbps ethernet link... "); #endif - } while (!(phyStatus & 0x0004)); /* !link up */ + miiphy_read(phyAddr, 0x1, &phyStatus); + miiphy_write(phyAddr, 0x0, 0x0080);
+ timeout = 20; + do { /* wait for link status to go down */ + udelay(10000); + if ((timeout--) == 0) { #if (DEBUG & 0x2) - printf ("done.\n"); + printf("hmmm, should not have waited..."); #endif - } else { /* MII100 */ - /* - * Set the auto-negotiation advertisement register bits - */ - miiphy_write(phyAddr, 0x4, 0x01e1); - - /* - * Set MDIO bit 0.12 = 1(&& bit 0.9=1?) to enable auto-negotiation - */ - miiphy_write(phyAddr, 0x0, 0x1200); - - /* - * Wait for AN completion - */ - timeout = 5000; - do { - udelay(1000); - - if ((timeout--) == 0) { + break; + } + miiphy_read(phyAddr, 0x1, &phyStatus); #if (DEBUG & 0x2) - printf("PHY auto neg 0 failed...\n"); + printf("="); #endif - return -1; - } + } while ((phyStatus & 0x0004)); /* !link up */
- if (miiphy_read(phyAddr, 0x1, &phyStatus) != 0) { + timeout = 1000; + do { /* wait for link status to come back up */ + udelay(10000); + if ((timeout--) == 0) { + printf("failed. Link is down.\n"); + break; + } + miiphy_read(phyAddr, 0x1, &phyStatus); #if (DEBUG & 0x2) - printf("PHY auto neg 1 failed 0x%04x...\n", phyStatus); + printf("+"); #endif - return -1; - } - } while ((phyStatus & 0x0020) != 0x0020); - + } while (!(phyStatus & 0x0004)); /* !link up */ + #if (DEBUG & 0x2) - printf("PHY auto neg complete! \n"); + printf ("done.\n"); #endif - }
}
diff -Naur u-boot/include/configs/IceCube.h u-boot-paub/include/configs/IceCube.h --- u-boot/include/configs/IceCube.h 2004-03-17 02:13:08.000000000 +0100 +++ u-boot-paub/include/configs/IceCube.h 2004-03-25 09:15:46.000000000 +0100 @@ -232,7 +232,8 @@ * Ethernet configuration */ #define CONFIG_MPC5xxx_FEC 1 -#define CONFIG_FEC_10MBIT 1 /* Workaround for FEC 100Mbit problem */ +/* Define CONFIG_FEC_10MB To force FEC at 10Mb */ +/* #define CONFIG_FEC_10MBIT 1 */ #define CONFIG_PHY_ADDR 0x00
/*

In message 40629804.5060107@staubli.com you wrote:
The attached patch fixes the FEC problems on my Lite5200 board. The network is working without any problems at 10 and 100Mb. The auto-negociation works too.
If CONFIG_FEC_10MBIT is defined, the FEC works at 10Mb with Half-Duplex. If CONFIG_FEC_10MBIT is undefined, the MII reads its configuration from hardware and uses the auto-negociation for determining network speed. The patch undefines CONFIG_FEC_10MBIT for the Lite5200.
Does it work for the other MPC5xxx boards ?
From what we saw, the FEC driver in U-Boot used to work quite stably,
until the IDE support was added. May be that was just a coincidence, but it seems obvious to me that something changed in U-Boot recently that broke the FEC driver. It is possible that "something" was not the IDE support in fact, but yet something else.
The MII initialization code used to work fine for us, as far as we were able to tell. Without having investigated this more closely, I will not check in this patch as I feel it might just fix some symptoms.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 40629804.5060107@staubli.com you wrote:
The attached patch fixes the FEC problems on my Lite5200 board. The network is working without any problems at 10 and 100Mb. The auto-negociation works too.
If CONFIG_FEC_10MBIT is defined, the FEC works at 10Mb with Half-Duplex. If CONFIG_FEC_10MBIT is undefined, the MII reads its configuration from hardware and uses the auto-negociation for determining network speed. The patch undefines CONFIG_FEC_10MBIT for the Lite5200.
Does it work for the other MPC5xxx boards ?
From what we saw, the FEC driver in U-Boot used to work quite stably, until the IDE support was added. May be that was just a coincidence, but it seems obvious to me that something changed in U-Boot recently that broke the FEC driver. It is possible that "something" was not the IDE support in fact, but yet something else.
On my side, I had the timeouts problems on tftp transferts from the begining. IDE support didn't change anything, the problem exists before.
The MII initialization code used to work fine for us, as far as we were able to tell. Without having investigated this more closely, I will not check in this patch as I feel it might just fix some symptoms.
For me, this init is useless, the MII takes its configuration from hardware. On MPC8xx boards, there's no such init sequence and FEC works fine for all boards.
Best regards,
Wolfgang Denk
Best regards

In message 4062A3C1.40107@staubli.com you wrote:
On my side, I had the timeouts problems on tftp transferts from the begining. IDE support didn't change anything, the problem exists before.
It would be interesting to know if there were some components in your setup that you were not able to replace:
LITE5200 board network cable(s) switch(es) / hub(s) TFTP server
Only if you were able to replace each of them, and the problem persisted, I am convinced of a problem with the code.
We had several boards, both with MGT5100 and MPC5200, with SDRAM and DDR, in several layour versions of the IceCube / LITE board, and additionally some custom boards. Never had that sort of problem until around the time the IDE stuff was checked in.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 4062A3C1.40107@staubli.com you wrote:
On my side, I had the timeouts problems on tftp transferts from the begining. IDE support didn't change anything, the problem exists before.
It would be interesting to know if there were some components in your setup that you were not able to replace:
LITE5200 board network cable(s) switch(es) / hub(s) TFTP server
I've made some tests with several tftp servers (Unix servers and PC servers). Of course, I've tried several cables and severals ports on several switches. I've also made some tests with a direct connection between a PC and my Lite5200 with same results (in this case, timeouts are rare, but it happens sometimes). Unfortunately, I've got only one Lite5200 board but other people have same problems (see thread http://sourceforge.net/mailarchive/forum.php?thread_id=4080201&forum_id=...) I think that my board is OK because I don't have any problem with the FEC under my operating system.
Only if you were able to replace each of them, and the problem persisted, I am convinced of a problem with the code.
We had several boards, both with MGT5100 and MPC5200, with SDRAM and DDR, in several layour versions of the IceCube / LITE board, and additionally some custom boards. Never had that sort of problem until around the time the IDE stuff was checked in.
Best regards,
Wolfgang Denk
Best regards
participants (2)
-
Pierre AUBERT
-
Wolfgang Denk