0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/gfp.h>
0009 #include <linux/kernel.h>
0010 #include <linux/tty.h>
0011 #include <linux/module.h>
0012 #include <linux/usb.h>
0013 #include <linux/usb/serial.h>
0014
0015 #define USB_DEBUG_MAX_PACKET_SIZE 8
0016 #define USB_DEBUG_BRK_SIZE 8
0017 static const char USB_DEBUG_BRK[USB_DEBUG_BRK_SIZE] = {
0018 0x00,
0019 0xff,
0020 0x01,
0021 0xfe,
0022 0x00,
0023 0xfe,
0024 0x01,
0025 0xff,
0026 };
0027
0028 static const struct usb_device_id id_table[] = {
0029 { USB_DEVICE(0x0525, 0x127a) },
0030 { },
0031 };
0032
0033 static const struct usb_device_id dbc_id_table[] = {
0034 { USB_DEVICE(0x1d6b, 0x0010) },
0035 { USB_DEVICE(0x1d6b, 0x0011) },
0036 { },
0037 };
0038
0039 static const struct usb_device_id id_table_combined[] = {
0040 { USB_DEVICE(0x0525, 0x127a) },
0041 { USB_DEVICE(0x1d6b, 0x0010) },
0042 { USB_DEVICE(0x1d6b, 0x0011) },
0043 { },
0044 };
0045 MODULE_DEVICE_TABLE(usb, id_table_combined);
0046
0047
0048
0049
0050 static void usb_debug_break_ctl(struct tty_struct *tty, int break_state)
0051 {
0052 struct usb_serial_port *port = tty->driver_data;
0053 if (!break_state)
0054 return;
0055 usb_serial_generic_write(tty, port, USB_DEBUG_BRK, USB_DEBUG_BRK_SIZE);
0056 }
0057
0058 static void usb_debug_process_read_urb(struct urb *urb)
0059 {
0060 struct usb_serial_port *port = urb->context;
0061
0062 if (urb->actual_length == USB_DEBUG_BRK_SIZE &&
0063 memcmp(urb->transfer_buffer, USB_DEBUG_BRK,
0064 USB_DEBUG_BRK_SIZE) == 0) {
0065 usb_serial_handle_break(port);
0066 return;
0067 }
0068
0069 usb_serial_generic_process_read_urb(urb);
0070 }
0071
0072 static struct usb_serial_driver debug_device = {
0073 .driver = {
0074 .owner = THIS_MODULE,
0075 .name = "debug",
0076 },
0077 .id_table = id_table,
0078 .num_ports = 1,
0079 .bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE,
0080 .break_ctl = usb_debug_break_ctl,
0081 .process_read_urb = usb_debug_process_read_urb,
0082 };
0083
0084 static struct usb_serial_driver dbc_device = {
0085 .driver = {
0086 .owner = THIS_MODULE,
0087 .name = "xhci_dbc",
0088 },
0089 .id_table = dbc_id_table,
0090 .num_ports = 1,
0091 .break_ctl = usb_debug_break_ctl,
0092 .process_read_urb = usb_debug_process_read_urb,
0093 };
0094
0095 static struct usb_serial_driver * const serial_drivers[] = {
0096 &debug_device, &dbc_device, NULL
0097 };
0098
0099 module_usb_serial_driver(serial_drivers, id_table_combined);
0100 MODULE_LICENSE("GPL v2");