blob: 92baba927598a914ba308d9e45eccab1979bd31e [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * (C) Copyright 2002
3 * Peter De Schrijver (p2@mind.be), Mind Linux Solutions, NV.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
19 *
20 */
21
22#include <asm/u-boot.h>
23#include <asm/processor.h>
24#include <common.h>
25#include <command.h>
26#include <configs/ML2.h>
27
28#if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2)
29#include <ns16550.h>
30#endif
31
32#if 0
33#include "serial.h"
34#endif
35
36#if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2)
37const NS16550_t COM_PORTS[] = { (NS16550_t) CFG_NS16550_COM1,
wdenk57b2d802003-06-27 21:31:46 +000038 (NS16550_t) CFG_NS16550_COM2 };
wdenkc6097192002-11-03 00:24:07 +000039#endif
40
41int
42serial_init (void)
43{
44 DECLARE_GLOBAL_DATA_PTR;
45
46 int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
47
48#ifdef CFG_INIT_CHAN1
49 (void)NS16550_init(COM_PORTS[0], clock_divisor);
50#endif
51#ifdef CFG_INIT_CHAN2
52 (void)NS16550_init(COM_PORTS[1], clock_divisor);
53#endif
54 return 0;
55
56}
57
58void
59serial_putc(const char c)
60{
61 if (c == '\n')
wdenk57b2d802003-06-27 21:31:46 +000062 NS16550_putc(COM_PORTS[CFG_DUART_CHAN], '\r');
wdenkc6097192002-11-03 00:24:07 +000063
64 NS16550_putc(COM_PORTS[CFG_DUART_CHAN], c);
65}
66
67int
68serial_getc(void)
69{
70 return NS16550_getc(COM_PORTS[CFG_DUART_CHAN]);
71}
72
73int
74serial_tstc(void)
75{
76 return NS16550_tstc(COM_PORTS[CFG_DUART_CHAN]);
77}
78
79void
80serial_setbrg (void)
81{
82 DECLARE_GLOBAL_DATA_PTR;
83
84 int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
85
86#ifdef CFG_INIT_CHAN1
87 NS16550_reinit(COM_PORTS[0], clock_divisor);
88#endif
89#ifdef CFG_INIT_CHAN2
90 NS16550_reinit(COM_PORTS[1], clock_divisor);
91#endif
92}
93
94void
95serial_puts (const char *s)
96{
97 while (*s) {
98 serial_putc (*s++);
99 }
100}
101
102#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
103void
104kgdb_serial_init(void)
105{
106}
107
108void
109putDebugChar (int c)
110{
111 serial_putc (c);
112}
113
114void
115putDebugStr (const char *str)
116{
117 serial_puts (str);
118}
119
120int
121getDebugChar (void)
122{
123 return serial_getc();
124}
125
126void
127kgdb_interruptible (int yes)
128{
129 return;
130}
131#endif /* CFG_CMD_KGDB */