[PATCH 1/2 v4] fs_enet/mii-fec.c: fix MII speed calculation

Grant Likely grant.likely at secretlab.ca
Fri Jul 17 08:44:21 EST 2009


On Thu, Jul 16, 2009 at 3:42 PM, Wolfgang Denk<wd at denx.de> wrote:
> The MII speed calculation was based on the CPU clock (ppc_proc_freq),
> but for MPC512x we must use the bus clock instead.
>
> This patch makes it use the correct clock and makes sure we don't
> clobber reserved bits in the MII_SPEED register.
>
> Signed-off-by: Wolfgang Denk <wd at denx.de>
> Cc: Grant Likely <grant.likely at secretlab.ca>
> Cc: Kumar Gala <galak at kernel.crashing.org>
> Cc: <netdev at vger.kernel.org>

Looks good to me.  Thanks for the work!

I assume this is tested.  I have not tested this on my board, and I've
got one question below, but otherwise I think I can say....
Acked-by: Grant Likely <grant.likely at secretlab.ca>

> -       fec->mii_speed = ((ppc_proc_freq + 4999999) / 5000000) << 1;
> +       if (get_bus_freq) {
> +               clock = get_bus_freq(ofdev->node);
> +
> +               if (!clock) {
> +                       dev_err(&ofdev->dev, "could not determine IPS/IPB clock\n");
> +                       goto out_unmap_regs;
> +               }
> +       } else
> +               clock = ppc_proc_freq;
> +
> +       /* scale for a MII clock <= 2.5 MHz */
> +       speed = (clock + 2499999) / 2500000;

The calculation has changed here for non mpc5121 users.  Shouldn't the
"clock = ppc_proc_freq;" line above be "clock = ppc_proc_freq / 2;"?
Or was this also a bug in the original driver?

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.


More information about the Linuxppc-dev mailing list