2 * Sysgo Real
-Time Solutions
, GmbH
<www
.elinos
.com
>
3 * Marius Groeger
<mgroeger@sysgo
.de
>
7 * Wolfgang Denk
, DENX Software Engineering
, <wd@denx
.de
>
10 * Sysgo Real
-Time Solutions
, GmbH
<www
.elinos
.com
>
11 * Marius Groeger
<mgroeger@sysgo
.de
>
14 * Sysgo Real
-Time Solutions
, GmbH
<www
.elinos
.com
>
15 * Alex Zuepke
<azu@sysgo
.de
>
17 * Copyright (C
) 1999 2000 2001 Erik
Mouw (J
.A
.K
.Mouw@its
.tudelft
.nl
)
19 * SPDX
-License
-Identifier
: GPL
-2.0+
23 #include <asm/hardware.h>
25 DECLARE_GLOBAL_DATA_PTR
;
27 /* flush serial input queue. returns 0 on success or negative error
30 static int serial_flush_input(void)
34 /* keep on reading as long as the receiver is not empty */
35 while(UTRSTAT0
&0x01) {
43 /* flush output queue. returns 0 on success or negative error number
46 static int serial_flush_output(void)
48 /* wait until the transmitter is no longer busy */
49 while(!(UTRSTAT0
& 0x02)) {
56 static void s3c44b0_serial_setbrg(void)
60 /* get correct divisor */
61 switch(gd
->baudrate
) {
64 #if CONFIG_S3C44B0_CLOCK_SPEED==66
66 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
69 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
74 #if CONFIG_S3C44B0_CLOCK_SPEED==66
76 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
79 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
84 #if CONFIG_S3C44B0_CLOCK_SPEED==66
86 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
89 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
94 #if CONFIG_S3C44B0_CLOCK_SPEED==66
96 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
99 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
103 #if CONFIG_S3C44B0_CLOCK_SPEED==66
105 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
108 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
112 #if CONFIG_S3C44B0_CLOCK_SPEED==66
114 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
117 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
121 serial_flush_output();
122 serial_flush_input();
133 for(divisor
=0; divisor
<100; divisor
++) {
140 * Initialise the serial port with the given baudrate. The settings
141 * are always 8 data bits, no parity, 1 stop bit, no start bits.
144 static int s3c44b0_serial_init(void)
153 * Output a single byte to the serial port.
155 static void s3c44b0_serial_putc(const char c
)
157 /* wait for room in the transmit FIFO */
158 while(!(UTRSTAT0
& 0x02));
160 UTXH0
= (unsigned char)c
;
163 to be polite with serial console add a line feed
164 to the carriage return character
171 * Read a single byte from the serial port. Returns 1 on success, 0
172 * otherwise. When the function is succesfull, the character read is
173 * written into its argument c.
175 static int s3c44b0_serial_tstc(void)
177 return (UTRSTAT0
& 0x01);
181 * Read a single byte from the serial port. Returns 1 on success, 0
182 * otherwise. When the function is succesfull, the character read is
183 * written into its argument c.
185 static int s3c44b0_serial_getc(void)
190 rv
= s3c44b0_serial_tstc();
197 static struct serial_device s3c44b0_serial_drv
= {
198 .name
= "s3c44b0_serial",
199 .start
= s3c44b0_serial_init
,
201 .setbrg
= s3c44b0_serial_setbrg
,
202 .putc
= s3c44b0_serial_putc
,
203 .puts
= default_serial_puts
,
204 .getc
= s3c44b0_serial_getc
,
205 .tstc
= s3c44b0_serial_tstc
,
208 void s3c44b0_serial_initialize(void)
210 serial_register(&s3c44b0_serial_drv
);
213 __weak
struct serial_device
*default_serial_console(void)
215 return &s3c44b0_serial_drv
;