2 * (C) Copyright 2004, Freescale, Inc
3 * TsiChung Liew, Tsi-Chung.Liew@freescale.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 * Minimal serial functions needed to use one of the PSC ports
27 * as serial console interface.
33 #if defined (CONFIG_EXTUART_CONSOLE)
36 # define PADSERIAL_BAUD_115200 0x40
37 # define PADSERIAL_BAUD_57600 0x20
38 # define PADSERIAL_BAUD_9600 0
39 # define PADCARD_FREQ 18432000
41 const NS16550_t com_port = (NS16550_t) CFG_NS16550_COM1;
43 int ext_serial_init (void)
45 DECLARE_GLOBAL_DATA_PTR;
46 volatile u8 *dipswitch = (volatile u8 *) (CFG_CPLD_BASE + 0x1002);
49 /* Find out the baud rate speed on debug card dip switches */
50 if (*dipswitch & PADSERIAL_BAUD_115200)
51 gd->baudrate = 115200;
52 else if (*dipswitch & PADSERIAL_BAUD_57600)
57 /* Debug card frequency */
58 baud_divisor = PADCARD_FREQ / (16 * gd->baudrate);
60 NS16550_init (com_port, baud_divisor);
65 void ext_serial_putc (const char c)
68 NS16550_putc (com_port, '\r');
70 NS16550_putc (com_port, c);
73 void ext_serial_puts (const char *s)
80 int ext_serial_getc (void)
82 return NS16550_getc (com_port);
85 int ext_serial_tstc (void)
87 return NS16550_tstc (com_port);
90 void ext_serial_setbrg (void)
92 DECLARE_GLOBAL_DATA_PTR;
94 volatile u8 *dipswitch = (volatile u8 *) (CFG_CPLD_BASE + 0x1002);
97 /* Find out the baud rate speed on debug card dip switches */
98 if (*dipswitch & PADSERIAL_BAUD_115200)
99 gd->baudrate = 115200;
100 else if (*dipswitch & PADSERIAL_BAUD_57600)
101 gd->baudrate = 57600;
105 /* Debug card frequency */
106 baud_divisor = PADCARD_FREQ / (16 * gd->baudrate);
108 NS16550_reinit (com_port, baud_divisor);
110 #endif /* CONFIG_EXTUART_CONSOLE */