]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/amirix/ap1000/serial.c
Add support for AP1000 board.
[people/ms/u-boot.git] / board / amirix / ap1000 / serial.c
1 /*
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 <config.h>
27
28 #include <ns16550.h>
29
30 #if 0
31 #include "serial.h"
32 #endif
33
34 const NS16550_t COM_PORTS[] = { (NS16550_t) CFG_NS16550_COM1, (NS16550_t) CFG_NS16550_COM2 };
35
36 #undef CFG_DUART_CHAN
37 #define CFG_DUART_CHAN gComPort
38 static int gComPort = 0;
39
40 int
41 serial_init (void)
42 {
43 DECLARE_GLOBAL_DATA_PTR;
44
45 int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
46
47 (void)NS16550_init(COM_PORTS[0], clock_divisor);
48 gComPort = 0;
49
50 return 0;
51
52 }
53
54 void
55 serial_putc(const char c)
56 {
57 if (c == '\n'){
58 NS16550_putc(COM_PORTS[CFG_DUART_CHAN], '\r');
59 }
60
61 NS16550_putc(COM_PORTS[CFG_DUART_CHAN], c);
62 }
63
64 int
65 serial_getc(void)
66 {
67 return NS16550_getc(COM_PORTS[CFG_DUART_CHAN]);
68 }
69
70 int
71 serial_tstc(void)
72 {
73 return NS16550_tstc(COM_PORTS[CFG_DUART_CHAN]);
74 }
75
76 void
77 serial_setbrg (void)
78 {
79 DECLARE_GLOBAL_DATA_PTR;
80
81 int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
82
83 #ifdef CFG_INIT_CHAN1
84 NS16550_reinit(COM_PORTS[0], clock_divisor);
85 #endif
86 #ifdef CFG_INIT_CHAN2
87 NS16550_reinit(COM_PORTS[1], clock_divisor);
88 #endif
89 }
90
91 void
92 serial_puts (const char *s)
93 {
94 while (*s) {
95 serial_putc (*s++);
96 }
97 }
98
99 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
100 void
101 kgdb_serial_init(void)
102 {
103 }
104
105 void
106 putDebugChar (int c)
107 {
108 serial_putc (c);
109 }
110
111 void
112 putDebugStr (const char *str)
113 {
114 serial_puts (str);
115 }
116
117 int
118 getDebugChar (void)
119 {
120 return serial_getc();
121 }
122
123 void
124 kgdb_interruptible (int yes)
125 {
126 return;
127 }
128 #endif /* CFG_CMD_KGDB */