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