From 67c7189dd35cb368ef665126fd17816581bd2e92 Mon Sep 17 00:00:00 2001 From: Renato Andreola Date: Tue, 16 Mar 2010 16:01:29 -0400 Subject: nios2: Added support to YANU UART Signed-off-by: Scott McNutt --- cpu/nios2/serial.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 167 insertions(+), 1 deletion(-) (limited to 'cpu') diff --git a/cpu/nios2/serial.c b/cpu/nios2/serial.c index 8bbb803a68..6c835af4b1 100644 --- a/cpu/nios2/serial.c +++ b/cpu/nios2/serial.c @@ -2,6 +2,9 @@ * (C) Copyright 2004, Psyent Corporation * Scott McNutt * + * YANU Support: + * Copyright 2010, Renato Andreola + * * See file CREDITS for list of people who contributed to this * project. * @@ -26,6 +29,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -74,10 +78,172 @@ 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_SYS_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) { + best_n = n; + break; + } + } + for (k = 0;; k++) { + if ((unsigned)CONFIG_BAUDRATE <= (max_uns >> (15+n-k))) + break; + } + best_m = + ((unsigned)CONFIG_BAUDRATE * (1 << (15 + n - k))) / + ((unsigned)CONFIG_SYS_CLK_FREQ >> k); + + baud = best_m + best_n * YANU_BAUDE; + writel(&uart->baud, baud); + + return; +} + +#else + +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)) >= + gd->baudrate) { + best_n = n; + break; + } + } + for (k = 0;; k++) { + if (gd->baudrate <= (max_uns >> (15+n-k))) + break; + } + best_m = + (gd->baudrate * (1 << (15 + n - k))) / + ((unsigned)CONFIG_SYS_CLK_FREQ >> k); + + baud = best_m + best_n * YANU_BAUDE; + writel(&uart->baud, baud); + + return; +} + + +#endif /* CONFIG_SYS_NIOS_FIXEDBAUD */ + +int serial_init (void) +{ + unsigned action,control; + + /* status register cleanup */ + action = YANU_ACTION_RRRDY | + YANU_ACTION_RTRDY | + YANU_ACTION_ROE | + YANU_ACTION_RBRK | + YANU_ACTION_RFE | + YANU_ACTION_RPE | + YANU_ACTION_RFE | YANU_ACTION_RFIFO_CLEAR | YANU_ACTION_TFIFO_CLEAR; + + writel(&uart->action, action); + + /* control register cleanup */ + /* no interrupts enabled */ + /* one stop bit */ + /* hardware flow control disabled */ + /* 8 bits */ + control = (0x7 << YANU_CONTROL_BITS_POS); + /* enven parity just to be clean */ + control |= YANU_CONTROL_PAREVEN; + /* we set threshold for fifo */ + control |= YANU_CONTROL_RDYDLY * YANU_RXFIFO_DLY; + control |= YANU_CONTROL_TXTHR * YANU_TXFIFO_THR; + + writel(&uart->control, control); + + /* to set baud rate */ + serial_setbrg(); + + return (0); +} + + +/*----------------------------------------------------------------------- + * YANU CONSOLE + *---------------------------------------------------------------------*/ +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<data, (unsigned char)c); +} + +void serial_puts (const char *s) +{ + while (*s != 0) { + serial_putc (*s++); + } +} + + +int serial_tstc(void) +{ + unsigned status ; + + status = readl(&uart->status); + return (((status >> YANU_RFIFO_CHARS_POS) & + ((1 << YANU_RFIFO_CHARS_N) - 1)) > 0); +} + +int serial_getc (void) +{ + while (serial_tstc() == 0) + WATCHDOG_RESET (); + + /* first we pull the char */ + writel(&uart->action, YANU_ACTION_RFIFO_PULL); + + return(readl(&uart->data) & YANU_DATA_CHAR_MASK); +} + +#else /*CONFIG_CONSOLE_YANU*/ + /*------------------------------------------------------------------ * UART the serial port *-----------------------------------------------------------------*/ -#else static nios_uart_t *uart = (nios_uart_t *) CONFIG_SYS_NIOS_CONSOLE; -- cgit v1.2.1 From 5647f78d04174b0b99857d2a7cbf25141bd14a45 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Sat, 13 Mar 2010 23:14:45 +0100 Subject: mod change 755 => 644 for multiple files I executed 'find . -name "*.[chS]" -perm 755 -exec chmod 644 {} \;' Signed-off-by: Thomas Weber Add some more: neither Makefile nor config.mk need execute permissions. Signed-off-by: Wolfgang Denk --- cpu/arm926ejs/spear/Makefile | 0 cpu/arm926ejs/spear/reset.c | 0 cpu/arm926ejs/spear/timer.c | 0 cpu/arm926ejs/versatile/timer.c | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 cpu/arm926ejs/spear/Makefile mode change 100755 => 100644 cpu/arm926ejs/spear/reset.c mode change 100755 => 100644 cpu/arm926ejs/spear/timer.c mode change 100755 => 100644 cpu/arm926ejs/versatile/timer.c (limited to 'cpu') diff --git a/cpu/arm926ejs/spear/Makefile b/cpu/arm926ejs/spear/Makefile old mode 100755 new mode 100644 diff --git a/cpu/arm926ejs/spear/reset.c b/cpu/arm926ejs/spear/reset.c old mode 100755 new mode 100644 diff --git a/cpu/arm926ejs/spear/timer.c b/cpu/arm926ejs/spear/timer.c old mode 100755 new mode 100644 diff --git a/cpu/arm926ejs/versatile/timer.c b/cpu/arm926ejs/versatile/timer.c old mode 100755 new mode 100644 -- cgit v1.2.1 From 51c2ac9bb574c1420b993615268392b0c1f829f6 Mon Sep 17 00:00:00 2001 From: Anatolij Gustschin Date: Tue, 16 Mar 2010 17:10:08 +0100 Subject: mpc5121: cpu/mpc512x/diu.c: fix warnings Fix warnings while compiling with CONFIG_VIDEO enabled: diu.c: In function 'video_hw_init': diu.c:158: warning: 'return' with no value, in function returning non-void diu.c:162: warning: format '%ld' expects type 'long int', but argument 6 has type 'int' diu.c:162: warning: format '%ld' expects type 'long int', but argument 7 has type 'int' Signed-off-by: Anatolij Gustschin --- cpu/mpc512x/diu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cpu') diff --git a/cpu/mpc512x/diu.c b/cpu/mpc512x/diu.c index a24f39510e..ca459a101e 100644 --- a/cpu/mpc512x/diu.c +++ b/cpu/mpc512x/diu.c @@ -145,10 +145,10 @@ void *video_hw_init(void) struct fb_info *info; if (mpc5121_diu_init() < 0) - return; + return NULL; /* fill in Graphic device struct */ - sprintf(pGD->modeIdent, "%dx%dx%d %ldkHz %ldHz", + sprintf(pGD->modeIdent, "%dx%dx%d %dkHz %dHz", xres, yres, 32, 64, 60); pGD->frameAdrs = (unsigned int)fsl_fb_open(&info); -- cgit v1.2.1