[U-Boot] [PATCH v2 04/11] serial: Use a more precise baud rate generation for serial_s3c24x0

Marek Vasut
2012-09-14T18:05:12Z

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