summaryrefslogtreecommitdiff
path: root/board/cogent/serial.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@pollux.denx.de>2006-03-31 18:32:53 +0200
committerWolfgang Denk <wd@pollux.denx.de>2006-03-31 18:32:53 +0200
commitd87080b721e4f8dca977af7571c5338ae7bb8db7 (patch)
tree514fc21eec39a2dd57f7aea516844a4400f8f140 /board/cogent/serial.c
parentf6dbbe986481cff01334c64cacb971a5f237a9a9 (diff)
downloadu-boot-imx-d87080b721e4f8dca977af7571c5338ae7bb8db7.zip
u-boot-imx-d87080b721e4f8dca977af7571c5338ae7bb8db7.tar.gz
u-boot-imx-d87080b721e4f8dca977af7571c5338ae7bb8db7.tar.bz2
GCC-4.x fixes: clean up global data pointer initialization for all boards.
Diffstat (limited to 'board/cogent/serial.c')
-rw-r--r--board/cogent/serial.c167
1 files changed, 75 insertions, 92 deletions
diff --git a/board/cogent/serial.c b/board/cogent/serial.c
index 4c20017..2b595a8 100644
--- a/board/cogent/serial.c
+++ b/board/cogent/serial.c
@@ -6,6 +6,8 @@
#include <common.h>
#include <board/cogent/serial.h>
+DECLARE_GLOBAL_DATA_PTR;
+
#if (CMA_MB_CAPS & CMA_MB_CAP_SERPAR)
#if (defined(CONFIG_8xx) && defined(CONFIG_8xx_CONS_NONE)) || \
@@ -25,76 +27,65 @@
int serial_init (void)
{
-/* DECLARE_GLOBAL_DATA_PTR; */
-
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_SERIAL_BASE;
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_SERIAL_BASE;
- cma_mb_reg_write(&mbsp->ser_ier, 0x00); /* turn off interrupts */
- serial_setbrg ();
- cma_mb_reg_write(&mbsp->ser_lcr, 0x03); /* 8 data, 1 stop, no parity */
- cma_mb_reg_write(&mbsp->ser_mcr, 0x03); /* RTS/DTR */
- cma_mb_reg_write(&mbsp->ser_fcr, 0x07); /* Clear & enable FIFOs */
+ cma_mb_reg_write (&mbsp->ser_ier, 0x00); /* turn off interrupts */
+ serial_setbrg ();
+ cma_mb_reg_write (&mbsp->ser_lcr, 0x03); /* 8 data, 1 stop, no parity */
+ cma_mb_reg_write (&mbsp->ser_mcr, 0x03); /* RTS/DTR */
+ cma_mb_reg_write (&mbsp->ser_fcr, 0x07); /* Clear & enable FIFOs */
- return (0);
+ return (0);
}
-void
-serial_setbrg (void)
+void serial_setbrg (void)
{
- DECLARE_GLOBAL_DATA_PTR;
-
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_SERIAL_BASE;
- unsigned int divisor;
- unsigned char lcr;
-
- if ((divisor = br_to_div(gd->baudrate)) == 0)
- divisor = DEFDIV;
-
- lcr = cma_mb_reg_read(&mbsp->ser_lcr);
- cma_mb_reg_write(&mbsp->ser_lcr, lcr|0x80);/* Access baud rate(set DLAB)*/
- cma_mb_reg_write(&mbsp->ser_brl, divisor & 0xff);
- cma_mb_reg_write(&mbsp->ser_brh, (divisor >> 8) & 0xff);
- cma_mb_reg_write(&mbsp->ser_lcr, lcr); /* unset DLAB */
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_SERIAL_BASE;
+ unsigned int divisor;
+ unsigned char lcr;
+
+ if ((divisor = br_to_div (gd->baudrate)) == 0)
+ divisor = DEFDIV;
+
+ lcr = cma_mb_reg_read (&mbsp->ser_lcr);
+ cma_mb_reg_write (&mbsp->ser_lcr, lcr | 0x80); /* Access baud rate(set DLAB) */
+ cma_mb_reg_write (&mbsp->ser_brl, divisor & 0xff);
+ cma_mb_reg_write (&mbsp->ser_brh, (divisor >> 8) & 0xff);
+ cma_mb_reg_write (&mbsp->ser_lcr, lcr); /* unset DLAB */
}
-void
-serial_putc(const char c)
+void serial_putc (const char c)
{
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_SERIAL_BASE;
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_SERIAL_BASE;
- if (c == '\n')
- serial_putc('\r');
+ if (c == '\n')
+ serial_putc ('\r');
- while ((cma_mb_reg_read(&mbsp->ser_lsr) & LSR_THRE) == 0)
- ;
+ while ((cma_mb_reg_read (&mbsp->ser_lsr) & LSR_THRE) == 0);
- cma_mb_reg_write(&mbsp->ser_thr, c);
+ cma_mb_reg_write (&mbsp->ser_thr, c);
}
-void
-serial_puts(const char *s)
+void serial_puts (const char *s)
{
- while (*s != '\0')
- serial_putc(*s++);
+ while (*s != '\0')
+ serial_putc (*s++);
}
-int
-serial_getc(void)
+int serial_getc (void)
{
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_SERIAL_BASE;
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_SERIAL_BASE;
- while ((cma_mb_reg_read(&mbsp->ser_lsr) & LSR_DR) == 0)
- ;
+ while ((cma_mb_reg_read (&mbsp->ser_lsr) & LSR_DR) == 0);
- return ((int)cma_mb_reg_read(&mbsp->ser_rhr) & 0x7f);
+ return ((int) cma_mb_reg_read (&mbsp->ser_rhr) & 0x7f);
}
-int
-serial_tstc(void)
+int serial_tstc (void)
{
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_SERIAL_BASE;
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_SERIAL_BASE;
- return ((cma_mb_reg_read(&mbsp->ser_lsr) & LSR_DR) != 0);
+ return ((cma_mb_reg_read (&mbsp->ser_lsr) & LSR_DR) != 0);
}
#endif /* CONS_NONE */
@@ -118,71 +109,63 @@ serial_tstc(void)
#error CONFIG_KGDB_INDEX must be configured for Cogent motherboard serial
#endif
-void
-kgdb_serial_init(void)
+void kgdb_serial_init (void)
{
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_KGDB_SER_BASE;
- unsigned int divisor;
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_KGDB_SER_BASE;
+ unsigned int divisor;
- if ((divisor = br_to_div(CONFIG_KGDB_BAUDRATE)) == 0)
- divisor = DEFDIV;
+ if ((divisor = br_to_div (CONFIG_KGDB_BAUDRATE)) == 0)
+ divisor = DEFDIV;
- cma_mb_reg_write(&mbsp->ser_ier, 0x00); /* turn off interrupts */
- cma_mb_reg_write(&mbsp->ser_lcr, 0x80); /* Access baud rate(set DLAB)*/
- cma_mb_reg_write(&mbsp->ser_brl, divisor & 0xff);
- cma_mb_reg_write(&mbsp->ser_brh, (divisor >> 8) & 0xff);
- cma_mb_reg_write(&mbsp->ser_lcr, 0x03); /* 8 data, 1 stop, no parity */
- cma_mb_reg_write(&mbsp->ser_mcr, 0x03); /* RTS/DTR */
- cma_mb_reg_write(&mbsp->ser_fcr, 0x07); /* Clear & enable FIFOs */
+ cma_mb_reg_write (&mbsp->ser_ier, 0x00); /* turn off interrupts */
+ cma_mb_reg_write (&mbsp->ser_lcr, 0x80); /* Access baud rate(set DLAB) */
+ cma_mb_reg_write (&mbsp->ser_brl, divisor & 0xff);
+ cma_mb_reg_write (&mbsp->ser_brh, (divisor >> 8) & 0xff);
+ cma_mb_reg_write (&mbsp->ser_lcr, 0x03); /* 8 data, 1 stop, no parity */
+ cma_mb_reg_write (&mbsp->ser_mcr, 0x03); /* RTS/DTR */
+ cma_mb_reg_write (&mbsp->ser_fcr, 0x07); /* Clear & enable FIFOs */
- printf("[on cma10x serial port B] ");
+ printf ("[on cma10x serial port B] ");
}
-void
-putDebugChar(int c)
+void putDebugChar (int c)
{
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_KGDB_SER_BASE;
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_KGDB_SER_BASE;
- while ((cma_mb_reg_read(&mbsp->ser_lsr) & LSR_THRE) == 0)
- ;
+ while ((cma_mb_reg_read (&mbsp->ser_lsr) & LSR_THRE) == 0);
- cma_mb_reg_write(&mbsp->ser_thr, c & 0xff);
+ cma_mb_reg_write (&mbsp->ser_thr, c & 0xff);
}
-void
-putDebugStr(const char *str)
+void putDebugStr (const char *str)
{
- while (*str != '\0') {
- if (*str == '\n')
- putDebugChar('\r');
- putDebugChar(*str++);
- }
+ while (*str != '\0') {
+ if (*str == '\n')
+ putDebugChar ('\r');
+ putDebugChar (*str++);
+ }
}
-int
-getDebugChar(void)
+int getDebugChar (void)
{
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_KGDB_SER_BASE;
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_KGDB_SER_BASE;
- while ((cma_mb_reg_read(&mbsp->ser_lsr) & LSR_DR) == 0)
- ;
+ while ((cma_mb_reg_read (&mbsp->ser_lsr) & LSR_DR) == 0);
- return ((int)cma_mb_reg_read(&mbsp->ser_rhr) & 0x7f);
+ return ((int) cma_mb_reg_read (&mbsp->ser_rhr) & 0x7f);
}
-void
-kgdb_interruptible(int yes)
+void kgdb_interruptible (int yes)
{
- cma_mb_serial *mbsp = (cma_mb_serial *)CMA_MB_KGDB_SER_BASE;
-
- if (yes == 1) {
- printf("kgdb: turning serial ints on\n");
- cma_mb_reg_write(&mbsp->ser_ier, 0xf);
- }
- else {
- printf("kgdb: turning serial ints off\n");
- cma_mb_reg_write(&mbsp->ser_ier, 0x0);
- }
+ cma_mb_serial *mbsp = (cma_mb_serial *) CMA_MB_KGDB_SER_BASE;
+
+ if (yes == 1) {
+ printf ("kgdb: turning serial ints on\n");
+ cma_mb_reg_write (&mbsp->ser_ier, 0xf);
+ } else {
+ printf ("kgdb: turning serial ints off\n");
+ cma_mb_reg_write (&mbsp->ser_ier, 0x0);
+ }
}
#endif /* KGDB && KGDB_NONE */