]>
Commit | Line | Data |
---|---|---|
c609719b 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 | ||
4ff170a8 | 22 | #include <common.h> |
c609719b WD |
23 | #include <asm/u-boot.h> |
24 | #include <asm/processor.h> | |
c609719b WD |
25 | #include <command.h> |
26 | #include <configs/ML2.h> | |
27 | ||
6d0f6bcf | 28 | #if (defined CONFIG_SYS_INIT_CHAN1) || (defined CONFIG_SYS_INIT_CHAN2) |
c609719b WD |
29 | #include <ns16550.h> |
30 | #endif | |
31 | ||
d87080b7 | 32 | DECLARE_GLOBAL_DATA_PTR; |
c609719b | 33 | |
6d0f6bcf JCPV |
34 | #if (defined CONFIG_SYS_INIT_CHAN1) || (defined CONFIG_SYS_INIT_CHAN2) |
35 | const NS16550_t COM_PORTS[] = { (NS16550_t) CONFIG_SYS_NS16550_COM1, | |
36 | (NS16550_t) CONFIG_SYS_NS16550_COM2 | |
d87080b7 | 37 | }; |
c609719b WD |
38 | #endif |
39 | ||
d87080b7 | 40 | int serial_init (void) |
c609719b | 41 | { |
6d0f6bcf | 42 | int clock_divisor = CONFIG_SYS_NS16550_CLK / 16 / gd->baudrate; |
c609719b | 43 | |
6d0f6bcf | 44 | #ifdef CONFIG_SYS_INIT_CHAN1 |
d87080b7 | 45 | (void) NS16550_init (COM_PORTS[0], clock_divisor); |
c609719b | 46 | #endif |
6d0f6bcf | 47 | #ifdef CONFIG_SYS_INIT_CHAN2 |
d87080b7 | 48 | (void) NS16550_init (COM_PORTS[1], clock_divisor); |
c609719b | 49 | #endif |
d87080b7 | 50 | return 0; |
c609719b WD |
51 | |
52 | } | |
53 | ||
d87080b7 | 54 | void serial_putc (const char c) |
c609719b | 55 | { |
d87080b7 | 56 | if (c == '\n') |
6d0f6bcf | 57 | NS16550_putc (COM_PORTS[CONFIG_SYS_DUART_CHAN], '\r'); |
c609719b | 58 | |
6d0f6bcf | 59 | NS16550_putc (COM_PORTS[CONFIG_SYS_DUART_CHAN], c); |
c609719b WD |
60 | } |
61 | ||
d87080b7 | 62 | int serial_getc (void) |
c609719b | 63 | { |
6d0f6bcf | 64 | return NS16550_getc (COM_PORTS[CONFIG_SYS_DUART_CHAN]); |
c609719b WD |
65 | } |
66 | ||
d87080b7 | 67 | int serial_tstc (void) |
c609719b | 68 | { |
6d0f6bcf | 69 | return NS16550_tstc (COM_PORTS[CONFIG_SYS_DUART_CHAN]); |
c609719b WD |
70 | } |
71 | ||
d87080b7 | 72 | void serial_setbrg (void) |
c609719b | 73 | { |
6d0f6bcf | 74 | int clock_divisor = CONFIG_SYS_NS16550_CLK / 16 / gd->baudrate; |
c609719b | 75 | |
6d0f6bcf | 76 | #ifdef CONFIG_SYS_INIT_CHAN1 |
d87080b7 | 77 | NS16550_reinit (COM_PORTS[0], clock_divisor); |
c609719b | 78 | #endif |
6d0f6bcf | 79 | #ifdef CONFIG_SYS_INIT_CHAN2 |
d87080b7 | 80 | NS16550_reinit (COM_PORTS[1], clock_divisor); |
c609719b WD |
81 | #endif |
82 | } | |
83 | ||
d87080b7 | 84 | void serial_puts (const char *s) |
c609719b WD |
85 | { |
86 | while (*s) { | |
87 | serial_putc (*s++); | |
88 | } | |
89 | } | |
90 | ||
3fe00109 | 91 | #if defined(CONFIG_CMD_KGDB) |
d87080b7 | 92 | void kgdb_serial_init (void) |
c609719b WD |
93 | { |
94 | } | |
95 | ||
d87080b7 | 96 | void putDebugChar (int c) |
c609719b WD |
97 | { |
98 | serial_putc (c); | |
99 | } | |
100 | ||
d87080b7 | 101 | void putDebugStr (const char *str) |
c609719b WD |
102 | { |
103 | serial_puts (str); | |
104 | } | |
105 | ||
d87080b7 | 106 | int getDebugChar (void) |
c609719b | 107 | { |
d87080b7 | 108 | return serial_getc (); |
c609719b WD |
109 | } |
110 | ||
d87080b7 | 111 | void kgdb_interruptible (int yes) |
c609719b WD |
112 | { |
113 | return; | |
114 | } | |
3fe00109 | 115 | #endif |