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"
51 int serial_init (void)
53 DECLARE_GLOBAL_DATA_PTR;
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 DECLARE_GLOBAL_DATA_PTR;
93 galbrg_set_baudrate (CONFIG_MPSC_PORT, gd->baudrate);
96 #else /* ! CONFIG_MPSC */
98 int serial_init (void)
100 DECLARE_GLOBAL_DATA_PTR;
102 int clock_divisor = 230400 / gd->baudrate;
104 #ifdef CFG_INIT_CHAN1
105 (void) NS16550_init (0, clock_divisor);
107 #ifdef CFG_INIT_CHAN2
108 (void) NS16550_init (1, clock_divisor);
113 void serial_putc (const char c)
116 NS16550_putc (COM_PORTS[CFG_DUART_CHAN], '\r');
118 NS16550_putc (COM_PORTS[CFG_DUART_CHAN], c);
121 int serial_getc (void)
123 return NS16550_getc (COM_PORTS[CFG_DUART_CHAN]);
126 int serial_tstc (void)
128 return NS16550_tstc (COM_PORTS[CFG_DUART_CHAN]);
131 void serial_setbrg (void)
133 DECLARE_GLOBAL_DATA_PTR;
135 int clock_divisor = 230400 / gd->baudrate;
137 #ifdef CFG_INIT_CHAN1
138 NS16550_reinit (COM_PORTS[0], clock_divisor);
140 #ifdef CFG_INIT_CHAN2
141 NS16550_reinit (COM_PORTS[1], clock_divisor);
145 #endif /* CONFIG_MPSC */
147 void serial_puts (const char *s)
154 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
155 void kgdb_serial_init (void)
159 void putDebugChar (int c)
164 void putDebugStr (const char *str)
169 int getDebugChar (void)
171 return serial_getc ();
174 void kgdb_interruptible (int yes)
178 #endif /* CFG_CMD_KGDB */