]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cpu/arm920t/s3c24x0/serial.c
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_S3C2410) || defined (CONFIG_TRAB)
24 #if defined(CONFIG_S3C2400) || defined(CONFIG_TRAB)
26 #elif defined(CONFIG_S3C2410)
30 DECLARE_GLOBAL_DATA_PTR
;
33 #define UART_NR S3C24X0_UART0
35 #elif defined(CONFIG_SERIAL2)
36 # if defined(CONFIG_TRAB)
37 # error "TRAB supports only CONFIG_SERIAL1"
39 #define UART_NR S3C24X0_UART1
41 #elif defined(CONFIG_SERIAL3)
42 # if defined(CONFIG_TRAB)
43 # #error "TRAB supports only CONFIG_SERIAL1"
45 #define UART_NR S3C24X0_UART2
48 #error "Bad: you didn't configure serial ..."
51 void serial_setbrg (void)
53 S3C24X0_UART
* const uart
= S3C24X0_GetBase_UART(UART_NR
);
57 /* value is calculated so : (int)(PCLK/16./baudrate) -1 */
58 reg
= get_PCLK() / (16 * gd
->baudrate
) - 1;
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 uart
->UMCON
= 0x1; /* RTS up */
75 for (i
= 0; i
< 100; i
++);
79 * Initialise the serial port with the given baudrate. The settings
80 * are always 8 data bits, no parity, 1 stop bit, no start bits.
83 int serial_init (void)
91 * Read a single byte from the serial port. Returns 1 on success, 0
92 * otherwise. When the function is succesfull, the character read is
93 * written into its argument c.
95 int serial_getc (void)
97 S3C24X0_UART
* const uart
= S3C24X0_GetBase_UART(UART_NR
);
99 /* wait for character to arrive */
100 while (!(uart
->UTRSTAT
& 0x1));
102 return uart
->URXH
& 0xff;
106 static int hwflow
= 0; /* turned off by default */
107 int hwflow_onoff(int on
)
112 break; /* return current */
114 hwflow
= 1; /* turn on */
117 hwflow
= 0; /* turn off */
124 #ifdef CONFIG_MODEM_SUPPORT
125 static int be_quiet
= 0;
126 void disable_putc(void)
131 void enable_putc(void)
139 * Output a single byte to the serial port.
141 void serial_putc (const char c
)
143 S3C24X0_UART
* const uart
= S3C24X0_GetBase_UART(UART_NR
);
144 #ifdef CONFIG_MODEM_SUPPORT
149 /* wait for room in the tx FIFO */
150 while (!(uart
->UTRSTAT
& 0x2));
153 /* Wait for CTS up */
154 while(hwflow
&& !(uart
->UMSTAT
& 0x1))
160 /* If \n, also do \r */
166 * Test whether a character is in the RX buffer
168 int serial_tstc (void)
170 S3C24X0_UART
* const uart
= S3C24X0_GetBase_UART(UART_NR
);
172 return uart
->UTRSTAT
& 0x1;
176 serial_puts (const char *s
)
183 #endif /* defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) */