GNU Linux-libre 4.9.317-gnu1
[releases.git] / drivers / usb / serial / usb-serial-simple.c
1 /*
2  * USB Serial "Simple" driver
3  *
4  * Copyright (C) 2001-2006,2008,2013 Greg Kroah-Hartman <greg@kroah.com>
5  * Copyright (C) 2005 Arthur Huillet (ahuillet@users.sf.net)
6  * Copyright (C) 2005 Thomas Hergenhahn <thomas.hergenhahn@suse.de>
7  * Copyright (C) 2009 Outpost Embedded, LLC
8  * Copyright (C) 2010 Zilogic Systems <code@zilogic.com>
9  * Copyright (C) 2013 Wei Shuai <cpuwolf@gmail.com>
10  * Copyright (C) 2013 Linux Foundation
11  *
12  *      This program is free software; you can redistribute it and/or
13  *      modify it under the terms of the GNU General Public License version
14  *      2 as published by the Free Software Foundation.
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/tty.h>
19 #include <linux/module.h>
20 #include <linux/usb.h>
21 #include <linux/usb/serial.h>
22
23 #define DEVICE_N(vendor, IDS, nport)                            \
24 static const struct usb_device_id vendor##_id_table[] = {       \
25         IDS(),                                                  \
26         { },                                                    \
27 };                                                              \
28 static struct usb_serial_driver vendor##_device = {             \
29         .driver = {                                             \
30                 .owner =        THIS_MODULE,                    \
31                 .name =         #vendor,                        \
32         },                                                      \
33         .id_table =             vendor##_id_table,              \
34         .num_ports =            nport,                          \
35 };
36
37 #define DEVICE(vendor, IDS)     DEVICE_N(vendor, IDS, 1)
38
39 /* Medtronic CareLink USB driver */
40 #define CARELINK_IDS()                  \
41         { USB_DEVICE(0x0a21, 0x8001) }  /* MMT-7305WW */
42 DEVICE(carelink, CARELINK_IDS);
43
44 /* ZIO Motherboard USB driver */
45 #define ZIO_IDS()                       \
46         { USB_DEVICE(0x1CBE, 0x0103) }
47 DEVICE(zio, ZIO_IDS);
48
49 /* Funsoft Serial USB driver */
50 #define FUNSOFT_IDS()                   \
51         { USB_DEVICE(0x1404, 0xcddc) }
52 DEVICE(funsoft, FUNSOFT_IDS);
53
54 /* Infineon Flashloader driver */
55 #define FLASHLOADER_IDS()               \
56         { USB_DEVICE_INTERFACE_CLASS(0x058b, 0x0041, USB_CLASS_CDC_DATA) }, \
57         { USB_DEVICE(0x8087, 0x0716) }, \
58         { USB_DEVICE(0x8087, 0x0801) }
59 DEVICE(flashloader, FLASHLOADER_IDS);
60
61 /* Google Serial USB SubClass */
62 #define GOOGLE_IDS()                                            \
63         { USB_VENDOR_AND_INTERFACE_INFO(0x18d1,                 \
64                                         USB_CLASS_VENDOR_SPEC,  \
65                                         0x50,                   \
66                                         0x01) }
67 DEVICE(google, GOOGLE_IDS);
68
69 /* Libtransistor USB console */
70 #define LIBTRANSISTOR_IDS()                     \
71         { USB_DEVICE(0x1209, 0x8b00) }
72 DEVICE(libtransistor, LIBTRANSISTOR_IDS);
73
74 /* ViVOpay USB Serial Driver */
75 #define VIVOPAY_IDS()                   \
76         { USB_DEVICE(0x1d5f, 0x1004) }  /* ViVOpay 8800 */
77 DEVICE(vivopay, VIVOPAY_IDS);
78
79 /* Motorola USB Phone driver */
80 #define MOTO_IDS()                      \
81         { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */    \
82         { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Motorola phone */    \
83         { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */         \
84         { USB_DEVICE(0x22b8, 0x2c84) }, /* Motorola VE240 phone */      \
85         { USB_DEVICE(0x22b8, 0x2c64) }  /* Motorola V950 phone */
86 DEVICE(moto_modem, MOTO_IDS);
87
88 /* Motorola Tetra driver */
89 #define MOTOROLA_TETRA_IDS()                    \
90         { USB_DEVICE(0x0cad, 0x9011) }, /* Motorola Solutions TETRA PEI */ \
91         { USB_DEVICE(0x0cad, 0x9012) }, /* MTP6550 */ \
92         { USB_DEVICE(0x0cad, 0x9013) }, /* MTP3xxx */ \
93         { USB_DEVICE(0x0cad, 0x9015) }, /* MTP85xx */ \
94         { USB_DEVICE(0x0cad, 0x9016) }  /* TPG2200 */
95 DEVICE(motorola_tetra, MOTOROLA_TETRA_IDS);
96
97 /* Nokia mobile phone driver */
98 #define NOKIA_IDS()                     \
99         { USB_DEVICE(0x0421, 0x069a) }  /* Nokia 130 (RM-1035) */
100 DEVICE(nokia, NOKIA_IDS);
101
102 /* Novatel Wireless GPS driver */
103 #define NOVATEL_IDS()                   \
104         { USB_DEVICE(0x09d7, 0x0100) }  /* NovAtel FlexPack GPS */
105 DEVICE_N(novatel_gps, NOVATEL_IDS, 3);
106
107 /* HP4x (48/49) Generic Serial driver */
108 #define HP4X_IDS()                      \
109         { USB_DEVICE(0x03f0, 0x0121) }
110 DEVICE(hp4x, HP4X_IDS);
111
112 /* Suunto ANT+ USB Driver */
113 #define SUUNTO_IDS()                    \
114         { USB_DEVICE(0x0fcf, 0x1008) }, \
115         { USB_DEVICE(0x0fcf, 0x1009) } /* Dynastream ANT USB-m Stick */
116 DEVICE(suunto, SUUNTO_IDS);
117
118 /* Siemens USB/MPI adapter */
119 #define SIEMENS_IDS()                   \
120         { USB_DEVICE(0x908, 0x0004) }
121 DEVICE(siemens_mpi, SIEMENS_IDS);
122
123 /* All of the above structures mushed into two lists */
124 static struct usb_serial_driver * const serial_drivers[] = {
125         &carelink_device,
126         &zio_device,
127         &funsoft_device,
128         &flashloader_device,
129         &google_device,
130         &libtransistor_device,
131         &vivopay_device,
132         &moto_modem_device,
133         &motorola_tetra_device,
134         &nokia_device,
135         &novatel_gps_device,
136         &hp4x_device,
137         &suunto_device,
138         &siemens_mpi_device,
139         NULL
140 };
141
142 static const struct usb_device_id id_table[] = {
143         CARELINK_IDS(),
144         ZIO_IDS(),
145         FUNSOFT_IDS(),
146         FLASHLOADER_IDS(),
147         GOOGLE_IDS(),
148         LIBTRANSISTOR_IDS(),
149         VIVOPAY_IDS(),
150         MOTO_IDS(),
151         MOTOROLA_TETRA_IDS(),
152         NOKIA_IDS(),
153         NOVATEL_IDS(),
154         HP4X_IDS(),
155         SUUNTO_IDS(),
156         SIEMENS_IDS(),
157         { },
158 };
159 MODULE_DEVICE_TABLE(usb, id_table);
160
161 module_usb_serial_driver(serial_drivers, id_table);
162 MODULE_LICENSE("GPL");