[Patch v.2] mpc5200b/uart: improve baud rate calculation (reach high baud rates, better accuracy)

Albrecht Dreß albrecht.dress at arcor.de
Thu Mar 4 20:56:46 EST 2010


Hi Grant:

Thanks a lot for your input!

[snip]
> Save yourself some duplicated code here.  The above 14 lines can be
> shared between the 512x, 52xx and 5200b versions.  Create yourself an
> internal __mpc5xxx_psc_set_divisor() function that is passed the *psc,
> the divisor, and the clock select register setting (both the 5200 and
> the 5121 have the clock select register).

Hmm, yes, that's true.  Will look into that.

[snip]
> > @@ -604,7 +676,6 @@ mpc52xx_uart_set_termios(struct uart_por
> >
> >        baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16);
> 
> I'm probably nitpicking, because I don't know if the io pin will
> handle this speed but uartclk/16 is no longer the maximum baudrate if
> a /4 prescaler is used.

Yes, you are right. Must of course be fixed.

[snip]
> > @@ -635,8 +706,7 @@ mpc52xx_uart_set_termios(struct uart_por
> >        out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1);
> >        out_8(&psc->mode, mr1);
> >        out_8(&psc->mode, mr2);
> > -       out_8(&psc->ctur, ctr >> 8);
> > -       out_8(&psc->ctlr, ctr & 0xff);
> > +       psc_ops->set_divisor(port, quot);
> 
> Hmmm.  The divisor calculations have some tricky bits to them.  I
> would consider changing the set_divisor() function to accept a baud
> rate, and modify the set_divisor function to call uart_get_divisor().

That sounds like a good idea to me.  I will change the code that way.

> That way each set_divisor() can do whatever makes the most sense for
> the divisors available to it.  The 5121 for example has both a /10 and
> a /32 divisor, plus it can use an external clock.

Ouch.  I don't have a 512x, but isn't the current code plain wrong then?  It uses mpc5xxx_get_bus_frequency() as input for the baud rate calculation, and if the serial code assumes /16 instead of /10, the result must be terribly off.  Or did I miss something here?

Best, Albrecht.

Tolle Dekolletés oder scharfe Tatoos? Vote jetzt ... oder mach selbst mit und zeige Deine Schokoladenseite
bei Topp oder Hopp von Arcor: http://www.arcor.de/rd/footer.toh


More information about the Linuxppc-dev mailing list