1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <linux/kernel.h>
19#include <linux/errno.h>
20#include <linux/slab.h>
21#include <linux/tty.h>
22#include <linux/tty_driver.h>
23#include <linux/tty_flip.h>
24#include <linux/module.h>
25#include <linux/spinlock.h>
26#include <linux/uaccess.h>
27#include <linux/usb.h>
28#include <linux/usb/serial.h>
29
30#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
31#define DRIVER_DESC "USB Empeg Mark I/II Driver"
32
33#define EMPEG_VENDOR_ID 0x084f
34#define EMPEG_PRODUCT_ID 0x0001
35
36
37static int empeg_startup(struct usb_serial *serial);
38static void empeg_init_termios(struct tty_struct *tty);
39
40static const struct usb_device_id id_table[] = {
41 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
42 { }
43};
44
45MODULE_DEVICE_TABLE(usb, id_table);
46
47static struct usb_serial_driver empeg_device = {
48 .driver = {
49 .owner = THIS_MODULE,
50 .name = "empeg",
51 },
52 .id_table = id_table,
53 .num_ports = 1,
54 .bulk_out_size = 256,
55 .throttle = usb_serial_generic_throttle,
56 .unthrottle = usb_serial_generic_unthrottle,
57 .attach = empeg_startup,
58 .init_termios = empeg_init_termios,
59};
60
61static struct usb_serial_driver * const serial_drivers[] = {
62 &empeg_device, NULL
63};
64
65static int empeg_startup(struct usb_serial *serial)
66{
67 int r;
68
69 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
70 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
71 serial->dev->actconfig->desc.bConfigurationValue);
72 return -ENODEV;
73 }
74
75 r = usb_reset_configuration(serial->dev);
76
77
78 return r;
79}
80
81static void empeg_init_termios(struct tty_struct *tty)
82{
83 struct ktermios *termios = &tty->termios;
84
85
86
87
88
89
90
91
92
93
94 termios->c_iflag
95 &= ~(IGNBRK
96 | BRKINT
97 | PARMRK
98 | ISTRIP
99 | INLCR
100 | IGNCR
101 | ICRNL
102 | IXON);
103
104 termios->c_oflag
105 &= ~OPOST;
106
107 termios->c_lflag
108 &= ~(ECHO
109 | ECHONL
110 | ICANON
111 | ISIG
112 | IEXTEN);
113
114 termios->c_cflag
115 &= ~(CSIZE
116 | PARENB
117 | CBAUD);
118
119 termios->c_cflag
120 |= CS8;
121
122 tty_encode_baud_rate(tty, 115200, 115200);
123}
124
125module_usb_serial_driver(serial_drivers, id_table);
126
127MODULE_AUTHOR(DRIVER_AUTHOR);
128MODULE_DESCRIPTION(DRIVER_DESC);
129MODULE_LICENSE("GPL");
130