3 * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
5 * See file CREDITS for list of people who contributed to this
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,
26 #include <linux/compiler.h>
30 DECLARE_GLOBAL_DATA_PTR;
32 #if CONFIG_CONS_INDEX == 1
33 static struct NS16550 *console =
34 (struct NS16550 *) (CONFIG_SYS_EUMB_ADDR + 0x4500);
35 #elif CONFIG_CONS_INDEX == 2
36 static struct NS16550 *console =
37 (struct NS16550 *) (CONFIG_SYS_EUMB_ADDR + 0x4500);
39 #error no valid console defined
42 extern ulong get_bus_freq (ulong);
44 static int bmw_serial_init(void)
46 int clock_divisor = gd->bus_clk / 16 / gd->baudrate;
48 NS16550_init (CONFIG_CONS_INDEX - 1, clock_divisor);
53 static void bmw_serial_putc(const char c)
58 NS16550_putc (console, c);
61 static void bmw_serial_puts(const char *s)
69 static int bmw_serial_getc(void)
71 return NS16550_getc (console);
74 static int bmw_serial_tstc(void)
76 return NS16550_tstc (console);
79 static void bmw_serial_setbrg(void)
81 int clock_divisor = get_bus_freq (0) / 16 / gd->baudrate;
83 NS16550_reinit (console, clock_divisor);
86 static struct serial_device bmw_serial_drv = {
88 .start = bmw_serial_init,
90 .setbrg = bmw_serial_setbrg,
91 .putc = bmw_serial_putc,
92 .puts = bmw_serial_puts,
93 .getc = bmw_serial_getc,
94 .tstc = bmw_serial_tstc,
97 void bmw_serial_initialize(void)
99 serial_register(&bmw_serial_drv);
102 __weak struct serial_device *default_serial_console(void)
104 return &bmw_serial_drv;