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>
28 #include <linux/compiler.h>
32 DECLARE_GLOBAL_DATA_PTR;
34 const NS16550_t COM_PORTS[] =
35 { (NS16550_t) CONFIG_SYS_NS16550_COM1, (NS16550_t) CONFIG_SYS_NS16550_COM2 };
37 #undef CONFIG_SYS_DUART_CHAN
38 #define CONFIG_SYS_DUART_CHAN gComPort
39 static int gComPort = 0;
41 static int amirix_serial_init(void)
43 int clock_divisor = CONFIG_SYS_NS16550_CLK / 16 / gd->baudrate;
45 (void) NS16550_init (COM_PORTS[0], clock_divisor);
51 static void amirix_serial_putc(const char c)
54 NS16550_putc (COM_PORTS[CONFIG_SYS_DUART_CHAN], '\r');
57 NS16550_putc (COM_PORTS[CONFIG_SYS_DUART_CHAN], c);
60 static int amirix_serial_getc(void)
62 return NS16550_getc (COM_PORTS[CONFIG_SYS_DUART_CHAN]);
65 static int amirix_serial_tstc(void)
67 return NS16550_tstc (COM_PORTS[CONFIG_SYS_DUART_CHAN]);
70 static void amirix_serial_setbrg(void)
72 int clock_divisor = CONFIG_SYS_NS16550_CLK / 16 / gd->baudrate;
74 #ifdef CONFIG_SYS_INIT_CHAN1
75 NS16550_reinit (COM_PORTS[0], clock_divisor);
77 #ifdef CONFIG_SYS_INIT_CHAN2
78 NS16550_reinit (COM_PORTS[1], clock_divisor);
82 static void amirix_serial_puts(const char *s)
89 static struct serial_device amirix_serial_drv = {
90 .name = "amirix_serial",
91 .start = amirix_serial_init,
93 .setbrg = amirix_serial_setbrg,
94 .putc = amirix_serial_putc,
95 .puts = amirix_serial_puts,
96 .getc = amirix_serial_getc,
97 .tstc = amirix_serial_tstc,
100 void amirix_serial_initialize(void)
102 serial_register(&amirix_serial_drv);
105 __weak struct serial_device *default_serial_console(void)
107 return &amirix_serial_drv;
110 #if defined(CONFIG_CMD_KGDB)
111 void kgdb_serial_init (void)
115 void putDebugChar (int c)
120 void putDebugStr (const char *str)
125 int getDebugChar (void)
127 return serial_getc ();
130 void kgdb_interruptible (int yes)