From 047d2add10048d6da8a7a935b878e9d1897344a2 Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" <w.terpstra@gsi.de> Date: Fri, 5 Apr 2013 19:14:16 +0200 Subject: [PATCH] usb: kernel driver for USB-WB bridge --- pcie-wb/Makefile | 2 +- pcie-wb/usb_wb.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 pcie-wb/usb_wb.c diff --git a/pcie-wb/Makefile b/pcie-wb/Makefile index 927c8b3..ddb676a 100644 --- a/pcie-wb/Makefile +++ b/pcie-wb/Makefile @@ -17,7 +17,7 @@ KERNELVER ?= `uname -r` KERNELDIR ?= /lib/modules/$(KERNELVER)/build ifneq ($(KERNELRELEASE),) - obj-m := pcie_wb.o wishbone.o spec_wb.o + obj-m := pcie_wb.o wishbone.o spec_wb.o usb_wb.o else KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) diff --git a/pcie-wb/usb_wb.c b/pcie-wb/usb_wb.c new file mode 100644 index 0000000..bf51ee1 --- /dev/null +++ b/pcie-wb/usb_wb.c @@ -0,0 +1,65 @@ +/* + * USB-WB adapter driver + * + * 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/kernel.h> +#include <linux/init.h> +#include <linux/tty.h> +#include <linux/module.h> +#include <linux/usb.h> +#include <linux/usb/serial.h> +#include <linux/uaccess.h> + +static const struct usb_device_id id_table[] = { + { USB_DEVICE_AND_INTERFACE_INFO(0x1D50, 0x6062, 0xFF, 0xFF, 0xFF) }, + { }, +}; +MODULE_DEVICE_TABLE(usb, id_table); + +static struct usb_driver usb_wb_driver = { + .name = "usb_wb", + .probe = usb_serial_probe, + .disconnect = usb_serial_disconnect, + .id_table = id_table, + .no_dynamic_id = 1, +}; + +static struct usb_serial_driver usb_wb_device = { + .driver = { + .owner = THIS_MODULE, + .name = "usb_wb", + }, + .id_table = id_table, + .usb_driver = &usb_wb_driver, + .num_ports = 1, +}; + +static int __init usb_wb_init(void) +{ + int retval; + + retval = usb_serial_register(&usb_wb_device); + if (retval) + return retval; + retval = usb_register(&usb_wb_driver); + if (retval) + usb_serial_deregister(&usb_wb_device); + return retval; +} + +static void __exit usb_wb_exit(void) +{ + usb_deregister(&usb_wb_driver); + usb_serial_deregister(&usb_wb_device); +} + +MODULE_AUTHOR("Wesley W. Terpstra <w.terpstra@gsi.de>"); +MODULE_DESCRIPTION("Wishbone-USB adapter"); +MODULE_LICENSE("GPL"); + +module_init(usb_wb_init); +module_exit(usb_wb_exit); -- GitLab