All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <florian.fainelli@openpattern.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] serial: add support for the OMRPv2 simple wishbone UART
Date: Wed, 24 Sep 2008 12:30:21 +0200	[thread overview]
Message-ID: <200809241230.21624.florian.fainelli@openpattern.org> (raw)

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

             reply	other threads:[~2008-09-24 10:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-24 10:30 Florian Fainelli [this message]
2008-10-10 19:19 ` [U-Boot] [PATCH] serial: add support for the OMRPv2 simple wishbone UART Jean-Christophe PLAGNIOL-VILLARD
2008-10-14 13:08 ` Wolfgang Denk
2008-10-14 16:04   ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200809241230.21624.florian.fainelli@openpattern.org \
    --to=florian.fainelli@openpattern.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.