glamo-mmc.patch
[u-boot-openmoko/mini2440.git] / board / bmw / serial.c
blob712a95b19e50e50e4b39449708d1a90d42369ba1
1 /*
2 * (C) Copyright 2000
3 * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
5 * See file CREDITS for list of people who contributed to this
6 * project.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
24 #include <common.h>
25 #include "ns16550.h"
27 DECLARE_GLOBAL_DATA_PTR;
29 #if CONFIG_CONS_INDEX == 1
30 static struct NS16550 *console =
31 (struct NS16550 *) (CFG_EUMB_ADDR + 0x4500);
32 #elif CONFIG_CONS_INDEX == 2
33 static struct NS16550 *console =
34 (struct NS16550 *) (CFG_EUMB_ADDR + 0x4500);
35 #else
36 #error no valid console defined
37 #endif
39 extern ulong get_bus_freq (ulong);
41 int serial_init (void)
43 int clock_divisor = gd->bus_clk / 16 / gd->baudrate;
45 NS16550_init (CONFIG_CONS_INDEX - 1, clock_divisor);
47 return (0);
50 void serial_putc (const char c)
52 if (c == '\n') {
53 serial_putc ('\r');
55 NS16550_putc (console, c);
58 void serial_puts (const char *s)
60 while (*s) {
61 serial_putc (*s++);
66 int serial_getc (void)
68 return NS16550_getc (console);
71 int serial_tstc (void)
73 return NS16550_tstc (console);
76 void serial_setbrg (void)
78 int clock_divisor = get_bus_freq (0) / 16 / gd->baudrate;
80 NS16550_reinit (console, clock_divisor);