]> git.sur5r.net Git - u-boot/blob - board/ml2/serial.c
Merge branch 'master' of git://www.denx.de/git/u-boot-ppc4xx
[u-boot] / board / ml2 / 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/types.h>
23 #include <asm/u-boot.h>
24 #include <asm/processor.h>
25 #include <common.h>
26 #include <command.h>
27 #include <configs/ML2.h>
28
29 #if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2)
30 #include <ns16550.h>
31 #endif
32
33 DECLARE_GLOBAL_DATA_PTR;
34
35 #if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2)
36 const NS16550_t COM_PORTS[] = { (NS16550_t) CFG_NS16550_COM1,
37         (NS16550_t) CFG_NS16550_COM2
38 };
39 #endif
40
41 int serial_init (void)
42 {
43         int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
44
45 #ifdef CFG_INIT_CHAN1
46         (void) NS16550_init (COM_PORTS[0], clock_divisor);
47 #endif
48 #ifdef CFG_INIT_CHAN2
49         (void) NS16550_init (COM_PORTS[1], clock_divisor);
50 #endif
51         return 0;
52
53 }
54
55 void serial_putc (const char c)
56 {
57         if (c == '\n')
58                 NS16550_putc (COM_PORTS[CFG_DUART_CHAN], '\r');
59
60         NS16550_putc (COM_PORTS[CFG_DUART_CHAN], c);
61 }
62
63 int serial_getc (void)
64 {
65         return NS16550_getc (COM_PORTS[CFG_DUART_CHAN]);
66 }
67
68 int serial_tstc (void)
69 {
70         return NS16550_tstc (COM_PORTS[CFG_DUART_CHAN]);
71 }
72
73 void serial_setbrg (void)
74 {
75         int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate;
76
77 #ifdef CFG_INIT_CHAN1
78         NS16550_reinit (COM_PORTS[0], clock_divisor);
79 #endif
80 #ifdef CFG_INIT_CHAN2
81         NS16550_reinit (COM_PORTS[1], clock_divisor);
82 #endif
83 }
84
85 void serial_puts (const char *s)
86 {
87         while (*s) {
88                 serial_putc (*s++);
89         }
90 }
91
92 #if defined(CONFIG_CMD_KGDB)
93 void kgdb_serial_init (void)
94 {
95 }
96
97 void putDebugChar (int c)
98 {
99         serial_putc (c);
100 }
101
102 void putDebugStr (const char *str)
103 {
104         serial_puts (str);
105 }
106
107 int getDebugChar (void)
108 {
109         return serial_getc ();
110 }
111
112 void kgdb_interruptible (int yes)
113 {
114         return;
115 }
116 #endif