3 * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (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, MA 02111-1307 USA
22 #if defined(CONFIG_S3C2400) || defined(CONFIG_TRAB)
24 #elif defined(CONFIG_S3C2410)
29 void serial_setbrg (void)
31 DECLARE_GLOBAL_DATA_PTR;
36 /* value is calculated so : (int)(PCLK/16./baudrate) -1 */
37 reg = get_PCLK() / (16 * gd->baudrate) - 1;
40 /* FIFO enable, Tx/Rx FIFO clear */
43 /* Normal,No parity,1 stop,8 bit */
46 * tx=level,rx=edge,disable timeout int.,enable rx error int.,
47 * normal,interrupt or polling
53 rUMCON0 = 0x1; /* RTS up */
55 for (i = 0; i < 100; i++);
57 # if defined(CONFIG_TRAB)
58 # #error "TRAB supports only CONFIG_SERIAL1"
60 /* FIFO enable, Tx/Rx FIFO clear */
63 /* Normal,No parity,1 stop,8 bit */
66 * tx=level,rx=edge,disable timeout int.,enable rx error int.,
67 * normal,interrupt or polling
73 rUMCON1 = 0x1; /* RTS up */
75 for (i = 0; i < 100; i++);
77 #error "Bad: you didn't configure serial ..."
82 * Initialise the serial port with the given baudrate. The settings
83 * are always 8 data bits, no parity, 1 stop bit, no start bits.
86 int serial_init (void)
94 * Read a single byte from the serial port. Returns 1 on success, 0
95 * otherwise. When the function is succesfull, the character read is
96 * written into its argument c.
98 int serial_getc (void)
100 #ifdef CONFIG_SERIAL1
101 while (!(rUTRSTAT0 & 0x1));
103 return rURXH0 & 0xff;
105 while (!(rUTRSTAT1 & 0x1));
107 return rURXH1 & 0xff;
112 static int hwflow = 0; /* turned off by default */
113 int hwflow_onoff(int on)
118 break; /* return current */
120 hwflow = 1; /* turn on */
123 hwflow = 0; /* turn off */
130 #ifdef CONFIG_MODEM_SUPPORT
131 static int be_quiet = 0;
132 void disable_putc(void)
137 void enable_putc(void)
145 * Output a single byte to the serial port.
147 void serial_putc (const char c)
149 #ifdef CONFIG_MODEM_SUPPORT
154 #ifdef CONFIG_SERIAL1
155 /* wait for room in the tx FIFO on SERIAL1 */
156 while (!(rUTRSTAT0 & 0x2));
159 /* Wait for CTS up */
160 while(hwflow && !(rUMSTAT0 & 0x1))
166 /* wait for room in the tx FIFO on SERIAL2 */
167 while (!(rUTRSTAT1 & 0x2));
170 /* Wait for CTS up */
171 while(hwflow && !(rUMSTAT1 & 0x1))
177 /* If \n, also do \r */
183 * Test whether a character is in the RX buffer
185 int serial_tstc (void)
187 #ifdef CONFIG_SERIAL1
188 return rUTRSTAT0 & 0x1;
190 return rUTRSTAT1 & 0x1;
195 serial_puts (const char *s)