From: Markus Niebel Date: Wed, 5 Feb 2014 09:54:11 +0000 (+0100) Subject: NET: fec_mxc: fix MDIO clock prescaler calculation X-Git-Tag: v2014.04-rc2~127^2~1^2~3 X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-uboot.git;a=commitdiff_plain;h=6ba45cc0f8b46533965219cfd90864a60ec1009b NET: fec_mxc: fix MDIO clock prescaler calculation The prescaler value for MDC is calculated wrong for MX6S. Implement the same logic as linux here which handles ENET_MAC different then original FEC. Tested on a custom board with i.MX6S and 100MBit PHY Signed-off-by: Markus Niebel --- diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 3b2b995b53..4cefda48e4 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -128,8 +128,12 @@ static void fec_mii_setspeed(struct ethernet_regs *eth) * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock * and do not drop the Preamble. */ - writel((((imx_get_fecclk() / 1000000) + 2) / 5) << 1, - ð->mii_speed); + register u32 speed = DIV_ROUND_UP(imx_get_fecclk(), 5000000); +#ifdef FEC_QUIRK_ENET_MAC + speed--; +#endif + speed <<= 1; + writel(speed, ð->mii_speed); debug("%s: mii_speed %08x\n", __func__, readl(ð->mii_speed)); }