[U-Boot] [PATCH v2 04/11] serial: Use a more precise baud rate generation for serial_s3c24x0
Marek Vasut
marex at denx.de
Fri Sep 14 20:05:12 CEST 2012
Dear José Miguel Gonçalves,
> Program udivslot register in order to obtain a more precise baudrate.
More explanatory commit message would be nice.
[...]
> +static const int udivslot[] = {
const array const members, no ?
> + 0x0000, 0x0080, 0x0808, 0x0888, 0x2222, 0x4924, 0x4A52, 0x54AA,
> + 0x5555, 0xD555, 0xD5D5, 0xDDD5, 0xDDDD, 0xDFDD, 0xDFDF, 0xFFDF,
> +};
> +
> void _serial_setbrg(const int dev_index)
> {
> struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
> - unsigned int reg = 0;
> + u32 pclk;
> + u32 baudrate;
> int i;
>
> - /* value is calculated so : (int)(PCLK/16./baudrate) -1 */
> - reg = get_PCLK() / (16 * gd->baudrate) - 1;
> + pclk = get_PCLK();
> + baudrate = gd->baudrate;
>
> - writel(reg, &uart->ubrdiv);
> + writel((pclk / baudrate / 16) - 1, &uart->ubrdiv);
> + writel(udivslot[(pclk / baudrate) % 16], &uart->udivslot);
> for (i = 0; i < 100; i++)
> /* Delay */ ;
> }
Best regards,
Marek Vasut
More information about the U-Boot
mailing list