From: vj <vicencb@gmail.com>
To: barebox@lists.infradead.org
Cc: vj <vicencb@gmail.com>
Subject: [PATCH 5/7] add console support over the same USB used for booting
Date: Wed, 26 Sep 2012 00:59:52 +0200 [thread overview]
Message-ID: <1348613994-1793-6-git-send-email-vicencb@gmail.com> (raw)
In-Reply-To: <1348613994-1793-1-git-send-email-vicencb@gmail.com>
---
drivers/serial/Kconfig | 7 +++++
drivers/serial/Makefile | 1 +
drivers/serial/serial_usb.c | 64 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+)
create mode 100644 drivers/serial/serial_usb.c
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 7eb96ed..4e85e1f 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_USB
+ bool "serial driver over omap4 usb"
+ default n
+ depends on USB_BOOT
+ 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..a89bb44 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_USB) += serial_usb.o
diff --git a/drivers/serial/serial_usb.c b/drivers/serial/serial_usb.c
new file mode 100644
index 0000000..25391db
--- /dev/null
+++ b/drivers/serial/serial_usb.c
@@ -0,0 +1,64 @@
+/*
+ * Use of usb-port as a serial communications port
+*/
+
+#include <common.h>
+#include <init.h>
+#include <malloc.h>
+#include <errno.h>
+#include <mach/omap4_rom_usb.h>
+
+struct serial_usb_priv {
+ struct console_device cdev;
+ int val;
+};
+
+static void serial_usb_putc(struct console_device *cdev, char c){
+ unsigned b = c;
+ usb_write(&b, 4);
+}
+
+static int serial_usb_tstc(struct console_device *cdev){
+ struct serial_usb_priv *priv = container_of(cdev, struct serial_usb_priv, cdev);
+ if(pusb->dread.status == -1 || pusb->dread.status == STATUS_WAITING)
+ return 0;
+ else if(pusb->dread.status != STATUS_OKAY)
+ usb_queue_read(&priv->val, 4);
+ return pusb->dread.status == STATUS_OKAY;
+}
+
+static int serial_usb_getc(struct console_device *cdev){
+ struct serial_usb_priv *priv = container_of(cdev, struct serial_usb_priv, cdev);
+ if(pusb->dread.status == -1 || pusb->dread.status == STATUS_WAITING)
+ ;
+ else if(pusb->dread.status != STATUS_OKAY)
+ usb_queue_read(&priv->val, 4);
+ usb_wait_read();
+ pusb->dread.status = -2;
+ return priv->val;
+}
+
+static int serial_usb_probe(struct device_d *dev){
+ struct serial_usb_priv *priv;
+ priv = xzalloc(sizeof(*priv));
+ pusb->dread.status=-2;
+
+ priv->cdev.dev = dev;
+ priv->cdev.f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+ priv->cdev.tstc = serial_usb_tstc;
+ priv->cdev.putc = serial_usb_putc;
+ priv->cdev.getc = serial_usb_getc;
+ priv->cdev.setbrg = NULL;
+
+ return console_register(&priv->cdev);
+}
+
+static struct driver_d serial_usb_driver = {
+ .name = "serial_usb",
+ .probe = serial_usb_probe,
+};
+
+static int serial_usb_init(void){
+ return register_driver(&serial_usb_driver);
+}
+console_initcall(serial_usb_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-25 23:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[RFC][PATCH] archosg9: add support for tablet>
2012-09-25 22:59 ` [PATCH 0/7] [RFC][PATCH] archosg9: add support for tablet vj
2012-09-25 22:59 ` [PATCH 1/7] Improved an error message and solved a minor bug vj
2012-09-26 7:11 ` Sascha Hauer
2012-09-25 22:59 ` [PATCH 2/7] added debug info for twl6030 vj
2012-09-25 22:59 ` [PATCH 3/7] OMAP specific changes vj
2012-09-26 7:18 ` Sascha Hauer
2012-09-25 22:59 ` [PATCH 4/7] Add USB booting capabilities to OMAP vj
2012-09-26 7:45 ` Sascha Hauer
2012-09-28 0:27 ` vj
2012-09-28 7:32 ` Sascha Hauer
2012-09-25 22:59 ` vj [this message]
2012-09-25 22:59 ` [PATCH 6/7] add filesystem support over the same USB used for booting vj
2012-09-25 22:59 ` [PATCH 7/7] Add support for Archos G9 tablet vj
2012-09-26 3:57 ` [PATCH 0/7] [RFC][PATCH] archosg9: add support for tablet Antony Pavlov
2012-09-26 7:06 ` Sascha Hauer
2012-09-26 22:38 ` vj
2012-09-26 8:16 ` 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=1348613994-1793-6-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