3 * Peter De Schrijver (p2@mind.be), Mind Linux Solutions, NV.
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.
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.
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,
23 #include <asm/u-boot.h>
24 #include <asm/processor.h>
26 #include <configs/ML2.h>
28 #include <linux/compiler.h>
30 #if (defined CONFIG_SYS_INIT_CHAN1) || (defined CONFIG_SYS_INIT_CHAN2)
34 DECLARE_GLOBAL_DATA_PTR;
36 #if (defined CONFIG_SYS_INIT_CHAN1) || (defined CONFIG_SYS_INIT_CHAN2)
37 const NS16550_t COM_PORTS[] = { (NS16550_t) CONFIG_SYS_NS16550_COM1,
38 (NS16550_t) CONFIG_SYS_NS16550_COM2
42 static int ml2_serial_init(void)
44 int clock_divisor = CONFIG_SYS_NS16550_CLK / 16 / gd->baudrate;
46 #ifdef CONFIG_SYS_INIT_CHAN1
47 (void) NS16550_init (COM_PORTS[0], clock_divisor);
49 #ifdef CONFIG_SYS_INIT_CHAN2
50 (void) NS16550_init (COM_PORTS[1], clock_divisor);
56 static void ml2_serial_putc(const char c)
59 NS16550_putc (COM_PORTS[CONFIG_SYS_DUART_CHAN], '\r');
61 NS16550_putc (COM_PORTS[CONFIG_SYS_DUART_CHAN], c);
64 static int ml2_serial_getc(void)
66 return NS16550_getc (COM_PORTS[CONFIG_SYS_DUART_CHAN]);
69 static int ml2_serial_tstc(void)
71 return NS16550_tstc (COM_PORTS[CONFIG_SYS_DUART_CHAN]);
74 static void ml2_serial_setbrg(void)
76 int clock_divisor = CONFIG_SYS_NS16550_CLK / 16 / gd->baudrate;
78 #ifdef CONFIG_SYS_INIT_CHAN1
79 NS16550_reinit (COM_PORTS[0], clock_divisor);
81 #ifdef CONFIG_SYS_INIT_CHAN2
82 NS16550_reinit (COM_PORTS[1], clock_divisor);
86 static void ml2_serial_puts(const char *s)
93 static struct serial_device ml2_serial_drv = {
95 .start = ml2_serial_init,
97 .setbrg = ml2_serial_setbrg,
98 .putc = ml2_serial_putc,
99 .puts = ml2_serial_puts,
100 .getc = ml2_serial_getc,
101 .tstc = ml2_serial_tstc,
104 void ml2_serial_initialize(void)
106 serial_register(&ml2_serial_drv);
109 __weak struct serial_device *default_serial_console(void)
111 return &ml2_serial_drv;
114 #if defined(CONFIG_CMD_KGDB)
115 void kgdb_serial_init (void)
119 void putDebugChar (int c)
124 void putDebugStr (const char *str)
129 int getDebugChar (void)
131 return serial_getc ();
134 void kgdb_interruptible (int yes)