3
* Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
6
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
7
* Marius Groeger <mgroeger@sysgo.de>
10
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
11
* Alex Zuepke <azu@sysgo.de>
13
* Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
15
* This program is free software; you can redistribute it and/or modify
16
* it under the terms of the GNU General Public License as published by
17
* the Free Software Foundation; either version 2 of the License, or
18
* (at your option) any later version.
20
* This program is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
* GNU General Public License for more details.
25
* You should have received a copy of the GNU General Public License
26
* along with this program; if not, write to the Free Software
27
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34
DECLARE_GLOBAL_DATA_PTR;
36
void serial_setbrg (void)
40
if (gd->baudrate == 1200)
42
else if (gd->baudrate == 9600)
44
else if (gd->baudrate == 19200)
46
else if (gd->baudrate == 38400)
48
else if (gd->baudrate == 57600)
50
else if (gd->baudrate == 115200)
56
/* SA1110 uart function */
57
Ser1SDCR0 |= SDCR0_SUS;
59
/* Wait until port is ready ... */
60
while(Ser1UTSR1 & UTSR1_TBY) {}
62
/* init serial serial 1 */
65
Ser1UTCR0 = ( UTCR0_1StpBit | UTCR0_8BitData );
68
Ser1UTCR3 = ( UTCR3_RXE | UTCR3_TXE );
69
#elif defined(CONFIG_SERIAL3)
70
/* Wait until port is ready ... */
71
while (Ser3UTSR1 & UTSR1_TBY) {
74
/* init serial serial 3 */
77
Ser3UTCR0 = (UTCR0_1StpBit | UTCR0_8BitData);
79
Ser3UTCR2 = (u32) reg;
80
Ser3UTCR3 = (UTCR3_RXE | UTCR3_TXE);
82
#error "Bad: you didn't configured serial ..."
88
* Initialise the serial port with the given baudrate. The settings
89
* are always 8 data bits, no parity, 1 stop bit, no start bits.
92
int serial_init (void)
101
* Output a single byte to the serial port.
103
void serial_putc (const char c)
105
#ifdef CONFIG_SERIAL1
106
/* wait for room in the tx FIFO on SERIAL1 */
107
while ((Ser1UTSR0 & UTSR0_TFS) == 0);
110
#elif defined(CONFIG_SERIAL3)
111
/* wait for room in the tx FIFO on SERIAL3 */
112
while ((Ser3UTSR0 & UTSR0_TFS) == 0);
117
/* If \n, also do \r */
123
* Read a single byte from the serial port. Returns 1 on success, 0
124
* otherwise. When the function is succesfull, the character read is
125
* written into its argument c.
127
int serial_tstc (void)
129
#ifdef CONFIG_SERIAL1
130
return Ser1UTSR1 & UTSR1_RNE;
131
#elif defined(CONFIG_SERIAL3)
132
return Ser3UTSR1 & UTSR1_RNE;
137
* Read a single byte from the serial port. Returns 1 on success, 0
138
* otherwise. When the function is succesfull, the character read is
139
* written into its argument c.
141
int serial_getc (void)
143
#ifdef CONFIG_SERIAL1
144
while (!(Ser1UTSR1 & UTSR1_RNE));
146
return (char) Ser1UTDR & 0xff;
147
#elif defined(CONFIG_SERIAL3)
148
while (!(Ser3UTSR1 & UTSR1_RNE));
150
return (char) Ser3UTDR & 0xff;
155
serial_puts (const char *s)