]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - board/logicpd/zoom2/zoom2_serial.c
2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
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,
20 * This file was adapted from arch/powerpc/cpu/mpc5xxx/serial.c
27 #include <asm/arch/cpu.h>
28 #include "zoom2_serial.h"
30 int quad_init_dev (unsigned long base
)
33 * The Quad UART is on the debug board.
34 * Check if the debug board is attached before using the UART
36 if (zoom2_debug_board_connected ()) {
37 NS16550_t com_port
= (NS16550_t
) base
;
38 int baud_divisor
= CONFIG_SYS_NS16550_CLK
/ 16 /
42 * Zoom2 has a board specific initialization of its UART.
43 * This generic initialization has been copied from
44 * drivers/serial/ns16550.c. The macros have been expanded.
46 * Do the following instead of
48 * NS16550_init (com_port, clock_divisor);
53 * On Zoom2 board Set pre-scalar to 1
54 * CLKSEL is GND => MCR[7] is 1 => preslr is 4
55 * So change the prescl to 1
58 com_port
->fcr
|= 0x10;
59 com_port
->mcr
&= 0x7F;
61 /* This is generic ns16550.c setup */
62 com_port
->lcr
= UART_LCR_BKSE
| UART_LCR_8N1
;
65 com_port
->lcr
= UART_LCR_8N1
;
66 com_port
->mcr
= UART_MCR_DTR
| UART_MCR_RTS
;
67 com_port
->fcr
= UART_FCR_FIFO_EN
| UART_FCR_RXSR
|
69 com_port
->lcr
= UART_LCR_BKSE
| UART_LCR_8N1
;
70 com_port
->dll
= baud_divisor
& 0xff;
71 com_port
->dlm
= (baud_divisor
>> 8) & 0xff;
72 com_port
->lcr
= UART_LCR_8N1
;
75 * We have to lie here, otherwise the board init code will hang
81 void quad_putc_dev (unsigned long base
, const char c
)
83 if (zoom2_debug_board_connected ()) {
86 quad_putc_dev (base
, '\r');
88 NS16550_putc ((NS16550_t
) base
, c
);
94 void quad_puts_dev (unsigned long base
, const char *s
)
96 if (zoom2_debug_board_connected ()) {
97 while ((s
!= NULL
) && (*s
!= '\0'))
98 quad_putc_dev (base
, *s
++);
104 int quad_getc_dev (unsigned long base
)
106 if (zoom2_debug_board_connected ())
107 return NS16550_getc ((NS16550_t
) base
);
109 return usbtty_getc();
112 int quad_tstc_dev (unsigned long base
)
114 if (zoom2_debug_board_connected ())
115 return NS16550_tstc ((NS16550_t
) base
);
117 return usbtty_tstc();
120 void quad_setbrg_dev (unsigned long base
)
122 if (zoom2_debug_board_connected ()) {
124 int clock_divisor
= CONFIG_SYS_NS16550_CLK
/ 16 /
127 NS16550_reinit ((NS16550_t
) base
, clock_divisor
);