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

Wolfgang Denk wd at denx.de
Mon Aug 24 12:12:19 CEST 2009


Dear Renato Andreola,

In message <4A9259BF.3030200 at imagos.it> you wrote:
>  From eae7788c435cfab344c9741c9501475e9ab2797a Mon Sep 17 00:00:00 2001
> From: Renato Andreola <renato.andreola at imagos.it>
> Date: Mon, 24 Aug 2009 11:10:44 +0200
> Subject: [PATCH] Yanu Support for U-Boot
> 
> with this patch YANU uart (from opencores) support will be added to u-boot.
> Remember to modify properly your board files for defining physical
> address etc etc
> ---
>   cpu/nios2/serial.c   |  170 +++++++++++++++++++++++++++++++++++++++++++++++++-
>   include/nios2-yanu.h |  122 ++++++++++++++++++++++++++++++++++++
>   2 files changed, 291 insertions(+), 1 deletions(-)
>   create mode 100644 include/nios2-yanu.h
> 
> diff --git a/cpu/nios2/serial.c b/cpu/nios2/serial.c
> index 8bbb803..84be160 100644
> --- a/cpu/nios2/serial.c
> +++ b/cpu/nios2/serial.c
> @@ -26,6 +26,7 @@
>   #include <watchdog.h>
>   #include <asm/io.h>
>   #include <nios2-io.h>
> +#include <nios2-yanu.h>

This patch is white-space corrupted. Please fix your mailer settings.


>   DECLARE_GLOBAL_DATA_PTR;
> 
> @@ -74,10 +75,177 @@ int serial_getc (void)
>   	return (c);
>   }
> 
> +#elif defined(CONFIG_CONSOLE_YANU)
> +/*-----------------------------------------------------------------*/
> +/* YANU Imagos serial port */
> +/*-----------------------------------------------------------------*/
> +
> +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)

Incorrect brace style.
Line too long.

> +		{
> +			best_n = n;
> +			break;
> +		}
> +	}
> +	for (k=0; ; k++)
> +	{
> +		if ((unsigned)CONFIG_BAUDRATE <= (max_uns >> (15+n-k)))
> +			break;
> +	}

Incorrect brace style.

> +	best_m = ((unsigned)CONFIG_BAUDRATE * (1 << (15+n-k))) / ((unsigned)CONFIG_SYS_CLK_FREQ >> k);

Line too long.

> +void serial_setbrg (void)
> +{
> +	DECLARE_GLOBAL_DATA_PTR;

This must be done _outside_ any function body.

> +	/* compute best N and M couple */
> +	best_n = YANU_MAX_PRESCALER_N;
> +	for (n = YANU_MAX_PRESCALER_N; n >= 0; n--)
> +	{

Incorrect brace style.

> +		if ((unsigned)CONFIG_SYS_CLK_FREQ / (1 << (n+4)) >= gd->baudrate)
> +		{

Incorrect brace style.
Line too long.

> +			best_n = n;
> +			break;
> +		}
> +	}
> +	for (k=0; ; k++)
> +	{

Incorrect brace style.

> +		if (gd->baudrate <= (max_uns >> (15+n-k)))
> +			break;
> +	}
> +	best_m = (gd->baudrate * (1 << (15+n-k))) / ((unsigned)CONFIG_SYS_CLK_FREQ >> k);

Line too long.


etc. etc.

> +typedef volatile struct yanu_uart_t
> +{
> +	volatile unsigned data;
> +/* control register (RW) 32-bit   */
> +	volatile unsigned control;
> +/* baud/prescaler register (RW) 32-bit */
> +	volatile unsigned baud;
> +/* action register (W) 32-bit */
> +	volatile unsigned action;
> +/* status register (R) 32-bit */
> +	volatile unsigned status;
> +/* magic register (R) 32-bit */
> +	volatile unsigned magic;
> +} yanu_uart_t;

Place comments on the same line with the declaration, please.


Please clean up and resubmit.

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
A star captain's most solemn oath is that he will give his life, even
his entire crew, rather than violate the Prime Directive.
	-- Kirk, "The Omega Glory", stardate unknown


More information about the U-Boot mailing list