public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] NET: fec_mxc: fix MDIO clock prescaler calculation
@ 2014-02-05  9:54 Markus Niebel
  2014-02-11  9:51 ` Stefano Babic
  2014-02-11 10:34 ` Stefano Babic
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Niebel @ 2014-02-05  9:54 UTC (permalink / raw)
  To: u-boot

From: Markus Niebel <Markus.Niebel@tqs.de>

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 <Markus.Niebel@tqs.de>
---
 drivers/net/fec_mxc.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 3b2b995..4cefda4 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,
-			&eth->mii_speed);
+	register u32 speed = DIV_ROUND_UP(imx_get_fecclk(), 5000000);
+#ifdef FEC_QUIRK_ENET_MAC
+	speed--;
+#endif
+	speed <<= 1;
+	writel(speed, &eth->mii_speed);
 	debug("%s: mii_speed %08x\n", __func__, readl(&eth->mii_speed));
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] NET: fec_mxc: fix MDIO clock prescaler calculation
  2014-02-05  9:54 [U-Boot] [PATCH] NET: fec_mxc: fix MDIO clock prescaler calculation Markus Niebel
@ 2014-02-11  9:51 ` Stefano Babic
  2014-02-11 10:34 ` Stefano Babic
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Babic @ 2014-02-11  9:51 UTC (permalink / raw)
  To: u-boot

Hi Marcus,

On 05/02/2014 10:54, Markus Niebel wrote:
> From: Markus Niebel <Markus.Niebel@tqs.de>
> 
> 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 <Markus.Niebel@tqs.de>
> ---
>  drivers/net/fec_mxc.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 3b2b995..4cefda4 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,
> -			&eth->mii_speed);
> +	register u32 speed = DIV_ROUND_UP(imx_get_fecclk(), 5000000);
> +#ifdef FEC_QUIRK_ENET_MAC
> +	speed--;
> +#endif
> +	speed <<= 1;
> +	writel(speed, &eth->mii_speed);
>  	debug("%s: mii_speed %08x\n", __func__, readl(&eth->mii_speed));
>  }

Thanks for this - I go for merging..


Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] NET: fec_mxc: fix MDIO clock prescaler calculation
  2014-02-05  9:54 [U-Boot] [PATCH] NET: fec_mxc: fix MDIO clock prescaler calculation Markus Niebel
  2014-02-11  9:51 ` Stefano Babic
@ 2014-02-11 10:34 ` Stefano Babic
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Babic @ 2014-02-11 10:34 UTC (permalink / raw)
  To: u-boot

On 05/02/2014 10:54, Markus Niebel wrote:
> From: Markus Niebel <Markus.Niebel@tqs.de>
> 
> 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 <Markus.Niebel@tqs.de>
> ---


Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-11 10:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05  9:54 [U-Boot] [PATCH] NET: fec_mxc: fix MDIO clock prescaler calculation Markus Niebel
2014-02-11  9:51 ` Stefano Babic
2014-02-11 10:34 ` Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox