blob: d678ab6b766e46eece567eb714f4a9140af0c39c [file] [log] [blame]
wdenk507bbe32004-04-18 21:13:41 +00001/*
2 * (C) Copyright 2004 Atmark Techno, Inc.
3 *
4 * Yasushi SHOJI <yashi@atmark-techno.com>
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#include <config.h>
wdenke35745b2004-04-18 23:32:11 +000026
Michal Simek0731cba2007-09-24 00:25:11 +020027#ifdef CONFIG_XILINX_UARTLITE
wdenke35745b2004-04-18 23:32:11 +000028
wdenk507bbe32004-04-18 21:13:41 +000029#include <asm/serial_xuartlite.h>
30
31/* FIXME: we should convert these to in32 and out32 */
32#define IO_WORD(offset) (*(volatile unsigned long *)(offset))
33#define IO_SERIAL(offset) IO_WORD(CONFIG_SERIAL_BASE + (offset))
34
35#define IO_SERIAL_RX_FIFO IO_SERIAL(XUL_RX_FIFO_OFFSET)
36#define IO_SERIAL_TX_FIFO IO_SERIAL(XUL_TX_FIFO_OFFSET)
37#define IO_SERIAL_STATUS IO_SERIAL(XUL_STATUS_REG_OFFSET)
38#define IO_SERIAL_CONTROL IO_SERIAL(XUL_CONTROL_REG_OFFSET)
39
40int serial_init(void)
41{
42 /* FIXME: Nothing for now. We should initialize fifo, etc */
43 return 0;
44}
45
46void serial_setbrg(void)
47{
48 /* FIXME: what's this for? */
49}
50
51void serial_putc(const char c)
52{
53 if (c == '\n') serial_putc('\r');
54 while (IO_SERIAL_STATUS & XUL_SR_TX_FIFO_FULL);
55 IO_SERIAL_TX_FIFO = (unsigned char) (c & 0xff);
wdenk507bbe32004-04-18 21:13:41 +000056}
57
58void serial_puts(const char * s)
59{
60 while (*s) {
61 serial_putc(*s++);
62 }
63}
64
65int serial_getc(void)
66{
67 while (!(IO_SERIAL_STATUS & XUL_SR_RX_FIFO_VALID_DATA));
68 return IO_SERIAL_RX_FIFO & 0xff;
69}
70
71int serial_tstc(void)
72{
73 return (IO_SERIAL_STATUS & XUL_SR_RX_FIFO_VALID_DATA);
74}
wdenke35745b2004-04-18 23:32:11 +000075
76#endif /* CONFIG_MICROBLZE */