From: vj <vicencb@gmail.com>
To: barebox@lists.infradead.org
Cc: vj <vicencb@gmail.com>
Subject: [PATCH 7/9] omap4: add serial communications over usb boot
Date: Sun, 30 Sep 2012 04:50:35 +0200 [thread overview]
Message-ID: <1348973437-31132-8-git-send-email-vicencb@gmail.com> (raw)
In-Reply-To: <1348973437-31132-1-git-send-email-vicencb@gmail.com>
---
drivers/serial/Kconfig | 7 +++
drivers/serial/Makefile | 1 +
drivers/serial/serial_omap4_usbboot.c | 87 +++++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+)
create mode 100644 drivers/serial/serial_omap4_usbboot.c
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 7eb96ed..0627b6e 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -100,4 +100,11 @@ config DRIVER_SERIAL_PXA
bool "PXA serial driver"
depends on ARCH_PXA
+config DRIVER_SERIAL_OMAP4_USBBOOT
+ bool "serial driver over omap4 usb"
+ default n
+ depends on OMAP4_USBBOOT
+ help
+ Enable this to get console support over the usb bus used to boot an OMAP4
+
endmenu
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index e2d56b9..ff99e72 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -19,3 +19,4 @@ obj-$(CONFIG_DRIVER_SERIAL_S3C) += serial_s3c.o
obj-$(CONFIG_DRIVER_SERIAL_ALTERA) += serial_altera.o
obj-$(CONFIG_DRIVER_SERIAL_ALTERA_JTAG) += serial_altera_jtag.o
obj-$(CONFIG_DRIVER_SERIAL_PXA) += serial_pxa.o
+obj-$(CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT) += serial_omap4_usbboot.o
diff --git a/drivers/serial/serial_omap4_usbboot.c b/drivers/serial/serial_omap4_usbboot.c
new file mode 100644
index 0000000..e1653b8
--- /dev/null
+++ b/drivers/serial/serial_omap4_usbboot.c
@@ -0,0 +1,87 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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 <common.h>
+#include <init.h>
+#include <malloc.h>
+#include <errno.h>
+#include <mach/omap4_rom_usb.h>
+
+struct serial_omap4_usbboot_priv {
+ struct console_device cdev;
+ u32 val;
+};
+
+static void serial_omap4_usbboot_putc(struct console_device *cdev, char c)
+{
+ unsigned b = c;
+ omap4_usbboot_write(&b, 4);
+}
+
+static int serial_omap4_usbboot_tstc(struct console_device *cdev)
+{
+ struct serial_omap4_usbboot_priv *priv =
+ container_of(cdev, struct serial_omap4_usbboot_priv, cdev);
+ if (omap4_usbboot_is_read_waiting())
+ return 0;
+ else if (omap4_usbboot_is_read_ok())
+ return 1;
+ omap4_usbboot_queue_read(&priv->val, 4);
+ udelay(100);
+ if (omap4_usbboot_is_read_waiting())
+ return 0;
+ else if (omap4_usbboot_is_read_ok())
+ return 1;
+ return 0;
+}
+
+static int serial_omap4_usbboot_getc(struct console_device *cdev)
+{
+ struct serial_omap4_usbboot_priv *priv =
+ container_of(cdev, struct serial_omap4_usbboot_priv, cdev);
+ if (omap4_usbboot_is_read_waiting() || omap4_usbboot_is_read_ok()) {
+ omap4_usbboot_wait_read();
+ return priv->val;
+ }
+ omap4_usbboot_read(&priv->val, 4);
+ return priv->val;
+}
+
+static int serial_omap4_usbboot_probe(struct device_d *dev)
+{
+ struct serial_omap4_usbboot_priv *priv;
+ priv = xzalloc(sizeof(*priv));
+
+ priv->cdev.dev = dev;
+ priv->cdev.f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+ priv->cdev.tstc = serial_omap4_usbboot_tstc;
+ priv->cdev.putc = serial_omap4_usbboot_putc;
+ priv->cdev.getc = serial_omap4_usbboot_getc;
+ priv->cdev.setbrg = NULL;
+
+ return console_register(&priv->cdev);
+}
+
+static struct driver_d serial_omap4_usbboot_driver = {
+ .name = "serial_omap4_usbboot",
+ .probe = serial_omap4_usbboot_probe,
+};
+
+static int serial_omap4_usbboot_init(void)
+{
+ return register_driver(&serial_omap4_usbboot_driver);
+}
+console_initcall(serial_omap4_usbboot_init);
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-09-30 2:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
2012-09-30 2:50 ` [PATCH 1/9] ARM: set rev instead of returning it vj
2012-09-30 2:50 ` [PATCH 2/9] mmc_omap: improve error message vj
2012-09-30 2:50 ` [PATCH 3/9] omap4: add/rename definitions to match datasheet vj
2012-09-30 2:50 ` [PATCH 4/9] twl6030: add debug info vj
2012-09-30 13:50 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02 13:46 ` Sascha Hauer
2012-09-30 2:50 ` [PATCH 5/9] add gitignore file vj
2012-09-30 2:50 ` [PATCH 6/9] omap4: add usb boot support vj
2012-09-30 12:14 ` Antony Pavlov
2012-09-30 14:02 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:02 ` vj
2012-09-30 15:29 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 16:00 ` vj
2012-10-01 12:48 ` Sascha Hauer
2012-09-30 14:07 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:23 ` vj
2012-09-30 15:30 ` vj
[not found] ` <CAAMcf8B0Qif3zVfw44zx5G813fYrMQTfUKi86Kr+JuFm=yf5rQ@mail.gmail.com>
2012-09-30 15:32 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02 13:51 ` Sascha Hauer
2012-09-30 2:50 ` vj [this message]
2012-09-30 2:50 ` [PATCH 8/9] omap4: add filesystem support over usb boot vj
2012-09-30 13:53 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 2:50 ` [PATCH 9/9] Add support for Archos G9 tablet vj
2012-09-30 14:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:02 ` Antony Pavlov
2012-10-02 17:06 ` [PATCH 0/9] archosg9: add support for tablet, second round Sascha Hauer
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=1348973437-31132-8-git-send-email-vicencb@gmail.com \
--to=vicencb@gmail.com \
--cc=barebox@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox