blob: c204b88e415bae025f8829025b4af8e642355624 [file] [log] [blame]
wdenk028ab6b2004-02-23 23:54:43 +00001/*
2 * Author: Xilinx, Inc.
3 *
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 *
11 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
12 * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
13 * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD,
14 * XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE
15 * FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
16 * ANY THIRD PARTY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
17 * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
18 * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
19 * WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM
20 * CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE.
22 *
23 *
24 * Xilinx hardware products are not intended for use in life support
25 * appliances, devices, or systems. Use in such applications is
26 * expressly prohibited.
27 *
28 *
29 * (c) Copyright 2002-2004 Xilinx Inc.
30 * All rights reserved.
31 *
32 *
33 * You should have received a copy of the GNU General Public License along
34 * with this program; if not, write to the Free Software Foundation, Inc.,
35 * 675 Mass Ave, Cambridge, MA 02139, USA.
36 *
37 */
38
39#include <asm/u-boot.h>
40#include <asm/processor.h>
41#include <common.h>
42#include <command.h>
43#include <configs/ml300.h>
44#include "xparameters.h"
45
Wolfgang Denkd87080b2006-03-31 18:32:53 +020046DECLARE_GLOBAL_DATA_PTR;
47
wdenk028ab6b2004-02-23 23:54:43 +000048#define USE_CHAN1 \
49 ((defined XPAR_UARTNS550_0_BASEADDR) && (defined CFG_INIT_CHAN1))
50#define USE_CHAN2 \
51 ((defined XPAR_UARTNS550_1_BASEADDR) && (defined CFG_INIT_CHAN2))
52
53#if USE_CHAN1
54#include <ns16550.h>
55#endif
56
57#if USE_CHAN1
58const NS16550_t COM_PORTS[] = { (NS16550_t) (XPAR_UARTNS550_0_BASEADDR + 3)
59#if USE_CHAN2
60 , (NS16550_t) (XPAR_UARTNS550_1_BASEADDR + 3)
61#endif
62};
63#endif
64
65int
66serial_init(void)
67{
68#if USE_CHAN1
wdenk028ab6b2004-02-23 23:54:43 +000069 int clock_divisor;
70
71 clock_divisor = XPAR_UARTNS550_0_CLOCK_FREQ_HZ / 16 / gd->baudrate;
72 (void) NS16550_init(COM_PORTS[0], clock_divisor);
73#if USE_CHAN2
74 clock_divisor = XPAR_UARTNS550_1_CLOCK_FREQ_HZ / 16 / gd->baudrate;
75 (void) NS16550_init(COM_PORTS[1], clock_divisor);
76#endif
77#endif
78 return 0;
79
80}
81
82void
83serial_putc(const char c)
84{
85 if (c == '\n')
86 NS16550_putc(COM_PORTS[CFG_DUART_CHAN], '\r');
87
88 NS16550_putc(COM_PORTS[CFG_DUART_CHAN], c);
89}
90
91int
92serial_getc(void)
93{
94 return NS16550_getc(COM_PORTS[CFG_DUART_CHAN]);
95}
96
97int
98serial_tstc(void)
99{
100 return NS16550_tstc(COM_PORTS[CFG_DUART_CHAN]);
101}
102
103void
104serial_setbrg(void)
105{
106#if USE_CHAN1
wdenk028ab6b2004-02-23 23:54:43 +0000107 int clock_divisor;
108
109 clock_divisor = XPAR_UARTNS550_0_CLOCK_FREQ_HZ / 16 / gd->baudrate;
110 NS16550_reinit(COM_PORTS[0], clock_divisor);
111#if USE_CHAN2
112 clock_divisor = XPAR_UARTNS550_1_CLOCK_FREQ_HZ / 16 / gd->baudrate;
113 NS16550_reinit(COM_PORTS[1], clock_divisor);
114#endif
115#endif
116}
117
118void
119serial_puts(const char *s)
120{
121 while (*s) {
122 serial_putc(*s++);
123 }
124}
125
126#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
127void
128kgdb_serial_init(void)
129{
130}
131
132void
133putDebugChar(int c)
134{
135 serial_putc(c);
136}
137
138void
139putDebugStr(const char *str)
140{
141 serial_puts(str);
142}
143
144int
145getDebugChar(void)
146{
147 return serial_getc();
148}
149
150void
151kgdb_interruptible(int yes)
152{
153 return;
154}
155#endif /* CFG_CMD_KGDB */