3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
5 * modified for marvell db64360 eval board by
6 * Ingo Assmus <ingo.assmus@keymile.com>
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * serial.c - serial support for the gal ev board
31 /* supports both the 16650 duart and the MPSC */
36 #include <linux/compiler.h>
38 #include "../include/memory.h"
42 #include "../db64360/mpsc.h"
46 #include "../db64460/mpsc.h"
51 DECLARE_GLOBAL_DATA_PTR;
54 static int marvell_serial_init(void)
56 #if (defined CONFIG_SYS_INIT_CHAN1) || (defined CONFIG_SYS_INIT_CHAN2)
57 int clock_divisor = 230400 / gd->baudrate;
60 mpsc_init (gd->baudrate);
62 /* init the DUART chans so that KGDB in the kernel can use them */
63 #ifdef CONFIG_SYS_INIT_CHAN1
64 NS16550_reinit (COM_PORTS[0], clock_divisor);
66 #ifdef CONFIG_SYS_INIT_CHAN2
67 NS16550_reinit (COM_PORTS[1], clock_divisor);
72 static void marvell_serial_putc(const char c)
80 static int marvell_serial_getc(void)
82 return mpsc_getchar ();
85 static int marvell_serial_tstc(void)
87 return mpsc_test_char ();
90 static void marvell_serial_setbrg(void)
92 galbrg_set_baudrate (CONFIG_MPSC_PORT, gd->baudrate);
95 #else /* ! CONFIG_MPSC */
97 static int marvell_serial_init(void)
99 int clock_divisor = 230400 / gd->baudrate;
101 #ifdef CONFIG_SYS_INIT_CHAN1
102 (void) NS16550_init (0, clock_divisor);
104 #ifdef CONFIG_SYS_INIT_CHAN2
105 (void) NS16550_init (1, clock_divisor);
110 static void marvell_serial_putc(const char c)
113 NS16550_putc (COM_PORTS[CONFIG_SYS_DUART_CHAN], '\r');
115 NS16550_putc (COM_PORTS[CONFIG_SYS_DUART_CHAN], c);
118 static int marvell_serial_getc(void)
120 return NS16550_getc (COM_PORTS[CONFIG_SYS_DUART_CHAN]);
123 static int marvell_serial_tstc(void)
125 return NS16550_tstc (COM_PORTS[CONFIG_SYS_DUART_CHAN]);
128 static void marvell_serial_setbrg(void)
130 int clock_divisor = 230400 / gd->baudrate;
132 #ifdef CONFIG_SYS_INIT_CHAN1
133 NS16550_reinit (COM_PORTS[0], clock_divisor);
135 #ifdef CONFIG_SYS_INIT_CHAN2
136 NS16550_reinit (COM_PORTS[1], clock_divisor);
140 #endif /* CONFIG_MPSC */
142 static void marvell_serial_puts(const char *s)
149 static struct serial_device marvell_serial_drv = {
150 .name = "marvell_serial",
151 .start = marvell_serial_init,
153 .setbrg = marvell_serial_setbrg,
154 .putc = marvell_serial_putc,
155 .puts = marvell_serial_puts,
156 .getc = marvell_serial_getc,
157 .tstc = marvell_serial_tstc,
160 void marvell_serial_initialize(void)
162 serial_register(&marvell_serial_drv);
165 __weak struct serial_device *default_serial_console(void)
167 return &marvell_serial_drv;
170 #if defined(CONFIG_CMD_KGDB)
171 void kgdb_serial_init (void)
175 void putDebugChar (int c)
180 void putDebugStr (const char *str)
185 int getDebugChar (void)
187 return serial_getc ();
190 void kgdb_interruptible (int yes)