diff options
author | Anton Staaf <robotboy@chromium.org> | 2014-09-10 14:32:27 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-29 18:38:27 +0000 |
commit | ac375d000eba1e3b582018ebfcbf654af41bdcb9 (patch) | |
tree | 3103952b3570a061367b9bd7605fea30fcc14366 /extra | |
parent | d7b99e993a343cca6a6ba403b2837548a5524f09 (diff) | |
download | chrome-ec-ac375d000eba1e3b582018ebfcbf654af41bdcb9.tar.gz |
USB-console: Add Linux USB serial kernel module
This is a simple kernel module and Makefile for
building it out of tree. This module just uses
the existing kernel usb serial driver and probes
for the Google VID/Class/SubClass/Protocol that
identifies a valid simple serial interface.
This code should be rolled into the existing kernel
driver at: drivers/usb/serial/usb-serial-simple.c
While that happens, this module is still useful to
developers.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=cd extra/usb_serial; make; sudo insmod raiden.ko
Connect the discovery-stm32f072 over USB and see
that its console is discovered and works.
Change-Id: I83661b816643c43b3e2dc9fdc825bc3a796af2f4
Reviewed-on: https://chromium-review.googlesource.com/225923
Reviewed-by: Olof Johansson <olofj@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'extra')
-rw-r--r-- | extra/usb_serial/Makefile | 10 | ||||
-rw-r--r-- | extra/usb_serial/raiden.c | 46 |
2 files changed, 56 insertions, 0 deletions
diff --git a/extra/usb_serial/Makefile b/extra/usb_serial/Makefile new file mode 100644 index 0000000000..9c478050cc --- /dev/null +++ b/extra/usb_serial/Makefile @@ -0,0 +1,10 @@ +obj-m := raiden.o + +.PHONY: all + +all: modules + +.DEFAULT: + $(MAKE) -C /lib/modules/$(shell uname -r)/build \ + M=$(shell pwd) \ + $(MAKECMDGOALS) diff --git a/extra/usb_serial/raiden.c b/extra/usb_serial/raiden.c new file mode 100644 index 0000000000..2733e47a90 --- /dev/null +++ b/extra/usb_serial/raiden.c @@ -0,0 +1,46 @@ +/* + * USB Serial module for Raiden USB debug serial console forwarding. + * SubClass and Protocol allocated in go/usb-ids + * + * Copyright (c) 2014 The Chromium OS Authors <chromium-os-dev@chromium.org> + * Author: Anton Staaf <robotboy@chromium.org> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/tty.h> +#include <linux/usb.h> +#include <linux/usb/serial.h> + +MODULE_LICENSE("GPL"); + +#define USB_VENDOR_ID_GOOGLE 0x18d1 +#define USB_SUBCLASS_GOOGLE_SERIAL 0x50 +#define USB_PROTOCOL_GOOGLE_SERIAL 0x01 + +static struct usb_device_id const ids[] = { + { USB_VENDOR_AND_INTERFACE_INFO(USB_VENDOR_ID_GOOGLE, + USB_CLASS_VENDOR_SPEC, + USB_SUBCLASS_GOOGLE_SERIAL, + USB_PROTOCOL_GOOGLE_SERIAL) }, + { 0 } +}; + +MODULE_DEVICE_TABLE(usb, ids); + +static struct usb_serial_driver device = +{ + .driver = { .owner = THIS_MODULE, + .name = "Google" }, + .id_table = ids, + .num_ports = 1, +}; + +static struct usb_serial_driver * const drivers[] = { &device, NULL }; + +module_usb_serial_driver(drivers, ids); |