From mboxrd@z Thu Jan 1 00:00:00 1970 From: Felix Radensky Date: Thu, 28 May 2009 23:20:26 +0300 Subject: [U-Boot] Incorrect MDIO clock setup in 4xx network driver Message-ID: <4A1EF20A.5040807@embedded-sol.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, The following piece of code in ppc_4xx_eth_init() results in incorrect MDIO clock setup on Canyonlands, in the case when OPB clock is 100Mhz /* Whack the M1 register */ mode_reg = 0x0; mode_reg &= ~0x00000038; if (sysinfo.freqOPB <= 50000000); else if (sysinfo.freqOPB <= 66666667) mode_reg |= EMAC_M1_OBCI_66; else if (sysinfo.freqOPB <= 83333333) mode_reg |= EMAC_M1_OBCI_83; else if (sysinfo.freqOPB <= 100000000) mode_reg |= EMAC_M1_OBCI_100; else mode_reg |= EMAC_M1_OBCI_GT100; out_be32((void *)EMAC_M1 + hw_p->hw_addr, mode_reg); When OPB clock runs at 100Mhz, the value of sysinfo.freqOPB is 100000001, so this code configures MDC clock to 3.3Mhz instead of less than 2.5Hz. This is not a problem on Canyonlands, where Marvell PHY MDIO clock can run at 8.3Mhz. However other PHYs may actually require MDIO clock to be less than 2.5Mhz. How about rewriting this code as freq = sysinfo.freqOPB / 1000000; if (freq <= 50) else if (freq <= 66) mode_reg |= EMAC_M1_OBCI_66; else if (freq <= 83) mode_reg |= EMAC_M1_OBCI_83; else if (freq <= 100) mode_reg |= EMAC_M1_OBCI_100; else mode_reg |= EMAC_M1_OBCI_GT100; Felix.