[U-Boot] PATCH - Added support to YANU Nios2 uart

Wolfgang Denk wd at denx.de
Thu Aug 6 15:27:08 CEST 2009


Dear Renato Andreola,

In message <4A7AD72A.4030004 at imagos.it> you wrote:
>  From 6e15ffc680ca75d5bd3a01fc9010c34637c6ab32 Mon Sep 17 00:00:00 2001
> From: Renato Andreola <renato.andreola at imagos.it>
> Date: Thu, 6 Aug 2009 12:28:51 +0200
> Subject: [PATCH] Yanu Support for U-Boot
> 
> with this patch YANU uart support will be added to u-boot.
> Remember to modify properly your board files for defining physical 
> address etc etc
> 
> Signed-off-by: Renato Andreola renato.andreola at imagos.it
> ---
>   cpu/nios2/serial.c   |  158 
> +++++++++++++++++++++++++++++++++++++++++++++++++-
>   include/nios2-yanu.h |  119 +++++++++++++++++++++++++++++++++++++
>   2 files changed, 276 insertions(+), 1 deletions(-)
>   create mode 100644 include/nios2-yanu.h
> 
> diff --git a/cpu/nios2/serial.c b/cpu/nios2/serial.c
> index 8bbb803..e77b2c6 100644
> --- a/cpu/nios2/serial.c
> +++ b/cpu/nios2/serial.c
> @@ -26,6 +26,8 @@
>   #include <watchdog.h>
>   #include <asm/io.h>
>   #include <nios2-io.h>
> +#include <nios2-yanu.h>
> +

This patch is seriously white-space corrupted. Please use
git-send-email to submit patches.

> +/*------------------------------------------------------------------
> + * YANU Imagos serial port
> + *-----------------------------------------------------------------*/
> +#elif defined(CONFIG_CONSOLE_YANU)

Incorrect multiline comment. Check globally.

And should the comment not go below the #elif ?

> +static yanu_uart_t *uart = (yanu_uart_t *)CONFIG_SYS_NIOS_CONSOLE;
> +
> +#if defined(CONFIG_NIOS_FIXEDBAUD)
> +
> +/* Everything's already setup for fixed-baud PTF
> + * assignment
> + */
> +void serial_setbrg (void) {
> +	int n, k;
> +	const unsigned max_uns = 0xFFFFFFFF;
> +	unsigned best_n, best_m, baud;
> +
> +	/* compute best N and M couple */
> +	best_n = YANU_MAX_PRESCALER_N;
> +	for (n = YANU_MAX_PRESCALER_N; n >= 0; n--)
> +		if ((unsigned)CONFIG_SYS_CLK_FREQ / (1 << (n+4)) >= 
> (unsigned)CONFIG_BAUDRATE) {

Patch also line-wrapped.

...
> +	best_n = YANU_MAX_PRESCALER_N;
> +	for (n = YANU_MAX_PRESCALER_N; n >= 0; n--)
> +		if ((unsigned)CONFIG_SYS_CLK_FREQ / (1 << (n+4)) >= gd->baudrate) {
> +			best_n = n;
> +			break;
> +		}

Please use braces around multi-line statements.

> +	for (k=0; ; k++)
> +		if (gd->baudrate <= (max_uns >> (15+n-k)))
> +			break;

Ditto.

> +void serial_putc (char c)
> +{
> +	int tx_chars;
> +	unsigned status;
> +
> +	if (c == '\n')
> +		serial_putc ('\r');
> +	
> +	while (1)
> +	{
> +		status = readl(&uart->status);
> +		tx_chars = (status>>YANU_TFIFO_CHARS_POS) & ((1<<YANU_TFIFO_CHARS_N)-1);

Line too long. Check globally.

> +		if (tx_chars < YANU_TXFIFO_SIZE-1)
> +			break;
> +		WATCHDOG_RESET ();
> +	}

Incorrect brace style. Check globally.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Deliver yesterday, code today, think tomorrow."


More information about the U-Boot mailing list