From ac375d000eba1e3b582018ebfcbf654af41bdcb9 Mon Sep 17 00:00:00 2001 From: Anton Staaf Date: Wed, 10 Sep 2014 14:32:27 -0700 Subject: [PATCH] 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 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 Reviewed-by: Vincent Palatin Tested-by: Anton Staaf Commit-Queue: Anton Staaf --- extra/usb_serial/Makefile | 10 +++++++++ extra/usb_serial/raiden.c | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 extra/usb_serial/Makefile create mode 100644 extra/usb_serial/raiden.c 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 + * Author: Anton Staaf + * + * 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 +#include +#include +#include +#include +#include + +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);