4 * http://www.dave-tech.it
5 * http://www.wawnet.biz
6 * mailto:info@wawnet.biz
8 * (C) Copyright 2002-2004
9 * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
12 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
13 * Marius Groeger <mgroeger@sysgo.de>
16 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
17 * Alex Zuepke <azu@sysgo.de>
19 * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 2 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 #include <asm/hardware.h>
40 DECLARE_GLOBAL_DATA_PTR;
42 /* flush serial input queue. returns 0 on success or negative error
45 static int serial_flush_input(void)
49 /* keep on reading as long as the receiver is not empty */
50 while(UTRSTAT0&0x01) {
58 /* flush output queue. returns 0 on success or negative error number
61 static int serial_flush_output(void)
63 /* wait until the transmitter is no longer busy */
64 while(!(UTRSTAT0 & 0x02)) {
71 void serial_setbrg (void)
75 /* get correct divisor */
76 switch(gd->baudrate) {
79 #if CONFIG_S3C44B0_CLOCK_SPEED==66
81 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
84 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
89 #if CONFIG_S3C44B0_CLOCK_SPEED==66
91 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
94 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
99 #if CONFIG_S3C44B0_CLOCK_SPEED==66
101 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
104 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
109 #if CONFIG_S3C44B0_CLOCK_SPEED==66
111 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
114 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
118 #if CONFIG_S3C44B0_CLOCK_SPEED==66
120 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
123 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
127 #if CONFIG_S3C44B0_CLOCK_SPEED==66
129 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
132 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
136 serial_flush_output();
137 serial_flush_input();
148 for(divisor=0; divisor<100; divisor++) {
155 * Initialise the serial port with the given baudrate. The settings
156 * are always 8 data bits, no parity, 1 stop bit, no start bits.
159 int serial_init (void)
168 * Output a single byte to the serial port.
170 void serial_putc (const char c)
172 /* wait for room in the transmit FIFO */
173 while(!(UTRSTAT0 & 0x02));
175 UTXH0 = (unsigned char)c;
178 to be polite with serial console add a line feed
179 to the carriage return character
186 * Read a single byte from the serial port. Returns 1 on success, 0
187 * otherwise. When the function is succesfull, the character read is
188 * written into its argument c.
190 int serial_tstc (void)
192 return (UTRSTAT0 & 0x01);
196 * Read a single byte from the serial port. Returns 1 on success, 0
197 * otherwise. When the function is succesfull, the character read is
198 * written into its argument c.
200 int serial_getc (void)
213 serial_puts (const char *s)