[U-Boot-Users] at91rm9200 serial frequency fix

Ulf Samuelsson ulf at atmel.com
Sun Aug 19 20:32:52 CEST 2007


sön 2007-08-19 klockan 18:35 +0200 skrev michael trimarchi:
> Fix CD calcutation on serial device.
> 
> Signed-off-by: Trimarchi Michael <trimarchimichael at yahoo.it>
> ---
> 
> --- cpu/arm920t/at91rm9200/serial.c.orig	2007-08-19 19:26:23.000000000 +0200
> +++ cpu/arm920t/at91rm9200/serial.c	2007-08-19 19:29:50.000000000 +0200
> @@ -50,14 +50,18 @@ AT91PS_USART us = (AT91PS_USART) AT91C_B
>  AT91PS_USART us = (AT91PS_USART) AT91C_BASE_US1;
>  #endif
>  
> +#define BAUDRATE(mck, baud) \
> +	((((mck) * 10) % ((baud) * 16)) >= 5) ? \
> +	(mck / (baud * 16) + 1) : ((mck) / (baud * 16))
> +
>  void serial_setbrg (void)
>  {
>  	int baudrate;
>  
>  	if ((baudrate = gd->baudrate) <= 0)
>  		baudrate = CONFIG_BAUDRATE;
> -	/* MASTER_CLOCK/(16 * baudrate) */
> -	us->US_BRGR = (AT91C_MASTER_CLOCK >> 4) / (unsigned)baudrate;
> +
> +	us->US_BRGR = BOUDRATE(AT91C_MASTER_CLOCK, (unsigned)baudrate);
>  }

You should read the part of the documentation where is says that
you should test any patch before sending it to the list.

You have obviously not tested your patch before use,
since there is a spelling error.
BAUDRATE != BOUDRATE

Pls reject this patch.

BR
Ulf Samuelsson






More information about the U-Boot mailing list