3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
5 * modified for marvell db64360 eval board by
6 * Ingo Assmus <ingo.assmus@keymile.com>
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * serial.c - serial support for the gal ev board
31 /* supports both the 16650 duart and the MPSC */
35 #include "../include/memory.h"
39 #include "../db64360/mpsc.h"
43 #include "../db64460/mpsc.h"
48 DECLARE_GLOBAL_DATA_PTR;
53 int serial_init (void)
55 #if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2)
56 int clock_divisor = 230400 / gd->baudrate;
59 mpsc_init (gd->baudrate);
61 /* init the DUART chans so that KGDB in the kernel can use them */
63 NS16550_reinit (COM_PORTS[0], clock_divisor);
66 NS16550_reinit (COM_PORTS[1], clock_divisor);
71 void serial_putc (const char c)
79 int serial_getc (void)
81 return mpsc_getchar ();
84 int serial_tstc (void)
86 return mpsc_test_char ();
89 void serial_setbrg (void)
91 galbrg_set_baudrate (CONFIG_MPSC_PORT, gd->baudrate);
94 #else /* ! CONFIG_MPSC */
96 int serial_init (void)
98 int clock_divisor = 230400 / gd->baudrate;
100 #ifdef CFG_INIT_CHAN1
101 (void) NS16550_init (0, clock_divisor);
103 #ifdef CFG_INIT_CHAN2
104 (void) NS16550_init (1, clock_divisor);
109 void serial_putc (const char c)
112 NS16550_putc (COM_PORTS[CFG_DUART_CHAN], '\r');
114 NS16550_putc (COM_PORTS[CFG_DUART_CHAN], c);
117 int serial_getc (void)
119 return NS16550_getc (COM_PORTS[CFG_DUART_CHAN]);
122 int serial_tstc (void)
124 return NS16550_tstc (COM_PORTS[CFG_DUART_CHAN]);
127 void serial_setbrg (void)
129 int clock_divisor = 230400 / gd->baudrate;
131 #ifdef CFG_INIT_CHAN1
132 NS16550_reinit (COM_PORTS[0], clock_divisor);
134 #ifdef CFG_INIT_CHAN2
135 NS16550_reinit (COM_PORTS[1], clock_divisor);
139 #endif /* CONFIG_MPSC */
141 void serial_puts (const char *s)
148 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
149 void kgdb_serial_init (void)
153 void putDebugChar (int c)
158 void putDebugStr (const char *str)
163 int getDebugChar (void)
165 return serial_getc ();
168 void kgdb_interruptible (int yes)
172 #endif /* CFG_CMD_KGDB */