[U-Boot] [PATCH] serial: add support for the OMRPv2 simple wishbone UART

(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>

On 12:30 Wed 24 Sep , Florian Fainelli wrote:
(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
Is it applied?
Best Regards, J.

Dear Florian Fainelli,
In message 200809241230.21624.florian.fainelli@openpattern.org you wrote:
(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
It seems ther eis no board in the mainline U-Boot code which uses this driver.
Do you plan to submit any board support that will actually use this driver?
diff --git a/drivers/serial/serial_wbuart.c b/drivers/serial/serial_wbuart.c new file mode 100644 index 0000000..a13ef2a
...
+#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)
Accesses to device registers through volatile pointers are depre- cated. Please use the respective accessor macros / functions instead.
+void serial_setbrg(void) +{
- /* FIXME: what's this for? */
+}
That's to set the baud rate. This function seems to be missing in your driver?
+void serial_putc(const char c) +{
- if (c == '\n') serial_putc('\r');
- while(IO_SERIAL_UCR & WUB_BUSY);
Please write like this:
while(IO_SERIAL_UCR & WUB_BUSY) ;
+void serial_puts(const char * s) +{
- while (*s) {
serial_putc(*s++);
- }
No curly braces for a single line statement, please.
- while(!(IO_SERIAL_UCR & WUB_DR));
See above.
--- /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>
This makes no sense to me - a header file which contains just a single line include for another header file?
Best regards,
Wolfgang Denk

Hi Wolfgang,
Le Tuesday 14 October 2008 15:08:14 Wolfgang Denk, vous avez écrit :
It seems ther eis no board in the mainline U-Boot code which uses this driver.
Do you plan to submit any board support that will actually use this driver?
Of course. I actually wanted to know about the good programming pratice before submitting it.
Accesses to device registers through volatile pointers are depre- cated. Please use the respective accessor macros / functions instead.
Ok, I could probably fixup the uartlite driver with another patch to use the proper accessors. I derived this driver from it.
That's to set the baud rate. This function seems to be missing in your driver?
Baudrate is hardcoded in the IP core because it is very simple and occupyiong only a few LUTs. I do not think I will have to change the baudrate ever.
Please write like this:
while(IO_SERIAL_UCR & WUB_BUSY) ;
Ok.
+void serial_puts(const char * s) +{
- while (*s) {
serial_putc(*s++);
- }
No curly braces for a single line statement, please.
- while(!(IO_SERIAL_UCR & WUB_DR));
See above.
This makes no sense to me - a header file which contains just a single line include for another header file?
I was following the uartlite/microblaze pratice, but that's right it does not make sense at all.
Thank you very much for your comments, when board support is ready I will resubmit everything in separate patches.
participants (3)
-
Florian Fainelli
-
Jean-Christophe PLAGNIOL-VILLARD
-
Wolfgang Denk