]>
Commit | Line | Data |
---|---|---|
7521af1c WD |
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 | ||
d87080b7 | 30 | DECLARE_GLOBAL_DATA_PTR; |
7521af1c | 31 | |
3df5bea0 WD |
32 | const NS16550_t COM_PORTS[] = |
33 | { (NS16550_t) CFG_NS16550_COM1, (NS16550_t) CFG_NS16550_COM2 }; | |
7521af1c WD |
34 | |
35 | #undef CFG_DUART_CHAN | |
36 | #define CFG_DUART_CHAN gComPort | |
37 | static int gComPort = 0; | |
38 | ||
3df5bea0 | 39 | int serial_init (void) |
7521af1c | 40 | { |
3df5bea0 | 41 | int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate; |
7521af1c | 42 | |
3df5bea0 WD |
43 | (void) NS16550_init (COM_PORTS[0], clock_divisor); |
44 | gComPort = 0; | |
7521af1c | 45 | |
3df5bea0 | 46 | return 0; |
7521af1c WD |
47 | } |
48 | ||
3df5bea0 | 49 | void serial_putc (const char c) |
7521af1c | 50 | { |
3df5bea0 WD |
51 | if (c == '\n') { |
52 | NS16550_putc (COM_PORTS[CFG_DUART_CHAN], '\r'); | |
53 | } | |
7521af1c | 54 | |
3df5bea0 | 55 | NS16550_putc (COM_PORTS[CFG_DUART_CHAN], c); |
7521af1c WD |
56 | } |
57 | ||
3df5bea0 | 58 | int serial_getc (void) |
7521af1c | 59 | { |
3df5bea0 | 60 | return NS16550_getc (COM_PORTS[CFG_DUART_CHAN]); |
7521af1c WD |
61 | } |
62 | ||
3df5bea0 | 63 | int serial_tstc (void) |
7521af1c | 64 | { |
3df5bea0 | 65 | return NS16550_tstc (COM_PORTS[CFG_DUART_CHAN]); |
7521af1c WD |
66 | } |
67 | ||
3df5bea0 | 68 | void serial_setbrg (void) |
7521af1c | 69 | { |
3df5bea0 | 70 | int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate; |
7521af1c WD |
71 | |
72 | #ifdef CFG_INIT_CHAN1 | |
3df5bea0 | 73 | NS16550_reinit (COM_PORTS[0], clock_divisor); |
7521af1c WD |
74 | #endif |
75 | #ifdef CFG_INIT_CHAN2 | |
3df5bea0 | 76 | NS16550_reinit (COM_PORTS[1], clock_divisor); |
7521af1c WD |
77 | #endif |
78 | } | |
79 | ||
3df5bea0 | 80 | void serial_puts (const char *s) |
7521af1c WD |
81 | { |
82 | while (*s) { | |
83 | serial_putc (*s++); | |
84 | } | |
85 | } | |
86 | ||
fcec2eb9 | 87 | #if defined(CONFIG_CMD_KGDB) |
3df5bea0 | 88 | void kgdb_serial_init (void) |
7521af1c WD |
89 | { |
90 | } | |
91 | ||
3df5bea0 | 92 | void putDebugChar (int c) |
7521af1c WD |
93 | { |
94 | serial_putc (c); | |
95 | } | |
96 | ||
3df5bea0 | 97 | void putDebugStr (const char *str) |
7521af1c WD |
98 | { |
99 | serial_puts (str); | |
100 | } | |
101 | ||
3df5bea0 | 102 | int getDebugChar (void) |
7521af1c | 103 | { |
3df5bea0 | 104 | return serial_getc (); |
7521af1c WD |
105 | } |
106 | ||
3df5bea0 | 107 | void kgdb_interruptible (int yes) |
7521af1c WD |
108 | { |
109 | return; | |
110 | } | |
77a31854 | 111 | #endif |