3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * serial.c - serial support for the gal ev board
28 /* supports both the 16650 duart and the MPSC */
32 #include <galileo/memory.h>
34 #if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2)
42 DECLARE_GLOBAL_DATA_PTR;
44 #if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2)
45 const NS16550_t COM_PORTS[] = { (NS16550_t) CFG_NS16550_COM1,
46 (NS16550_t) CFG_NS16550_COM2 };
51 int serial_init (void)
53 #if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2)
54 int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
57 mpsc_init(gd->baudrate);
59 /* init the DUART chans so that KGDB in the kernel can use them */
61 NS16550_reinit(COM_PORTS[0], clock_divisor);
64 NS16550_reinit(COM_PORTS[1], clock_divisor);
70 serial_putc(const char c)
81 return mpsc_getchar();
87 return mpsc_test_char();
93 galbrg_set_baudrate(CONFIG_MPSC_PORT, gd->baudrate);
96 #else /* ! CONFIG_MPSC */
98 int serial_init (void)
100 int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
102 #ifdef CFG_INIT_CHAN1
103 (void)NS16550_init(COM_PORTS[0], clock_divisor);
105 #ifdef CFG_INIT_CHAN2
106 (void)NS16550_init(COM_PORTS[1], clock_divisor);
113 serial_putc(const char c)
116 NS16550_putc(COM_PORTS[CFG_DUART_CHAN], '\r');
118 NS16550_putc(COM_PORTS[CFG_DUART_CHAN], c);
124 return NS16550_getc(COM_PORTS[CFG_DUART_CHAN]);
130 return NS16550_tstc(COM_PORTS[CFG_DUART_CHAN]);
136 int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
138 #ifdef CFG_INIT_CHAN1
139 NS16550_reinit(COM_PORTS[0], clock_divisor);
141 #ifdef CFG_INIT_CHAN2
142 NS16550_reinit(COM_PORTS[1], clock_divisor);
146 #endif /* CONFIG_MPSC */
149 serial_puts (const char *s)
156 #if defined(CONFIG_CMD_KGDB)
158 kgdb_serial_init(void)
169 putDebugStr (const char *str)
177 return serial_getc();
181 kgdb_interruptible (int yes)
185 #endif /* CFG_CMD_KGDB */