--- 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@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox