[Patch] mpc5200b: improve baud rate calculation (reach high baud rates, better accuracy)
grant.likely at secretlab.ca
Wed Mar 3 07:22:08 EST 2010
Thanks for this work, comment below...
On Mon, Mar 1, 2010 at 11:11 AM, Albrecht Dreß <albrecht.dress at arcor.de> wrote:
> On the MPC5200B, select the baud rate prescaler as /4 by default to make very
> high baud rates (e.g. 3 MBaud) accessible and to achieve a higher precision
> for high baud rates in general. For baud rates below ~500 Baud, the code will
> automatically fall back to the /32 prescaler. The original MPC5200 does only
> have a /32 prescaler which is detected only once and stored in a global. A
> new chip-dependent method is used to set the divisor.
> Tested on a custom 5200B based board, with up to 3 MBaud.
> Signed-off-by: Albrecht Dreß <albrecht.dress at arcor.de>
> --- linux-2.6.33/drivers/serial/mpc52xx_uart.c.orig 2010-02-24 19:52:17.000000000 +0100
> +++ linux-2.6.33/drivers/serial/mpc52xx_uart.c 2010-02-26 21:12:51.000000000 +0100
> /* Search for bus-frequency property in this node or a parent */
> static unsigned long mpc52xx_getuartclk(void *p)
> - * 5200 UARTs have a / 32 prescaler
> - * but the generic serial code assumes 16
> - * so return ipb freq / 2
> + * The 5200 has only /32 prescalers.
> + * 5200B UARTs have a /4 or a /32 prescaler. For higher accuracy, we
> + * do all calculations using the /4 prescaler for this chip.
> + * The generic serial code assumes /16 so return ipb freq / 2 (5200)
> + * or ipb freq * 4 (5200B).
> - return mpc5xxx_get_bus_frequency(p) / 2;
> + if (is_mpc5200b == 1)
> + return mpc5xxx_get_bus_frequency(p) * 4;
> + else
> + return mpc5xxx_get_bus_frequency(p) / 2;
Remove this function entirely and the associated .getuartclk() hook
from the psc_ops structure. Callers can just call
mpc5xxx_get_bus_frequency() directly. mpc5121 already just passes
back the return value unmodified, and current mpc52xx code uses a /2,
but that would be eliminated if the new set_divisor hook took that
into account. That way all the chip-specific clock setup calculation
is consolidated into a single function. I like patches that make
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
More information about the Linuxppc-dev