
(please CC me as I am not on the list yet). -- From: Florian Fainelli florian.fainelli@openpattern.org Date: Wed, 24 Sep 2008 10:46:10 +0200 Subject: [PATCH] serial: add support for the OMRPv2 simple wishbone UART
This patch adds support for the wishbone UART we are using on the OpenPattern Modular Routing Platform v2. wb_uart HDL files can be found here : https://dev.openpattern.org/browser/trunk/fpga/aemb/rtl/wb_uart
Signed-off-by: Florian Fainelli florian.fainelli@openpattern.org --- drivers/serial/Makefile | 1 + drivers/serial/serial_wbuart.c | 73 +++++++++++++++++++++ include/asm-microblaze/arch-microblaze/wbuart_l.h | 15 ++++ include/asm-microblaze/serial_wbuart.h | 25 +++++++ 4 files changed, 114 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/serial_wbuart.c create mode 100644 include/asm-microblaze/arch-microblaze/wbuart_l.h create mode 100644 include/asm-microblaze/serial_wbuart.h
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index c9e797e..12dfaa2 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -36,6 +36,7 @@ COBJS-y += serial_pl010.o COBJS-y += serial_pl011.o COBJS-y += serial_xuartlite.o COBJS-y += serial_sh.o +COBJS-y += serial_wbuart.o COBJS-y += usbtty.o
COBJS := $(COBJS-y) diff --git a/drivers/serial/serial_wbuart.c b/drivers/serial/serial_wbuart.c new file mode 100644 index 0000000..a13ef2a --- /dev/null +++ b/drivers/serial/serial_wbuart.c @@ -0,0 +1,73 @@ +/* + * (C) Copyright 2008 OpenPattern SARL + * + * Florian Fainelli florian.fainelli@openpattern.org + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <config.h> + +#ifdef CONFIG_WB_UART + +#include <asm/serial_wbuart.h> + +#define IO_WORD(offset) (*(volatile unsigned long *)(offset)) +#define IO_SERIAL(offset) IO_WORD(CONFIG_SERIAL_BASE + (offset)) + +#define IO_SERIAL_RXTX IO_SERIAL(WUB_RXTX_OFFSET) +#define IO_SERIAL_UCR IO_SERIAL(WUB_UCR_OFFSET) + +int serial_init(void) +{ + /* FIXME: Nothing for now. We should initialize fifo, etc */ + return 0; +} + +void serial_setbrg(void) +{ + /* FIXME: what's this for? */ +} + +void serial_putc(const char c) +{ + if (c == '\n') serial_putc('\r'); + while(IO_SERIAL_UCR & WUB_BUSY); + IO_SERIAL_RXTX = c; +} + +void serial_puts(const char * s) +{ + while (*s) { + serial_putc(*s++); + } +} + +int serial_getc(void) +{ + while(!(IO_SERIAL_UCR & WUB_DR)); + return IO_SERIAL_RXTX; +} + +int serial_tstc(void) +{ + return 0; +} + +#endif /* CONFIG_WB_UART */ diff --git a/include/asm-microblaze/arch-microblaze/wbuart_l.h b/include/asm-microblaze/arch-microblaze/wbuart_l.h new file mode 100644 index 0000000..cf4b90e --- /dev/null +++ b/include/asm-microblaze/arch-microblaze/wbuart_l.h @@ -0,0 +1,15 @@ +/* + * Wishbone UART low-level definitions + */ + +#ifndef WBUART_L_H +#define WUBART_L_H + +#define WUB_UCR_OFFSET 0x0 +#define WUB_RXTX_OFFSET 0x4 + +#define WUB_DR 0x01 +#define WUB_ERR 0x02 +#define WUB_BUSY 0x10 + +#endif /* WBUART_L_H */ diff --git a/include/asm-microblaze/serial_wbuart.h b/include/asm-microblaze/serial_wbuart.h new file mode 100644 index 0000000..089d19b --- /dev/null +++ b/include/asm-microblaze/serial_wbuart.h @@ -0,0 +1,25 @@ +/* + * (C) Copyright 2008 OpenPattern SARL + * + * Florian Fainelli florian.fainelli@openpattern.org + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <asm/arch/wbuart_l.h>