Commit 8ee7a330fbb78344802cc6c3cc8be023b6d05aa0

Authored by Linus Torvalds

Merge tag 'usb-3.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are some fixes for 3.15-rc8 that resolve a number of tiny USB
  issues that have been reported, and there are some new device ids as
  well.

  All have been tested in linux-next"

* tag 'usb-3.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  xhci: delete endpoints from bandwidth list before freeing whole device
  usb: pci-quirks: Prevent Sony VAIO t-series from switching usb ports
  USB: cdc-wdm: properly include types.h
  usb: cdc-wdm: export cdc-wdm uapi header
  USB: serial: option: add support for Novatel E371 PCIe card
  USB: ftdi_sio: add NovaTech OrionLXm product ID
  USB: io_ti: fix firmware download on big-endian machines (part 2)
  USB: Avoid runtime suspend loops for HCDs that can't handle suspend/resume

Showing 11 changed files Inline Diff

drivers/usb/core/driver.c
1 /* 1 /*
2 * drivers/usb/driver.c - most of the driver model stuff for usb 2 * drivers/usb/driver.c - most of the driver model stuff for usb
3 * 3 *
4 * (C) Copyright 2005 Greg Kroah-Hartman <gregkh@suse.de> 4 * (C) Copyright 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 * 5 *
6 * based on drivers/usb/usb.c which had the following copyrights: 6 * based on drivers/usb/usb.c which had the following copyrights:
7 * (C) Copyright Linus Torvalds 1999 7 * (C) Copyright Linus Torvalds 1999
8 * (C) Copyright Johannes Erdfelt 1999-2001 8 * (C) Copyright Johannes Erdfelt 1999-2001
9 * (C) Copyright Andreas Gal 1999 9 * (C) Copyright Andreas Gal 1999
10 * (C) Copyright Gregory P. Smith 1999 10 * (C) Copyright Gregory P. Smith 1999
11 * (C) Copyright Deti Fliegl 1999 (new USB architecture) 11 * (C) Copyright Deti Fliegl 1999 (new USB architecture)
12 * (C) Copyright Randy Dunlap 2000 12 * (C) Copyright Randy Dunlap 2000
13 * (C) Copyright David Brownell 2000-2004 13 * (C) Copyright David Brownell 2000-2004
14 * (C) Copyright Yggdrasil Computing, Inc. 2000 14 * (C) Copyright Yggdrasil Computing, Inc. 2000
15 * (usb_device_id matching changes by Adam J. Richter) 15 * (usb_device_id matching changes by Adam J. Richter)
16 * (C) Copyright Greg Kroah-Hartman 2002-2003 16 * (C) Copyright Greg Kroah-Hartman 2002-2003
17 * 17 *
18 * NOTE! This is not actually a driver at all, rather this is 18 * NOTE! This is not actually a driver at all, rather this is
19 * just a collection of helper routines that implement the 19 * just a collection of helper routines that implement the
20 * matching, probing, releasing, suspending and resuming for 20 * matching, probing, releasing, suspending and resuming for
21 * real drivers. 21 * real drivers.
22 * 22 *
23 */ 23 */
24 24
25 #include <linux/device.h> 25 #include <linux/device.h>
26 #include <linux/slab.h> 26 #include <linux/slab.h>
27 #include <linux/export.h> 27 #include <linux/export.h>
28 #include <linux/usb.h> 28 #include <linux/usb.h>
29 #include <linux/usb/quirks.h> 29 #include <linux/usb/quirks.h>
30 #include <linux/usb/hcd.h> 30 #include <linux/usb/hcd.h>
31 31
32 #include "usb.h" 32 #include "usb.h"
33 33
34 34
35 /* 35 /*
36 * Adds a new dynamic USBdevice ID to this driver, 36 * Adds a new dynamic USBdevice ID to this driver,
37 * and cause the driver to probe for all devices again. 37 * and cause the driver to probe for all devices again.
38 */ 38 */
39 ssize_t usb_store_new_id(struct usb_dynids *dynids, 39 ssize_t usb_store_new_id(struct usb_dynids *dynids,
40 const struct usb_device_id *id_table, 40 const struct usb_device_id *id_table,
41 struct device_driver *driver, 41 struct device_driver *driver,
42 const char *buf, size_t count) 42 const char *buf, size_t count)
43 { 43 {
44 struct usb_dynid *dynid; 44 struct usb_dynid *dynid;
45 u32 idVendor = 0; 45 u32 idVendor = 0;
46 u32 idProduct = 0; 46 u32 idProduct = 0;
47 unsigned int bInterfaceClass = 0; 47 unsigned int bInterfaceClass = 0;
48 u32 refVendor, refProduct; 48 u32 refVendor, refProduct;
49 int fields = 0; 49 int fields = 0;
50 int retval = 0; 50 int retval = 0;
51 51
52 fields = sscanf(buf, "%x %x %x %x %x", &idVendor, &idProduct, 52 fields = sscanf(buf, "%x %x %x %x %x", &idVendor, &idProduct,
53 &bInterfaceClass, &refVendor, &refProduct); 53 &bInterfaceClass, &refVendor, &refProduct);
54 if (fields < 2) 54 if (fields < 2)
55 return -EINVAL; 55 return -EINVAL;
56 56
57 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 57 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
58 if (!dynid) 58 if (!dynid)
59 return -ENOMEM; 59 return -ENOMEM;
60 60
61 INIT_LIST_HEAD(&dynid->node); 61 INIT_LIST_HEAD(&dynid->node);
62 dynid->id.idVendor = idVendor; 62 dynid->id.idVendor = idVendor;
63 dynid->id.idProduct = idProduct; 63 dynid->id.idProduct = idProduct;
64 dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; 64 dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE;
65 if (fields > 2 && bInterfaceClass) { 65 if (fields > 2 && bInterfaceClass) {
66 if (bInterfaceClass > 255) { 66 if (bInterfaceClass > 255) {
67 retval = -EINVAL; 67 retval = -EINVAL;
68 goto fail; 68 goto fail;
69 } 69 }
70 70
71 dynid->id.bInterfaceClass = (u8)bInterfaceClass; 71 dynid->id.bInterfaceClass = (u8)bInterfaceClass;
72 dynid->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS; 72 dynid->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS;
73 } 73 }
74 74
75 if (fields > 4) { 75 if (fields > 4) {
76 const struct usb_device_id *id = id_table; 76 const struct usb_device_id *id = id_table;
77 77
78 if (!id) { 78 if (!id) {
79 retval = -ENODEV; 79 retval = -ENODEV;
80 goto fail; 80 goto fail;
81 } 81 }
82 82
83 for (; id->match_flags; id++) 83 for (; id->match_flags; id++)
84 if (id->idVendor == refVendor && id->idProduct == refProduct) 84 if (id->idVendor == refVendor && id->idProduct == refProduct)
85 break; 85 break;
86 86
87 if (id->match_flags) { 87 if (id->match_flags) {
88 dynid->id.driver_info = id->driver_info; 88 dynid->id.driver_info = id->driver_info;
89 } else { 89 } else {
90 retval = -ENODEV; 90 retval = -ENODEV;
91 goto fail; 91 goto fail;
92 } 92 }
93 } 93 }
94 94
95 spin_lock(&dynids->lock); 95 spin_lock(&dynids->lock);
96 list_add_tail(&dynid->node, &dynids->list); 96 list_add_tail(&dynid->node, &dynids->list);
97 spin_unlock(&dynids->lock); 97 spin_unlock(&dynids->lock);
98 98
99 retval = driver_attach(driver); 99 retval = driver_attach(driver);
100 100
101 if (retval) 101 if (retval)
102 return retval; 102 return retval;
103 return count; 103 return count;
104 104
105 fail: 105 fail:
106 kfree(dynid); 106 kfree(dynid);
107 return retval; 107 return retval;
108 } 108 }
109 EXPORT_SYMBOL_GPL(usb_store_new_id); 109 EXPORT_SYMBOL_GPL(usb_store_new_id);
110 110
111 ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf) 111 ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf)
112 { 112 {
113 struct usb_dynid *dynid; 113 struct usb_dynid *dynid;
114 size_t count = 0; 114 size_t count = 0;
115 115
116 list_for_each_entry(dynid, &dynids->list, node) 116 list_for_each_entry(dynid, &dynids->list, node)
117 if (dynid->id.bInterfaceClass != 0) 117 if (dynid->id.bInterfaceClass != 0)
118 count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x %02x\n", 118 count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x %02x\n",
119 dynid->id.idVendor, dynid->id.idProduct, 119 dynid->id.idVendor, dynid->id.idProduct,
120 dynid->id.bInterfaceClass); 120 dynid->id.bInterfaceClass);
121 else 121 else
122 count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x\n", 122 count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x\n",
123 dynid->id.idVendor, dynid->id.idProduct); 123 dynid->id.idVendor, dynid->id.idProduct);
124 return count; 124 return count;
125 } 125 }
126 EXPORT_SYMBOL_GPL(usb_show_dynids); 126 EXPORT_SYMBOL_GPL(usb_show_dynids);
127 127
128 static ssize_t new_id_show(struct device_driver *driver, char *buf) 128 static ssize_t new_id_show(struct device_driver *driver, char *buf)
129 { 129 {
130 struct usb_driver *usb_drv = to_usb_driver(driver); 130 struct usb_driver *usb_drv = to_usb_driver(driver);
131 131
132 return usb_show_dynids(&usb_drv->dynids, buf); 132 return usb_show_dynids(&usb_drv->dynids, buf);
133 } 133 }
134 134
135 static ssize_t new_id_store(struct device_driver *driver, 135 static ssize_t new_id_store(struct device_driver *driver,
136 const char *buf, size_t count) 136 const char *buf, size_t count)
137 { 137 {
138 struct usb_driver *usb_drv = to_usb_driver(driver); 138 struct usb_driver *usb_drv = to_usb_driver(driver);
139 139
140 return usb_store_new_id(&usb_drv->dynids, usb_drv->id_table, driver, buf, count); 140 return usb_store_new_id(&usb_drv->dynids, usb_drv->id_table, driver, buf, count);
141 } 141 }
142 static DRIVER_ATTR_RW(new_id); 142 static DRIVER_ATTR_RW(new_id);
143 143
144 /* 144 /*
145 * Remove a USB device ID from this driver 145 * Remove a USB device ID from this driver
146 */ 146 */
147 static ssize_t remove_id_store(struct device_driver *driver, const char *buf, 147 static ssize_t remove_id_store(struct device_driver *driver, const char *buf,
148 size_t count) 148 size_t count)
149 { 149 {
150 struct usb_dynid *dynid, *n; 150 struct usb_dynid *dynid, *n;
151 struct usb_driver *usb_driver = to_usb_driver(driver); 151 struct usb_driver *usb_driver = to_usb_driver(driver);
152 u32 idVendor; 152 u32 idVendor;
153 u32 idProduct; 153 u32 idProduct;
154 int fields; 154 int fields;
155 155
156 fields = sscanf(buf, "%x %x", &idVendor, &idProduct); 156 fields = sscanf(buf, "%x %x", &idVendor, &idProduct);
157 if (fields < 2) 157 if (fields < 2)
158 return -EINVAL; 158 return -EINVAL;
159 159
160 spin_lock(&usb_driver->dynids.lock); 160 spin_lock(&usb_driver->dynids.lock);
161 list_for_each_entry_safe(dynid, n, &usb_driver->dynids.list, node) { 161 list_for_each_entry_safe(dynid, n, &usb_driver->dynids.list, node) {
162 struct usb_device_id *id = &dynid->id; 162 struct usb_device_id *id = &dynid->id;
163 if ((id->idVendor == idVendor) && 163 if ((id->idVendor == idVendor) &&
164 (id->idProduct == idProduct)) { 164 (id->idProduct == idProduct)) {
165 list_del(&dynid->node); 165 list_del(&dynid->node);
166 kfree(dynid); 166 kfree(dynid);
167 break; 167 break;
168 } 168 }
169 } 169 }
170 spin_unlock(&usb_driver->dynids.lock); 170 spin_unlock(&usb_driver->dynids.lock);
171 return count; 171 return count;
172 } 172 }
173 173
174 static ssize_t remove_id_show(struct device_driver *driver, char *buf) 174 static ssize_t remove_id_show(struct device_driver *driver, char *buf)
175 { 175 {
176 return new_id_show(driver, buf); 176 return new_id_show(driver, buf);
177 } 177 }
178 static DRIVER_ATTR_RW(remove_id); 178 static DRIVER_ATTR_RW(remove_id);
179 179
180 static int usb_create_newid_files(struct usb_driver *usb_drv) 180 static int usb_create_newid_files(struct usb_driver *usb_drv)
181 { 181 {
182 int error = 0; 182 int error = 0;
183 183
184 if (usb_drv->no_dynamic_id) 184 if (usb_drv->no_dynamic_id)
185 goto exit; 185 goto exit;
186 186
187 if (usb_drv->probe != NULL) { 187 if (usb_drv->probe != NULL) {
188 error = driver_create_file(&usb_drv->drvwrap.driver, 188 error = driver_create_file(&usb_drv->drvwrap.driver,
189 &driver_attr_new_id); 189 &driver_attr_new_id);
190 if (error == 0) { 190 if (error == 0) {
191 error = driver_create_file(&usb_drv->drvwrap.driver, 191 error = driver_create_file(&usb_drv->drvwrap.driver,
192 &driver_attr_remove_id); 192 &driver_attr_remove_id);
193 if (error) 193 if (error)
194 driver_remove_file(&usb_drv->drvwrap.driver, 194 driver_remove_file(&usb_drv->drvwrap.driver,
195 &driver_attr_new_id); 195 &driver_attr_new_id);
196 } 196 }
197 } 197 }
198 exit: 198 exit:
199 return error; 199 return error;
200 } 200 }
201 201
202 static void usb_remove_newid_files(struct usb_driver *usb_drv) 202 static void usb_remove_newid_files(struct usb_driver *usb_drv)
203 { 203 {
204 if (usb_drv->no_dynamic_id) 204 if (usb_drv->no_dynamic_id)
205 return; 205 return;
206 206
207 if (usb_drv->probe != NULL) { 207 if (usb_drv->probe != NULL) {
208 driver_remove_file(&usb_drv->drvwrap.driver, 208 driver_remove_file(&usb_drv->drvwrap.driver,
209 &driver_attr_remove_id); 209 &driver_attr_remove_id);
210 driver_remove_file(&usb_drv->drvwrap.driver, 210 driver_remove_file(&usb_drv->drvwrap.driver,
211 &driver_attr_new_id); 211 &driver_attr_new_id);
212 } 212 }
213 } 213 }
214 214
215 static void usb_free_dynids(struct usb_driver *usb_drv) 215 static void usb_free_dynids(struct usb_driver *usb_drv)
216 { 216 {
217 struct usb_dynid *dynid, *n; 217 struct usb_dynid *dynid, *n;
218 218
219 spin_lock(&usb_drv->dynids.lock); 219 spin_lock(&usb_drv->dynids.lock);
220 list_for_each_entry_safe(dynid, n, &usb_drv->dynids.list, node) { 220 list_for_each_entry_safe(dynid, n, &usb_drv->dynids.list, node) {
221 list_del(&dynid->node); 221 list_del(&dynid->node);
222 kfree(dynid); 222 kfree(dynid);
223 } 223 }
224 spin_unlock(&usb_drv->dynids.lock); 224 spin_unlock(&usb_drv->dynids.lock);
225 } 225 }
226 226
227 static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf, 227 static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf,
228 struct usb_driver *drv) 228 struct usb_driver *drv)
229 { 229 {
230 struct usb_dynid *dynid; 230 struct usb_dynid *dynid;
231 231
232 spin_lock(&drv->dynids.lock); 232 spin_lock(&drv->dynids.lock);
233 list_for_each_entry(dynid, &drv->dynids.list, node) { 233 list_for_each_entry(dynid, &drv->dynids.list, node) {
234 if (usb_match_one_id(intf, &dynid->id)) { 234 if (usb_match_one_id(intf, &dynid->id)) {
235 spin_unlock(&drv->dynids.lock); 235 spin_unlock(&drv->dynids.lock);
236 return &dynid->id; 236 return &dynid->id;
237 } 237 }
238 } 238 }
239 spin_unlock(&drv->dynids.lock); 239 spin_unlock(&drv->dynids.lock);
240 return NULL; 240 return NULL;
241 } 241 }
242 242
243 243
244 /* called from driver core with dev locked */ 244 /* called from driver core with dev locked */
245 static int usb_probe_device(struct device *dev) 245 static int usb_probe_device(struct device *dev)
246 { 246 {
247 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver); 247 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
248 struct usb_device *udev = to_usb_device(dev); 248 struct usb_device *udev = to_usb_device(dev);
249 int error = 0; 249 int error = 0;
250 250
251 dev_dbg(dev, "%s\n", __func__); 251 dev_dbg(dev, "%s\n", __func__);
252 252
253 /* TODO: Add real matching code */ 253 /* TODO: Add real matching code */
254 254
255 /* The device should always appear to be in use 255 /* The device should always appear to be in use
256 * unless the driver supports autosuspend. 256 * unless the driver supports autosuspend.
257 */ 257 */
258 if (!udriver->supports_autosuspend) 258 if (!udriver->supports_autosuspend)
259 error = usb_autoresume_device(udev); 259 error = usb_autoresume_device(udev);
260 260
261 if (!error) 261 if (!error)
262 error = udriver->probe(udev); 262 error = udriver->probe(udev);
263 return error; 263 return error;
264 } 264 }
265 265
266 /* called from driver core with dev locked */ 266 /* called from driver core with dev locked */
267 static int usb_unbind_device(struct device *dev) 267 static int usb_unbind_device(struct device *dev)
268 { 268 {
269 struct usb_device *udev = to_usb_device(dev); 269 struct usb_device *udev = to_usb_device(dev);
270 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver); 270 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
271 271
272 udriver->disconnect(udev); 272 udriver->disconnect(udev);
273 if (!udriver->supports_autosuspend) 273 if (!udriver->supports_autosuspend)
274 usb_autosuspend_device(udev); 274 usb_autosuspend_device(udev);
275 return 0; 275 return 0;
276 } 276 }
277 277
278 /* 278 /*
279 * Cancel any pending scheduled resets 279 * Cancel any pending scheduled resets
280 * 280 *
281 * [see usb_queue_reset_device()] 281 * [see usb_queue_reset_device()]
282 * 282 *
283 * Called after unconfiguring / when releasing interfaces. See 283 * Called after unconfiguring / when releasing interfaces. See
284 * comments in __usb_queue_reset_device() regarding 284 * comments in __usb_queue_reset_device() regarding
285 * udev->reset_running. 285 * udev->reset_running.
286 */ 286 */
287 static void usb_cancel_queued_reset(struct usb_interface *iface) 287 static void usb_cancel_queued_reset(struct usb_interface *iface)
288 { 288 {
289 if (iface->reset_running == 0) 289 if (iface->reset_running == 0)
290 cancel_work_sync(&iface->reset_ws); 290 cancel_work_sync(&iface->reset_ws);
291 } 291 }
292 292
293 /* called from driver core with dev locked */ 293 /* called from driver core with dev locked */
294 static int usb_probe_interface(struct device *dev) 294 static int usb_probe_interface(struct device *dev)
295 { 295 {
296 struct usb_driver *driver = to_usb_driver(dev->driver); 296 struct usb_driver *driver = to_usb_driver(dev->driver);
297 struct usb_interface *intf = to_usb_interface(dev); 297 struct usb_interface *intf = to_usb_interface(dev);
298 struct usb_device *udev = interface_to_usbdev(intf); 298 struct usb_device *udev = interface_to_usbdev(intf);
299 const struct usb_device_id *id; 299 const struct usb_device_id *id;
300 int error = -ENODEV; 300 int error = -ENODEV;
301 int lpm_disable_error; 301 int lpm_disable_error;
302 302
303 dev_dbg(dev, "%s\n", __func__); 303 dev_dbg(dev, "%s\n", __func__);
304 304
305 intf->needs_binding = 0; 305 intf->needs_binding = 0;
306 306
307 if (usb_device_is_owned(udev)) 307 if (usb_device_is_owned(udev))
308 return error; 308 return error;
309 309
310 if (udev->authorized == 0) { 310 if (udev->authorized == 0) {
311 dev_err(&intf->dev, "Device is not authorized for usage\n"); 311 dev_err(&intf->dev, "Device is not authorized for usage\n");
312 return error; 312 return error;
313 } 313 }
314 314
315 id = usb_match_dynamic_id(intf, driver); 315 id = usb_match_dynamic_id(intf, driver);
316 if (!id) 316 if (!id)
317 id = usb_match_id(intf, driver->id_table); 317 id = usb_match_id(intf, driver->id_table);
318 if (!id) 318 if (!id)
319 return error; 319 return error;
320 320
321 dev_dbg(dev, "%s - got id\n", __func__); 321 dev_dbg(dev, "%s - got id\n", __func__);
322 322
323 error = usb_autoresume_device(udev); 323 error = usb_autoresume_device(udev);
324 if (error) 324 if (error)
325 return error; 325 return error;
326 326
327 intf->condition = USB_INTERFACE_BINDING; 327 intf->condition = USB_INTERFACE_BINDING;
328 328
329 /* Probed interfaces are initially active. They are 329 /* Probed interfaces are initially active. They are
330 * runtime-PM-enabled only if the driver has autosuspend support. 330 * runtime-PM-enabled only if the driver has autosuspend support.
331 * They are sensitive to their children's power states. 331 * They are sensitive to their children's power states.
332 */ 332 */
333 pm_runtime_set_active(dev); 333 pm_runtime_set_active(dev);
334 pm_suspend_ignore_children(dev, false); 334 pm_suspend_ignore_children(dev, false);
335 if (driver->supports_autosuspend) 335 if (driver->supports_autosuspend)
336 pm_runtime_enable(dev); 336 pm_runtime_enable(dev);
337 337
338 /* If the new driver doesn't allow hub-initiated LPM, and we can't 338 /* If the new driver doesn't allow hub-initiated LPM, and we can't
339 * disable hub-initiated LPM, then fail the probe. 339 * disable hub-initiated LPM, then fail the probe.
340 * 340 *
341 * Otherwise, leaving LPM enabled should be harmless, because the 341 * Otherwise, leaving LPM enabled should be harmless, because the
342 * endpoint intervals should remain the same, and the U1/U2 timeouts 342 * endpoint intervals should remain the same, and the U1/U2 timeouts
343 * should remain the same. 343 * should remain the same.
344 * 344 *
345 * If we need to install alt setting 0 before probe, or another alt 345 * If we need to install alt setting 0 before probe, or another alt
346 * setting during probe, that should also be fine. usb_set_interface() 346 * setting during probe, that should also be fine. usb_set_interface()
347 * will attempt to disable LPM, and fail if it can't disable it. 347 * will attempt to disable LPM, and fail if it can't disable it.
348 */ 348 */
349 lpm_disable_error = usb_unlocked_disable_lpm(udev); 349 lpm_disable_error = usb_unlocked_disable_lpm(udev);
350 if (lpm_disable_error && driver->disable_hub_initiated_lpm) { 350 if (lpm_disable_error && driver->disable_hub_initiated_lpm) {
351 dev_err(&intf->dev, "%s Failed to disable LPM for driver %s\n.", 351 dev_err(&intf->dev, "%s Failed to disable LPM for driver %s\n.",
352 __func__, driver->name); 352 __func__, driver->name);
353 error = lpm_disable_error; 353 error = lpm_disable_error;
354 goto err; 354 goto err;
355 } 355 }
356 356
357 /* Carry out a deferred switch to altsetting 0 */ 357 /* Carry out a deferred switch to altsetting 0 */
358 if (intf->needs_altsetting0) { 358 if (intf->needs_altsetting0) {
359 error = usb_set_interface(udev, intf->altsetting[0]. 359 error = usb_set_interface(udev, intf->altsetting[0].
360 desc.bInterfaceNumber, 0); 360 desc.bInterfaceNumber, 0);
361 if (error < 0) 361 if (error < 0)
362 goto err; 362 goto err;
363 intf->needs_altsetting0 = 0; 363 intf->needs_altsetting0 = 0;
364 } 364 }
365 365
366 error = driver->probe(intf, id); 366 error = driver->probe(intf, id);
367 if (error) 367 if (error)
368 goto err; 368 goto err;
369 369
370 intf->condition = USB_INTERFACE_BOUND; 370 intf->condition = USB_INTERFACE_BOUND;
371 371
372 /* If the LPM disable succeeded, balance the ref counts. */ 372 /* If the LPM disable succeeded, balance the ref counts. */
373 if (!lpm_disable_error) 373 if (!lpm_disable_error)
374 usb_unlocked_enable_lpm(udev); 374 usb_unlocked_enable_lpm(udev);
375 375
376 usb_autosuspend_device(udev); 376 usb_autosuspend_device(udev);
377 return error; 377 return error;
378 378
379 err: 379 err:
380 usb_set_intfdata(intf, NULL); 380 usb_set_intfdata(intf, NULL);
381 intf->needs_remote_wakeup = 0; 381 intf->needs_remote_wakeup = 0;
382 intf->condition = USB_INTERFACE_UNBOUND; 382 intf->condition = USB_INTERFACE_UNBOUND;
383 usb_cancel_queued_reset(intf); 383 usb_cancel_queued_reset(intf);
384 384
385 /* If the LPM disable succeeded, balance the ref counts. */ 385 /* If the LPM disable succeeded, balance the ref counts. */
386 if (!lpm_disable_error) 386 if (!lpm_disable_error)
387 usb_unlocked_enable_lpm(udev); 387 usb_unlocked_enable_lpm(udev);
388 388
389 /* Unbound interfaces are always runtime-PM-disabled and -suspended */ 389 /* Unbound interfaces are always runtime-PM-disabled and -suspended */
390 if (driver->supports_autosuspend) 390 if (driver->supports_autosuspend)
391 pm_runtime_disable(dev); 391 pm_runtime_disable(dev);
392 pm_runtime_set_suspended(dev); 392 pm_runtime_set_suspended(dev);
393 393
394 usb_autosuspend_device(udev); 394 usb_autosuspend_device(udev);
395 return error; 395 return error;
396 } 396 }
397 397
398 /* called from driver core with dev locked */ 398 /* called from driver core with dev locked */
399 static int usb_unbind_interface(struct device *dev) 399 static int usb_unbind_interface(struct device *dev)
400 { 400 {
401 struct usb_driver *driver = to_usb_driver(dev->driver); 401 struct usb_driver *driver = to_usb_driver(dev->driver);
402 struct usb_interface *intf = to_usb_interface(dev); 402 struct usb_interface *intf = to_usb_interface(dev);
403 struct usb_host_endpoint *ep, **eps = NULL; 403 struct usb_host_endpoint *ep, **eps = NULL;
404 struct usb_device *udev; 404 struct usb_device *udev;
405 int i, j, error, r, lpm_disable_error; 405 int i, j, error, r, lpm_disable_error;
406 406
407 intf->condition = USB_INTERFACE_UNBINDING; 407 intf->condition = USB_INTERFACE_UNBINDING;
408 408
409 /* Autoresume for set_interface call below */ 409 /* Autoresume for set_interface call below */
410 udev = interface_to_usbdev(intf); 410 udev = interface_to_usbdev(intf);
411 error = usb_autoresume_device(udev); 411 error = usb_autoresume_device(udev);
412 412
413 /* Hub-initiated LPM policy may change, so attempt to disable LPM until 413 /* Hub-initiated LPM policy may change, so attempt to disable LPM until
414 * the driver is unbound. If LPM isn't disabled, that's fine because it 414 * the driver is unbound. If LPM isn't disabled, that's fine because it
415 * wouldn't be enabled unless all the bound interfaces supported 415 * wouldn't be enabled unless all the bound interfaces supported
416 * hub-initiated LPM. 416 * hub-initiated LPM.
417 */ 417 */
418 lpm_disable_error = usb_unlocked_disable_lpm(udev); 418 lpm_disable_error = usb_unlocked_disable_lpm(udev);
419 419
420 /* Terminate all URBs for this interface unless the driver 420 /* Terminate all URBs for this interface unless the driver
421 * supports "soft" unbinding. 421 * supports "soft" unbinding.
422 */ 422 */
423 if (!driver->soft_unbind) 423 if (!driver->soft_unbind)
424 usb_disable_interface(udev, intf, false); 424 usb_disable_interface(udev, intf, false);
425 425
426 driver->disconnect(intf); 426 driver->disconnect(intf);
427 usb_cancel_queued_reset(intf); 427 usb_cancel_queued_reset(intf);
428 428
429 /* Free streams */ 429 /* Free streams */
430 for (i = 0, j = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { 430 for (i = 0, j = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
431 ep = &intf->cur_altsetting->endpoint[i]; 431 ep = &intf->cur_altsetting->endpoint[i];
432 if (ep->streams == 0) 432 if (ep->streams == 0)
433 continue; 433 continue;
434 if (j == 0) { 434 if (j == 0) {
435 eps = kmalloc(USB_MAXENDPOINTS * sizeof(void *), 435 eps = kmalloc(USB_MAXENDPOINTS * sizeof(void *),
436 GFP_KERNEL); 436 GFP_KERNEL);
437 if (!eps) { 437 if (!eps) {
438 dev_warn(dev, "oom, leaking streams\n"); 438 dev_warn(dev, "oom, leaking streams\n");
439 break; 439 break;
440 } 440 }
441 } 441 }
442 eps[j++] = ep; 442 eps[j++] = ep;
443 } 443 }
444 if (j) { 444 if (j) {
445 usb_free_streams(intf, eps, j, GFP_KERNEL); 445 usb_free_streams(intf, eps, j, GFP_KERNEL);
446 kfree(eps); 446 kfree(eps);
447 } 447 }
448 448
449 /* Reset other interface state. 449 /* Reset other interface state.
450 * We cannot do a Set-Interface if the device is suspended or 450 * We cannot do a Set-Interface if the device is suspended or
451 * if it is prepared for a system sleep (since installing a new 451 * if it is prepared for a system sleep (since installing a new
452 * altsetting means creating new endpoint device entries). 452 * altsetting means creating new endpoint device entries).
453 * When either of these happens, defer the Set-Interface. 453 * When either of these happens, defer the Set-Interface.
454 */ 454 */
455 if (intf->cur_altsetting->desc.bAlternateSetting == 0) { 455 if (intf->cur_altsetting->desc.bAlternateSetting == 0) {
456 /* Already in altsetting 0 so skip Set-Interface. 456 /* Already in altsetting 0 so skip Set-Interface.
457 * Just re-enable it without affecting the endpoint toggles. 457 * Just re-enable it without affecting the endpoint toggles.
458 */ 458 */
459 usb_enable_interface(udev, intf, false); 459 usb_enable_interface(udev, intf, false);
460 } else if (!error && !intf->dev.power.is_prepared) { 460 } else if (!error && !intf->dev.power.is_prepared) {
461 r = usb_set_interface(udev, intf->altsetting[0]. 461 r = usb_set_interface(udev, intf->altsetting[0].
462 desc.bInterfaceNumber, 0); 462 desc.bInterfaceNumber, 0);
463 if (r < 0) 463 if (r < 0)
464 intf->needs_altsetting0 = 1; 464 intf->needs_altsetting0 = 1;
465 } else { 465 } else {
466 intf->needs_altsetting0 = 1; 466 intf->needs_altsetting0 = 1;
467 } 467 }
468 usb_set_intfdata(intf, NULL); 468 usb_set_intfdata(intf, NULL);
469 469
470 intf->condition = USB_INTERFACE_UNBOUND; 470 intf->condition = USB_INTERFACE_UNBOUND;
471 intf->needs_remote_wakeup = 0; 471 intf->needs_remote_wakeup = 0;
472 472
473 /* Attempt to re-enable USB3 LPM, if the disable succeeded. */ 473 /* Attempt to re-enable USB3 LPM, if the disable succeeded. */
474 if (!lpm_disable_error) 474 if (!lpm_disable_error)
475 usb_unlocked_enable_lpm(udev); 475 usb_unlocked_enable_lpm(udev);
476 476
477 /* Unbound interfaces are always runtime-PM-disabled and -suspended */ 477 /* Unbound interfaces are always runtime-PM-disabled and -suspended */
478 if (driver->supports_autosuspend) 478 if (driver->supports_autosuspend)
479 pm_runtime_disable(dev); 479 pm_runtime_disable(dev);
480 pm_runtime_set_suspended(dev); 480 pm_runtime_set_suspended(dev);
481 481
482 /* Undo any residual pm_autopm_get_interface_* calls */ 482 /* Undo any residual pm_autopm_get_interface_* calls */
483 for (r = atomic_read(&intf->pm_usage_cnt); r > 0; --r) 483 for (r = atomic_read(&intf->pm_usage_cnt); r > 0; --r)
484 usb_autopm_put_interface_no_suspend(intf); 484 usb_autopm_put_interface_no_suspend(intf);
485 atomic_set(&intf->pm_usage_cnt, 0); 485 atomic_set(&intf->pm_usage_cnt, 0);
486 486
487 if (!error) 487 if (!error)
488 usb_autosuspend_device(udev); 488 usb_autosuspend_device(udev);
489 489
490 return 0; 490 return 0;
491 } 491 }
492 492
493 /** 493 /**
494 * usb_driver_claim_interface - bind a driver to an interface 494 * usb_driver_claim_interface - bind a driver to an interface
495 * @driver: the driver to be bound 495 * @driver: the driver to be bound
496 * @iface: the interface to which it will be bound; must be in the 496 * @iface: the interface to which it will be bound; must be in the
497 * usb device's active configuration 497 * usb device's active configuration
498 * @priv: driver data associated with that interface 498 * @priv: driver data associated with that interface
499 * 499 *
500 * This is used by usb device drivers that need to claim more than one 500 * This is used by usb device drivers that need to claim more than one
501 * interface on a device when probing (audio and acm are current examples). 501 * interface on a device when probing (audio and acm are current examples).
502 * No device driver should directly modify internal usb_interface or 502 * No device driver should directly modify internal usb_interface or
503 * usb_device structure members. 503 * usb_device structure members.
504 * 504 *
505 * Few drivers should need to use this routine, since the most natural 505 * Few drivers should need to use this routine, since the most natural
506 * way to bind to an interface is to return the private data from 506 * way to bind to an interface is to return the private data from
507 * the driver's probe() method. 507 * the driver's probe() method.
508 * 508 *
509 * Callers must own the device lock, so driver probe() entries don't need 509 * Callers must own the device lock, so driver probe() entries don't need
510 * extra locking, but other call contexts may need to explicitly claim that 510 * extra locking, but other call contexts may need to explicitly claim that
511 * lock. 511 * lock.
512 * 512 *
513 * Return: 0 on success. 513 * Return: 0 on success.
514 */ 514 */
515 int usb_driver_claim_interface(struct usb_driver *driver, 515 int usb_driver_claim_interface(struct usb_driver *driver,
516 struct usb_interface *iface, void *priv) 516 struct usb_interface *iface, void *priv)
517 { 517 {
518 struct device *dev = &iface->dev; 518 struct device *dev = &iface->dev;
519 struct usb_device *udev; 519 struct usb_device *udev;
520 int retval = 0; 520 int retval = 0;
521 int lpm_disable_error; 521 int lpm_disable_error;
522 522
523 if (dev->driver) 523 if (dev->driver)
524 return -EBUSY; 524 return -EBUSY;
525 525
526 udev = interface_to_usbdev(iface); 526 udev = interface_to_usbdev(iface);
527 527
528 dev->driver = &driver->drvwrap.driver; 528 dev->driver = &driver->drvwrap.driver;
529 usb_set_intfdata(iface, priv); 529 usb_set_intfdata(iface, priv);
530 iface->needs_binding = 0; 530 iface->needs_binding = 0;
531 531
532 iface->condition = USB_INTERFACE_BOUND; 532 iface->condition = USB_INTERFACE_BOUND;
533 533
534 /* Disable LPM until this driver is bound. */ 534 /* Disable LPM until this driver is bound. */
535 lpm_disable_error = usb_unlocked_disable_lpm(udev); 535 lpm_disable_error = usb_unlocked_disable_lpm(udev);
536 if (lpm_disable_error && driver->disable_hub_initiated_lpm) { 536 if (lpm_disable_error && driver->disable_hub_initiated_lpm) {
537 dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.", 537 dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.",
538 __func__, driver->name); 538 __func__, driver->name);
539 return -ENOMEM; 539 return -ENOMEM;
540 } 540 }
541 541
542 /* Claimed interfaces are initially inactive (suspended) and 542 /* Claimed interfaces are initially inactive (suspended) and
543 * runtime-PM-enabled, but only if the driver has autosuspend 543 * runtime-PM-enabled, but only if the driver has autosuspend
544 * support. Otherwise they are marked active, to prevent the 544 * support. Otherwise they are marked active, to prevent the
545 * device from being autosuspended, but left disabled. In either 545 * device from being autosuspended, but left disabled. In either
546 * case they are sensitive to their children's power states. 546 * case they are sensitive to their children's power states.
547 */ 547 */
548 pm_suspend_ignore_children(dev, false); 548 pm_suspend_ignore_children(dev, false);
549 if (driver->supports_autosuspend) 549 if (driver->supports_autosuspend)
550 pm_runtime_enable(dev); 550 pm_runtime_enable(dev);
551 else 551 else
552 pm_runtime_set_active(dev); 552 pm_runtime_set_active(dev);
553 553
554 /* if interface was already added, bind now; else let 554 /* if interface was already added, bind now; else let
555 * the future device_add() bind it, bypassing probe() 555 * the future device_add() bind it, bypassing probe()
556 */ 556 */
557 if (device_is_registered(dev)) 557 if (device_is_registered(dev))
558 retval = device_bind_driver(dev); 558 retval = device_bind_driver(dev);
559 559
560 /* Attempt to re-enable USB3 LPM, if the disable was successful. */ 560 /* Attempt to re-enable USB3 LPM, if the disable was successful. */
561 if (!lpm_disable_error) 561 if (!lpm_disable_error)
562 usb_unlocked_enable_lpm(udev); 562 usb_unlocked_enable_lpm(udev);
563 563
564 return retval; 564 return retval;
565 } 565 }
566 EXPORT_SYMBOL_GPL(usb_driver_claim_interface); 566 EXPORT_SYMBOL_GPL(usb_driver_claim_interface);
567 567
568 /** 568 /**
569 * usb_driver_release_interface - unbind a driver from an interface 569 * usb_driver_release_interface - unbind a driver from an interface
570 * @driver: the driver to be unbound 570 * @driver: the driver to be unbound
571 * @iface: the interface from which it will be unbound 571 * @iface: the interface from which it will be unbound
572 * 572 *
573 * This can be used by drivers to release an interface without waiting 573 * This can be used by drivers to release an interface without waiting
574 * for their disconnect() methods to be called. In typical cases this 574 * for their disconnect() methods to be called. In typical cases this
575 * also causes the driver disconnect() method to be called. 575 * also causes the driver disconnect() method to be called.
576 * 576 *
577 * This call is synchronous, and may not be used in an interrupt context. 577 * This call is synchronous, and may not be used in an interrupt context.
578 * Callers must own the device lock, so driver disconnect() entries don't 578 * Callers must own the device lock, so driver disconnect() entries don't
579 * need extra locking, but other call contexts may need to explicitly claim 579 * need extra locking, but other call contexts may need to explicitly claim
580 * that lock. 580 * that lock.
581 */ 581 */
582 void usb_driver_release_interface(struct usb_driver *driver, 582 void usb_driver_release_interface(struct usb_driver *driver,
583 struct usb_interface *iface) 583 struct usb_interface *iface)
584 { 584 {
585 struct device *dev = &iface->dev; 585 struct device *dev = &iface->dev;
586 586
587 /* this should never happen, don't release something that's not ours */ 587 /* this should never happen, don't release something that's not ours */
588 if (!dev->driver || dev->driver != &driver->drvwrap.driver) 588 if (!dev->driver || dev->driver != &driver->drvwrap.driver)
589 return; 589 return;
590 590
591 /* don't release from within disconnect() */ 591 /* don't release from within disconnect() */
592 if (iface->condition != USB_INTERFACE_BOUND) 592 if (iface->condition != USB_INTERFACE_BOUND)
593 return; 593 return;
594 iface->condition = USB_INTERFACE_UNBINDING; 594 iface->condition = USB_INTERFACE_UNBINDING;
595 595
596 /* Release via the driver core only if the interface 596 /* Release via the driver core only if the interface
597 * has already been registered 597 * has already been registered
598 */ 598 */
599 if (device_is_registered(dev)) { 599 if (device_is_registered(dev)) {
600 device_release_driver(dev); 600 device_release_driver(dev);
601 } else { 601 } else {
602 device_lock(dev); 602 device_lock(dev);
603 usb_unbind_interface(dev); 603 usb_unbind_interface(dev);
604 dev->driver = NULL; 604 dev->driver = NULL;
605 device_unlock(dev); 605 device_unlock(dev);
606 } 606 }
607 } 607 }
608 EXPORT_SYMBOL_GPL(usb_driver_release_interface); 608 EXPORT_SYMBOL_GPL(usb_driver_release_interface);
609 609
610 /* returns 0 if no match, 1 if match */ 610 /* returns 0 if no match, 1 if match */
611 int usb_match_device(struct usb_device *dev, const struct usb_device_id *id) 611 int usb_match_device(struct usb_device *dev, const struct usb_device_id *id)
612 { 612 {
613 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && 613 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
614 id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) 614 id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
615 return 0; 615 return 0;
616 616
617 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && 617 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
618 id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) 618 id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
619 return 0; 619 return 0;
620 620
621 /* No need to test id->bcdDevice_lo != 0, since 0 is never 621 /* No need to test id->bcdDevice_lo != 0, since 0 is never
622 greater than any unsigned number. */ 622 greater than any unsigned number. */
623 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && 623 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
624 (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) 624 (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
625 return 0; 625 return 0;
626 626
627 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && 627 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
628 (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) 628 (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
629 return 0; 629 return 0;
630 630
631 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && 631 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
632 (id->bDeviceClass != dev->descriptor.bDeviceClass)) 632 (id->bDeviceClass != dev->descriptor.bDeviceClass))
633 return 0; 633 return 0;
634 634
635 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && 635 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
636 (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) 636 (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
637 return 0; 637 return 0;
638 638
639 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && 639 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
640 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) 640 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
641 return 0; 641 return 0;
642 642
643 return 1; 643 return 1;
644 } 644 }
645 645
646 /* returns 0 if no match, 1 if match */ 646 /* returns 0 if no match, 1 if match */
647 int usb_match_one_id_intf(struct usb_device *dev, 647 int usb_match_one_id_intf(struct usb_device *dev,
648 struct usb_host_interface *intf, 648 struct usb_host_interface *intf,
649 const struct usb_device_id *id) 649 const struct usb_device_id *id)
650 { 650 {
651 /* The interface class, subclass, protocol and number should never be 651 /* The interface class, subclass, protocol and number should never be
652 * checked for a match if the device class is Vendor Specific, 652 * checked for a match if the device class is Vendor Specific,
653 * unless the match record specifies the Vendor ID. */ 653 * unless the match record specifies the Vendor ID. */
654 if (dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC && 654 if (dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC &&
655 !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && 655 !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
656 (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS | 656 (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS |
657 USB_DEVICE_ID_MATCH_INT_SUBCLASS | 657 USB_DEVICE_ID_MATCH_INT_SUBCLASS |
658 USB_DEVICE_ID_MATCH_INT_PROTOCOL | 658 USB_DEVICE_ID_MATCH_INT_PROTOCOL |
659 USB_DEVICE_ID_MATCH_INT_NUMBER))) 659 USB_DEVICE_ID_MATCH_INT_NUMBER)))
660 return 0; 660 return 0;
661 661
662 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && 662 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
663 (id->bInterfaceClass != intf->desc.bInterfaceClass)) 663 (id->bInterfaceClass != intf->desc.bInterfaceClass))
664 return 0; 664 return 0;
665 665
666 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) && 666 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&
667 (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass)) 667 (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass))
668 return 0; 668 return 0;
669 669
670 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) && 670 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&
671 (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol)) 671 (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol))
672 return 0; 672 return 0;
673 673
674 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_NUMBER) && 674 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_NUMBER) &&
675 (id->bInterfaceNumber != intf->desc.bInterfaceNumber)) 675 (id->bInterfaceNumber != intf->desc.bInterfaceNumber))
676 return 0; 676 return 0;
677 677
678 return 1; 678 return 1;
679 } 679 }
680 680
681 /* returns 0 if no match, 1 if match */ 681 /* returns 0 if no match, 1 if match */
682 int usb_match_one_id(struct usb_interface *interface, 682 int usb_match_one_id(struct usb_interface *interface,
683 const struct usb_device_id *id) 683 const struct usb_device_id *id)
684 { 684 {
685 struct usb_host_interface *intf; 685 struct usb_host_interface *intf;
686 struct usb_device *dev; 686 struct usb_device *dev;
687 687
688 /* proc_connectinfo in devio.c may call us with id == NULL. */ 688 /* proc_connectinfo in devio.c may call us with id == NULL. */
689 if (id == NULL) 689 if (id == NULL)
690 return 0; 690 return 0;
691 691
692 intf = interface->cur_altsetting; 692 intf = interface->cur_altsetting;
693 dev = interface_to_usbdev(interface); 693 dev = interface_to_usbdev(interface);
694 694
695 if (!usb_match_device(dev, id)) 695 if (!usb_match_device(dev, id))
696 return 0; 696 return 0;
697 697
698 return usb_match_one_id_intf(dev, intf, id); 698 return usb_match_one_id_intf(dev, intf, id);
699 } 699 }
700 EXPORT_SYMBOL_GPL(usb_match_one_id); 700 EXPORT_SYMBOL_GPL(usb_match_one_id);
701 701
702 /** 702 /**
703 * usb_match_id - find first usb_device_id matching device or interface 703 * usb_match_id - find first usb_device_id matching device or interface
704 * @interface: the interface of interest 704 * @interface: the interface of interest
705 * @id: array of usb_device_id structures, terminated by zero entry 705 * @id: array of usb_device_id structures, terminated by zero entry
706 * 706 *
707 * usb_match_id searches an array of usb_device_id's and returns 707 * usb_match_id searches an array of usb_device_id's and returns
708 * the first one matching the device or interface, or null. 708 * the first one matching the device or interface, or null.
709 * This is used when binding (or rebinding) a driver to an interface. 709 * This is used when binding (or rebinding) a driver to an interface.
710 * Most USB device drivers will use this indirectly, through the usb core, 710 * Most USB device drivers will use this indirectly, through the usb core,
711 * but some layered driver frameworks use it directly. 711 * but some layered driver frameworks use it directly.
712 * These device tables are exported with MODULE_DEVICE_TABLE, through 712 * These device tables are exported with MODULE_DEVICE_TABLE, through
713 * modutils, to support the driver loading functionality of USB hotplugging. 713 * modutils, to support the driver loading functionality of USB hotplugging.
714 * 714 *
715 * Return: The first matching usb_device_id, or %NULL. 715 * Return: The first matching usb_device_id, or %NULL.
716 * 716 *
717 * What Matches: 717 * What Matches:
718 * 718 *
719 * The "match_flags" element in a usb_device_id controls which 719 * The "match_flags" element in a usb_device_id controls which
720 * members are used. If the corresponding bit is set, the 720 * members are used. If the corresponding bit is set, the
721 * value in the device_id must match its corresponding member 721 * value in the device_id must match its corresponding member
722 * in the device or interface descriptor, or else the device_id 722 * in the device or interface descriptor, or else the device_id
723 * does not match. 723 * does not match.
724 * 724 *
725 * "driver_info" is normally used only by device drivers, 725 * "driver_info" is normally used only by device drivers,
726 * but you can create a wildcard "matches anything" usb_device_id 726 * but you can create a wildcard "matches anything" usb_device_id
727 * as a driver's "modules.usbmap" entry if you provide an id with 727 * as a driver's "modules.usbmap" entry if you provide an id with
728 * only a nonzero "driver_info" field. If you do this, the USB device 728 * only a nonzero "driver_info" field. If you do this, the USB device
729 * driver's probe() routine should use additional intelligence to 729 * driver's probe() routine should use additional intelligence to
730 * decide whether to bind to the specified interface. 730 * decide whether to bind to the specified interface.
731 * 731 *
732 * What Makes Good usb_device_id Tables: 732 * What Makes Good usb_device_id Tables:
733 * 733 *
734 * The match algorithm is very simple, so that intelligence in 734 * The match algorithm is very simple, so that intelligence in
735 * driver selection must come from smart driver id records. 735 * driver selection must come from smart driver id records.
736 * Unless you have good reasons to use another selection policy, 736 * Unless you have good reasons to use another selection policy,
737 * provide match elements only in related groups, and order match 737 * provide match elements only in related groups, and order match
738 * specifiers from specific to general. Use the macros provided 738 * specifiers from specific to general. Use the macros provided
739 * for that purpose if you can. 739 * for that purpose if you can.
740 * 740 *
741 * The most specific match specifiers use device descriptor 741 * The most specific match specifiers use device descriptor
742 * data. These are commonly used with product-specific matches; 742 * data. These are commonly used with product-specific matches;
743 * the USB_DEVICE macro lets you provide vendor and product IDs, 743 * the USB_DEVICE macro lets you provide vendor and product IDs,
744 * and you can also match against ranges of product revisions. 744 * and you can also match against ranges of product revisions.
745 * These are widely used for devices with application or vendor 745 * These are widely used for devices with application or vendor
746 * specific bDeviceClass values. 746 * specific bDeviceClass values.
747 * 747 *
748 * Matches based on device class/subclass/protocol specifications 748 * Matches based on device class/subclass/protocol specifications
749 * are slightly more general; use the USB_DEVICE_INFO macro, or 749 * are slightly more general; use the USB_DEVICE_INFO macro, or
750 * its siblings. These are used with single-function devices 750 * its siblings. These are used with single-function devices
751 * where bDeviceClass doesn't specify that each interface has 751 * where bDeviceClass doesn't specify that each interface has
752 * its own class. 752 * its own class.
753 * 753 *
754 * Matches based on interface class/subclass/protocol are the 754 * Matches based on interface class/subclass/protocol are the
755 * most general; they let drivers bind to any interface on a 755 * most general; they let drivers bind to any interface on a
756 * multiple-function device. Use the USB_INTERFACE_INFO 756 * multiple-function device. Use the USB_INTERFACE_INFO
757 * macro, or its siblings, to match class-per-interface style 757 * macro, or its siblings, to match class-per-interface style
758 * devices (as recorded in bInterfaceClass). 758 * devices (as recorded in bInterfaceClass).
759 * 759 *
760 * Note that an entry created by USB_INTERFACE_INFO won't match 760 * Note that an entry created by USB_INTERFACE_INFO won't match
761 * any interface if the device class is set to Vendor-Specific. 761 * any interface if the device class is set to Vendor-Specific.
762 * This is deliberate; according to the USB spec the meanings of 762 * This is deliberate; according to the USB spec the meanings of
763 * the interface class/subclass/protocol for these devices are also 763 * the interface class/subclass/protocol for these devices are also
764 * vendor-specific, and hence matching against a standard product 764 * vendor-specific, and hence matching against a standard product
765 * class wouldn't work anyway. If you really want to use an 765 * class wouldn't work anyway. If you really want to use an
766 * interface-based match for such a device, create a match record 766 * interface-based match for such a device, create a match record
767 * that also specifies the vendor ID. (Unforunately there isn't a 767 * that also specifies the vendor ID. (Unforunately there isn't a
768 * standard macro for creating records like this.) 768 * standard macro for creating records like this.)
769 * 769 *
770 * Within those groups, remember that not all combinations are 770 * Within those groups, remember that not all combinations are
771 * meaningful. For example, don't give a product version range 771 * meaningful. For example, don't give a product version range
772 * without vendor and product IDs; or specify a protocol without 772 * without vendor and product IDs; or specify a protocol without
773 * its associated class and subclass. 773 * its associated class and subclass.
774 */ 774 */
775 const struct usb_device_id *usb_match_id(struct usb_interface *interface, 775 const struct usb_device_id *usb_match_id(struct usb_interface *interface,
776 const struct usb_device_id *id) 776 const struct usb_device_id *id)
777 { 777 {
778 /* proc_connectinfo in devio.c may call us with id == NULL. */ 778 /* proc_connectinfo in devio.c may call us with id == NULL. */
779 if (id == NULL) 779 if (id == NULL)
780 return NULL; 780 return NULL;
781 781
782 /* It is important to check that id->driver_info is nonzero, 782 /* It is important to check that id->driver_info is nonzero,
783 since an entry that is all zeroes except for a nonzero 783 since an entry that is all zeroes except for a nonzero
784 id->driver_info is the way to create an entry that 784 id->driver_info is the way to create an entry that
785 indicates that the driver want to examine every 785 indicates that the driver want to examine every
786 device and interface. */ 786 device and interface. */
787 for (; id->idVendor || id->idProduct || id->bDeviceClass || 787 for (; id->idVendor || id->idProduct || id->bDeviceClass ||
788 id->bInterfaceClass || id->driver_info; id++) { 788 id->bInterfaceClass || id->driver_info; id++) {
789 if (usb_match_one_id(interface, id)) 789 if (usb_match_one_id(interface, id))
790 return id; 790 return id;
791 } 791 }
792 792
793 return NULL; 793 return NULL;
794 } 794 }
795 EXPORT_SYMBOL_GPL(usb_match_id); 795 EXPORT_SYMBOL_GPL(usb_match_id);
796 796
797 static int usb_device_match(struct device *dev, struct device_driver *drv) 797 static int usb_device_match(struct device *dev, struct device_driver *drv)
798 { 798 {
799 /* devices and interfaces are handled separately */ 799 /* devices and interfaces are handled separately */
800 if (is_usb_device(dev)) { 800 if (is_usb_device(dev)) {
801 801
802 /* interface drivers never match devices */ 802 /* interface drivers never match devices */
803 if (!is_usb_device_driver(drv)) 803 if (!is_usb_device_driver(drv))
804 return 0; 804 return 0;
805 805
806 /* TODO: Add real matching code */ 806 /* TODO: Add real matching code */
807 return 1; 807 return 1;
808 808
809 } else if (is_usb_interface(dev)) { 809 } else if (is_usb_interface(dev)) {
810 struct usb_interface *intf; 810 struct usb_interface *intf;
811 struct usb_driver *usb_drv; 811 struct usb_driver *usb_drv;
812 const struct usb_device_id *id; 812 const struct usb_device_id *id;
813 813
814 /* device drivers never match interfaces */ 814 /* device drivers never match interfaces */
815 if (is_usb_device_driver(drv)) 815 if (is_usb_device_driver(drv))
816 return 0; 816 return 0;
817 817
818 intf = to_usb_interface(dev); 818 intf = to_usb_interface(dev);
819 usb_drv = to_usb_driver(drv); 819 usb_drv = to_usb_driver(drv);
820 820
821 id = usb_match_id(intf, usb_drv->id_table); 821 id = usb_match_id(intf, usb_drv->id_table);
822 if (id) 822 if (id)
823 return 1; 823 return 1;
824 824
825 id = usb_match_dynamic_id(intf, usb_drv); 825 id = usb_match_dynamic_id(intf, usb_drv);
826 if (id) 826 if (id)
827 return 1; 827 return 1;
828 } 828 }
829 829
830 return 0; 830 return 0;
831 } 831 }
832 832
833 static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) 833 static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
834 { 834 {
835 struct usb_device *usb_dev; 835 struct usb_device *usb_dev;
836 836
837 if (is_usb_device(dev)) { 837 if (is_usb_device(dev)) {
838 usb_dev = to_usb_device(dev); 838 usb_dev = to_usb_device(dev);
839 } else if (is_usb_interface(dev)) { 839 } else if (is_usb_interface(dev)) {
840 struct usb_interface *intf = to_usb_interface(dev); 840 struct usb_interface *intf = to_usb_interface(dev);
841 841
842 usb_dev = interface_to_usbdev(intf); 842 usb_dev = interface_to_usbdev(intf);
843 } else { 843 } else {
844 return 0; 844 return 0;
845 } 845 }
846 846
847 if (usb_dev->devnum < 0) { 847 if (usb_dev->devnum < 0) {
848 /* driver is often null here; dev_dbg() would oops */ 848 /* driver is often null here; dev_dbg() would oops */
849 pr_debug("usb %s: already deleted?\n", dev_name(dev)); 849 pr_debug("usb %s: already deleted?\n", dev_name(dev));
850 return -ENODEV; 850 return -ENODEV;
851 } 851 }
852 if (!usb_dev->bus) { 852 if (!usb_dev->bus) {
853 pr_debug("usb %s: bus removed?\n", dev_name(dev)); 853 pr_debug("usb %s: bus removed?\n", dev_name(dev));
854 return -ENODEV; 854 return -ENODEV;
855 } 855 }
856 856
857 /* per-device configurations are common */ 857 /* per-device configurations are common */
858 if (add_uevent_var(env, "PRODUCT=%x/%x/%x", 858 if (add_uevent_var(env, "PRODUCT=%x/%x/%x",
859 le16_to_cpu(usb_dev->descriptor.idVendor), 859 le16_to_cpu(usb_dev->descriptor.idVendor),
860 le16_to_cpu(usb_dev->descriptor.idProduct), 860 le16_to_cpu(usb_dev->descriptor.idProduct),
861 le16_to_cpu(usb_dev->descriptor.bcdDevice))) 861 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
862 return -ENOMEM; 862 return -ENOMEM;
863 863
864 /* class-based driver binding models */ 864 /* class-based driver binding models */
865 if (add_uevent_var(env, "TYPE=%d/%d/%d", 865 if (add_uevent_var(env, "TYPE=%d/%d/%d",
866 usb_dev->descriptor.bDeviceClass, 866 usb_dev->descriptor.bDeviceClass,
867 usb_dev->descriptor.bDeviceSubClass, 867 usb_dev->descriptor.bDeviceSubClass,
868 usb_dev->descriptor.bDeviceProtocol)) 868 usb_dev->descriptor.bDeviceProtocol))
869 return -ENOMEM; 869 return -ENOMEM;
870 870
871 return 0; 871 return 0;
872 } 872 }
873 873
874 /** 874 /**
875 * usb_register_device_driver - register a USB device (not interface) driver 875 * usb_register_device_driver - register a USB device (not interface) driver
876 * @new_udriver: USB operations for the device driver 876 * @new_udriver: USB operations for the device driver
877 * @owner: module owner of this driver. 877 * @owner: module owner of this driver.
878 * 878 *
879 * Registers a USB device driver with the USB core. The list of 879 * Registers a USB device driver with the USB core. The list of
880 * unattached devices will be rescanned whenever a new driver is 880 * unattached devices will be rescanned whenever a new driver is
881 * added, allowing the new driver to attach to any recognized devices. 881 * added, allowing the new driver to attach to any recognized devices.
882 * 882 *
883 * Return: A negative error code on failure and 0 on success. 883 * Return: A negative error code on failure and 0 on success.
884 */ 884 */
885 int usb_register_device_driver(struct usb_device_driver *new_udriver, 885 int usb_register_device_driver(struct usb_device_driver *new_udriver,
886 struct module *owner) 886 struct module *owner)
887 { 887 {
888 int retval = 0; 888 int retval = 0;
889 889
890 if (usb_disabled()) 890 if (usb_disabled())
891 return -ENODEV; 891 return -ENODEV;
892 892
893 new_udriver->drvwrap.for_devices = 1; 893 new_udriver->drvwrap.for_devices = 1;
894 new_udriver->drvwrap.driver.name = new_udriver->name; 894 new_udriver->drvwrap.driver.name = new_udriver->name;
895 new_udriver->drvwrap.driver.bus = &usb_bus_type; 895 new_udriver->drvwrap.driver.bus = &usb_bus_type;
896 new_udriver->drvwrap.driver.probe = usb_probe_device; 896 new_udriver->drvwrap.driver.probe = usb_probe_device;
897 new_udriver->drvwrap.driver.remove = usb_unbind_device; 897 new_udriver->drvwrap.driver.remove = usb_unbind_device;
898 new_udriver->drvwrap.driver.owner = owner; 898 new_udriver->drvwrap.driver.owner = owner;
899 899
900 retval = driver_register(&new_udriver->drvwrap.driver); 900 retval = driver_register(&new_udriver->drvwrap.driver);
901 901
902 if (!retval) 902 if (!retval)
903 pr_info("%s: registered new device driver %s\n", 903 pr_info("%s: registered new device driver %s\n",
904 usbcore_name, new_udriver->name); 904 usbcore_name, new_udriver->name);
905 else 905 else
906 printk(KERN_ERR "%s: error %d registering device " 906 printk(KERN_ERR "%s: error %d registering device "
907 " driver %s\n", 907 " driver %s\n",
908 usbcore_name, retval, new_udriver->name); 908 usbcore_name, retval, new_udriver->name);
909 909
910 return retval; 910 return retval;
911 } 911 }
912 EXPORT_SYMBOL_GPL(usb_register_device_driver); 912 EXPORT_SYMBOL_GPL(usb_register_device_driver);
913 913
914 /** 914 /**
915 * usb_deregister_device_driver - unregister a USB device (not interface) driver 915 * usb_deregister_device_driver - unregister a USB device (not interface) driver
916 * @udriver: USB operations of the device driver to unregister 916 * @udriver: USB operations of the device driver to unregister
917 * Context: must be able to sleep 917 * Context: must be able to sleep
918 * 918 *
919 * Unlinks the specified driver from the internal USB driver list. 919 * Unlinks the specified driver from the internal USB driver list.
920 */ 920 */
921 void usb_deregister_device_driver(struct usb_device_driver *udriver) 921 void usb_deregister_device_driver(struct usb_device_driver *udriver)
922 { 922 {
923 pr_info("%s: deregistering device driver %s\n", 923 pr_info("%s: deregistering device driver %s\n",
924 usbcore_name, udriver->name); 924 usbcore_name, udriver->name);
925 925
926 driver_unregister(&udriver->drvwrap.driver); 926 driver_unregister(&udriver->drvwrap.driver);
927 } 927 }
928 EXPORT_SYMBOL_GPL(usb_deregister_device_driver); 928 EXPORT_SYMBOL_GPL(usb_deregister_device_driver);
929 929
930 /** 930 /**
931 * usb_register_driver - register a USB interface driver 931 * usb_register_driver - register a USB interface driver
932 * @new_driver: USB operations for the interface driver 932 * @new_driver: USB operations for the interface driver
933 * @owner: module owner of this driver. 933 * @owner: module owner of this driver.
934 * @mod_name: module name string 934 * @mod_name: module name string
935 * 935 *
936 * Registers a USB interface driver with the USB core. The list of 936 * Registers a USB interface driver with the USB core. The list of
937 * unattached interfaces will be rescanned whenever a new driver is 937 * unattached interfaces will be rescanned whenever a new driver is
938 * added, allowing the new driver to attach to any recognized interfaces. 938 * added, allowing the new driver to attach to any recognized interfaces.
939 * 939 *
940 * Return: A negative error code on failure and 0 on success. 940 * Return: A negative error code on failure and 0 on success.
941 * 941 *
942 * NOTE: if you want your driver to use the USB major number, you must call 942 * NOTE: if you want your driver to use the USB major number, you must call
943 * usb_register_dev() to enable that functionality. This function no longer 943 * usb_register_dev() to enable that functionality. This function no longer
944 * takes care of that. 944 * takes care of that.
945 */ 945 */
946 int usb_register_driver(struct usb_driver *new_driver, struct module *owner, 946 int usb_register_driver(struct usb_driver *new_driver, struct module *owner,
947 const char *mod_name) 947 const char *mod_name)
948 { 948 {
949 int retval = 0; 949 int retval = 0;
950 950
951 if (usb_disabled()) 951 if (usb_disabled())
952 return -ENODEV; 952 return -ENODEV;
953 953
954 new_driver->drvwrap.for_devices = 0; 954 new_driver->drvwrap.for_devices = 0;
955 new_driver->drvwrap.driver.name = new_driver->name; 955 new_driver->drvwrap.driver.name = new_driver->name;
956 new_driver->drvwrap.driver.bus = &usb_bus_type; 956 new_driver->drvwrap.driver.bus = &usb_bus_type;
957 new_driver->drvwrap.driver.probe = usb_probe_interface; 957 new_driver->drvwrap.driver.probe = usb_probe_interface;
958 new_driver->drvwrap.driver.remove = usb_unbind_interface; 958 new_driver->drvwrap.driver.remove = usb_unbind_interface;
959 new_driver->drvwrap.driver.owner = owner; 959 new_driver->drvwrap.driver.owner = owner;
960 new_driver->drvwrap.driver.mod_name = mod_name; 960 new_driver->drvwrap.driver.mod_name = mod_name;
961 spin_lock_init(&new_driver->dynids.lock); 961 spin_lock_init(&new_driver->dynids.lock);
962 INIT_LIST_HEAD(&new_driver->dynids.list); 962 INIT_LIST_HEAD(&new_driver->dynids.list);
963 963
964 retval = driver_register(&new_driver->drvwrap.driver); 964 retval = driver_register(&new_driver->drvwrap.driver);
965 if (retval) 965 if (retval)
966 goto out; 966 goto out;
967 967
968 retval = usb_create_newid_files(new_driver); 968 retval = usb_create_newid_files(new_driver);
969 if (retval) 969 if (retval)
970 goto out_newid; 970 goto out_newid;
971 971
972 pr_info("%s: registered new interface driver %s\n", 972 pr_info("%s: registered new interface driver %s\n",
973 usbcore_name, new_driver->name); 973 usbcore_name, new_driver->name);
974 974
975 out: 975 out:
976 return retval; 976 return retval;
977 977
978 out_newid: 978 out_newid:
979 driver_unregister(&new_driver->drvwrap.driver); 979 driver_unregister(&new_driver->drvwrap.driver);
980 980
981 printk(KERN_ERR "%s: error %d registering interface " 981 printk(KERN_ERR "%s: error %d registering interface "
982 " driver %s\n", 982 " driver %s\n",
983 usbcore_name, retval, new_driver->name); 983 usbcore_name, retval, new_driver->name);
984 goto out; 984 goto out;
985 } 985 }
986 EXPORT_SYMBOL_GPL(usb_register_driver); 986 EXPORT_SYMBOL_GPL(usb_register_driver);
987 987
988 /** 988 /**
989 * usb_deregister - unregister a USB interface driver 989 * usb_deregister - unregister a USB interface driver
990 * @driver: USB operations of the interface driver to unregister 990 * @driver: USB operations of the interface driver to unregister
991 * Context: must be able to sleep 991 * Context: must be able to sleep
992 * 992 *
993 * Unlinks the specified driver from the internal USB driver list. 993 * Unlinks the specified driver from the internal USB driver list.
994 * 994 *
995 * NOTE: If you called usb_register_dev(), you still need to call 995 * NOTE: If you called usb_register_dev(), you still need to call
996 * usb_deregister_dev() to clean up your driver's allocated minor numbers, 996 * usb_deregister_dev() to clean up your driver's allocated minor numbers,
997 * this * call will no longer do it for you. 997 * this * call will no longer do it for you.
998 */ 998 */
999 void usb_deregister(struct usb_driver *driver) 999 void usb_deregister(struct usb_driver *driver)
1000 { 1000 {
1001 pr_info("%s: deregistering interface driver %s\n", 1001 pr_info("%s: deregistering interface driver %s\n",
1002 usbcore_name, driver->name); 1002 usbcore_name, driver->name);
1003 1003
1004 usb_remove_newid_files(driver); 1004 usb_remove_newid_files(driver);
1005 driver_unregister(&driver->drvwrap.driver); 1005 driver_unregister(&driver->drvwrap.driver);
1006 usb_free_dynids(driver); 1006 usb_free_dynids(driver);
1007 } 1007 }
1008 EXPORT_SYMBOL_GPL(usb_deregister); 1008 EXPORT_SYMBOL_GPL(usb_deregister);
1009 1009
1010 /* Forced unbinding of a USB interface driver, either because 1010 /* Forced unbinding of a USB interface driver, either because
1011 * it doesn't support pre_reset/post_reset/reset_resume or 1011 * it doesn't support pre_reset/post_reset/reset_resume or
1012 * because it doesn't support suspend/resume. 1012 * because it doesn't support suspend/resume.
1013 * 1013 *
1014 * The caller must hold @intf's device's lock, but not @intf's lock. 1014 * The caller must hold @intf's device's lock, but not @intf's lock.
1015 */ 1015 */
1016 void usb_forced_unbind_intf(struct usb_interface *intf) 1016 void usb_forced_unbind_intf(struct usb_interface *intf)
1017 { 1017 {
1018 struct usb_driver *driver = to_usb_driver(intf->dev.driver); 1018 struct usb_driver *driver = to_usb_driver(intf->dev.driver);
1019 1019
1020 dev_dbg(&intf->dev, "forced unbind\n"); 1020 dev_dbg(&intf->dev, "forced unbind\n");
1021 usb_driver_release_interface(driver, intf); 1021 usb_driver_release_interface(driver, intf);
1022 1022
1023 /* Mark the interface for later rebinding */ 1023 /* Mark the interface for later rebinding */
1024 intf->needs_binding = 1; 1024 intf->needs_binding = 1;
1025 } 1025 }
1026 1026
1027 /* 1027 /*
1028 * Unbind drivers for @udev's marked interfaces. These interfaces have 1028 * Unbind drivers for @udev's marked interfaces. These interfaces have
1029 * the needs_binding flag set, for example by usb_resume_interface(). 1029 * the needs_binding flag set, for example by usb_resume_interface().
1030 * 1030 *
1031 * The caller must hold @udev's device lock. 1031 * The caller must hold @udev's device lock.
1032 */ 1032 */
1033 static void unbind_marked_interfaces(struct usb_device *udev) 1033 static void unbind_marked_interfaces(struct usb_device *udev)
1034 { 1034 {
1035 struct usb_host_config *config; 1035 struct usb_host_config *config;
1036 int i; 1036 int i;
1037 struct usb_interface *intf; 1037 struct usb_interface *intf;
1038 1038
1039 config = udev->actconfig; 1039 config = udev->actconfig;
1040 if (config) { 1040 if (config) {
1041 for (i = 0; i < config->desc.bNumInterfaces; ++i) { 1041 for (i = 0; i < config->desc.bNumInterfaces; ++i) {
1042 intf = config->interface[i]; 1042 intf = config->interface[i];
1043 if (intf->dev.driver && intf->needs_binding) 1043 if (intf->dev.driver && intf->needs_binding)
1044 usb_forced_unbind_intf(intf); 1044 usb_forced_unbind_intf(intf);
1045 } 1045 }
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 /* Delayed forced unbinding of a USB interface driver and scan 1049 /* Delayed forced unbinding of a USB interface driver and scan
1050 * for rebinding. 1050 * for rebinding.
1051 * 1051 *
1052 * The caller must hold @intf's device's lock, but not @intf's lock. 1052 * The caller must hold @intf's device's lock, but not @intf's lock.
1053 * 1053 *
1054 * Note: Rebinds will be skipped if a system sleep transition is in 1054 * Note: Rebinds will be skipped if a system sleep transition is in
1055 * progress and the PM "complete" callback hasn't occurred yet. 1055 * progress and the PM "complete" callback hasn't occurred yet.
1056 */ 1056 */
1057 static void usb_rebind_intf(struct usb_interface *intf) 1057 static void usb_rebind_intf(struct usb_interface *intf)
1058 { 1058 {
1059 int rc; 1059 int rc;
1060 1060
1061 /* Delayed unbind of an existing driver */ 1061 /* Delayed unbind of an existing driver */
1062 if (intf->dev.driver) 1062 if (intf->dev.driver)
1063 usb_forced_unbind_intf(intf); 1063 usb_forced_unbind_intf(intf);
1064 1064
1065 /* Try to rebind the interface */ 1065 /* Try to rebind the interface */
1066 if (!intf->dev.power.is_prepared) { 1066 if (!intf->dev.power.is_prepared) {
1067 intf->needs_binding = 0; 1067 intf->needs_binding = 0;
1068 rc = device_attach(&intf->dev); 1068 rc = device_attach(&intf->dev);
1069 if (rc < 0) 1069 if (rc < 0)
1070 dev_warn(&intf->dev, "rebind failed: %d\n", rc); 1070 dev_warn(&intf->dev, "rebind failed: %d\n", rc);
1071 } 1071 }
1072 } 1072 }
1073 1073
1074 /* 1074 /*
1075 * Rebind drivers to @udev's marked interfaces. These interfaces have 1075 * Rebind drivers to @udev's marked interfaces. These interfaces have
1076 * the needs_binding flag set. 1076 * the needs_binding flag set.
1077 * 1077 *
1078 * The caller must hold @udev's device lock. 1078 * The caller must hold @udev's device lock.
1079 */ 1079 */
1080 static void rebind_marked_interfaces(struct usb_device *udev) 1080 static void rebind_marked_interfaces(struct usb_device *udev)
1081 { 1081 {
1082 struct usb_host_config *config; 1082 struct usb_host_config *config;
1083 int i; 1083 int i;
1084 struct usb_interface *intf; 1084 struct usb_interface *intf;
1085 1085
1086 config = udev->actconfig; 1086 config = udev->actconfig;
1087 if (config) { 1087 if (config) {
1088 for (i = 0; i < config->desc.bNumInterfaces; ++i) { 1088 for (i = 0; i < config->desc.bNumInterfaces; ++i) {
1089 intf = config->interface[i]; 1089 intf = config->interface[i];
1090 if (intf->needs_binding) 1090 if (intf->needs_binding)
1091 usb_rebind_intf(intf); 1091 usb_rebind_intf(intf);
1092 } 1092 }
1093 } 1093 }
1094 } 1094 }
1095 1095
1096 /* 1096 /*
1097 * Unbind all of @udev's marked interfaces and then rebind all of them. 1097 * Unbind all of @udev's marked interfaces and then rebind all of them.
1098 * This ordering is necessary because some drivers claim several interfaces 1098 * This ordering is necessary because some drivers claim several interfaces
1099 * when they are first probed. 1099 * when they are first probed.
1100 * 1100 *
1101 * The caller must hold @udev's device lock. 1101 * The caller must hold @udev's device lock.
1102 */ 1102 */
1103 void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev) 1103 void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev)
1104 { 1104 {
1105 unbind_marked_interfaces(udev); 1105 unbind_marked_interfaces(udev);
1106 rebind_marked_interfaces(udev); 1106 rebind_marked_interfaces(udev);
1107 } 1107 }
1108 1108
1109 #ifdef CONFIG_PM 1109 #ifdef CONFIG_PM
1110 1110
1111 /* Unbind drivers for @udev's interfaces that don't support suspend/resume 1111 /* Unbind drivers for @udev's interfaces that don't support suspend/resume
1112 * There is no check for reset_resume here because it can be determined 1112 * There is no check for reset_resume here because it can be determined
1113 * only during resume whether reset_resume is needed. 1113 * only during resume whether reset_resume is needed.
1114 * 1114 *
1115 * The caller must hold @udev's device lock. 1115 * The caller must hold @udev's device lock.
1116 */ 1116 */
1117 static void unbind_no_pm_drivers_interfaces(struct usb_device *udev) 1117 static void unbind_no_pm_drivers_interfaces(struct usb_device *udev)
1118 { 1118 {
1119 struct usb_host_config *config; 1119 struct usb_host_config *config;
1120 int i; 1120 int i;
1121 struct usb_interface *intf; 1121 struct usb_interface *intf;
1122 struct usb_driver *drv; 1122 struct usb_driver *drv;
1123 1123
1124 config = udev->actconfig; 1124 config = udev->actconfig;
1125 if (config) { 1125 if (config) {
1126 for (i = 0; i < config->desc.bNumInterfaces; ++i) { 1126 for (i = 0; i < config->desc.bNumInterfaces; ++i) {
1127 intf = config->interface[i]; 1127 intf = config->interface[i];
1128 1128
1129 if (intf->dev.driver) { 1129 if (intf->dev.driver) {
1130 drv = to_usb_driver(intf->dev.driver); 1130 drv = to_usb_driver(intf->dev.driver);
1131 if (!drv->suspend || !drv->resume) 1131 if (!drv->suspend || !drv->resume)
1132 usb_forced_unbind_intf(intf); 1132 usb_forced_unbind_intf(intf);
1133 } 1133 }
1134 } 1134 }
1135 } 1135 }
1136 } 1136 }
1137 1137
1138 static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) 1138 static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
1139 { 1139 {
1140 struct usb_device_driver *udriver; 1140 struct usb_device_driver *udriver;
1141 int status = 0; 1141 int status = 0;
1142 1142
1143 if (udev->state == USB_STATE_NOTATTACHED || 1143 if (udev->state == USB_STATE_NOTATTACHED ||
1144 udev->state == USB_STATE_SUSPENDED) 1144 udev->state == USB_STATE_SUSPENDED)
1145 goto done; 1145 goto done;
1146 1146
1147 /* For devices that don't have a driver, we do a generic suspend. */ 1147 /* For devices that don't have a driver, we do a generic suspend. */
1148 if (udev->dev.driver) 1148 if (udev->dev.driver)
1149 udriver = to_usb_device_driver(udev->dev.driver); 1149 udriver = to_usb_device_driver(udev->dev.driver);
1150 else { 1150 else {
1151 udev->do_remote_wakeup = 0; 1151 udev->do_remote_wakeup = 0;
1152 udriver = &usb_generic_driver; 1152 udriver = &usb_generic_driver;
1153 } 1153 }
1154 status = udriver->suspend(udev, msg); 1154 status = udriver->suspend(udev, msg);
1155 1155
1156 done: 1156 done:
1157 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); 1157 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
1158 return status; 1158 return status;
1159 } 1159 }
1160 1160
1161 static int usb_resume_device(struct usb_device *udev, pm_message_t msg) 1161 static int usb_resume_device(struct usb_device *udev, pm_message_t msg)
1162 { 1162 {
1163 struct usb_device_driver *udriver; 1163 struct usb_device_driver *udriver;
1164 int status = 0; 1164 int status = 0;
1165 1165
1166 if (udev->state == USB_STATE_NOTATTACHED) 1166 if (udev->state == USB_STATE_NOTATTACHED)
1167 goto done; 1167 goto done;
1168 1168
1169 /* Can't resume it if it doesn't have a driver. */ 1169 /* Can't resume it if it doesn't have a driver. */
1170 if (udev->dev.driver == NULL) { 1170 if (udev->dev.driver == NULL) {
1171 status = -ENOTCONN; 1171 status = -ENOTCONN;
1172 goto done; 1172 goto done;
1173 } 1173 }
1174 1174
1175 /* Non-root devices on a full/low-speed bus must wait for their 1175 /* Non-root devices on a full/low-speed bus must wait for their
1176 * companion high-speed root hub, in case a handoff is needed. 1176 * companion high-speed root hub, in case a handoff is needed.
1177 */ 1177 */
1178 if (!PMSG_IS_AUTO(msg) && udev->parent && udev->bus->hs_companion) 1178 if (!PMSG_IS_AUTO(msg) && udev->parent && udev->bus->hs_companion)
1179 device_pm_wait_for_dev(&udev->dev, 1179 device_pm_wait_for_dev(&udev->dev,
1180 &udev->bus->hs_companion->root_hub->dev); 1180 &udev->bus->hs_companion->root_hub->dev);
1181 1181
1182 if (udev->quirks & USB_QUIRK_RESET_RESUME) 1182 if (udev->quirks & USB_QUIRK_RESET_RESUME)
1183 udev->reset_resume = 1; 1183 udev->reset_resume = 1;
1184 1184
1185 udriver = to_usb_device_driver(udev->dev.driver); 1185 udriver = to_usb_device_driver(udev->dev.driver);
1186 status = udriver->resume(udev, msg); 1186 status = udriver->resume(udev, msg);
1187 1187
1188 done: 1188 done:
1189 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); 1189 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
1190 return status; 1190 return status;
1191 } 1191 }
1192 1192
1193 static int usb_suspend_interface(struct usb_device *udev, 1193 static int usb_suspend_interface(struct usb_device *udev,
1194 struct usb_interface *intf, pm_message_t msg) 1194 struct usb_interface *intf, pm_message_t msg)
1195 { 1195 {
1196 struct usb_driver *driver; 1196 struct usb_driver *driver;
1197 int status = 0; 1197 int status = 0;
1198 1198
1199 if (udev->state == USB_STATE_NOTATTACHED || 1199 if (udev->state == USB_STATE_NOTATTACHED ||
1200 intf->condition == USB_INTERFACE_UNBOUND) 1200 intf->condition == USB_INTERFACE_UNBOUND)
1201 goto done; 1201 goto done;
1202 driver = to_usb_driver(intf->dev.driver); 1202 driver = to_usb_driver(intf->dev.driver);
1203 1203
1204 /* at this time we know the driver supports suspend */ 1204 /* at this time we know the driver supports suspend */
1205 status = driver->suspend(intf, msg); 1205 status = driver->suspend(intf, msg);
1206 if (status && !PMSG_IS_AUTO(msg)) 1206 if (status && !PMSG_IS_AUTO(msg))
1207 dev_err(&intf->dev, "suspend error %d\n", status); 1207 dev_err(&intf->dev, "suspend error %d\n", status);
1208 1208
1209 done: 1209 done:
1210 dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); 1210 dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status);
1211 return status; 1211 return status;
1212 } 1212 }
1213 1213
1214 static int usb_resume_interface(struct usb_device *udev, 1214 static int usb_resume_interface(struct usb_device *udev,
1215 struct usb_interface *intf, pm_message_t msg, int reset_resume) 1215 struct usb_interface *intf, pm_message_t msg, int reset_resume)
1216 { 1216 {
1217 struct usb_driver *driver; 1217 struct usb_driver *driver;
1218 int status = 0; 1218 int status = 0;
1219 1219
1220 if (udev->state == USB_STATE_NOTATTACHED) 1220 if (udev->state == USB_STATE_NOTATTACHED)
1221 goto done; 1221 goto done;
1222 1222
1223 /* Don't let autoresume interfere with unbinding */ 1223 /* Don't let autoresume interfere with unbinding */
1224 if (intf->condition == USB_INTERFACE_UNBINDING) 1224 if (intf->condition == USB_INTERFACE_UNBINDING)
1225 goto done; 1225 goto done;
1226 1226
1227 /* Can't resume it if it doesn't have a driver. */ 1227 /* Can't resume it if it doesn't have a driver. */
1228 if (intf->condition == USB_INTERFACE_UNBOUND) { 1228 if (intf->condition == USB_INTERFACE_UNBOUND) {
1229 1229
1230 /* Carry out a deferred switch to altsetting 0 */ 1230 /* Carry out a deferred switch to altsetting 0 */
1231 if (intf->needs_altsetting0 && !intf->dev.power.is_prepared) { 1231 if (intf->needs_altsetting0 && !intf->dev.power.is_prepared) {
1232 usb_set_interface(udev, intf->altsetting[0]. 1232 usb_set_interface(udev, intf->altsetting[0].
1233 desc.bInterfaceNumber, 0); 1233 desc.bInterfaceNumber, 0);
1234 intf->needs_altsetting0 = 0; 1234 intf->needs_altsetting0 = 0;
1235 } 1235 }
1236 goto done; 1236 goto done;
1237 } 1237 }
1238 1238
1239 /* Don't resume if the interface is marked for rebinding */ 1239 /* Don't resume if the interface is marked for rebinding */
1240 if (intf->needs_binding) 1240 if (intf->needs_binding)
1241 goto done; 1241 goto done;
1242 driver = to_usb_driver(intf->dev.driver); 1242 driver = to_usb_driver(intf->dev.driver);
1243 1243
1244 if (reset_resume) { 1244 if (reset_resume) {
1245 if (driver->reset_resume) { 1245 if (driver->reset_resume) {
1246 status = driver->reset_resume(intf); 1246 status = driver->reset_resume(intf);
1247 if (status) 1247 if (status)
1248 dev_err(&intf->dev, "%s error %d\n", 1248 dev_err(&intf->dev, "%s error %d\n",
1249 "reset_resume", status); 1249 "reset_resume", status);
1250 } else { 1250 } else {
1251 intf->needs_binding = 1; 1251 intf->needs_binding = 1;
1252 dev_dbg(&intf->dev, "no reset_resume for driver %s?\n", 1252 dev_dbg(&intf->dev, "no reset_resume for driver %s?\n",
1253 driver->name); 1253 driver->name);
1254 } 1254 }
1255 } else { 1255 } else {
1256 status = driver->resume(intf); 1256 status = driver->resume(intf);
1257 if (status) 1257 if (status)
1258 dev_err(&intf->dev, "resume error %d\n", status); 1258 dev_err(&intf->dev, "resume error %d\n", status);
1259 } 1259 }
1260 1260
1261 done: 1261 done:
1262 dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); 1262 dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status);
1263 1263
1264 /* Later we will unbind the driver and/or reprobe, if necessary */ 1264 /* Later we will unbind the driver and/or reprobe, if necessary */
1265 return status; 1265 return status;
1266 } 1266 }
1267 1267
1268 /** 1268 /**
1269 * usb_suspend_both - suspend a USB device and its interfaces 1269 * usb_suspend_both - suspend a USB device and its interfaces
1270 * @udev: the usb_device to suspend 1270 * @udev: the usb_device to suspend
1271 * @msg: Power Management message describing this state transition 1271 * @msg: Power Management message describing this state transition
1272 * 1272 *
1273 * This is the central routine for suspending USB devices. It calls the 1273 * This is the central routine for suspending USB devices. It calls the
1274 * suspend methods for all the interface drivers in @udev and then calls 1274 * suspend methods for all the interface drivers in @udev and then calls
1275 * the suspend method for @udev itself. When the routine is called in 1275 * the suspend method for @udev itself. When the routine is called in
1276 * autosuspend, if an error occurs at any stage, all the interfaces 1276 * autosuspend, if an error occurs at any stage, all the interfaces
1277 * which were suspended are resumed so that they remain in the same 1277 * which were suspended are resumed so that they remain in the same
1278 * state as the device, but when called from system sleep, all error 1278 * state as the device, but when called from system sleep, all error
1279 * from suspend methods of interfaces and the non-root-hub device itself 1279 * from suspend methods of interfaces and the non-root-hub device itself
1280 * are simply ignored, so all suspended interfaces are only resumed 1280 * are simply ignored, so all suspended interfaces are only resumed
1281 * to the device's state when @udev is root-hub and its suspend method 1281 * to the device's state when @udev is root-hub and its suspend method
1282 * returns failure. 1282 * returns failure.
1283 * 1283 *
1284 * Autosuspend requests originating from a child device or an interface 1284 * Autosuspend requests originating from a child device or an interface
1285 * driver may be made without the protection of @udev's device lock, but 1285 * driver may be made without the protection of @udev's device lock, but
1286 * all other suspend calls will hold the lock. Usbcore will insure that 1286 * all other suspend calls will hold the lock. Usbcore will insure that
1287 * method calls do not arrive during bind, unbind, or reset operations. 1287 * method calls do not arrive during bind, unbind, or reset operations.
1288 * However drivers must be prepared to handle suspend calls arriving at 1288 * However drivers must be prepared to handle suspend calls arriving at
1289 * unpredictable times. 1289 * unpredictable times.
1290 * 1290 *
1291 * This routine can run only in process context. 1291 * This routine can run only in process context.
1292 * 1292 *
1293 * Return: 0 if the suspend succeeded. 1293 * Return: 0 if the suspend succeeded.
1294 */ 1294 */
1295 static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) 1295 static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1296 { 1296 {
1297 int status = 0; 1297 int status = 0;
1298 int i = 0, n = 0; 1298 int i = 0, n = 0;
1299 struct usb_interface *intf; 1299 struct usb_interface *intf;
1300 1300
1301 if (udev->state == USB_STATE_NOTATTACHED || 1301 if (udev->state == USB_STATE_NOTATTACHED ||
1302 udev->state == USB_STATE_SUSPENDED) 1302 udev->state == USB_STATE_SUSPENDED)
1303 goto done; 1303 goto done;
1304 1304
1305 /* Suspend all the interfaces and then udev itself */ 1305 /* Suspend all the interfaces and then udev itself */
1306 if (udev->actconfig) { 1306 if (udev->actconfig) {
1307 n = udev->actconfig->desc.bNumInterfaces; 1307 n = udev->actconfig->desc.bNumInterfaces;
1308 for (i = n - 1; i >= 0; --i) { 1308 for (i = n - 1; i >= 0; --i) {
1309 intf = udev->actconfig->interface[i]; 1309 intf = udev->actconfig->interface[i];
1310 status = usb_suspend_interface(udev, intf, msg); 1310 status = usb_suspend_interface(udev, intf, msg);
1311 1311
1312 /* Ignore errors during system sleep transitions */ 1312 /* Ignore errors during system sleep transitions */
1313 if (!PMSG_IS_AUTO(msg)) 1313 if (!PMSG_IS_AUTO(msg))
1314 status = 0; 1314 status = 0;
1315 if (status != 0) 1315 if (status != 0)
1316 break; 1316 break;
1317 } 1317 }
1318 } 1318 }
1319 if (status == 0) { 1319 if (status == 0) {
1320 status = usb_suspend_device(udev, msg); 1320 status = usb_suspend_device(udev, msg);
1321 1321
1322 /* 1322 /*
1323 * Ignore errors from non-root-hub devices during 1323 * Ignore errors from non-root-hub devices during
1324 * system sleep transitions. For the most part, 1324 * system sleep transitions. For the most part,
1325 * these devices should go to low power anyway when 1325 * these devices should go to low power anyway when
1326 * the entire bus is suspended. 1326 * the entire bus is suspended.
1327 */ 1327 */
1328 if (udev->parent && !PMSG_IS_AUTO(msg)) 1328 if (udev->parent && !PMSG_IS_AUTO(msg))
1329 status = 0; 1329 status = 0;
1330 } 1330 }
1331 1331
1332 /* If the suspend failed, resume interfaces that did get suspended */ 1332 /* If the suspend failed, resume interfaces that did get suspended */
1333 if (status != 0) { 1333 if (status != 0) {
1334 if (udev->actconfig) { 1334 if (udev->actconfig) {
1335 msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME); 1335 msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME);
1336 while (++i < n) { 1336 while (++i < n) {
1337 intf = udev->actconfig->interface[i]; 1337 intf = udev->actconfig->interface[i];
1338 usb_resume_interface(udev, intf, msg, 0); 1338 usb_resume_interface(udev, intf, msg, 0);
1339 } 1339 }
1340 } 1340 }
1341 1341
1342 /* If the suspend succeeded then prevent any more URB submissions 1342 /* If the suspend succeeded then prevent any more URB submissions
1343 * and flush any outstanding URBs. 1343 * and flush any outstanding URBs.
1344 */ 1344 */
1345 } else { 1345 } else {
1346 udev->can_submit = 0; 1346 udev->can_submit = 0;
1347 for (i = 0; i < 16; ++i) { 1347 for (i = 0; i < 16; ++i) {
1348 usb_hcd_flush_endpoint(udev, udev->ep_out[i]); 1348 usb_hcd_flush_endpoint(udev, udev->ep_out[i]);
1349 usb_hcd_flush_endpoint(udev, udev->ep_in[i]); 1349 usb_hcd_flush_endpoint(udev, udev->ep_in[i]);
1350 } 1350 }
1351 } 1351 }
1352 1352
1353 done: 1353 done:
1354 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); 1354 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
1355 return status; 1355 return status;
1356 } 1356 }
1357 1357
1358 /** 1358 /**
1359 * usb_resume_both - resume a USB device and its interfaces 1359 * usb_resume_both - resume a USB device and its interfaces
1360 * @udev: the usb_device to resume 1360 * @udev: the usb_device to resume
1361 * @msg: Power Management message describing this state transition 1361 * @msg: Power Management message describing this state transition
1362 * 1362 *
1363 * This is the central routine for resuming USB devices. It calls the 1363 * This is the central routine for resuming USB devices. It calls the
1364 * the resume method for @udev and then calls the resume methods for all 1364 * the resume method for @udev and then calls the resume methods for all
1365 * the interface drivers in @udev. 1365 * the interface drivers in @udev.
1366 * 1366 *
1367 * Autoresume requests originating from a child device or an interface 1367 * Autoresume requests originating from a child device or an interface
1368 * driver may be made without the protection of @udev's device lock, but 1368 * driver may be made without the protection of @udev's device lock, but
1369 * all other resume calls will hold the lock. Usbcore will insure that 1369 * all other resume calls will hold the lock. Usbcore will insure that
1370 * method calls do not arrive during bind, unbind, or reset operations. 1370 * method calls do not arrive during bind, unbind, or reset operations.
1371 * However drivers must be prepared to handle resume calls arriving at 1371 * However drivers must be prepared to handle resume calls arriving at
1372 * unpredictable times. 1372 * unpredictable times.
1373 * 1373 *
1374 * This routine can run only in process context. 1374 * This routine can run only in process context.
1375 * 1375 *
1376 * Return: 0 on success. 1376 * Return: 0 on success.
1377 */ 1377 */
1378 static int usb_resume_both(struct usb_device *udev, pm_message_t msg) 1378 static int usb_resume_both(struct usb_device *udev, pm_message_t msg)
1379 { 1379 {
1380 int status = 0; 1380 int status = 0;
1381 int i; 1381 int i;
1382 struct usb_interface *intf; 1382 struct usb_interface *intf;
1383 1383
1384 if (udev->state == USB_STATE_NOTATTACHED) { 1384 if (udev->state == USB_STATE_NOTATTACHED) {
1385 status = -ENODEV; 1385 status = -ENODEV;
1386 goto done; 1386 goto done;
1387 } 1387 }
1388 udev->can_submit = 1; 1388 udev->can_submit = 1;
1389 1389
1390 /* Resume the device */ 1390 /* Resume the device */
1391 if (udev->state == USB_STATE_SUSPENDED || udev->reset_resume) 1391 if (udev->state == USB_STATE_SUSPENDED || udev->reset_resume)
1392 status = usb_resume_device(udev, msg); 1392 status = usb_resume_device(udev, msg);
1393 1393
1394 /* Resume the interfaces */ 1394 /* Resume the interfaces */
1395 if (status == 0 && udev->actconfig) { 1395 if (status == 0 && udev->actconfig) {
1396 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1396 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1397 intf = udev->actconfig->interface[i]; 1397 intf = udev->actconfig->interface[i];
1398 usb_resume_interface(udev, intf, msg, 1398 usb_resume_interface(udev, intf, msg,
1399 udev->reset_resume); 1399 udev->reset_resume);
1400 } 1400 }
1401 } 1401 }
1402 usb_mark_last_busy(udev); 1402 usb_mark_last_busy(udev);
1403 1403
1404 done: 1404 done:
1405 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); 1405 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
1406 if (!status) 1406 if (!status)
1407 udev->reset_resume = 0; 1407 udev->reset_resume = 0;
1408 return status; 1408 return status;
1409 } 1409 }
1410 1410
1411 static void choose_wakeup(struct usb_device *udev, pm_message_t msg) 1411 static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
1412 { 1412 {
1413 int w; 1413 int w;
1414 1414
1415 /* Remote wakeup is needed only when we actually go to sleep. 1415 /* Remote wakeup is needed only when we actually go to sleep.
1416 * For things like FREEZE and QUIESCE, if the device is already 1416 * For things like FREEZE and QUIESCE, if the device is already
1417 * autosuspended then its current wakeup setting is okay. 1417 * autosuspended then its current wakeup setting is okay.
1418 */ 1418 */
1419 if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_QUIESCE) { 1419 if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_QUIESCE) {
1420 if (udev->state != USB_STATE_SUSPENDED) 1420 if (udev->state != USB_STATE_SUSPENDED)
1421 udev->do_remote_wakeup = 0; 1421 udev->do_remote_wakeup = 0;
1422 return; 1422 return;
1423 } 1423 }
1424 1424
1425 /* Enable remote wakeup if it is allowed, even if no interface drivers 1425 /* Enable remote wakeup if it is allowed, even if no interface drivers
1426 * actually want it. 1426 * actually want it.
1427 */ 1427 */
1428 w = device_may_wakeup(&udev->dev); 1428 w = device_may_wakeup(&udev->dev);
1429 1429
1430 /* If the device is autosuspended with the wrong wakeup setting, 1430 /* If the device is autosuspended with the wrong wakeup setting,
1431 * autoresume now so the setting can be changed. 1431 * autoresume now so the setting can be changed.
1432 */ 1432 */
1433 if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup) 1433 if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup)
1434 pm_runtime_resume(&udev->dev); 1434 pm_runtime_resume(&udev->dev);
1435 udev->do_remote_wakeup = w; 1435 udev->do_remote_wakeup = w;
1436 } 1436 }
1437 1437
1438 /* The device lock is held by the PM core */ 1438 /* The device lock is held by the PM core */
1439 int usb_suspend(struct device *dev, pm_message_t msg) 1439 int usb_suspend(struct device *dev, pm_message_t msg)
1440 { 1440 {
1441 struct usb_device *udev = to_usb_device(dev); 1441 struct usb_device *udev = to_usb_device(dev);
1442 1442
1443 unbind_no_pm_drivers_interfaces(udev); 1443 unbind_no_pm_drivers_interfaces(udev);
1444 1444
1445 /* From now on we are sure all drivers support suspend/resume 1445 /* From now on we are sure all drivers support suspend/resume
1446 * but not necessarily reset_resume() 1446 * but not necessarily reset_resume()
1447 * so we may still need to unbind and rebind upon resume 1447 * so we may still need to unbind and rebind upon resume
1448 */ 1448 */
1449 choose_wakeup(udev, msg); 1449 choose_wakeup(udev, msg);
1450 return usb_suspend_both(udev, msg); 1450 return usb_suspend_both(udev, msg);
1451 } 1451 }
1452 1452
1453 /* The device lock is held by the PM core */ 1453 /* The device lock is held by the PM core */
1454 int usb_resume_complete(struct device *dev) 1454 int usb_resume_complete(struct device *dev)
1455 { 1455 {
1456 struct usb_device *udev = to_usb_device(dev); 1456 struct usb_device *udev = to_usb_device(dev);
1457 1457
1458 /* For PM complete calls, all we do is rebind interfaces 1458 /* For PM complete calls, all we do is rebind interfaces
1459 * whose needs_binding flag is set 1459 * whose needs_binding flag is set
1460 */ 1460 */
1461 if (udev->state != USB_STATE_NOTATTACHED) 1461 if (udev->state != USB_STATE_NOTATTACHED)
1462 rebind_marked_interfaces(udev); 1462 rebind_marked_interfaces(udev);
1463 return 0; 1463 return 0;
1464 } 1464 }
1465 1465
1466 /* The device lock is held by the PM core */ 1466 /* The device lock is held by the PM core */
1467 int usb_resume(struct device *dev, pm_message_t msg) 1467 int usb_resume(struct device *dev, pm_message_t msg)
1468 { 1468 {
1469 struct usb_device *udev = to_usb_device(dev); 1469 struct usb_device *udev = to_usb_device(dev);
1470 int status; 1470 int status;
1471 1471
1472 /* For all calls, take the device back to full power and 1472 /* For all calls, take the device back to full power and
1473 * tell the PM core in case it was autosuspended previously. 1473 * tell the PM core in case it was autosuspended previously.
1474 * Unbind the interfaces that will need rebinding later, 1474 * Unbind the interfaces that will need rebinding later,
1475 * because they fail to support reset_resume. 1475 * because they fail to support reset_resume.
1476 * (This can't be done in usb_resume_interface() 1476 * (This can't be done in usb_resume_interface()
1477 * above because it doesn't own the right set of locks.) 1477 * above because it doesn't own the right set of locks.)
1478 */ 1478 */
1479 status = usb_resume_both(udev, msg); 1479 status = usb_resume_both(udev, msg);
1480 if (status == 0) { 1480 if (status == 0) {
1481 pm_runtime_disable(dev); 1481 pm_runtime_disable(dev);
1482 pm_runtime_set_active(dev); 1482 pm_runtime_set_active(dev);
1483 pm_runtime_enable(dev); 1483 pm_runtime_enable(dev);
1484 unbind_marked_interfaces(udev); 1484 unbind_marked_interfaces(udev);
1485 } 1485 }
1486 1486
1487 /* Avoid PM error messages for devices disconnected while suspended 1487 /* Avoid PM error messages for devices disconnected while suspended
1488 * as we'll display regular disconnect messages just a bit later. 1488 * as we'll display regular disconnect messages just a bit later.
1489 */ 1489 */
1490 if (status == -ENODEV || status == -ESHUTDOWN) 1490 if (status == -ENODEV || status == -ESHUTDOWN)
1491 status = 0; 1491 status = 0;
1492 return status; 1492 return status;
1493 } 1493 }
1494 1494
1495 #endif /* CONFIG_PM */ 1495 #endif /* CONFIG_PM */
1496 1496
1497 #ifdef CONFIG_PM_RUNTIME 1497 #ifdef CONFIG_PM_RUNTIME
1498 1498
1499 /** 1499 /**
1500 * usb_enable_autosuspend - allow a USB device to be autosuspended 1500 * usb_enable_autosuspend - allow a USB device to be autosuspended
1501 * @udev: the USB device which may be autosuspended 1501 * @udev: the USB device which may be autosuspended
1502 * 1502 *
1503 * This routine allows @udev to be autosuspended. An autosuspend won't 1503 * This routine allows @udev to be autosuspended. An autosuspend won't
1504 * take place until the autosuspend_delay has elapsed and all the other 1504 * take place until the autosuspend_delay has elapsed and all the other
1505 * necessary conditions are satisfied. 1505 * necessary conditions are satisfied.
1506 * 1506 *
1507 * The caller must hold @udev's device lock. 1507 * The caller must hold @udev's device lock.
1508 */ 1508 */
1509 void usb_enable_autosuspend(struct usb_device *udev) 1509 void usb_enable_autosuspend(struct usb_device *udev)
1510 { 1510 {
1511 pm_runtime_allow(&udev->dev); 1511 pm_runtime_allow(&udev->dev);
1512 } 1512 }
1513 EXPORT_SYMBOL_GPL(usb_enable_autosuspend); 1513 EXPORT_SYMBOL_GPL(usb_enable_autosuspend);
1514 1514
1515 /** 1515 /**
1516 * usb_disable_autosuspend - prevent a USB device from being autosuspended 1516 * usb_disable_autosuspend - prevent a USB device from being autosuspended
1517 * @udev: the USB device which may not be autosuspended 1517 * @udev: the USB device which may not be autosuspended
1518 * 1518 *
1519 * This routine prevents @udev from being autosuspended and wakes it up 1519 * This routine prevents @udev from being autosuspended and wakes it up
1520 * if it is already autosuspended. 1520 * if it is already autosuspended.
1521 * 1521 *
1522 * The caller must hold @udev's device lock. 1522 * The caller must hold @udev's device lock.
1523 */ 1523 */
1524 void usb_disable_autosuspend(struct usb_device *udev) 1524 void usb_disable_autosuspend(struct usb_device *udev)
1525 { 1525 {
1526 pm_runtime_forbid(&udev->dev); 1526 pm_runtime_forbid(&udev->dev);
1527 } 1527 }
1528 EXPORT_SYMBOL_GPL(usb_disable_autosuspend); 1528 EXPORT_SYMBOL_GPL(usb_disable_autosuspend);
1529 1529
1530 /** 1530 /**
1531 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces 1531 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces
1532 * @udev: the usb_device to autosuspend 1532 * @udev: the usb_device to autosuspend
1533 * 1533 *
1534 * This routine should be called when a core subsystem is finished using 1534 * This routine should be called when a core subsystem is finished using
1535 * @udev and wants to allow it to autosuspend. Examples would be when 1535 * @udev and wants to allow it to autosuspend. Examples would be when
1536 * @udev's device file in usbfs is closed or after a configuration change. 1536 * @udev's device file in usbfs is closed or after a configuration change.
1537 * 1537 *
1538 * @udev's usage counter is decremented; if it drops to 0 and all the 1538 * @udev's usage counter is decremented; if it drops to 0 and all the
1539 * interfaces are inactive then a delayed autosuspend will be attempted. 1539 * interfaces are inactive then a delayed autosuspend will be attempted.
1540 * The attempt may fail (see autosuspend_check()). 1540 * The attempt may fail (see autosuspend_check()).
1541 * 1541 *
1542 * The caller must hold @udev's device lock. 1542 * The caller must hold @udev's device lock.
1543 * 1543 *
1544 * This routine can run only in process context. 1544 * This routine can run only in process context.
1545 */ 1545 */
1546 void usb_autosuspend_device(struct usb_device *udev) 1546 void usb_autosuspend_device(struct usb_device *udev)
1547 { 1547 {
1548 int status; 1548 int status;
1549 1549
1550 usb_mark_last_busy(udev); 1550 usb_mark_last_busy(udev);
1551 status = pm_runtime_put_sync_autosuspend(&udev->dev); 1551 status = pm_runtime_put_sync_autosuspend(&udev->dev);
1552 dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", 1552 dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n",
1553 __func__, atomic_read(&udev->dev.power.usage_count), 1553 __func__, atomic_read(&udev->dev.power.usage_count),
1554 status); 1554 status);
1555 } 1555 }
1556 1556
1557 /** 1557 /**
1558 * usb_autoresume_device - immediately autoresume a USB device and its interfaces 1558 * usb_autoresume_device - immediately autoresume a USB device and its interfaces
1559 * @udev: the usb_device to autoresume 1559 * @udev: the usb_device to autoresume
1560 * 1560 *
1561 * This routine should be called when a core subsystem wants to use @udev 1561 * This routine should be called when a core subsystem wants to use @udev
1562 * and needs to guarantee that it is not suspended. No autosuspend will 1562 * and needs to guarantee that it is not suspended. No autosuspend will
1563 * occur until usb_autosuspend_device() is called. (Note that this will 1563 * occur until usb_autosuspend_device() is called. (Note that this will
1564 * not prevent suspend events originating in the PM core.) Examples would 1564 * not prevent suspend events originating in the PM core.) Examples would
1565 * be when @udev's device file in usbfs is opened or when a remote-wakeup 1565 * be when @udev's device file in usbfs is opened or when a remote-wakeup
1566 * request is received. 1566 * request is received.
1567 * 1567 *
1568 * @udev's usage counter is incremented to prevent subsequent autosuspends. 1568 * @udev's usage counter is incremented to prevent subsequent autosuspends.
1569 * However if the autoresume fails then the usage counter is re-decremented. 1569 * However if the autoresume fails then the usage counter is re-decremented.
1570 * 1570 *
1571 * The caller must hold @udev's device lock. 1571 * The caller must hold @udev's device lock.
1572 * 1572 *
1573 * This routine can run only in process context. 1573 * This routine can run only in process context.
1574 * 1574 *
1575 * Return: 0 on success. A negative error code otherwise. 1575 * Return: 0 on success. A negative error code otherwise.
1576 */ 1576 */
1577 int usb_autoresume_device(struct usb_device *udev) 1577 int usb_autoresume_device(struct usb_device *udev)
1578 { 1578 {
1579 int status; 1579 int status;
1580 1580
1581 status = pm_runtime_get_sync(&udev->dev); 1581 status = pm_runtime_get_sync(&udev->dev);
1582 if (status < 0) 1582 if (status < 0)
1583 pm_runtime_put_sync(&udev->dev); 1583 pm_runtime_put_sync(&udev->dev);
1584 dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", 1584 dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n",
1585 __func__, atomic_read(&udev->dev.power.usage_count), 1585 __func__, atomic_read(&udev->dev.power.usage_count),
1586 status); 1586 status);
1587 if (status > 0) 1587 if (status > 0)
1588 status = 0; 1588 status = 0;
1589 return status; 1589 return status;
1590 } 1590 }
1591 1591
1592 /** 1592 /**
1593 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter 1593 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter
1594 * @intf: the usb_interface whose counter should be decremented 1594 * @intf: the usb_interface whose counter should be decremented
1595 * 1595 *
1596 * This routine should be called by an interface driver when it is 1596 * This routine should be called by an interface driver when it is
1597 * finished using @intf and wants to allow it to autosuspend. A typical 1597 * finished using @intf and wants to allow it to autosuspend. A typical
1598 * example would be a character-device driver when its device file is 1598 * example would be a character-device driver when its device file is
1599 * closed. 1599 * closed.
1600 * 1600 *
1601 * The routine decrements @intf's usage counter. When the counter reaches 1601 * The routine decrements @intf's usage counter. When the counter reaches
1602 * 0, a delayed autosuspend request for @intf's device is attempted. The 1602 * 0, a delayed autosuspend request for @intf's device is attempted. The
1603 * attempt may fail (see autosuspend_check()). 1603 * attempt may fail (see autosuspend_check()).
1604 * 1604 *
1605 * This routine can run only in process context. 1605 * This routine can run only in process context.
1606 */ 1606 */
1607 void usb_autopm_put_interface(struct usb_interface *intf) 1607 void usb_autopm_put_interface(struct usb_interface *intf)
1608 { 1608 {
1609 struct usb_device *udev = interface_to_usbdev(intf); 1609 struct usb_device *udev = interface_to_usbdev(intf);
1610 int status; 1610 int status;
1611 1611
1612 usb_mark_last_busy(udev); 1612 usb_mark_last_busy(udev);
1613 atomic_dec(&intf->pm_usage_cnt); 1613 atomic_dec(&intf->pm_usage_cnt);
1614 status = pm_runtime_put_sync(&intf->dev); 1614 status = pm_runtime_put_sync(&intf->dev);
1615 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", 1615 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
1616 __func__, atomic_read(&intf->dev.power.usage_count), 1616 __func__, atomic_read(&intf->dev.power.usage_count),
1617 status); 1617 status);
1618 } 1618 }
1619 EXPORT_SYMBOL_GPL(usb_autopm_put_interface); 1619 EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1620 1620
1621 /** 1621 /**
1622 * usb_autopm_put_interface_async - decrement a USB interface's PM-usage counter 1622 * usb_autopm_put_interface_async - decrement a USB interface's PM-usage counter
1623 * @intf: the usb_interface whose counter should be decremented 1623 * @intf: the usb_interface whose counter should be decremented
1624 * 1624 *
1625 * This routine does much the same thing as usb_autopm_put_interface(): 1625 * This routine does much the same thing as usb_autopm_put_interface():
1626 * It decrements @intf's usage counter and schedules a delayed 1626 * It decrements @intf's usage counter and schedules a delayed
1627 * autosuspend request if the counter is <= 0. The difference is that it 1627 * autosuspend request if the counter is <= 0. The difference is that it
1628 * does not perform any synchronization; callers should hold a private 1628 * does not perform any synchronization; callers should hold a private
1629 * lock and handle all synchronization issues themselves. 1629 * lock and handle all synchronization issues themselves.
1630 * 1630 *
1631 * Typically a driver would call this routine during an URB's completion 1631 * Typically a driver would call this routine during an URB's completion
1632 * handler, if no more URBs were pending. 1632 * handler, if no more URBs were pending.
1633 * 1633 *
1634 * This routine can run in atomic context. 1634 * This routine can run in atomic context.
1635 */ 1635 */
1636 void usb_autopm_put_interface_async(struct usb_interface *intf) 1636 void usb_autopm_put_interface_async(struct usb_interface *intf)
1637 { 1637 {
1638 struct usb_device *udev = interface_to_usbdev(intf); 1638 struct usb_device *udev = interface_to_usbdev(intf);
1639 int status; 1639 int status;
1640 1640
1641 usb_mark_last_busy(udev); 1641 usb_mark_last_busy(udev);
1642 atomic_dec(&intf->pm_usage_cnt); 1642 atomic_dec(&intf->pm_usage_cnt);
1643 status = pm_runtime_put(&intf->dev); 1643 status = pm_runtime_put(&intf->dev);
1644 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", 1644 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
1645 __func__, atomic_read(&intf->dev.power.usage_count), 1645 __func__, atomic_read(&intf->dev.power.usage_count),
1646 status); 1646 status);
1647 } 1647 }
1648 EXPORT_SYMBOL_GPL(usb_autopm_put_interface_async); 1648 EXPORT_SYMBOL_GPL(usb_autopm_put_interface_async);
1649 1649
1650 /** 1650 /**
1651 * usb_autopm_put_interface_no_suspend - decrement a USB interface's PM-usage counter 1651 * usb_autopm_put_interface_no_suspend - decrement a USB interface's PM-usage counter
1652 * @intf: the usb_interface whose counter should be decremented 1652 * @intf: the usb_interface whose counter should be decremented
1653 * 1653 *
1654 * This routine decrements @intf's usage counter but does not carry out an 1654 * This routine decrements @intf's usage counter but does not carry out an
1655 * autosuspend. 1655 * autosuspend.
1656 * 1656 *
1657 * This routine can run in atomic context. 1657 * This routine can run in atomic context.
1658 */ 1658 */
1659 void usb_autopm_put_interface_no_suspend(struct usb_interface *intf) 1659 void usb_autopm_put_interface_no_suspend(struct usb_interface *intf)
1660 { 1660 {
1661 struct usb_device *udev = interface_to_usbdev(intf); 1661 struct usb_device *udev = interface_to_usbdev(intf);
1662 1662
1663 usb_mark_last_busy(udev); 1663 usb_mark_last_busy(udev);
1664 atomic_dec(&intf->pm_usage_cnt); 1664 atomic_dec(&intf->pm_usage_cnt);
1665 pm_runtime_put_noidle(&intf->dev); 1665 pm_runtime_put_noidle(&intf->dev);
1666 } 1666 }
1667 EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend); 1667 EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend);
1668 1668
1669 /** 1669 /**
1670 * usb_autopm_get_interface - increment a USB interface's PM-usage counter 1670 * usb_autopm_get_interface - increment a USB interface's PM-usage counter
1671 * @intf: the usb_interface whose counter should be incremented 1671 * @intf: the usb_interface whose counter should be incremented
1672 * 1672 *
1673 * This routine should be called by an interface driver when it wants to 1673 * This routine should be called by an interface driver when it wants to
1674 * use @intf and needs to guarantee that it is not suspended. In addition, 1674 * use @intf and needs to guarantee that it is not suspended. In addition,
1675 * the routine prevents @intf from being autosuspended subsequently. (Note 1675 * the routine prevents @intf from being autosuspended subsequently. (Note
1676 * that this will not prevent suspend events originating in the PM core.) 1676 * that this will not prevent suspend events originating in the PM core.)
1677 * This prevention will persist until usb_autopm_put_interface() is called 1677 * This prevention will persist until usb_autopm_put_interface() is called
1678 * or @intf is unbound. A typical example would be a character-device 1678 * or @intf is unbound. A typical example would be a character-device
1679 * driver when its device file is opened. 1679 * driver when its device file is opened.
1680 * 1680 *
1681 * @intf's usage counter is incremented to prevent subsequent autosuspends. 1681 * @intf's usage counter is incremented to prevent subsequent autosuspends.
1682 * However if the autoresume fails then the counter is re-decremented. 1682 * However if the autoresume fails then the counter is re-decremented.
1683 * 1683 *
1684 * This routine can run only in process context. 1684 * This routine can run only in process context.
1685 * 1685 *
1686 * Return: 0 on success. 1686 * Return: 0 on success.
1687 */ 1687 */
1688 int usb_autopm_get_interface(struct usb_interface *intf) 1688 int usb_autopm_get_interface(struct usb_interface *intf)
1689 { 1689 {
1690 int status; 1690 int status;
1691 1691
1692 status = pm_runtime_get_sync(&intf->dev); 1692 status = pm_runtime_get_sync(&intf->dev);
1693 if (status < 0) 1693 if (status < 0)
1694 pm_runtime_put_sync(&intf->dev); 1694 pm_runtime_put_sync(&intf->dev);
1695 else 1695 else
1696 atomic_inc(&intf->pm_usage_cnt); 1696 atomic_inc(&intf->pm_usage_cnt);
1697 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", 1697 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
1698 __func__, atomic_read(&intf->dev.power.usage_count), 1698 __func__, atomic_read(&intf->dev.power.usage_count),
1699 status); 1699 status);
1700 if (status > 0) 1700 if (status > 0)
1701 status = 0; 1701 status = 0;
1702 return status; 1702 return status;
1703 } 1703 }
1704 EXPORT_SYMBOL_GPL(usb_autopm_get_interface); 1704 EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
1705 1705
1706 /** 1706 /**
1707 * usb_autopm_get_interface_async - increment a USB interface's PM-usage counter 1707 * usb_autopm_get_interface_async - increment a USB interface's PM-usage counter
1708 * @intf: the usb_interface whose counter should be incremented 1708 * @intf: the usb_interface whose counter should be incremented
1709 * 1709 *
1710 * This routine does much the same thing as 1710 * This routine does much the same thing as
1711 * usb_autopm_get_interface(): It increments @intf's usage counter and 1711 * usb_autopm_get_interface(): It increments @intf's usage counter and
1712 * queues an autoresume request if the device is suspended. The 1712 * queues an autoresume request if the device is suspended. The
1713 * differences are that it does not perform any synchronization (callers 1713 * differences are that it does not perform any synchronization (callers
1714 * should hold a private lock and handle all synchronization issues 1714 * should hold a private lock and handle all synchronization issues
1715 * themselves), and it does not autoresume the device directly (it only 1715 * themselves), and it does not autoresume the device directly (it only
1716 * queues a request). After a successful call, the device may not yet be 1716 * queues a request). After a successful call, the device may not yet be
1717 * resumed. 1717 * resumed.
1718 * 1718 *
1719 * This routine can run in atomic context. 1719 * This routine can run in atomic context.
1720 * 1720 *
1721 * Return: 0 on success. A negative error code otherwise. 1721 * Return: 0 on success. A negative error code otherwise.
1722 */ 1722 */
1723 int usb_autopm_get_interface_async(struct usb_interface *intf) 1723 int usb_autopm_get_interface_async(struct usb_interface *intf)
1724 { 1724 {
1725 int status; 1725 int status;
1726 1726
1727 status = pm_runtime_get(&intf->dev); 1727 status = pm_runtime_get(&intf->dev);
1728 if (status < 0 && status != -EINPROGRESS) 1728 if (status < 0 && status != -EINPROGRESS)
1729 pm_runtime_put_noidle(&intf->dev); 1729 pm_runtime_put_noidle(&intf->dev);
1730 else 1730 else
1731 atomic_inc(&intf->pm_usage_cnt); 1731 atomic_inc(&intf->pm_usage_cnt);
1732 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", 1732 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
1733 __func__, atomic_read(&intf->dev.power.usage_count), 1733 __func__, atomic_read(&intf->dev.power.usage_count),
1734 status); 1734 status);
1735 if (status > 0 || status == -EINPROGRESS) 1735 if (status > 0 || status == -EINPROGRESS)
1736 status = 0; 1736 status = 0;
1737 return status; 1737 return status;
1738 } 1738 }
1739 EXPORT_SYMBOL_GPL(usb_autopm_get_interface_async); 1739 EXPORT_SYMBOL_GPL(usb_autopm_get_interface_async);
1740 1740
1741 /** 1741 /**
1742 * usb_autopm_get_interface_no_resume - increment a USB interface's PM-usage counter 1742 * usb_autopm_get_interface_no_resume - increment a USB interface's PM-usage counter
1743 * @intf: the usb_interface whose counter should be incremented 1743 * @intf: the usb_interface whose counter should be incremented
1744 * 1744 *
1745 * This routine increments @intf's usage counter but does not carry out an 1745 * This routine increments @intf's usage counter but does not carry out an
1746 * autoresume. 1746 * autoresume.
1747 * 1747 *
1748 * This routine can run in atomic context. 1748 * This routine can run in atomic context.
1749 */ 1749 */
1750 void usb_autopm_get_interface_no_resume(struct usb_interface *intf) 1750 void usb_autopm_get_interface_no_resume(struct usb_interface *intf)
1751 { 1751 {
1752 struct usb_device *udev = interface_to_usbdev(intf); 1752 struct usb_device *udev = interface_to_usbdev(intf);
1753 1753
1754 usb_mark_last_busy(udev); 1754 usb_mark_last_busy(udev);
1755 atomic_inc(&intf->pm_usage_cnt); 1755 atomic_inc(&intf->pm_usage_cnt);
1756 pm_runtime_get_noresume(&intf->dev); 1756 pm_runtime_get_noresume(&intf->dev);
1757 } 1757 }
1758 EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume); 1758 EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume);
1759 1759
1760 /* Internal routine to check whether we may autosuspend a device. */ 1760 /* Internal routine to check whether we may autosuspend a device. */
1761 static int autosuspend_check(struct usb_device *udev) 1761 static int autosuspend_check(struct usb_device *udev)
1762 { 1762 {
1763 int w, i; 1763 int w, i;
1764 struct usb_interface *intf; 1764 struct usb_interface *intf;
1765 1765
1766 /* Fail if autosuspend is disabled, or any interfaces are in use, or 1766 /* Fail if autosuspend is disabled, or any interfaces are in use, or
1767 * any interface drivers require remote wakeup but it isn't available. 1767 * any interface drivers require remote wakeup but it isn't available.
1768 */ 1768 */
1769 w = 0; 1769 w = 0;
1770 if (udev->actconfig) { 1770 if (udev->actconfig) {
1771 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1771 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1772 intf = udev->actconfig->interface[i]; 1772 intf = udev->actconfig->interface[i];
1773 1773
1774 /* We don't need to check interfaces that are 1774 /* We don't need to check interfaces that are
1775 * disabled for runtime PM. Either they are unbound 1775 * disabled for runtime PM. Either they are unbound
1776 * or else their drivers don't support autosuspend 1776 * or else their drivers don't support autosuspend
1777 * and so they are permanently active. 1777 * and so they are permanently active.
1778 */ 1778 */
1779 if (intf->dev.power.disable_depth) 1779 if (intf->dev.power.disable_depth)
1780 continue; 1780 continue;
1781 if (atomic_read(&intf->dev.power.usage_count) > 0) 1781 if (atomic_read(&intf->dev.power.usage_count) > 0)
1782 return -EBUSY; 1782 return -EBUSY;
1783 w |= intf->needs_remote_wakeup; 1783 w |= intf->needs_remote_wakeup;
1784 1784
1785 /* Don't allow autosuspend if the device will need 1785 /* Don't allow autosuspend if the device will need
1786 * a reset-resume and any of its interface drivers 1786 * a reset-resume and any of its interface drivers
1787 * doesn't include support or needs remote wakeup. 1787 * doesn't include support or needs remote wakeup.
1788 */ 1788 */
1789 if (udev->quirks & USB_QUIRK_RESET_RESUME) { 1789 if (udev->quirks & USB_QUIRK_RESET_RESUME) {
1790 struct usb_driver *driver; 1790 struct usb_driver *driver;
1791 1791
1792 driver = to_usb_driver(intf->dev.driver); 1792 driver = to_usb_driver(intf->dev.driver);
1793 if (!driver->reset_resume || 1793 if (!driver->reset_resume ||
1794 intf->needs_remote_wakeup) 1794 intf->needs_remote_wakeup)
1795 return -EOPNOTSUPP; 1795 return -EOPNOTSUPP;
1796 } 1796 }
1797 } 1797 }
1798 } 1798 }
1799 if (w && !device_can_wakeup(&udev->dev)) { 1799 if (w && !device_can_wakeup(&udev->dev)) {
1800 dev_dbg(&udev->dev, "remote wakeup needed for autosuspend\n"); 1800 dev_dbg(&udev->dev, "remote wakeup needed for autosuspend\n");
1801 return -EOPNOTSUPP; 1801 return -EOPNOTSUPP;
1802 } 1802 }
1803 udev->do_remote_wakeup = w; 1803 udev->do_remote_wakeup = w;
1804 return 0; 1804 return 0;
1805 } 1805 }
1806 1806
1807 int usb_runtime_suspend(struct device *dev) 1807 int usb_runtime_suspend(struct device *dev)
1808 { 1808 {
1809 struct usb_device *udev = to_usb_device(dev); 1809 struct usb_device *udev = to_usb_device(dev);
1810 int status; 1810 int status;
1811 1811
1812 /* A USB device can be suspended if it passes the various autosuspend 1812 /* A USB device can be suspended if it passes the various autosuspend
1813 * checks. Runtime suspend for a USB device means suspending all the 1813 * checks. Runtime suspend for a USB device means suspending all the
1814 * interfaces and then the device itself. 1814 * interfaces and then the device itself.
1815 */ 1815 */
1816 if (autosuspend_check(udev) != 0) 1816 if (autosuspend_check(udev) != 0)
1817 return -EAGAIN; 1817 return -EAGAIN;
1818 1818
1819 status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND); 1819 status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND);
1820 1820
1821 /* Allow a retry if autosuspend failed temporarily */ 1821 /* Allow a retry if autosuspend failed temporarily */
1822 if (status == -EAGAIN || status == -EBUSY) 1822 if (status == -EAGAIN || status == -EBUSY)
1823 usb_mark_last_busy(udev); 1823 usb_mark_last_busy(udev);
1824 1824
1825 /* The PM core reacts badly unless the return code is 0, 1825 /*
1826 * -EAGAIN, or -EBUSY, so always return -EBUSY on an error. 1826 * The PM core reacts badly unless the return code is 0,
1827 * -EAGAIN, or -EBUSY, so always return -EBUSY on an error
1828 * (except for root hubs, because they don't suspend through
1829 * an upstream port like other USB devices).
1827 */ 1830 */
1828 if (status != 0) 1831 if (status != 0 && udev->parent)
1829 return -EBUSY; 1832 return -EBUSY;
1830 return status; 1833 return status;
1831 } 1834 }
1832 1835
1833 int usb_runtime_resume(struct device *dev) 1836 int usb_runtime_resume(struct device *dev)
1834 { 1837 {
1835 struct usb_device *udev = to_usb_device(dev); 1838 struct usb_device *udev = to_usb_device(dev);
1836 int status; 1839 int status;
1837 1840
1838 /* Runtime resume for a USB device means resuming both the device 1841 /* Runtime resume for a USB device means resuming both the device
1839 * and all its interfaces. 1842 * and all its interfaces.
1840 */ 1843 */
1841 status = usb_resume_both(udev, PMSG_AUTO_RESUME); 1844 status = usb_resume_both(udev, PMSG_AUTO_RESUME);
1842 return status; 1845 return status;
1843 } 1846 }
1844 1847
1845 int usb_runtime_idle(struct device *dev) 1848 int usb_runtime_idle(struct device *dev)
1846 { 1849 {
1847 struct usb_device *udev = to_usb_device(dev); 1850 struct usb_device *udev = to_usb_device(dev);
1848 1851
1849 /* An idle USB device can be suspended if it passes the various 1852 /* An idle USB device can be suspended if it passes the various
1850 * autosuspend checks. 1853 * autosuspend checks.
1851 */ 1854 */
1852 if (autosuspend_check(udev) == 0) 1855 if (autosuspend_check(udev) == 0)
1853 pm_runtime_autosuspend(dev); 1856 pm_runtime_autosuspend(dev);
1854 /* Tell the core not to suspend it, though. */ 1857 /* Tell the core not to suspend it, though. */
1855 return -EBUSY; 1858 return -EBUSY;
1856 } 1859 }
1857 1860
1858 int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) 1861 int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
1859 { 1862 {
1860 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 1863 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
1861 int ret = -EPERM; 1864 int ret = -EPERM;
1862 1865
1863 if (enable && !udev->usb2_hw_lpm_allowed) 1866 if (enable && !udev->usb2_hw_lpm_allowed)
1864 return 0; 1867 return 0;
1865 1868
1866 if (hcd->driver->set_usb2_hw_lpm) { 1869 if (hcd->driver->set_usb2_hw_lpm) {
1867 ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable); 1870 ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable);
1868 if (!ret) 1871 if (!ret)
1869 udev->usb2_hw_lpm_enabled = enable; 1872 udev->usb2_hw_lpm_enabled = enable;
1870 } 1873 }
1871 1874
1872 return ret; 1875 return ret;
1873 } 1876 }
1874 1877
1875 #endif /* CONFIG_PM_RUNTIME */ 1878 #endif /* CONFIG_PM_RUNTIME */
1876 1879
1877 struct bus_type usb_bus_type = { 1880 struct bus_type usb_bus_type = {
1878 .name = "usb", 1881 .name = "usb",
1879 .match = usb_device_match, 1882 .match = usb_device_match,
1880 .uevent = usb_uevent, 1883 .uevent = usb_uevent,
1881 }; 1884 };
1882 1885
drivers/usb/core/hub.c
1 /* 1 /*
2 * USB hub driver. 2 * USB hub driver.
3 * 3 *
4 * (C) Copyright 1999 Linus Torvalds 4 * (C) Copyright 1999 Linus Torvalds
5 * (C) Copyright 1999 Johannes Erdfelt 5 * (C) Copyright 1999 Johannes Erdfelt
6 * (C) Copyright 1999 Gregory P. Smith 6 * (C) Copyright 1999 Gregory P. Smith
7 * (C) Copyright 2001 Brad Hards (bhards@bigpond.net.au) 7 * (C) Copyright 2001 Brad Hards (bhards@bigpond.net.au)
8 * 8 *
9 */ 9 */
10 10
11 #include <linux/kernel.h> 11 #include <linux/kernel.h>
12 #include <linux/errno.h> 12 #include <linux/errno.h>
13 #include <linux/module.h> 13 #include <linux/module.h>
14 #include <linux/moduleparam.h> 14 #include <linux/moduleparam.h>
15 #include <linux/completion.h> 15 #include <linux/completion.h>
16 #include <linux/sched.h> 16 #include <linux/sched.h>
17 #include <linux/list.h> 17 #include <linux/list.h>
18 #include <linux/slab.h> 18 #include <linux/slab.h>
19 #include <linux/ioctl.h> 19 #include <linux/ioctl.h>
20 #include <linux/usb.h> 20 #include <linux/usb.h>
21 #include <linux/usbdevice_fs.h> 21 #include <linux/usbdevice_fs.h>
22 #include <linux/usb/hcd.h> 22 #include <linux/usb/hcd.h>
23 #include <linux/usb/otg.h> 23 #include <linux/usb/otg.h>
24 #include <linux/usb/quirks.h> 24 #include <linux/usb/quirks.h>
25 #include <linux/kthread.h> 25 #include <linux/kthread.h>
26 #include <linux/mutex.h> 26 #include <linux/mutex.h>
27 #include <linux/freezer.h> 27 #include <linux/freezer.h>
28 #include <linux/random.h> 28 #include <linux/random.h>
29 #include <linux/pm_qos.h> 29 #include <linux/pm_qos.h>
30 30
31 #include <asm/uaccess.h> 31 #include <asm/uaccess.h>
32 #include <asm/byteorder.h> 32 #include <asm/byteorder.h>
33 33
34 #include "hub.h" 34 #include "hub.h"
35 35
36 #define USB_VENDOR_GENESYS_LOGIC 0x05e3 36 #define USB_VENDOR_GENESYS_LOGIC 0x05e3
37 #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01 37 #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01
38 38
39 static inline int hub_is_superspeed(struct usb_device *hdev) 39 static inline int hub_is_superspeed(struct usb_device *hdev)
40 { 40 {
41 return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS); 41 return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS);
42 } 42 }
43 43
44 /* Protect struct usb_device->state and ->children members 44 /* Protect struct usb_device->state and ->children members
45 * Note: Both are also protected by ->dev.sem, except that ->state can 45 * Note: Both are also protected by ->dev.sem, except that ->state can
46 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ 46 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
47 static DEFINE_SPINLOCK(device_state_lock); 47 static DEFINE_SPINLOCK(device_state_lock);
48 48
49 /* khubd's worklist and its lock */ 49 /* khubd's worklist and its lock */
50 static DEFINE_SPINLOCK(hub_event_lock); 50 static DEFINE_SPINLOCK(hub_event_lock);
51 static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */ 51 static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */
52 52
53 /* Wakes up khubd */ 53 /* Wakes up khubd */
54 static DECLARE_WAIT_QUEUE_HEAD(khubd_wait); 54 static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
55 55
56 static struct task_struct *khubd_task; 56 static struct task_struct *khubd_task;
57 57
58 /* cycle leds on hubs that aren't blinking for attention */ 58 /* cycle leds on hubs that aren't blinking for attention */
59 static bool blinkenlights = 0; 59 static bool blinkenlights = 0;
60 module_param (blinkenlights, bool, S_IRUGO); 60 module_param (blinkenlights, bool, S_IRUGO);
61 MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); 61 MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs");
62 62
63 /* 63 /*
64 * Device SATA8000 FW1.0 from DATAST0R Technology Corp requires about 64 * Device SATA8000 FW1.0 from DATAST0R Technology Corp requires about
65 * 10 seconds to send reply for the initial 64-byte descriptor request. 65 * 10 seconds to send reply for the initial 64-byte descriptor request.
66 */ 66 */
67 /* define initial 64-byte descriptor request timeout in milliseconds */ 67 /* define initial 64-byte descriptor request timeout in milliseconds */
68 static int initial_descriptor_timeout = USB_CTRL_GET_TIMEOUT; 68 static int initial_descriptor_timeout = USB_CTRL_GET_TIMEOUT;
69 module_param(initial_descriptor_timeout, int, S_IRUGO|S_IWUSR); 69 module_param(initial_descriptor_timeout, int, S_IRUGO|S_IWUSR);
70 MODULE_PARM_DESC(initial_descriptor_timeout, 70 MODULE_PARM_DESC(initial_descriptor_timeout,
71 "initial 64-byte descriptor request timeout in milliseconds " 71 "initial 64-byte descriptor request timeout in milliseconds "
72 "(default 5000 - 5.0 seconds)"); 72 "(default 5000 - 5.0 seconds)");
73 73
74 /* 74 /*
75 * As of 2.6.10 we introduce a new USB device initialization scheme which 75 * As of 2.6.10 we introduce a new USB device initialization scheme which
76 * closely resembles the way Windows works. Hopefully it will be compatible 76 * closely resembles the way Windows works. Hopefully it will be compatible
77 * with a wider range of devices than the old scheme. However some previously 77 * with a wider range of devices than the old scheme. However some previously
78 * working devices may start giving rise to "device not accepting address" 78 * working devices may start giving rise to "device not accepting address"
79 * errors; if that happens the user can try the old scheme by adjusting the 79 * errors; if that happens the user can try the old scheme by adjusting the
80 * following module parameters. 80 * following module parameters.
81 * 81 *
82 * For maximum flexibility there are two boolean parameters to control the 82 * For maximum flexibility there are two boolean parameters to control the
83 * hub driver's behavior. On the first initialization attempt, if the 83 * hub driver's behavior. On the first initialization attempt, if the
84 * "old_scheme_first" parameter is set then the old scheme will be used, 84 * "old_scheme_first" parameter is set then the old scheme will be used,
85 * otherwise the new scheme is used. If that fails and "use_both_schemes" 85 * otherwise the new scheme is used. If that fails and "use_both_schemes"
86 * is set, then the driver will make another attempt, using the other scheme. 86 * is set, then the driver will make another attempt, using the other scheme.
87 */ 87 */
88 static bool old_scheme_first = 0; 88 static bool old_scheme_first = 0;
89 module_param(old_scheme_first, bool, S_IRUGO | S_IWUSR); 89 module_param(old_scheme_first, bool, S_IRUGO | S_IWUSR);
90 MODULE_PARM_DESC(old_scheme_first, 90 MODULE_PARM_DESC(old_scheme_first,
91 "start with the old device initialization scheme"); 91 "start with the old device initialization scheme");
92 92
93 static bool use_both_schemes = 1; 93 static bool use_both_schemes = 1;
94 module_param(use_both_schemes, bool, S_IRUGO | S_IWUSR); 94 module_param(use_both_schemes, bool, S_IRUGO | S_IWUSR);
95 MODULE_PARM_DESC(use_both_schemes, 95 MODULE_PARM_DESC(use_both_schemes,
96 "try the other device initialization scheme if the " 96 "try the other device initialization scheme if the "
97 "first one fails"); 97 "first one fails");
98 98
99 /* Mutual exclusion for EHCI CF initialization. This interferes with 99 /* Mutual exclusion for EHCI CF initialization. This interferes with
100 * port reset on some companion controllers. 100 * port reset on some companion controllers.
101 */ 101 */
102 DECLARE_RWSEM(ehci_cf_port_reset_rwsem); 102 DECLARE_RWSEM(ehci_cf_port_reset_rwsem);
103 EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); 103 EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
104 104
105 #define HUB_DEBOUNCE_TIMEOUT 2000 105 #define HUB_DEBOUNCE_TIMEOUT 2000
106 #define HUB_DEBOUNCE_STEP 25 106 #define HUB_DEBOUNCE_STEP 25
107 #define HUB_DEBOUNCE_STABLE 100 107 #define HUB_DEBOUNCE_STABLE 100
108 108
109 static int usb_reset_and_verify_device(struct usb_device *udev); 109 static int usb_reset_and_verify_device(struct usb_device *udev);
110 110
111 static inline char *portspeed(struct usb_hub *hub, int portstatus) 111 static inline char *portspeed(struct usb_hub *hub, int portstatus)
112 { 112 {
113 if (hub_is_superspeed(hub->hdev)) 113 if (hub_is_superspeed(hub->hdev))
114 return "5.0 Gb/s"; 114 return "5.0 Gb/s";
115 if (portstatus & USB_PORT_STAT_HIGH_SPEED) 115 if (portstatus & USB_PORT_STAT_HIGH_SPEED)
116 return "480 Mb/s"; 116 return "480 Mb/s";
117 else if (portstatus & USB_PORT_STAT_LOW_SPEED) 117 else if (portstatus & USB_PORT_STAT_LOW_SPEED)
118 return "1.5 Mb/s"; 118 return "1.5 Mb/s";
119 else 119 else
120 return "12 Mb/s"; 120 return "12 Mb/s";
121 } 121 }
122 122
123 /* Note that hdev or one of its children must be locked! */ 123 /* Note that hdev or one of its children must be locked! */
124 struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev) 124 struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev)
125 { 125 {
126 if (!hdev || !hdev->actconfig || !hdev->maxchild) 126 if (!hdev || !hdev->actconfig || !hdev->maxchild)
127 return NULL; 127 return NULL;
128 return usb_get_intfdata(hdev->actconfig->interface[0]); 128 return usb_get_intfdata(hdev->actconfig->interface[0]);
129 } 129 }
130 130
131 static int usb_device_supports_lpm(struct usb_device *udev) 131 static int usb_device_supports_lpm(struct usb_device *udev)
132 { 132 {
133 /* USB 2.1 (and greater) devices indicate LPM support through 133 /* USB 2.1 (and greater) devices indicate LPM support through
134 * their USB 2.0 Extended Capabilities BOS descriptor. 134 * their USB 2.0 Extended Capabilities BOS descriptor.
135 */ 135 */
136 if (udev->speed == USB_SPEED_HIGH) { 136 if (udev->speed == USB_SPEED_HIGH) {
137 if (udev->bos->ext_cap && 137 if (udev->bos->ext_cap &&
138 (USB_LPM_SUPPORT & 138 (USB_LPM_SUPPORT &
139 le32_to_cpu(udev->bos->ext_cap->bmAttributes))) 139 le32_to_cpu(udev->bos->ext_cap->bmAttributes)))
140 return 1; 140 return 1;
141 return 0; 141 return 0;
142 } 142 }
143 143
144 /* 144 /*
145 * According to the USB 3.0 spec, all USB 3.0 devices must support LPM. 145 * According to the USB 3.0 spec, all USB 3.0 devices must support LPM.
146 * However, there are some that don't, and they set the U1/U2 exit 146 * However, there are some that don't, and they set the U1/U2 exit
147 * latencies to zero. 147 * latencies to zero.
148 */ 148 */
149 if (!udev->bos->ss_cap) { 149 if (!udev->bos->ss_cap) {
150 dev_info(&udev->dev, "No LPM exit latency info found, disabling LPM.\n"); 150 dev_info(&udev->dev, "No LPM exit latency info found, disabling LPM.\n");
151 return 0; 151 return 0;
152 } 152 }
153 153
154 if (udev->bos->ss_cap->bU1devExitLat == 0 && 154 if (udev->bos->ss_cap->bU1devExitLat == 0 &&
155 udev->bos->ss_cap->bU2DevExitLat == 0) { 155 udev->bos->ss_cap->bU2DevExitLat == 0) {
156 if (udev->parent) 156 if (udev->parent)
157 dev_info(&udev->dev, "LPM exit latency is zeroed, disabling LPM.\n"); 157 dev_info(&udev->dev, "LPM exit latency is zeroed, disabling LPM.\n");
158 else 158 else
159 dev_info(&udev->dev, "We don't know the algorithms for LPM for this host, disabling LPM.\n"); 159 dev_info(&udev->dev, "We don't know the algorithms for LPM for this host, disabling LPM.\n");
160 return 0; 160 return 0;
161 } 161 }
162 162
163 if (!udev->parent || udev->parent->lpm_capable) 163 if (!udev->parent || udev->parent->lpm_capable)
164 return 1; 164 return 1;
165 return 0; 165 return 0;
166 } 166 }
167 167
168 /* 168 /*
169 * Set the Maximum Exit Latency (MEL) for the host to initiate a transition from 169 * Set the Maximum Exit Latency (MEL) for the host to initiate a transition from
170 * either U1 or U2. 170 * either U1 or U2.
171 */ 171 */
172 static void usb_set_lpm_mel(struct usb_device *udev, 172 static void usb_set_lpm_mel(struct usb_device *udev,
173 struct usb3_lpm_parameters *udev_lpm_params, 173 struct usb3_lpm_parameters *udev_lpm_params,
174 unsigned int udev_exit_latency, 174 unsigned int udev_exit_latency,
175 struct usb_hub *hub, 175 struct usb_hub *hub,
176 struct usb3_lpm_parameters *hub_lpm_params, 176 struct usb3_lpm_parameters *hub_lpm_params,
177 unsigned int hub_exit_latency) 177 unsigned int hub_exit_latency)
178 { 178 {
179 unsigned int total_mel; 179 unsigned int total_mel;
180 unsigned int device_mel; 180 unsigned int device_mel;
181 unsigned int hub_mel; 181 unsigned int hub_mel;
182 182
183 /* 183 /*
184 * Calculate the time it takes to transition all links from the roothub 184 * Calculate the time it takes to transition all links from the roothub
185 * to the parent hub into U0. The parent hub must then decode the 185 * to the parent hub into U0. The parent hub must then decode the
186 * packet (hub header decode latency) to figure out which port it was 186 * packet (hub header decode latency) to figure out which port it was
187 * bound for. 187 * bound for.
188 * 188 *
189 * The Hub Header decode latency is expressed in 0.1us intervals (0x1 189 * The Hub Header decode latency is expressed in 0.1us intervals (0x1
190 * means 0.1us). Multiply that by 100 to get nanoseconds. 190 * means 0.1us). Multiply that by 100 to get nanoseconds.
191 */ 191 */
192 total_mel = hub_lpm_params->mel + 192 total_mel = hub_lpm_params->mel +
193 (hub->descriptor->u.ss.bHubHdrDecLat * 100); 193 (hub->descriptor->u.ss.bHubHdrDecLat * 100);
194 194
195 /* 195 /*
196 * How long will it take to transition the downstream hub's port into 196 * How long will it take to transition the downstream hub's port into
197 * U0? The greater of either the hub exit latency or the device exit 197 * U0? The greater of either the hub exit latency or the device exit
198 * latency. 198 * latency.
199 * 199 *
200 * The BOS U1/U2 exit latencies are expressed in 1us intervals. 200 * The BOS U1/U2 exit latencies are expressed in 1us intervals.
201 * Multiply that by 1000 to get nanoseconds. 201 * Multiply that by 1000 to get nanoseconds.
202 */ 202 */
203 device_mel = udev_exit_latency * 1000; 203 device_mel = udev_exit_latency * 1000;
204 hub_mel = hub_exit_latency * 1000; 204 hub_mel = hub_exit_latency * 1000;
205 if (device_mel > hub_mel) 205 if (device_mel > hub_mel)
206 total_mel += device_mel; 206 total_mel += device_mel;
207 else 207 else
208 total_mel += hub_mel; 208 total_mel += hub_mel;
209 209
210 udev_lpm_params->mel = total_mel; 210 udev_lpm_params->mel = total_mel;
211 } 211 }
212 212
213 /* 213 /*
214 * Set the maximum Device to Host Exit Latency (PEL) for the device to initiate 214 * Set the maximum Device to Host Exit Latency (PEL) for the device to initiate
215 * a transition from either U1 or U2. 215 * a transition from either U1 or U2.
216 */ 216 */
217 static void usb_set_lpm_pel(struct usb_device *udev, 217 static void usb_set_lpm_pel(struct usb_device *udev,
218 struct usb3_lpm_parameters *udev_lpm_params, 218 struct usb3_lpm_parameters *udev_lpm_params,
219 unsigned int udev_exit_latency, 219 unsigned int udev_exit_latency,
220 struct usb_hub *hub, 220 struct usb_hub *hub,
221 struct usb3_lpm_parameters *hub_lpm_params, 221 struct usb3_lpm_parameters *hub_lpm_params,
222 unsigned int hub_exit_latency, 222 unsigned int hub_exit_latency,
223 unsigned int port_to_port_exit_latency) 223 unsigned int port_to_port_exit_latency)
224 { 224 {
225 unsigned int first_link_pel; 225 unsigned int first_link_pel;
226 unsigned int hub_pel; 226 unsigned int hub_pel;
227 227
228 /* 228 /*
229 * First, the device sends an LFPS to transition the link between the 229 * First, the device sends an LFPS to transition the link between the
230 * device and the parent hub into U0. The exit latency is the bigger of 230 * device and the parent hub into U0. The exit latency is the bigger of
231 * the device exit latency or the hub exit latency. 231 * the device exit latency or the hub exit latency.
232 */ 232 */
233 if (udev_exit_latency > hub_exit_latency) 233 if (udev_exit_latency > hub_exit_latency)
234 first_link_pel = udev_exit_latency * 1000; 234 first_link_pel = udev_exit_latency * 1000;
235 else 235 else
236 first_link_pel = hub_exit_latency * 1000; 236 first_link_pel = hub_exit_latency * 1000;
237 237
238 /* 238 /*
239 * When the hub starts to receive the LFPS, there is a slight delay for 239 * When the hub starts to receive the LFPS, there is a slight delay for
240 * it to figure out that one of the ports is sending an LFPS. Then it 240 * it to figure out that one of the ports is sending an LFPS. Then it
241 * will forward the LFPS to its upstream link. The exit latency is the 241 * will forward the LFPS to its upstream link. The exit latency is the
242 * delay, plus the PEL that we calculated for this hub. 242 * delay, plus the PEL that we calculated for this hub.
243 */ 243 */
244 hub_pel = port_to_port_exit_latency * 1000 + hub_lpm_params->pel; 244 hub_pel = port_to_port_exit_latency * 1000 + hub_lpm_params->pel;
245 245
246 /* 246 /*
247 * According to figure C-7 in the USB 3.0 spec, the PEL for this device 247 * According to figure C-7 in the USB 3.0 spec, the PEL for this device
248 * is the greater of the two exit latencies. 248 * is the greater of the two exit latencies.
249 */ 249 */
250 if (first_link_pel > hub_pel) 250 if (first_link_pel > hub_pel)
251 udev_lpm_params->pel = first_link_pel; 251 udev_lpm_params->pel = first_link_pel;
252 else 252 else
253 udev_lpm_params->pel = hub_pel; 253 udev_lpm_params->pel = hub_pel;
254 } 254 }
255 255
256 /* 256 /*
257 * Set the System Exit Latency (SEL) to indicate the total worst-case time from 257 * Set the System Exit Latency (SEL) to indicate the total worst-case time from
258 * when a device initiates a transition to U0, until when it will receive the 258 * when a device initiates a transition to U0, until when it will receive the
259 * first packet from the host controller. 259 * first packet from the host controller.
260 * 260 *
261 * Section C.1.5.1 describes the four components to this: 261 * Section C.1.5.1 describes the four components to this:
262 * - t1: device PEL 262 * - t1: device PEL
263 * - t2: time for the ERDY to make it from the device to the host. 263 * - t2: time for the ERDY to make it from the device to the host.
264 * - t3: a host-specific delay to process the ERDY. 264 * - t3: a host-specific delay to process the ERDY.
265 * - t4: time for the packet to make it from the host to the device. 265 * - t4: time for the packet to make it from the host to the device.
266 * 266 *
267 * t3 is specific to both the xHCI host and the platform the host is integrated 267 * t3 is specific to both the xHCI host and the platform the host is integrated
268 * into. The Intel HW folks have said it's negligible, FIXME if a different 268 * into. The Intel HW folks have said it's negligible, FIXME if a different
269 * vendor says otherwise. 269 * vendor says otherwise.
270 */ 270 */
271 static void usb_set_lpm_sel(struct usb_device *udev, 271 static void usb_set_lpm_sel(struct usb_device *udev,
272 struct usb3_lpm_parameters *udev_lpm_params) 272 struct usb3_lpm_parameters *udev_lpm_params)
273 { 273 {
274 struct usb_device *parent; 274 struct usb_device *parent;
275 unsigned int num_hubs; 275 unsigned int num_hubs;
276 unsigned int total_sel; 276 unsigned int total_sel;
277 277
278 /* t1 = device PEL */ 278 /* t1 = device PEL */
279 total_sel = udev_lpm_params->pel; 279 total_sel = udev_lpm_params->pel;
280 /* How many external hubs are in between the device & the root port. */ 280 /* How many external hubs are in between the device & the root port. */
281 for (parent = udev->parent, num_hubs = 0; parent->parent; 281 for (parent = udev->parent, num_hubs = 0; parent->parent;
282 parent = parent->parent) 282 parent = parent->parent)
283 num_hubs++; 283 num_hubs++;
284 /* t2 = 2.1us + 250ns * (num_hubs - 1) */ 284 /* t2 = 2.1us + 250ns * (num_hubs - 1) */
285 if (num_hubs > 0) 285 if (num_hubs > 0)
286 total_sel += 2100 + 250 * (num_hubs - 1); 286 total_sel += 2100 + 250 * (num_hubs - 1);
287 287
288 /* t4 = 250ns * num_hubs */ 288 /* t4 = 250ns * num_hubs */
289 total_sel += 250 * num_hubs; 289 total_sel += 250 * num_hubs;
290 290
291 udev_lpm_params->sel = total_sel; 291 udev_lpm_params->sel = total_sel;
292 } 292 }
293 293
294 static void usb_set_lpm_parameters(struct usb_device *udev) 294 static void usb_set_lpm_parameters(struct usb_device *udev)
295 { 295 {
296 struct usb_hub *hub; 296 struct usb_hub *hub;
297 unsigned int port_to_port_delay; 297 unsigned int port_to_port_delay;
298 unsigned int udev_u1_del; 298 unsigned int udev_u1_del;
299 unsigned int udev_u2_del; 299 unsigned int udev_u2_del;
300 unsigned int hub_u1_del; 300 unsigned int hub_u1_del;
301 unsigned int hub_u2_del; 301 unsigned int hub_u2_del;
302 302
303 if (!udev->lpm_capable || udev->speed != USB_SPEED_SUPER) 303 if (!udev->lpm_capable || udev->speed != USB_SPEED_SUPER)
304 return; 304 return;
305 305
306 hub = usb_hub_to_struct_hub(udev->parent); 306 hub = usb_hub_to_struct_hub(udev->parent);
307 /* It doesn't take time to transition the roothub into U0, since it 307 /* It doesn't take time to transition the roothub into U0, since it
308 * doesn't have an upstream link. 308 * doesn't have an upstream link.
309 */ 309 */
310 if (!hub) 310 if (!hub)
311 return; 311 return;
312 312
313 udev_u1_del = udev->bos->ss_cap->bU1devExitLat; 313 udev_u1_del = udev->bos->ss_cap->bU1devExitLat;
314 udev_u2_del = le16_to_cpu(udev->bos->ss_cap->bU2DevExitLat); 314 udev_u2_del = le16_to_cpu(udev->bos->ss_cap->bU2DevExitLat);
315 hub_u1_del = udev->parent->bos->ss_cap->bU1devExitLat; 315 hub_u1_del = udev->parent->bos->ss_cap->bU1devExitLat;
316 hub_u2_del = le16_to_cpu(udev->parent->bos->ss_cap->bU2DevExitLat); 316 hub_u2_del = le16_to_cpu(udev->parent->bos->ss_cap->bU2DevExitLat);
317 317
318 usb_set_lpm_mel(udev, &udev->u1_params, udev_u1_del, 318 usb_set_lpm_mel(udev, &udev->u1_params, udev_u1_del,
319 hub, &udev->parent->u1_params, hub_u1_del); 319 hub, &udev->parent->u1_params, hub_u1_del);
320 320
321 usb_set_lpm_mel(udev, &udev->u2_params, udev_u2_del, 321 usb_set_lpm_mel(udev, &udev->u2_params, udev_u2_del,
322 hub, &udev->parent->u2_params, hub_u2_del); 322 hub, &udev->parent->u2_params, hub_u2_del);
323 323
324 /* 324 /*
325 * Appendix C, section C.2.2.2, says that there is a slight delay from 325 * Appendix C, section C.2.2.2, says that there is a slight delay from
326 * when the parent hub notices the downstream port is trying to 326 * when the parent hub notices the downstream port is trying to
327 * transition to U0 to when the hub initiates a U0 transition on its 327 * transition to U0 to when the hub initiates a U0 transition on its
328 * upstream port. The section says the delays are tPort2PortU1EL and 328 * upstream port. The section says the delays are tPort2PortU1EL and
329 * tPort2PortU2EL, but it doesn't define what they are. 329 * tPort2PortU2EL, but it doesn't define what they are.
330 * 330 *
331 * The hub chapter, sections 10.4.2.4 and 10.4.2.5 seem to be talking 331 * The hub chapter, sections 10.4.2.4 and 10.4.2.5 seem to be talking
332 * about the same delays. Use the maximum delay calculations from those 332 * about the same delays. Use the maximum delay calculations from those
333 * sections. For U1, it's tHubPort2PortExitLat, which is 1us max. For 333 * sections. For U1, it's tHubPort2PortExitLat, which is 1us max. For
334 * U2, it's tHubPort2PortExitLat + U2DevExitLat - U1DevExitLat. I 334 * U2, it's tHubPort2PortExitLat + U2DevExitLat - U1DevExitLat. I
335 * assume the device exit latencies they are talking about are the hub 335 * assume the device exit latencies they are talking about are the hub
336 * exit latencies. 336 * exit latencies.
337 * 337 *
338 * What do we do if the U2 exit latency is less than the U1 exit 338 * What do we do if the U2 exit latency is less than the U1 exit
339 * latency? It's possible, although not likely... 339 * latency? It's possible, although not likely...
340 */ 340 */
341 port_to_port_delay = 1; 341 port_to_port_delay = 1;
342 342
343 usb_set_lpm_pel(udev, &udev->u1_params, udev_u1_del, 343 usb_set_lpm_pel(udev, &udev->u1_params, udev_u1_del,
344 hub, &udev->parent->u1_params, hub_u1_del, 344 hub, &udev->parent->u1_params, hub_u1_del,
345 port_to_port_delay); 345 port_to_port_delay);
346 346
347 if (hub_u2_del > hub_u1_del) 347 if (hub_u2_del > hub_u1_del)
348 port_to_port_delay = 1 + hub_u2_del - hub_u1_del; 348 port_to_port_delay = 1 + hub_u2_del - hub_u1_del;
349 else 349 else
350 port_to_port_delay = 1 + hub_u1_del; 350 port_to_port_delay = 1 + hub_u1_del;
351 351
352 usb_set_lpm_pel(udev, &udev->u2_params, udev_u2_del, 352 usb_set_lpm_pel(udev, &udev->u2_params, udev_u2_del,
353 hub, &udev->parent->u2_params, hub_u2_del, 353 hub, &udev->parent->u2_params, hub_u2_del,
354 port_to_port_delay); 354 port_to_port_delay);
355 355
356 /* Now that we've got PEL, calculate SEL. */ 356 /* Now that we've got PEL, calculate SEL. */
357 usb_set_lpm_sel(udev, &udev->u1_params); 357 usb_set_lpm_sel(udev, &udev->u1_params);
358 usb_set_lpm_sel(udev, &udev->u2_params); 358 usb_set_lpm_sel(udev, &udev->u2_params);
359 } 359 }
360 360
361 /* USB 2.0 spec Section 11.24.4.5 */ 361 /* USB 2.0 spec Section 11.24.4.5 */
362 static int get_hub_descriptor(struct usb_device *hdev, void *data) 362 static int get_hub_descriptor(struct usb_device *hdev, void *data)
363 { 363 {
364 int i, ret, size; 364 int i, ret, size;
365 unsigned dtype; 365 unsigned dtype;
366 366
367 if (hub_is_superspeed(hdev)) { 367 if (hub_is_superspeed(hdev)) {
368 dtype = USB_DT_SS_HUB; 368 dtype = USB_DT_SS_HUB;
369 size = USB_DT_SS_HUB_SIZE; 369 size = USB_DT_SS_HUB_SIZE;
370 } else { 370 } else {
371 dtype = USB_DT_HUB; 371 dtype = USB_DT_HUB;
372 size = sizeof(struct usb_hub_descriptor); 372 size = sizeof(struct usb_hub_descriptor);
373 } 373 }
374 374
375 for (i = 0; i < 3; i++) { 375 for (i = 0; i < 3; i++) {
376 ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), 376 ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
377 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB, 377 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
378 dtype << 8, 0, data, size, 378 dtype << 8, 0, data, size,
379 USB_CTRL_GET_TIMEOUT); 379 USB_CTRL_GET_TIMEOUT);
380 if (ret >= (USB_DT_HUB_NONVAR_SIZE + 2)) 380 if (ret >= (USB_DT_HUB_NONVAR_SIZE + 2))
381 return ret; 381 return ret;
382 } 382 }
383 return -EINVAL; 383 return -EINVAL;
384 } 384 }
385 385
386 /* 386 /*
387 * USB 2.0 spec Section 11.24.2.1 387 * USB 2.0 spec Section 11.24.2.1
388 */ 388 */
389 static int clear_hub_feature(struct usb_device *hdev, int feature) 389 static int clear_hub_feature(struct usb_device *hdev, int feature)
390 { 390 {
391 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), 391 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
392 USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature, 0, NULL, 0, 1000); 392 USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature, 0, NULL, 0, 1000);
393 } 393 }
394 394
395 /* 395 /*
396 * USB 2.0 spec Section 11.24.2.2 396 * USB 2.0 spec Section 11.24.2.2
397 */ 397 */
398 int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature) 398 int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature)
399 { 399 {
400 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), 400 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
401 USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port1, 401 USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port1,
402 NULL, 0, 1000); 402 NULL, 0, 1000);
403 } 403 }
404 404
405 /* 405 /*
406 * USB 2.0 spec Section 11.24.2.13 406 * USB 2.0 spec Section 11.24.2.13
407 */ 407 */
408 static int set_port_feature(struct usb_device *hdev, int port1, int feature) 408 static int set_port_feature(struct usb_device *hdev, int port1, int feature)
409 { 409 {
410 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), 410 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
411 USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1, 411 USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1,
412 NULL, 0, 1000); 412 NULL, 0, 1000);
413 } 413 }
414 414
415 /* 415 /*
416 * USB 2.0 spec Section 11.24.2.7.1.10 and table 11-7 416 * USB 2.0 spec Section 11.24.2.7.1.10 and table 11-7
417 * for info about using port indicators 417 * for info about using port indicators
418 */ 418 */
419 static void set_port_led( 419 static void set_port_led(
420 struct usb_hub *hub, 420 struct usb_hub *hub,
421 int port1, 421 int port1,
422 int selector 422 int selector
423 ) 423 )
424 { 424 {
425 int status = set_port_feature(hub->hdev, (selector << 8) | port1, 425 int status = set_port_feature(hub->hdev, (selector << 8) | port1,
426 USB_PORT_FEAT_INDICATOR); 426 USB_PORT_FEAT_INDICATOR);
427 if (status < 0) 427 if (status < 0)
428 dev_dbg (hub->intfdev, 428 dev_dbg (hub->intfdev,
429 "port %d indicator %s status %d\n", 429 "port %d indicator %s status %d\n",
430 port1, 430 port1,
431 ({ char *s; switch (selector) { 431 ({ char *s; switch (selector) {
432 case HUB_LED_AMBER: s = "amber"; break; 432 case HUB_LED_AMBER: s = "amber"; break;
433 case HUB_LED_GREEN: s = "green"; break; 433 case HUB_LED_GREEN: s = "green"; break;
434 case HUB_LED_OFF: s = "off"; break; 434 case HUB_LED_OFF: s = "off"; break;
435 case HUB_LED_AUTO: s = "auto"; break; 435 case HUB_LED_AUTO: s = "auto"; break;
436 default: s = "??"; break; 436 default: s = "??"; break;
437 } s; }), 437 } s; }),
438 status); 438 status);
439 } 439 }
440 440
441 #define LED_CYCLE_PERIOD ((2*HZ)/3) 441 #define LED_CYCLE_PERIOD ((2*HZ)/3)
442 442
443 static void led_work (struct work_struct *work) 443 static void led_work (struct work_struct *work)
444 { 444 {
445 struct usb_hub *hub = 445 struct usb_hub *hub =
446 container_of(work, struct usb_hub, leds.work); 446 container_of(work, struct usb_hub, leds.work);
447 struct usb_device *hdev = hub->hdev; 447 struct usb_device *hdev = hub->hdev;
448 unsigned i; 448 unsigned i;
449 unsigned changed = 0; 449 unsigned changed = 0;
450 int cursor = -1; 450 int cursor = -1;
451 451
452 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing) 452 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing)
453 return; 453 return;
454 454
455 for (i = 0; i < hdev->maxchild; i++) { 455 for (i = 0; i < hdev->maxchild; i++) {
456 unsigned selector, mode; 456 unsigned selector, mode;
457 457
458 /* 30%-50% duty cycle */ 458 /* 30%-50% duty cycle */
459 459
460 switch (hub->indicator[i]) { 460 switch (hub->indicator[i]) {
461 /* cycle marker */ 461 /* cycle marker */
462 case INDICATOR_CYCLE: 462 case INDICATOR_CYCLE:
463 cursor = i; 463 cursor = i;
464 selector = HUB_LED_AUTO; 464 selector = HUB_LED_AUTO;
465 mode = INDICATOR_AUTO; 465 mode = INDICATOR_AUTO;
466 break; 466 break;
467 /* blinking green = sw attention */ 467 /* blinking green = sw attention */
468 case INDICATOR_GREEN_BLINK: 468 case INDICATOR_GREEN_BLINK:
469 selector = HUB_LED_GREEN; 469 selector = HUB_LED_GREEN;
470 mode = INDICATOR_GREEN_BLINK_OFF; 470 mode = INDICATOR_GREEN_BLINK_OFF;
471 break; 471 break;
472 case INDICATOR_GREEN_BLINK_OFF: 472 case INDICATOR_GREEN_BLINK_OFF:
473 selector = HUB_LED_OFF; 473 selector = HUB_LED_OFF;
474 mode = INDICATOR_GREEN_BLINK; 474 mode = INDICATOR_GREEN_BLINK;
475 break; 475 break;
476 /* blinking amber = hw attention */ 476 /* blinking amber = hw attention */
477 case INDICATOR_AMBER_BLINK: 477 case INDICATOR_AMBER_BLINK:
478 selector = HUB_LED_AMBER; 478 selector = HUB_LED_AMBER;
479 mode = INDICATOR_AMBER_BLINK_OFF; 479 mode = INDICATOR_AMBER_BLINK_OFF;
480 break; 480 break;
481 case INDICATOR_AMBER_BLINK_OFF: 481 case INDICATOR_AMBER_BLINK_OFF:
482 selector = HUB_LED_OFF; 482 selector = HUB_LED_OFF;
483 mode = INDICATOR_AMBER_BLINK; 483 mode = INDICATOR_AMBER_BLINK;
484 break; 484 break;
485 /* blink green/amber = reserved */ 485 /* blink green/amber = reserved */
486 case INDICATOR_ALT_BLINK: 486 case INDICATOR_ALT_BLINK:
487 selector = HUB_LED_GREEN; 487 selector = HUB_LED_GREEN;
488 mode = INDICATOR_ALT_BLINK_OFF; 488 mode = INDICATOR_ALT_BLINK_OFF;
489 break; 489 break;
490 case INDICATOR_ALT_BLINK_OFF: 490 case INDICATOR_ALT_BLINK_OFF:
491 selector = HUB_LED_AMBER; 491 selector = HUB_LED_AMBER;
492 mode = INDICATOR_ALT_BLINK; 492 mode = INDICATOR_ALT_BLINK;
493 break; 493 break;
494 default: 494 default:
495 continue; 495 continue;
496 } 496 }
497 if (selector != HUB_LED_AUTO) 497 if (selector != HUB_LED_AUTO)
498 changed = 1; 498 changed = 1;
499 set_port_led(hub, i + 1, selector); 499 set_port_led(hub, i + 1, selector);
500 hub->indicator[i] = mode; 500 hub->indicator[i] = mode;
501 } 501 }
502 if (!changed && blinkenlights) { 502 if (!changed && blinkenlights) {
503 cursor++; 503 cursor++;
504 cursor %= hdev->maxchild; 504 cursor %= hdev->maxchild;
505 set_port_led(hub, cursor + 1, HUB_LED_GREEN); 505 set_port_led(hub, cursor + 1, HUB_LED_GREEN);
506 hub->indicator[cursor] = INDICATOR_CYCLE; 506 hub->indicator[cursor] = INDICATOR_CYCLE;
507 changed++; 507 changed++;
508 } 508 }
509 if (changed) 509 if (changed)
510 queue_delayed_work(system_power_efficient_wq, 510 queue_delayed_work(system_power_efficient_wq,
511 &hub->leds, LED_CYCLE_PERIOD); 511 &hub->leds, LED_CYCLE_PERIOD);
512 } 512 }
513 513
514 /* use a short timeout for hub/port status fetches */ 514 /* use a short timeout for hub/port status fetches */
515 #define USB_STS_TIMEOUT 1000 515 #define USB_STS_TIMEOUT 1000
516 #define USB_STS_RETRIES 5 516 #define USB_STS_RETRIES 5
517 517
518 /* 518 /*
519 * USB 2.0 spec Section 11.24.2.6 519 * USB 2.0 spec Section 11.24.2.6
520 */ 520 */
521 static int get_hub_status(struct usb_device *hdev, 521 static int get_hub_status(struct usb_device *hdev,
522 struct usb_hub_status *data) 522 struct usb_hub_status *data)
523 { 523 {
524 int i, status = -ETIMEDOUT; 524 int i, status = -ETIMEDOUT;
525 525
526 for (i = 0; i < USB_STS_RETRIES && 526 for (i = 0; i < USB_STS_RETRIES &&
527 (status == -ETIMEDOUT || status == -EPIPE); i++) { 527 (status == -ETIMEDOUT || status == -EPIPE); i++) {
528 status = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), 528 status = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
529 USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_HUB, 0, 0, 529 USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_HUB, 0, 0,
530 data, sizeof(*data), USB_STS_TIMEOUT); 530 data, sizeof(*data), USB_STS_TIMEOUT);
531 } 531 }
532 return status; 532 return status;
533 } 533 }
534 534
535 /* 535 /*
536 * USB 2.0 spec Section 11.24.2.7 536 * USB 2.0 spec Section 11.24.2.7
537 */ 537 */
538 static int get_port_status(struct usb_device *hdev, int port1, 538 static int get_port_status(struct usb_device *hdev, int port1,
539 struct usb_port_status *data) 539 struct usb_port_status *data)
540 { 540 {
541 int i, status = -ETIMEDOUT; 541 int i, status = -ETIMEDOUT;
542 542
543 for (i = 0; i < USB_STS_RETRIES && 543 for (i = 0; i < USB_STS_RETRIES &&
544 (status == -ETIMEDOUT || status == -EPIPE); i++) { 544 (status == -ETIMEDOUT || status == -EPIPE); i++) {
545 status = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), 545 status = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
546 USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port1, 546 USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port1,
547 data, sizeof(*data), USB_STS_TIMEOUT); 547 data, sizeof(*data), USB_STS_TIMEOUT);
548 } 548 }
549 return status; 549 return status;
550 } 550 }
551 551
552 static int hub_port_status(struct usb_hub *hub, int port1, 552 static int hub_port_status(struct usb_hub *hub, int port1,
553 u16 *status, u16 *change) 553 u16 *status, u16 *change)
554 { 554 {
555 int ret; 555 int ret;
556 556
557 mutex_lock(&hub->status_mutex); 557 mutex_lock(&hub->status_mutex);
558 ret = get_port_status(hub->hdev, port1, &hub->status->port); 558 ret = get_port_status(hub->hdev, port1, &hub->status->port);
559 if (ret < 4) { 559 if (ret < 4) {
560 if (ret != -ENODEV) 560 if (ret != -ENODEV)
561 dev_err(hub->intfdev, 561 dev_err(hub->intfdev,
562 "%s failed (err = %d)\n", __func__, ret); 562 "%s failed (err = %d)\n", __func__, ret);
563 if (ret >= 0) 563 if (ret >= 0)
564 ret = -EIO; 564 ret = -EIO;
565 } else { 565 } else {
566 *status = le16_to_cpu(hub->status->port.wPortStatus); 566 *status = le16_to_cpu(hub->status->port.wPortStatus);
567 *change = le16_to_cpu(hub->status->port.wPortChange); 567 *change = le16_to_cpu(hub->status->port.wPortChange);
568 568
569 ret = 0; 569 ret = 0;
570 } 570 }
571 mutex_unlock(&hub->status_mutex); 571 mutex_unlock(&hub->status_mutex);
572 return ret; 572 return ret;
573 } 573 }
574 574
575 static void kick_khubd(struct usb_hub *hub) 575 static void kick_khubd(struct usb_hub *hub)
576 { 576 {
577 unsigned long flags; 577 unsigned long flags;
578 578
579 spin_lock_irqsave(&hub_event_lock, flags); 579 spin_lock_irqsave(&hub_event_lock, flags);
580 if (!hub->disconnected && list_empty(&hub->event_list)) { 580 if (!hub->disconnected && list_empty(&hub->event_list)) {
581 list_add_tail(&hub->event_list, &hub_event_list); 581 list_add_tail(&hub->event_list, &hub_event_list);
582 582
583 /* Suppress autosuspend until khubd runs */ 583 /* Suppress autosuspend until khubd runs */
584 usb_autopm_get_interface_no_resume( 584 usb_autopm_get_interface_no_resume(
585 to_usb_interface(hub->intfdev)); 585 to_usb_interface(hub->intfdev));
586 wake_up(&khubd_wait); 586 wake_up(&khubd_wait);
587 } 587 }
588 spin_unlock_irqrestore(&hub_event_lock, flags); 588 spin_unlock_irqrestore(&hub_event_lock, flags);
589 } 589 }
590 590
591 void usb_kick_khubd(struct usb_device *hdev) 591 void usb_kick_khubd(struct usb_device *hdev)
592 { 592 {
593 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); 593 struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
594 594
595 if (hub) 595 if (hub)
596 kick_khubd(hub); 596 kick_khubd(hub);
597 } 597 }
598 598
599 /* 599 /*
600 * Let the USB core know that a USB 3.0 device has sent a Function Wake Device 600 * Let the USB core know that a USB 3.0 device has sent a Function Wake Device
601 * Notification, which indicates it had initiated remote wakeup. 601 * Notification, which indicates it had initiated remote wakeup.
602 * 602 *
603 * USB 3.0 hubs do not report the port link state change from U3 to U0 when the 603 * USB 3.0 hubs do not report the port link state change from U3 to U0 when the
604 * device initiates resume, so the USB core will not receive notice of the 604 * device initiates resume, so the USB core will not receive notice of the
605 * resume through the normal hub interrupt URB. 605 * resume through the normal hub interrupt URB.
606 */ 606 */
607 void usb_wakeup_notification(struct usb_device *hdev, 607 void usb_wakeup_notification(struct usb_device *hdev,
608 unsigned int portnum) 608 unsigned int portnum)
609 { 609 {
610 struct usb_hub *hub; 610 struct usb_hub *hub;
611 611
612 if (!hdev) 612 if (!hdev)
613 return; 613 return;
614 614
615 hub = usb_hub_to_struct_hub(hdev); 615 hub = usb_hub_to_struct_hub(hdev);
616 if (hub) { 616 if (hub) {
617 set_bit(portnum, hub->wakeup_bits); 617 set_bit(portnum, hub->wakeup_bits);
618 kick_khubd(hub); 618 kick_khubd(hub);
619 } 619 }
620 } 620 }
621 EXPORT_SYMBOL_GPL(usb_wakeup_notification); 621 EXPORT_SYMBOL_GPL(usb_wakeup_notification);
622 622
623 /* completion function, fires on port status changes and various faults */ 623 /* completion function, fires on port status changes and various faults */
624 static void hub_irq(struct urb *urb) 624 static void hub_irq(struct urb *urb)
625 { 625 {
626 struct usb_hub *hub = urb->context; 626 struct usb_hub *hub = urb->context;
627 int status = urb->status; 627 int status = urb->status;
628 unsigned i; 628 unsigned i;
629 unsigned long bits; 629 unsigned long bits;
630 630
631 switch (status) { 631 switch (status) {
632 case -ENOENT: /* synchronous unlink */ 632 case -ENOENT: /* synchronous unlink */
633 case -ECONNRESET: /* async unlink */ 633 case -ECONNRESET: /* async unlink */
634 case -ESHUTDOWN: /* hardware going away */ 634 case -ESHUTDOWN: /* hardware going away */
635 return; 635 return;
636 636
637 default: /* presumably an error */ 637 default: /* presumably an error */
638 /* Cause a hub reset after 10 consecutive errors */ 638 /* Cause a hub reset after 10 consecutive errors */
639 dev_dbg (hub->intfdev, "transfer --> %d\n", status); 639 dev_dbg (hub->intfdev, "transfer --> %d\n", status);
640 if ((++hub->nerrors < 10) || hub->error) 640 if ((++hub->nerrors < 10) || hub->error)
641 goto resubmit; 641 goto resubmit;
642 hub->error = status; 642 hub->error = status;
643 /* FALL THROUGH */ 643 /* FALL THROUGH */
644 644
645 /* let khubd handle things */ 645 /* let khubd handle things */
646 case 0: /* we got data: port status changed */ 646 case 0: /* we got data: port status changed */
647 bits = 0; 647 bits = 0;
648 for (i = 0; i < urb->actual_length; ++i) 648 for (i = 0; i < urb->actual_length; ++i)
649 bits |= ((unsigned long) ((*hub->buffer)[i])) 649 bits |= ((unsigned long) ((*hub->buffer)[i]))
650 << (i*8); 650 << (i*8);
651 hub->event_bits[0] = bits; 651 hub->event_bits[0] = bits;
652 break; 652 break;
653 } 653 }
654 654
655 hub->nerrors = 0; 655 hub->nerrors = 0;
656 656
657 /* Something happened, let khubd figure it out */ 657 /* Something happened, let khubd figure it out */
658 kick_khubd(hub); 658 kick_khubd(hub);
659 659
660 resubmit: 660 resubmit:
661 if (hub->quiescing) 661 if (hub->quiescing)
662 return; 662 return;
663 663
664 if ((status = usb_submit_urb (hub->urb, GFP_ATOMIC)) != 0 664 if ((status = usb_submit_urb (hub->urb, GFP_ATOMIC)) != 0
665 && status != -ENODEV && status != -EPERM) 665 && status != -ENODEV && status != -EPERM)
666 dev_err (hub->intfdev, "resubmit --> %d\n", status); 666 dev_err (hub->intfdev, "resubmit --> %d\n", status);
667 } 667 }
668 668
669 /* USB 2.0 spec Section 11.24.2.3 */ 669 /* USB 2.0 spec Section 11.24.2.3 */
670 static inline int 670 static inline int
671 hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt) 671 hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
672 { 672 {
673 /* Need to clear both directions for control ep */ 673 /* Need to clear both directions for control ep */
674 if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) == 674 if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) ==
675 USB_ENDPOINT_XFER_CONTROL) { 675 USB_ENDPOINT_XFER_CONTROL) {
676 int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), 676 int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
677 HUB_CLEAR_TT_BUFFER, USB_RT_PORT, 677 HUB_CLEAR_TT_BUFFER, USB_RT_PORT,
678 devinfo ^ 0x8000, tt, NULL, 0, 1000); 678 devinfo ^ 0x8000, tt, NULL, 0, 1000);
679 if (status) 679 if (status)
680 return status; 680 return status;
681 } 681 }
682 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), 682 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
683 HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo, 683 HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo,
684 tt, NULL, 0, 1000); 684 tt, NULL, 0, 1000);
685 } 685 }
686 686
687 /* 687 /*
688 * enumeration blocks khubd for a long time. we use keventd instead, since 688 * enumeration blocks khubd for a long time. we use keventd instead, since
689 * long blocking there is the exception, not the rule. accordingly, HCDs 689 * long blocking there is the exception, not the rule. accordingly, HCDs
690 * talking to TTs must queue control transfers (not just bulk and iso), so 690 * talking to TTs must queue control transfers (not just bulk and iso), so
691 * both can talk to the same hub concurrently. 691 * both can talk to the same hub concurrently.
692 */ 692 */
693 static void hub_tt_work(struct work_struct *work) 693 static void hub_tt_work(struct work_struct *work)
694 { 694 {
695 struct usb_hub *hub = 695 struct usb_hub *hub =
696 container_of(work, struct usb_hub, tt.clear_work); 696 container_of(work, struct usb_hub, tt.clear_work);
697 unsigned long flags; 697 unsigned long flags;
698 698
699 spin_lock_irqsave (&hub->tt.lock, flags); 699 spin_lock_irqsave (&hub->tt.lock, flags);
700 while (!list_empty(&hub->tt.clear_list)) { 700 while (!list_empty(&hub->tt.clear_list)) {
701 struct list_head *next; 701 struct list_head *next;
702 struct usb_tt_clear *clear; 702 struct usb_tt_clear *clear;
703 struct usb_device *hdev = hub->hdev; 703 struct usb_device *hdev = hub->hdev;
704 const struct hc_driver *drv; 704 const struct hc_driver *drv;
705 int status; 705 int status;
706 706
707 next = hub->tt.clear_list.next; 707 next = hub->tt.clear_list.next;
708 clear = list_entry (next, struct usb_tt_clear, clear_list); 708 clear = list_entry (next, struct usb_tt_clear, clear_list);
709 list_del (&clear->clear_list); 709 list_del (&clear->clear_list);
710 710
711 /* drop lock so HCD can concurrently report other TT errors */ 711 /* drop lock so HCD can concurrently report other TT errors */
712 spin_unlock_irqrestore (&hub->tt.lock, flags); 712 spin_unlock_irqrestore (&hub->tt.lock, flags);
713 status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt); 713 status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt);
714 if (status && status != -ENODEV) 714 if (status && status != -ENODEV)
715 dev_err (&hdev->dev, 715 dev_err (&hdev->dev,
716 "clear tt %d (%04x) error %d\n", 716 "clear tt %d (%04x) error %d\n",
717 clear->tt, clear->devinfo, status); 717 clear->tt, clear->devinfo, status);
718 718
719 /* Tell the HCD, even if the operation failed */ 719 /* Tell the HCD, even if the operation failed */
720 drv = clear->hcd->driver; 720 drv = clear->hcd->driver;
721 if (drv->clear_tt_buffer_complete) 721 if (drv->clear_tt_buffer_complete)
722 (drv->clear_tt_buffer_complete)(clear->hcd, clear->ep); 722 (drv->clear_tt_buffer_complete)(clear->hcd, clear->ep);
723 723
724 kfree(clear); 724 kfree(clear);
725 spin_lock_irqsave(&hub->tt.lock, flags); 725 spin_lock_irqsave(&hub->tt.lock, flags);
726 } 726 }
727 spin_unlock_irqrestore (&hub->tt.lock, flags); 727 spin_unlock_irqrestore (&hub->tt.lock, flags);
728 } 728 }
729 729
730 /** 730 /**
731 * usb_hub_set_port_power - control hub port's power state 731 * usb_hub_set_port_power - control hub port's power state
732 * @hdev: USB device belonging to the usb hub 732 * @hdev: USB device belonging to the usb hub
733 * @hub: target hub 733 * @hub: target hub
734 * @port1: port index 734 * @port1: port index
735 * @set: expected status 735 * @set: expected status
736 * 736 *
737 * call this function to control port's power via setting or 737 * call this function to control port's power via setting or
738 * clearing the port's PORT_POWER feature. 738 * clearing the port's PORT_POWER feature.
739 * 739 *
740 * Return: 0 if successful. A negative error code otherwise. 740 * Return: 0 if successful. A negative error code otherwise.
741 */ 741 */
742 int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub, 742 int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub,
743 int port1, bool set) 743 int port1, bool set)
744 { 744 {
745 int ret; 745 int ret;
746 struct usb_port *port_dev = hub->ports[port1 - 1]; 746 struct usb_port *port_dev = hub->ports[port1 - 1];
747 747
748 if (set) 748 if (set)
749 ret = set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 749 ret = set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
750 else 750 else
751 ret = usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 751 ret = usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
752 752
753 if (!ret) 753 if (!ret)
754 port_dev->power_is_on = set; 754 port_dev->power_is_on = set;
755 return ret; 755 return ret;
756 } 756 }
757 757
758 /** 758 /**
759 * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub 759 * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub
760 * @urb: an URB associated with the failed or incomplete split transaction 760 * @urb: an URB associated with the failed or incomplete split transaction
761 * 761 *
762 * High speed HCDs use this to tell the hub driver that some split control or 762 * High speed HCDs use this to tell the hub driver that some split control or
763 * bulk transaction failed in a way that requires clearing internal state of 763 * bulk transaction failed in a way that requires clearing internal state of
764 * a transaction translator. This is normally detected (and reported) from 764 * a transaction translator. This is normally detected (and reported) from
765 * interrupt context. 765 * interrupt context.
766 * 766 *
767 * It may not be possible for that hub to handle additional full (or low) 767 * It may not be possible for that hub to handle additional full (or low)
768 * speed transactions until that state is fully cleared out. 768 * speed transactions until that state is fully cleared out.
769 * 769 *
770 * Return: 0 if successful. A negative error code otherwise. 770 * Return: 0 if successful. A negative error code otherwise.
771 */ 771 */
772 int usb_hub_clear_tt_buffer(struct urb *urb) 772 int usb_hub_clear_tt_buffer(struct urb *urb)
773 { 773 {
774 struct usb_device *udev = urb->dev; 774 struct usb_device *udev = urb->dev;
775 int pipe = urb->pipe; 775 int pipe = urb->pipe;
776 struct usb_tt *tt = udev->tt; 776 struct usb_tt *tt = udev->tt;
777 unsigned long flags; 777 unsigned long flags;
778 struct usb_tt_clear *clear; 778 struct usb_tt_clear *clear;
779 779
780 /* we've got to cope with an arbitrary number of pending TT clears, 780 /* we've got to cope with an arbitrary number of pending TT clears,
781 * since each TT has "at least two" buffers that can need it (and 781 * since each TT has "at least two" buffers that can need it (and
782 * there can be many TTs per hub). even if they're uncommon. 782 * there can be many TTs per hub). even if they're uncommon.
783 */ 783 */
784 if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) { 784 if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) {
785 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n"); 785 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
786 /* FIXME recover somehow ... RESET_TT? */ 786 /* FIXME recover somehow ... RESET_TT? */
787 return -ENOMEM; 787 return -ENOMEM;
788 } 788 }
789 789
790 /* info that CLEAR_TT_BUFFER needs */ 790 /* info that CLEAR_TT_BUFFER needs */
791 clear->tt = tt->multi ? udev->ttport : 1; 791 clear->tt = tt->multi ? udev->ttport : 1;
792 clear->devinfo = usb_pipeendpoint (pipe); 792 clear->devinfo = usb_pipeendpoint (pipe);
793 clear->devinfo |= udev->devnum << 4; 793 clear->devinfo |= udev->devnum << 4;
794 clear->devinfo |= usb_pipecontrol (pipe) 794 clear->devinfo |= usb_pipecontrol (pipe)
795 ? (USB_ENDPOINT_XFER_CONTROL << 11) 795 ? (USB_ENDPOINT_XFER_CONTROL << 11)
796 : (USB_ENDPOINT_XFER_BULK << 11); 796 : (USB_ENDPOINT_XFER_BULK << 11);
797 if (usb_pipein (pipe)) 797 if (usb_pipein (pipe))
798 clear->devinfo |= 1 << 15; 798 clear->devinfo |= 1 << 15;
799 799
800 /* info for completion callback */ 800 /* info for completion callback */
801 clear->hcd = bus_to_hcd(udev->bus); 801 clear->hcd = bus_to_hcd(udev->bus);
802 clear->ep = urb->ep; 802 clear->ep = urb->ep;
803 803
804 /* tell keventd to clear state for this TT */ 804 /* tell keventd to clear state for this TT */
805 spin_lock_irqsave (&tt->lock, flags); 805 spin_lock_irqsave (&tt->lock, flags);
806 list_add_tail (&clear->clear_list, &tt->clear_list); 806 list_add_tail (&clear->clear_list, &tt->clear_list);
807 schedule_work(&tt->clear_work); 807 schedule_work(&tt->clear_work);
808 spin_unlock_irqrestore (&tt->lock, flags); 808 spin_unlock_irqrestore (&tt->lock, flags);
809 return 0; 809 return 0;
810 } 810 }
811 EXPORT_SYMBOL_GPL(usb_hub_clear_tt_buffer); 811 EXPORT_SYMBOL_GPL(usb_hub_clear_tt_buffer);
812 812
813 /* If do_delay is false, return the number of milliseconds the caller 813 /* If do_delay is false, return the number of milliseconds the caller
814 * needs to delay. 814 * needs to delay.
815 */ 815 */
816 static unsigned hub_power_on(struct usb_hub *hub, bool do_delay) 816 static unsigned hub_power_on(struct usb_hub *hub, bool do_delay)
817 { 817 {
818 int port1; 818 int port1;
819 unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; 819 unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
820 unsigned delay; 820 unsigned delay;
821 u16 wHubCharacteristics = 821 u16 wHubCharacteristics =
822 le16_to_cpu(hub->descriptor->wHubCharacteristics); 822 le16_to_cpu(hub->descriptor->wHubCharacteristics);
823 823
824 /* Enable power on each port. Some hubs have reserved values 824 /* Enable power on each port. Some hubs have reserved values
825 * of LPSM (> 2) in their descriptors, even though they are 825 * of LPSM (> 2) in their descriptors, even though they are
826 * USB 2.0 hubs. Some hubs do not implement port-power switching 826 * USB 2.0 hubs. Some hubs do not implement port-power switching
827 * but only emulate it. In all cases, the ports won't work 827 * but only emulate it. In all cases, the ports won't work
828 * unless we send these messages to the hub. 828 * unless we send these messages to the hub.
829 */ 829 */
830 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2) 830 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2)
831 dev_dbg(hub->intfdev, "enabling power on all ports\n"); 831 dev_dbg(hub->intfdev, "enabling power on all ports\n");
832 else 832 else
833 dev_dbg(hub->intfdev, "trying to enable port power on " 833 dev_dbg(hub->intfdev, "trying to enable port power on "
834 "non-switchable hub\n"); 834 "non-switchable hub\n");
835 for (port1 = 1; port1 <= hub->hdev->maxchild; port1++) 835 for (port1 = 1; port1 <= hub->hdev->maxchild; port1++)
836 if (hub->ports[port1 - 1]->power_is_on) 836 if (hub->ports[port1 - 1]->power_is_on)
837 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); 837 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
838 else 838 else
839 usb_clear_port_feature(hub->hdev, port1, 839 usb_clear_port_feature(hub->hdev, port1,
840 USB_PORT_FEAT_POWER); 840 USB_PORT_FEAT_POWER);
841 841
842 /* Wait at least 100 msec for power to become stable */ 842 /* Wait at least 100 msec for power to become stable */
843 delay = max(pgood_delay, (unsigned) 100); 843 delay = max(pgood_delay, (unsigned) 100);
844 if (do_delay) 844 if (do_delay)
845 msleep(delay); 845 msleep(delay);
846 return delay; 846 return delay;
847 } 847 }
848 848
849 static int hub_hub_status(struct usb_hub *hub, 849 static int hub_hub_status(struct usb_hub *hub,
850 u16 *status, u16 *change) 850 u16 *status, u16 *change)
851 { 851 {
852 int ret; 852 int ret;
853 853
854 mutex_lock(&hub->status_mutex); 854 mutex_lock(&hub->status_mutex);
855 ret = get_hub_status(hub->hdev, &hub->status->hub); 855 ret = get_hub_status(hub->hdev, &hub->status->hub);
856 if (ret < 0) { 856 if (ret < 0) {
857 if (ret != -ENODEV) 857 if (ret != -ENODEV)
858 dev_err(hub->intfdev, 858 dev_err(hub->intfdev,
859 "%s failed (err = %d)\n", __func__, ret); 859 "%s failed (err = %d)\n", __func__, ret);
860 } else { 860 } else {
861 *status = le16_to_cpu(hub->status->hub.wHubStatus); 861 *status = le16_to_cpu(hub->status->hub.wHubStatus);
862 *change = le16_to_cpu(hub->status->hub.wHubChange); 862 *change = le16_to_cpu(hub->status->hub.wHubChange);
863 ret = 0; 863 ret = 0;
864 } 864 }
865 mutex_unlock(&hub->status_mutex); 865 mutex_unlock(&hub->status_mutex);
866 return ret; 866 return ret;
867 } 867 }
868 868
869 static int hub_set_port_link_state(struct usb_hub *hub, int port1, 869 static int hub_set_port_link_state(struct usb_hub *hub, int port1,
870 unsigned int link_status) 870 unsigned int link_status)
871 { 871 {
872 return set_port_feature(hub->hdev, 872 return set_port_feature(hub->hdev,
873 port1 | (link_status << 3), 873 port1 | (link_status << 3),
874 USB_PORT_FEAT_LINK_STATE); 874 USB_PORT_FEAT_LINK_STATE);
875 } 875 }
876 876
877 /* 877 /*
878 * If USB 3.0 ports are placed into the Disabled state, they will no longer 878 * If USB 3.0 ports are placed into the Disabled state, they will no longer
879 * detect any device connects or disconnects. This is generally not what the 879 * detect any device connects or disconnects. This is generally not what the
880 * USB core wants, since it expects a disabled port to produce a port status 880 * USB core wants, since it expects a disabled port to produce a port status
881 * change event when a new device connects. 881 * change event when a new device connects.
882 * 882 *
883 * Instead, set the link state to Disabled, wait for the link to settle into 883 * Instead, set the link state to Disabled, wait for the link to settle into
884 * that state, clear any change bits, and then put the port into the RxDetect 884 * that state, clear any change bits, and then put the port into the RxDetect
885 * state. 885 * state.
886 */ 886 */
887 static int hub_usb3_port_disable(struct usb_hub *hub, int port1) 887 static int hub_usb3_port_disable(struct usb_hub *hub, int port1)
888 { 888 {
889 int ret; 889 int ret;
890 int total_time; 890 int total_time;
891 u16 portchange, portstatus; 891 u16 portchange, portstatus;
892 892
893 if (!hub_is_superspeed(hub->hdev)) 893 if (!hub_is_superspeed(hub->hdev))
894 return -EINVAL; 894 return -EINVAL;
895 895
896 ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); 896 ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED);
897 if (ret) 897 if (ret)
898 return ret; 898 return ret;
899 899
900 /* Wait for the link to enter the disabled state. */ 900 /* Wait for the link to enter the disabled state. */
901 for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { 901 for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) {
902 ret = hub_port_status(hub, port1, &portstatus, &portchange); 902 ret = hub_port_status(hub, port1, &portstatus, &portchange);
903 if (ret < 0) 903 if (ret < 0)
904 return ret; 904 return ret;
905 905
906 if ((portstatus & USB_PORT_STAT_LINK_STATE) == 906 if ((portstatus & USB_PORT_STAT_LINK_STATE) ==
907 USB_SS_PORT_LS_SS_DISABLED) 907 USB_SS_PORT_LS_SS_DISABLED)
908 break; 908 break;
909 if (total_time >= HUB_DEBOUNCE_TIMEOUT) 909 if (total_time >= HUB_DEBOUNCE_TIMEOUT)
910 break; 910 break;
911 msleep(HUB_DEBOUNCE_STEP); 911 msleep(HUB_DEBOUNCE_STEP);
912 } 912 }
913 if (total_time >= HUB_DEBOUNCE_TIMEOUT) 913 if (total_time >= HUB_DEBOUNCE_TIMEOUT)
914 dev_warn(hub->intfdev, "Could not disable port %d after %d ms\n", 914 dev_warn(hub->intfdev, "Could not disable port %d after %d ms\n",
915 port1, total_time); 915 port1, total_time);
916 916
917 return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT); 917 return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT);
918 } 918 }
919 919
920 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) 920 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
921 { 921 {
922 struct usb_device *hdev = hub->hdev; 922 struct usb_device *hdev = hub->hdev;
923 int ret = 0; 923 int ret = 0;
924 924
925 if (hub->ports[port1 - 1]->child && set_state) 925 if (hub->ports[port1 - 1]->child && set_state)
926 usb_set_device_state(hub->ports[port1 - 1]->child, 926 usb_set_device_state(hub->ports[port1 - 1]->child,
927 USB_STATE_NOTATTACHED); 927 USB_STATE_NOTATTACHED);
928 if (!hub->error) { 928 if (!hub->error) {
929 if (hub_is_superspeed(hub->hdev)) 929 if (hub_is_superspeed(hub->hdev))
930 ret = hub_usb3_port_disable(hub, port1); 930 ret = hub_usb3_port_disable(hub, port1);
931 else 931 else
932 ret = usb_clear_port_feature(hdev, port1, 932 ret = usb_clear_port_feature(hdev, port1,
933 USB_PORT_FEAT_ENABLE); 933 USB_PORT_FEAT_ENABLE);
934 } 934 }
935 if (ret && ret != -ENODEV) 935 if (ret && ret != -ENODEV)
936 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", 936 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
937 port1, ret); 937 port1, ret);
938 return ret; 938 return ret;
939 } 939 }
940 940
941 /* 941 /*
942 * Disable a port and mark a logical connect-change event, so that some 942 * Disable a port and mark a logical connect-change event, so that some
943 * time later khubd will disconnect() any existing usb_device on the port 943 * time later khubd will disconnect() any existing usb_device on the port
944 * and will re-enumerate if there actually is a device attached. 944 * and will re-enumerate if there actually is a device attached.
945 */ 945 */
946 static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) 946 static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
947 { 947 {
948 dev_dbg(hub->intfdev, "logical disconnect on port %d\n", port1); 948 dev_dbg(hub->intfdev, "logical disconnect on port %d\n", port1);
949 hub_port_disable(hub, port1, 1); 949 hub_port_disable(hub, port1, 1);
950 950
951 /* FIXME let caller ask to power down the port: 951 /* FIXME let caller ask to power down the port:
952 * - some devices won't enumerate without a VBUS power cycle 952 * - some devices won't enumerate without a VBUS power cycle
953 * - SRP saves power that way 953 * - SRP saves power that way
954 * - ... new call, TBD ... 954 * - ... new call, TBD ...
955 * That's easy if this hub can switch power per-port, and 955 * That's easy if this hub can switch power per-port, and
956 * khubd reactivates the port later (timer, SRP, etc). 956 * khubd reactivates the port later (timer, SRP, etc).
957 * Powerdown must be optional, because of reset/DFU. 957 * Powerdown must be optional, because of reset/DFU.
958 */ 958 */
959 959
960 set_bit(port1, hub->change_bits); 960 set_bit(port1, hub->change_bits);
961 kick_khubd(hub); 961 kick_khubd(hub);
962 } 962 }
963 963
964 /** 964 /**
965 * usb_remove_device - disable a device's port on its parent hub 965 * usb_remove_device - disable a device's port on its parent hub
966 * @udev: device to be disabled and removed 966 * @udev: device to be disabled and removed
967 * Context: @udev locked, must be able to sleep. 967 * Context: @udev locked, must be able to sleep.
968 * 968 *
969 * After @udev's port has been disabled, khubd is notified and it will 969 * After @udev's port has been disabled, khubd is notified and it will
970 * see that the device has been disconnected. When the device is 970 * see that the device has been disconnected. When the device is
971 * physically unplugged and something is plugged in, the events will 971 * physically unplugged and something is plugged in, the events will
972 * be received and processed normally. 972 * be received and processed normally.
973 * 973 *
974 * Return: 0 if successful. A negative error code otherwise. 974 * Return: 0 if successful. A negative error code otherwise.
975 */ 975 */
976 int usb_remove_device(struct usb_device *udev) 976 int usb_remove_device(struct usb_device *udev)
977 { 977 {
978 struct usb_hub *hub; 978 struct usb_hub *hub;
979 struct usb_interface *intf; 979 struct usb_interface *intf;
980 980
981 if (!udev->parent) /* Can't remove a root hub */ 981 if (!udev->parent) /* Can't remove a root hub */
982 return -EINVAL; 982 return -EINVAL;
983 hub = usb_hub_to_struct_hub(udev->parent); 983 hub = usb_hub_to_struct_hub(udev->parent);
984 intf = to_usb_interface(hub->intfdev); 984 intf = to_usb_interface(hub->intfdev);
985 985
986 usb_autopm_get_interface(intf); 986 usb_autopm_get_interface(intf);
987 set_bit(udev->portnum, hub->removed_bits); 987 set_bit(udev->portnum, hub->removed_bits);
988 hub_port_logical_disconnect(hub, udev->portnum); 988 hub_port_logical_disconnect(hub, udev->portnum);
989 usb_autopm_put_interface(intf); 989 usb_autopm_put_interface(intf);
990 return 0; 990 return 0;
991 } 991 }
992 992
993 enum hub_activation_type { 993 enum hub_activation_type {
994 HUB_INIT, HUB_INIT2, HUB_INIT3, /* INITs must come first */ 994 HUB_INIT, HUB_INIT2, HUB_INIT3, /* INITs must come first */
995 HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME, 995 HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME,
996 }; 996 };
997 997
998 static void hub_init_func2(struct work_struct *ws); 998 static void hub_init_func2(struct work_struct *ws);
999 static void hub_init_func3(struct work_struct *ws); 999 static void hub_init_func3(struct work_struct *ws);
1000 1000
1001 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) 1001 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
1002 { 1002 {
1003 struct usb_device *hdev = hub->hdev; 1003 struct usb_device *hdev = hub->hdev;
1004 struct usb_hcd *hcd; 1004 struct usb_hcd *hcd;
1005 int ret; 1005 int ret;
1006 int port1; 1006 int port1;
1007 int status; 1007 int status;
1008 bool need_debounce_delay = false; 1008 bool need_debounce_delay = false;
1009 unsigned delay; 1009 unsigned delay;
1010 1010
1011 /* Continue a partial initialization */ 1011 /* Continue a partial initialization */
1012 if (type == HUB_INIT2) 1012 if (type == HUB_INIT2)
1013 goto init2; 1013 goto init2;
1014 if (type == HUB_INIT3) 1014 if (type == HUB_INIT3)
1015 goto init3; 1015 goto init3;
1016 1016
1017 /* The superspeed hub except for root hub has to use Hub Depth 1017 /* The superspeed hub except for root hub has to use Hub Depth
1018 * value as an offset into the route string to locate the bits 1018 * value as an offset into the route string to locate the bits
1019 * it uses to determine the downstream port number. So hub driver 1019 * it uses to determine the downstream port number. So hub driver
1020 * should send a set hub depth request to superspeed hub after 1020 * should send a set hub depth request to superspeed hub after
1021 * the superspeed hub is set configuration in initialization or 1021 * the superspeed hub is set configuration in initialization or
1022 * reset procedure. 1022 * reset procedure.
1023 * 1023 *
1024 * After a resume, port power should still be on. 1024 * After a resume, port power should still be on.
1025 * For any other type of activation, turn it on. 1025 * For any other type of activation, turn it on.
1026 */ 1026 */
1027 if (type != HUB_RESUME) { 1027 if (type != HUB_RESUME) {
1028 if (hdev->parent && hub_is_superspeed(hdev)) { 1028 if (hdev->parent && hub_is_superspeed(hdev)) {
1029 ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), 1029 ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
1030 HUB_SET_DEPTH, USB_RT_HUB, 1030 HUB_SET_DEPTH, USB_RT_HUB,
1031 hdev->level - 1, 0, NULL, 0, 1031 hdev->level - 1, 0, NULL, 0,
1032 USB_CTRL_SET_TIMEOUT); 1032 USB_CTRL_SET_TIMEOUT);
1033 if (ret < 0) 1033 if (ret < 0)
1034 dev_err(hub->intfdev, 1034 dev_err(hub->intfdev,
1035 "set hub depth failed\n"); 1035 "set hub depth failed\n");
1036 } 1036 }
1037 1037
1038 /* Speed up system boot by using a delayed_work for the 1038 /* Speed up system boot by using a delayed_work for the
1039 * hub's initial power-up delays. This is pretty awkward 1039 * hub's initial power-up delays. This is pretty awkward
1040 * and the implementation looks like a home-brewed sort of 1040 * and the implementation looks like a home-brewed sort of
1041 * setjmp/longjmp, but it saves at least 100 ms for each 1041 * setjmp/longjmp, but it saves at least 100 ms for each
1042 * root hub (assuming usbcore is compiled into the kernel 1042 * root hub (assuming usbcore is compiled into the kernel
1043 * rather than as a module). It adds up. 1043 * rather than as a module). It adds up.
1044 * 1044 *
1045 * This can't be done for HUB_RESUME or HUB_RESET_RESUME 1045 * This can't be done for HUB_RESUME or HUB_RESET_RESUME
1046 * because for those activation types the ports have to be 1046 * because for those activation types the ports have to be
1047 * operational when we return. In theory this could be done 1047 * operational when we return. In theory this could be done
1048 * for HUB_POST_RESET, but it's easier not to. 1048 * for HUB_POST_RESET, but it's easier not to.
1049 */ 1049 */
1050 if (type == HUB_INIT) { 1050 if (type == HUB_INIT) {
1051 delay = hub_power_on(hub, false); 1051 delay = hub_power_on(hub, false);
1052 INIT_DELAYED_WORK(&hub->init_work, hub_init_func2); 1052 INIT_DELAYED_WORK(&hub->init_work, hub_init_func2);
1053 queue_delayed_work(system_power_efficient_wq, 1053 queue_delayed_work(system_power_efficient_wq,
1054 &hub->init_work, 1054 &hub->init_work,
1055 msecs_to_jiffies(delay)); 1055 msecs_to_jiffies(delay));
1056 1056
1057 /* Suppress autosuspend until init is done */ 1057 /* Suppress autosuspend until init is done */
1058 usb_autopm_get_interface_no_resume( 1058 usb_autopm_get_interface_no_resume(
1059 to_usb_interface(hub->intfdev)); 1059 to_usb_interface(hub->intfdev));
1060 return; /* Continues at init2: below */ 1060 return; /* Continues at init2: below */
1061 } else if (type == HUB_RESET_RESUME) { 1061 } else if (type == HUB_RESET_RESUME) {
1062 /* The internal host controller state for the hub device 1062 /* The internal host controller state for the hub device
1063 * may be gone after a host power loss on system resume. 1063 * may be gone after a host power loss on system resume.
1064 * Update the device's info so the HW knows it's a hub. 1064 * Update the device's info so the HW knows it's a hub.
1065 */ 1065 */
1066 hcd = bus_to_hcd(hdev->bus); 1066 hcd = bus_to_hcd(hdev->bus);
1067 if (hcd->driver->update_hub_device) { 1067 if (hcd->driver->update_hub_device) {
1068 ret = hcd->driver->update_hub_device(hcd, hdev, 1068 ret = hcd->driver->update_hub_device(hcd, hdev,
1069 &hub->tt, GFP_NOIO); 1069 &hub->tt, GFP_NOIO);
1070 if (ret < 0) { 1070 if (ret < 0) {
1071 dev_err(hub->intfdev, "Host not " 1071 dev_err(hub->intfdev, "Host not "
1072 "accepting hub info " 1072 "accepting hub info "
1073 "update.\n"); 1073 "update.\n");
1074 dev_err(hub->intfdev, "LS/FS devices " 1074 dev_err(hub->intfdev, "LS/FS devices "
1075 "and hubs may not work " 1075 "and hubs may not work "
1076 "under this hub\n."); 1076 "under this hub\n.");
1077 } 1077 }
1078 } 1078 }
1079 hub_power_on(hub, true); 1079 hub_power_on(hub, true);
1080 } else { 1080 } else {
1081 hub_power_on(hub, true); 1081 hub_power_on(hub, true);
1082 } 1082 }
1083 } 1083 }
1084 init2: 1084 init2:
1085 1085
1086 /* Check each port and set hub->change_bits to let khubd know 1086 /* Check each port and set hub->change_bits to let khubd know
1087 * which ports need attention. 1087 * which ports need attention.
1088 */ 1088 */
1089 for (port1 = 1; port1 <= hdev->maxchild; ++port1) { 1089 for (port1 = 1; port1 <= hdev->maxchild; ++port1) {
1090 struct usb_device *udev = hub->ports[port1 - 1]->child; 1090 struct usb_device *udev = hub->ports[port1 - 1]->child;
1091 u16 portstatus, portchange; 1091 u16 portstatus, portchange;
1092 1092
1093 portstatus = portchange = 0; 1093 portstatus = portchange = 0;
1094 status = hub_port_status(hub, port1, &portstatus, &portchange); 1094 status = hub_port_status(hub, port1, &portstatus, &portchange);
1095 if (udev || (portstatus & USB_PORT_STAT_CONNECTION)) 1095 if (udev || (portstatus & USB_PORT_STAT_CONNECTION))
1096 dev_dbg(hub->intfdev, 1096 dev_dbg(hub->intfdev,
1097 "port %d: status %04x change %04x\n", 1097 "port %d: status %04x change %04x\n",
1098 port1, portstatus, portchange); 1098 port1, portstatus, portchange);
1099 1099
1100 /* After anything other than HUB_RESUME (i.e., initialization 1100 /* After anything other than HUB_RESUME (i.e., initialization
1101 * or any sort of reset), every port should be disabled. 1101 * or any sort of reset), every port should be disabled.
1102 * Unconnected ports should likewise be disabled (paranoia), 1102 * Unconnected ports should likewise be disabled (paranoia),
1103 * and so should ports for which we have no usb_device. 1103 * and so should ports for which we have no usb_device.
1104 */ 1104 */
1105 if ((portstatus & USB_PORT_STAT_ENABLE) && ( 1105 if ((portstatus & USB_PORT_STAT_ENABLE) && (
1106 type != HUB_RESUME || 1106 type != HUB_RESUME ||
1107 !(portstatus & USB_PORT_STAT_CONNECTION) || 1107 !(portstatus & USB_PORT_STAT_CONNECTION) ||
1108 !udev || 1108 !udev ||
1109 udev->state == USB_STATE_NOTATTACHED)) { 1109 udev->state == USB_STATE_NOTATTACHED)) {
1110 /* 1110 /*
1111 * USB3 protocol ports will automatically transition 1111 * USB3 protocol ports will automatically transition
1112 * to Enabled state when detect an USB3.0 device attach. 1112 * to Enabled state when detect an USB3.0 device attach.
1113 * Do not disable USB3 protocol ports, just pretend 1113 * Do not disable USB3 protocol ports, just pretend
1114 * power was lost 1114 * power was lost
1115 */ 1115 */
1116 portstatus &= ~USB_PORT_STAT_ENABLE; 1116 portstatus &= ~USB_PORT_STAT_ENABLE;
1117 if (!hub_is_superspeed(hdev)) 1117 if (!hub_is_superspeed(hdev))
1118 usb_clear_port_feature(hdev, port1, 1118 usb_clear_port_feature(hdev, port1,
1119 USB_PORT_FEAT_ENABLE); 1119 USB_PORT_FEAT_ENABLE);
1120 } 1120 }
1121 1121
1122 /* Clear status-change flags; we'll debounce later */ 1122 /* Clear status-change flags; we'll debounce later */
1123 if (portchange & USB_PORT_STAT_C_CONNECTION) { 1123 if (portchange & USB_PORT_STAT_C_CONNECTION) {
1124 need_debounce_delay = true; 1124 need_debounce_delay = true;
1125 usb_clear_port_feature(hub->hdev, port1, 1125 usb_clear_port_feature(hub->hdev, port1,
1126 USB_PORT_FEAT_C_CONNECTION); 1126 USB_PORT_FEAT_C_CONNECTION);
1127 } 1127 }
1128 if (portchange & USB_PORT_STAT_C_ENABLE) { 1128 if (portchange & USB_PORT_STAT_C_ENABLE) {
1129 need_debounce_delay = true; 1129 need_debounce_delay = true;
1130 usb_clear_port_feature(hub->hdev, port1, 1130 usb_clear_port_feature(hub->hdev, port1,
1131 USB_PORT_FEAT_C_ENABLE); 1131 USB_PORT_FEAT_C_ENABLE);
1132 } 1132 }
1133 if (portchange & USB_PORT_STAT_C_RESET) { 1133 if (portchange & USB_PORT_STAT_C_RESET) {
1134 need_debounce_delay = true; 1134 need_debounce_delay = true;
1135 usb_clear_port_feature(hub->hdev, port1, 1135 usb_clear_port_feature(hub->hdev, port1,
1136 USB_PORT_FEAT_C_RESET); 1136 USB_PORT_FEAT_C_RESET);
1137 } 1137 }
1138 if ((portchange & USB_PORT_STAT_C_BH_RESET) && 1138 if ((portchange & USB_PORT_STAT_C_BH_RESET) &&
1139 hub_is_superspeed(hub->hdev)) { 1139 hub_is_superspeed(hub->hdev)) {
1140 need_debounce_delay = true; 1140 need_debounce_delay = true;
1141 usb_clear_port_feature(hub->hdev, port1, 1141 usb_clear_port_feature(hub->hdev, port1,
1142 USB_PORT_FEAT_C_BH_PORT_RESET); 1142 USB_PORT_FEAT_C_BH_PORT_RESET);
1143 } 1143 }
1144 /* We can forget about a "removed" device when there's a 1144 /* We can forget about a "removed" device when there's a
1145 * physical disconnect or the connect status changes. 1145 * physical disconnect or the connect status changes.
1146 */ 1146 */
1147 if (!(portstatus & USB_PORT_STAT_CONNECTION) || 1147 if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
1148 (portchange & USB_PORT_STAT_C_CONNECTION)) 1148 (portchange & USB_PORT_STAT_C_CONNECTION))
1149 clear_bit(port1, hub->removed_bits); 1149 clear_bit(port1, hub->removed_bits);
1150 1150
1151 if (!udev || udev->state == USB_STATE_NOTATTACHED) { 1151 if (!udev || udev->state == USB_STATE_NOTATTACHED) {
1152 /* Tell khubd to disconnect the device or 1152 /* Tell khubd to disconnect the device or
1153 * check for a new connection 1153 * check for a new connection
1154 */ 1154 */
1155 if (udev || (portstatus & USB_PORT_STAT_CONNECTION) || 1155 if (udev || (portstatus & USB_PORT_STAT_CONNECTION) ||
1156 (portstatus & USB_PORT_STAT_OVERCURRENT)) 1156 (portstatus & USB_PORT_STAT_OVERCURRENT))
1157 set_bit(port1, hub->change_bits); 1157 set_bit(port1, hub->change_bits);
1158 1158
1159 } else if (portstatus & USB_PORT_STAT_ENABLE) { 1159 } else if (portstatus & USB_PORT_STAT_ENABLE) {
1160 bool port_resumed = (portstatus & 1160 bool port_resumed = (portstatus &
1161 USB_PORT_STAT_LINK_STATE) == 1161 USB_PORT_STAT_LINK_STATE) ==
1162 USB_SS_PORT_LS_U0; 1162 USB_SS_PORT_LS_U0;
1163 /* The power session apparently survived the resume. 1163 /* The power session apparently survived the resume.
1164 * If there was an overcurrent or suspend change 1164 * If there was an overcurrent or suspend change
1165 * (i.e., remote wakeup request), have khubd 1165 * (i.e., remote wakeup request), have khubd
1166 * take care of it. Look at the port link state 1166 * take care of it. Look at the port link state
1167 * for USB 3.0 hubs, since they don't have a suspend 1167 * for USB 3.0 hubs, since they don't have a suspend
1168 * change bit, and they don't set the port link change 1168 * change bit, and they don't set the port link change
1169 * bit on device-initiated resume. 1169 * bit on device-initiated resume.
1170 */ 1170 */
1171 if (portchange || (hub_is_superspeed(hub->hdev) && 1171 if (portchange || (hub_is_superspeed(hub->hdev) &&
1172 port_resumed)) 1172 port_resumed))
1173 set_bit(port1, hub->change_bits); 1173 set_bit(port1, hub->change_bits);
1174 1174
1175 } else if (udev->persist_enabled) { 1175 } else if (udev->persist_enabled) {
1176 struct usb_port *port_dev = hub->ports[port1 - 1]; 1176 struct usb_port *port_dev = hub->ports[port1 - 1];
1177 1177
1178 #ifdef CONFIG_PM 1178 #ifdef CONFIG_PM
1179 udev->reset_resume = 1; 1179 udev->reset_resume = 1;
1180 #endif 1180 #endif
1181 /* Don't set the change_bits when the device 1181 /* Don't set the change_bits when the device
1182 * was powered off. 1182 * was powered off.
1183 */ 1183 */
1184 if (port_dev->power_is_on) 1184 if (port_dev->power_is_on)
1185 set_bit(port1, hub->change_bits); 1185 set_bit(port1, hub->change_bits);
1186 1186
1187 } else { 1187 } else {
1188 /* The power session is gone; tell khubd */ 1188 /* The power session is gone; tell khubd */
1189 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1189 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
1190 set_bit(port1, hub->change_bits); 1190 set_bit(port1, hub->change_bits);
1191 } 1191 }
1192 } 1192 }
1193 1193
1194 /* If no port-status-change flags were set, we don't need any 1194 /* If no port-status-change flags were set, we don't need any
1195 * debouncing. If flags were set we can try to debounce the 1195 * debouncing. If flags were set we can try to debounce the
1196 * ports all at once right now, instead of letting khubd do them 1196 * ports all at once right now, instead of letting khubd do them
1197 * one at a time later on. 1197 * one at a time later on.
1198 * 1198 *
1199 * If any port-status changes do occur during this delay, khubd 1199 * If any port-status changes do occur during this delay, khubd
1200 * will see them later and handle them normally. 1200 * will see them later and handle them normally.
1201 */ 1201 */
1202 if (need_debounce_delay) { 1202 if (need_debounce_delay) {
1203 delay = HUB_DEBOUNCE_STABLE; 1203 delay = HUB_DEBOUNCE_STABLE;
1204 1204
1205 /* Don't do a long sleep inside a workqueue routine */ 1205 /* Don't do a long sleep inside a workqueue routine */
1206 if (type == HUB_INIT2) { 1206 if (type == HUB_INIT2) {
1207 INIT_DELAYED_WORK(&hub->init_work, hub_init_func3); 1207 INIT_DELAYED_WORK(&hub->init_work, hub_init_func3);
1208 queue_delayed_work(system_power_efficient_wq, 1208 queue_delayed_work(system_power_efficient_wq,
1209 &hub->init_work, 1209 &hub->init_work,
1210 msecs_to_jiffies(delay)); 1210 msecs_to_jiffies(delay));
1211 return; /* Continues at init3: below */ 1211 return; /* Continues at init3: below */
1212 } else { 1212 } else {
1213 msleep(delay); 1213 msleep(delay);
1214 } 1214 }
1215 } 1215 }
1216 init3: 1216 init3:
1217 hub->quiescing = 0; 1217 hub->quiescing = 0;
1218 1218
1219 status = usb_submit_urb(hub->urb, GFP_NOIO); 1219 status = usb_submit_urb(hub->urb, GFP_NOIO);
1220 if (status < 0) 1220 if (status < 0)
1221 dev_err(hub->intfdev, "activate --> %d\n", status); 1221 dev_err(hub->intfdev, "activate --> %d\n", status);
1222 if (hub->has_indicators && blinkenlights) 1222 if (hub->has_indicators && blinkenlights)
1223 queue_delayed_work(system_power_efficient_wq, 1223 queue_delayed_work(system_power_efficient_wq,
1224 &hub->leds, LED_CYCLE_PERIOD); 1224 &hub->leds, LED_CYCLE_PERIOD);
1225 1225
1226 /* Scan all ports that need attention */ 1226 /* Scan all ports that need attention */
1227 kick_khubd(hub); 1227 kick_khubd(hub);
1228 1228
1229 /* Allow autosuspend if it was suppressed */ 1229 /* Allow autosuspend if it was suppressed */
1230 if (type <= HUB_INIT3) 1230 if (type <= HUB_INIT3)
1231 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); 1231 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev));
1232 } 1232 }
1233 1233
1234 /* Implement the continuations for the delays above */ 1234 /* Implement the continuations for the delays above */
1235 static void hub_init_func2(struct work_struct *ws) 1235 static void hub_init_func2(struct work_struct *ws)
1236 { 1236 {
1237 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); 1237 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work);
1238 1238
1239 hub_activate(hub, HUB_INIT2); 1239 hub_activate(hub, HUB_INIT2);
1240 } 1240 }
1241 1241
1242 static void hub_init_func3(struct work_struct *ws) 1242 static void hub_init_func3(struct work_struct *ws)
1243 { 1243 {
1244 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); 1244 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work);
1245 1245
1246 hub_activate(hub, HUB_INIT3); 1246 hub_activate(hub, HUB_INIT3);
1247 } 1247 }
1248 1248
1249 enum hub_quiescing_type { 1249 enum hub_quiescing_type {
1250 HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND 1250 HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND
1251 }; 1251 };
1252 1252
1253 static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) 1253 static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
1254 { 1254 {
1255 struct usb_device *hdev = hub->hdev; 1255 struct usb_device *hdev = hub->hdev;
1256 int i; 1256 int i;
1257 1257
1258 cancel_delayed_work_sync(&hub->init_work); 1258 cancel_delayed_work_sync(&hub->init_work);
1259 1259
1260 /* khubd and related activity won't re-trigger */ 1260 /* khubd and related activity won't re-trigger */
1261 hub->quiescing = 1; 1261 hub->quiescing = 1;
1262 1262
1263 if (type != HUB_SUSPEND) { 1263 if (type != HUB_SUSPEND) {
1264 /* Disconnect all the children */ 1264 /* Disconnect all the children */
1265 for (i = 0; i < hdev->maxchild; ++i) { 1265 for (i = 0; i < hdev->maxchild; ++i) {
1266 if (hub->ports[i]->child) 1266 if (hub->ports[i]->child)
1267 usb_disconnect(&hub->ports[i]->child); 1267 usb_disconnect(&hub->ports[i]->child);
1268 } 1268 }
1269 } 1269 }
1270 1270
1271 /* Stop khubd and related activity */ 1271 /* Stop khubd and related activity */
1272 usb_kill_urb(hub->urb); 1272 usb_kill_urb(hub->urb);
1273 if (hub->has_indicators) 1273 if (hub->has_indicators)
1274 cancel_delayed_work_sync(&hub->leds); 1274 cancel_delayed_work_sync(&hub->leds);
1275 if (hub->tt.hub) 1275 if (hub->tt.hub)
1276 flush_work(&hub->tt.clear_work); 1276 flush_work(&hub->tt.clear_work);
1277 } 1277 }
1278 1278
1279 /* caller has locked the hub device */ 1279 /* caller has locked the hub device */
1280 static int hub_pre_reset(struct usb_interface *intf) 1280 static int hub_pre_reset(struct usb_interface *intf)
1281 { 1281 {
1282 struct usb_hub *hub = usb_get_intfdata(intf); 1282 struct usb_hub *hub = usb_get_intfdata(intf);
1283 1283
1284 hub_quiesce(hub, HUB_PRE_RESET); 1284 hub_quiesce(hub, HUB_PRE_RESET);
1285 return 0; 1285 return 0;
1286 } 1286 }
1287 1287
1288 /* caller has locked the hub device */ 1288 /* caller has locked the hub device */
1289 static int hub_post_reset(struct usb_interface *intf) 1289 static int hub_post_reset(struct usb_interface *intf)
1290 { 1290 {
1291 struct usb_hub *hub = usb_get_intfdata(intf); 1291 struct usb_hub *hub = usb_get_intfdata(intf);
1292 1292
1293 hub_activate(hub, HUB_POST_RESET); 1293 hub_activate(hub, HUB_POST_RESET);
1294 return 0; 1294 return 0;
1295 } 1295 }
1296 1296
1297 static int hub_configure(struct usb_hub *hub, 1297 static int hub_configure(struct usb_hub *hub,
1298 struct usb_endpoint_descriptor *endpoint) 1298 struct usb_endpoint_descriptor *endpoint)
1299 { 1299 {
1300 struct usb_hcd *hcd; 1300 struct usb_hcd *hcd;
1301 struct usb_device *hdev = hub->hdev; 1301 struct usb_device *hdev = hub->hdev;
1302 struct device *hub_dev = hub->intfdev; 1302 struct device *hub_dev = hub->intfdev;
1303 u16 hubstatus, hubchange; 1303 u16 hubstatus, hubchange;
1304 u16 wHubCharacteristics; 1304 u16 wHubCharacteristics;
1305 unsigned int pipe; 1305 unsigned int pipe;
1306 int maxp, ret, i; 1306 int maxp, ret, i;
1307 char *message = "out of memory"; 1307 char *message = "out of memory";
1308 unsigned unit_load; 1308 unsigned unit_load;
1309 unsigned full_load; 1309 unsigned full_load;
1310 1310
1311 hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); 1311 hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL);
1312 if (!hub->buffer) { 1312 if (!hub->buffer) {
1313 ret = -ENOMEM; 1313 ret = -ENOMEM;
1314 goto fail; 1314 goto fail;
1315 } 1315 }
1316 1316
1317 hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL); 1317 hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL);
1318 if (!hub->status) { 1318 if (!hub->status) {
1319 ret = -ENOMEM; 1319 ret = -ENOMEM;
1320 goto fail; 1320 goto fail;
1321 } 1321 }
1322 mutex_init(&hub->status_mutex); 1322 mutex_init(&hub->status_mutex);
1323 1323
1324 hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL); 1324 hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL);
1325 if (!hub->descriptor) { 1325 if (!hub->descriptor) {
1326 ret = -ENOMEM; 1326 ret = -ENOMEM;
1327 goto fail; 1327 goto fail;
1328 } 1328 }
1329 1329
1330 /* Request the entire hub descriptor. 1330 /* Request the entire hub descriptor.
1331 * hub->descriptor can handle USB_MAXCHILDREN ports, 1331 * hub->descriptor can handle USB_MAXCHILDREN ports,
1332 * but the hub can/will return fewer bytes here. 1332 * but the hub can/will return fewer bytes here.
1333 */ 1333 */
1334 ret = get_hub_descriptor(hdev, hub->descriptor); 1334 ret = get_hub_descriptor(hdev, hub->descriptor);
1335 if (ret < 0) { 1335 if (ret < 0) {
1336 message = "can't read hub descriptor"; 1336 message = "can't read hub descriptor";
1337 goto fail; 1337 goto fail;
1338 } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) { 1338 } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) {
1339 message = "hub has too many ports!"; 1339 message = "hub has too many ports!";
1340 ret = -ENODEV; 1340 ret = -ENODEV;
1341 goto fail; 1341 goto fail;
1342 } else if (hub->descriptor->bNbrPorts == 0) { 1342 } else if (hub->descriptor->bNbrPorts == 0) {
1343 message = "hub doesn't have any ports!"; 1343 message = "hub doesn't have any ports!";
1344 ret = -ENODEV; 1344 ret = -ENODEV;
1345 goto fail; 1345 goto fail;
1346 } 1346 }
1347 1347
1348 hdev->maxchild = hub->descriptor->bNbrPorts; 1348 hdev->maxchild = hub->descriptor->bNbrPorts;
1349 dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, 1349 dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild,
1350 (hdev->maxchild == 1) ? "" : "s"); 1350 (hdev->maxchild == 1) ? "" : "s");
1351 1351
1352 hub->ports = kzalloc(hdev->maxchild * sizeof(struct usb_port *), 1352 hub->ports = kzalloc(hdev->maxchild * sizeof(struct usb_port *),
1353 GFP_KERNEL); 1353 GFP_KERNEL);
1354 if (!hub->ports) { 1354 if (!hub->ports) {
1355 ret = -ENOMEM; 1355 ret = -ENOMEM;
1356 goto fail; 1356 goto fail;
1357 } 1357 }
1358 1358
1359 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); 1359 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
1360 if (hub_is_superspeed(hdev)) { 1360 if (hub_is_superspeed(hdev)) {
1361 unit_load = 150; 1361 unit_load = 150;
1362 full_load = 900; 1362 full_load = 900;
1363 } else { 1363 } else {
1364 unit_load = 100; 1364 unit_load = 100;
1365 full_load = 500; 1365 full_load = 500;
1366 } 1366 }
1367 1367
1368 /* FIXME for USB 3.0, skip for now */ 1368 /* FIXME for USB 3.0, skip for now */
1369 if ((wHubCharacteristics & HUB_CHAR_COMPOUND) && 1369 if ((wHubCharacteristics & HUB_CHAR_COMPOUND) &&
1370 !(hub_is_superspeed(hdev))) { 1370 !(hub_is_superspeed(hdev))) {
1371 int i; 1371 int i;
1372 char portstr[USB_MAXCHILDREN + 1]; 1372 char portstr[USB_MAXCHILDREN + 1];
1373 1373
1374 for (i = 0; i < hdev->maxchild; i++) 1374 for (i = 0; i < hdev->maxchild; i++)
1375 portstr[i] = hub->descriptor->u.hs.DeviceRemovable 1375 portstr[i] = hub->descriptor->u.hs.DeviceRemovable
1376 [((i + 1) / 8)] & (1 << ((i + 1) % 8)) 1376 [((i + 1) / 8)] & (1 << ((i + 1) % 8))
1377 ? 'F' : 'R'; 1377 ? 'F' : 'R';
1378 portstr[hdev->maxchild] = 0; 1378 portstr[hdev->maxchild] = 0;
1379 dev_dbg(hub_dev, "compound device; port removable status: %s\n", portstr); 1379 dev_dbg(hub_dev, "compound device; port removable status: %s\n", portstr);
1380 } else 1380 } else
1381 dev_dbg(hub_dev, "standalone hub\n"); 1381 dev_dbg(hub_dev, "standalone hub\n");
1382 1382
1383 switch (wHubCharacteristics & HUB_CHAR_LPSM) { 1383 switch (wHubCharacteristics & HUB_CHAR_LPSM) {
1384 case HUB_CHAR_COMMON_LPSM: 1384 case HUB_CHAR_COMMON_LPSM:
1385 dev_dbg(hub_dev, "ganged power switching\n"); 1385 dev_dbg(hub_dev, "ganged power switching\n");
1386 break; 1386 break;
1387 case HUB_CHAR_INDV_PORT_LPSM: 1387 case HUB_CHAR_INDV_PORT_LPSM:
1388 dev_dbg(hub_dev, "individual port power switching\n"); 1388 dev_dbg(hub_dev, "individual port power switching\n");
1389 break; 1389 break;
1390 case HUB_CHAR_NO_LPSM: 1390 case HUB_CHAR_NO_LPSM:
1391 case HUB_CHAR_LPSM: 1391 case HUB_CHAR_LPSM:
1392 dev_dbg(hub_dev, "no power switching (usb 1.0)\n"); 1392 dev_dbg(hub_dev, "no power switching (usb 1.0)\n");
1393 break; 1393 break;
1394 } 1394 }
1395 1395
1396 switch (wHubCharacteristics & HUB_CHAR_OCPM) { 1396 switch (wHubCharacteristics & HUB_CHAR_OCPM) {
1397 case HUB_CHAR_COMMON_OCPM: 1397 case HUB_CHAR_COMMON_OCPM:
1398 dev_dbg(hub_dev, "global over-current protection\n"); 1398 dev_dbg(hub_dev, "global over-current protection\n");
1399 break; 1399 break;
1400 case HUB_CHAR_INDV_PORT_OCPM: 1400 case HUB_CHAR_INDV_PORT_OCPM:
1401 dev_dbg(hub_dev, "individual port over-current protection\n"); 1401 dev_dbg(hub_dev, "individual port over-current protection\n");
1402 break; 1402 break;
1403 case HUB_CHAR_NO_OCPM: 1403 case HUB_CHAR_NO_OCPM:
1404 case HUB_CHAR_OCPM: 1404 case HUB_CHAR_OCPM:
1405 dev_dbg(hub_dev, "no over-current protection\n"); 1405 dev_dbg(hub_dev, "no over-current protection\n");
1406 break; 1406 break;
1407 } 1407 }
1408 1408
1409 spin_lock_init (&hub->tt.lock); 1409 spin_lock_init (&hub->tt.lock);
1410 INIT_LIST_HEAD (&hub->tt.clear_list); 1410 INIT_LIST_HEAD (&hub->tt.clear_list);
1411 INIT_WORK(&hub->tt.clear_work, hub_tt_work); 1411 INIT_WORK(&hub->tt.clear_work, hub_tt_work);
1412 switch (hdev->descriptor.bDeviceProtocol) { 1412 switch (hdev->descriptor.bDeviceProtocol) {
1413 case USB_HUB_PR_FS: 1413 case USB_HUB_PR_FS:
1414 break; 1414 break;
1415 case USB_HUB_PR_HS_SINGLE_TT: 1415 case USB_HUB_PR_HS_SINGLE_TT:
1416 dev_dbg(hub_dev, "Single TT\n"); 1416 dev_dbg(hub_dev, "Single TT\n");
1417 hub->tt.hub = hdev; 1417 hub->tt.hub = hdev;
1418 break; 1418 break;
1419 case USB_HUB_PR_HS_MULTI_TT: 1419 case USB_HUB_PR_HS_MULTI_TT:
1420 ret = usb_set_interface(hdev, 0, 1); 1420 ret = usb_set_interface(hdev, 0, 1);
1421 if (ret == 0) { 1421 if (ret == 0) {
1422 dev_dbg(hub_dev, "TT per port\n"); 1422 dev_dbg(hub_dev, "TT per port\n");
1423 hub->tt.multi = 1; 1423 hub->tt.multi = 1;
1424 } else 1424 } else
1425 dev_err(hub_dev, "Using single TT (err %d)\n", 1425 dev_err(hub_dev, "Using single TT (err %d)\n",
1426 ret); 1426 ret);
1427 hub->tt.hub = hdev; 1427 hub->tt.hub = hdev;
1428 break; 1428 break;
1429 case USB_HUB_PR_SS: 1429 case USB_HUB_PR_SS:
1430 /* USB 3.0 hubs don't have a TT */ 1430 /* USB 3.0 hubs don't have a TT */
1431 break; 1431 break;
1432 default: 1432 default:
1433 dev_dbg(hub_dev, "Unrecognized hub protocol %d\n", 1433 dev_dbg(hub_dev, "Unrecognized hub protocol %d\n",
1434 hdev->descriptor.bDeviceProtocol); 1434 hdev->descriptor.bDeviceProtocol);
1435 break; 1435 break;
1436 } 1436 }
1437 1437
1438 /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ 1438 /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */
1439 switch (wHubCharacteristics & HUB_CHAR_TTTT) { 1439 switch (wHubCharacteristics & HUB_CHAR_TTTT) {
1440 case HUB_TTTT_8_BITS: 1440 case HUB_TTTT_8_BITS:
1441 if (hdev->descriptor.bDeviceProtocol != 0) { 1441 if (hdev->descriptor.bDeviceProtocol != 0) {
1442 hub->tt.think_time = 666; 1442 hub->tt.think_time = 666;
1443 dev_dbg(hub_dev, "TT requires at most %d " 1443 dev_dbg(hub_dev, "TT requires at most %d "
1444 "FS bit times (%d ns)\n", 1444 "FS bit times (%d ns)\n",
1445 8, hub->tt.think_time); 1445 8, hub->tt.think_time);
1446 } 1446 }
1447 break; 1447 break;
1448 case HUB_TTTT_16_BITS: 1448 case HUB_TTTT_16_BITS:
1449 hub->tt.think_time = 666 * 2; 1449 hub->tt.think_time = 666 * 2;
1450 dev_dbg(hub_dev, "TT requires at most %d " 1450 dev_dbg(hub_dev, "TT requires at most %d "
1451 "FS bit times (%d ns)\n", 1451 "FS bit times (%d ns)\n",
1452 16, hub->tt.think_time); 1452 16, hub->tt.think_time);
1453 break; 1453 break;
1454 case HUB_TTTT_24_BITS: 1454 case HUB_TTTT_24_BITS:
1455 hub->tt.think_time = 666 * 3; 1455 hub->tt.think_time = 666 * 3;
1456 dev_dbg(hub_dev, "TT requires at most %d " 1456 dev_dbg(hub_dev, "TT requires at most %d "
1457 "FS bit times (%d ns)\n", 1457 "FS bit times (%d ns)\n",
1458 24, hub->tt.think_time); 1458 24, hub->tt.think_time);
1459 break; 1459 break;
1460 case HUB_TTTT_32_BITS: 1460 case HUB_TTTT_32_BITS:
1461 hub->tt.think_time = 666 * 4; 1461 hub->tt.think_time = 666 * 4;
1462 dev_dbg(hub_dev, "TT requires at most %d " 1462 dev_dbg(hub_dev, "TT requires at most %d "
1463 "FS bit times (%d ns)\n", 1463 "FS bit times (%d ns)\n",
1464 32, hub->tt.think_time); 1464 32, hub->tt.think_time);
1465 break; 1465 break;
1466 } 1466 }
1467 1467
1468 /* probe() zeroes hub->indicator[] */ 1468 /* probe() zeroes hub->indicator[] */
1469 if (wHubCharacteristics & HUB_CHAR_PORTIND) { 1469 if (wHubCharacteristics & HUB_CHAR_PORTIND) {
1470 hub->has_indicators = 1; 1470 hub->has_indicators = 1;
1471 dev_dbg(hub_dev, "Port indicators are supported\n"); 1471 dev_dbg(hub_dev, "Port indicators are supported\n");
1472 } 1472 }
1473 1473
1474 dev_dbg(hub_dev, "power on to power good time: %dms\n", 1474 dev_dbg(hub_dev, "power on to power good time: %dms\n",
1475 hub->descriptor->bPwrOn2PwrGood * 2); 1475 hub->descriptor->bPwrOn2PwrGood * 2);
1476 1476
1477 /* power budgeting mostly matters with bus-powered hubs, 1477 /* power budgeting mostly matters with bus-powered hubs,
1478 * and battery-powered root hubs (may provide just 8 mA). 1478 * and battery-powered root hubs (may provide just 8 mA).
1479 */ 1479 */
1480 ret = usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus); 1480 ret = usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus);
1481 if (ret) { 1481 if (ret) {
1482 message = "can't get hub status"; 1482 message = "can't get hub status";
1483 goto fail; 1483 goto fail;
1484 } 1484 }
1485 hcd = bus_to_hcd(hdev->bus); 1485 hcd = bus_to_hcd(hdev->bus);
1486 if (hdev == hdev->bus->root_hub) { 1486 if (hdev == hdev->bus->root_hub) {
1487 if (hcd->power_budget > 0) 1487 if (hcd->power_budget > 0)
1488 hdev->bus_mA = hcd->power_budget; 1488 hdev->bus_mA = hcd->power_budget;
1489 else 1489 else
1490 hdev->bus_mA = full_load * hdev->maxchild; 1490 hdev->bus_mA = full_load * hdev->maxchild;
1491 if (hdev->bus_mA >= full_load) 1491 if (hdev->bus_mA >= full_load)
1492 hub->mA_per_port = full_load; 1492 hub->mA_per_port = full_load;
1493 else { 1493 else {
1494 hub->mA_per_port = hdev->bus_mA; 1494 hub->mA_per_port = hdev->bus_mA;
1495 hub->limited_power = 1; 1495 hub->limited_power = 1;
1496 } 1496 }
1497 } else if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) { 1497 } else if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) {
1498 int remaining = hdev->bus_mA - 1498 int remaining = hdev->bus_mA -
1499 hub->descriptor->bHubContrCurrent; 1499 hub->descriptor->bHubContrCurrent;
1500 1500
1501 dev_dbg(hub_dev, "hub controller current requirement: %dmA\n", 1501 dev_dbg(hub_dev, "hub controller current requirement: %dmA\n",
1502 hub->descriptor->bHubContrCurrent); 1502 hub->descriptor->bHubContrCurrent);
1503 hub->limited_power = 1; 1503 hub->limited_power = 1;
1504 1504
1505 if (remaining < hdev->maxchild * unit_load) 1505 if (remaining < hdev->maxchild * unit_load)
1506 dev_warn(hub_dev, 1506 dev_warn(hub_dev,
1507 "insufficient power available " 1507 "insufficient power available "
1508 "to use all downstream ports\n"); 1508 "to use all downstream ports\n");
1509 hub->mA_per_port = unit_load; /* 7.2.1 */ 1509 hub->mA_per_port = unit_load; /* 7.2.1 */
1510 1510
1511 } else { /* Self-powered external hub */ 1511 } else { /* Self-powered external hub */
1512 /* FIXME: What about battery-powered external hubs that 1512 /* FIXME: What about battery-powered external hubs that
1513 * provide less current per port? */ 1513 * provide less current per port? */
1514 hub->mA_per_port = full_load; 1514 hub->mA_per_port = full_load;
1515 } 1515 }
1516 if (hub->mA_per_port < full_load) 1516 if (hub->mA_per_port < full_load)
1517 dev_dbg(hub_dev, "%umA bus power budget for each child\n", 1517 dev_dbg(hub_dev, "%umA bus power budget for each child\n",
1518 hub->mA_per_port); 1518 hub->mA_per_port);
1519 1519
1520 /* Update the HCD's internal representation of this hub before khubd 1520 /* Update the HCD's internal representation of this hub before khubd
1521 * starts getting port status changes for devices under the hub. 1521 * starts getting port status changes for devices under the hub.
1522 */ 1522 */
1523 if (hcd->driver->update_hub_device) { 1523 if (hcd->driver->update_hub_device) {
1524 ret = hcd->driver->update_hub_device(hcd, hdev, 1524 ret = hcd->driver->update_hub_device(hcd, hdev,
1525 &hub->tt, GFP_KERNEL); 1525 &hub->tt, GFP_KERNEL);
1526 if (ret < 0) { 1526 if (ret < 0) {
1527 message = "can't update HCD hub info"; 1527 message = "can't update HCD hub info";
1528 goto fail; 1528 goto fail;
1529 } 1529 }
1530 } 1530 }
1531 1531
1532 ret = hub_hub_status(hub, &hubstatus, &hubchange); 1532 ret = hub_hub_status(hub, &hubstatus, &hubchange);
1533 if (ret < 0) { 1533 if (ret < 0) {
1534 message = "can't get hub status"; 1534 message = "can't get hub status";
1535 goto fail; 1535 goto fail;
1536 } 1536 }
1537 1537
1538 /* local power status reports aren't always correct */ 1538 /* local power status reports aren't always correct */
1539 if (hdev->actconfig->desc.bmAttributes & USB_CONFIG_ATT_SELFPOWER) 1539 if (hdev->actconfig->desc.bmAttributes & USB_CONFIG_ATT_SELFPOWER)
1540 dev_dbg(hub_dev, "local power source is %s\n", 1540 dev_dbg(hub_dev, "local power source is %s\n",
1541 (hubstatus & HUB_STATUS_LOCAL_POWER) 1541 (hubstatus & HUB_STATUS_LOCAL_POWER)
1542 ? "lost (inactive)" : "good"); 1542 ? "lost (inactive)" : "good");
1543 1543
1544 if ((wHubCharacteristics & HUB_CHAR_OCPM) == 0) 1544 if ((wHubCharacteristics & HUB_CHAR_OCPM) == 0)
1545 dev_dbg(hub_dev, "%sover-current condition exists\n", 1545 dev_dbg(hub_dev, "%sover-current condition exists\n",
1546 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); 1546 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");
1547 1547
1548 /* set up the interrupt endpoint 1548 /* set up the interrupt endpoint
1549 * We use the EP's maxpacket size instead of (PORTS+1+7)/8 1549 * We use the EP's maxpacket size instead of (PORTS+1+7)/8
1550 * bytes as USB2.0[11.12.3] says because some hubs are known 1550 * bytes as USB2.0[11.12.3] says because some hubs are known
1551 * to send more data (and thus cause overflow). For root hubs, 1551 * to send more data (and thus cause overflow). For root hubs,
1552 * maxpktsize is defined in hcd.c's fake endpoint descriptors 1552 * maxpktsize is defined in hcd.c's fake endpoint descriptors
1553 * to be big enough for at least USB_MAXCHILDREN ports. */ 1553 * to be big enough for at least USB_MAXCHILDREN ports. */
1554 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 1554 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress);
1555 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 1555 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe));
1556 1556
1557 if (maxp > sizeof(*hub->buffer)) 1557 if (maxp > sizeof(*hub->buffer))
1558 maxp = sizeof(*hub->buffer); 1558 maxp = sizeof(*hub->buffer);
1559 1559
1560 hub->urb = usb_alloc_urb(0, GFP_KERNEL); 1560 hub->urb = usb_alloc_urb(0, GFP_KERNEL);
1561 if (!hub->urb) { 1561 if (!hub->urb) {
1562 ret = -ENOMEM; 1562 ret = -ENOMEM;
1563 goto fail; 1563 goto fail;
1564 } 1564 }
1565 1565
1566 usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq, 1566 usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq,
1567 hub, endpoint->bInterval); 1567 hub, endpoint->bInterval);
1568 1568
1569 /* maybe cycle the hub leds */ 1569 /* maybe cycle the hub leds */
1570 if (hub->has_indicators && blinkenlights) 1570 if (hub->has_indicators && blinkenlights)
1571 hub->indicator[0] = INDICATOR_CYCLE; 1571 hub->indicator[0] = INDICATOR_CYCLE;
1572 1572
1573 for (i = 0; i < hdev->maxchild; i++) { 1573 for (i = 0; i < hdev->maxchild; i++) {
1574 ret = usb_hub_create_port_device(hub, i + 1); 1574 ret = usb_hub_create_port_device(hub, i + 1);
1575 if (ret < 0) { 1575 if (ret < 0) {
1576 dev_err(hub->intfdev, 1576 dev_err(hub->intfdev,
1577 "couldn't create port%d device.\n", i + 1); 1577 "couldn't create port%d device.\n", i + 1);
1578 hdev->maxchild = i; 1578 hdev->maxchild = i;
1579 goto fail_keep_maxchild; 1579 goto fail_keep_maxchild;
1580 } 1580 }
1581 } 1581 }
1582 1582
1583 usb_hub_adjust_deviceremovable(hdev, hub->descriptor); 1583 usb_hub_adjust_deviceremovable(hdev, hub->descriptor);
1584 1584
1585 hub_activate(hub, HUB_INIT); 1585 hub_activate(hub, HUB_INIT);
1586 return 0; 1586 return 0;
1587 1587
1588 fail: 1588 fail:
1589 hdev->maxchild = 0; 1589 hdev->maxchild = 0;
1590 fail_keep_maxchild: 1590 fail_keep_maxchild:
1591 dev_err (hub_dev, "config failed, %s (err %d)\n", 1591 dev_err (hub_dev, "config failed, %s (err %d)\n",
1592 message, ret); 1592 message, ret);
1593 /* hub_disconnect() frees urb and descriptor */ 1593 /* hub_disconnect() frees urb and descriptor */
1594 return ret; 1594 return ret;
1595 } 1595 }
1596 1596
1597 static void hub_release(struct kref *kref) 1597 static void hub_release(struct kref *kref)
1598 { 1598 {
1599 struct usb_hub *hub = container_of(kref, struct usb_hub, kref); 1599 struct usb_hub *hub = container_of(kref, struct usb_hub, kref);
1600 1600
1601 usb_put_intf(to_usb_interface(hub->intfdev)); 1601 usb_put_intf(to_usb_interface(hub->intfdev));
1602 kfree(hub); 1602 kfree(hub);
1603 } 1603 }
1604 1604
1605 static unsigned highspeed_hubs; 1605 static unsigned highspeed_hubs;
1606 1606
1607 static void hub_disconnect(struct usb_interface *intf) 1607 static void hub_disconnect(struct usb_interface *intf)
1608 { 1608 {
1609 struct usb_hub *hub = usb_get_intfdata(intf); 1609 struct usb_hub *hub = usb_get_intfdata(intf);
1610 struct usb_device *hdev = interface_to_usbdev(intf); 1610 struct usb_device *hdev = interface_to_usbdev(intf);
1611 int port1; 1611 int port1;
1612 1612
1613 /* Take the hub off the event list and don't let it be added again */ 1613 /* Take the hub off the event list and don't let it be added again */
1614 spin_lock_irq(&hub_event_lock); 1614 spin_lock_irq(&hub_event_lock);
1615 if (!list_empty(&hub->event_list)) { 1615 if (!list_empty(&hub->event_list)) {
1616 list_del_init(&hub->event_list); 1616 list_del_init(&hub->event_list);
1617 usb_autopm_put_interface_no_suspend(intf); 1617 usb_autopm_put_interface_no_suspend(intf);
1618 } 1618 }
1619 hub->disconnected = 1; 1619 hub->disconnected = 1;
1620 spin_unlock_irq(&hub_event_lock); 1620 spin_unlock_irq(&hub_event_lock);
1621 1621
1622 /* Disconnect all children and quiesce the hub */ 1622 /* Disconnect all children and quiesce the hub */
1623 hub->error = 0; 1623 hub->error = 0;
1624 hub_quiesce(hub, HUB_DISCONNECT); 1624 hub_quiesce(hub, HUB_DISCONNECT);
1625 1625
1626 /* Avoid races with recursively_mark_NOTATTACHED() */ 1626 /* Avoid races with recursively_mark_NOTATTACHED() */
1627 spin_lock_irq(&device_state_lock); 1627 spin_lock_irq(&device_state_lock);
1628 port1 = hdev->maxchild; 1628 port1 = hdev->maxchild;
1629 hdev->maxchild = 0; 1629 hdev->maxchild = 0;
1630 usb_set_intfdata(intf, NULL); 1630 usb_set_intfdata(intf, NULL);
1631 spin_unlock_irq(&device_state_lock); 1631 spin_unlock_irq(&device_state_lock);
1632 1632
1633 for (; port1 > 0; --port1) 1633 for (; port1 > 0; --port1)
1634 usb_hub_remove_port_device(hub, port1); 1634 usb_hub_remove_port_device(hub, port1);
1635 1635
1636 if (hub->hdev->speed == USB_SPEED_HIGH) 1636 if (hub->hdev->speed == USB_SPEED_HIGH)
1637 highspeed_hubs--; 1637 highspeed_hubs--;
1638 1638
1639 usb_free_urb(hub->urb); 1639 usb_free_urb(hub->urb);
1640 kfree(hub->ports); 1640 kfree(hub->ports);
1641 kfree(hub->descriptor); 1641 kfree(hub->descriptor);
1642 kfree(hub->status); 1642 kfree(hub->status);
1643 kfree(hub->buffer); 1643 kfree(hub->buffer);
1644 1644
1645 pm_suspend_ignore_children(&intf->dev, false); 1645 pm_suspend_ignore_children(&intf->dev, false);
1646 kref_put(&hub->kref, hub_release); 1646 kref_put(&hub->kref, hub_release);
1647 } 1647 }
1648 1648
1649 static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) 1649 static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
1650 { 1650 {
1651 struct usb_host_interface *desc; 1651 struct usb_host_interface *desc;
1652 struct usb_endpoint_descriptor *endpoint; 1652 struct usb_endpoint_descriptor *endpoint;
1653 struct usb_device *hdev; 1653 struct usb_device *hdev;
1654 struct usb_hub *hub; 1654 struct usb_hub *hub;
1655 1655
1656 desc = intf->cur_altsetting; 1656 desc = intf->cur_altsetting;
1657 hdev = interface_to_usbdev(intf); 1657 hdev = interface_to_usbdev(intf);
1658 1658
1659 /* 1659 /*
1660 * Set default autosuspend delay as 0 to speedup bus suspend, 1660 * Set default autosuspend delay as 0 to speedup bus suspend,
1661 * based on the below considerations: 1661 * based on the below considerations:
1662 * 1662 *
1663 * - Unlike other drivers, the hub driver does not rely on the 1663 * - Unlike other drivers, the hub driver does not rely on the
1664 * autosuspend delay to provide enough time to handle a wakeup 1664 * autosuspend delay to provide enough time to handle a wakeup
1665 * event, and the submitted status URB is just to check future 1665 * event, and the submitted status URB is just to check future
1666 * change on hub downstream ports, so it is safe to do it. 1666 * change on hub downstream ports, so it is safe to do it.
1667 * 1667 *
1668 * - The patch might cause one or more auto supend/resume for 1668 * - The patch might cause one or more auto supend/resume for
1669 * below very rare devices when they are plugged into hub 1669 * below very rare devices when they are plugged into hub
1670 * first time: 1670 * first time:
1671 * 1671 *
1672 * devices having trouble initializing, and disconnect 1672 * devices having trouble initializing, and disconnect
1673 * themselves from the bus and then reconnect a second 1673 * themselves from the bus and then reconnect a second
1674 * or so later 1674 * or so later
1675 * 1675 *
1676 * devices just for downloading firmware, and disconnects 1676 * devices just for downloading firmware, and disconnects
1677 * themselves after completing it 1677 * themselves after completing it
1678 * 1678 *
1679 * For these quite rare devices, their drivers may change the 1679 * For these quite rare devices, their drivers may change the
1680 * autosuspend delay of their parent hub in the probe() to one 1680 * autosuspend delay of their parent hub in the probe() to one
1681 * appropriate value to avoid the subtle problem if someone 1681 * appropriate value to avoid the subtle problem if someone
1682 * does care it. 1682 * does care it.
1683 * 1683 *
1684 * - The patch may cause one or more auto suspend/resume on 1684 * - The patch may cause one or more auto suspend/resume on
1685 * hub during running 'lsusb', but it is probably too 1685 * hub during running 'lsusb', but it is probably too
1686 * infrequent to worry about. 1686 * infrequent to worry about.
1687 * 1687 *
1688 * - Change autosuspend delay of hub can avoid unnecessary auto 1688 * - Change autosuspend delay of hub can avoid unnecessary auto
1689 * suspend timer for hub, also may decrease power consumption 1689 * suspend timer for hub, also may decrease power consumption
1690 * of USB bus. 1690 * of USB bus.
1691 */ 1691 */
1692 pm_runtime_set_autosuspend_delay(&hdev->dev, 0); 1692 pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
1693 1693
1694 /* Hubs have proper suspend/resume support. */ 1694 /*
1695 usb_enable_autosuspend(hdev); 1695 * Hubs have proper suspend/resume support, except for root hubs
1696 * where the controller driver doesn't have bus_suspend and
1697 * bus_resume methods.
1698 */
1699 if (hdev->parent) { /* normal device */
1700 usb_enable_autosuspend(hdev);
1701 } else { /* root hub */
1702 const struct hc_driver *drv = bus_to_hcd(hdev->bus)->driver;
1703
1704 if (drv->bus_suspend && drv->bus_resume)
1705 usb_enable_autosuspend(hdev);
1706 }
1696 1707
1697 if (hdev->level == MAX_TOPO_LEVEL) { 1708 if (hdev->level == MAX_TOPO_LEVEL) {
1698 dev_err(&intf->dev, 1709 dev_err(&intf->dev,
1699 "Unsupported bus topology: hub nested too deep\n"); 1710 "Unsupported bus topology: hub nested too deep\n");
1700 return -E2BIG; 1711 return -E2BIG;
1701 } 1712 }
1702 1713
1703 #ifdef CONFIG_USB_OTG_BLACKLIST_HUB 1714 #ifdef CONFIG_USB_OTG_BLACKLIST_HUB
1704 if (hdev->parent) { 1715 if (hdev->parent) {
1705 dev_warn(&intf->dev, "ignoring external hub\n"); 1716 dev_warn(&intf->dev, "ignoring external hub\n");
1706 return -ENODEV; 1717 return -ENODEV;
1707 } 1718 }
1708 #endif 1719 #endif
1709 1720
1710 /* Some hubs have a subclass of 1, which AFAICT according to the */ 1721 /* Some hubs have a subclass of 1, which AFAICT according to the */
1711 /* specs is not defined, but it works */ 1722 /* specs is not defined, but it works */
1712 if ((desc->desc.bInterfaceSubClass != 0) && 1723 if ((desc->desc.bInterfaceSubClass != 0) &&
1713 (desc->desc.bInterfaceSubClass != 1)) { 1724 (desc->desc.bInterfaceSubClass != 1)) {
1714 descriptor_error: 1725 descriptor_error:
1715 dev_err (&intf->dev, "bad descriptor, ignoring hub\n"); 1726 dev_err (&intf->dev, "bad descriptor, ignoring hub\n");
1716 return -EIO; 1727 return -EIO;
1717 } 1728 }
1718 1729
1719 /* Multiple endpoints? What kind of mutant ninja-hub is this? */ 1730 /* Multiple endpoints? What kind of mutant ninja-hub is this? */
1720 if (desc->desc.bNumEndpoints != 1) 1731 if (desc->desc.bNumEndpoints != 1)
1721 goto descriptor_error; 1732 goto descriptor_error;
1722 1733
1723 endpoint = &desc->endpoint[0].desc; 1734 endpoint = &desc->endpoint[0].desc;
1724 1735
1725 /* If it's not an interrupt in endpoint, we'd better punt! */ 1736 /* If it's not an interrupt in endpoint, we'd better punt! */
1726 if (!usb_endpoint_is_int_in(endpoint)) 1737 if (!usb_endpoint_is_int_in(endpoint))
1727 goto descriptor_error; 1738 goto descriptor_error;
1728 1739
1729 /* We found a hub */ 1740 /* We found a hub */
1730 dev_info (&intf->dev, "USB hub found\n"); 1741 dev_info (&intf->dev, "USB hub found\n");
1731 1742
1732 hub = kzalloc(sizeof(*hub), GFP_KERNEL); 1743 hub = kzalloc(sizeof(*hub), GFP_KERNEL);
1733 if (!hub) { 1744 if (!hub) {
1734 dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n"); 1745 dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n");
1735 return -ENOMEM; 1746 return -ENOMEM;
1736 } 1747 }
1737 1748
1738 kref_init(&hub->kref); 1749 kref_init(&hub->kref);
1739 INIT_LIST_HEAD(&hub->event_list); 1750 INIT_LIST_HEAD(&hub->event_list);
1740 hub->intfdev = &intf->dev; 1751 hub->intfdev = &intf->dev;
1741 hub->hdev = hdev; 1752 hub->hdev = hdev;
1742 INIT_DELAYED_WORK(&hub->leds, led_work); 1753 INIT_DELAYED_WORK(&hub->leds, led_work);
1743 INIT_DELAYED_WORK(&hub->init_work, NULL); 1754 INIT_DELAYED_WORK(&hub->init_work, NULL);
1744 usb_get_intf(intf); 1755 usb_get_intf(intf);
1745 1756
1746 usb_set_intfdata (intf, hub); 1757 usb_set_intfdata (intf, hub);
1747 intf->needs_remote_wakeup = 1; 1758 intf->needs_remote_wakeup = 1;
1748 pm_suspend_ignore_children(&intf->dev, true); 1759 pm_suspend_ignore_children(&intf->dev, true);
1749 1760
1750 if (hdev->speed == USB_SPEED_HIGH) 1761 if (hdev->speed == USB_SPEED_HIGH)
1751 highspeed_hubs++; 1762 highspeed_hubs++;
1752 1763
1753 if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND) 1764 if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND)
1754 hub->quirk_check_port_auto_suspend = 1; 1765 hub->quirk_check_port_auto_suspend = 1;
1755 1766
1756 if (hub_configure(hub, endpoint) >= 0) 1767 if (hub_configure(hub, endpoint) >= 0)
1757 return 0; 1768 return 0;
1758 1769
1759 hub_disconnect (intf); 1770 hub_disconnect (intf);
1760 return -ENODEV; 1771 return -ENODEV;
1761 } 1772 }
1762 1773
1763 static int 1774 static int
1764 hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) 1775 hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data)
1765 { 1776 {
1766 struct usb_device *hdev = interface_to_usbdev (intf); 1777 struct usb_device *hdev = interface_to_usbdev (intf);
1767 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); 1778 struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
1768 1779
1769 /* assert ifno == 0 (part of hub spec) */ 1780 /* assert ifno == 0 (part of hub spec) */
1770 switch (code) { 1781 switch (code) {
1771 case USBDEVFS_HUB_PORTINFO: { 1782 case USBDEVFS_HUB_PORTINFO: {
1772 struct usbdevfs_hub_portinfo *info = user_data; 1783 struct usbdevfs_hub_portinfo *info = user_data;
1773 int i; 1784 int i;
1774 1785
1775 spin_lock_irq(&device_state_lock); 1786 spin_lock_irq(&device_state_lock);
1776 if (hdev->devnum <= 0) 1787 if (hdev->devnum <= 0)
1777 info->nports = 0; 1788 info->nports = 0;
1778 else { 1789 else {
1779 info->nports = hdev->maxchild; 1790 info->nports = hdev->maxchild;
1780 for (i = 0; i < info->nports; i++) { 1791 for (i = 0; i < info->nports; i++) {
1781 if (hub->ports[i]->child == NULL) 1792 if (hub->ports[i]->child == NULL)
1782 info->port[i] = 0; 1793 info->port[i] = 0;
1783 else 1794 else
1784 info->port[i] = 1795 info->port[i] =
1785 hub->ports[i]->child->devnum; 1796 hub->ports[i]->child->devnum;
1786 } 1797 }
1787 } 1798 }
1788 spin_unlock_irq(&device_state_lock); 1799 spin_unlock_irq(&device_state_lock);
1789 1800
1790 return info->nports + 1; 1801 return info->nports + 1;
1791 } 1802 }
1792 1803
1793 default: 1804 default:
1794 return -ENOSYS; 1805 return -ENOSYS;
1795 } 1806 }
1796 } 1807 }
1797 1808
1798 /* 1809 /*
1799 * Allow user programs to claim ports on a hub. When a device is attached 1810 * Allow user programs to claim ports on a hub. When a device is attached
1800 * to one of these "claimed" ports, the program will "own" the device. 1811 * to one of these "claimed" ports, the program will "own" the device.
1801 */ 1812 */
1802 static int find_port_owner(struct usb_device *hdev, unsigned port1, 1813 static int find_port_owner(struct usb_device *hdev, unsigned port1,
1803 struct usb_dev_state ***ppowner) 1814 struct usb_dev_state ***ppowner)
1804 { 1815 {
1805 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); 1816 struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
1806 1817
1807 if (hdev->state == USB_STATE_NOTATTACHED) 1818 if (hdev->state == USB_STATE_NOTATTACHED)
1808 return -ENODEV; 1819 return -ENODEV;
1809 if (port1 == 0 || port1 > hdev->maxchild) 1820 if (port1 == 0 || port1 > hdev->maxchild)
1810 return -EINVAL; 1821 return -EINVAL;
1811 1822
1812 /* Devices not managed by the hub driver 1823 /* Devices not managed by the hub driver
1813 * will always have maxchild equal to 0. 1824 * will always have maxchild equal to 0.
1814 */ 1825 */
1815 *ppowner = &(hub->ports[port1 - 1]->port_owner); 1826 *ppowner = &(hub->ports[port1 - 1]->port_owner);
1816 return 0; 1827 return 0;
1817 } 1828 }
1818 1829
1819 /* In the following three functions, the caller must hold hdev's lock */ 1830 /* In the following three functions, the caller must hold hdev's lock */
1820 int usb_hub_claim_port(struct usb_device *hdev, unsigned port1, 1831 int usb_hub_claim_port(struct usb_device *hdev, unsigned port1,
1821 struct usb_dev_state *owner) 1832 struct usb_dev_state *owner)
1822 { 1833 {
1823 int rc; 1834 int rc;
1824 struct usb_dev_state **powner; 1835 struct usb_dev_state **powner;
1825 1836
1826 rc = find_port_owner(hdev, port1, &powner); 1837 rc = find_port_owner(hdev, port1, &powner);
1827 if (rc) 1838 if (rc)
1828 return rc; 1839 return rc;
1829 if (*powner) 1840 if (*powner)
1830 return -EBUSY; 1841 return -EBUSY;
1831 *powner = owner; 1842 *powner = owner;
1832 return rc; 1843 return rc;
1833 } 1844 }
1834 EXPORT_SYMBOL_GPL(usb_hub_claim_port); 1845 EXPORT_SYMBOL_GPL(usb_hub_claim_port);
1835 1846
1836 int usb_hub_release_port(struct usb_device *hdev, unsigned port1, 1847 int usb_hub_release_port(struct usb_device *hdev, unsigned port1,
1837 struct usb_dev_state *owner) 1848 struct usb_dev_state *owner)
1838 { 1849 {
1839 int rc; 1850 int rc;
1840 struct usb_dev_state **powner; 1851 struct usb_dev_state **powner;
1841 1852
1842 rc = find_port_owner(hdev, port1, &powner); 1853 rc = find_port_owner(hdev, port1, &powner);
1843 if (rc) 1854 if (rc)
1844 return rc; 1855 return rc;
1845 if (*powner != owner) 1856 if (*powner != owner)
1846 return -ENOENT; 1857 return -ENOENT;
1847 *powner = NULL; 1858 *powner = NULL;
1848 return rc; 1859 return rc;
1849 } 1860 }
1850 EXPORT_SYMBOL_GPL(usb_hub_release_port); 1861 EXPORT_SYMBOL_GPL(usb_hub_release_port);
1851 1862
1852 void usb_hub_release_all_ports(struct usb_device *hdev, struct usb_dev_state *owner) 1863 void usb_hub_release_all_ports(struct usb_device *hdev, struct usb_dev_state *owner)
1853 { 1864 {
1854 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); 1865 struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
1855 int n; 1866 int n;
1856 1867
1857 for (n = 0; n < hdev->maxchild; n++) { 1868 for (n = 0; n < hdev->maxchild; n++) {
1858 if (hub->ports[n]->port_owner == owner) 1869 if (hub->ports[n]->port_owner == owner)
1859 hub->ports[n]->port_owner = NULL; 1870 hub->ports[n]->port_owner = NULL;
1860 } 1871 }
1861 1872
1862 } 1873 }
1863 1874
1864 /* The caller must hold udev's lock */ 1875 /* The caller must hold udev's lock */
1865 bool usb_device_is_owned(struct usb_device *udev) 1876 bool usb_device_is_owned(struct usb_device *udev)
1866 { 1877 {
1867 struct usb_hub *hub; 1878 struct usb_hub *hub;
1868 1879
1869 if (udev->state == USB_STATE_NOTATTACHED || !udev->parent) 1880 if (udev->state == USB_STATE_NOTATTACHED || !udev->parent)
1870 return false; 1881 return false;
1871 hub = usb_hub_to_struct_hub(udev->parent); 1882 hub = usb_hub_to_struct_hub(udev->parent);
1872 return !!hub->ports[udev->portnum - 1]->port_owner; 1883 return !!hub->ports[udev->portnum - 1]->port_owner;
1873 } 1884 }
1874 1885
1875 static void recursively_mark_NOTATTACHED(struct usb_device *udev) 1886 static void recursively_mark_NOTATTACHED(struct usb_device *udev)
1876 { 1887 {
1877 struct usb_hub *hub = usb_hub_to_struct_hub(udev); 1888 struct usb_hub *hub = usb_hub_to_struct_hub(udev);
1878 int i; 1889 int i;
1879 1890
1880 for (i = 0; i < udev->maxchild; ++i) { 1891 for (i = 0; i < udev->maxchild; ++i) {
1881 if (hub->ports[i]->child) 1892 if (hub->ports[i]->child)
1882 recursively_mark_NOTATTACHED(hub->ports[i]->child); 1893 recursively_mark_NOTATTACHED(hub->ports[i]->child);
1883 } 1894 }
1884 if (udev->state == USB_STATE_SUSPENDED) 1895 if (udev->state == USB_STATE_SUSPENDED)
1885 udev->active_duration -= jiffies; 1896 udev->active_duration -= jiffies;
1886 udev->state = USB_STATE_NOTATTACHED; 1897 udev->state = USB_STATE_NOTATTACHED;
1887 } 1898 }
1888 1899
1889 /** 1900 /**
1890 * usb_set_device_state - change a device's current state (usbcore, hcds) 1901 * usb_set_device_state - change a device's current state (usbcore, hcds)
1891 * @udev: pointer to device whose state should be changed 1902 * @udev: pointer to device whose state should be changed
1892 * @new_state: new state value to be stored 1903 * @new_state: new state value to be stored
1893 * 1904 *
1894 * udev->state is _not_ fully protected by the device lock. Although 1905 * udev->state is _not_ fully protected by the device lock. Although
1895 * most transitions are made only while holding the lock, the state can 1906 * most transitions are made only while holding the lock, the state can
1896 * can change to USB_STATE_NOTATTACHED at almost any time. This 1907 * can change to USB_STATE_NOTATTACHED at almost any time. This
1897 * is so that devices can be marked as disconnected as soon as possible, 1908 * is so that devices can be marked as disconnected as soon as possible,
1898 * without having to wait for any semaphores to be released. As a result, 1909 * without having to wait for any semaphores to be released. As a result,
1899 * all changes to any device's state must be protected by the 1910 * all changes to any device's state must be protected by the
1900 * device_state_lock spinlock. 1911 * device_state_lock spinlock.
1901 * 1912 *
1902 * Once a device has been added to the device tree, all changes to its state 1913 * Once a device has been added to the device tree, all changes to its state
1903 * should be made using this routine. The state should _not_ be set directly. 1914 * should be made using this routine. The state should _not_ be set directly.
1904 * 1915 *
1905 * If udev->state is already USB_STATE_NOTATTACHED then no change is made. 1916 * If udev->state is already USB_STATE_NOTATTACHED then no change is made.
1906 * Otherwise udev->state is set to new_state, and if new_state is 1917 * Otherwise udev->state is set to new_state, and if new_state is
1907 * USB_STATE_NOTATTACHED then all of udev's descendants' states are also set 1918 * USB_STATE_NOTATTACHED then all of udev's descendants' states are also set
1908 * to USB_STATE_NOTATTACHED. 1919 * to USB_STATE_NOTATTACHED.
1909 */ 1920 */
1910 void usb_set_device_state(struct usb_device *udev, 1921 void usb_set_device_state(struct usb_device *udev,
1911 enum usb_device_state new_state) 1922 enum usb_device_state new_state)
1912 { 1923 {
1913 unsigned long flags; 1924 unsigned long flags;
1914 int wakeup = -1; 1925 int wakeup = -1;
1915 1926
1916 spin_lock_irqsave(&device_state_lock, flags); 1927 spin_lock_irqsave(&device_state_lock, flags);
1917 if (udev->state == USB_STATE_NOTATTACHED) 1928 if (udev->state == USB_STATE_NOTATTACHED)
1918 ; /* do nothing */ 1929 ; /* do nothing */
1919 else if (new_state != USB_STATE_NOTATTACHED) { 1930 else if (new_state != USB_STATE_NOTATTACHED) {
1920 1931
1921 /* root hub wakeup capabilities are managed out-of-band 1932 /* root hub wakeup capabilities are managed out-of-band
1922 * and may involve silicon errata ... ignore them here. 1933 * and may involve silicon errata ... ignore them here.
1923 */ 1934 */
1924 if (udev->parent) { 1935 if (udev->parent) {
1925 if (udev->state == USB_STATE_SUSPENDED 1936 if (udev->state == USB_STATE_SUSPENDED
1926 || new_state == USB_STATE_SUSPENDED) 1937 || new_state == USB_STATE_SUSPENDED)
1927 ; /* No change to wakeup settings */ 1938 ; /* No change to wakeup settings */
1928 else if (new_state == USB_STATE_CONFIGURED) 1939 else if (new_state == USB_STATE_CONFIGURED)
1929 wakeup = udev->actconfig->desc.bmAttributes 1940 wakeup = udev->actconfig->desc.bmAttributes
1930 & USB_CONFIG_ATT_WAKEUP; 1941 & USB_CONFIG_ATT_WAKEUP;
1931 else 1942 else
1932 wakeup = 0; 1943 wakeup = 0;
1933 } 1944 }
1934 if (udev->state == USB_STATE_SUSPENDED && 1945 if (udev->state == USB_STATE_SUSPENDED &&
1935 new_state != USB_STATE_SUSPENDED) 1946 new_state != USB_STATE_SUSPENDED)
1936 udev->active_duration -= jiffies; 1947 udev->active_duration -= jiffies;
1937 else if (new_state == USB_STATE_SUSPENDED && 1948 else if (new_state == USB_STATE_SUSPENDED &&
1938 udev->state != USB_STATE_SUSPENDED) 1949 udev->state != USB_STATE_SUSPENDED)
1939 udev->active_duration += jiffies; 1950 udev->active_duration += jiffies;
1940 udev->state = new_state; 1951 udev->state = new_state;
1941 } else 1952 } else
1942 recursively_mark_NOTATTACHED(udev); 1953 recursively_mark_NOTATTACHED(udev);
1943 spin_unlock_irqrestore(&device_state_lock, flags); 1954 spin_unlock_irqrestore(&device_state_lock, flags);
1944 if (wakeup >= 0) 1955 if (wakeup >= 0)
1945 device_set_wakeup_capable(&udev->dev, wakeup); 1956 device_set_wakeup_capable(&udev->dev, wakeup);
1946 } 1957 }
1947 EXPORT_SYMBOL_GPL(usb_set_device_state); 1958 EXPORT_SYMBOL_GPL(usb_set_device_state);
1948 1959
1949 /* 1960 /*
1950 * Choose a device number. 1961 * Choose a device number.
1951 * 1962 *
1952 * Device numbers are used as filenames in usbfs. On USB-1.1 and 1963 * Device numbers are used as filenames in usbfs. On USB-1.1 and
1953 * USB-2.0 buses they are also used as device addresses, however on 1964 * USB-2.0 buses they are also used as device addresses, however on
1954 * USB-3.0 buses the address is assigned by the controller hardware 1965 * USB-3.0 buses the address is assigned by the controller hardware
1955 * and it usually is not the same as the device number. 1966 * and it usually is not the same as the device number.
1956 * 1967 *
1957 * WUSB devices are simple: they have no hubs behind, so the mapping 1968 * WUSB devices are simple: they have no hubs behind, so the mapping
1958 * device <-> virtual port number becomes 1:1. Why? to simplify the 1969 * device <-> virtual port number becomes 1:1. Why? to simplify the
1959 * life of the device connection logic in 1970 * life of the device connection logic in
1960 * drivers/usb/wusbcore/devconnect.c. When we do the initial secret 1971 * drivers/usb/wusbcore/devconnect.c. When we do the initial secret
1961 * handshake we need to assign a temporary address in the unauthorized 1972 * handshake we need to assign a temporary address in the unauthorized
1962 * space. For simplicity we use the first virtual port number found to 1973 * space. For simplicity we use the first virtual port number found to
1963 * be free [drivers/usb/wusbcore/devconnect.c:wusbhc_devconnect_ack()] 1974 * be free [drivers/usb/wusbcore/devconnect.c:wusbhc_devconnect_ack()]
1964 * and that becomes it's address [X < 128] or its unauthorized address 1975 * and that becomes it's address [X < 128] or its unauthorized address
1965 * [X | 0x80]. 1976 * [X | 0x80].
1966 * 1977 *
1967 * We add 1 as an offset to the one-based USB-stack port number 1978 * We add 1 as an offset to the one-based USB-stack port number
1968 * (zero-based wusb virtual port index) for two reasons: (a) dev addr 1979 * (zero-based wusb virtual port index) for two reasons: (a) dev addr
1969 * 0 is reserved by USB for default address; (b) Linux's USB stack 1980 * 0 is reserved by USB for default address; (b) Linux's USB stack
1970 * uses always #1 for the root hub of the controller. So USB stack's 1981 * uses always #1 for the root hub of the controller. So USB stack's
1971 * port #1, which is wusb virtual-port #0 has address #2. 1982 * port #1, which is wusb virtual-port #0 has address #2.
1972 * 1983 *
1973 * Devices connected under xHCI are not as simple. The host controller 1984 * Devices connected under xHCI are not as simple. The host controller
1974 * supports virtualization, so the hardware assigns device addresses and 1985 * supports virtualization, so the hardware assigns device addresses and
1975 * the HCD must setup data structures before issuing a set address 1986 * the HCD must setup data structures before issuing a set address
1976 * command to the hardware. 1987 * command to the hardware.
1977 */ 1988 */
1978 static void choose_devnum(struct usb_device *udev) 1989 static void choose_devnum(struct usb_device *udev)
1979 { 1990 {
1980 int devnum; 1991 int devnum;
1981 struct usb_bus *bus = udev->bus; 1992 struct usb_bus *bus = udev->bus;
1982 1993
1983 /* If khubd ever becomes multithreaded, this will need a lock */ 1994 /* If khubd ever becomes multithreaded, this will need a lock */
1984 if (udev->wusb) { 1995 if (udev->wusb) {
1985 devnum = udev->portnum + 1; 1996 devnum = udev->portnum + 1;
1986 BUG_ON(test_bit(devnum, bus->devmap.devicemap)); 1997 BUG_ON(test_bit(devnum, bus->devmap.devicemap));
1987 } else { 1998 } else {
1988 /* Try to allocate the next devnum beginning at 1999 /* Try to allocate the next devnum beginning at
1989 * bus->devnum_next. */ 2000 * bus->devnum_next. */
1990 devnum = find_next_zero_bit(bus->devmap.devicemap, 128, 2001 devnum = find_next_zero_bit(bus->devmap.devicemap, 128,
1991 bus->devnum_next); 2002 bus->devnum_next);
1992 if (devnum >= 128) 2003 if (devnum >= 128)
1993 devnum = find_next_zero_bit(bus->devmap.devicemap, 2004 devnum = find_next_zero_bit(bus->devmap.devicemap,
1994 128, 1); 2005 128, 1);
1995 bus->devnum_next = (devnum >= 127 ? 1 : devnum + 1); 2006 bus->devnum_next = (devnum >= 127 ? 1 : devnum + 1);
1996 } 2007 }
1997 if (devnum < 128) { 2008 if (devnum < 128) {
1998 set_bit(devnum, bus->devmap.devicemap); 2009 set_bit(devnum, bus->devmap.devicemap);
1999 udev->devnum = devnum; 2010 udev->devnum = devnum;
2000 } 2011 }
2001 } 2012 }
2002 2013
2003 static void release_devnum(struct usb_device *udev) 2014 static void release_devnum(struct usb_device *udev)
2004 { 2015 {
2005 if (udev->devnum > 0) { 2016 if (udev->devnum > 0) {
2006 clear_bit(udev->devnum, udev->bus->devmap.devicemap); 2017 clear_bit(udev->devnum, udev->bus->devmap.devicemap);
2007 udev->devnum = -1; 2018 udev->devnum = -1;
2008 } 2019 }
2009 } 2020 }
2010 2021
2011 static void update_devnum(struct usb_device *udev, int devnum) 2022 static void update_devnum(struct usb_device *udev, int devnum)
2012 { 2023 {
2013 /* The address for a WUSB device is managed by wusbcore. */ 2024 /* The address for a WUSB device is managed by wusbcore. */
2014 if (!udev->wusb) 2025 if (!udev->wusb)
2015 udev->devnum = devnum; 2026 udev->devnum = devnum;
2016 } 2027 }
2017 2028
2018 static void hub_free_dev(struct usb_device *udev) 2029 static void hub_free_dev(struct usb_device *udev)
2019 { 2030 {
2020 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 2031 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
2021 2032
2022 /* Root hubs aren't real devices, so don't free HCD resources */ 2033 /* Root hubs aren't real devices, so don't free HCD resources */
2023 if (hcd->driver->free_dev && udev->parent) 2034 if (hcd->driver->free_dev && udev->parent)
2024 hcd->driver->free_dev(hcd, udev); 2035 hcd->driver->free_dev(hcd, udev);
2025 } 2036 }
2026 2037
2027 /** 2038 /**
2028 * usb_disconnect - disconnect a device (usbcore-internal) 2039 * usb_disconnect - disconnect a device (usbcore-internal)
2029 * @pdev: pointer to device being disconnected 2040 * @pdev: pointer to device being disconnected
2030 * Context: !in_interrupt () 2041 * Context: !in_interrupt ()
2031 * 2042 *
2032 * Something got disconnected. Get rid of it and all of its children. 2043 * Something got disconnected. Get rid of it and all of its children.
2033 * 2044 *
2034 * If *pdev is a normal device then the parent hub must already be locked. 2045 * If *pdev is a normal device then the parent hub must already be locked.
2035 * If *pdev is a root hub then the caller must hold the usb_bus_list_lock, 2046 * If *pdev is a root hub then the caller must hold the usb_bus_list_lock,
2036 * which protects the set of root hubs as well as the list of buses. 2047 * which protects the set of root hubs as well as the list of buses.
2037 * 2048 *
2038 * Only hub drivers (including virtual root hub drivers for host 2049 * Only hub drivers (including virtual root hub drivers for host
2039 * controllers) should ever call this. 2050 * controllers) should ever call this.
2040 * 2051 *
2041 * This call is synchronous, and may not be used in an interrupt context. 2052 * This call is synchronous, and may not be used in an interrupt context.
2042 */ 2053 */
2043 void usb_disconnect(struct usb_device **pdev) 2054 void usb_disconnect(struct usb_device **pdev)
2044 { 2055 {
2045 struct usb_device *udev = *pdev; 2056 struct usb_device *udev = *pdev;
2046 struct usb_hub *hub = usb_hub_to_struct_hub(udev); 2057 struct usb_hub *hub = usb_hub_to_struct_hub(udev);
2047 int i; 2058 int i;
2048 2059
2049 /* mark the device as inactive, so any further urb submissions for 2060 /* mark the device as inactive, so any further urb submissions for
2050 * this device (and any of its children) will fail immediately. 2061 * this device (and any of its children) will fail immediately.
2051 * this quiesces everything except pending urbs. 2062 * this quiesces everything except pending urbs.
2052 */ 2063 */
2053 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 2064 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
2054 dev_info(&udev->dev, "USB disconnect, device number %d\n", 2065 dev_info(&udev->dev, "USB disconnect, device number %d\n",
2055 udev->devnum); 2066 udev->devnum);
2056 2067
2057 usb_lock_device(udev); 2068 usb_lock_device(udev);
2058 2069
2059 /* Free up all the children before we remove this device */ 2070 /* Free up all the children before we remove this device */
2060 for (i = 0; i < udev->maxchild; i++) { 2071 for (i = 0; i < udev->maxchild; i++) {
2061 if (hub->ports[i]->child) 2072 if (hub->ports[i]->child)
2062 usb_disconnect(&hub->ports[i]->child); 2073 usb_disconnect(&hub->ports[i]->child);
2063 } 2074 }
2064 2075
2065 /* deallocate hcd/hardware state ... nuking all pending urbs and 2076 /* deallocate hcd/hardware state ... nuking all pending urbs and
2066 * cleaning up all state associated with the current configuration 2077 * cleaning up all state associated with the current configuration
2067 * so that the hardware is now fully quiesced. 2078 * so that the hardware is now fully quiesced.
2068 */ 2079 */
2069 dev_dbg (&udev->dev, "unregistering device\n"); 2080 dev_dbg (&udev->dev, "unregistering device\n");
2070 usb_disable_device(udev, 0); 2081 usb_disable_device(udev, 0);
2071 usb_hcd_synchronize_unlinks(udev); 2082 usb_hcd_synchronize_unlinks(udev);
2072 2083
2073 if (udev->parent) { 2084 if (udev->parent) {
2074 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); 2085 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
2075 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; 2086 struct usb_port *port_dev = hub->ports[udev->portnum - 1];
2076 2087
2077 sysfs_remove_link(&udev->dev.kobj, "port"); 2088 sysfs_remove_link(&udev->dev.kobj, "port");
2078 sysfs_remove_link(&port_dev->dev.kobj, "device"); 2089 sysfs_remove_link(&port_dev->dev.kobj, "device");
2079 2090
2080 if (!port_dev->did_runtime_put) 2091 if (!port_dev->did_runtime_put)
2081 pm_runtime_put(&port_dev->dev); 2092 pm_runtime_put(&port_dev->dev);
2082 else 2093 else
2083 port_dev->did_runtime_put = false; 2094 port_dev->did_runtime_put = false;
2084 } 2095 }
2085 2096
2086 usb_remove_ep_devs(&udev->ep0); 2097 usb_remove_ep_devs(&udev->ep0);
2087 usb_unlock_device(udev); 2098 usb_unlock_device(udev);
2088 2099
2089 /* Unregister the device. The device driver is responsible 2100 /* Unregister the device. The device driver is responsible
2090 * for de-configuring the device and invoking the remove-device 2101 * for de-configuring the device and invoking the remove-device
2091 * notifier chain (used by usbfs and possibly others). 2102 * notifier chain (used by usbfs and possibly others).
2092 */ 2103 */
2093 device_del(&udev->dev); 2104 device_del(&udev->dev);
2094 2105
2095 /* Free the device number and delete the parent's children[] 2106 /* Free the device number and delete the parent's children[]
2096 * (or root_hub) pointer. 2107 * (or root_hub) pointer.
2097 */ 2108 */
2098 release_devnum(udev); 2109 release_devnum(udev);
2099 2110
2100 /* Avoid races with recursively_mark_NOTATTACHED() */ 2111 /* Avoid races with recursively_mark_NOTATTACHED() */
2101 spin_lock_irq(&device_state_lock); 2112 spin_lock_irq(&device_state_lock);
2102 *pdev = NULL; 2113 *pdev = NULL;
2103 spin_unlock_irq(&device_state_lock); 2114 spin_unlock_irq(&device_state_lock);
2104 2115
2105 hub_free_dev(udev); 2116 hub_free_dev(udev);
2106 2117
2107 put_device(&udev->dev); 2118 put_device(&udev->dev);
2108 } 2119 }
2109 2120
2110 #ifdef CONFIG_USB_ANNOUNCE_NEW_DEVICES 2121 #ifdef CONFIG_USB_ANNOUNCE_NEW_DEVICES
2111 static void show_string(struct usb_device *udev, char *id, char *string) 2122 static void show_string(struct usb_device *udev, char *id, char *string)
2112 { 2123 {
2113 if (!string) 2124 if (!string)
2114 return; 2125 return;
2115 dev_info(&udev->dev, "%s: %s\n", id, string); 2126 dev_info(&udev->dev, "%s: %s\n", id, string);
2116 } 2127 }
2117 2128
2118 static void announce_device(struct usb_device *udev) 2129 static void announce_device(struct usb_device *udev)
2119 { 2130 {
2120 dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n", 2131 dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n",
2121 le16_to_cpu(udev->descriptor.idVendor), 2132 le16_to_cpu(udev->descriptor.idVendor),
2122 le16_to_cpu(udev->descriptor.idProduct)); 2133 le16_to_cpu(udev->descriptor.idProduct));
2123 dev_info(&udev->dev, 2134 dev_info(&udev->dev,
2124 "New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\n", 2135 "New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
2125 udev->descriptor.iManufacturer, 2136 udev->descriptor.iManufacturer,
2126 udev->descriptor.iProduct, 2137 udev->descriptor.iProduct,
2127 udev->descriptor.iSerialNumber); 2138 udev->descriptor.iSerialNumber);
2128 show_string(udev, "Product", udev->product); 2139 show_string(udev, "Product", udev->product);
2129 show_string(udev, "Manufacturer", udev->manufacturer); 2140 show_string(udev, "Manufacturer", udev->manufacturer);
2130 show_string(udev, "SerialNumber", udev->serial); 2141 show_string(udev, "SerialNumber", udev->serial);
2131 } 2142 }
2132 #else 2143 #else
2133 static inline void announce_device(struct usb_device *udev) { } 2144 static inline void announce_device(struct usb_device *udev) { }
2134 #endif 2145 #endif
2135 2146
2136 #ifdef CONFIG_USB_OTG 2147 #ifdef CONFIG_USB_OTG
2137 #include "otg_whitelist.h" 2148 #include "otg_whitelist.h"
2138 #endif 2149 #endif
2139 2150
2140 /** 2151 /**
2141 * usb_enumerate_device_otg - FIXME (usbcore-internal) 2152 * usb_enumerate_device_otg - FIXME (usbcore-internal)
2142 * @udev: newly addressed device (in ADDRESS state) 2153 * @udev: newly addressed device (in ADDRESS state)
2143 * 2154 *
2144 * Finish enumeration for On-The-Go devices 2155 * Finish enumeration for On-The-Go devices
2145 * 2156 *
2146 * Return: 0 if successful. A negative error code otherwise. 2157 * Return: 0 if successful. A negative error code otherwise.
2147 */ 2158 */
2148 static int usb_enumerate_device_otg(struct usb_device *udev) 2159 static int usb_enumerate_device_otg(struct usb_device *udev)
2149 { 2160 {
2150 int err = 0; 2161 int err = 0;
2151 2162
2152 #ifdef CONFIG_USB_OTG 2163 #ifdef CONFIG_USB_OTG
2153 /* 2164 /*
2154 * OTG-aware devices on OTG-capable root hubs may be able to use SRP, 2165 * OTG-aware devices on OTG-capable root hubs may be able to use SRP,
2155 * to wake us after we've powered off VBUS; and HNP, switching roles 2166 * to wake us after we've powered off VBUS; and HNP, switching roles
2156 * "host" to "peripheral". The OTG descriptor helps figure this out. 2167 * "host" to "peripheral". The OTG descriptor helps figure this out.
2157 */ 2168 */
2158 if (!udev->bus->is_b_host 2169 if (!udev->bus->is_b_host
2159 && udev->config 2170 && udev->config
2160 && udev->parent == udev->bus->root_hub) { 2171 && udev->parent == udev->bus->root_hub) {
2161 struct usb_otg_descriptor *desc = NULL; 2172 struct usb_otg_descriptor *desc = NULL;
2162 struct usb_bus *bus = udev->bus; 2173 struct usb_bus *bus = udev->bus;
2163 2174
2164 /* descriptor may appear anywhere in config */ 2175 /* descriptor may appear anywhere in config */
2165 if (__usb_get_extra_descriptor (udev->rawdescriptors[0], 2176 if (__usb_get_extra_descriptor (udev->rawdescriptors[0],
2166 le16_to_cpu(udev->config[0].desc.wTotalLength), 2177 le16_to_cpu(udev->config[0].desc.wTotalLength),
2167 USB_DT_OTG, (void **) &desc) == 0) { 2178 USB_DT_OTG, (void **) &desc) == 0) {
2168 if (desc->bmAttributes & USB_OTG_HNP) { 2179 if (desc->bmAttributes & USB_OTG_HNP) {
2169 unsigned port1 = udev->portnum; 2180 unsigned port1 = udev->portnum;
2170 2181
2171 dev_info(&udev->dev, 2182 dev_info(&udev->dev,
2172 "Dual-Role OTG device on %sHNP port\n", 2183 "Dual-Role OTG device on %sHNP port\n",
2173 (port1 == bus->otg_port) 2184 (port1 == bus->otg_port)
2174 ? "" : "non-"); 2185 ? "" : "non-");
2175 2186
2176 /* enable HNP before suspend, it's simpler */ 2187 /* enable HNP before suspend, it's simpler */
2177 if (port1 == bus->otg_port) 2188 if (port1 == bus->otg_port)
2178 bus->b_hnp_enable = 1; 2189 bus->b_hnp_enable = 1;
2179 err = usb_control_msg(udev, 2190 err = usb_control_msg(udev,
2180 usb_sndctrlpipe(udev, 0), 2191 usb_sndctrlpipe(udev, 0),
2181 USB_REQ_SET_FEATURE, 0, 2192 USB_REQ_SET_FEATURE, 0,
2182 bus->b_hnp_enable 2193 bus->b_hnp_enable
2183 ? USB_DEVICE_B_HNP_ENABLE 2194 ? USB_DEVICE_B_HNP_ENABLE
2184 : USB_DEVICE_A_ALT_HNP_SUPPORT, 2195 : USB_DEVICE_A_ALT_HNP_SUPPORT,
2185 0, NULL, 0, USB_CTRL_SET_TIMEOUT); 2196 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
2186 if (err < 0) { 2197 if (err < 0) {
2187 /* OTG MESSAGE: report errors here, 2198 /* OTG MESSAGE: report errors here,
2188 * customize to match your product. 2199 * customize to match your product.
2189 */ 2200 */
2190 dev_info(&udev->dev, 2201 dev_info(&udev->dev,
2191 "can't set HNP mode: %d\n", 2202 "can't set HNP mode: %d\n",
2192 err); 2203 err);
2193 bus->b_hnp_enable = 0; 2204 bus->b_hnp_enable = 0;
2194 } 2205 }
2195 } 2206 }
2196 } 2207 }
2197 } 2208 }
2198 2209
2199 if (!is_targeted(udev)) { 2210 if (!is_targeted(udev)) {
2200 2211
2201 /* Maybe it can talk to us, though we can't talk to it. 2212 /* Maybe it can talk to us, though we can't talk to it.
2202 * (Includes HNP test device.) 2213 * (Includes HNP test device.)
2203 */ 2214 */
2204 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 2215 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
2205 err = usb_port_suspend(udev, PMSG_SUSPEND); 2216 err = usb_port_suspend(udev, PMSG_SUSPEND);
2206 if (err < 0) 2217 if (err < 0)
2207 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 2218 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
2208 } 2219 }
2209 err = -ENOTSUPP; 2220 err = -ENOTSUPP;
2210 goto fail; 2221 goto fail;
2211 } 2222 }
2212 fail: 2223 fail:
2213 #endif 2224 #endif
2214 return err; 2225 return err;
2215 } 2226 }
2216 2227
2217 2228
2218 /** 2229 /**
2219 * usb_enumerate_device - Read device configs/intfs/otg (usbcore-internal) 2230 * usb_enumerate_device - Read device configs/intfs/otg (usbcore-internal)
2220 * @udev: newly addressed device (in ADDRESS state) 2231 * @udev: newly addressed device (in ADDRESS state)
2221 * 2232 *
2222 * This is only called by usb_new_device() and usb_authorize_device() 2233 * This is only called by usb_new_device() and usb_authorize_device()
2223 * and FIXME -- all comments that apply to them apply here wrt to 2234 * and FIXME -- all comments that apply to them apply here wrt to
2224 * environment. 2235 * environment.
2225 * 2236 *
2226 * If the device is WUSB and not authorized, we don't attempt to read 2237 * If the device is WUSB and not authorized, we don't attempt to read
2227 * the string descriptors, as they will be errored out by the device 2238 * the string descriptors, as they will be errored out by the device
2228 * until it has been authorized. 2239 * until it has been authorized.
2229 * 2240 *
2230 * Return: 0 if successful. A negative error code otherwise. 2241 * Return: 0 if successful. A negative error code otherwise.
2231 */ 2242 */
2232 static int usb_enumerate_device(struct usb_device *udev) 2243 static int usb_enumerate_device(struct usb_device *udev)
2233 { 2244 {
2234 int err; 2245 int err;
2235 2246
2236 if (udev->config == NULL) { 2247 if (udev->config == NULL) {
2237 err = usb_get_configuration(udev); 2248 err = usb_get_configuration(udev);
2238 if (err < 0) { 2249 if (err < 0) {
2239 if (err != -ENODEV) 2250 if (err != -ENODEV)
2240 dev_err(&udev->dev, "can't read configurations, error %d\n", 2251 dev_err(&udev->dev, "can't read configurations, error %d\n",
2241 err); 2252 err);
2242 return err; 2253 return err;
2243 } 2254 }
2244 } 2255 }
2245 2256
2246 /* read the standard strings and cache them if present */ 2257 /* read the standard strings and cache them if present */
2247 udev->product = usb_cache_string(udev, udev->descriptor.iProduct); 2258 udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
2248 udev->manufacturer = usb_cache_string(udev, 2259 udev->manufacturer = usb_cache_string(udev,
2249 udev->descriptor.iManufacturer); 2260 udev->descriptor.iManufacturer);
2250 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber); 2261 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
2251 2262
2252 err = usb_enumerate_device_otg(udev); 2263 err = usb_enumerate_device_otg(udev);
2253 if (err < 0) 2264 if (err < 0)
2254 return err; 2265 return err;
2255 2266
2256 usb_detect_interface_quirks(udev); 2267 usb_detect_interface_quirks(udev);
2257 2268
2258 return 0; 2269 return 0;
2259 } 2270 }
2260 2271
2261 static void set_usb_port_removable(struct usb_device *udev) 2272 static void set_usb_port_removable(struct usb_device *udev)
2262 { 2273 {
2263 struct usb_device *hdev = udev->parent; 2274 struct usb_device *hdev = udev->parent;
2264 struct usb_hub *hub; 2275 struct usb_hub *hub;
2265 u8 port = udev->portnum; 2276 u8 port = udev->portnum;
2266 u16 wHubCharacteristics; 2277 u16 wHubCharacteristics;
2267 bool removable = true; 2278 bool removable = true;
2268 2279
2269 if (!hdev) 2280 if (!hdev)
2270 return; 2281 return;
2271 2282
2272 hub = usb_hub_to_struct_hub(udev->parent); 2283 hub = usb_hub_to_struct_hub(udev->parent);
2273 2284
2274 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); 2285 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
2275 2286
2276 if (!(wHubCharacteristics & HUB_CHAR_COMPOUND)) 2287 if (!(wHubCharacteristics & HUB_CHAR_COMPOUND))
2277 return; 2288 return;
2278 2289
2279 if (hub_is_superspeed(hdev)) { 2290 if (hub_is_superspeed(hdev)) {
2280 if (le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable) 2291 if (le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable)
2281 & (1 << port)) 2292 & (1 << port))
2282 removable = false; 2293 removable = false;
2283 } else { 2294 } else {
2284 if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) 2295 if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8)))
2285 removable = false; 2296 removable = false;
2286 } 2297 }
2287 2298
2288 if (removable) 2299 if (removable)
2289 udev->removable = USB_DEVICE_REMOVABLE; 2300 udev->removable = USB_DEVICE_REMOVABLE;
2290 else 2301 else
2291 udev->removable = USB_DEVICE_FIXED; 2302 udev->removable = USB_DEVICE_FIXED;
2292 } 2303 }
2293 2304
2294 /** 2305 /**
2295 * usb_new_device - perform initial device setup (usbcore-internal) 2306 * usb_new_device - perform initial device setup (usbcore-internal)
2296 * @udev: newly addressed device (in ADDRESS state) 2307 * @udev: newly addressed device (in ADDRESS state)
2297 * 2308 *
2298 * This is called with devices which have been detected but not fully 2309 * This is called with devices which have been detected but not fully
2299 * enumerated. The device descriptor is available, but not descriptors 2310 * enumerated. The device descriptor is available, but not descriptors
2300 * for any device configuration. The caller must have locked either 2311 * for any device configuration. The caller must have locked either
2301 * the parent hub (if udev is a normal device) or else the 2312 * the parent hub (if udev is a normal device) or else the
2302 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to 2313 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
2303 * udev has already been installed, but udev is not yet visible through 2314 * udev has already been installed, but udev is not yet visible through
2304 * sysfs or other filesystem code. 2315 * sysfs or other filesystem code.
2305 * 2316 *
2306 * This call is synchronous, and may not be used in an interrupt context. 2317 * This call is synchronous, and may not be used in an interrupt context.
2307 * 2318 *
2308 * Only the hub driver or root-hub registrar should ever call this. 2319 * Only the hub driver or root-hub registrar should ever call this.
2309 * 2320 *
2310 * Return: Whether the device is configured properly or not. Zero if the 2321 * Return: Whether the device is configured properly or not. Zero if the
2311 * interface was registered with the driver core; else a negative errno 2322 * interface was registered with the driver core; else a negative errno
2312 * value. 2323 * value.
2313 * 2324 *
2314 */ 2325 */
2315 int usb_new_device(struct usb_device *udev) 2326 int usb_new_device(struct usb_device *udev)
2316 { 2327 {
2317 int err; 2328 int err;
2318 2329
2319 if (udev->parent) { 2330 if (udev->parent) {
2320 /* Initialize non-root-hub device wakeup to disabled; 2331 /* Initialize non-root-hub device wakeup to disabled;
2321 * device (un)configuration controls wakeup capable 2332 * device (un)configuration controls wakeup capable
2322 * sysfs power/wakeup controls wakeup enabled/disabled 2333 * sysfs power/wakeup controls wakeup enabled/disabled
2323 */ 2334 */
2324 device_init_wakeup(&udev->dev, 0); 2335 device_init_wakeup(&udev->dev, 0);
2325 } 2336 }
2326 2337
2327 /* Tell the runtime-PM framework the device is active */ 2338 /* Tell the runtime-PM framework the device is active */
2328 pm_runtime_set_active(&udev->dev); 2339 pm_runtime_set_active(&udev->dev);
2329 pm_runtime_get_noresume(&udev->dev); 2340 pm_runtime_get_noresume(&udev->dev);
2330 pm_runtime_use_autosuspend(&udev->dev); 2341 pm_runtime_use_autosuspend(&udev->dev);
2331 pm_runtime_enable(&udev->dev); 2342 pm_runtime_enable(&udev->dev);
2332 2343
2333 /* By default, forbid autosuspend for all devices. It will be 2344 /* By default, forbid autosuspend for all devices. It will be
2334 * allowed for hubs during binding. 2345 * allowed for hubs during binding.
2335 */ 2346 */
2336 usb_disable_autosuspend(udev); 2347 usb_disable_autosuspend(udev);
2337 2348
2338 err = usb_enumerate_device(udev); /* Read descriptors */ 2349 err = usb_enumerate_device(udev); /* Read descriptors */
2339 if (err < 0) 2350 if (err < 0)
2340 goto fail; 2351 goto fail;
2341 dev_dbg(&udev->dev, "udev %d, busnum %d, minor = %d\n", 2352 dev_dbg(&udev->dev, "udev %d, busnum %d, minor = %d\n",
2342 udev->devnum, udev->bus->busnum, 2353 udev->devnum, udev->bus->busnum,
2343 (((udev->bus->busnum-1) * 128) + (udev->devnum-1))); 2354 (((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
2344 /* export the usbdev device-node for libusb */ 2355 /* export the usbdev device-node for libusb */
2345 udev->dev.devt = MKDEV(USB_DEVICE_MAJOR, 2356 udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
2346 (((udev->bus->busnum-1) * 128) + (udev->devnum-1))); 2357 (((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
2347 2358
2348 /* Tell the world! */ 2359 /* Tell the world! */
2349 announce_device(udev); 2360 announce_device(udev);
2350 2361
2351 if (udev->serial) 2362 if (udev->serial)
2352 add_device_randomness(udev->serial, strlen(udev->serial)); 2363 add_device_randomness(udev->serial, strlen(udev->serial));
2353 if (udev->product) 2364 if (udev->product)
2354 add_device_randomness(udev->product, strlen(udev->product)); 2365 add_device_randomness(udev->product, strlen(udev->product));
2355 if (udev->manufacturer) 2366 if (udev->manufacturer)
2356 add_device_randomness(udev->manufacturer, 2367 add_device_randomness(udev->manufacturer,
2357 strlen(udev->manufacturer)); 2368 strlen(udev->manufacturer));
2358 2369
2359 device_enable_async_suspend(&udev->dev); 2370 device_enable_async_suspend(&udev->dev);
2360 2371
2361 /* 2372 /*
2362 * check whether the hub marks this port as non-removable. Do it 2373 * check whether the hub marks this port as non-removable. Do it
2363 * now so that platform-specific data can override it in 2374 * now so that platform-specific data can override it in
2364 * device_add() 2375 * device_add()
2365 */ 2376 */
2366 if (udev->parent) 2377 if (udev->parent)
2367 set_usb_port_removable(udev); 2378 set_usb_port_removable(udev);
2368 2379
2369 /* Register the device. The device driver is responsible 2380 /* Register the device. The device driver is responsible
2370 * for configuring the device and invoking the add-device 2381 * for configuring the device and invoking the add-device
2371 * notifier chain (used by usbfs and possibly others). 2382 * notifier chain (used by usbfs and possibly others).
2372 */ 2383 */
2373 err = device_add(&udev->dev); 2384 err = device_add(&udev->dev);
2374 if (err) { 2385 if (err) {
2375 dev_err(&udev->dev, "can't device_add, error %d\n", err); 2386 dev_err(&udev->dev, "can't device_add, error %d\n", err);
2376 goto fail; 2387 goto fail;
2377 } 2388 }
2378 2389
2379 /* Create link files between child device and usb port device. */ 2390 /* Create link files between child device and usb port device. */
2380 if (udev->parent) { 2391 if (udev->parent) {
2381 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); 2392 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
2382 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; 2393 struct usb_port *port_dev = hub->ports[udev->portnum - 1];
2383 2394
2384 err = sysfs_create_link(&udev->dev.kobj, 2395 err = sysfs_create_link(&udev->dev.kobj,
2385 &port_dev->dev.kobj, "port"); 2396 &port_dev->dev.kobj, "port");
2386 if (err) 2397 if (err)
2387 goto fail; 2398 goto fail;
2388 2399
2389 err = sysfs_create_link(&port_dev->dev.kobj, 2400 err = sysfs_create_link(&port_dev->dev.kobj,
2390 &udev->dev.kobj, "device"); 2401 &udev->dev.kobj, "device");
2391 if (err) { 2402 if (err) {
2392 sysfs_remove_link(&udev->dev.kobj, "port"); 2403 sysfs_remove_link(&udev->dev.kobj, "port");
2393 goto fail; 2404 goto fail;
2394 } 2405 }
2395 2406
2396 pm_runtime_get_sync(&port_dev->dev); 2407 pm_runtime_get_sync(&port_dev->dev);
2397 } 2408 }
2398 2409
2399 (void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev); 2410 (void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev);
2400 usb_mark_last_busy(udev); 2411 usb_mark_last_busy(udev);
2401 pm_runtime_put_sync_autosuspend(&udev->dev); 2412 pm_runtime_put_sync_autosuspend(&udev->dev);
2402 return err; 2413 return err;
2403 2414
2404 fail: 2415 fail:
2405 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 2416 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
2406 pm_runtime_disable(&udev->dev); 2417 pm_runtime_disable(&udev->dev);
2407 pm_runtime_set_suspended(&udev->dev); 2418 pm_runtime_set_suspended(&udev->dev);
2408 return err; 2419 return err;
2409 } 2420 }
2410 2421
2411 2422
2412 /** 2423 /**
2413 * usb_deauthorize_device - deauthorize a device (usbcore-internal) 2424 * usb_deauthorize_device - deauthorize a device (usbcore-internal)
2414 * @usb_dev: USB device 2425 * @usb_dev: USB device
2415 * 2426 *
2416 * Move the USB device to a very basic state where interfaces are disabled 2427 * Move the USB device to a very basic state where interfaces are disabled
2417 * and the device is in fact unconfigured and unusable. 2428 * and the device is in fact unconfigured and unusable.
2418 * 2429 *
2419 * We share a lock (that we have) with device_del(), so we need to 2430 * We share a lock (that we have) with device_del(), so we need to
2420 * defer its call. 2431 * defer its call.
2421 * 2432 *
2422 * Return: 0. 2433 * Return: 0.
2423 */ 2434 */
2424 int usb_deauthorize_device(struct usb_device *usb_dev) 2435 int usb_deauthorize_device(struct usb_device *usb_dev)
2425 { 2436 {
2426 usb_lock_device(usb_dev); 2437 usb_lock_device(usb_dev);
2427 if (usb_dev->authorized == 0) 2438 if (usb_dev->authorized == 0)
2428 goto out_unauthorized; 2439 goto out_unauthorized;
2429 2440
2430 usb_dev->authorized = 0; 2441 usb_dev->authorized = 0;
2431 usb_set_configuration(usb_dev, -1); 2442 usb_set_configuration(usb_dev, -1);
2432 2443
2433 out_unauthorized: 2444 out_unauthorized:
2434 usb_unlock_device(usb_dev); 2445 usb_unlock_device(usb_dev);
2435 return 0; 2446 return 0;
2436 } 2447 }
2437 2448
2438 2449
2439 int usb_authorize_device(struct usb_device *usb_dev) 2450 int usb_authorize_device(struct usb_device *usb_dev)
2440 { 2451 {
2441 int result = 0, c; 2452 int result = 0, c;
2442 2453
2443 usb_lock_device(usb_dev); 2454 usb_lock_device(usb_dev);
2444 if (usb_dev->authorized == 1) 2455 if (usb_dev->authorized == 1)
2445 goto out_authorized; 2456 goto out_authorized;
2446 2457
2447 result = usb_autoresume_device(usb_dev); 2458 result = usb_autoresume_device(usb_dev);
2448 if (result < 0) { 2459 if (result < 0) {
2449 dev_err(&usb_dev->dev, 2460 dev_err(&usb_dev->dev,
2450 "can't autoresume for authorization: %d\n", result); 2461 "can't autoresume for authorization: %d\n", result);
2451 goto error_autoresume; 2462 goto error_autoresume;
2452 } 2463 }
2453 result = usb_get_device_descriptor(usb_dev, sizeof(usb_dev->descriptor)); 2464 result = usb_get_device_descriptor(usb_dev, sizeof(usb_dev->descriptor));
2454 if (result < 0) { 2465 if (result < 0) {
2455 dev_err(&usb_dev->dev, "can't re-read device descriptor for " 2466 dev_err(&usb_dev->dev, "can't re-read device descriptor for "
2456 "authorization: %d\n", result); 2467 "authorization: %d\n", result);
2457 goto error_device_descriptor; 2468 goto error_device_descriptor;
2458 } 2469 }
2459 2470
2460 usb_dev->authorized = 1; 2471 usb_dev->authorized = 1;
2461 /* Choose and set the configuration. This registers the interfaces 2472 /* Choose and set the configuration. This registers the interfaces
2462 * with the driver core and lets interface drivers bind to them. 2473 * with the driver core and lets interface drivers bind to them.
2463 */ 2474 */
2464 c = usb_choose_configuration(usb_dev); 2475 c = usb_choose_configuration(usb_dev);
2465 if (c >= 0) { 2476 if (c >= 0) {
2466 result = usb_set_configuration(usb_dev, c); 2477 result = usb_set_configuration(usb_dev, c);
2467 if (result) { 2478 if (result) {
2468 dev_err(&usb_dev->dev, 2479 dev_err(&usb_dev->dev,
2469 "can't set config #%d, error %d\n", c, result); 2480 "can't set config #%d, error %d\n", c, result);
2470 /* This need not be fatal. The user can try to 2481 /* This need not be fatal. The user can try to
2471 * set other configurations. */ 2482 * set other configurations. */
2472 } 2483 }
2473 } 2484 }
2474 dev_info(&usb_dev->dev, "authorized to connect\n"); 2485 dev_info(&usb_dev->dev, "authorized to connect\n");
2475 2486
2476 error_device_descriptor: 2487 error_device_descriptor:
2477 usb_autosuspend_device(usb_dev); 2488 usb_autosuspend_device(usb_dev);
2478 error_autoresume: 2489 error_autoresume:
2479 out_authorized: 2490 out_authorized:
2480 usb_unlock_device(usb_dev); /* complements locktree */ 2491 usb_unlock_device(usb_dev); /* complements locktree */
2481 return result; 2492 return result;
2482 } 2493 }
2483 2494
2484 2495
2485 /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */ 2496 /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */
2486 static unsigned hub_is_wusb(struct usb_hub *hub) 2497 static unsigned hub_is_wusb(struct usb_hub *hub)
2487 { 2498 {
2488 struct usb_hcd *hcd; 2499 struct usb_hcd *hcd;
2489 if (hub->hdev->parent != NULL) /* not a root hub? */ 2500 if (hub->hdev->parent != NULL) /* not a root hub? */
2490 return 0; 2501 return 0;
2491 hcd = container_of(hub->hdev->bus, struct usb_hcd, self); 2502 hcd = container_of(hub->hdev->bus, struct usb_hcd, self);
2492 return hcd->wireless; 2503 return hcd->wireless;
2493 } 2504 }
2494 2505
2495 2506
2496 #define PORT_RESET_TRIES 5 2507 #define PORT_RESET_TRIES 5
2497 #define SET_ADDRESS_TRIES 2 2508 #define SET_ADDRESS_TRIES 2
2498 #define GET_DESCRIPTOR_TRIES 2 2509 #define GET_DESCRIPTOR_TRIES 2
2499 #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1)) 2510 #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1))
2500 #define USE_NEW_SCHEME(i) ((i) / 2 == (int)old_scheme_first) 2511 #define USE_NEW_SCHEME(i) ((i) / 2 == (int)old_scheme_first)
2501 2512
2502 #define HUB_ROOT_RESET_TIME 50 /* times are in msec */ 2513 #define HUB_ROOT_RESET_TIME 50 /* times are in msec */
2503 #define HUB_SHORT_RESET_TIME 10 2514 #define HUB_SHORT_RESET_TIME 10
2504 #define HUB_BH_RESET_TIME 50 2515 #define HUB_BH_RESET_TIME 50
2505 #define HUB_LONG_RESET_TIME 200 2516 #define HUB_LONG_RESET_TIME 200
2506 #define HUB_RESET_TIMEOUT 800 2517 #define HUB_RESET_TIMEOUT 800
2507 2518
2508 /* 2519 /*
2509 * "New scheme" enumeration causes an extra state transition to be 2520 * "New scheme" enumeration causes an extra state transition to be
2510 * exposed to an xhci host and causes USB3 devices to receive control 2521 * exposed to an xhci host and causes USB3 devices to receive control
2511 * commands in the default state. This has been seen to cause 2522 * commands in the default state. This has been seen to cause
2512 * enumeration failures, so disable this enumeration scheme for USB3 2523 * enumeration failures, so disable this enumeration scheme for USB3
2513 * devices. 2524 * devices.
2514 */ 2525 */
2515 static bool use_new_scheme(struct usb_device *udev, int retry) 2526 static bool use_new_scheme(struct usb_device *udev, int retry)
2516 { 2527 {
2517 if (udev->speed == USB_SPEED_SUPER) 2528 if (udev->speed == USB_SPEED_SUPER)
2518 return false; 2529 return false;
2519 2530
2520 return USE_NEW_SCHEME(retry); 2531 return USE_NEW_SCHEME(retry);
2521 } 2532 }
2522 2533
2523 static int hub_port_reset(struct usb_hub *hub, int port1, 2534 static int hub_port_reset(struct usb_hub *hub, int port1,
2524 struct usb_device *udev, unsigned int delay, bool warm); 2535 struct usb_device *udev, unsigned int delay, bool warm);
2525 2536
2526 /* Is a USB 3.0 port in the Inactive or Compliance Mode state? 2537 /* Is a USB 3.0 port in the Inactive or Compliance Mode state?
2527 * Port worm reset is required to recover 2538 * Port worm reset is required to recover
2528 */ 2539 */
2529 static bool hub_port_warm_reset_required(struct usb_hub *hub, u16 portstatus) 2540 static bool hub_port_warm_reset_required(struct usb_hub *hub, u16 portstatus)
2530 { 2541 {
2531 return hub_is_superspeed(hub->hdev) && 2542 return hub_is_superspeed(hub->hdev) &&
2532 (((portstatus & USB_PORT_STAT_LINK_STATE) == 2543 (((portstatus & USB_PORT_STAT_LINK_STATE) ==
2533 USB_SS_PORT_LS_SS_INACTIVE) || 2544 USB_SS_PORT_LS_SS_INACTIVE) ||
2534 ((portstatus & USB_PORT_STAT_LINK_STATE) == 2545 ((portstatus & USB_PORT_STAT_LINK_STATE) ==
2535 USB_SS_PORT_LS_COMP_MOD)) ; 2546 USB_SS_PORT_LS_COMP_MOD)) ;
2536 } 2547 }
2537 2548
2538 static int hub_port_wait_reset(struct usb_hub *hub, int port1, 2549 static int hub_port_wait_reset(struct usb_hub *hub, int port1,
2539 struct usb_device *udev, unsigned int delay, bool warm) 2550 struct usb_device *udev, unsigned int delay, bool warm)
2540 { 2551 {
2541 int delay_time, ret; 2552 int delay_time, ret;
2542 u16 portstatus; 2553 u16 portstatus;
2543 u16 portchange; 2554 u16 portchange;
2544 2555
2545 for (delay_time = 0; 2556 for (delay_time = 0;
2546 delay_time < HUB_RESET_TIMEOUT; 2557 delay_time < HUB_RESET_TIMEOUT;
2547 delay_time += delay) { 2558 delay_time += delay) {
2548 /* wait to give the device a chance to reset */ 2559 /* wait to give the device a chance to reset */
2549 msleep(delay); 2560 msleep(delay);
2550 2561
2551 /* read and decode port status */ 2562 /* read and decode port status */
2552 ret = hub_port_status(hub, port1, &portstatus, &portchange); 2563 ret = hub_port_status(hub, port1, &portstatus, &portchange);
2553 if (ret < 0) 2564 if (ret < 0)
2554 return ret; 2565 return ret;
2555 2566
2556 /* The port state is unknown until the reset completes. */ 2567 /* The port state is unknown until the reset completes. */
2557 if (!(portstatus & USB_PORT_STAT_RESET)) 2568 if (!(portstatus & USB_PORT_STAT_RESET))
2558 break; 2569 break;
2559 2570
2560 /* switch to the long delay after two short delay failures */ 2571 /* switch to the long delay after two short delay failures */
2561 if (delay_time >= 2 * HUB_SHORT_RESET_TIME) 2572 if (delay_time >= 2 * HUB_SHORT_RESET_TIME)
2562 delay = HUB_LONG_RESET_TIME; 2573 delay = HUB_LONG_RESET_TIME;
2563 2574
2564 dev_dbg (hub->intfdev, 2575 dev_dbg (hub->intfdev,
2565 "port %d not %sreset yet, waiting %dms\n", 2576 "port %d not %sreset yet, waiting %dms\n",
2566 port1, warm ? "warm " : "", delay); 2577 port1, warm ? "warm " : "", delay);
2567 } 2578 }
2568 2579
2569 if ((portstatus & USB_PORT_STAT_RESET)) 2580 if ((portstatus & USB_PORT_STAT_RESET))
2570 return -EBUSY; 2581 return -EBUSY;
2571 2582
2572 if (hub_port_warm_reset_required(hub, portstatus)) 2583 if (hub_port_warm_reset_required(hub, portstatus))
2573 return -ENOTCONN; 2584 return -ENOTCONN;
2574 2585
2575 /* Device went away? */ 2586 /* Device went away? */
2576 if (!(portstatus & USB_PORT_STAT_CONNECTION)) 2587 if (!(portstatus & USB_PORT_STAT_CONNECTION))
2577 return -ENOTCONN; 2588 return -ENOTCONN;
2578 2589
2579 /* bomb out completely if the connection bounced. A USB 3.0 2590 /* bomb out completely if the connection bounced. A USB 3.0
2580 * connection may bounce if multiple warm resets were issued, 2591 * connection may bounce if multiple warm resets were issued,
2581 * but the device may have successfully re-connected. Ignore it. 2592 * but the device may have successfully re-connected. Ignore it.
2582 */ 2593 */
2583 if (!hub_is_superspeed(hub->hdev) && 2594 if (!hub_is_superspeed(hub->hdev) &&
2584 (portchange & USB_PORT_STAT_C_CONNECTION)) 2595 (portchange & USB_PORT_STAT_C_CONNECTION))
2585 return -ENOTCONN; 2596 return -ENOTCONN;
2586 2597
2587 if (!(portstatus & USB_PORT_STAT_ENABLE)) 2598 if (!(portstatus & USB_PORT_STAT_ENABLE))
2588 return -EBUSY; 2599 return -EBUSY;
2589 2600
2590 if (!udev) 2601 if (!udev)
2591 return 0; 2602 return 0;
2592 2603
2593 if (hub_is_wusb(hub)) 2604 if (hub_is_wusb(hub))
2594 udev->speed = USB_SPEED_WIRELESS; 2605 udev->speed = USB_SPEED_WIRELESS;
2595 else if (hub_is_superspeed(hub->hdev)) 2606 else if (hub_is_superspeed(hub->hdev))
2596 udev->speed = USB_SPEED_SUPER; 2607 udev->speed = USB_SPEED_SUPER;
2597 else if (portstatus & USB_PORT_STAT_HIGH_SPEED) 2608 else if (portstatus & USB_PORT_STAT_HIGH_SPEED)
2598 udev->speed = USB_SPEED_HIGH; 2609 udev->speed = USB_SPEED_HIGH;
2599 else if (portstatus & USB_PORT_STAT_LOW_SPEED) 2610 else if (portstatus & USB_PORT_STAT_LOW_SPEED)
2600 udev->speed = USB_SPEED_LOW; 2611 udev->speed = USB_SPEED_LOW;
2601 else 2612 else
2602 udev->speed = USB_SPEED_FULL; 2613 udev->speed = USB_SPEED_FULL;
2603 return 0; 2614 return 0;
2604 } 2615 }
2605 2616
2606 static void hub_port_finish_reset(struct usb_hub *hub, int port1, 2617 static void hub_port_finish_reset(struct usb_hub *hub, int port1,
2607 struct usb_device *udev, int *status) 2618 struct usb_device *udev, int *status)
2608 { 2619 {
2609 switch (*status) { 2620 switch (*status) {
2610 case 0: 2621 case 0:
2611 /* TRSTRCY = 10 ms; plus some extra */ 2622 /* TRSTRCY = 10 ms; plus some extra */
2612 msleep(10 + 40); 2623 msleep(10 + 40);
2613 if (udev) { 2624 if (udev) {
2614 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 2625 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
2615 2626
2616 update_devnum(udev, 0); 2627 update_devnum(udev, 0);
2617 /* The xHC may think the device is already reset, 2628 /* The xHC may think the device is already reset,
2618 * so ignore the status. 2629 * so ignore the status.
2619 */ 2630 */
2620 if (hcd->driver->reset_device) 2631 if (hcd->driver->reset_device)
2621 hcd->driver->reset_device(hcd, udev); 2632 hcd->driver->reset_device(hcd, udev);
2622 } 2633 }
2623 /* FALL THROUGH */ 2634 /* FALL THROUGH */
2624 case -ENOTCONN: 2635 case -ENOTCONN:
2625 case -ENODEV: 2636 case -ENODEV:
2626 usb_clear_port_feature(hub->hdev, 2637 usb_clear_port_feature(hub->hdev,
2627 port1, USB_PORT_FEAT_C_RESET); 2638 port1, USB_PORT_FEAT_C_RESET);
2628 if (hub_is_superspeed(hub->hdev)) { 2639 if (hub_is_superspeed(hub->hdev)) {
2629 usb_clear_port_feature(hub->hdev, port1, 2640 usb_clear_port_feature(hub->hdev, port1,
2630 USB_PORT_FEAT_C_BH_PORT_RESET); 2641 USB_PORT_FEAT_C_BH_PORT_RESET);
2631 usb_clear_port_feature(hub->hdev, port1, 2642 usb_clear_port_feature(hub->hdev, port1,
2632 USB_PORT_FEAT_C_PORT_LINK_STATE); 2643 USB_PORT_FEAT_C_PORT_LINK_STATE);
2633 usb_clear_port_feature(hub->hdev, port1, 2644 usb_clear_port_feature(hub->hdev, port1,
2634 USB_PORT_FEAT_C_CONNECTION); 2645 USB_PORT_FEAT_C_CONNECTION);
2635 } 2646 }
2636 if (udev) 2647 if (udev)
2637 usb_set_device_state(udev, *status 2648 usb_set_device_state(udev, *status
2638 ? USB_STATE_NOTATTACHED 2649 ? USB_STATE_NOTATTACHED
2639 : USB_STATE_DEFAULT); 2650 : USB_STATE_DEFAULT);
2640 break; 2651 break;
2641 } 2652 }
2642 } 2653 }
2643 2654
2644 /* Handle port reset and port warm(BH) reset (for USB3 protocol ports) */ 2655 /* Handle port reset and port warm(BH) reset (for USB3 protocol ports) */
2645 static int hub_port_reset(struct usb_hub *hub, int port1, 2656 static int hub_port_reset(struct usb_hub *hub, int port1,
2646 struct usb_device *udev, unsigned int delay, bool warm) 2657 struct usb_device *udev, unsigned int delay, bool warm)
2647 { 2658 {
2648 int i, status; 2659 int i, status;
2649 u16 portchange, portstatus; 2660 u16 portchange, portstatus;
2650 2661
2651 if (!hub_is_superspeed(hub->hdev)) { 2662 if (!hub_is_superspeed(hub->hdev)) {
2652 if (warm) { 2663 if (warm) {
2653 dev_err(hub->intfdev, "only USB3 hub support " 2664 dev_err(hub->intfdev, "only USB3 hub support "
2654 "warm reset\n"); 2665 "warm reset\n");
2655 return -EINVAL; 2666 return -EINVAL;
2656 } 2667 }
2657 /* Block EHCI CF initialization during the port reset. 2668 /* Block EHCI CF initialization during the port reset.
2658 * Some companion controllers don't like it when they mix. 2669 * Some companion controllers don't like it when they mix.
2659 */ 2670 */
2660 down_read(&ehci_cf_port_reset_rwsem); 2671 down_read(&ehci_cf_port_reset_rwsem);
2661 } else if (!warm) { 2672 } else if (!warm) {
2662 /* 2673 /*
2663 * If the caller hasn't explicitly requested a warm reset, 2674 * If the caller hasn't explicitly requested a warm reset,
2664 * double check and see if one is needed. 2675 * double check and see if one is needed.
2665 */ 2676 */
2666 status = hub_port_status(hub, port1, 2677 status = hub_port_status(hub, port1,
2667 &portstatus, &portchange); 2678 &portstatus, &portchange);
2668 if (status < 0) 2679 if (status < 0)
2669 goto done; 2680 goto done;
2670 2681
2671 if (hub_port_warm_reset_required(hub, portstatus)) 2682 if (hub_port_warm_reset_required(hub, portstatus))
2672 warm = true; 2683 warm = true;
2673 } 2684 }
2674 2685
2675 /* Reset the port */ 2686 /* Reset the port */
2676 for (i = 0; i < PORT_RESET_TRIES; i++) { 2687 for (i = 0; i < PORT_RESET_TRIES; i++) {
2677 status = set_port_feature(hub->hdev, port1, (warm ? 2688 status = set_port_feature(hub->hdev, port1, (warm ?
2678 USB_PORT_FEAT_BH_PORT_RESET : 2689 USB_PORT_FEAT_BH_PORT_RESET :
2679 USB_PORT_FEAT_RESET)); 2690 USB_PORT_FEAT_RESET));
2680 if (status == -ENODEV) { 2691 if (status == -ENODEV) {
2681 ; /* The hub is gone */ 2692 ; /* The hub is gone */
2682 } else if (status) { 2693 } else if (status) {
2683 dev_err(hub->intfdev, 2694 dev_err(hub->intfdev,
2684 "cannot %sreset port %d (err = %d)\n", 2695 "cannot %sreset port %d (err = %d)\n",
2685 warm ? "warm " : "", port1, status); 2696 warm ? "warm " : "", port1, status);
2686 } else { 2697 } else {
2687 status = hub_port_wait_reset(hub, port1, udev, delay, 2698 status = hub_port_wait_reset(hub, port1, udev, delay,
2688 warm); 2699 warm);
2689 if (status && status != -ENOTCONN && status != -ENODEV) 2700 if (status && status != -ENOTCONN && status != -ENODEV)
2690 dev_dbg(hub->intfdev, 2701 dev_dbg(hub->intfdev,
2691 "port_wait_reset: err = %d\n", 2702 "port_wait_reset: err = %d\n",
2692 status); 2703 status);
2693 } 2704 }
2694 2705
2695 /* Check for disconnect or reset */ 2706 /* Check for disconnect or reset */
2696 if (status == 0 || status == -ENOTCONN || status == -ENODEV) { 2707 if (status == 0 || status == -ENOTCONN || status == -ENODEV) {
2697 hub_port_finish_reset(hub, port1, udev, &status); 2708 hub_port_finish_reset(hub, port1, udev, &status);
2698 2709
2699 if (!hub_is_superspeed(hub->hdev)) 2710 if (!hub_is_superspeed(hub->hdev))
2700 goto done; 2711 goto done;
2701 2712
2702 /* 2713 /*
2703 * If a USB 3.0 device migrates from reset to an error 2714 * If a USB 3.0 device migrates from reset to an error
2704 * state, re-issue the warm reset. 2715 * state, re-issue the warm reset.
2705 */ 2716 */
2706 if (hub_port_status(hub, port1, 2717 if (hub_port_status(hub, port1,
2707 &portstatus, &portchange) < 0) 2718 &portstatus, &portchange) < 0)
2708 goto done; 2719 goto done;
2709 2720
2710 if (!hub_port_warm_reset_required(hub, portstatus)) 2721 if (!hub_port_warm_reset_required(hub, portstatus))
2711 goto done; 2722 goto done;
2712 2723
2713 /* 2724 /*
2714 * If the port is in SS.Inactive or Compliance Mode, the 2725 * If the port is in SS.Inactive or Compliance Mode, the
2715 * hot or warm reset failed. Try another warm reset. 2726 * hot or warm reset failed. Try another warm reset.
2716 */ 2727 */
2717 if (!warm) { 2728 if (!warm) {
2718 dev_dbg(hub->intfdev, "hot reset failed, warm reset port %d\n", 2729 dev_dbg(hub->intfdev, "hot reset failed, warm reset port %d\n",
2719 port1); 2730 port1);
2720 warm = true; 2731 warm = true;
2721 } 2732 }
2722 } 2733 }
2723 2734
2724 dev_dbg (hub->intfdev, 2735 dev_dbg (hub->intfdev,
2725 "port %d not enabled, trying %sreset again...\n", 2736 "port %d not enabled, trying %sreset again...\n",
2726 port1, warm ? "warm " : ""); 2737 port1, warm ? "warm " : "");
2727 delay = HUB_LONG_RESET_TIME; 2738 delay = HUB_LONG_RESET_TIME;
2728 } 2739 }
2729 2740
2730 dev_err (hub->intfdev, 2741 dev_err (hub->intfdev,
2731 "Cannot enable port %i. Maybe the USB cable is bad?\n", 2742 "Cannot enable port %i. Maybe the USB cable is bad?\n",
2732 port1); 2743 port1);
2733 2744
2734 done: 2745 done:
2735 if (!hub_is_superspeed(hub->hdev)) 2746 if (!hub_is_superspeed(hub->hdev))
2736 up_read(&ehci_cf_port_reset_rwsem); 2747 up_read(&ehci_cf_port_reset_rwsem);
2737 2748
2738 return status; 2749 return status;
2739 } 2750 }
2740 2751
2741 /* Check if a port is power on */ 2752 /* Check if a port is power on */
2742 static int port_is_power_on(struct usb_hub *hub, unsigned portstatus) 2753 static int port_is_power_on(struct usb_hub *hub, unsigned portstatus)
2743 { 2754 {
2744 int ret = 0; 2755 int ret = 0;
2745 2756
2746 if (hub_is_superspeed(hub->hdev)) { 2757 if (hub_is_superspeed(hub->hdev)) {
2747 if (portstatus & USB_SS_PORT_STAT_POWER) 2758 if (portstatus & USB_SS_PORT_STAT_POWER)
2748 ret = 1; 2759 ret = 1;
2749 } else { 2760 } else {
2750 if (portstatus & USB_PORT_STAT_POWER) 2761 if (portstatus & USB_PORT_STAT_POWER)
2751 ret = 1; 2762 ret = 1;
2752 } 2763 }
2753 2764
2754 return ret; 2765 return ret;
2755 } 2766 }
2756 2767
2757 #ifdef CONFIG_PM 2768 #ifdef CONFIG_PM
2758 2769
2759 /* Check if a port is suspended(USB2.0 port) or in U3 state(USB3.0 port) */ 2770 /* Check if a port is suspended(USB2.0 port) or in U3 state(USB3.0 port) */
2760 static int port_is_suspended(struct usb_hub *hub, unsigned portstatus) 2771 static int port_is_suspended(struct usb_hub *hub, unsigned portstatus)
2761 { 2772 {
2762 int ret = 0; 2773 int ret = 0;
2763 2774
2764 if (hub_is_superspeed(hub->hdev)) { 2775 if (hub_is_superspeed(hub->hdev)) {
2765 if ((portstatus & USB_PORT_STAT_LINK_STATE) 2776 if ((portstatus & USB_PORT_STAT_LINK_STATE)
2766 == USB_SS_PORT_LS_U3) 2777 == USB_SS_PORT_LS_U3)
2767 ret = 1; 2778 ret = 1;
2768 } else { 2779 } else {
2769 if (portstatus & USB_PORT_STAT_SUSPEND) 2780 if (portstatus & USB_PORT_STAT_SUSPEND)
2770 ret = 1; 2781 ret = 1;
2771 } 2782 }
2772 2783
2773 return ret; 2784 return ret;
2774 } 2785 }
2775 2786
2776 /* Determine whether the device on a port is ready for a normal resume, 2787 /* Determine whether the device on a port is ready for a normal resume,
2777 * is ready for a reset-resume, or should be disconnected. 2788 * is ready for a reset-resume, or should be disconnected.
2778 */ 2789 */
2779 static int check_port_resume_type(struct usb_device *udev, 2790 static int check_port_resume_type(struct usb_device *udev,
2780 struct usb_hub *hub, int port1, 2791 struct usb_hub *hub, int port1,
2781 int status, unsigned portchange, unsigned portstatus) 2792 int status, unsigned portchange, unsigned portstatus)
2782 { 2793 {
2783 /* Is the device still present? */ 2794 /* Is the device still present? */
2784 if (status || port_is_suspended(hub, portstatus) || 2795 if (status || port_is_suspended(hub, portstatus) ||
2785 !port_is_power_on(hub, portstatus) || 2796 !port_is_power_on(hub, portstatus) ||
2786 !(portstatus & USB_PORT_STAT_CONNECTION)) { 2797 !(portstatus & USB_PORT_STAT_CONNECTION)) {
2787 if (status >= 0) 2798 if (status >= 0)
2788 status = -ENODEV; 2799 status = -ENODEV;
2789 } 2800 }
2790 2801
2791 /* Can't do a normal resume if the port isn't enabled, 2802 /* Can't do a normal resume if the port isn't enabled,
2792 * so try a reset-resume instead. 2803 * so try a reset-resume instead.
2793 */ 2804 */
2794 else if (!(portstatus & USB_PORT_STAT_ENABLE) && !udev->reset_resume) { 2805 else if (!(portstatus & USB_PORT_STAT_ENABLE) && !udev->reset_resume) {
2795 if (udev->persist_enabled) 2806 if (udev->persist_enabled)
2796 udev->reset_resume = 1; 2807 udev->reset_resume = 1;
2797 else 2808 else
2798 status = -ENODEV; 2809 status = -ENODEV;
2799 } 2810 }
2800 2811
2801 if (status) { 2812 if (status) {
2802 dev_dbg(hub->intfdev, 2813 dev_dbg(hub->intfdev,
2803 "port %d status %04x.%04x after resume, %d\n", 2814 "port %d status %04x.%04x after resume, %d\n",
2804 port1, portchange, portstatus, status); 2815 port1, portchange, portstatus, status);
2805 } else if (udev->reset_resume) { 2816 } else if (udev->reset_resume) {
2806 2817
2807 /* Late port handoff can set status-change bits */ 2818 /* Late port handoff can set status-change bits */
2808 if (portchange & USB_PORT_STAT_C_CONNECTION) 2819 if (portchange & USB_PORT_STAT_C_CONNECTION)
2809 usb_clear_port_feature(hub->hdev, port1, 2820 usb_clear_port_feature(hub->hdev, port1,
2810 USB_PORT_FEAT_C_CONNECTION); 2821 USB_PORT_FEAT_C_CONNECTION);
2811 if (portchange & USB_PORT_STAT_C_ENABLE) 2822 if (portchange & USB_PORT_STAT_C_ENABLE)
2812 usb_clear_port_feature(hub->hdev, port1, 2823 usb_clear_port_feature(hub->hdev, port1,
2813 USB_PORT_FEAT_C_ENABLE); 2824 USB_PORT_FEAT_C_ENABLE);
2814 } 2825 }
2815 2826
2816 return status; 2827 return status;
2817 } 2828 }
2818 2829
2819 int usb_disable_ltm(struct usb_device *udev) 2830 int usb_disable_ltm(struct usb_device *udev)
2820 { 2831 {
2821 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 2832 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
2822 2833
2823 /* Check if the roothub and device supports LTM. */ 2834 /* Check if the roothub and device supports LTM. */
2824 if (!usb_device_supports_ltm(hcd->self.root_hub) || 2835 if (!usb_device_supports_ltm(hcd->self.root_hub) ||
2825 !usb_device_supports_ltm(udev)) 2836 !usb_device_supports_ltm(udev))
2826 return 0; 2837 return 0;
2827 2838
2828 /* Clear Feature LTM Enable can only be sent if the device is 2839 /* Clear Feature LTM Enable can only be sent if the device is
2829 * configured. 2840 * configured.
2830 */ 2841 */
2831 if (!udev->actconfig) 2842 if (!udev->actconfig)
2832 return 0; 2843 return 0;
2833 2844
2834 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 2845 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2835 USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, 2846 USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
2836 USB_DEVICE_LTM_ENABLE, 0, NULL, 0, 2847 USB_DEVICE_LTM_ENABLE, 0, NULL, 0,
2837 USB_CTRL_SET_TIMEOUT); 2848 USB_CTRL_SET_TIMEOUT);
2838 } 2849 }
2839 EXPORT_SYMBOL_GPL(usb_disable_ltm); 2850 EXPORT_SYMBOL_GPL(usb_disable_ltm);
2840 2851
2841 void usb_enable_ltm(struct usb_device *udev) 2852 void usb_enable_ltm(struct usb_device *udev)
2842 { 2853 {
2843 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 2854 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
2844 2855
2845 /* Check if the roothub and device supports LTM. */ 2856 /* Check if the roothub and device supports LTM. */
2846 if (!usb_device_supports_ltm(hcd->self.root_hub) || 2857 if (!usb_device_supports_ltm(hcd->self.root_hub) ||
2847 !usb_device_supports_ltm(udev)) 2858 !usb_device_supports_ltm(udev))
2848 return; 2859 return;
2849 2860
2850 /* Set Feature LTM Enable can only be sent if the device is 2861 /* Set Feature LTM Enable can only be sent if the device is
2851 * configured. 2862 * configured.
2852 */ 2863 */
2853 if (!udev->actconfig) 2864 if (!udev->actconfig)
2854 return; 2865 return;
2855 2866
2856 usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 2867 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2857 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, 2868 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE,
2858 USB_DEVICE_LTM_ENABLE, 0, NULL, 0, 2869 USB_DEVICE_LTM_ENABLE, 0, NULL, 0,
2859 USB_CTRL_SET_TIMEOUT); 2870 USB_CTRL_SET_TIMEOUT);
2860 } 2871 }
2861 EXPORT_SYMBOL_GPL(usb_enable_ltm); 2872 EXPORT_SYMBOL_GPL(usb_enable_ltm);
2862 2873
2863 /* 2874 /*
2864 * usb_enable_remote_wakeup - enable remote wakeup for a device 2875 * usb_enable_remote_wakeup - enable remote wakeup for a device
2865 * @udev: target device 2876 * @udev: target device
2866 * 2877 *
2867 * For USB-2 devices: Set the device's remote wakeup feature. 2878 * For USB-2 devices: Set the device's remote wakeup feature.
2868 * 2879 *
2869 * For USB-3 devices: Assume there's only one function on the device and 2880 * For USB-3 devices: Assume there's only one function on the device and
2870 * enable remote wake for the first interface. FIXME if the interface 2881 * enable remote wake for the first interface. FIXME if the interface
2871 * association descriptor shows there's more than one function. 2882 * association descriptor shows there's more than one function.
2872 */ 2883 */
2873 static int usb_enable_remote_wakeup(struct usb_device *udev) 2884 static int usb_enable_remote_wakeup(struct usb_device *udev)
2874 { 2885 {
2875 if (udev->speed < USB_SPEED_SUPER) 2886 if (udev->speed < USB_SPEED_SUPER)
2876 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 2887 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2877 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, 2888 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE,
2878 USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, 2889 USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0,
2879 USB_CTRL_SET_TIMEOUT); 2890 USB_CTRL_SET_TIMEOUT);
2880 else 2891 else
2881 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 2892 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2882 USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, 2893 USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE,
2883 USB_INTRF_FUNC_SUSPEND, 2894 USB_INTRF_FUNC_SUSPEND,
2884 USB_INTRF_FUNC_SUSPEND_RW | 2895 USB_INTRF_FUNC_SUSPEND_RW |
2885 USB_INTRF_FUNC_SUSPEND_LP, 2896 USB_INTRF_FUNC_SUSPEND_LP,
2886 NULL, 0, USB_CTRL_SET_TIMEOUT); 2897 NULL, 0, USB_CTRL_SET_TIMEOUT);
2887 } 2898 }
2888 2899
2889 /* 2900 /*
2890 * usb_disable_remote_wakeup - disable remote wakeup for a device 2901 * usb_disable_remote_wakeup - disable remote wakeup for a device
2891 * @udev: target device 2902 * @udev: target device
2892 * 2903 *
2893 * For USB-2 devices: Clear the device's remote wakeup feature. 2904 * For USB-2 devices: Clear the device's remote wakeup feature.
2894 * 2905 *
2895 * For USB-3 devices: Assume there's only one function on the device and 2906 * For USB-3 devices: Assume there's only one function on the device and
2896 * disable remote wake for the first interface. FIXME if the interface 2907 * disable remote wake for the first interface. FIXME if the interface
2897 * association descriptor shows there's more than one function. 2908 * association descriptor shows there's more than one function.
2898 */ 2909 */
2899 static int usb_disable_remote_wakeup(struct usb_device *udev) 2910 static int usb_disable_remote_wakeup(struct usb_device *udev)
2900 { 2911 {
2901 if (udev->speed < USB_SPEED_SUPER) 2912 if (udev->speed < USB_SPEED_SUPER)
2902 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 2913 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2903 USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, 2914 USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
2904 USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, 2915 USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0,
2905 USB_CTRL_SET_TIMEOUT); 2916 USB_CTRL_SET_TIMEOUT);
2906 else 2917 else
2907 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 2918 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2908 USB_REQ_CLEAR_FEATURE, USB_RECIP_INTERFACE, 2919 USB_REQ_CLEAR_FEATURE, USB_RECIP_INTERFACE,
2909 USB_INTRF_FUNC_SUSPEND, 0, NULL, 0, 2920 USB_INTRF_FUNC_SUSPEND, 0, NULL, 0,
2910 USB_CTRL_SET_TIMEOUT); 2921 USB_CTRL_SET_TIMEOUT);
2911 } 2922 }
2912 2923
2913 /* Count of wakeup-enabled devices at or below udev */ 2924 /* Count of wakeup-enabled devices at or below udev */
2914 static unsigned wakeup_enabled_descendants(struct usb_device *udev) 2925 static unsigned wakeup_enabled_descendants(struct usb_device *udev)
2915 { 2926 {
2916 struct usb_hub *hub = usb_hub_to_struct_hub(udev); 2927 struct usb_hub *hub = usb_hub_to_struct_hub(udev);
2917 2928
2918 return udev->do_remote_wakeup + 2929 return udev->do_remote_wakeup +
2919 (hub ? hub->wakeup_enabled_descendants : 0); 2930 (hub ? hub->wakeup_enabled_descendants : 0);
2920 } 2931 }
2921 2932
2922 /* 2933 /*
2923 * usb_port_suspend - suspend a usb device's upstream port 2934 * usb_port_suspend - suspend a usb device's upstream port
2924 * @udev: device that's no longer in active use, not a root hub 2935 * @udev: device that's no longer in active use, not a root hub
2925 * Context: must be able to sleep; device not locked; pm locks held 2936 * Context: must be able to sleep; device not locked; pm locks held
2926 * 2937 *
2927 * Suspends a USB device that isn't in active use, conserving power. 2938 * Suspends a USB device that isn't in active use, conserving power.
2928 * Devices may wake out of a suspend, if anything important happens, 2939 * Devices may wake out of a suspend, if anything important happens,
2929 * using the remote wakeup mechanism. They may also be taken out of 2940 * using the remote wakeup mechanism. They may also be taken out of
2930 * suspend by the host, using usb_port_resume(). It's also routine 2941 * suspend by the host, using usb_port_resume(). It's also routine
2931 * to disconnect devices while they are suspended. 2942 * to disconnect devices while they are suspended.
2932 * 2943 *
2933 * This only affects the USB hardware for a device; its interfaces 2944 * This only affects the USB hardware for a device; its interfaces
2934 * (and, for hubs, child devices) must already have been suspended. 2945 * (and, for hubs, child devices) must already have been suspended.
2935 * 2946 *
2936 * Selective port suspend reduces power; most suspended devices draw 2947 * Selective port suspend reduces power; most suspended devices draw
2937 * less than 500 uA. It's also used in OTG, along with remote wakeup. 2948 * less than 500 uA. It's also used in OTG, along with remote wakeup.
2938 * All devices below the suspended port are also suspended. 2949 * All devices below the suspended port are also suspended.
2939 * 2950 *
2940 * Devices leave suspend state when the host wakes them up. Some devices 2951 * Devices leave suspend state when the host wakes them up. Some devices
2941 * also support "remote wakeup", where the device can activate the USB 2952 * also support "remote wakeup", where the device can activate the USB
2942 * tree above them to deliver data, such as a keypress or packet. In 2953 * tree above them to deliver data, such as a keypress or packet. In
2943 * some cases, this wakes the USB host. 2954 * some cases, this wakes the USB host.
2944 * 2955 *
2945 * Suspending OTG devices may trigger HNP, if that's been enabled 2956 * Suspending OTG devices may trigger HNP, if that's been enabled
2946 * between a pair of dual-role devices. That will change roles, such 2957 * between a pair of dual-role devices. That will change roles, such
2947 * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral. 2958 * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral.
2948 * 2959 *
2949 * Devices on USB hub ports have only one "suspend" state, corresponding 2960 * Devices on USB hub ports have only one "suspend" state, corresponding
2950 * to ACPI D2, "may cause the device to lose some context". 2961 * to ACPI D2, "may cause the device to lose some context".
2951 * State transitions include: 2962 * State transitions include:
2952 * 2963 *
2953 * - suspend, resume ... when the VBUS power link stays live 2964 * - suspend, resume ... when the VBUS power link stays live
2954 * - suspend, disconnect ... VBUS lost 2965 * - suspend, disconnect ... VBUS lost
2955 * 2966 *
2956 * Once VBUS drop breaks the circuit, the port it's using has to go through 2967 * Once VBUS drop breaks the circuit, the port it's using has to go through
2957 * normal re-enumeration procedures, starting with enabling VBUS power. 2968 * normal re-enumeration procedures, starting with enabling VBUS power.
2958 * Other than re-initializing the hub (plug/unplug, except for root hubs), 2969 * Other than re-initializing the hub (plug/unplug, except for root hubs),
2959 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd 2970 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd
2960 * timer, no SRP, no requests through sysfs. 2971 * timer, no SRP, no requests through sysfs.
2961 * 2972 *
2962 * If Runtime PM isn't enabled or used, non-SuperSpeed devices may not get 2973 * If Runtime PM isn't enabled or used, non-SuperSpeed devices may not get
2963 * suspended until their bus goes into global suspend (i.e., the root 2974 * suspended until their bus goes into global suspend (i.e., the root
2964 * hub is suspended). Nevertheless, we change @udev->state to 2975 * hub is suspended). Nevertheless, we change @udev->state to
2965 * USB_STATE_SUSPENDED as this is the device's "logical" state. The actual 2976 * USB_STATE_SUSPENDED as this is the device's "logical" state. The actual
2966 * upstream port setting is stored in @udev->port_is_suspended. 2977 * upstream port setting is stored in @udev->port_is_suspended.
2967 * 2978 *
2968 * Returns 0 on success, else negative errno. 2979 * Returns 0 on success, else negative errno.
2969 */ 2980 */
2970 int usb_port_suspend(struct usb_device *udev, pm_message_t msg) 2981 int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2971 { 2982 {
2972 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); 2983 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
2973 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; 2984 struct usb_port *port_dev = hub->ports[udev->portnum - 1];
2974 int port1 = udev->portnum; 2985 int port1 = udev->portnum;
2975 int status; 2986 int status;
2976 bool really_suspend = true; 2987 bool really_suspend = true;
2977 2988
2978 /* enable remote wakeup when appropriate; this lets the device 2989 /* enable remote wakeup when appropriate; this lets the device
2979 * wake up the upstream hub (including maybe the root hub). 2990 * wake up the upstream hub (including maybe the root hub).
2980 * 2991 *
2981 * NOTE: OTG devices may issue remote wakeup (or SRP) even when 2992 * NOTE: OTG devices may issue remote wakeup (or SRP) even when
2982 * we don't explicitly enable it here. 2993 * we don't explicitly enable it here.
2983 */ 2994 */
2984 if (udev->do_remote_wakeup) { 2995 if (udev->do_remote_wakeup) {
2985 status = usb_enable_remote_wakeup(udev); 2996 status = usb_enable_remote_wakeup(udev);
2986 if (status) { 2997 if (status) {
2987 dev_dbg(&udev->dev, "won't remote wakeup, status %d\n", 2998 dev_dbg(&udev->dev, "won't remote wakeup, status %d\n",
2988 status); 2999 status);
2989 /* bail if autosuspend is requested */ 3000 /* bail if autosuspend is requested */
2990 if (PMSG_IS_AUTO(msg)) 3001 if (PMSG_IS_AUTO(msg))
2991 goto err_wakeup; 3002 goto err_wakeup;
2992 } 3003 }
2993 } 3004 }
2994 3005
2995 /* disable USB2 hardware LPM */ 3006 /* disable USB2 hardware LPM */
2996 if (udev->usb2_hw_lpm_enabled == 1) 3007 if (udev->usb2_hw_lpm_enabled == 1)
2997 usb_set_usb2_hardware_lpm(udev, 0); 3008 usb_set_usb2_hardware_lpm(udev, 0);
2998 3009
2999 if (usb_disable_ltm(udev)) { 3010 if (usb_disable_ltm(udev)) {
3000 dev_err(&udev->dev, "Failed to disable LTM before suspend\n."); 3011 dev_err(&udev->dev, "Failed to disable LTM before suspend\n.");
3001 status = -ENOMEM; 3012 status = -ENOMEM;
3002 if (PMSG_IS_AUTO(msg)) 3013 if (PMSG_IS_AUTO(msg))
3003 goto err_ltm; 3014 goto err_ltm;
3004 } 3015 }
3005 if (usb_unlocked_disable_lpm(udev)) { 3016 if (usb_unlocked_disable_lpm(udev)) {
3006 dev_err(&udev->dev, "Failed to disable LPM before suspend\n."); 3017 dev_err(&udev->dev, "Failed to disable LPM before suspend\n.");
3007 status = -ENOMEM; 3018 status = -ENOMEM;
3008 if (PMSG_IS_AUTO(msg)) 3019 if (PMSG_IS_AUTO(msg))
3009 goto err_lpm3; 3020 goto err_lpm3;
3010 } 3021 }
3011 3022
3012 /* see 7.1.7.6 */ 3023 /* see 7.1.7.6 */
3013 if (hub_is_superspeed(hub->hdev)) 3024 if (hub_is_superspeed(hub->hdev))
3014 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3); 3025 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3);
3015 3026
3016 /* 3027 /*
3017 * For system suspend, we do not need to enable the suspend feature 3028 * For system suspend, we do not need to enable the suspend feature
3018 * on individual USB-2 ports. The devices will automatically go 3029 * on individual USB-2 ports. The devices will automatically go
3019 * into suspend a few ms after the root hub stops sending packets. 3030 * into suspend a few ms after the root hub stops sending packets.
3020 * The USB 2.0 spec calls this "global suspend". 3031 * The USB 2.0 spec calls this "global suspend".
3021 * 3032 *
3022 * However, many USB hubs have a bug: They don't relay wakeup requests 3033 * However, many USB hubs have a bug: They don't relay wakeup requests
3023 * from a downstream port if the port's suspend feature isn't on. 3034 * from a downstream port if the port's suspend feature isn't on.
3024 * Therefore we will turn on the suspend feature if udev or any of its 3035 * Therefore we will turn on the suspend feature if udev or any of its
3025 * descendants is enabled for remote wakeup. 3036 * descendants is enabled for remote wakeup.
3026 */ 3037 */
3027 else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0) 3038 else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0)
3028 status = set_port_feature(hub->hdev, port1, 3039 status = set_port_feature(hub->hdev, port1,
3029 USB_PORT_FEAT_SUSPEND); 3040 USB_PORT_FEAT_SUSPEND);
3030 else { 3041 else {
3031 really_suspend = false; 3042 really_suspend = false;
3032 status = 0; 3043 status = 0;
3033 } 3044 }
3034 if (status) { 3045 if (status) {
3035 dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n", 3046 dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n",
3036 port1, status); 3047 port1, status);
3037 3048
3038 /* Try to enable USB3 LPM and LTM again */ 3049 /* Try to enable USB3 LPM and LTM again */
3039 usb_unlocked_enable_lpm(udev); 3050 usb_unlocked_enable_lpm(udev);
3040 err_lpm3: 3051 err_lpm3:
3041 usb_enable_ltm(udev); 3052 usb_enable_ltm(udev);
3042 err_ltm: 3053 err_ltm:
3043 /* Try to enable USB2 hardware LPM again */ 3054 /* Try to enable USB2 hardware LPM again */
3044 if (udev->usb2_hw_lpm_capable == 1) 3055 if (udev->usb2_hw_lpm_capable == 1)
3045 usb_set_usb2_hardware_lpm(udev, 1); 3056 usb_set_usb2_hardware_lpm(udev, 1);
3046 3057
3047 if (udev->do_remote_wakeup) 3058 if (udev->do_remote_wakeup)
3048 (void) usb_disable_remote_wakeup(udev); 3059 (void) usb_disable_remote_wakeup(udev);
3049 err_wakeup: 3060 err_wakeup:
3050 3061
3051 /* System sleep transitions should never fail */ 3062 /* System sleep transitions should never fail */
3052 if (!PMSG_IS_AUTO(msg)) 3063 if (!PMSG_IS_AUTO(msg))
3053 status = 0; 3064 status = 0;
3054 } else { 3065 } else {
3055 dev_dbg(&udev->dev, "usb %ssuspend, wakeup %d\n", 3066 dev_dbg(&udev->dev, "usb %ssuspend, wakeup %d\n",
3056 (PMSG_IS_AUTO(msg) ? "auto-" : ""), 3067 (PMSG_IS_AUTO(msg) ? "auto-" : ""),
3057 udev->do_remote_wakeup); 3068 udev->do_remote_wakeup);
3058 if (really_suspend) { 3069 if (really_suspend) {
3059 udev->port_is_suspended = 1; 3070 udev->port_is_suspended = 1;
3060 3071
3061 /* device has up to 10 msec to fully suspend */ 3072 /* device has up to 10 msec to fully suspend */
3062 msleep(10); 3073 msleep(10);
3063 } 3074 }
3064 usb_set_device_state(udev, USB_STATE_SUSPENDED); 3075 usb_set_device_state(udev, USB_STATE_SUSPENDED);
3065 } 3076 }
3066 3077
3067 if (status == 0 && !udev->do_remote_wakeup && udev->persist_enabled) { 3078 if (status == 0 && !udev->do_remote_wakeup && udev->persist_enabled) {
3068 pm_runtime_put_sync(&port_dev->dev); 3079 pm_runtime_put_sync(&port_dev->dev);
3069 port_dev->did_runtime_put = true; 3080 port_dev->did_runtime_put = true;
3070 } 3081 }
3071 3082
3072 usb_mark_last_busy(hub->hdev); 3083 usb_mark_last_busy(hub->hdev);
3073 return status; 3084 return status;
3074 } 3085 }
3075 3086
3076 /* 3087 /*
3077 * If the USB "suspend" state is in use (rather than "global suspend"), 3088 * If the USB "suspend" state is in use (rather than "global suspend"),
3078 * many devices will be individually taken out of suspend state using 3089 * many devices will be individually taken out of suspend state using
3079 * special "resume" signaling. This routine kicks in shortly after 3090 * special "resume" signaling. This routine kicks in shortly after
3080 * hardware resume signaling is finished, either because of selective 3091 * hardware resume signaling is finished, either because of selective
3081 * resume (by host) or remote wakeup (by device) ... now see what changed 3092 * resume (by host) or remote wakeup (by device) ... now see what changed
3082 * in the tree that's rooted at this device. 3093 * in the tree that's rooted at this device.
3083 * 3094 *
3084 * If @udev->reset_resume is set then the device is reset before the 3095 * If @udev->reset_resume is set then the device is reset before the
3085 * status check is done. 3096 * status check is done.
3086 */ 3097 */
3087 static int finish_port_resume(struct usb_device *udev) 3098 static int finish_port_resume(struct usb_device *udev)
3088 { 3099 {
3089 int status = 0; 3100 int status = 0;
3090 u16 devstatus = 0; 3101 u16 devstatus = 0;
3091 3102
3092 /* caller owns the udev device lock */ 3103 /* caller owns the udev device lock */
3093 dev_dbg(&udev->dev, "%s\n", 3104 dev_dbg(&udev->dev, "%s\n",
3094 udev->reset_resume ? "finish reset-resume" : "finish resume"); 3105 udev->reset_resume ? "finish reset-resume" : "finish resume");
3095 3106
3096 /* usb ch9 identifies four variants of SUSPENDED, based on what 3107 /* usb ch9 identifies four variants of SUSPENDED, based on what
3097 * state the device resumes to. Linux currently won't see the 3108 * state the device resumes to. Linux currently won't see the
3098 * first two on the host side; they'd be inside hub_port_init() 3109 * first two on the host side; they'd be inside hub_port_init()
3099 * during many timeouts, but khubd can't suspend until later. 3110 * during many timeouts, but khubd can't suspend until later.
3100 */ 3111 */
3101 usb_set_device_state(udev, udev->actconfig 3112 usb_set_device_state(udev, udev->actconfig
3102 ? USB_STATE_CONFIGURED 3113 ? USB_STATE_CONFIGURED
3103 : USB_STATE_ADDRESS); 3114 : USB_STATE_ADDRESS);
3104 3115
3105 /* 10.5.4.5 says not to reset a suspended port if the attached 3116 /* 10.5.4.5 says not to reset a suspended port if the attached
3106 * device is enabled for remote wakeup. Hence the reset 3117 * device is enabled for remote wakeup. Hence the reset
3107 * operation is carried out here, after the port has been 3118 * operation is carried out here, after the port has been
3108 * resumed. 3119 * resumed.
3109 */ 3120 */
3110 if (udev->reset_resume) { 3121 if (udev->reset_resume) {
3111 /* 3122 /*
3112 * If the device morphs or switches modes when it is reset, 3123 * If the device morphs or switches modes when it is reset,
3113 * we don't want to perform a reset-resume. We'll fail the 3124 * we don't want to perform a reset-resume. We'll fail the
3114 * resume, which will cause a logical disconnect, and then 3125 * resume, which will cause a logical disconnect, and then
3115 * the device will be rediscovered. 3126 * the device will be rediscovered.
3116 */ 3127 */
3117 retry_reset_resume: 3128 retry_reset_resume:
3118 if (udev->quirks & USB_QUIRK_RESET) 3129 if (udev->quirks & USB_QUIRK_RESET)
3119 status = -ENODEV; 3130 status = -ENODEV;
3120 else 3131 else
3121 status = usb_reset_and_verify_device(udev); 3132 status = usb_reset_and_verify_device(udev);
3122 } 3133 }
3123 3134
3124 /* 10.5.4.5 says be sure devices in the tree are still there. 3135 /* 10.5.4.5 says be sure devices in the tree are still there.
3125 * For now let's assume the device didn't go crazy on resume, 3136 * For now let's assume the device didn't go crazy on resume,
3126 * and device drivers will know about any resume quirks. 3137 * and device drivers will know about any resume quirks.
3127 */ 3138 */
3128 if (status == 0) { 3139 if (status == 0) {
3129 devstatus = 0; 3140 devstatus = 0;
3130 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); 3141 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus);
3131 3142
3132 /* If a normal resume failed, try doing a reset-resume */ 3143 /* If a normal resume failed, try doing a reset-resume */
3133 if (status && !udev->reset_resume && udev->persist_enabled) { 3144 if (status && !udev->reset_resume && udev->persist_enabled) {
3134 dev_dbg(&udev->dev, "retry with reset-resume\n"); 3145 dev_dbg(&udev->dev, "retry with reset-resume\n");
3135 udev->reset_resume = 1; 3146 udev->reset_resume = 1;
3136 goto retry_reset_resume; 3147 goto retry_reset_resume;
3137 } 3148 }
3138 } 3149 }
3139 3150
3140 if (status) { 3151 if (status) {
3141 dev_dbg(&udev->dev, "gone after usb resume? status %d\n", 3152 dev_dbg(&udev->dev, "gone after usb resume? status %d\n",
3142 status); 3153 status);
3143 /* 3154 /*
3144 * There are a few quirky devices which violate the standard 3155 * There are a few quirky devices which violate the standard
3145 * by claiming to have remote wakeup enabled after a reset, 3156 * by claiming to have remote wakeup enabled after a reset,
3146 * which crash if the feature is cleared, hence check for 3157 * which crash if the feature is cleared, hence check for
3147 * udev->reset_resume 3158 * udev->reset_resume
3148 */ 3159 */
3149 } else if (udev->actconfig && !udev->reset_resume) { 3160 } else if (udev->actconfig && !udev->reset_resume) {
3150 if (udev->speed < USB_SPEED_SUPER) { 3161 if (udev->speed < USB_SPEED_SUPER) {
3151 if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) 3162 if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP))
3152 status = usb_disable_remote_wakeup(udev); 3163 status = usb_disable_remote_wakeup(udev);
3153 } else { 3164 } else {
3154 status = usb_get_status(udev, USB_RECIP_INTERFACE, 0, 3165 status = usb_get_status(udev, USB_RECIP_INTERFACE, 0,
3155 &devstatus); 3166 &devstatus);
3156 if (!status && devstatus & (USB_INTRF_STAT_FUNC_RW_CAP 3167 if (!status && devstatus & (USB_INTRF_STAT_FUNC_RW_CAP
3157 | USB_INTRF_STAT_FUNC_RW)) 3168 | USB_INTRF_STAT_FUNC_RW))
3158 status = usb_disable_remote_wakeup(udev); 3169 status = usb_disable_remote_wakeup(udev);
3159 } 3170 }
3160 3171
3161 if (status) 3172 if (status)
3162 dev_dbg(&udev->dev, 3173 dev_dbg(&udev->dev,
3163 "disable remote wakeup, status %d\n", 3174 "disable remote wakeup, status %d\n",
3164 status); 3175 status);
3165 status = 0; 3176 status = 0;
3166 } 3177 }
3167 return status; 3178 return status;
3168 } 3179 }
3169 3180
3170 /* 3181 /*
3171 * usb_port_resume - re-activate a suspended usb device's upstream port 3182 * usb_port_resume - re-activate a suspended usb device's upstream port
3172 * @udev: device to re-activate, not a root hub 3183 * @udev: device to re-activate, not a root hub
3173 * Context: must be able to sleep; device not locked; pm locks held 3184 * Context: must be able to sleep; device not locked; pm locks held
3174 * 3185 *
3175 * This will re-activate the suspended device, increasing power usage 3186 * This will re-activate the suspended device, increasing power usage
3176 * while letting drivers communicate again with its endpoints. 3187 * while letting drivers communicate again with its endpoints.
3177 * USB resume explicitly guarantees that the power session between 3188 * USB resume explicitly guarantees that the power session between
3178 * the host and the device is the same as it was when the device 3189 * the host and the device is the same as it was when the device
3179 * suspended. 3190 * suspended.
3180 * 3191 *
3181 * If @udev->reset_resume is set then this routine won't check that the 3192 * If @udev->reset_resume is set then this routine won't check that the
3182 * port is still enabled. Furthermore, finish_port_resume() above will 3193 * port is still enabled. Furthermore, finish_port_resume() above will
3183 * reset @udev. The end result is that a broken power session can be 3194 * reset @udev. The end result is that a broken power session can be
3184 * recovered and @udev will appear to persist across a loss of VBUS power. 3195 * recovered and @udev will appear to persist across a loss of VBUS power.
3185 * 3196 *
3186 * For example, if a host controller doesn't maintain VBUS suspend current 3197 * For example, if a host controller doesn't maintain VBUS suspend current
3187 * during a system sleep or is reset when the system wakes up, all the USB 3198 * during a system sleep or is reset when the system wakes up, all the USB
3188 * power sessions below it will be broken. This is especially troublesome 3199 * power sessions below it will be broken. This is especially troublesome
3189 * for mass-storage devices containing mounted filesystems, since the 3200 * for mass-storage devices containing mounted filesystems, since the
3190 * device will appear to have disconnected and all the memory mappings 3201 * device will appear to have disconnected and all the memory mappings
3191 * to it will be lost. Using the USB_PERSIST facility, the device can be 3202 * to it will be lost. Using the USB_PERSIST facility, the device can be
3192 * made to appear as if it had not disconnected. 3203 * made to appear as if it had not disconnected.
3193 * 3204 *
3194 * This facility can be dangerous. Although usb_reset_and_verify_device() makes 3205 * This facility can be dangerous. Although usb_reset_and_verify_device() makes
3195 * every effort to insure that the same device is present after the 3206 * every effort to insure that the same device is present after the
3196 * reset as before, it cannot provide a 100% guarantee. Furthermore it's 3207 * reset as before, it cannot provide a 100% guarantee. Furthermore it's
3197 * quite possible for a device to remain unaltered but its media to be 3208 * quite possible for a device to remain unaltered but its media to be
3198 * changed. If the user replaces a flash memory card while the system is 3209 * changed. If the user replaces a flash memory card while the system is
3199 * asleep, he will have only himself to blame when the filesystem on the 3210 * asleep, he will have only himself to blame when the filesystem on the
3200 * new card is corrupted and the system crashes. 3211 * new card is corrupted and the system crashes.
3201 * 3212 *
3202 * Returns 0 on success, else negative errno. 3213 * Returns 0 on success, else negative errno.
3203 */ 3214 */
3204 int usb_port_resume(struct usb_device *udev, pm_message_t msg) 3215 int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3205 { 3216 {
3206 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); 3217 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
3207 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; 3218 struct usb_port *port_dev = hub->ports[udev->portnum - 1];
3208 int port1 = udev->portnum; 3219 int port1 = udev->portnum;
3209 int status; 3220 int status;
3210 u16 portchange, portstatus; 3221 u16 portchange, portstatus;
3211 3222
3212 if (port_dev->did_runtime_put) { 3223 if (port_dev->did_runtime_put) {
3213 status = pm_runtime_get_sync(&port_dev->dev); 3224 status = pm_runtime_get_sync(&port_dev->dev);
3214 port_dev->did_runtime_put = false; 3225 port_dev->did_runtime_put = false;
3215 if (status < 0) { 3226 if (status < 0) {
3216 dev_dbg(&udev->dev, "can't resume usb port, status %d\n", 3227 dev_dbg(&udev->dev, "can't resume usb port, status %d\n",
3217 status); 3228 status);
3218 return status; 3229 return status;
3219 } 3230 }
3220 } 3231 }
3221 3232
3222 /* Skip the initial Clear-Suspend step for a remote wakeup */ 3233 /* Skip the initial Clear-Suspend step for a remote wakeup */
3223 status = hub_port_status(hub, port1, &portstatus, &portchange); 3234 status = hub_port_status(hub, port1, &portstatus, &portchange);
3224 if (status == 0 && !port_is_suspended(hub, portstatus)) 3235 if (status == 0 && !port_is_suspended(hub, portstatus))
3225 goto SuspendCleared; 3236 goto SuspendCleared;
3226 3237
3227 /* dev_dbg(hub->intfdev, "resume port %d\n", port1); */ 3238 /* dev_dbg(hub->intfdev, "resume port %d\n", port1); */
3228 3239
3229 set_bit(port1, hub->busy_bits); 3240 set_bit(port1, hub->busy_bits);
3230 3241
3231 /* see 7.1.7.7; affects power usage, but not budgeting */ 3242 /* see 7.1.7.7; affects power usage, but not budgeting */
3232 if (hub_is_superspeed(hub->hdev)) 3243 if (hub_is_superspeed(hub->hdev))
3233 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0); 3244 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0);
3234 else 3245 else
3235 status = usb_clear_port_feature(hub->hdev, 3246 status = usb_clear_port_feature(hub->hdev,
3236 port1, USB_PORT_FEAT_SUSPEND); 3247 port1, USB_PORT_FEAT_SUSPEND);
3237 if (status) { 3248 if (status) {
3238 dev_dbg(hub->intfdev, "can't resume port %d, status %d\n", 3249 dev_dbg(hub->intfdev, "can't resume port %d, status %d\n",
3239 port1, status); 3250 port1, status);
3240 } else { 3251 } else {
3241 /* drive resume for at least 20 msec */ 3252 /* drive resume for at least 20 msec */
3242 dev_dbg(&udev->dev, "usb %sresume\n", 3253 dev_dbg(&udev->dev, "usb %sresume\n",
3243 (PMSG_IS_AUTO(msg) ? "auto-" : "")); 3254 (PMSG_IS_AUTO(msg) ? "auto-" : ""));
3244 msleep(25); 3255 msleep(25);
3245 3256
3246 /* Virtual root hubs can trigger on GET_PORT_STATUS to 3257 /* Virtual root hubs can trigger on GET_PORT_STATUS to
3247 * stop resume signaling. Then finish the resume 3258 * stop resume signaling. Then finish the resume
3248 * sequence. 3259 * sequence.
3249 */ 3260 */
3250 status = hub_port_status(hub, port1, &portstatus, &portchange); 3261 status = hub_port_status(hub, port1, &portstatus, &portchange);
3251 3262
3252 /* TRSMRCY = 10 msec */ 3263 /* TRSMRCY = 10 msec */
3253 msleep(10); 3264 msleep(10);
3254 } 3265 }
3255 3266
3256 SuspendCleared: 3267 SuspendCleared:
3257 if (status == 0) { 3268 if (status == 0) {
3258 udev->port_is_suspended = 0; 3269 udev->port_is_suspended = 0;
3259 if (hub_is_superspeed(hub->hdev)) { 3270 if (hub_is_superspeed(hub->hdev)) {
3260 if (portchange & USB_PORT_STAT_C_LINK_STATE) 3271 if (portchange & USB_PORT_STAT_C_LINK_STATE)
3261 usb_clear_port_feature(hub->hdev, port1, 3272 usb_clear_port_feature(hub->hdev, port1,
3262 USB_PORT_FEAT_C_PORT_LINK_STATE); 3273 USB_PORT_FEAT_C_PORT_LINK_STATE);
3263 } else { 3274 } else {
3264 if (portchange & USB_PORT_STAT_C_SUSPEND) 3275 if (portchange & USB_PORT_STAT_C_SUSPEND)
3265 usb_clear_port_feature(hub->hdev, port1, 3276 usb_clear_port_feature(hub->hdev, port1,
3266 USB_PORT_FEAT_C_SUSPEND); 3277 USB_PORT_FEAT_C_SUSPEND);
3267 } 3278 }
3268 } 3279 }
3269 3280
3270 clear_bit(port1, hub->busy_bits); 3281 clear_bit(port1, hub->busy_bits);
3271 3282
3272 status = check_port_resume_type(udev, 3283 status = check_port_resume_type(udev,
3273 hub, port1, status, portchange, portstatus); 3284 hub, port1, status, portchange, portstatus);
3274 if (status == 0) 3285 if (status == 0)
3275 status = finish_port_resume(udev); 3286 status = finish_port_resume(udev);
3276 if (status < 0) { 3287 if (status < 0) {
3277 dev_dbg(&udev->dev, "can't resume, status %d\n", status); 3288 dev_dbg(&udev->dev, "can't resume, status %d\n", status);
3278 hub_port_logical_disconnect(hub, port1); 3289 hub_port_logical_disconnect(hub, port1);
3279 } else { 3290 } else {
3280 /* Try to enable USB2 hardware LPM */ 3291 /* Try to enable USB2 hardware LPM */
3281 if (udev->usb2_hw_lpm_capable == 1) 3292 if (udev->usb2_hw_lpm_capable == 1)
3282 usb_set_usb2_hardware_lpm(udev, 1); 3293 usb_set_usb2_hardware_lpm(udev, 1);
3283 3294
3284 /* Try to enable USB3 LTM and LPM */ 3295 /* Try to enable USB3 LTM and LPM */
3285 usb_enable_ltm(udev); 3296 usb_enable_ltm(udev);
3286 usb_unlocked_enable_lpm(udev); 3297 usb_unlocked_enable_lpm(udev);
3287 } 3298 }
3288 3299
3289 return status; 3300 return status;
3290 } 3301 }
3291 3302
3292 #ifdef CONFIG_PM_RUNTIME 3303 #ifdef CONFIG_PM_RUNTIME
3293 3304
3294 /* caller has locked udev */ 3305 /* caller has locked udev */
3295 int usb_remote_wakeup(struct usb_device *udev) 3306 int usb_remote_wakeup(struct usb_device *udev)
3296 { 3307 {
3297 int status = 0; 3308 int status = 0;
3298 3309
3299 if (udev->state == USB_STATE_SUSPENDED) { 3310 if (udev->state == USB_STATE_SUSPENDED) {
3300 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); 3311 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-");
3301 status = usb_autoresume_device(udev); 3312 status = usb_autoresume_device(udev);
3302 if (status == 0) { 3313 if (status == 0) {
3303 /* Let the drivers do their thing, then... */ 3314 /* Let the drivers do their thing, then... */
3304 usb_autosuspend_device(udev); 3315 usb_autosuspend_device(udev);
3305 } 3316 }
3306 } 3317 }
3307 return status; 3318 return status;
3308 } 3319 }
3309 3320
3310 #endif 3321 #endif
3311 3322
3312 static int check_ports_changed(struct usb_hub *hub) 3323 static int check_ports_changed(struct usb_hub *hub)
3313 { 3324 {
3314 int port1; 3325 int port1;
3315 3326
3316 for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) { 3327 for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) {
3317 u16 portstatus, portchange; 3328 u16 portstatus, portchange;
3318 int status; 3329 int status;
3319 3330
3320 status = hub_port_status(hub, port1, &portstatus, &portchange); 3331 status = hub_port_status(hub, port1, &portstatus, &portchange);
3321 if (!status && portchange) 3332 if (!status && portchange)
3322 return 1; 3333 return 1;
3323 } 3334 }
3324 return 0; 3335 return 0;
3325 } 3336 }
3326 3337
3327 static int hub_suspend(struct usb_interface *intf, pm_message_t msg) 3338 static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
3328 { 3339 {
3329 struct usb_hub *hub = usb_get_intfdata (intf); 3340 struct usb_hub *hub = usb_get_intfdata (intf);
3330 struct usb_device *hdev = hub->hdev; 3341 struct usb_device *hdev = hub->hdev;
3331 unsigned port1; 3342 unsigned port1;
3332 int status; 3343 int status;
3333 3344
3334 /* 3345 /*
3335 * Warn if children aren't already suspended. 3346 * Warn if children aren't already suspended.
3336 * Also, add up the number of wakeup-enabled descendants. 3347 * Also, add up the number of wakeup-enabled descendants.
3337 */ 3348 */
3338 hub->wakeup_enabled_descendants = 0; 3349 hub->wakeup_enabled_descendants = 0;
3339 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 3350 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
3340 struct usb_device *udev; 3351 struct usb_device *udev;
3341 3352
3342 udev = hub->ports[port1 - 1]->child; 3353 udev = hub->ports[port1 - 1]->child;
3343 if (udev && udev->can_submit) { 3354 if (udev && udev->can_submit) {
3344 dev_warn(&intf->dev, "port %d not suspended yet\n", 3355 dev_warn(&intf->dev, "port %d not suspended yet\n",
3345 port1); 3356 port1);
3346 if (PMSG_IS_AUTO(msg)) 3357 if (PMSG_IS_AUTO(msg))
3347 return -EBUSY; 3358 return -EBUSY;
3348 } 3359 }
3349 if (udev) 3360 if (udev)
3350 hub->wakeup_enabled_descendants += 3361 hub->wakeup_enabled_descendants +=
3351 wakeup_enabled_descendants(udev); 3362 wakeup_enabled_descendants(udev);
3352 } 3363 }
3353 3364
3354 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { 3365 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) {
3355 /* check if there are changes pending on hub ports */ 3366 /* check if there are changes pending on hub ports */
3356 if (check_ports_changed(hub)) { 3367 if (check_ports_changed(hub)) {
3357 if (PMSG_IS_AUTO(msg)) 3368 if (PMSG_IS_AUTO(msg))
3358 return -EBUSY; 3369 return -EBUSY;
3359 pm_wakeup_event(&hdev->dev, 2000); 3370 pm_wakeup_event(&hdev->dev, 2000);
3360 } 3371 }
3361 } 3372 }
3362 3373
3363 if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { 3374 if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) {
3364 /* Enable hub to send remote wakeup for all ports. */ 3375 /* Enable hub to send remote wakeup for all ports. */
3365 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 3376 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
3366 status = set_port_feature(hdev, 3377 status = set_port_feature(hdev,
3367 port1 | 3378 port1 |
3368 USB_PORT_FEAT_REMOTE_WAKE_CONNECT | 3379 USB_PORT_FEAT_REMOTE_WAKE_CONNECT |
3369 USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT | 3380 USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT |
3370 USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT, 3381 USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT,
3371 USB_PORT_FEAT_REMOTE_WAKE_MASK); 3382 USB_PORT_FEAT_REMOTE_WAKE_MASK);
3372 } 3383 }
3373 } 3384 }
3374 3385
3375 dev_dbg(&intf->dev, "%s\n", __func__); 3386 dev_dbg(&intf->dev, "%s\n", __func__);
3376 3387
3377 /* stop khubd and related activity */ 3388 /* stop khubd and related activity */
3378 hub_quiesce(hub, HUB_SUSPEND); 3389 hub_quiesce(hub, HUB_SUSPEND);
3379 return 0; 3390 return 0;
3380 } 3391 }
3381 3392
3382 static int hub_resume(struct usb_interface *intf) 3393 static int hub_resume(struct usb_interface *intf)
3383 { 3394 {
3384 struct usb_hub *hub = usb_get_intfdata(intf); 3395 struct usb_hub *hub = usb_get_intfdata(intf);
3385 3396
3386 dev_dbg(&intf->dev, "%s\n", __func__); 3397 dev_dbg(&intf->dev, "%s\n", __func__);
3387 hub_activate(hub, HUB_RESUME); 3398 hub_activate(hub, HUB_RESUME);
3388 return 0; 3399 return 0;
3389 } 3400 }
3390 3401
3391 static int hub_reset_resume(struct usb_interface *intf) 3402 static int hub_reset_resume(struct usb_interface *intf)
3392 { 3403 {
3393 struct usb_hub *hub = usb_get_intfdata(intf); 3404 struct usb_hub *hub = usb_get_intfdata(intf);
3394 3405
3395 dev_dbg(&intf->dev, "%s\n", __func__); 3406 dev_dbg(&intf->dev, "%s\n", __func__);
3396 hub_activate(hub, HUB_RESET_RESUME); 3407 hub_activate(hub, HUB_RESET_RESUME);
3397 return 0; 3408 return 0;
3398 } 3409 }
3399 3410
3400 /** 3411 /**
3401 * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power 3412 * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power
3402 * @rhdev: struct usb_device for the root hub 3413 * @rhdev: struct usb_device for the root hub
3403 * 3414 *
3404 * The USB host controller driver calls this function when its root hub 3415 * The USB host controller driver calls this function when its root hub
3405 * is resumed and Vbus power has been interrupted or the controller 3416 * is resumed and Vbus power has been interrupted or the controller
3406 * has been reset. The routine marks @rhdev as having lost power. 3417 * has been reset. The routine marks @rhdev as having lost power.
3407 * When the hub driver is resumed it will take notice and carry out 3418 * When the hub driver is resumed it will take notice and carry out
3408 * power-session recovery for all the "USB-PERSIST"-enabled child devices; 3419 * power-session recovery for all the "USB-PERSIST"-enabled child devices;
3409 * the others will be disconnected. 3420 * the others will be disconnected.
3410 */ 3421 */
3411 void usb_root_hub_lost_power(struct usb_device *rhdev) 3422 void usb_root_hub_lost_power(struct usb_device *rhdev)
3412 { 3423 {
3413 dev_warn(&rhdev->dev, "root hub lost power or was reset\n"); 3424 dev_warn(&rhdev->dev, "root hub lost power or was reset\n");
3414 rhdev->reset_resume = 1; 3425 rhdev->reset_resume = 1;
3415 } 3426 }
3416 EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); 3427 EXPORT_SYMBOL_GPL(usb_root_hub_lost_power);
3417 3428
3418 static const char * const usb3_lpm_names[] = { 3429 static const char * const usb3_lpm_names[] = {
3419 "U0", 3430 "U0",
3420 "U1", 3431 "U1",
3421 "U2", 3432 "U2",
3422 "U3", 3433 "U3",
3423 }; 3434 };
3424 3435
3425 /* 3436 /*
3426 * Send a Set SEL control transfer to the device, prior to enabling 3437 * Send a Set SEL control transfer to the device, prior to enabling
3427 * device-initiated U1 or U2. This lets the device know the exit latencies from 3438 * device-initiated U1 or U2. This lets the device know the exit latencies from
3428 * the time the device initiates a U1 or U2 exit, to the time it will receive a 3439 * the time the device initiates a U1 or U2 exit, to the time it will receive a
3429 * packet from the host. 3440 * packet from the host.
3430 * 3441 *
3431 * This function will fail if the SEL or PEL values for udev are greater than 3442 * This function will fail if the SEL or PEL values for udev are greater than
3432 * the maximum allowed values for the link state to be enabled. 3443 * the maximum allowed values for the link state to be enabled.
3433 */ 3444 */
3434 static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state) 3445 static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state)
3435 { 3446 {
3436 struct usb_set_sel_req *sel_values; 3447 struct usb_set_sel_req *sel_values;
3437 unsigned long long u1_sel; 3448 unsigned long long u1_sel;
3438 unsigned long long u1_pel; 3449 unsigned long long u1_pel;
3439 unsigned long long u2_sel; 3450 unsigned long long u2_sel;
3440 unsigned long long u2_pel; 3451 unsigned long long u2_pel;
3441 int ret; 3452 int ret;
3442 3453
3443 if (udev->state != USB_STATE_CONFIGURED) 3454 if (udev->state != USB_STATE_CONFIGURED)
3444 return 0; 3455 return 0;
3445 3456
3446 /* Convert SEL and PEL stored in ns to us */ 3457 /* Convert SEL and PEL stored in ns to us */
3447 u1_sel = DIV_ROUND_UP(udev->u1_params.sel, 1000); 3458 u1_sel = DIV_ROUND_UP(udev->u1_params.sel, 1000);
3448 u1_pel = DIV_ROUND_UP(udev->u1_params.pel, 1000); 3459 u1_pel = DIV_ROUND_UP(udev->u1_params.pel, 1000);
3449 u2_sel = DIV_ROUND_UP(udev->u2_params.sel, 1000); 3460 u2_sel = DIV_ROUND_UP(udev->u2_params.sel, 1000);
3450 u2_pel = DIV_ROUND_UP(udev->u2_params.pel, 1000); 3461 u2_pel = DIV_ROUND_UP(udev->u2_params.pel, 1000);
3451 3462
3452 /* 3463 /*
3453 * Make sure that the calculated SEL and PEL values for the link 3464 * Make sure that the calculated SEL and PEL values for the link
3454 * state we're enabling aren't bigger than the max SEL/PEL 3465 * state we're enabling aren't bigger than the max SEL/PEL
3455 * value that will fit in the SET SEL control transfer. 3466 * value that will fit in the SET SEL control transfer.
3456 * Otherwise the device would get an incorrect idea of the exit 3467 * Otherwise the device would get an incorrect idea of the exit
3457 * latency for the link state, and could start a device-initiated 3468 * latency for the link state, and could start a device-initiated
3458 * U1/U2 when the exit latencies are too high. 3469 * U1/U2 when the exit latencies are too high.
3459 */ 3470 */
3460 if ((state == USB3_LPM_U1 && 3471 if ((state == USB3_LPM_U1 &&
3461 (u1_sel > USB3_LPM_MAX_U1_SEL_PEL || 3472 (u1_sel > USB3_LPM_MAX_U1_SEL_PEL ||
3462 u1_pel > USB3_LPM_MAX_U1_SEL_PEL)) || 3473 u1_pel > USB3_LPM_MAX_U1_SEL_PEL)) ||
3463 (state == USB3_LPM_U2 && 3474 (state == USB3_LPM_U2 &&
3464 (u2_sel > USB3_LPM_MAX_U2_SEL_PEL || 3475 (u2_sel > USB3_LPM_MAX_U2_SEL_PEL ||
3465 u2_pel > USB3_LPM_MAX_U2_SEL_PEL))) { 3476 u2_pel > USB3_LPM_MAX_U2_SEL_PEL))) {
3466 dev_dbg(&udev->dev, "Device-initiated %s disabled due to long SEL %llu us or PEL %llu us\n", 3477 dev_dbg(&udev->dev, "Device-initiated %s disabled due to long SEL %llu us or PEL %llu us\n",
3467 usb3_lpm_names[state], u1_sel, u1_pel); 3478 usb3_lpm_names[state], u1_sel, u1_pel);
3468 return -EINVAL; 3479 return -EINVAL;
3469 } 3480 }
3470 3481
3471 /* 3482 /*
3472 * If we're enabling device-initiated LPM for one link state, 3483 * If we're enabling device-initiated LPM for one link state,
3473 * but the other link state has a too high SEL or PEL value, 3484 * but the other link state has a too high SEL or PEL value,
3474 * just set those values to the max in the Set SEL request. 3485 * just set those values to the max in the Set SEL request.
3475 */ 3486 */
3476 if (u1_sel > USB3_LPM_MAX_U1_SEL_PEL) 3487 if (u1_sel > USB3_LPM_MAX_U1_SEL_PEL)
3477 u1_sel = USB3_LPM_MAX_U1_SEL_PEL; 3488 u1_sel = USB3_LPM_MAX_U1_SEL_PEL;
3478 3489
3479 if (u1_pel > USB3_LPM_MAX_U1_SEL_PEL) 3490 if (u1_pel > USB3_LPM_MAX_U1_SEL_PEL)
3480 u1_pel = USB3_LPM_MAX_U1_SEL_PEL; 3491 u1_pel = USB3_LPM_MAX_U1_SEL_PEL;
3481 3492
3482 if (u2_sel > USB3_LPM_MAX_U2_SEL_PEL) 3493 if (u2_sel > USB3_LPM_MAX_U2_SEL_PEL)
3483 u2_sel = USB3_LPM_MAX_U2_SEL_PEL; 3494 u2_sel = USB3_LPM_MAX_U2_SEL_PEL;
3484 3495
3485 if (u2_pel > USB3_LPM_MAX_U2_SEL_PEL) 3496 if (u2_pel > USB3_LPM_MAX_U2_SEL_PEL)
3486 u2_pel = USB3_LPM_MAX_U2_SEL_PEL; 3497 u2_pel = USB3_LPM_MAX_U2_SEL_PEL;
3487 3498
3488 /* 3499 /*
3489 * usb_enable_lpm() can be called as part of a failed device reset, 3500 * usb_enable_lpm() can be called as part of a failed device reset,
3490 * which may be initiated by an error path of a mass storage driver. 3501 * which may be initiated by an error path of a mass storage driver.
3491 * Therefore, use GFP_NOIO. 3502 * Therefore, use GFP_NOIO.
3492 */ 3503 */
3493 sel_values = kmalloc(sizeof *(sel_values), GFP_NOIO); 3504 sel_values = kmalloc(sizeof *(sel_values), GFP_NOIO);
3494 if (!sel_values) 3505 if (!sel_values)
3495 return -ENOMEM; 3506 return -ENOMEM;
3496 3507
3497 sel_values->u1_sel = u1_sel; 3508 sel_values->u1_sel = u1_sel;
3498 sel_values->u1_pel = u1_pel; 3509 sel_values->u1_pel = u1_pel;
3499 sel_values->u2_sel = cpu_to_le16(u2_sel); 3510 sel_values->u2_sel = cpu_to_le16(u2_sel);
3500 sel_values->u2_pel = cpu_to_le16(u2_pel); 3511 sel_values->u2_pel = cpu_to_le16(u2_pel);
3501 3512
3502 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 3513 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
3503 USB_REQ_SET_SEL, 3514 USB_REQ_SET_SEL,
3504 USB_RECIP_DEVICE, 3515 USB_RECIP_DEVICE,
3505 0, 0, 3516 0, 0,
3506 sel_values, sizeof *(sel_values), 3517 sel_values, sizeof *(sel_values),
3507 USB_CTRL_SET_TIMEOUT); 3518 USB_CTRL_SET_TIMEOUT);
3508 kfree(sel_values); 3519 kfree(sel_values);
3509 return ret; 3520 return ret;
3510 } 3521 }
3511 3522
3512 /* 3523 /*
3513 * Enable or disable device-initiated U1 or U2 transitions. 3524 * Enable or disable device-initiated U1 or U2 transitions.
3514 */ 3525 */
3515 static int usb_set_device_initiated_lpm(struct usb_device *udev, 3526 static int usb_set_device_initiated_lpm(struct usb_device *udev,
3516 enum usb3_link_state state, bool enable) 3527 enum usb3_link_state state, bool enable)
3517 { 3528 {
3518 int ret; 3529 int ret;
3519 int feature; 3530 int feature;
3520 3531
3521 switch (state) { 3532 switch (state) {
3522 case USB3_LPM_U1: 3533 case USB3_LPM_U1:
3523 feature = USB_DEVICE_U1_ENABLE; 3534 feature = USB_DEVICE_U1_ENABLE;
3524 break; 3535 break;
3525 case USB3_LPM_U2: 3536 case USB3_LPM_U2:
3526 feature = USB_DEVICE_U2_ENABLE; 3537 feature = USB_DEVICE_U2_ENABLE;
3527 break; 3538 break;
3528 default: 3539 default:
3529 dev_warn(&udev->dev, "%s: Can't %s non-U1 or U2 state.\n", 3540 dev_warn(&udev->dev, "%s: Can't %s non-U1 or U2 state.\n",
3530 __func__, enable ? "enable" : "disable"); 3541 __func__, enable ? "enable" : "disable");
3531 return -EINVAL; 3542 return -EINVAL;
3532 } 3543 }
3533 3544
3534 if (udev->state != USB_STATE_CONFIGURED) { 3545 if (udev->state != USB_STATE_CONFIGURED) {
3535 dev_dbg(&udev->dev, "%s: Can't %s %s state " 3546 dev_dbg(&udev->dev, "%s: Can't %s %s state "
3536 "for unconfigured device.\n", 3547 "for unconfigured device.\n",
3537 __func__, enable ? "enable" : "disable", 3548 __func__, enable ? "enable" : "disable",
3538 usb3_lpm_names[state]); 3549 usb3_lpm_names[state]);
3539 return 0; 3550 return 0;
3540 } 3551 }
3541 3552
3542 if (enable) { 3553 if (enable) {
3543 /* 3554 /*
3544 * Now send the control transfer to enable device-initiated LPM 3555 * Now send the control transfer to enable device-initiated LPM
3545 * for either U1 or U2. 3556 * for either U1 or U2.
3546 */ 3557 */
3547 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 3558 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
3548 USB_REQ_SET_FEATURE, 3559 USB_REQ_SET_FEATURE,
3549 USB_RECIP_DEVICE, 3560 USB_RECIP_DEVICE,
3550 feature, 3561 feature,
3551 0, NULL, 0, 3562 0, NULL, 0,
3552 USB_CTRL_SET_TIMEOUT); 3563 USB_CTRL_SET_TIMEOUT);
3553 } else { 3564 } else {
3554 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 3565 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
3555 USB_REQ_CLEAR_FEATURE, 3566 USB_REQ_CLEAR_FEATURE,
3556 USB_RECIP_DEVICE, 3567 USB_RECIP_DEVICE,
3557 feature, 3568 feature,
3558 0, NULL, 0, 3569 0, NULL, 0,
3559 USB_CTRL_SET_TIMEOUT); 3570 USB_CTRL_SET_TIMEOUT);
3560 } 3571 }
3561 if (ret < 0) { 3572 if (ret < 0) {
3562 dev_warn(&udev->dev, "%s of device-initiated %s failed.\n", 3573 dev_warn(&udev->dev, "%s of device-initiated %s failed.\n",
3563 enable ? "Enable" : "Disable", 3574 enable ? "Enable" : "Disable",
3564 usb3_lpm_names[state]); 3575 usb3_lpm_names[state]);
3565 return -EBUSY; 3576 return -EBUSY;
3566 } 3577 }
3567 return 0; 3578 return 0;
3568 } 3579 }
3569 3580
3570 static int usb_set_lpm_timeout(struct usb_device *udev, 3581 static int usb_set_lpm_timeout(struct usb_device *udev,
3571 enum usb3_link_state state, int timeout) 3582 enum usb3_link_state state, int timeout)
3572 { 3583 {
3573 int ret; 3584 int ret;
3574 int feature; 3585 int feature;
3575 3586
3576 switch (state) { 3587 switch (state) {
3577 case USB3_LPM_U1: 3588 case USB3_LPM_U1:
3578 feature = USB_PORT_FEAT_U1_TIMEOUT; 3589 feature = USB_PORT_FEAT_U1_TIMEOUT;
3579 break; 3590 break;
3580 case USB3_LPM_U2: 3591 case USB3_LPM_U2:
3581 feature = USB_PORT_FEAT_U2_TIMEOUT; 3592 feature = USB_PORT_FEAT_U2_TIMEOUT;
3582 break; 3593 break;
3583 default: 3594 default:
3584 dev_warn(&udev->dev, "%s: Can't set timeout for non-U1 or U2 state.\n", 3595 dev_warn(&udev->dev, "%s: Can't set timeout for non-U1 or U2 state.\n",
3585 __func__); 3596 __func__);
3586 return -EINVAL; 3597 return -EINVAL;
3587 } 3598 }
3588 3599
3589 if (state == USB3_LPM_U1 && timeout > USB3_LPM_U1_MAX_TIMEOUT && 3600 if (state == USB3_LPM_U1 && timeout > USB3_LPM_U1_MAX_TIMEOUT &&
3590 timeout != USB3_LPM_DEVICE_INITIATED) { 3601 timeout != USB3_LPM_DEVICE_INITIATED) {
3591 dev_warn(&udev->dev, "Failed to set %s timeout to 0x%x, " 3602 dev_warn(&udev->dev, "Failed to set %s timeout to 0x%x, "
3592 "which is a reserved value.\n", 3603 "which is a reserved value.\n",
3593 usb3_lpm_names[state], timeout); 3604 usb3_lpm_names[state], timeout);
3594 return -EINVAL; 3605 return -EINVAL;
3595 } 3606 }
3596 3607
3597 ret = set_port_feature(udev->parent, 3608 ret = set_port_feature(udev->parent,
3598 USB_PORT_LPM_TIMEOUT(timeout) | udev->portnum, 3609 USB_PORT_LPM_TIMEOUT(timeout) | udev->portnum,
3599 feature); 3610 feature);
3600 if (ret < 0) { 3611 if (ret < 0) {
3601 dev_warn(&udev->dev, "Failed to set %s timeout to 0x%x," 3612 dev_warn(&udev->dev, "Failed to set %s timeout to 0x%x,"
3602 "error code %i\n", usb3_lpm_names[state], 3613 "error code %i\n", usb3_lpm_names[state],
3603 timeout, ret); 3614 timeout, ret);
3604 return -EBUSY; 3615 return -EBUSY;
3605 } 3616 }
3606 if (state == USB3_LPM_U1) 3617 if (state == USB3_LPM_U1)
3607 udev->u1_params.timeout = timeout; 3618 udev->u1_params.timeout = timeout;
3608 else 3619 else
3609 udev->u2_params.timeout = timeout; 3620 udev->u2_params.timeout = timeout;
3610 return 0; 3621 return 0;
3611 } 3622 }
3612 3623
3613 /* 3624 /*
3614 * Enable the hub-initiated U1/U2 idle timeouts, and enable device-initiated 3625 * Enable the hub-initiated U1/U2 idle timeouts, and enable device-initiated
3615 * U1/U2 entry. 3626 * U1/U2 entry.
3616 * 3627 *
3617 * We will attempt to enable U1 or U2, but there are no guarantees that the 3628 * We will attempt to enable U1 or U2, but there are no guarantees that the
3618 * control transfers to set the hub timeout or enable device-initiated U1/U2 3629 * control transfers to set the hub timeout or enable device-initiated U1/U2
3619 * will be successful. 3630 * will be successful.
3620 * 3631 *
3621 * If we cannot set the parent hub U1/U2 timeout, we attempt to let the xHCI 3632 * If we cannot set the parent hub U1/U2 timeout, we attempt to let the xHCI
3622 * driver know about it. If that call fails, it should be harmless, and just 3633 * driver know about it. If that call fails, it should be harmless, and just
3623 * take up more slightly more bus bandwidth for unnecessary U1/U2 exit latency. 3634 * take up more slightly more bus bandwidth for unnecessary U1/U2 exit latency.
3624 */ 3635 */
3625 static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, 3636 static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
3626 enum usb3_link_state state) 3637 enum usb3_link_state state)
3627 { 3638 {
3628 int timeout, ret; 3639 int timeout, ret;
3629 __u8 u1_mel = udev->bos->ss_cap->bU1devExitLat; 3640 __u8 u1_mel = udev->bos->ss_cap->bU1devExitLat;
3630 __le16 u2_mel = udev->bos->ss_cap->bU2DevExitLat; 3641 __le16 u2_mel = udev->bos->ss_cap->bU2DevExitLat;
3631 3642
3632 /* If the device says it doesn't have *any* exit latency to come out of 3643 /* If the device says it doesn't have *any* exit latency to come out of
3633 * U1 or U2, it's probably lying. Assume it doesn't implement that link 3644 * U1 or U2, it's probably lying. Assume it doesn't implement that link
3634 * state. 3645 * state.
3635 */ 3646 */
3636 if ((state == USB3_LPM_U1 && u1_mel == 0) || 3647 if ((state == USB3_LPM_U1 && u1_mel == 0) ||
3637 (state == USB3_LPM_U2 && u2_mel == 0)) 3648 (state == USB3_LPM_U2 && u2_mel == 0))
3638 return; 3649 return;
3639 3650
3640 /* 3651 /*
3641 * First, let the device know about the exit latencies 3652 * First, let the device know about the exit latencies
3642 * associated with the link state we're about to enable. 3653 * associated with the link state we're about to enable.
3643 */ 3654 */
3644 ret = usb_req_set_sel(udev, state); 3655 ret = usb_req_set_sel(udev, state);
3645 if (ret < 0) { 3656 if (ret < 0) {
3646 dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n", 3657 dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n",
3647 usb3_lpm_names[state]); 3658 usb3_lpm_names[state]);
3648 return; 3659 return;
3649 } 3660 }
3650 3661
3651 /* We allow the host controller to set the U1/U2 timeout internally 3662 /* We allow the host controller to set the U1/U2 timeout internally
3652 * first, so that it can change its schedule to account for the 3663 * first, so that it can change its schedule to account for the
3653 * additional latency to send data to a device in a lower power 3664 * additional latency to send data to a device in a lower power
3654 * link state. 3665 * link state.
3655 */ 3666 */
3656 timeout = hcd->driver->enable_usb3_lpm_timeout(hcd, udev, state); 3667 timeout = hcd->driver->enable_usb3_lpm_timeout(hcd, udev, state);
3657 3668
3658 /* xHCI host controller doesn't want to enable this LPM state. */ 3669 /* xHCI host controller doesn't want to enable this LPM state. */
3659 if (timeout == 0) 3670 if (timeout == 0)
3660 return; 3671 return;
3661 3672
3662 if (timeout < 0) { 3673 if (timeout < 0) {
3663 dev_warn(&udev->dev, "Could not enable %s link state, " 3674 dev_warn(&udev->dev, "Could not enable %s link state, "
3664 "xHCI error %i.\n", usb3_lpm_names[state], 3675 "xHCI error %i.\n", usb3_lpm_names[state],
3665 timeout); 3676 timeout);
3666 return; 3677 return;
3667 } 3678 }
3668 3679
3669 if (usb_set_lpm_timeout(udev, state, timeout)) 3680 if (usb_set_lpm_timeout(udev, state, timeout))
3670 /* If we can't set the parent hub U1/U2 timeout, 3681 /* If we can't set the parent hub U1/U2 timeout,
3671 * device-initiated LPM won't be allowed either, so let the xHCI 3682 * device-initiated LPM won't be allowed either, so let the xHCI
3672 * host know that this link state won't be enabled. 3683 * host know that this link state won't be enabled.
3673 */ 3684 */
3674 hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state); 3685 hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state);
3675 3686
3676 /* Only a configured device will accept the Set Feature U1/U2_ENABLE */ 3687 /* Only a configured device will accept the Set Feature U1/U2_ENABLE */
3677 else if (udev->actconfig) 3688 else if (udev->actconfig)
3678 usb_set_device_initiated_lpm(udev, state, true); 3689 usb_set_device_initiated_lpm(udev, state, true);
3679 3690
3680 } 3691 }
3681 3692
3682 /* 3693 /*
3683 * Disable the hub-initiated U1/U2 idle timeouts, and disable device-initiated 3694 * Disable the hub-initiated U1/U2 idle timeouts, and disable device-initiated
3684 * U1/U2 entry. 3695 * U1/U2 entry.
3685 * 3696 *
3686 * If this function returns -EBUSY, the parent hub will still allow U1/U2 entry. 3697 * If this function returns -EBUSY, the parent hub will still allow U1/U2 entry.
3687 * If zero is returned, the parent will not allow the link to go into U1/U2. 3698 * If zero is returned, the parent will not allow the link to go into U1/U2.
3688 * 3699 *
3689 * If zero is returned, device-initiated U1/U2 entry may still be enabled, but 3700 * If zero is returned, device-initiated U1/U2 entry may still be enabled, but
3690 * it won't have an effect on the bus link state because the parent hub will 3701 * it won't have an effect on the bus link state because the parent hub will
3691 * still disallow device-initiated U1/U2 entry. 3702 * still disallow device-initiated U1/U2 entry.
3692 * 3703 *
3693 * If zero is returned, the xHCI host controller may still think U1/U2 entry is 3704 * If zero is returned, the xHCI host controller may still think U1/U2 entry is
3694 * possible. The result will be slightly more bus bandwidth will be taken up 3705 * possible. The result will be slightly more bus bandwidth will be taken up
3695 * (to account for U1/U2 exit latency), but it should be harmless. 3706 * (to account for U1/U2 exit latency), but it should be harmless.
3696 */ 3707 */
3697 static int usb_disable_link_state(struct usb_hcd *hcd, struct usb_device *udev, 3708 static int usb_disable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
3698 enum usb3_link_state state) 3709 enum usb3_link_state state)
3699 { 3710 {
3700 int feature; 3711 int feature;
3701 3712
3702 switch (state) { 3713 switch (state) {
3703 case USB3_LPM_U1: 3714 case USB3_LPM_U1:
3704 feature = USB_PORT_FEAT_U1_TIMEOUT; 3715 feature = USB_PORT_FEAT_U1_TIMEOUT;
3705 break; 3716 break;
3706 case USB3_LPM_U2: 3717 case USB3_LPM_U2:
3707 feature = USB_PORT_FEAT_U2_TIMEOUT; 3718 feature = USB_PORT_FEAT_U2_TIMEOUT;
3708 break; 3719 break;
3709 default: 3720 default:
3710 dev_warn(&udev->dev, "%s: Can't disable non-U1 or U2 state.\n", 3721 dev_warn(&udev->dev, "%s: Can't disable non-U1 or U2 state.\n",
3711 __func__); 3722 __func__);
3712 return -EINVAL; 3723 return -EINVAL;
3713 } 3724 }
3714 3725
3715 if (usb_set_lpm_timeout(udev, state, 0)) 3726 if (usb_set_lpm_timeout(udev, state, 0))
3716 return -EBUSY; 3727 return -EBUSY;
3717 3728
3718 usb_set_device_initiated_lpm(udev, state, false); 3729 usb_set_device_initiated_lpm(udev, state, false);
3719 3730
3720 if (hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state)) 3731 if (hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state))
3721 dev_warn(&udev->dev, "Could not disable xHCI %s timeout, " 3732 dev_warn(&udev->dev, "Could not disable xHCI %s timeout, "
3722 "bus schedule bandwidth may be impacted.\n", 3733 "bus schedule bandwidth may be impacted.\n",
3723 usb3_lpm_names[state]); 3734 usb3_lpm_names[state]);
3724 return 0; 3735 return 0;
3725 } 3736 }
3726 3737
3727 /* 3738 /*
3728 * Disable hub-initiated and device-initiated U1 and U2 entry. 3739 * Disable hub-initiated and device-initiated U1 and U2 entry.
3729 * Caller must own the bandwidth_mutex. 3740 * Caller must own the bandwidth_mutex.
3730 * 3741 *
3731 * This will call usb_enable_lpm() on failure, which will decrement 3742 * This will call usb_enable_lpm() on failure, which will decrement
3732 * lpm_disable_count, and will re-enable LPM if lpm_disable_count reaches zero. 3743 * lpm_disable_count, and will re-enable LPM if lpm_disable_count reaches zero.
3733 */ 3744 */
3734 int usb_disable_lpm(struct usb_device *udev) 3745 int usb_disable_lpm(struct usb_device *udev)
3735 { 3746 {
3736 struct usb_hcd *hcd; 3747 struct usb_hcd *hcd;
3737 3748
3738 if (!udev || !udev->parent || 3749 if (!udev || !udev->parent ||
3739 udev->speed != USB_SPEED_SUPER || 3750 udev->speed != USB_SPEED_SUPER ||
3740 !udev->lpm_capable) 3751 !udev->lpm_capable)
3741 return 0; 3752 return 0;
3742 3753
3743 hcd = bus_to_hcd(udev->bus); 3754 hcd = bus_to_hcd(udev->bus);
3744 if (!hcd || !hcd->driver->disable_usb3_lpm_timeout) 3755 if (!hcd || !hcd->driver->disable_usb3_lpm_timeout)
3745 return 0; 3756 return 0;
3746 3757
3747 udev->lpm_disable_count++; 3758 udev->lpm_disable_count++;
3748 if ((udev->u1_params.timeout == 0 && udev->u2_params.timeout == 0)) 3759 if ((udev->u1_params.timeout == 0 && udev->u2_params.timeout == 0))
3749 return 0; 3760 return 0;
3750 3761
3751 /* If LPM is enabled, attempt to disable it. */ 3762 /* If LPM is enabled, attempt to disable it. */
3752 if (usb_disable_link_state(hcd, udev, USB3_LPM_U1)) 3763 if (usb_disable_link_state(hcd, udev, USB3_LPM_U1))
3753 goto enable_lpm; 3764 goto enable_lpm;
3754 if (usb_disable_link_state(hcd, udev, USB3_LPM_U2)) 3765 if (usb_disable_link_state(hcd, udev, USB3_LPM_U2))
3755 goto enable_lpm; 3766 goto enable_lpm;
3756 3767
3757 return 0; 3768 return 0;
3758 3769
3759 enable_lpm: 3770 enable_lpm:
3760 usb_enable_lpm(udev); 3771 usb_enable_lpm(udev);
3761 return -EBUSY; 3772 return -EBUSY;
3762 } 3773 }
3763 EXPORT_SYMBOL_GPL(usb_disable_lpm); 3774 EXPORT_SYMBOL_GPL(usb_disable_lpm);
3764 3775
3765 /* Grab the bandwidth_mutex before calling usb_disable_lpm() */ 3776 /* Grab the bandwidth_mutex before calling usb_disable_lpm() */
3766 int usb_unlocked_disable_lpm(struct usb_device *udev) 3777 int usb_unlocked_disable_lpm(struct usb_device *udev)
3767 { 3778 {
3768 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 3779 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
3769 int ret; 3780 int ret;
3770 3781
3771 if (!hcd) 3782 if (!hcd)
3772 return -EINVAL; 3783 return -EINVAL;
3773 3784
3774 mutex_lock(hcd->bandwidth_mutex); 3785 mutex_lock(hcd->bandwidth_mutex);
3775 ret = usb_disable_lpm(udev); 3786 ret = usb_disable_lpm(udev);
3776 mutex_unlock(hcd->bandwidth_mutex); 3787 mutex_unlock(hcd->bandwidth_mutex);
3777 3788
3778 return ret; 3789 return ret;
3779 } 3790 }
3780 EXPORT_SYMBOL_GPL(usb_unlocked_disable_lpm); 3791 EXPORT_SYMBOL_GPL(usb_unlocked_disable_lpm);
3781 3792
3782 /* 3793 /*
3783 * Attempt to enable device-initiated and hub-initiated U1 and U2 entry. The 3794 * Attempt to enable device-initiated and hub-initiated U1 and U2 entry. The
3784 * xHCI host policy may prevent U1 or U2 from being enabled. 3795 * xHCI host policy may prevent U1 or U2 from being enabled.
3785 * 3796 *
3786 * Other callers may have disabled link PM, so U1 and U2 entry will be disabled 3797 * Other callers may have disabled link PM, so U1 and U2 entry will be disabled
3787 * until the lpm_disable_count drops to zero. Caller must own the 3798 * until the lpm_disable_count drops to zero. Caller must own the
3788 * bandwidth_mutex. 3799 * bandwidth_mutex.
3789 */ 3800 */
3790 void usb_enable_lpm(struct usb_device *udev) 3801 void usb_enable_lpm(struct usb_device *udev)
3791 { 3802 {
3792 struct usb_hcd *hcd; 3803 struct usb_hcd *hcd;
3793 3804
3794 if (!udev || !udev->parent || 3805 if (!udev || !udev->parent ||
3795 udev->speed != USB_SPEED_SUPER || 3806 udev->speed != USB_SPEED_SUPER ||
3796 !udev->lpm_capable) 3807 !udev->lpm_capable)
3797 return; 3808 return;
3798 3809
3799 udev->lpm_disable_count--; 3810 udev->lpm_disable_count--;
3800 hcd = bus_to_hcd(udev->bus); 3811 hcd = bus_to_hcd(udev->bus);
3801 /* Double check that we can both enable and disable LPM. 3812 /* Double check that we can both enable and disable LPM.
3802 * Device must be configured to accept set feature U1/U2 timeout. 3813 * Device must be configured to accept set feature U1/U2 timeout.
3803 */ 3814 */
3804 if (!hcd || !hcd->driver->enable_usb3_lpm_timeout || 3815 if (!hcd || !hcd->driver->enable_usb3_lpm_timeout ||
3805 !hcd->driver->disable_usb3_lpm_timeout) 3816 !hcd->driver->disable_usb3_lpm_timeout)
3806 return; 3817 return;
3807 3818
3808 if (udev->lpm_disable_count > 0) 3819 if (udev->lpm_disable_count > 0)
3809 return; 3820 return;
3810 3821
3811 usb_enable_link_state(hcd, udev, USB3_LPM_U1); 3822 usb_enable_link_state(hcd, udev, USB3_LPM_U1);
3812 usb_enable_link_state(hcd, udev, USB3_LPM_U2); 3823 usb_enable_link_state(hcd, udev, USB3_LPM_U2);
3813 } 3824 }
3814 EXPORT_SYMBOL_GPL(usb_enable_lpm); 3825 EXPORT_SYMBOL_GPL(usb_enable_lpm);
3815 3826
3816 /* Grab the bandwidth_mutex before calling usb_enable_lpm() */ 3827 /* Grab the bandwidth_mutex before calling usb_enable_lpm() */
3817 void usb_unlocked_enable_lpm(struct usb_device *udev) 3828 void usb_unlocked_enable_lpm(struct usb_device *udev)
3818 { 3829 {
3819 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 3830 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
3820 3831
3821 if (!hcd) 3832 if (!hcd)
3822 return; 3833 return;
3823 3834
3824 mutex_lock(hcd->bandwidth_mutex); 3835 mutex_lock(hcd->bandwidth_mutex);
3825 usb_enable_lpm(udev); 3836 usb_enable_lpm(udev);
3826 mutex_unlock(hcd->bandwidth_mutex); 3837 mutex_unlock(hcd->bandwidth_mutex);
3827 } 3838 }
3828 EXPORT_SYMBOL_GPL(usb_unlocked_enable_lpm); 3839 EXPORT_SYMBOL_GPL(usb_unlocked_enable_lpm);
3829 3840
3830 3841
3831 #else /* CONFIG_PM */ 3842 #else /* CONFIG_PM */
3832 3843
3833 #define hub_suspend NULL 3844 #define hub_suspend NULL
3834 #define hub_resume NULL 3845 #define hub_resume NULL
3835 #define hub_reset_resume NULL 3846 #define hub_reset_resume NULL
3836 3847
3837 int usb_disable_lpm(struct usb_device *udev) 3848 int usb_disable_lpm(struct usb_device *udev)
3838 { 3849 {
3839 return 0; 3850 return 0;
3840 } 3851 }
3841 EXPORT_SYMBOL_GPL(usb_disable_lpm); 3852 EXPORT_SYMBOL_GPL(usb_disable_lpm);
3842 3853
3843 void usb_enable_lpm(struct usb_device *udev) { } 3854 void usb_enable_lpm(struct usb_device *udev) { }
3844 EXPORT_SYMBOL_GPL(usb_enable_lpm); 3855 EXPORT_SYMBOL_GPL(usb_enable_lpm);
3845 3856
3846 int usb_unlocked_disable_lpm(struct usb_device *udev) 3857 int usb_unlocked_disable_lpm(struct usb_device *udev)
3847 { 3858 {
3848 return 0; 3859 return 0;
3849 } 3860 }
3850 EXPORT_SYMBOL_GPL(usb_unlocked_disable_lpm); 3861 EXPORT_SYMBOL_GPL(usb_unlocked_disable_lpm);
3851 3862
3852 void usb_unlocked_enable_lpm(struct usb_device *udev) { } 3863 void usb_unlocked_enable_lpm(struct usb_device *udev) { }
3853 EXPORT_SYMBOL_GPL(usb_unlocked_enable_lpm); 3864 EXPORT_SYMBOL_GPL(usb_unlocked_enable_lpm);
3854 3865
3855 int usb_disable_ltm(struct usb_device *udev) 3866 int usb_disable_ltm(struct usb_device *udev)
3856 { 3867 {
3857 return 0; 3868 return 0;
3858 } 3869 }
3859 EXPORT_SYMBOL_GPL(usb_disable_ltm); 3870 EXPORT_SYMBOL_GPL(usb_disable_ltm);
3860 3871
3861 void usb_enable_ltm(struct usb_device *udev) { } 3872 void usb_enable_ltm(struct usb_device *udev) { }
3862 EXPORT_SYMBOL_GPL(usb_enable_ltm); 3873 EXPORT_SYMBOL_GPL(usb_enable_ltm);
3863 3874
3864 #endif /* CONFIG_PM */ 3875 #endif /* CONFIG_PM */
3865 3876
3866 3877
3867 /* USB 2.0 spec, 7.1.7.3 / fig 7-29: 3878 /* USB 2.0 spec, 7.1.7.3 / fig 7-29:
3868 * 3879 *
3869 * Between connect detection and reset signaling there must be a delay 3880 * Between connect detection and reset signaling there must be a delay
3870 * of 100ms at least for debounce and power-settling. The corresponding 3881 * of 100ms at least for debounce and power-settling. The corresponding
3871 * timer shall restart whenever the downstream port detects a disconnect. 3882 * timer shall restart whenever the downstream port detects a disconnect.
3872 * 3883 *
3873 * Apparently there are some bluetooth and irda-dongles and a number of 3884 * Apparently there are some bluetooth and irda-dongles and a number of
3874 * low-speed devices for which this debounce period may last over a second. 3885 * low-speed devices for which this debounce period may last over a second.
3875 * Not covered by the spec - but easy to deal with. 3886 * Not covered by the spec - but easy to deal with.
3876 * 3887 *
3877 * This implementation uses a 1500ms total debounce timeout; if the 3888 * This implementation uses a 1500ms total debounce timeout; if the
3878 * connection isn't stable by then it returns -ETIMEDOUT. It checks 3889 * connection isn't stable by then it returns -ETIMEDOUT. It checks
3879 * every 25ms for transient disconnects. When the port status has been 3890 * every 25ms for transient disconnects. When the port status has been
3880 * unchanged for 100ms it returns the port status. 3891 * unchanged for 100ms it returns the port status.
3881 */ 3892 */
3882 int hub_port_debounce(struct usb_hub *hub, int port1, bool must_be_connected) 3893 int hub_port_debounce(struct usb_hub *hub, int port1, bool must_be_connected)
3883 { 3894 {
3884 int ret; 3895 int ret;
3885 int total_time, stable_time = 0; 3896 int total_time, stable_time = 0;
3886 u16 portchange, portstatus; 3897 u16 portchange, portstatus;
3887 unsigned connection = 0xffff; 3898 unsigned connection = 0xffff;
3888 3899
3889 for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { 3900 for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) {
3890 ret = hub_port_status(hub, port1, &portstatus, &portchange); 3901 ret = hub_port_status(hub, port1, &portstatus, &portchange);
3891 if (ret < 0) 3902 if (ret < 0)
3892 return ret; 3903 return ret;
3893 3904
3894 if (!(portchange & USB_PORT_STAT_C_CONNECTION) && 3905 if (!(portchange & USB_PORT_STAT_C_CONNECTION) &&
3895 (portstatus & USB_PORT_STAT_CONNECTION) == connection) { 3906 (portstatus & USB_PORT_STAT_CONNECTION) == connection) {
3896 if (!must_be_connected || 3907 if (!must_be_connected ||
3897 (connection == USB_PORT_STAT_CONNECTION)) 3908 (connection == USB_PORT_STAT_CONNECTION))
3898 stable_time += HUB_DEBOUNCE_STEP; 3909 stable_time += HUB_DEBOUNCE_STEP;
3899 if (stable_time >= HUB_DEBOUNCE_STABLE) 3910 if (stable_time >= HUB_DEBOUNCE_STABLE)
3900 break; 3911 break;
3901 } else { 3912 } else {
3902 stable_time = 0; 3913 stable_time = 0;
3903 connection = portstatus & USB_PORT_STAT_CONNECTION; 3914 connection = portstatus & USB_PORT_STAT_CONNECTION;
3904 } 3915 }
3905 3916
3906 if (portchange & USB_PORT_STAT_C_CONNECTION) { 3917 if (portchange & USB_PORT_STAT_C_CONNECTION) {
3907 usb_clear_port_feature(hub->hdev, port1, 3918 usb_clear_port_feature(hub->hdev, port1,
3908 USB_PORT_FEAT_C_CONNECTION); 3919 USB_PORT_FEAT_C_CONNECTION);
3909 } 3920 }
3910 3921
3911 if (total_time >= HUB_DEBOUNCE_TIMEOUT) 3922 if (total_time >= HUB_DEBOUNCE_TIMEOUT)
3912 break; 3923 break;
3913 msleep(HUB_DEBOUNCE_STEP); 3924 msleep(HUB_DEBOUNCE_STEP);
3914 } 3925 }
3915 3926
3916 dev_dbg (hub->intfdev, 3927 dev_dbg (hub->intfdev,
3917 "debounce: port %d: total %dms stable %dms status 0x%x\n", 3928 "debounce: port %d: total %dms stable %dms status 0x%x\n",
3918 port1, total_time, stable_time, portstatus); 3929 port1, total_time, stable_time, portstatus);
3919 3930
3920 if (stable_time < HUB_DEBOUNCE_STABLE) 3931 if (stable_time < HUB_DEBOUNCE_STABLE)
3921 return -ETIMEDOUT; 3932 return -ETIMEDOUT;
3922 return portstatus; 3933 return portstatus;
3923 } 3934 }
3924 3935
3925 void usb_ep0_reinit(struct usb_device *udev) 3936 void usb_ep0_reinit(struct usb_device *udev)
3926 { 3937 {
3927 usb_disable_endpoint(udev, 0 + USB_DIR_IN, true); 3938 usb_disable_endpoint(udev, 0 + USB_DIR_IN, true);
3928 usb_disable_endpoint(udev, 0 + USB_DIR_OUT, true); 3939 usb_disable_endpoint(udev, 0 + USB_DIR_OUT, true);
3929 usb_enable_endpoint(udev, &udev->ep0, true); 3940 usb_enable_endpoint(udev, &udev->ep0, true);
3930 } 3941 }
3931 EXPORT_SYMBOL_GPL(usb_ep0_reinit); 3942 EXPORT_SYMBOL_GPL(usb_ep0_reinit);
3932 3943
3933 #define usb_sndaddr0pipe() (PIPE_CONTROL << 30) 3944 #define usb_sndaddr0pipe() (PIPE_CONTROL << 30)
3934 #define usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN) 3945 #define usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN)
3935 3946
3936 static int hub_set_address(struct usb_device *udev, int devnum) 3947 static int hub_set_address(struct usb_device *udev, int devnum)
3937 { 3948 {
3938 int retval; 3949 int retval;
3939 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 3950 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
3940 3951
3941 /* 3952 /*
3942 * The host controller will choose the device address, 3953 * The host controller will choose the device address,
3943 * instead of the core having chosen it earlier 3954 * instead of the core having chosen it earlier
3944 */ 3955 */
3945 if (!hcd->driver->address_device && devnum <= 1) 3956 if (!hcd->driver->address_device && devnum <= 1)
3946 return -EINVAL; 3957 return -EINVAL;
3947 if (udev->state == USB_STATE_ADDRESS) 3958 if (udev->state == USB_STATE_ADDRESS)
3948 return 0; 3959 return 0;
3949 if (udev->state != USB_STATE_DEFAULT) 3960 if (udev->state != USB_STATE_DEFAULT)
3950 return -EINVAL; 3961 return -EINVAL;
3951 if (hcd->driver->address_device) 3962 if (hcd->driver->address_device)
3952 retval = hcd->driver->address_device(hcd, udev); 3963 retval = hcd->driver->address_device(hcd, udev);
3953 else 3964 else
3954 retval = usb_control_msg(udev, usb_sndaddr0pipe(), 3965 retval = usb_control_msg(udev, usb_sndaddr0pipe(),
3955 USB_REQ_SET_ADDRESS, 0, devnum, 0, 3966 USB_REQ_SET_ADDRESS, 0, devnum, 0,
3956 NULL, 0, USB_CTRL_SET_TIMEOUT); 3967 NULL, 0, USB_CTRL_SET_TIMEOUT);
3957 if (retval == 0) { 3968 if (retval == 0) {
3958 update_devnum(udev, devnum); 3969 update_devnum(udev, devnum);
3959 /* Device now using proper address. */ 3970 /* Device now using proper address. */
3960 usb_set_device_state(udev, USB_STATE_ADDRESS); 3971 usb_set_device_state(udev, USB_STATE_ADDRESS);
3961 usb_ep0_reinit(udev); 3972 usb_ep0_reinit(udev);
3962 } 3973 }
3963 return retval; 3974 return retval;
3964 } 3975 }
3965 3976
3966 /* 3977 /*
3967 * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM 3978 * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM
3968 * when they're plugged into a USB 2.0 port, but they don't work when LPM is 3979 * when they're plugged into a USB 2.0 port, but they don't work when LPM is
3969 * enabled. 3980 * enabled.
3970 * 3981 *
3971 * Only enable USB 2.0 Link PM if the port is internal (hardwired), or the 3982 * Only enable USB 2.0 Link PM if the port is internal (hardwired), or the
3972 * device says it supports the new USB 2.0 Link PM errata by setting the BESL 3983 * device says it supports the new USB 2.0 Link PM errata by setting the BESL
3973 * support bit in the BOS descriptor. 3984 * support bit in the BOS descriptor.
3974 */ 3985 */
3975 static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev) 3986 static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev)
3976 { 3987 {
3977 int connect_type; 3988 int connect_type;
3978 3989
3979 if (!udev->usb2_hw_lpm_capable) 3990 if (!udev->usb2_hw_lpm_capable)
3980 return; 3991 return;
3981 3992
3982 connect_type = usb_get_hub_port_connect_type(udev->parent, 3993 connect_type = usb_get_hub_port_connect_type(udev->parent,
3983 udev->portnum); 3994 udev->portnum);
3984 3995
3985 if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) || 3996 if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) ||
3986 connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { 3997 connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
3987 udev->usb2_hw_lpm_allowed = 1; 3998 udev->usb2_hw_lpm_allowed = 1;
3988 usb_set_usb2_hardware_lpm(udev, 1); 3999 usb_set_usb2_hardware_lpm(udev, 1);
3989 } 4000 }
3990 } 4001 }
3991 4002
3992 static int hub_enable_device(struct usb_device *udev) 4003 static int hub_enable_device(struct usb_device *udev)
3993 { 4004 {
3994 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 4005 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
3995 4006
3996 if (!hcd->driver->enable_device) 4007 if (!hcd->driver->enable_device)
3997 return 0; 4008 return 0;
3998 if (udev->state == USB_STATE_ADDRESS) 4009 if (udev->state == USB_STATE_ADDRESS)
3999 return 0; 4010 return 0;
4000 if (udev->state != USB_STATE_DEFAULT) 4011 if (udev->state != USB_STATE_DEFAULT)
4001 return -EINVAL; 4012 return -EINVAL;
4002 4013
4003 return hcd->driver->enable_device(hcd, udev); 4014 return hcd->driver->enable_device(hcd, udev);
4004 } 4015 }
4005 4016
4006 /* Reset device, (re)assign address, get device descriptor. 4017 /* Reset device, (re)assign address, get device descriptor.
4007 * Device connection must be stable, no more debouncing needed. 4018 * Device connection must be stable, no more debouncing needed.
4008 * Returns device in USB_STATE_ADDRESS, except on error. 4019 * Returns device in USB_STATE_ADDRESS, except on error.
4009 * 4020 *
4010 * If this is called for an already-existing device (as part of 4021 * If this is called for an already-existing device (as part of
4011 * usb_reset_and_verify_device), the caller must own the device lock. For a 4022 * usb_reset_and_verify_device), the caller must own the device lock. For a
4012 * newly detected device that is not accessible through any global 4023 * newly detected device that is not accessible through any global
4013 * pointers, it's not necessary to lock the device. 4024 * pointers, it's not necessary to lock the device.
4014 */ 4025 */
4015 static int 4026 static int
4016 hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, 4027 hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4017 int retry_counter) 4028 int retry_counter)
4018 { 4029 {
4019 static DEFINE_MUTEX(usb_address0_mutex); 4030 static DEFINE_MUTEX(usb_address0_mutex);
4020 4031
4021 struct usb_device *hdev = hub->hdev; 4032 struct usb_device *hdev = hub->hdev;
4022 struct usb_hcd *hcd = bus_to_hcd(hdev->bus); 4033 struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
4023 int i, j, retval; 4034 int i, j, retval;
4024 unsigned delay = HUB_SHORT_RESET_TIME; 4035 unsigned delay = HUB_SHORT_RESET_TIME;
4025 enum usb_device_speed oldspeed = udev->speed; 4036 enum usb_device_speed oldspeed = udev->speed;
4026 const char *speed; 4037 const char *speed;
4027 int devnum = udev->devnum; 4038 int devnum = udev->devnum;
4028 4039
4029 /* root hub ports have a slightly longer reset period 4040 /* root hub ports have a slightly longer reset period
4030 * (from USB 2.0 spec, section 7.1.7.5) 4041 * (from USB 2.0 spec, section 7.1.7.5)
4031 */ 4042 */
4032 if (!hdev->parent) { 4043 if (!hdev->parent) {
4033 delay = HUB_ROOT_RESET_TIME; 4044 delay = HUB_ROOT_RESET_TIME;
4034 if (port1 == hdev->bus->otg_port) 4045 if (port1 == hdev->bus->otg_port)
4035 hdev->bus->b_hnp_enable = 0; 4046 hdev->bus->b_hnp_enable = 0;
4036 } 4047 }
4037 4048
4038 /* Some low speed devices have problems with the quick delay, so */ 4049 /* Some low speed devices have problems with the quick delay, so */
4039 /* be a bit pessimistic with those devices. RHbug #23670 */ 4050 /* be a bit pessimistic with those devices. RHbug #23670 */
4040 if (oldspeed == USB_SPEED_LOW) 4051 if (oldspeed == USB_SPEED_LOW)
4041 delay = HUB_LONG_RESET_TIME; 4052 delay = HUB_LONG_RESET_TIME;
4042 4053
4043 mutex_lock(&usb_address0_mutex); 4054 mutex_lock(&usb_address0_mutex);
4044 4055
4045 /* Reset the device; full speed may morph to high speed */ 4056 /* Reset the device; full speed may morph to high speed */
4046 /* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */ 4057 /* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */
4047 retval = hub_port_reset(hub, port1, udev, delay, false); 4058 retval = hub_port_reset(hub, port1, udev, delay, false);
4048 if (retval < 0) /* error or disconnect */ 4059 if (retval < 0) /* error or disconnect */
4049 goto fail; 4060 goto fail;
4050 /* success, speed is known */ 4061 /* success, speed is known */
4051 4062
4052 retval = -ENODEV; 4063 retval = -ENODEV;
4053 4064
4054 if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed) { 4065 if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed) {
4055 dev_dbg(&udev->dev, "device reset changed speed!\n"); 4066 dev_dbg(&udev->dev, "device reset changed speed!\n");
4056 goto fail; 4067 goto fail;
4057 } 4068 }
4058 oldspeed = udev->speed; 4069 oldspeed = udev->speed;
4059 4070
4060 /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ... 4071 /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
4061 * it's fixed size except for full speed devices. 4072 * it's fixed size except for full speed devices.
4062 * For Wireless USB devices, ep0 max packet is always 512 (tho 4073 * For Wireless USB devices, ep0 max packet is always 512 (tho
4063 * reported as 0xff in the device descriptor). WUSB1.0[4.8.1]. 4074 * reported as 0xff in the device descriptor). WUSB1.0[4.8.1].
4064 */ 4075 */
4065 switch (udev->speed) { 4076 switch (udev->speed) {
4066 case USB_SPEED_SUPER: 4077 case USB_SPEED_SUPER:
4067 case USB_SPEED_WIRELESS: /* fixed at 512 */ 4078 case USB_SPEED_WIRELESS: /* fixed at 512 */
4068 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512); 4079 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512);
4069 break; 4080 break;
4070 case USB_SPEED_HIGH: /* fixed at 64 */ 4081 case USB_SPEED_HIGH: /* fixed at 64 */
4071 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64); 4082 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
4072 break; 4083 break;
4073 case USB_SPEED_FULL: /* 8, 16, 32, or 64 */ 4084 case USB_SPEED_FULL: /* 8, 16, 32, or 64 */
4074 /* to determine the ep0 maxpacket size, try to read 4085 /* to determine the ep0 maxpacket size, try to read
4075 * the device descriptor to get bMaxPacketSize0 and 4086 * the device descriptor to get bMaxPacketSize0 and
4076 * then correct our initial guess. 4087 * then correct our initial guess.
4077 */ 4088 */
4078 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64); 4089 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
4079 break; 4090 break;
4080 case USB_SPEED_LOW: /* fixed at 8 */ 4091 case USB_SPEED_LOW: /* fixed at 8 */
4081 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(8); 4092 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(8);
4082 break; 4093 break;
4083 default: 4094 default:
4084 goto fail; 4095 goto fail;
4085 } 4096 }
4086 4097
4087 if (udev->speed == USB_SPEED_WIRELESS) 4098 if (udev->speed == USB_SPEED_WIRELESS)
4088 speed = "variable speed Wireless"; 4099 speed = "variable speed Wireless";
4089 else 4100 else
4090 speed = usb_speed_string(udev->speed); 4101 speed = usb_speed_string(udev->speed);
4091 4102
4092 if (udev->speed != USB_SPEED_SUPER) 4103 if (udev->speed != USB_SPEED_SUPER)
4093 dev_info(&udev->dev, 4104 dev_info(&udev->dev,
4094 "%s %s USB device number %d using %s\n", 4105 "%s %s USB device number %d using %s\n",
4095 (udev->config) ? "reset" : "new", speed, 4106 (udev->config) ? "reset" : "new", speed,
4096 devnum, udev->bus->controller->driver->name); 4107 devnum, udev->bus->controller->driver->name);
4097 4108
4098 /* Set up TT records, if needed */ 4109 /* Set up TT records, if needed */
4099 if (hdev->tt) { 4110 if (hdev->tt) {
4100 udev->tt = hdev->tt; 4111 udev->tt = hdev->tt;
4101 udev->ttport = hdev->ttport; 4112 udev->ttport = hdev->ttport;
4102 } else if (udev->speed != USB_SPEED_HIGH 4113 } else if (udev->speed != USB_SPEED_HIGH
4103 && hdev->speed == USB_SPEED_HIGH) { 4114 && hdev->speed == USB_SPEED_HIGH) {
4104 if (!hub->tt.hub) { 4115 if (!hub->tt.hub) {
4105 dev_err(&udev->dev, "parent hub has no TT\n"); 4116 dev_err(&udev->dev, "parent hub has no TT\n");
4106 retval = -EINVAL; 4117 retval = -EINVAL;
4107 goto fail; 4118 goto fail;
4108 } 4119 }
4109 udev->tt = &hub->tt; 4120 udev->tt = &hub->tt;
4110 udev->ttport = port1; 4121 udev->ttport = port1;
4111 } 4122 }
4112 4123
4113 /* Why interleave GET_DESCRIPTOR and SET_ADDRESS this way? 4124 /* Why interleave GET_DESCRIPTOR and SET_ADDRESS this way?
4114 * Because device hardware and firmware is sometimes buggy in 4125 * Because device hardware and firmware is sometimes buggy in
4115 * this area, and this is how Linux has done it for ages. 4126 * this area, and this is how Linux has done it for ages.
4116 * Change it cautiously. 4127 * Change it cautiously.
4117 * 4128 *
4118 * NOTE: If use_new_scheme() is true we will start by issuing 4129 * NOTE: If use_new_scheme() is true we will start by issuing
4119 * a 64-byte GET_DESCRIPTOR request. This is what Windows does, 4130 * a 64-byte GET_DESCRIPTOR request. This is what Windows does,
4120 * so it may help with some non-standards-compliant devices. 4131 * so it may help with some non-standards-compliant devices.
4121 * Otherwise we start with SET_ADDRESS and then try to read the 4132 * Otherwise we start with SET_ADDRESS and then try to read the
4122 * first 8 bytes of the device descriptor to get the ep0 maxpacket 4133 * first 8 bytes of the device descriptor to get the ep0 maxpacket
4123 * value. 4134 * value.
4124 */ 4135 */
4125 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) { 4136 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) {
4126 bool did_new_scheme = false; 4137 bool did_new_scheme = false;
4127 4138
4128 if (use_new_scheme(udev, retry_counter)) { 4139 if (use_new_scheme(udev, retry_counter)) {
4129 struct usb_device_descriptor *buf; 4140 struct usb_device_descriptor *buf;
4130 int r = 0; 4141 int r = 0;
4131 4142
4132 did_new_scheme = true; 4143 did_new_scheme = true;
4133 retval = hub_enable_device(udev); 4144 retval = hub_enable_device(udev);
4134 if (retval < 0) { 4145 if (retval < 0) {
4135 dev_err(&udev->dev, 4146 dev_err(&udev->dev,
4136 "hub failed to enable device, error %d\n", 4147 "hub failed to enable device, error %d\n",
4137 retval); 4148 retval);
4138 goto fail; 4149 goto fail;
4139 } 4150 }
4140 4151
4141 #define GET_DESCRIPTOR_BUFSIZE 64 4152 #define GET_DESCRIPTOR_BUFSIZE 64
4142 buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO); 4153 buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO);
4143 if (!buf) { 4154 if (!buf) {
4144 retval = -ENOMEM; 4155 retval = -ENOMEM;
4145 continue; 4156 continue;
4146 } 4157 }
4147 4158
4148 /* Retry on all errors; some devices are flakey. 4159 /* Retry on all errors; some devices are flakey.
4149 * 255 is for WUSB devices, we actually need to use 4160 * 255 is for WUSB devices, we actually need to use
4150 * 512 (WUSB1.0[4.8.1]). 4161 * 512 (WUSB1.0[4.8.1]).
4151 */ 4162 */
4152 for (j = 0; j < 3; ++j) { 4163 for (j = 0; j < 3; ++j) {
4153 buf->bMaxPacketSize0 = 0; 4164 buf->bMaxPacketSize0 = 0;
4154 r = usb_control_msg(udev, usb_rcvaddr0pipe(), 4165 r = usb_control_msg(udev, usb_rcvaddr0pipe(),
4155 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, 4166 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
4156 USB_DT_DEVICE << 8, 0, 4167 USB_DT_DEVICE << 8, 0,
4157 buf, GET_DESCRIPTOR_BUFSIZE, 4168 buf, GET_DESCRIPTOR_BUFSIZE,
4158 initial_descriptor_timeout); 4169 initial_descriptor_timeout);
4159 switch (buf->bMaxPacketSize0) { 4170 switch (buf->bMaxPacketSize0) {
4160 case 8: case 16: case 32: case 64: case 255: 4171 case 8: case 16: case 32: case 64: case 255:
4161 if (buf->bDescriptorType == 4172 if (buf->bDescriptorType ==
4162 USB_DT_DEVICE) { 4173 USB_DT_DEVICE) {
4163 r = 0; 4174 r = 0;
4164 break; 4175 break;
4165 } 4176 }
4166 /* FALL THROUGH */ 4177 /* FALL THROUGH */
4167 default: 4178 default:
4168 if (r == 0) 4179 if (r == 0)
4169 r = -EPROTO; 4180 r = -EPROTO;
4170 break; 4181 break;
4171 } 4182 }
4172 if (r == 0) 4183 if (r == 0)
4173 break; 4184 break;
4174 } 4185 }
4175 udev->descriptor.bMaxPacketSize0 = 4186 udev->descriptor.bMaxPacketSize0 =
4176 buf->bMaxPacketSize0; 4187 buf->bMaxPacketSize0;
4177 kfree(buf); 4188 kfree(buf);
4178 4189
4179 retval = hub_port_reset(hub, port1, udev, delay, false); 4190 retval = hub_port_reset(hub, port1, udev, delay, false);
4180 if (retval < 0) /* error or disconnect */ 4191 if (retval < 0) /* error or disconnect */
4181 goto fail; 4192 goto fail;
4182 if (oldspeed != udev->speed) { 4193 if (oldspeed != udev->speed) {
4183 dev_dbg(&udev->dev, 4194 dev_dbg(&udev->dev,
4184 "device reset changed speed!\n"); 4195 "device reset changed speed!\n");
4185 retval = -ENODEV; 4196 retval = -ENODEV;
4186 goto fail; 4197 goto fail;
4187 } 4198 }
4188 if (r) { 4199 if (r) {
4189 if (r != -ENODEV) 4200 if (r != -ENODEV)
4190 dev_err(&udev->dev, "device descriptor read/64, error %d\n", 4201 dev_err(&udev->dev, "device descriptor read/64, error %d\n",
4191 r); 4202 r);
4192 retval = -EMSGSIZE; 4203 retval = -EMSGSIZE;
4193 continue; 4204 continue;
4194 } 4205 }
4195 #undef GET_DESCRIPTOR_BUFSIZE 4206 #undef GET_DESCRIPTOR_BUFSIZE
4196 } 4207 }
4197 4208
4198 /* 4209 /*
4199 * If device is WUSB, we already assigned an 4210 * If device is WUSB, we already assigned an
4200 * unauthorized address in the Connect Ack sequence; 4211 * unauthorized address in the Connect Ack sequence;
4201 * authorization will assign the final address. 4212 * authorization will assign the final address.
4202 */ 4213 */
4203 if (udev->wusb == 0) { 4214 if (udev->wusb == 0) {
4204 for (j = 0; j < SET_ADDRESS_TRIES; ++j) { 4215 for (j = 0; j < SET_ADDRESS_TRIES; ++j) {
4205 retval = hub_set_address(udev, devnum); 4216 retval = hub_set_address(udev, devnum);
4206 if (retval >= 0) 4217 if (retval >= 0)
4207 break; 4218 break;
4208 msleep(200); 4219 msleep(200);
4209 } 4220 }
4210 if (retval < 0) { 4221 if (retval < 0) {
4211 if (retval != -ENODEV) 4222 if (retval != -ENODEV)
4212 dev_err(&udev->dev, "device not accepting address %d, error %d\n", 4223 dev_err(&udev->dev, "device not accepting address %d, error %d\n",
4213 devnum, retval); 4224 devnum, retval);
4214 goto fail; 4225 goto fail;
4215 } 4226 }
4216 if (udev->speed == USB_SPEED_SUPER) { 4227 if (udev->speed == USB_SPEED_SUPER) {
4217 devnum = udev->devnum; 4228 devnum = udev->devnum;
4218 dev_info(&udev->dev, 4229 dev_info(&udev->dev,
4219 "%s SuperSpeed USB device number %d using %s\n", 4230 "%s SuperSpeed USB device number %d using %s\n",
4220 (udev->config) ? "reset" : "new", 4231 (udev->config) ? "reset" : "new",
4221 devnum, udev->bus->controller->driver->name); 4232 devnum, udev->bus->controller->driver->name);
4222 } 4233 }
4223 4234
4224 /* cope with hardware quirkiness: 4235 /* cope with hardware quirkiness:
4225 * - let SET_ADDRESS settle, some device hardware wants it 4236 * - let SET_ADDRESS settle, some device hardware wants it
4226 * - read ep0 maxpacket even for high and low speed, 4237 * - read ep0 maxpacket even for high and low speed,
4227 */ 4238 */
4228 msleep(10); 4239 msleep(10);
4229 /* use_new_scheme() checks the speed which may have 4240 /* use_new_scheme() checks the speed which may have
4230 * changed since the initial look so we cache the result 4241 * changed since the initial look so we cache the result
4231 * in did_new_scheme 4242 * in did_new_scheme
4232 */ 4243 */
4233 if (did_new_scheme) 4244 if (did_new_scheme)
4234 break; 4245 break;
4235 } 4246 }
4236 4247
4237 retval = usb_get_device_descriptor(udev, 8); 4248 retval = usb_get_device_descriptor(udev, 8);
4238 if (retval < 8) { 4249 if (retval < 8) {
4239 if (retval != -ENODEV) 4250 if (retval != -ENODEV)
4240 dev_err(&udev->dev, 4251 dev_err(&udev->dev,
4241 "device descriptor read/8, error %d\n", 4252 "device descriptor read/8, error %d\n",
4242 retval); 4253 retval);
4243 if (retval >= 0) 4254 if (retval >= 0)
4244 retval = -EMSGSIZE; 4255 retval = -EMSGSIZE;
4245 } else { 4256 } else {
4246 retval = 0; 4257 retval = 0;
4247 break; 4258 break;
4248 } 4259 }
4249 } 4260 }
4250 if (retval) 4261 if (retval)
4251 goto fail; 4262 goto fail;
4252 4263
4253 if (hcd->phy && !hdev->parent) 4264 if (hcd->phy && !hdev->parent)
4254 usb_phy_notify_connect(hcd->phy, udev->speed); 4265 usb_phy_notify_connect(hcd->phy, udev->speed);
4255 4266
4256 /* 4267 /*
4257 * Some superspeed devices have finished the link training process 4268 * Some superspeed devices have finished the link training process
4258 * and attached to a superspeed hub port, but the device descriptor 4269 * and attached to a superspeed hub port, but the device descriptor
4259 * got from those devices show they aren't superspeed devices. Warm 4270 * got from those devices show they aren't superspeed devices. Warm
4260 * reset the port attached by the devices can fix them. 4271 * reset the port attached by the devices can fix them.
4261 */ 4272 */
4262 if ((udev->speed == USB_SPEED_SUPER) && 4273 if ((udev->speed == USB_SPEED_SUPER) &&
4263 (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0300)) { 4274 (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0300)) {
4264 dev_err(&udev->dev, "got a wrong device descriptor, " 4275 dev_err(&udev->dev, "got a wrong device descriptor, "
4265 "warm reset device\n"); 4276 "warm reset device\n");
4266 hub_port_reset(hub, port1, udev, 4277 hub_port_reset(hub, port1, udev,
4267 HUB_BH_RESET_TIME, true); 4278 HUB_BH_RESET_TIME, true);
4268 retval = -EINVAL; 4279 retval = -EINVAL;
4269 goto fail; 4280 goto fail;
4270 } 4281 }
4271 4282
4272 if (udev->descriptor.bMaxPacketSize0 == 0xff || 4283 if (udev->descriptor.bMaxPacketSize0 == 0xff ||
4273 udev->speed == USB_SPEED_SUPER) 4284 udev->speed == USB_SPEED_SUPER)
4274 i = 512; 4285 i = 512;
4275 else 4286 else
4276 i = udev->descriptor.bMaxPacketSize0; 4287 i = udev->descriptor.bMaxPacketSize0;
4277 if (usb_endpoint_maxp(&udev->ep0.desc) != i) { 4288 if (usb_endpoint_maxp(&udev->ep0.desc) != i) {
4278 if (udev->speed == USB_SPEED_LOW || 4289 if (udev->speed == USB_SPEED_LOW ||
4279 !(i == 8 || i == 16 || i == 32 || i == 64)) { 4290 !(i == 8 || i == 16 || i == 32 || i == 64)) {
4280 dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i); 4291 dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i);
4281 retval = -EMSGSIZE; 4292 retval = -EMSGSIZE;
4282 goto fail; 4293 goto fail;
4283 } 4294 }
4284 if (udev->speed == USB_SPEED_FULL) 4295 if (udev->speed == USB_SPEED_FULL)
4285 dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i); 4296 dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
4286 else 4297 else
4287 dev_warn(&udev->dev, "Using ep0 maxpacket: %d\n", i); 4298 dev_warn(&udev->dev, "Using ep0 maxpacket: %d\n", i);
4288 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i); 4299 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i);
4289 usb_ep0_reinit(udev); 4300 usb_ep0_reinit(udev);
4290 } 4301 }
4291 4302
4292 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE); 4303 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
4293 if (retval < (signed)sizeof(udev->descriptor)) { 4304 if (retval < (signed)sizeof(udev->descriptor)) {
4294 if (retval != -ENODEV) 4305 if (retval != -ENODEV)
4295 dev_err(&udev->dev, "device descriptor read/all, error %d\n", 4306 dev_err(&udev->dev, "device descriptor read/all, error %d\n",
4296 retval); 4307 retval);
4297 if (retval >= 0) 4308 if (retval >= 0)
4298 retval = -ENOMSG; 4309 retval = -ENOMSG;
4299 goto fail; 4310 goto fail;
4300 } 4311 }
4301 4312
4302 if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) { 4313 if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) {
4303 retval = usb_get_bos_descriptor(udev); 4314 retval = usb_get_bos_descriptor(udev);
4304 if (!retval) { 4315 if (!retval) {
4305 udev->lpm_capable = usb_device_supports_lpm(udev); 4316 udev->lpm_capable = usb_device_supports_lpm(udev);
4306 usb_set_lpm_parameters(udev); 4317 usb_set_lpm_parameters(udev);
4307 } 4318 }
4308 } 4319 }
4309 4320
4310 retval = 0; 4321 retval = 0;
4311 /* notify HCD that we have a device connected and addressed */ 4322 /* notify HCD that we have a device connected and addressed */
4312 if (hcd->driver->update_device) 4323 if (hcd->driver->update_device)
4313 hcd->driver->update_device(hcd, udev); 4324 hcd->driver->update_device(hcd, udev);
4314 hub_set_initial_usb2_lpm_policy(udev); 4325 hub_set_initial_usb2_lpm_policy(udev);
4315 fail: 4326 fail:
4316 if (retval) { 4327 if (retval) {
4317 hub_port_disable(hub, port1, 0); 4328 hub_port_disable(hub, port1, 0);
4318 update_devnum(udev, devnum); /* for disconnect processing */ 4329 update_devnum(udev, devnum); /* for disconnect processing */
4319 } 4330 }
4320 mutex_unlock(&usb_address0_mutex); 4331 mutex_unlock(&usb_address0_mutex);
4321 return retval; 4332 return retval;
4322 } 4333 }
4323 4334
4324 static void 4335 static void
4325 check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1) 4336 check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
4326 { 4337 {
4327 struct usb_qualifier_descriptor *qual; 4338 struct usb_qualifier_descriptor *qual;
4328 int status; 4339 int status;
4329 4340
4330 qual = kmalloc (sizeof *qual, GFP_KERNEL); 4341 qual = kmalloc (sizeof *qual, GFP_KERNEL);
4331 if (qual == NULL) 4342 if (qual == NULL)
4332 return; 4343 return;
4333 4344
4334 status = usb_get_descriptor (udev, USB_DT_DEVICE_QUALIFIER, 0, 4345 status = usb_get_descriptor (udev, USB_DT_DEVICE_QUALIFIER, 0,
4335 qual, sizeof *qual); 4346 qual, sizeof *qual);
4336 if (status == sizeof *qual) { 4347 if (status == sizeof *qual) {
4337 dev_info(&udev->dev, "not running at top speed; " 4348 dev_info(&udev->dev, "not running at top speed; "
4338 "connect to a high speed hub\n"); 4349 "connect to a high speed hub\n");
4339 /* hub LEDs are probably harder to miss than syslog */ 4350 /* hub LEDs are probably harder to miss than syslog */
4340 if (hub->has_indicators) { 4351 if (hub->has_indicators) {
4341 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; 4352 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK;
4342 queue_delayed_work(system_power_efficient_wq, 4353 queue_delayed_work(system_power_efficient_wq,
4343 &hub->leds, 0); 4354 &hub->leds, 0);
4344 } 4355 }
4345 } 4356 }
4346 kfree(qual); 4357 kfree(qual);
4347 } 4358 }
4348 4359
4349 static unsigned 4360 static unsigned
4350 hub_power_remaining (struct usb_hub *hub) 4361 hub_power_remaining (struct usb_hub *hub)
4351 { 4362 {
4352 struct usb_device *hdev = hub->hdev; 4363 struct usb_device *hdev = hub->hdev;
4353 int remaining; 4364 int remaining;
4354 int port1; 4365 int port1;
4355 4366
4356 if (!hub->limited_power) 4367 if (!hub->limited_power)
4357 return 0; 4368 return 0;
4358 4369
4359 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; 4370 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent;
4360 for (port1 = 1; port1 <= hdev->maxchild; ++port1) { 4371 for (port1 = 1; port1 <= hdev->maxchild; ++port1) {
4361 struct usb_device *udev = hub->ports[port1 - 1]->child; 4372 struct usb_device *udev = hub->ports[port1 - 1]->child;
4362 int delta; 4373 int delta;
4363 unsigned unit_load; 4374 unsigned unit_load;
4364 4375
4365 if (!udev) 4376 if (!udev)
4366 continue; 4377 continue;
4367 if (hub_is_superspeed(udev)) 4378 if (hub_is_superspeed(udev))
4368 unit_load = 150; 4379 unit_load = 150;
4369 else 4380 else
4370 unit_load = 100; 4381 unit_load = 100;
4371 4382
4372 /* 4383 /*
4373 * Unconfigured devices may not use more than one unit load, 4384 * Unconfigured devices may not use more than one unit load,
4374 * or 8mA for OTG ports 4385 * or 8mA for OTG ports
4375 */ 4386 */
4376 if (udev->actconfig) 4387 if (udev->actconfig)
4377 delta = usb_get_max_power(udev, udev->actconfig); 4388 delta = usb_get_max_power(udev, udev->actconfig);
4378 else if (port1 != udev->bus->otg_port || hdev->parent) 4389 else if (port1 != udev->bus->otg_port || hdev->parent)
4379 delta = unit_load; 4390 delta = unit_load;
4380 else 4391 else
4381 delta = 8; 4392 delta = 8;
4382 if (delta > hub->mA_per_port) 4393 if (delta > hub->mA_per_port)
4383 dev_warn(&udev->dev, 4394 dev_warn(&udev->dev,
4384 "%dmA is over %umA budget for port %d!\n", 4395 "%dmA is over %umA budget for port %d!\n",
4385 delta, hub->mA_per_port, port1); 4396 delta, hub->mA_per_port, port1);
4386 remaining -= delta; 4397 remaining -= delta;
4387 } 4398 }
4388 if (remaining < 0) { 4399 if (remaining < 0) {
4389 dev_warn(hub->intfdev, "%dmA over power budget!\n", 4400 dev_warn(hub->intfdev, "%dmA over power budget!\n",
4390 -remaining); 4401 -remaining);
4391 remaining = 0; 4402 remaining = 0;
4392 } 4403 }
4393 return remaining; 4404 return remaining;
4394 } 4405 }
4395 4406
4396 /* Handle physical or logical connection change events. 4407 /* Handle physical or logical connection change events.
4397 * This routine is called when: 4408 * This routine is called when:
4398 * a port connection-change occurs; 4409 * a port connection-change occurs;
4399 * a port enable-change occurs (often caused by EMI); 4410 * a port enable-change occurs (often caused by EMI);
4400 * usb_reset_and_verify_device() encounters changed descriptors (as from 4411 * usb_reset_and_verify_device() encounters changed descriptors (as from
4401 * a firmware download) 4412 * a firmware download)
4402 * caller already locked the hub 4413 * caller already locked the hub
4403 */ 4414 */
4404 static void hub_port_connect_change(struct usb_hub *hub, int port1, 4415 static void hub_port_connect_change(struct usb_hub *hub, int port1,
4405 u16 portstatus, u16 portchange) 4416 u16 portstatus, u16 portchange)
4406 { 4417 {
4407 struct usb_device *hdev = hub->hdev; 4418 struct usb_device *hdev = hub->hdev;
4408 struct device *hub_dev = hub->intfdev; 4419 struct device *hub_dev = hub->intfdev;
4409 struct usb_hcd *hcd = bus_to_hcd(hdev->bus); 4420 struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
4410 unsigned wHubCharacteristics = 4421 unsigned wHubCharacteristics =
4411 le16_to_cpu(hub->descriptor->wHubCharacteristics); 4422 le16_to_cpu(hub->descriptor->wHubCharacteristics);
4412 struct usb_device *udev; 4423 struct usb_device *udev;
4413 int status, i; 4424 int status, i;
4414 unsigned unit_load; 4425 unsigned unit_load;
4415 4426
4416 dev_dbg (hub_dev, 4427 dev_dbg (hub_dev,
4417 "port %d, status %04x, change %04x, %s\n", 4428 "port %d, status %04x, change %04x, %s\n",
4418 port1, portstatus, portchange, portspeed(hub, portstatus)); 4429 port1, portstatus, portchange, portspeed(hub, portstatus));
4419 4430
4420 if (hub->has_indicators) { 4431 if (hub->has_indicators) {
4421 set_port_led(hub, port1, HUB_LED_AUTO); 4432 set_port_led(hub, port1, HUB_LED_AUTO);
4422 hub->indicator[port1-1] = INDICATOR_AUTO; 4433 hub->indicator[port1-1] = INDICATOR_AUTO;
4423 } 4434 }
4424 4435
4425 #ifdef CONFIG_USB_OTG 4436 #ifdef CONFIG_USB_OTG
4426 /* during HNP, don't repeat the debounce */ 4437 /* during HNP, don't repeat the debounce */
4427 if (hdev->bus->is_b_host) 4438 if (hdev->bus->is_b_host)
4428 portchange &= ~(USB_PORT_STAT_C_CONNECTION | 4439 portchange &= ~(USB_PORT_STAT_C_CONNECTION |
4429 USB_PORT_STAT_C_ENABLE); 4440 USB_PORT_STAT_C_ENABLE);
4430 #endif 4441 #endif
4431 4442
4432 /* Try to resuscitate an existing device */ 4443 /* Try to resuscitate an existing device */
4433 udev = hub->ports[port1 - 1]->child; 4444 udev = hub->ports[port1 - 1]->child;
4434 if ((portstatus & USB_PORT_STAT_CONNECTION) && udev && 4445 if ((portstatus & USB_PORT_STAT_CONNECTION) && udev &&
4435 udev->state != USB_STATE_NOTATTACHED) { 4446 udev->state != USB_STATE_NOTATTACHED) {
4436 usb_lock_device(udev); 4447 usb_lock_device(udev);
4437 if (portstatus & USB_PORT_STAT_ENABLE) { 4448 if (portstatus & USB_PORT_STAT_ENABLE) {
4438 status = 0; /* Nothing to do */ 4449 status = 0; /* Nothing to do */
4439 4450
4440 #ifdef CONFIG_PM_RUNTIME 4451 #ifdef CONFIG_PM_RUNTIME
4441 } else if (udev->state == USB_STATE_SUSPENDED && 4452 } else if (udev->state == USB_STATE_SUSPENDED &&
4442 udev->persist_enabled) { 4453 udev->persist_enabled) {
4443 /* For a suspended device, treat this as a 4454 /* For a suspended device, treat this as a
4444 * remote wakeup event. 4455 * remote wakeup event.
4445 */ 4456 */
4446 status = usb_remote_wakeup(udev); 4457 status = usb_remote_wakeup(udev);
4447 #endif 4458 #endif
4448 4459
4449 } else { 4460 } else {
4450 status = -ENODEV; /* Don't resuscitate */ 4461 status = -ENODEV; /* Don't resuscitate */
4451 } 4462 }
4452 usb_unlock_device(udev); 4463 usb_unlock_device(udev);
4453 4464
4454 if (status == 0) { 4465 if (status == 0) {
4455 clear_bit(port1, hub->change_bits); 4466 clear_bit(port1, hub->change_bits);
4456 return; 4467 return;
4457 } 4468 }
4458 } 4469 }
4459 4470
4460 /* Disconnect any existing devices under this port */ 4471 /* Disconnect any existing devices under this port */
4461 if (udev) { 4472 if (udev) {
4462 if (hcd->phy && !hdev->parent && 4473 if (hcd->phy && !hdev->parent &&
4463 !(portstatus & USB_PORT_STAT_CONNECTION)) 4474 !(portstatus & USB_PORT_STAT_CONNECTION))
4464 usb_phy_notify_disconnect(hcd->phy, udev->speed); 4475 usb_phy_notify_disconnect(hcd->phy, udev->speed);
4465 usb_disconnect(&hub->ports[port1 - 1]->child); 4476 usb_disconnect(&hub->ports[port1 - 1]->child);
4466 } 4477 }
4467 clear_bit(port1, hub->change_bits); 4478 clear_bit(port1, hub->change_bits);
4468 4479
4469 /* We can forget about a "removed" device when there's a physical 4480 /* We can forget about a "removed" device when there's a physical
4470 * disconnect or the connect status changes. 4481 * disconnect or the connect status changes.
4471 */ 4482 */
4472 if (!(portstatus & USB_PORT_STAT_CONNECTION) || 4483 if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
4473 (portchange & USB_PORT_STAT_C_CONNECTION)) 4484 (portchange & USB_PORT_STAT_C_CONNECTION))
4474 clear_bit(port1, hub->removed_bits); 4485 clear_bit(port1, hub->removed_bits);
4475 4486
4476 if (portchange & (USB_PORT_STAT_C_CONNECTION | 4487 if (portchange & (USB_PORT_STAT_C_CONNECTION |
4477 USB_PORT_STAT_C_ENABLE)) { 4488 USB_PORT_STAT_C_ENABLE)) {
4478 status = hub_port_debounce_be_stable(hub, port1); 4489 status = hub_port_debounce_be_stable(hub, port1);
4479 if (status < 0) { 4490 if (status < 0) {
4480 if (status != -ENODEV && printk_ratelimit()) 4491 if (status != -ENODEV && printk_ratelimit())
4481 dev_err(hub_dev, "connect-debounce failed, " 4492 dev_err(hub_dev, "connect-debounce failed, "
4482 "port %d disabled\n", port1); 4493 "port %d disabled\n", port1);
4483 portstatus &= ~USB_PORT_STAT_CONNECTION; 4494 portstatus &= ~USB_PORT_STAT_CONNECTION;
4484 } else { 4495 } else {
4485 portstatus = status; 4496 portstatus = status;
4486 } 4497 }
4487 } 4498 }
4488 4499
4489 /* Return now if debouncing failed or nothing is connected or 4500 /* Return now if debouncing failed or nothing is connected or
4490 * the device was "removed". 4501 * the device was "removed".
4491 */ 4502 */
4492 if (!(portstatus & USB_PORT_STAT_CONNECTION) || 4503 if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
4493 test_bit(port1, hub->removed_bits)) { 4504 test_bit(port1, hub->removed_bits)) {
4494 4505
4495 /* maybe switch power back on (e.g. root hub was reset) */ 4506 /* maybe switch power back on (e.g. root hub was reset) */
4496 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2 4507 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
4497 && !port_is_power_on(hub, portstatus)) 4508 && !port_is_power_on(hub, portstatus))
4498 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 4509 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
4499 4510
4500 if (portstatus & USB_PORT_STAT_ENABLE) 4511 if (portstatus & USB_PORT_STAT_ENABLE)
4501 goto done; 4512 goto done;
4502 return; 4513 return;
4503 } 4514 }
4504 if (hub_is_superspeed(hub->hdev)) 4515 if (hub_is_superspeed(hub->hdev))
4505 unit_load = 150; 4516 unit_load = 150;
4506 else 4517 else
4507 unit_load = 100; 4518 unit_load = 100;
4508 4519
4509 status = 0; 4520 status = 0;
4510 for (i = 0; i < SET_CONFIG_TRIES; i++) { 4521 for (i = 0; i < SET_CONFIG_TRIES; i++) {
4511 4522
4512 /* reallocate for each attempt, since references 4523 /* reallocate for each attempt, since references
4513 * to the previous one can escape in various ways 4524 * to the previous one can escape in various ways
4514 */ 4525 */
4515 udev = usb_alloc_dev(hdev, hdev->bus, port1); 4526 udev = usb_alloc_dev(hdev, hdev->bus, port1);
4516 if (!udev) { 4527 if (!udev) {
4517 dev_err (hub_dev, 4528 dev_err (hub_dev,
4518 "couldn't allocate port %d usb_device\n", 4529 "couldn't allocate port %d usb_device\n",
4519 port1); 4530 port1);
4520 goto done; 4531 goto done;
4521 } 4532 }
4522 4533
4523 usb_set_device_state(udev, USB_STATE_POWERED); 4534 usb_set_device_state(udev, USB_STATE_POWERED);
4524 udev->bus_mA = hub->mA_per_port; 4535 udev->bus_mA = hub->mA_per_port;
4525 udev->level = hdev->level + 1; 4536 udev->level = hdev->level + 1;
4526 udev->wusb = hub_is_wusb(hub); 4537 udev->wusb = hub_is_wusb(hub);
4527 4538
4528 /* Only USB 3.0 devices are connected to SuperSpeed hubs. */ 4539 /* Only USB 3.0 devices are connected to SuperSpeed hubs. */
4529 if (hub_is_superspeed(hub->hdev)) 4540 if (hub_is_superspeed(hub->hdev))
4530 udev->speed = USB_SPEED_SUPER; 4541 udev->speed = USB_SPEED_SUPER;
4531 else 4542 else
4532 udev->speed = USB_SPEED_UNKNOWN; 4543 udev->speed = USB_SPEED_UNKNOWN;
4533 4544
4534 choose_devnum(udev); 4545 choose_devnum(udev);
4535 if (udev->devnum <= 0) { 4546 if (udev->devnum <= 0) {
4536 status = -ENOTCONN; /* Don't retry */ 4547 status = -ENOTCONN; /* Don't retry */
4537 goto loop; 4548 goto loop;
4538 } 4549 }
4539 4550
4540 /* reset (non-USB 3.0 devices) and get descriptor */ 4551 /* reset (non-USB 3.0 devices) and get descriptor */
4541 status = hub_port_init(hub, udev, port1, i); 4552 status = hub_port_init(hub, udev, port1, i);
4542 if (status < 0) 4553 if (status < 0)
4543 goto loop; 4554 goto loop;
4544 4555
4545 usb_detect_quirks(udev); 4556 usb_detect_quirks(udev);
4546 if (udev->quirks & USB_QUIRK_DELAY_INIT) 4557 if (udev->quirks & USB_QUIRK_DELAY_INIT)
4547 msleep(1000); 4558 msleep(1000);
4548 4559
4549 /* consecutive bus-powered hubs aren't reliable; they can 4560 /* consecutive bus-powered hubs aren't reliable; they can
4550 * violate the voltage drop budget. if the new child has 4561 * violate the voltage drop budget. if the new child has
4551 * a "powered" LED, users should notice we didn't enable it 4562 * a "powered" LED, users should notice we didn't enable it
4552 * (without reading syslog), even without per-port LEDs 4563 * (without reading syslog), even without per-port LEDs
4553 * on the parent. 4564 * on the parent.
4554 */ 4565 */
4555 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB 4566 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB
4556 && udev->bus_mA <= unit_load) { 4567 && udev->bus_mA <= unit_load) {
4557 u16 devstat; 4568 u16 devstat;
4558 4569
4559 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, 4570 status = usb_get_status(udev, USB_RECIP_DEVICE, 0,
4560 &devstat); 4571 &devstat);
4561 if (status) { 4572 if (status) {
4562 dev_dbg(&udev->dev, "get status %d ?\n", status); 4573 dev_dbg(&udev->dev, "get status %d ?\n", status);
4563 goto loop_disable; 4574 goto loop_disable;
4564 } 4575 }
4565 if ((devstat & (1 << USB_DEVICE_SELF_POWERED)) == 0) { 4576 if ((devstat & (1 << USB_DEVICE_SELF_POWERED)) == 0) {
4566 dev_err(&udev->dev, 4577 dev_err(&udev->dev,
4567 "can't connect bus-powered hub " 4578 "can't connect bus-powered hub "
4568 "to this port\n"); 4579 "to this port\n");
4569 if (hub->has_indicators) { 4580 if (hub->has_indicators) {
4570 hub->indicator[port1-1] = 4581 hub->indicator[port1-1] =
4571 INDICATOR_AMBER_BLINK; 4582 INDICATOR_AMBER_BLINK;
4572 queue_delayed_work( 4583 queue_delayed_work(
4573 system_power_efficient_wq, 4584 system_power_efficient_wq,
4574 &hub->leds, 0); 4585 &hub->leds, 0);
4575 } 4586 }
4576 status = -ENOTCONN; /* Don't retry */ 4587 status = -ENOTCONN; /* Don't retry */
4577 goto loop_disable; 4588 goto loop_disable;
4578 } 4589 }
4579 } 4590 }
4580 4591
4581 /* check for devices running slower than they could */ 4592 /* check for devices running slower than they could */
4582 if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0200 4593 if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0200
4583 && udev->speed == USB_SPEED_FULL 4594 && udev->speed == USB_SPEED_FULL
4584 && highspeed_hubs != 0) 4595 && highspeed_hubs != 0)
4585 check_highspeed (hub, udev, port1); 4596 check_highspeed (hub, udev, port1);
4586 4597
4587 /* Store the parent's children[] pointer. At this point 4598 /* Store the parent's children[] pointer. At this point
4588 * udev becomes globally accessible, although presumably 4599 * udev becomes globally accessible, although presumably
4589 * no one will look at it until hdev is unlocked. 4600 * no one will look at it until hdev is unlocked.
4590 */ 4601 */
4591 status = 0; 4602 status = 0;
4592 4603
4593 /* We mustn't add new devices if the parent hub has 4604 /* We mustn't add new devices if the parent hub has
4594 * been disconnected; we would race with the 4605 * been disconnected; we would race with the
4595 * recursively_mark_NOTATTACHED() routine. 4606 * recursively_mark_NOTATTACHED() routine.
4596 */ 4607 */
4597 spin_lock_irq(&device_state_lock); 4608 spin_lock_irq(&device_state_lock);
4598 if (hdev->state == USB_STATE_NOTATTACHED) 4609 if (hdev->state == USB_STATE_NOTATTACHED)
4599 status = -ENOTCONN; 4610 status = -ENOTCONN;
4600 else 4611 else
4601 hub->ports[port1 - 1]->child = udev; 4612 hub->ports[port1 - 1]->child = udev;
4602 spin_unlock_irq(&device_state_lock); 4613 spin_unlock_irq(&device_state_lock);
4603 4614
4604 /* Run it through the hoops (find a driver, etc) */ 4615 /* Run it through the hoops (find a driver, etc) */
4605 if (!status) { 4616 if (!status) {
4606 status = usb_new_device(udev); 4617 status = usb_new_device(udev);
4607 if (status) { 4618 if (status) {
4608 spin_lock_irq(&device_state_lock); 4619 spin_lock_irq(&device_state_lock);
4609 hub->ports[port1 - 1]->child = NULL; 4620 hub->ports[port1 - 1]->child = NULL;
4610 spin_unlock_irq(&device_state_lock); 4621 spin_unlock_irq(&device_state_lock);
4611 } 4622 }
4612 } 4623 }
4613 4624
4614 if (status) 4625 if (status)
4615 goto loop_disable; 4626 goto loop_disable;
4616 4627
4617 status = hub_power_remaining(hub); 4628 status = hub_power_remaining(hub);
4618 if (status) 4629 if (status)
4619 dev_dbg(hub_dev, "%dmA power budget left\n", status); 4630 dev_dbg(hub_dev, "%dmA power budget left\n", status);
4620 4631
4621 return; 4632 return;
4622 4633
4623 loop_disable: 4634 loop_disable:
4624 hub_port_disable(hub, port1, 1); 4635 hub_port_disable(hub, port1, 1);
4625 loop: 4636 loop:
4626 usb_ep0_reinit(udev); 4637 usb_ep0_reinit(udev);
4627 release_devnum(udev); 4638 release_devnum(udev);
4628 hub_free_dev(udev); 4639 hub_free_dev(udev);
4629 usb_put_dev(udev); 4640 usb_put_dev(udev);
4630 if ((status == -ENOTCONN) || (status == -ENOTSUPP)) 4641 if ((status == -ENOTCONN) || (status == -ENOTSUPP))
4631 break; 4642 break;
4632 } 4643 }
4633 if (hub->hdev->parent || 4644 if (hub->hdev->parent ||
4634 !hcd->driver->port_handed_over || 4645 !hcd->driver->port_handed_over ||
4635 !(hcd->driver->port_handed_over)(hcd, port1)) { 4646 !(hcd->driver->port_handed_over)(hcd, port1)) {
4636 if (status != -ENOTCONN && status != -ENODEV) 4647 if (status != -ENOTCONN && status != -ENODEV)
4637 dev_err(hub_dev, "unable to enumerate USB device on port %d\n", 4648 dev_err(hub_dev, "unable to enumerate USB device on port %d\n",
4638 port1); 4649 port1);
4639 } 4650 }
4640 4651
4641 done: 4652 done:
4642 hub_port_disable(hub, port1, 1); 4653 hub_port_disable(hub, port1, 1);
4643 if (hcd->driver->relinquish_port && !hub->hdev->parent) 4654 if (hcd->driver->relinquish_port && !hub->hdev->parent)
4644 hcd->driver->relinquish_port(hcd, port1); 4655 hcd->driver->relinquish_port(hcd, port1);
4645 } 4656 }
4646 4657
4647 /* Returns 1 if there was a remote wakeup and a connect status change. */ 4658 /* Returns 1 if there was a remote wakeup and a connect status change. */
4648 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, 4659 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port,
4649 u16 portstatus, u16 portchange) 4660 u16 portstatus, u16 portchange)
4650 { 4661 {
4651 struct usb_device *hdev; 4662 struct usb_device *hdev;
4652 struct usb_device *udev; 4663 struct usb_device *udev;
4653 int connect_change = 0; 4664 int connect_change = 0;
4654 int ret; 4665 int ret;
4655 4666
4656 hdev = hub->hdev; 4667 hdev = hub->hdev;
4657 udev = hub->ports[port - 1]->child; 4668 udev = hub->ports[port - 1]->child;
4658 if (!hub_is_superspeed(hdev)) { 4669 if (!hub_is_superspeed(hdev)) {
4659 if (!(portchange & USB_PORT_STAT_C_SUSPEND)) 4670 if (!(portchange & USB_PORT_STAT_C_SUSPEND))
4660 return 0; 4671 return 0;
4661 usb_clear_port_feature(hdev, port, USB_PORT_FEAT_C_SUSPEND); 4672 usb_clear_port_feature(hdev, port, USB_PORT_FEAT_C_SUSPEND);
4662 } else { 4673 } else {
4663 if (!udev || udev->state != USB_STATE_SUSPENDED || 4674 if (!udev || udev->state != USB_STATE_SUSPENDED ||
4664 (portstatus & USB_PORT_STAT_LINK_STATE) != 4675 (portstatus & USB_PORT_STAT_LINK_STATE) !=
4665 USB_SS_PORT_LS_U0) 4676 USB_SS_PORT_LS_U0)
4666 return 0; 4677 return 0;
4667 } 4678 }
4668 4679
4669 if (udev) { 4680 if (udev) {
4670 /* TRSMRCY = 10 msec */ 4681 /* TRSMRCY = 10 msec */
4671 msleep(10); 4682 msleep(10);
4672 4683
4673 usb_lock_device(udev); 4684 usb_lock_device(udev);
4674 ret = usb_remote_wakeup(udev); 4685 ret = usb_remote_wakeup(udev);
4675 usb_unlock_device(udev); 4686 usb_unlock_device(udev);
4676 if (ret < 0) 4687 if (ret < 0)
4677 connect_change = 1; 4688 connect_change = 1;
4678 } else { 4689 } else {
4679 ret = -ENODEV; 4690 ret = -ENODEV;
4680 hub_port_disable(hub, port, 1); 4691 hub_port_disable(hub, port, 1);
4681 } 4692 }
4682 dev_dbg(hub->intfdev, "resume on port %d, status %d\n", 4693 dev_dbg(hub->intfdev, "resume on port %d, status %d\n",
4683 port, ret); 4694 port, ret);
4684 return connect_change; 4695 return connect_change;
4685 } 4696 }
4686 4697
4687 static void hub_events(void) 4698 static void hub_events(void)
4688 { 4699 {
4689 struct list_head *tmp; 4700 struct list_head *tmp;
4690 struct usb_device *hdev; 4701 struct usb_device *hdev;
4691 struct usb_interface *intf; 4702 struct usb_interface *intf;
4692 struct usb_hub *hub; 4703 struct usb_hub *hub;
4693 struct device *hub_dev; 4704 struct device *hub_dev;
4694 u16 hubstatus; 4705 u16 hubstatus;
4695 u16 hubchange; 4706 u16 hubchange;
4696 u16 portstatus; 4707 u16 portstatus;
4697 u16 portchange; 4708 u16 portchange;
4698 int i, ret; 4709 int i, ret;
4699 int connect_change, wakeup_change; 4710 int connect_change, wakeup_change;
4700 4711
4701 /* 4712 /*
4702 * We restart the list every time to avoid a deadlock with 4713 * We restart the list every time to avoid a deadlock with
4703 * deleting hubs downstream from this one. This should be 4714 * deleting hubs downstream from this one. This should be
4704 * safe since we delete the hub from the event list. 4715 * safe since we delete the hub from the event list.
4705 * Not the most efficient, but avoids deadlocks. 4716 * Not the most efficient, but avoids deadlocks.
4706 */ 4717 */
4707 while (1) { 4718 while (1) {
4708 4719
4709 /* Grab the first entry at the beginning of the list */ 4720 /* Grab the first entry at the beginning of the list */
4710 spin_lock_irq(&hub_event_lock); 4721 spin_lock_irq(&hub_event_lock);
4711 if (list_empty(&hub_event_list)) { 4722 if (list_empty(&hub_event_list)) {
4712 spin_unlock_irq(&hub_event_lock); 4723 spin_unlock_irq(&hub_event_lock);
4713 break; 4724 break;
4714 } 4725 }
4715 4726
4716 tmp = hub_event_list.next; 4727 tmp = hub_event_list.next;
4717 list_del_init(tmp); 4728 list_del_init(tmp);
4718 4729
4719 hub = list_entry(tmp, struct usb_hub, event_list); 4730 hub = list_entry(tmp, struct usb_hub, event_list);
4720 kref_get(&hub->kref); 4731 kref_get(&hub->kref);
4721 spin_unlock_irq(&hub_event_lock); 4732 spin_unlock_irq(&hub_event_lock);
4722 4733
4723 hdev = hub->hdev; 4734 hdev = hub->hdev;
4724 hub_dev = hub->intfdev; 4735 hub_dev = hub->intfdev;
4725 intf = to_usb_interface(hub_dev); 4736 intf = to_usb_interface(hub_dev);
4726 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", 4737 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
4727 hdev->state, hdev->maxchild, 4738 hdev->state, hdev->maxchild,
4728 /* NOTE: expects max 15 ports... */ 4739 /* NOTE: expects max 15 ports... */
4729 (u16) hub->change_bits[0], 4740 (u16) hub->change_bits[0],
4730 (u16) hub->event_bits[0]); 4741 (u16) hub->event_bits[0]);
4731 4742
4732 /* Lock the device, then check to see if we were 4743 /* Lock the device, then check to see if we were
4733 * disconnected while waiting for the lock to succeed. */ 4744 * disconnected while waiting for the lock to succeed. */
4734 usb_lock_device(hdev); 4745 usb_lock_device(hdev);
4735 if (unlikely(hub->disconnected)) 4746 if (unlikely(hub->disconnected))
4736 goto loop_disconnected; 4747 goto loop_disconnected;
4737 4748
4738 /* If the hub has died, clean up after it */ 4749 /* If the hub has died, clean up after it */
4739 if (hdev->state == USB_STATE_NOTATTACHED) { 4750 if (hdev->state == USB_STATE_NOTATTACHED) {
4740 hub->error = -ENODEV; 4751 hub->error = -ENODEV;
4741 hub_quiesce(hub, HUB_DISCONNECT); 4752 hub_quiesce(hub, HUB_DISCONNECT);
4742 goto loop; 4753 goto loop;
4743 } 4754 }
4744 4755
4745 /* Autoresume */ 4756 /* Autoresume */
4746 ret = usb_autopm_get_interface(intf); 4757 ret = usb_autopm_get_interface(intf);
4747 if (ret) { 4758 if (ret) {
4748 dev_dbg(hub_dev, "Can't autoresume: %d\n", ret); 4759 dev_dbg(hub_dev, "Can't autoresume: %d\n", ret);
4749 goto loop; 4760 goto loop;
4750 } 4761 }
4751 4762
4752 /* If this is an inactive hub, do nothing */ 4763 /* If this is an inactive hub, do nothing */
4753 if (hub->quiescing) 4764 if (hub->quiescing)
4754 goto loop_autopm; 4765 goto loop_autopm;
4755 4766
4756 if (hub->error) { 4767 if (hub->error) {
4757 dev_dbg (hub_dev, "resetting for error %d\n", 4768 dev_dbg (hub_dev, "resetting for error %d\n",
4758 hub->error); 4769 hub->error);
4759 4770
4760 ret = usb_reset_device(hdev); 4771 ret = usb_reset_device(hdev);
4761 if (ret) { 4772 if (ret) {
4762 dev_dbg (hub_dev, 4773 dev_dbg (hub_dev,
4763 "error resetting hub: %d\n", ret); 4774 "error resetting hub: %d\n", ret);
4764 goto loop_autopm; 4775 goto loop_autopm;
4765 } 4776 }
4766 4777
4767 hub->nerrors = 0; 4778 hub->nerrors = 0;
4768 hub->error = 0; 4779 hub->error = 0;
4769 } 4780 }
4770 4781
4771 /* deal with port status changes */ 4782 /* deal with port status changes */
4772 for (i = 1; i <= hdev->maxchild; i++) { 4783 for (i = 1; i <= hdev->maxchild; i++) {
4773 struct usb_device *udev = hub->ports[i - 1]->child; 4784 struct usb_device *udev = hub->ports[i - 1]->child;
4774 4785
4775 if (test_bit(i, hub->busy_bits)) 4786 if (test_bit(i, hub->busy_bits))
4776 continue; 4787 continue;
4777 connect_change = test_bit(i, hub->change_bits); 4788 connect_change = test_bit(i, hub->change_bits);
4778 wakeup_change = test_and_clear_bit(i, hub->wakeup_bits); 4789 wakeup_change = test_and_clear_bit(i, hub->wakeup_bits);
4779 if (!test_and_clear_bit(i, hub->event_bits) && 4790 if (!test_and_clear_bit(i, hub->event_bits) &&
4780 !connect_change && !wakeup_change) 4791 !connect_change && !wakeup_change)
4781 continue; 4792 continue;
4782 4793
4783 ret = hub_port_status(hub, i, 4794 ret = hub_port_status(hub, i,
4784 &portstatus, &portchange); 4795 &portstatus, &portchange);
4785 if (ret < 0) 4796 if (ret < 0)
4786 continue; 4797 continue;
4787 4798
4788 if (portchange & USB_PORT_STAT_C_CONNECTION) { 4799 if (portchange & USB_PORT_STAT_C_CONNECTION) {
4789 usb_clear_port_feature(hdev, i, 4800 usb_clear_port_feature(hdev, i,
4790 USB_PORT_FEAT_C_CONNECTION); 4801 USB_PORT_FEAT_C_CONNECTION);
4791 connect_change = 1; 4802 connect_change = 1;
4792 } 4803 }
4793 4804
4794 if (portchange & USB_PORT_STAT_C_ENABLE) { 4805 if (portchange & USB_PORT_STAT_C_ENABLE) {
4795 if (!connect_change) 4806 if (!connect_change)
4796 dev_dbg (hub_dev, 4807 dev_dbg (hub_dev,
4797 "port %d enable change, " 4808 "port %d enable change, "
4798 "status %08x\n", 4809 "status %08x\n",
4799 i, portstatus); 4810 i, portstatus);
4800 usb_clear_port_feature(hdev, i, 4811 usb_clear_port_feature(hdev, i,
4801 USB_PORT_FEAT_C_ENABLE); 4812 USB_PORT_FEAT_C_ENABLE);
4802 4813
4803 /* 4814 /*
4804 * EM interference sometimes causes badly 4815 * EM interference sometimes causes badly
4805 * shielded USB devices to be shutdown by 4816 * shielded USB devices to be shutdown by
4806 * the hub, this hack enables them again. 4817 * the hub, this hack enables them again.
4807 * Works at least with mouse driver. 4818 * Works at least with mouse driver.
4808 */ 4819 */
4809 if (!(portstatus & USB_PORT_STAT_ENABLE) 4820 if (!(portstatus & USB_PORT_STAT_ENABLE)
4810 && !connect_change 4821 && !connect_change
4811 && hub->ports[i - 1]->child) { 4822 && hub->ports[i - 1]->child) {
4812 dev_err (hub_dev, 4823 dev_err (hub_dev,
4813 "port %i " 4824 "port %i "
4814 "disabled by hub (EMI?), " 4825 "disabled by hub (EMI?), "
4815 "re-enabling...\n", 4826 "re-enabling...\n",
4816 i); 4827 i);
4817 connect_change = 1; 4828 connect_change = 1;
4818 } 4829 }
4819 } 4830 }
4820 4831
4821 if (hub_handle_remote_wakeup(hub, i, 4832 if (hub_handle_remote_wakeup(hub, i,
4822 portstatus, portchange)) 4833 portstatus, portchange))
4823 connect_change = 1; 4834 connect_change = 1;
4824 4835
4825 if (portchange & USB_PORT_STAT_C_OVERCURRENT) { 4836 if (portchange & USB_PORT_STAT_C_OVERCURRENT) {
4826 u16 status = 0; 4837 u16 status = 0;
4827 u16 unused; 4838 u16 unused;
4828 4839
4829 dev_dbg(hub_dev, "over-current change on port " 4840 dev_dbg(hub_dev, "over-current change on port "
4830 "%d\n", i); 4841 "%d\n", i);
4831 usb_clear_port_feature(hdev, i, 4842 usb_clear_port_feature(hdev, i,
4832 USB_PORT_FEAT_C_OVER_CURRENT); 4843 USB_PORT_FEAT_C_OVER_CURRENT);
4833 msleep(100); /* Cool down */ 4844 msleep(100); /* Cool down */
4834 hub_power_on(hub, true); 4845 hub_power_on(hub, true);
4835 hub_port_status(hub, i, &status, &unused); 4846 hub_port_status(hub, i, &status, &unused);
4836 if (status & USB_PORT_STAT_OVERCURRENT) 4847 if (status & USB_PORT_STAT_OVERCURRENT)
4837 dev_err(hub_dev, "over-current " 4848 dev_err(hub_dev, "over-current "
4838 "condition on port %d\n", i); 4849 "condition on port %d\n", i);
4839 } 4850 }
4840 4851
4841 if (portchange & USB_PORT_STAT_C_RESET) { 4852 if (portchange & USB_PORT_STAT_C_RESET) {
4842 dev_dbg (hub_dev, 4853 dev_dbg (hub_dev,
4843 "reset change on port %d\n", 4854 "reset change on port %d\n",
4844 i); 4855 i);
4845 usb_clear_port_feature(hdev, i, 4856 usb_clear_port_feature(hdev, i,
4846 USB_PORT_FEAT_C_RESET); 4857 USB_PORT_FEAT_C_RESET);
4847 } 4858 }
4848 if ((portchange & USB_PORT_STAT_C_BH_RESET) && 4859 if ((portchange & USB_PORT_STAT_C_BH_RESET) &&
4849 hub_is_superspeed(hub->hdev)) { 4860 hub_is_superspeed(hub->hdev)) {
4850 dev_dbg(hub_dev, 4861 dev_dbg(hub_dev,
4851 "warm reset change on port %d\n", 4862 "warm reset change on port %d\n",
4852 i); 4863 i);
4853 usb_clear_port_feature(hdev, i, 4864 usb_clear_port_feature(hdev, i,
4854 USB_PORT_FEAT_C_BH_PORT_RESET); 4865 USB_PORT_FEAT_C_BH_PORT_RESET);
4855 } 4866 }
4856 if (portchange & USB_PORT_STAT_C_LINK_STATE) { 4867 if (portchange & USB_PORT_STAT_C_LINK_STATE) {
4857 usb_clear_port_feature(hub->hdev, i, 4868 usb_clear_port_feature(hub->hdev, i,
4858 USB_PORT_FEAT_C_PORT_LINK_STATE); 4869 USB_PORT_FEAT_C_PORT_LINK_STATE);
4859 } 4870 }
4860 if (portchange & USB_PORT_STAT_C_CONFIG_ERROR) { 4871 if (portchange & USB_PORT_STAT_C_CONFIG_ERROR) {
4861 dev_warn(hub_dev, 4872 dev_warn(hub_dev,
4862 "config error on port %d\n", 4873 "config error on port %d\n",
4863 i); 4874 i);
4864 usb_clear_port_feature(hub->hdev, i, 4875 usb_clear_port_feature(hub->hdev, i,
4865 USB_PORT_FEAT_C_PORT_CONFIG_ERROR); 4876 USB_PORT_FEAT_C_PORT_CONFIG_ERROR);
4866 } 4877 }
4867 4878
4868 /* Warm reset a USB3 protocol port if it's in 4879 /* Warm reset a USB3 protocol port if it's in
4869 * SS.Inactive state. 4880 * SS.Inactive state.
4870 */ 4881 */
4871 if (hub_port_warm_reset_required(hub, portstatus)) { 4882 if (hub_port_warm_reset_required(hub, portstatus)) {
4872 int status; 4883 int status;
4873 4884
4874 dev_dbg(hub_dev, "warm reset port %d\n", i); 4885 dev_dbg(hub_dev, "warm reset port %d\n", i);
4875 if (!udev || 4886 if (!udev ||
4876 !(portstatus & USB_PORT_STAT_CONNECTION) || 4887 !(portstatus & USB_PORT_STAT_CONNECTION) ||
4877 udev->state == USB_STATE_NOTATTACHED) { 4888 udev->state == USB_STATE_NOTATTACHED) {
4878 status = hub_port_reset(hub, i, 4889 status = hub_port_reset(hub, i,
4879 NULL, HUB_BH_RESET_TIME, 4890 NULL, HUB_BH_RESET_TIME,
4880 true); 4891 true);
4881 if (status < 0) 4892 if (status < 0)
4882 hub_port_disable(hub, i, 1); 4893 hub_port_disable(hub, i, 1);
4883 } else { 4894 } else {
4884 usb_lock_device(udev); 4895 usb_lock_device(udev);
4885 status = usb_reset_device(udev); 4896 status = usb_reset_device(udev);
4886 usb_unlock_device(udev); 4897 usb_unlock_device(udev);
4887 connect_change = 0; 4898 connect_change = 0;
4888 } 4899 }
4889 /* 4900 /*
4890 * On disconnect USB3 protocol ports transit from U0 to 4901 * On disconnect USB3 protocol ports transit from U0 to
4891 * SS.Inactive to Rx.Detect. If this happens a warm- 4902 * SS.Inactive to Rx.Detect. If this happens a warm-
4892 * reset is not needed, but a (re)connect may happen 4903 * reset is not needed, but a (re)connect may happen
4893 * before khubd runs and sees the disconnect, and the 4904 * before khubd runs and sees the disconnect, and the
4894 * device may be an unknown state. 4905 * device may be an unknown state.
4895 * 4906 *
4896 * If the port went through SS.Inactive without khubd 4907 * If the port went through SS.Inactive without khubd
4897 * seeing it the C_LINK_STATE change flag will be set, 4908 * seeing it the C_LINK_STATE change flag will be set,
4898 * and we reset the dev to put it in a known state. 4909 * and we reset the dev to put it in a known state.
4899 */ 4910 */
4900 } else if (udev && hub_is_superspeed(hub->hdev) && 4911 } else if (udev && hub_is_superspeed(hub->hdev) &&
4901 (portchange & USB_PORT_STAT_C_LINK_STATE) && 4912 (portchange & USB_PORT_STAT_C_LINK_STATE) &&
4902 (portstatus & USB_PORT_STAT_CONNECTION)) { 4913 (portstatus & USB_PORT_STAT_CONNECTION)) {
4903 usb_lock_device(udev); 4914 usb_lock_device(udev);
4904 usb_reset_device(udev); 4915 usb_reset_device(udev);
4905 usb_unlock_device(udev); 4916 usb_unlock_device(udev);
4906 connect_change = 0; 4917 connect_change = 0;
4907 } 4918 }
4908 4919
4909 if (connect_change) 4920 if (connect_change)
4910 hub_port_connect_change(hub, i, 4921 hub_port_connect_change(hub, i,
4911 portstatus, portchange); 4922 portstatus, portchange);
4912 } /* end for i */ 4923 } /* end for i */
4913 4924
4914 /* deal with hub status changes */ 4925 /* deal with hub status changes */
4915 if (test_and_clear_bit(0, hub->event_bits) == 0) 4926 if (test_and_clear_bit(0, hub->event_bits) == 0)
4916 ; /* do nothing */ 4927 ; /* do nothing */
4917 else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0) 4928 else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0)
4918 dev_err (hub_dev, "get_hub_status failed\n"); 4929 dev_err (hub_dev, "get_hub_status failed\n");
4919 else { 4930 else {
4920 if (hubchange & HUB_CHANGE_LOCAL_POWER) { 4931 if (hubchange & HUB_CHANGE_LOCAL_POWER) {
4921 dev_dbg (hub_dev, "power change\n"); 4932 dev_dbg (hub_dev, "power change\n");
4922 clear_hub_feature(hdev, C_HUB_LOCAL_POWER); 4933 clear_hub_feature(hdev, C_HUB_LOCAL_POWER);
4923 if (hubstatus & HUB_STATUS_LOCAL_POWER) 4934 if (hubstatus & HUB_STATUS_LOCAL_POWER)
4924 /* FIXME: Is this always true? */ 4935 /* FIXME: Is this always true? */
4925 hub->limited_power = 1; 4936 hub->limited_power = 1;
4926 else 4937 else
4927 hub->limited_power = 0; 4938 hub->limited_power = 0;
4928 } 4939 }
4929 if (hubchange & HUB_CHANGE_OVERCURRENT) { 4940 if (hubchange & HUB_CHANGE_OVERCURRENT) {
4930 u16 status = 0; 4941 u16 status = 0;
4931 u16 unused; 4942 u16 unused;
4932 4943
4933 dev_dbg(hub_dev, "over-current change\n"); 4944 dev_dbg(hub_dev, "over-current change\n");
4934 clear_hub_feature(hdev, C_HUB_OVER_CURRENT); 4945 clear_hub_feature(hdev, C_HUB_OVER_CURRENT);
4935 msleep(500); /* Cool down */ 4946 msleep(500); /* Cool down */
4936 hub_power_on(hub, true); 4947 hub_power_on(hub, true);
4937 hub_hub_status(hub, &status, &unused); 4948 hub_hub_status(hub, &status, &unused);
4938 if (status & HUB_STATUS_OVERCURRENT) 4949 if (status & HUB_STATUS_OVERCURRENT)
4939 dev_err(hub_dev, "over-current " 4950 dev_err(hub_dev, "over-current "
4940 "condition\n"); 4951 "condition\n");
4941 } 4952 }
4942 } 4953 }
4943 4954
4944 loop_autopm: 4955 loop_autopm:
4945 /* Balance the usb_autopm_get_interface() above */ 4956 /* Balance the usb_autopm_get_interface() above */
4946 usb_autopm_put_interface_no_suspend(intf); 4957 usb_autopm_put_interface_no_suspend(intf);
4947 loop: 4958 loop:
4948 /* Balance the usb_autopm_get_interface_no_resume() in 4959 /* Balance the usb_autopm_get_interface_no_resume() in
4949 * kick_khubd() and allow autosuspend. 4960 * kick_khubd() and allow autosuspend.
4950 */ 4961 */
4951 usb_autopm_put_interface(intf); 4962 usb_autopm_put_interface(intf);
4952 loop_disconnected: 4963 loop_disconnected:
4953 usb_unlock_device(hdev); 4964 usb_unlock_device(hdev);
4954 kref_put(&hub->kref, hub_release); 4965 kref_put(&hub->kref, hub_release);
4955 4966
4956 } /* end while (1) */ 4967 } /* end while (1) */
4957 } 4968 }
4958 4969
4959 static int hub_thread(void *__unused) 4970 static int hub_thread(void *__unused)
4960 { 4971 {
4961 /* khubd needs to be freezable to avoid interfering with USB-PERSIST 4972 /* khubd needs to be freezable to avoid interfering with USB-PERSIST
4962 * port handover. Otherwise it might see that a full-speed device 4973 * port handover. Otherwise it might see that a full-speed device
4963 * was gone before the EHCI controller had handed its port over to 4974 * was gone before the EHCI controller had handed its port over to
4964 * the companion full-speed controller. 4975 * the companion full-speed controller.
4965 */ 4976 */
4966 set_freezable(); 4977 set_freezable();
4967 4978
4968 do { 4979 do {
4969 hub_events(); 4980 hub_events();
4970 wait_event_freezable(khubd_wait, 4981 wait_event_freezable(khubd_wait,
4971 !list_empty(&hub_event_list) || 4982 !list_empty(&hub_event_list) ||
4972 kthread_should_stop()); 4983 kthread_should_stop());
4973 } while (!kthread_should_stop() || !list_empty(&hub_event_list)); 4984 } while (!kthread_should_stop() || !list_empty(&hub_event_list));
4974 4985
4975 pr_debug("%s: khubd exiting\n", usbcore_name); 4986 pr_debug("%s: khubd exiting\n", usbcore_name);
4976 return 0; 4987 return 0;
4977 } 4988 }
4978 4989
4979 static const struct usb_device_id hub_id_table[] = { 4990 static const struct usb_device_id hub_id_table[] = {
4980 { .match_flags = USB_DEVICE_ID_MATCH_VENDOR 4991 { .match_flags = USB_DEVICE_ID_MATCH_VENDOR
4981 | USB_DEVICE_ID_MATCH_INT_CLASS, 4992 | USB_DEVICE_ID_MATCH_INT_CLASS,
4982 .idVendor = USB_VENDOR_GENESYS_LOGIC, 4993 .idVendor = USB_VENDOR_GENESYS_LOGIC,
4983 .bInterfaceClass = USB_CLASS_HUB, 4994 .bInterfaceClass = USB_CLASS_HUB,
4984 .driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND}, 4995 .driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND},
4985 { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, 4996 { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS,
4986 .bDeviceClass = USB_CLASS_HUB}, 4997 .bDeviceClass = USB_CLASS_HUB},
4987 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, 4998 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
4988 .bInterfaceClass = USB_CLASS_HUB}, 4999 .bInterfaceClass = USB_CLASS_HUB},
4989 { } /* Terminating entry */ 5000 { } /* Terminating entry */
4990 }; 5001 };
4991 5002
4992 MODULE_DEVICE_TABLE (usb, hub_id_table); 5003 MODULE_DEVICE_TABLE (usb, hub_id_table);
4993 5004
4994 static struct usb_driver hub_driver = { 5005 static struct usb_driver hub_driver = {
4995 .name = "hub", 5006 .name = "hub",
4996 .probe = hub_probe, 5007 .probe = hub_probe,
4997 .disconnect = hub_disconnect, 5008 .disconnect = hub_disconnect,
4998 .suspend = hub_suspend, 5009 .suspend = hub_suspend,
4999 .resume = hub_resume, 5010 .resume = hub_resume,
5000 .reset_resume = hub_reset_resume, 5011 .reset_resume = hub_reset_resume,
5001 .pre_reset = hub_pre_reset, 5012 .pre_reset = hub_pre_reset,
5002 .post_reset = hub_post_reset, 5013 .post_reset = hub_post_reset,
5003 .unlocked_ioctl = hub_ioctl, 5014 .unlocked_ioctl = hub_ioctl,
5004 .id_table = hub_id_table, 5015 .id_table = hub_id_table,
5005 .supports_autosuspend = 1, 5016 .supports_autosuspend = 1,
5006 }; 5017 };
5007 5018
5008 int usb_hub_init(void) 5019 int usb_hub_init(void)
5009 { 5020 {
5010 if (usb_register(&hub_driver) < 0) { 5021 if (usb_register(&hub_driver) < 0) {
5011 printk(KERN_ERR "%s: can't register hub driver\n", 5022 printk(KERN_ERR "%s: can't register hub driver\n",
5012 usbcore_name); 5023 usbcore_name);
5013 return -1; 5024 return -1;
5014 } 5025 }
5015 5026
5016 khubd_task = kthread_run(hub_thread, NULL, "khubd"); 5027 khubd_task = kthread_run(hub_thread, NULL, "khubd");
5017 if (!IS_ERR(khubd_task)) 5028 if (!IS_ERR(khubd_task))
5018 return 0; 5029 return 0;
5019 5030
5020 /* Fall through if kernel_thread failed */ 5031 /* Fall through if kernel_thread failed */
5021 usb_deregister(&hub_driver); 5032 usb_deregister(&hub_driver);
5022 printk(KERN_ERR "%s: can't start khubd\n", usbcore_name); 5033 printk(KERN_ERR "%s: can't start khubd\n", usbcore_name);
5023 5034
5024 return -1; 5035 return -1;
5025 } 5036 }
5026 5037
5027 void usb_hub_cleanup(void) 5038 void usb_hub_cleanup(void)
5028 { 5039 {
5029 kthread_stop(khubd_task); 5040 kthread_stop(khubd_task);
5030 5041
5031 /* 5042 /*
5032 * Hub resources are freed for us by usb_deregister. It calls 5043 * Hub resources are freed for us by usb_deregister. It calls
5033 * usb_driver_purge on every device which in turn calls that 5044 * usb_driver_purge on every device which in turn calls that
5034 * devices disconnect function if it is using this driver. 5045 * devices disconnect function if it is using this driver.
5035 * The hub_disconnect function takes care of releasing the 5046 * The hub_disconnect function takes care of releasing the
5036 * individual hub resources. -greg 5047 * individual hub resources. -greg
5037 */ 5048 */
5038 usb_deregister(&hub_driver); 5049 usb_deregister(&hub_driver);
5039 } /* usb_hub_cleanup() */ 5050 } /* usb_hub_cleanup() */
5040 5051
5041 static int descriptors_changed(struct usb_device *udev, 5052 static int descriptors_changed(struct usb_device *udev,
5042 struct usb_device_descriptor *old_device_descriptor, 5053 struct usb_device_descriptor *old_device_descriptor,
5043 struct usb_host_bos *old_bos) 5054 struct usb_host_bos *old_bos)
5044 { 5055 {
5045 int changed = 0; 5056 int changed = 0;
5046 unsigned index; 5057 unsigned index;
5047 unsigned serial_len = 0; 5058 unsigned serial_len = 0;
5048 unsigned len; 5059 unsigned len;
5049 unsigned old_length; 5060 unsigned old_length;
5050 int length; 5061 int length;
5051 char *buf; 5062 char *buf;
5052 5063
5053 if (memcmp(&udev->descriptor, old_device_descriptor, 5064 if (memcmp(&udev->descriptor, old_device_descriptor,
5054 sizeof(*old_device_descriptor)) != 0) 5065 sizeof(*old_device_descriptor)) != 0)
5055 return 1; 5066 return 1;
5056 5067
5057 if ((old_bos && !udev->bos) || (!old_bos && udev->bos)) 5068 if ((old_bos && !udev->bos) || (!old_bos && udev->bos))
5058 return 1; 5069 return 1;
5059 if (udev->bos) { 5070 if (udev->bos) {
5060 len = le16_to_cpu(udev->bos->desc->wTotalLength); 5071 len = le16_to_cpu(udev->bos->desc->wTotalLength);
5061 if (len != le16_to_cpu(old_bos->desc->wTotalLength)) 5072 if (len != le16_to_cpu(old_bos->desc->wTotalLength))
5062 return 1; 5073 return 1;
5063 if (memcmp(udev->bos->desc, old_bos->desc, len)) 5074 if (memcmp(udev->bos->desc, old_bos->desc, len))
5064 return 1; 5075 return 1;
5065 } 5076 }
5066 5077
5067 /* Since the idVendor, idProduct, and bcdDevice values in the 5078 /* Since the idVendor, idProduct, and bcdDevice values in the
5068 * device descriptor haven't changed, we will assume the 5079 * device descriptor haven't changed, we will assume the
5069 * Manufacturer and Product strings haven't changed either. 5080 * Manufacturer and Product strings haven't changed either.
5070 * But the SerialNumber string could be different (e.g., a 5081 * But the SerialNumber string could be different (e.g., a
5071 * different flash card of the same brand). 5082 * different flash card of the same brand).
5072 */ 5083 */
5073 if (udev->serial) 5084 if (udev->serial)
5074 serial_len = strlen(udev->serial) + 1; 5085 serial_len = strlen(udev->serial) + 1;
5075 5086
5076 len = serial_len; 5087 len = serial_len;
5077 for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { 5088 for (index = 0; index < udev->descriptor.bNumConfigurations; index++) {
5078 old_length = le16_to_cpu(udev->config[index].desc.wTotalLength); 5089 old_length = le16_to_cpu(udev->config[index].desc.wTotalLength);
5079 len = max(len, old_length); 5090 len = max(len, old_length);
5080 } 5091 }
5081 5092
5082 buf = kmalloc(len, GFP_NOIO); 5093 buf = kmalloc(len, GFP_NOIO);
5083 if (buf == NULL) { 5094 if (buf == NULL) {
5084 dev_err(&udev->dev, "no mem to re-read configs after reset\n"); 5095 dev_err(&udev->dev, "no mem to re-read configs after reset\n");
5085 /* assume the worst */ 5096 /* assume the worst */
5086 return 1; 5097 return 1;
5087 } 5098 }
5088 for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { 5099 for (index = 0; index < udev->descriptor.bNumConfigurations; index++) {
5089 old_length = le16_to_cpu(udev->config[index].desc.wTotalLength); 5100 old_length = le16_to_cpu(udev->config[index].desc.wTotalLength);
5090 length = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf, 5101 length = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf,
5091 old_length); 5102 old_length);
5092 if (length != old_length) { 5103 if (length != old_length) {
5093 dev_dbg(&udev->dev, "config index %d, error %d\n", 5104 dev_dbg(&udev->dev, "config index %d, error %d\n",
5094 index, length); 5105 index, length);
5095 changed = 1; 5106 changed = 1;
5096 break; 5107 break;
5097 } 5108 }
5098 if (memcmp (buf, udev->rawdescriptors[index], old_length) 5109 if (memcmp (buf, udev->rawdescriptors[index], old_length)
5099 != 0) { 5110 != 0) {
5100 dev_dbg(&udev->dev, "config index %d changed (#%d)\n", 5111 dev_dbg(&udev->dev, "config index %d changed (#%d)\n",
5101 index, 5112 index,
5102 ((struct usb_config_descriptor *) buf)-> 5113 ((struct usb_config_descriptor *) buf)->
5103 bConfigurationValue); 5114 bConfigurationValue);
5104 changed = 1; 5115 changed = 1;
5105 break; 5116 break;
5106 } 5117 }
5107 } 5118 }
5108 5119
5109 if (!changed && serial_len) { 5120 if (!changed && serial_len) {
5110 length = usb_string(udev, udev->descriptor.iSerialNumber, 5121 length = usb_string(udev, udev->descriptor.iSerialNumber,
5111 buf, serial_len); 5122 buf, serial_len);
5112 if (length + 1 != serial_len) { 5123 if (length + 1 != serial_len) {
5113 dev_dbg(&udev->dev, "serial string error %d\n", 5124 dev_dbg(&udev->dev, "serial string error %d\n",
5114 length); 5125 length);
5115 changed = 1; 5126 changed = 1;
5116 } else if (memcmp(buf, udev->serial, length) != 0) { 5127 } else if (memcmp(buf, udev->serial, length) != 0) {
5117 dev_dbg(&udev->dev, "serial string changed\n"); 5128 dev_dbg(&udev->dev, "serial string changed\n");
5118 changed = 1; 5129 changed = 1;
5119 } 5130 }
5120 } 5131 }
5121 5132
5122 kfree(buf); 5133 kfree(buf);
5123 return changed; 5134 return changed;
5124 } 5135 }
5125 5136
5126 /** 5137 /**
5127 * usb_reset_and_verify_device - perform a USB port reset to reinitialize a device 5138 * usb_reset_and_verify_device - perform a USB port reset to reinitialize a device
5128 * @udev: device to reset (not in SUSPENDED or NOTATTACHED state) 5139 * @udev: device to reset (not in SUSPENDED or NOTATTACHED state)
5129 * 5140 *
5130 * WARNING - don't use this routine to reset a composite device 5141 * WARNING - don't use this routine to reset a composite device
5131 * (one with multiple interfaces owned by separate drivers)! 5142 * (one with multiple interfaces owned by separate drivers)!
5132 * Use usb_reset_device() instead. 5143 * Use usb_reset_device() instead.
5133 * 5144 *
5134 * Do a port reset, reassign the device's address, and establish its 5145 * Do a port reset, reassign the device's address, and establish its
5135 * former operating configuration. If the reset fails, or the device's 5146 * former operating configuration. If the reset fails, or the device's
5136 * descriptors change from their values before the reset, or the original 5147 * descriptors change from their values before the reset, or the original
5137 * configuration and altsettings cannot be restored, a flag will be set 5148 * configuration and altsettings cannot be restored, a flag will be set
5138 * telling khubd to pretend the device has been disconnected and then 5149 * telling khubd to pretend the device has been disconnected and then
5139 * re-connected. All drivers will be unbound, and the device will be 5150 * re-connected. All drivers will be unbound, and the device will be
5140 * re-enumerated and probed all over again. 5151 * re-enumerated and probed all over again.
5141 * 5152 *
5142 * Return: 0 if the reset succeeded, -ENODEV if the device has been 5153 * Return: 0 if the reset succeeded, -ENODEV if the device has been
5143 * flagged for logical disconnection, or some other negative error code 5154 * flagged for logical disconnection, or some other negative error code
5144 * if the reset wasn't even attempted. 5155 * if the reset wasn't even attempted.
5145 * 5156 *
5146 * Note: 5157 * Note:
5147 * The caller must own the device lock. For example, it's safe to use 5158 * The caller must own the device lock. For example, it's safe to use
5148 * this from a driver probe() routine after downloading new firmware. 5159 * this from a driver probe() routine after downloading new firmware.
5149 * For calls that might not occur during probe(), drivers should lock 5160 * For calls that might not occur during probe(), drivers should lock
5150 * the device using usb_lock_device_for_reset(). 5161 * the device using usb_lock_device_for_reset().
5151 * 5162 *
5152 * Locking exception: This routine may also be called from within an 5163 * Locking exception: This routine may also be called from within an
5153 * autoresume handler. Such usage won't conflict with other tasks 5164 * autoresume handler. Such usage won't conflict with other tasks
5154 * holding the device lock because these tasks should always call 5165 * holding the device lock because these tasks should always call
5155 * usb_autopm_resume_device(), thereby preventing any unwanted autoresume. 5166 * usb_autopm_resume_device(), thereby preventing any unwanted autoresume.
5156 */ 5167 */
5157 static int usb_reset_and_verify_device(struct usb_device *udev) 5168 static int usb_reset_and_verify_device(struct usb_device *udev)
5158 { 5169 {
5159 struct usb_device *parent_hdev = udev->parent; 5170 struct usb_device *parent_hdev = udev->parent;
5160 struct usb_hub *parent_hub; 5171 struct usb_hub *parent_hub;
5161 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 5172 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
5162 struct usb_device_descriptor descriptor = udev->descriptor; 5173 struct usb_device_descriptor descriptor = udev->descriptor;
5163 struct usb_host_bos *bos; 5174 struct usb_host_bos *bos;
5164 int i, j, ret = 0; 5175 int i, j, ret = 0;
5165 int port1 = udev->portnum; 5176 int port1 = udev->portnum;
5166 5177
5167 if (udev->state == USB_STATE_NOTATTACHED || 5178 if (udev->state == USB_STATE_NOTATTACHED ||
5168 udev->state == USB_STATE_SUSPENDED) { 5179 udev->state == USB_STATE_SUSPENDED) {
5169 dev_dbg(&udev->dev, "device reset not allowed in state %d\n", 5180 dev_dbg(&udev->dev, "device reset not allowed in state %d\n",
5170 udev->state); 5181 udev->state);
5171 return -EINVAL; 5182 return -EINVAL;
5172 } 5183 }
5173 5184
5174 if (!parent_hdev) { 5185 if (!parent_hdev) {
5175 /* this requires hcd-specific logic; see ohci_restart() */ 5186 /* this requires hcd-specific logic; see ohci_restart() */
5176 dev_dbg(&udev->dev, "%s for root hub!\n", __func__); 5187 dev_dbg(&udev->dev, "%s for root hub!\n", __func__);
5177 return -EISDIR; 5188 return -EISDIR;
5178 } 5189 }
5179 parent_hub = usb_hub_to_struct_hub(parent_hdev); 5190 parent_hub = usb_hub_to_struct_hub(parent_hdev);
5180 5191
5181 /* Disable USB2 hardware LPM. 5192 /* Disable USB2 hardware LPM.
5182 * It will be re-enabled by the enumeration process. 5193 * It will be re-enabled by the enumeration process.
5183 */ 5194 */
5184 if (udev->usb2_hw_lpm_enabled == 1) 5195 if (udev->usb2_hw_lpm_enabled == 1)
5185 usb_set_usb2_hardware_lpm(udev, 0); 5196 usb_set_usb2_hardware_lpm(udev, 0);
5186 5197
5187 bos = udev->bos; 5198 bos = udev->bos;
5188 udev->bos = NULL; 5199 udev->bos = NULL;
5189 5200
5190 /* Disable LPM and LTM while we reset the device and reinstall the alt 5201 /* Disable LPM and LTM while we reset the device and reinstall the alt
5191 * settings. Device-initiated LPM settings, and system exit latency 5202 * settings. Device-initiated LPM settings, and system exit latency
5192 * settings are cleared when the device is reset, so we have to set 5203 * settings are cleared when the device is reset, so we have to set
5193 * them up again. 5204 * them up again.
5194 */ 5205 */
5195 ret = usb_unlocked_disable_lpm(udev); 5206 ret = usb_unlocked_disable_lpm(udev);
5196 if (ret) { 5207 if (ret) {
5197 dev_err(&udev->dev, "%s Failed to disable LPM\n.", __func__); 5208 dev_err(&udev->dev, "%s Failed to disable LPM\n.", __func__);
5198 goto re_enumerate; 5209 goto re_enumerate;
5199 } 5210 }
5200 ret = usb_disable_ltm(udev); 5211 ret = usb_disable_ltm(udev);
5201 if (ret) { 5212 if (ret) {
5202 dev_err(&udev->dev, "%s Failed to disable LTM\n.", 5213 dev_err(&udev->dev, "%s Failed to disable LTM\n.",
5203 __func__); 5214 __func__);
5204 goto re_enumerate; 5215 goto re_enumerate;
5205 } 5216 }
5206 5217
5207 set_bit(port1, parent_hub->busy_bits); 5218 set_bit(port1, parent_hub->busy_bits);
5208 for (i = 0; i < SET_CONFIG_TRIES; ++i) { 5219 for (i = 0; i < SET_CONFIG_TRIES; ++i) {
5209 5220
5210 /* ep0 maxpacket size may change; let the HCD know about it. 5221 /* ep0 maxpacket size may change; let the HCD know about it.
5211 * Other endpoints will be handled by re-enumeration. */ 5222 * Other endpoints will be handled by re-enumeration. */
5212 usb_ep0_reinit(udev); 5223 usb_ep0_reinit(udev);
5213 ret = hub_port_init(parent_hub, udev, port1, i); 5224 ret = hub_port_init(parent_hub, udev, port1, i);
5214 if (ret >= 0 || ret == -ENOTCONN || ret == -ENODEV) 5225 if (ret >= 0 || ret == -ENOTCONN || ret == -ENODEV)
5215 break; 5226 break;
5216 } 5227 }
5217 clear_bit(port1, parent_hub->busy_bits); 5228 clear_bit(port1, parent_hub->busy_bits);
5218 5229
5219 if (ret < 0) 5230 if (ret < 0)
5220 goto re_enumerate; 5231 goto re_enumerate;
5221 5232
5222 /* Device might have changed firmware (DFU or similar) */ 5233 /* Device might have changed firmware (DFU or similar) */
5223 if (descriptors_changed(udev, &descriptor, bos)) { 5234 if (descriptors_changed(udev, &descriptor, bos)) {
5224 dev_info(&udev->dev, "device firmware changed\n"); 5235 dev_info(&udev->dev, "device firmware changed\n");
5225 udev->descriptor = descriptor; /* for disconnect() calls */ 5236 udev->descriptor = descriptor; /* for disconnect() calls */
5226 goto re_enumerate; 5237 goto re_enumerate;
5227 } 5238 }
5228 5239
5229 /* Restore the device's previous configuration */ 5240 /* Restore the device's previous configuration */
5230 if (!udev->actconfig) 5241 if (!udev->actconfig)
5231 goto done; 5242 goto done;
5232 5243
5233 mutex_lock(hcd->bandwidth_mutex); 5244 mutex_lock(hcd->bandwidth_mutex);
5234 ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL); 5245 ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL);
5235 if (ret < 0) { 5246 if (ret < 0) {
5236 dev_warn(&udev->dev, 5247 dev_warn(&udev->dev,
5237 "Busted HC? Not enough HCD resources for " 5248 "Busted HC? Not enough HCD resources for "
5238 "old configuration.\n"); 5249 "old configuration.\n");
5239 mutex_unlock(hcd->bandwidth_mutex); 5250 mutex_unlock(hcd->bandwidth_mutex);
5240 goto re_enumerate; 5251 goto re_enumerate;
5241 } 5252 }
5242 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 5253 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
5243 USB_REQ_SET_CONFIGURATION, 0, 5254 USB_REQ_SET_CONFIGURATION, 0,
5244 udev->actconfig->desc.bConfigurationValue, 0, 5255 udev->actconfig->desc.bConfigurationValue, 0,
5245 NULL, 0, USB_CTRL_SET_TIMEOUT); 5256 NULL, 0, USB_CTRL_SET_TIMEOUT);
5246 if (ret < 0) { 5257 if (ret < 0) {
5247 dev_err(&udev->dev, 5258 dev_err(&udev->dev,
5248 "can't restore configuration #%d (error=%d)\n", 5259 "can't restore configuration #%d (error=%d)\n",
5249 udev->actconfig->desc.bConfigurationValue, ret); 5260 udev->actconfig->desc.bConfigurationValue, ret);
5250 mutex_unlock(hcd->bandwidth_mutex); 5261 mutex_unlock(hcd->bandwidth_mutex);
5251 goto re_enumerate; 5262 goto re_enumerate;
5252 } 5263 }
5253 mutex_unlock(hcd->bandwidth_mutex); 5264 mutex_unlock(hcd->bandwidth_mutex);
5254 usb_set_device_state(udev, USB_STATE_CONFIGURED); 5265 usb_set_device_state(udev, USB_STATE_CONFIGURED);
5255 5266
5256 /* Put interfaces back into the same altsettings as before. 5267 /* Put interfaces back into the same altsettings as before.
5257 * Don't bother to send the Set-Interface request for interfaces 5268 * Don't bother to send the Set-Interface request for interfaces
5258 * that were already in altsetting 0; besides being unnecessary, 5269 * that were already in altsetting 0; besides being unnecessary,
5259 * many devices can't handle it. Instead just reset the host-side 5270 * many devices can't handle it. Instead just reset the host-side
5260 * endpoint state. 5271 * endpoint state.
5261 */ 5272 */
5262 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 5273 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
5263 struct usb_host_config *config = udev->actconfig; 5274 struct usb_host_config *config = udev->actconfig;
5264 struct usb_interface *intf = config->interface[i]; 5275 struct usb_interface *intf = config->interface[i];
5265 struct usb_interface_descriptor *desc; 5276 struct usb_interface_descriptor *desc;
5266 5277
5267 desc = &intf->cur_altsetting->desc; 5278 desc = &intf->cur_altsetting->desc;
5268 if (desc->bAlternateSetting == 0) { 5279 if (desc->bAlternateSetting == 0) {
5269 usb_disable_interface(udev, intf, true); 5280 usb_disable_interface(udev, intf, true);
5270 usb_enable_interface(udev, intf, true); 5281 usb_enable_interface(udev, intf, true);
5271 ret = 0; 5282 ret = 0;
5272 } else { 5283 } else {
5273 /* Let the bandwidth allocation function know that this 5284 /* Let the bandwidth allocation function know that this
5274 * device has been reset, and it will have to use 5285 * device has been reset, and it will have to use
5275 * alternate setting 0 as the current alternate setting. 5286 * alternate setting 0 as the current alternate setting.
5276 */ 5287 */
5277 intf->resetting_device = 1; 5288 intf->resetting_device = 1;
5278 ret = usb_set_interface(udev, desc->bInterfaceNumber, 5289 ret = usb_set_interface(udev, desc->bInterfaceNumber,
5279 desc->bAlternateSetting); 5290 desc->bAlternateSetting);
5280 intf->resetting_device = 0; 5291 intf->resetting_device = 0;
5281 } 5292 }
5282 if (ret < 0) { 5293 if (ret < 0) {
5283 dev_err(&udev->dev, "failed to restore interface %d " 5294 dev_err(&udev->dev, "failed to restore interface %d "
5284 "altsetting %d (error=%d)\n", 5295 "altsetting %d (error=%d)\n",
5285 desc->bInterfaceNumber, 5296 desc->bInterfaceNumber,
5286 desc->bAlternateSetting, 5297 desc->bAlternateSetting,
5287 ret); 5298 ret);
5288 goto re_enumerate; 5299 goto re_enumerate;
5289 } 5300 }
5290 /* Resetting also frees any allocated streams */ 5301 /* Resetting also frees any allocated streams */
5291 for (j = 0; j < intf->cur_altsetting->desc.bNumEndpoints; j++) 5302 for (j = 0; j < intf->cur_altsetting->desc.bNumEndpoints; j++)
5292 intf->cur_altsetting->endpoint[j].streams = 0; 5303 intf->cur_altsetting->endpoint[j].streams = 0;
5293 } 5304 }
5294 5305
5295 done: 5306 done:
5296 /* Now that the alt settings are re-installed, enable LTM and LPM. */ 5307 /* Now that the alt settings are re-installed, enable LTM and LPM. */
5297 usb_set_usb2_hardware_lpm(udev, 1); 5308 usb_set_usb2_hardware_lpm(udev, 1);
5298 usb_unlocked_enable_lpm(udev); 5309 usb_unlocked_enable_lpm(udev);
5299 usb_enable_ltm(udev); 5310 usb_enable_ltm(udev);
5300 usb_release_bos_descriptor(udev); 5311 usb_release_bos_descriptor(udev);
5301 udev->bos = bos; 5312 udev->bos = bos;
5302 return 0; 5313 return 0;
5303 5314
5304 re_enumerate: 5315 re_enumerate:
5305 /* LPM state doesn't matter when we're about to destroy the device. */ 5316 /* LPM state doesn't matter when we're about to destroy the device. */
5306 hub_port_logical_disconnect(parent_hub, port1); 5317 hub_port_logical_disconnect(parent_hub, port1);
5307 usb_release_bos_descriptor(udev); 5318 usb_release_bos_descriptor(udev);
5308 udev->bos = bos; 5319 udev->bos = bos;
5309 return -ENODEV; 5320 return -ENODEV;
5310 } 5321 }
5311 5322
5312 /** 5323 /**
5313 * usb_reset_device - warn interface drivers and perform a USB port reset 5324 * usb_reset_device - warn interface drivers and perform a USB port reset
5314 * @udev: device to reset (not in SUSPENDED or NOTATTACHED state) 5325 * @udev: device to reset (not in SUSPENDED or NOTATTACHED state)
5315 * 5326 *
5316 * Warns all drivers bound to registered interfaces (using their pre_reset 5327 * Warns all drivers bound to registered interfaces (using their pre_reset
5317 * method), performs the port reset, and then lets the drivers know that 5328 * method), performs the port reset, and then lets the drivers know that
5318 * the reset is over (using their post_reset method). 5329 * the reset is over (using their post_reset method).
5319 * 5330 *
5320 * Return: The same as for usb_reset_and_verify_device(). 5331 * Return: The same as for usb_reset_and_verify_device().
5321 * 5332 *
5322 * Note: 5333 * Note:
5323 * The caller must own the device lock. For example, it's safe to use 5334 * The caller must own the device lock. For example, it's safe to use
5324 * this from a driver probe() routine after downloading new firmware. 5335 * this from a driver probe() routine after downloading new firmware.
5325 * For calls that might not occur during probe(), drivers should lock 5336 * For calls that might not occur during probe(), drivers should lock
5326 * the device using usb_lock_device_for_reset(). 5337 * the device using usb_lock_device_for_reset().
5327 * 5338 *
5328 * If an interface is currently being probed or disconnected, we assume 5339 * If an interface is currently being probed or disconnected, we assume
5329 * its driver knows how to handle resets. For all other interfaces, 5340 * its driver knows how to handle resets. For all other interfaces,
5330 * if the driver doesn't have pre_reset and post_reset methods then 5341 * if the driver doesn't have pre_reset and post_reset methods then
5331 * we attempt to unbind it and rebind afterward. 5342 * we attempt to unbind it and rebind afterward.
5332 */ 5343 */
5333 int usb_reset_device(struct usb_device *udev) 5344 int usb_reset_device(struct usb_device *udev)
5334 { 5345 {
5335 int ret; 5346 int ret;
5336 int i; 5347 int i;
5337 unsigned int noio_flag; 5348 unsigned int noio_flag;
5338 struct usb_host_config *config = udev->actconfig; 5349 struct usb_host_config *config = udev->actconfig;
5339 5350
5340 if (udev->state == USB_STATE_NOTATTACHED || 5351 if (udev->state == USB_STATE_NOTATTACHED ||
5341 udev->state == USB_STATE_SUSPENDED) { 5352 udev->state == USB_STATE_SUSPENDED) {
5342 dev_dbg(&udev->dev, "device reset not allowed in state %d\n", 5353 dev_dbg(&udev->dev, "device reset not allowed in state %d\n",
5343 udev->state); 5354 udev->state);
5344 return -EINVAL; 5355 return -EINVAL;
5345 } 5356 }
5346 5357
5347 /* 5358 /*
5348 * Don't allocate memory with GFP_KERNEL in current 5359 * Don't allocate memory with GFP_KERNEL in current
5349 * context to avoid possible deadlock if usb mass 5360 * context to avoid possible deadlock if usb mass
5350 * storage interface or usbnet interface(iSCSI case) 5361 * storage interface or usbnet interface(iSCSI case)
5351 * is included in current configuration. The easist 5362 * is included in current configuration. The easist
5352 * approach is to do it for every device reset, 5363 * approach is to do it for every device reset,
5353 * because the device 'memalloc_noio' flag may have 5364 * because the device 'memalloc_noio' flag may have
5354 * not been set before reseting the usb device. 5365 * not been set before reseting the usb device.
5355 */ 5366 */
5356 noio_flag = memalloc_noio_save(); 5367 noio_flag = memalloc_noio_save();
5357 5368
5358 /* Prevent autosuspend during the reset */ 5369 /* Prevent autosuspend during the reset */
5359 usb_autoresume_device(udev); 5370 usb_autoresume_device(udev);
5360 5371
5361 if (config) { 5372 if (config) {
5362 for (i = 0; i < config->desc.bNumInterfaces; ++i) { 5373 for (i = 0; i < config->desc.bNumInterfaces; ++i) {
5363 struct usb_interface *cintf = config->interface[i]; 5374 struct usb_interface *cintf = config->interface[i];
5364 struct usb_driver *drv; 5375 struct usb_driver *drv;
5365 int unbind = 0; 5376 int unbind = 0;
5366 5377
5367 if (cintf->dev.driver) { 5378 if (cintf->dev.driver) {
5368 drv = to_usb_driver(cintf->dev.driver); 5379 drv = to_usb_driver(cintf->dev.driver);
5369 if (drv->pre_reset && drv->post_reset) 5380 if (drv->pre_reset && drv->post_reset)
5370 unbind = (drv->pre_reset)(cintf); 5381 unbind = (drv->pre_reset)(cintf);
5371 else if (cintf->condition == 5382 else if (cintf->condition ==
5372 USB_INTERFACE_BOUND) 5383 USB_INTERFACE_BOUND)
5373 unbind = 1; 5384 unbind = 1;
5374 if (unbind) 5385 if (unbind)
5375 usb_forced_unbind_intf(cintf); 5386 usb_forced_unbind_intf(cintf);
5376 } 5387 }
5377 } 5388 }
5378 } 5389 }
5379 5390
5380 ret = usb_reset_and_verify_device(udev); 5391 ret = usb_reset_and_verify_device(udev);
5381 5392
5382 if (config) { 5393 if (config) {
5383 for (i = config->desc.bNumInterfaces - 1; i >= 0; --i) { 5394 for (i = config->desc.bNumInterfaces - 1; i >= 0; --i) {
5384 struct usb_interface *cintf = config->interface[i]; 5395 struct usb_interface *cintf = config->interface[i];
5385 struct usb_driver *drv; 5396 struct usb_driver *drv;
5386 int rebind = cintf->needs_binding; 5397 int rebind = cintf->needs_binding;
5387 5398
5388 if (!rebind && cintf->dev.driver) { 5399 if (!rebind && cintf->dev.driver) {
5389 drv = to_usb_driver(cintf->dev.driver); 5400 drv = to_usb_driver(cintf->dev.driver);
5390 if (drv->post_reset) 5401 if (drv->post_reset)
5391 rebind = (drv->post_reset)(cintf); 5402 rebind = (drv->post_reset)(cintf);
5392 else if (cintf->condition == 5403 else if (cintf->condition ==
5393 USB_INTERFACE_BOUND) 5404 USB_INTERFACE_BOUND)
5394 rebind = 1; 5405 rebind = 1;
5395 if (rebind) 5406 if (rebind)
5396 cintf->needs_binding = 1; 5407 cintf->needs_binding = 1;
5397 } 5408 }
5398 } 5409 }
5399 usb_unbind_and_rebind_marked_interfaces(udev); 5410 usb_unbind_and_rebind_marked_interfaces(udev);
5400 } 5411 }
5401 5412
5402 usb_autosuspend_device(udev); 5413 usb_autosuspend_device(udev);
5403 memalloc_noio_restore(noio_flag); 5414 memalloc_noio_restore(noio_flag);
5404 return ret; 5415 return ret;
5405 } 5416 }
5406 EXPORT_SYMBOL_GPL(usb_reset_device); 5417 EXPORT_SYMBOL_GPL(usb_reset_device);
5407 5418
5408 5419
5409 /** 5420 /**
5410 * usb_queue_reset_device - Reset a USB device from an atomic context 5421 * usb_queue_reset_device - Reset a USB device from an atomic context
5411 * @iface: USB interface belonging to the device to reset 5422 * @iface: USB interface belonging to the device to reset
5412 * 5423 *
5413 * This function can be used to reset a USB device from an atomic 5424 * This function can be used to reset a USB device from an atomic
5414 * context, where usb_reset_device() won't work (as it blocks). 5425 * context, where usb_reset_device() won't work (as it blocks).
5415 * 5426 *
5416 * Doing a reset via this method is functionally equivalent to calling 5427 * Doing a reset via this method is functionally equivalent to calling
5417 * usb_reset_device(), except for the fact that it is delayed to a 5428 * usb_reset_device(), except for the fact that it is delayed to a
5418 * workqueue. This means that any drivers bound to other interfaces 5429 * workqueue. This means that any drivers bound to other interfaces
5419 * might be unbound, as well as users from usbfs in user space. 5430 * might be unbound, as well as users from usbfs in user space.
5420 * 5431 *
5421 * Corner cases: 5432 * Corner cases:
5422 * 5433 *
5423 * - Scheduling two resets at the same time from two different drivers 5434 * - Scheduling two resets at the same time from two different drivers
5424 * attached to two different interfaces of the same device is 5435 * attached to two different interfaces of the same device is
5425 * possible; depending on how the driver attached to each interface 5436 * possible; depending on how the driver attached to each interface
5426 * handles ->pre_reset(), the second reset might happen or not. 5437 * handles ->pre_reset(), the second reset might happen or not.
5427 * 5438 *
5428 * - If a driver is unbound and it had a pending reset, the reset will 5439 * - If a driver is unbound and it had a pending reset, the reset will
5429 * be cancelled. 5440 * be cancelled.
5430 * 5441 *
5431 * - This function can be called during .probe() or .disconnect() 5442 * - This function can be called during .probe() or .disconnect()
5432 * times. On return from .disconnect(), any pending resets will be 5443 * times. On return from .disconnect(), any pending resets will be
5433 * cancelled. 5444 * cancelled.
5434 * 5445 *
5435 * There is no no need to lock/unlock the @reset_ws as schedule_work() 5446 * There is no no need to lock/unlock the @reset_ws as schedule_work()
5436 * does its own. 5447 * does its own.
5437 * 5448 *
5438 * NOTE: We don't do any reference count tracking because it is not 5449 * NOTE: We don't do any reference count tracking because it is not
5439 * needed. The lifecycle of the work_struct is tied to the 5450 * needed. The lifecycle of the work_struct is tied to the
5440 * usb_interface. Before destroying the interface we cancel the 5451 * usb_interface. Before destroying the interface we cancel the
5441 * work_struct, so the fact that work_struct is queued and or 5452 * work_struct, so the fact that work_struct is queued and or
5442 * running means the interface (and thus, the device) exist and 5453 * running means the interface (and thus, the device) exist and
5443 * are referenced. 5454 * are referenced.
5444 */ 5455 */
5445 void usb_queue_reset_device(struct usb_interface *iface) 5456 void usb_queue_reset_device(struct usb_interface *iface)
5446 { 5457 {
5447 schedule_work(&iface->reset_ws); 5458 schedule_work(&iface->reset_ws);
5448 } 5459 }
5449 EXPORT_SYMBOL_GPL(usb_queue_reset_device); 5460 EXPORT_SYMBOL_GPL(usb_queue_reset_device);
5450 5461
5451 /** 5462 /**
5452 * usb_hub_find_child - Get the pointer of child device 5463 * usb_hub_find_child - Get the pointer of child device
5453 * attached to the port which is specified by @port1. 5464 * attached to the port which is specified by @port1.
5454 * @hdev: USB device belonging to the usb hub 5465 * @hdev: USB device belonging to the usb hub
5455 * @port1: port num to indicate which port the child device 5466 * @port1: port num to indicate which port the child device
5456 * is attached to. 5467 * is attached to.
5457 * 5468 *
5458 * USB drivers call this function to get hub's child device 5469 * USB drivers call this function to get hub's child device
5459 * pointer. 5470 * pointer.
5460 * 5471 *
5461 * Return: %NULL if input param is invalid and 5472 * Return: %NULL if input param is invalid and
5462 * child's usb_device pointer if non-NULL. 5473 * child's usb_device pointer if non-NULL.
5463 */ 5474 */
5464 struct usb_device *usb_hub_find_child(struct usb_device *hdev, 5475 struct usb_device *usb_hub_find_child(struct usb_device *hdev,
5465 int port1) 5476 int port1)
5466 { 5477 {
5467 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); 5478 struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
5468 5479
5469 if (port1 < 1 || port1 > hdev->maxchild) 5480 if (port1 < 1 || port1 > hdev->maxchild)
5470 return NULL; 5481 return NULL;
5471 return hub->ports[port1 - 1]->child; 5482 return hub->ports[port1 - 1]->child;
5472 } 5483 }
5473 EXPORT_SYMBOL_GPL(usb_hub_find_child); 5484 EXPORT_SYMBOL_GPL(usb_hub_find_child);
5474 5485
5475 /** 5486 /**
5476 * usb_set_hub_port_connect_type - set hub port connect type. 5487 * usb_set_hub_port_connect_type - set hub port connect type.
5477 * @hdev: USB device belonging to the usb hub 5488 * @hdev: USB device belonging to the usb hub
5478 * @port1: port num of the port 5489 * @port1: port num of the port
5479 * @type: connect type of the port 5490 * @type: connect type of the port
5480 */ 5491 */
5481 void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1, 5492 void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1,
5482 enum usb_port_connect_type type) 5493 enum usb_port_connect_type type)
5483 { 5494 {
5484 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); 5495 struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
5485 5496
5486 if (hub) 5497 if (hub)
5487 hub->ports[port1 - 1]->connect_type = type; 5498 hub->ports[port1 - 1]->connect_type = type;
5488 } 5499 }
5489 5500
5490 /** 5501 /**
5491 * usb_get_hub_port_connect_type - Get the port's connect type 5502 * usb_get_hub_port_connect_type - Get the port's connect type
5492 * @hdev: USB device belonging to the usb hub 5503 * @hdev: USB device belonging to the usb hub
5493 * @port1: port num of the port 5504 * @port1: port num of the port
5494 * 5505 *
5495 * Return: The connect type of the port if successful. Or 5506 * Return: The connect type of the port if successful. Or
5496 * USB_PORT_CONNECT_TYPE_UNKNOWN if input params are invalid. 5507 * USB_PORT_CONNECT_TYPE_UNKNOWN if input params are invalid.
5497 */ 5508 */
5498 enum usb_port_connect_type 5509 enum usb_port_connect_type
5499 usb_get_hub_port_connect_type(struct usb_device *hdev, int port1) 5510 usb_get_hub_port_connect_type(struct usb_device *hdev, int port1)
5500 { 5511 {
5501 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); 5512 struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
5502 5513
5503 if (!hub) 5514 if (!hub)
5504 return USB_PORT_CONNECT_TYPE_UNKNOWN; 5515 return USB_PORT_CONNECT_TYPE_UNKNOWN;
5505 5516
5506 return hub->ports[port1 - 1]->connect_type; 5517 return hub->ports[port1 - 1]->connect_type;
5507 } 5518 }
5508 5519
5509 void usb_hub_adjust_deviceremovable(struct usb_device *hdev, 5520 void usb_hub_adjust_deviceremovable(struct usb_device *hdev,
5510 struct usb_hub_descriptor *desc) 5521 struct usb_hub_descriptor *desc)
5511 { 5522 {
5512 enum usb_port_connect_type connect_type; 5523 enum usb_port_connect_type connect_type;
5513 int i; 5524 int i;
5514 5525
5515 if (!hub_is_superspeed(hdev)) { 5526 if (!hub_is_superspeed(hdev)) {
5516 for (i = 1; i <= hdev->maxchild; i++) { 5527 for (i = 1; i <= hdev->maxchild; i++) {
5517 connect_type = usb_get_hub_port_connect_type(hdev, i); 5528 connect_type = usb_get_hub_port_connect_type(hdev, i);
5518 5529
5519 if (connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { 5530 if (connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
5520 u8 mask = 1 << (i%8); 5531 u8 mask = 1 << (i%8);
5521 5532
5522 if (!(desc->u.hs.DeviceRemovable[i/8] & mask)) { 5533 if (!(desc->u.hs.DeviceRemovable[i/8] & mask)) {
5523 dev_dbg(&hdev->dev, "usb port%d's DeviceRemovable is changed to 1 according to platform information.\n", 5534 dev_dbg(&hdev->dev, "usb port%d's DeviceRemovable is changed to 1 according to platform information.\n",
5524 i); 5535 i);
5525 desc->u.hs.DeviceRemovable[i/8] |= mask; 5536 desc->u.hs.DeviceRemovable[i/8] |= mask;
5526 } 5537 }
5527 } 5538 }
5528 } 5539 }
5529 } else { 5540 } else {
5530 u16 port_removable = le16_to_cpu(desc->u.ss.DeviceRemovable); 5541 u16 port_removable = le16_to_cpu(desc->u.ss.DeviceRemovable);
5531 5542
5532 for (i = 1; i <= hdev->maxchild; i++) { 5543 for (i = 1; i <= hdev->maxchild; i++) {
5533 connect_type = usb_get_hub_port_connect_type(hdev, i); 5544 connect_type = usb_get_hub_port_connect_type(hdev, i);
5534 5545
5535 if (connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { 5546 if (connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
5536 u16 mask = 1 << i; 5547 u16 mask = 1 << i;
5537 5548
5538 if (!(port_removable & mask)) { 5549 if (!(port_removable & mask)) {
5539 dev_dbg(&hdev->dev, "usb port%d's DeviceRemovable is changed to 1 according to platform information.\n", 5550 dev_dbg(&hdev->dev, "usb port%d's DeviceRemovable is changed to 1 according to platform information.\n",
5540 i); 5551 i);
5541 port_removable |= mask; 5552 port_removable |= mask;
5542 } 5553 }
5543 } 5554 }
5544 } 5555 }
5545 5556
5546 desc->u.ss.DeviceRemovable = cpu_to_le16(port_removable); 5557 desc->u.ss.DeviceRemovable = cpu_to_le16(port_removable);
5547 } 5558 }
5548 } 5559 }
5549 5560
5550 #ifdef CONFIG_ACPI 5561 #ifdef CONFIG_ACPI
5551 /** 5562 /**
5552 * usb_get_hub_port_acpi_handle - Get the usb port's acpi handle 5563 * usb_get_hub_port_acpi_handle - Get the usb port's acpi handle
5553 * @hdev: USB device belonging to the usb hub 5564 * @hdev: USB device belonging to the usb hub
5554 * @port1: port num of the port 5565 * @port1: port num of the port
5555 * 5566 *
5556 * Return: Port's acpi handle if successful, %NULL if params are 5567 * Return: Port's acpi handle if successful, %NULL if params are
5557 * invalid. 5568 * invalid.
5558 */ 5569 */
5559 acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev, 5570 acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev,
5560 int port1) 5571 int port1)
5561 { 5572 {
5562 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); 5573 struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
5563 5574
5564 if (!hub) 5575 if (!hub)
5565 return NULL; 5576 return NULL;
5566 5577
5567 return ACPI_HANDLE(&hub->ports[port1 - 1]->dev); 5578 return ACPI_HANDLE(&hub->ports[port1 - 1]->dev);
5568 } 5579 }
5569 #endif 5580 #endif
5570 5581
drivers/usb/host/pci-quirks.c
1 /* 1 /*
2 * This file contains code to reset and initialize USB host controllers. 2 * This file contains code to reset and initialize USB host controllers.
3 * Some of it includes work-arounds for PCI hardware and BIOS quirks. 3 * Some of it includes work-arounds for PCI hardware and BIOS quirks.
4 * It may need to run early during booting -- before USB would normally 4 * It may need to run early during booting -- before USB would normally
5 * initialize -- to ensure that Linux doesn't use any legacy modes. 5 * initialize -- to ensure that Linux doesn't use any legacy modes.
6 * 6 *
7 * Copyright (c) 1999 Martin Mares <mj@ucw.cz> 7 * Copyright (c) 1999 Martin Mares <mj@ucw.cz>
8 * (and others) 8 * (and others)
9 */ 9 */
10 10
11 #include <linux/types.h> 11 #include <linux/types.h>
12 #include <linux/kconfig.h> 12 #include <linux/kconfig.h>
13 #include <linux/kernel.h> 13 #include <linux/kernel.h>
14 #include <linux/pci.h> 14 #include <linux/pci.h>
15 #include <linux/delay.h> 15 #include <linux/delay.h>
16 #include <linux/export.h> 16 #include <linux/export.h>
17 #include <linux/acpi.h> 17 #include <linux/acpi.h>
18 #include <linux/dmi.h> 18 #include <linux/dmi.h>
19 #include "pci-quirks.h" 19 #include "pci-quirks.h"
20 #include "xhci-ext-caps.h" 20 #include "xhci-ext-caps.h"
21 21
22 22
23 #define UHCI_USBLEGSUP 0xc0 /* legacy support */ 23 #define UHCI_USBLEGSUP 0xc0 /* legacy support */
24 #define UHCI_USBCMD 0 /* command register */ 24 #define UHCI_USBCMD 0 /* command register */
25 #define UHCI_USBINTR 4 /* interrupt register */ 25 #define UHCI_USBINTR 4 /* interrupt register */
26 #define UHCI_USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ 26 #define UHCI_USBLEGSUP_RWC 0x8f00 /* the R/WC bits */
27 #define UHCI_USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ 27 #define UHCI_USBLEGSUP_RO 0x5040 /* R/O and reserved bits */
28 #define UHCI_USBCMD_RUN 0x0001 /* RUN/STOP bit */ 28 #define UHCI_USBCMD_RUN 0x0001 /* RUN/STOP bit */
29 #define UHCI_USBCMD_HCRESET 0x0002 /* Host Controller reset */ 29 #define UHCI_USBCMD_HCRESET 0x0002 /* Host Controller reset */
30 #define UHCI_USBCMD_EGSM 0x0008 /* Global Suspend Mode */ 30 #define UHCI_USBCMD_EGSM 0x0008 /* Global Suspend Mode */
31 #define UHCI_USBCMD_CONFIGURE 0x0040 /* Config Flag */ 31 #define UHCI_USBCMD_CONFIGURE 0x0040 /* Config Flag */
32 #define UHCI_USBINTR_RESUME 0x0002 /* Resume interrupt enable */ 32 #define UHCI_USBINTR_RESUME 0x0002 /* Resume interrupt enable */
33 33
34 #define OHCI_CONTROL 0x04 34 #define OHCI_CONTROL 0x04
35 #define OHCI_CMDSTATUS 0x08 35 #define OHCI_CMDSTATUS 0x08
36 #define OHCI_INTRSTATUS 0x0c 36 #define OHCI_INTRSTATUS 0x0c
37 #define OHCI_INTRENABLE 0x10 37 #define OHCI_INTRENABLE 0x10
38 #define OHCI_INTRDISABLE 0x14 38 #define OHCI_INTRDISABLE 0x14
39 #define OHCI_FMINTERVAL 0x34 39 #define OHCI_FMINTERVAL 0x34
40 #define OHCI_HCFS (3 << 6) /* hc functional state */ 40 #define OHCI_HCFS (3 << 6) /* hc functional state */
41 #define OHCI_HCR (1 << 0) /* host controller reset */ 41 #define OHCI_HCR (1 << 0) /* host controller reset */
42 #define OHCI_OCR (1 << 3) /* ownership change request */ 42 #define OHCI_OCR (1 << 3) /* ownership change request */
43 #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */ 43 #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */
44 #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */ 44 #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
45 #define OHCI_INTR_OC (1 << 30) /* ownership change */ 45 #define OHCI_INTR_OC (1 << 30) /* ownership change */
46 46
47 #define EHCI_HCC_PARAMS 0x08 /* extended capabilities */ 47 #define EHCI_HCC_PARAMS 0x08 /* extended capabilities */
48 #define EHCI_USBCMD 0 /* command register */ 48 #define EHCI_USBCMD 0 /* command register */
49 #define EHCI_USBCMD_RUN (1 << 0) /* RUN/STOP bit */ 49 #define EHCI_USBCMD_RUN (1 << 0) /* RUN/STOP bit */
50 #define EHCI_USBSTS 4 /* status register */ 50 #define EHCI_USBSTS 4 /* status register */
51 #define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */ 51 #define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */
52 #define EHCI_USBINTR 8 /* interrupt register */ 52 #define EHCI_USBINTR 8 /* interrupt register */
53 #define EHCI_CONFIGFLAG 0x40 /* configured flag register */ 53 #define EHCI_CONFIGFLAG 0x40 /* configured flag register */
54 #define EHCI_USBLEGSUP 0 /* legacy support register */ 54 #define EHCI_USBLEGSUP 0 /* legacy support register */
55 #define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */ 55 #define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */
56 #define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */ 56 #define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */
57 #define EHCI_USBLEGCTLSTS 4 /* legacy control/status */ 57 #define EHCI_USBLEGCTLSTS 4 /* legacy control/status */
58 #define EHCI_USBLEGCTLSTS_SOOE (1 << 13) /* SMI on ownership change */ 58 #define EHCI_USBLEGCTLSTS_SOOE (1 << 13) /* SMI on ownership change */
59 59
60 /* AMD quirk use */ 60 /* AMD quirk use */
61 #define AB_REG_BAR_LOW 0xe0 61 #define AB_REG_BAR_LOW 0xe0
62 #define AB_REG_BAR_HIGH 0xe1 62 #define AB_REG_BAR_HIGH 0xe1
63 #define AB_REG_BAR_SB700 0xf0 63 #define AB_REG_BAR_SB700 0xf0
64 #define AB_INDX(addr) ((addr) + 0x00) 64 #define AB_INDX(addr) ((addr) + 0x00)
65 #define AB_DATA(addr) ((addr) + 0x04) 65 #define AB_DATA(addr) ((addr) + 0x04)
66 #define AX_INDXC 0x30 66 #define AX_INDXC 0x30
67 #define AX_DATAC 0x34 67 #define AX_DATAC 0x34
68 68
69 #define NB_PCIE_INDX_ADDR 0xe0 69 #define NB_PCIE_INDX_ADDR 0xe0
70 #define NB_PCIE_INDX_DATA 0xe4 70 #define NB_PCIE_INDX_DATA 0xe4
71 #define PCIE_P_CNTL 0x10040 71 #define PCIE_P_CNTL 0x10040
72 #define BIF_NB 0x10002 72 #define BIF_NB 0x10002
73 #define NB_PIF0_PWRDOWN_0 0x01100012 73 #define NB_PIF0_PWRDOWN_0 0x01100012
74 #define NB_PIF0_PWRDOWN_1 0x01100013 74 #define NB_PIF0_PWRDOWN_1 0x01100013
75 75
76 #define USB_INTEL_XUSB2PR 0xD0 76 #define USB_INTEL_XUSB2PR 0xD0
77 #define USB_INTEL_USB2PRM 0xD4 77 #define USB_INTEL_USB2PRM 0xD4
78 #define USB_INTEL_USB3_PSSEN 0xD8 78 #define USB_INTEL_USB3_PSSEN 0xD8
79 #define USB_INTEL_USB3PRM 0xDC 79 #define USB_INTEL_USB3PRM 0xDC
80 80
81 /* 81 /*
82 * amd_chipset_gen values represent AMD different chipset generations 82 * amd_chipset_gen values represent AMD different chipset generations
83 */ 83 */
84 enum amd_chipset_gen { 84 enum amd_chipset_gen {
85 NOT_AMD_CHIPSET = 0, 85 NOT_AMD_CHIPSET = 0,
86 AMD_CHIPSET_SB600, 86 AMD_CHIPSET_SB600,
87 AMD_CHIPSET_SB700, 87 AMD_CHIPSET_SB700,
88 AMD_CHIPSET_SB800, 88 AMD_CHIPSET_SB800,
89 AMD_CHIPSET_HUDSON2, 89 AMD_CHIPSET_HUDSON2,
90 AMD_CHIPSET_BOLTON, 90 AMD_CHIPSET_BOLTON,
91 AMD_CHIPSET_YANGTZE, 91 AMD_CHIPSET_YANGTZE,
92 AMD_CHIPSET_UNKNOWN, 92 AMD_CHIPSET_UNKNOWN,
93 }; 93 };
94 94
95 struct amd_chipset_type { 95 struct amd_chipset_type {
96 enum amd_chipset_gen gen; 96 enum amd_chipset_gen gen;
97 u8 rev; 97 u8 rev;
98 }; 98 };
99 99
100 static struct amd_chipset_info { 100 static struct amd_chipset_info {
101 struct pci_dev *nb_dev; 101 struct pci_dev *nb_dev;
102 struct pci_dev *smbus_dev; 102 struct pci_dev *smbus_dev;
103 int nb_type; 103 int nb_type;
104 struct amd_chipset_type sb_type; 104 struct amd_chipset_type sb_type;
105 int isoc_reqs; 105 int isoc_reqs;
106 int probe_count; 106 int probe_count;
107 int probe_result; 107 int probe_result;
108 } amd_chipset; 108 } amd_chipset;
109 109
110 static DEFINE_SPINLOCK(amd_lock); 110 static DEFINE_SPINLOCK(amd_lock);
111 111
112 /* 112 /*
113 * amd_chipset_sb_type_init - initialize amd chipset southbridge type 113 * amd_chipset_sb_type_init - initialize amd chipset southbridge type
114 * 114 *
115 * AMD FCH/SB generation and revision is identified by SMBus controller 115 * AMD FCH/SB generation and revision is identified by SMBus controller
116 * vendor, device and revision IDs. 116 * vendor, device and revision IDs.
117 * 117 *
118 * Returns: 1 if it is an AMD chipset, 0 otherwise. 118 * Returns: 1 if it is an AMD chipset, 0 otherwise.
119 */ 119 */
120 static int amd_chipset_sb_type_init(struct amd_chipset_info *pinfo) 120 static int amd_chipset_sb_type_init(struct amd_chipset_info *pinfo)
121 { 121 {
122 u8 rev = 0; 122 u8 rev = 0;
123 pinfo->sb_type.gen = AMD_CHIPSET_UNKNOWN; 123 pinfo->sb_type.gen = AMD_CHIPSET_UNKNOWN;
124 124
125 pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 125 pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI,
126 PCI_DEVICE_ID_ATI_SBX00_SMBUS, NULL); 126 PCI_DEVICE_ID_ATI_SBX00_SMBUS, NULL);
127 if (pinfo->smbus_dev) { 127 if (pinfo->smbus_dev) {
128 rev = pinfo->smbus_dev->revision; 128 rev = pinfo->smbus_dev->revision;
129 if (rev >= 0x10 && rev <= 0x1f) 129 if (rev >= 0x10 && rev <= 0x1f)
130 pinfo->sb_type.gen = AMD_CHIPSET_SB600; 130 pinfo->sb_type.gen = AMD_CHIPSET_SB600;
131 else if (rev >= 0x30 && rev <= 0x3f) 131 else if (rev >= 0x30 && rev <= 0x3f)
132 pinfo->sb_type.gen = AMD_CHIPSET_SB700; 132 pinfo->sb_type.gen = AMD_CHIPSET_SB700;
133 else if (rev >= 0x40 && rev <= 0x4f) 133 else if (rev >= 0x40 && rev <= 0x4f)
134 pinfo->sb_type.gen = AMD_CHIPSET_SB800; 134 pinfo->sb_type.gen = AMD_CHIPSET_SB800;
135 } else { 135 } else {
136 pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, 136 pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
137 PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL); 137 PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL);
138 138
139 if (!pinfo->smbus_dev) { 139 if (!pinfo->smbus_dev) {
140 pinfo->sb_type.gen = NOT_AMD_CHIPSET; 140 pinfo->sb_type.gen = NOT_AMD_CHIPSET;
141 return 0; 141 return 0;
142 } 142 }
143 143
144 rev = pinfo->smbus_dev->revision; 144 rev = pinfo->smbus_dev->revision;
145 if (rev >= 0x11 && rev <= 0x14) 145 if (rev >= 0x11 && rev <= 0x14)
146 pinfo->sb_type.gen = AMD_CHIPSET_HUDSON2; 146 pinfo->sb_type.gen = AMD_CHIPSET_HUDSON2;
147 else if (rev >= 0x15 && rev <= 0x18) 147 else if (rev >= 0x15 && rev <= 0x18)
148 pinfo->sb_type.gen = AMD_CHIPSET_BOLTON; 148 pinfo->sb_type.gen = AMD_CHIPSET_BOLTON;
149 else if (rev >= 0x39 && rev <= 0x3a) 149 else if (rev >= 0x39 && rev <= 0x3a)
150 pinfo->sb_type.gen = AMD_CHIPSET_YANGTZE; 150 pinfo->sb_type.gen = AMD_CHIPSET_YANGTZE;
151 } 151 }
152 152
153 pinfo->sb_type.rev = rev; 153 pinfo->sb_type.rev = rev;
154 return 1; 154 return 1;
155 } 155 }
156 156
157 void sb800_prefetch(struct device *dev, int on) 157 void sb800_prefetch(struct device *dev, int on)
158 { 158 {
159 u16 misc; 159 u16 misc;
160 struct pci_dev *pdev = to_pci_dev(dev); 160 struct pci_dev *pdev = to_pci_dev(dev);
161 161
162 pci_read_config_word(pdev, 0x50, &misc); 162 pci_read_config_word(pdev, 0x50, &misc);
163 if (on == 0) 163 if (on == 0)
164 pci_write_config_word(pdev, 0x50, misc & 0xfcff); 164 pci_write_config_word(pdev, 0x50, misc & 0xfcff);
165 else 165 else
166 pci_write_config_word(pdev, 0x50, misc | 0x0300); 166 pci_write_config_word(pdev, 0x50, misc | 0x0300);
167 } 167 }
168 EXPORT_SYMBOL_GPL(sb800_prefetch); 168 EXPORT_SYMBOL_GPL(sb800_prefetch);
169 169
170 int usb_amd_find_chipset_info(void) 170 int usb_amd_find_chipset_info(void)
171 { 171 {
172 unsigned long flags; 172 unsigned long flags;
173 struct amd_chipset_info info; 173 struct amd_chipset_info info;
174 int ret; 174 int ret;
175 175
176 spin_lock_irqsave(&amd_lock, flags); 176 spin_lock_irqsave(&amd_lock, flags);
177 177
178 /* probe only once */ 178 /* probe only once */
179 if (amd_chipset.probe_count > 0) { 179 if (amd_chipset.probe_count > 0) {
180 amd_chipset.probe_count++; 180 amd_chipset.probe_count++;
181 spin_unlock_irqrestore(&amd_lock, flags); 181 spin_unlock_irqrestore(&amd_lock, flags);
182 return amd_chipset.probe_result; 182 return amd_chipset.probe_result;
183 } 183 }
184 memset(&info, 0, sizeof(info)); 184 memset(&info, 0, sizeof(info));
185 spin_unlock_irqrestore(&amd_lock, flags); 185 spin_unlock_irqrestore(&amd_lock, flags);
186 186
187 if (!amd_chipset_sb_type_init(&info)) { 187 if (!amd_chipset_sb_type_init(&info)) {
188 ret = 0; 188 ret = 0;
189 goto commit; 189 goto commit;
190 } 190 }
191 191
192 /* Below chipset generations needn't enable AMD PLL quirk */ 192 /* Below chipset generations needn't enable AMD PLL quirk */
193 if (info.sb_type.gen == AMD_CHIPSET_UNKNOWN || 193 if (info.sb_type.gen == AMD_CHIPSET_UNKNOWN ||
194 info.sb_type.gen == AMD_CHIPSET_SB600 || 194 info.sb_type.gen == AMD_CHIPSET_SB600 ||
195 info.sb_type.gen == AMD_CHIPSET_YANGTZE || 195 info.sb_type.gen == AMD_CHIPSET_YANGTZE ||
196 (info.sb_type.gen == AMD_CHIPSET_SB700 && 196 (info.sb_type.gen == AMD_CHIPSET_SB700 &&
197 info.sb_type.rev > 0x3b)) { 197 info.sb_type.rev > 0x3b)) {
198 if (info.smbus_dev) { 198 if (info.smbus_dev) {
199 pci_dev_put(info.smbus_dev); 199 pci_dev_put(info.smbus_dev);
200 info.smbus_dev = NULL; 200 info.smbus_dev = NULL;
201 } 201 }
202 ret = 0; 202 ret = 0;
203 goto commit; 203 goto commit;
204 } 204 }
205 205
206 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x9601, NULL); 206 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x9601, NULL);
207 if (info.nb_dev) { 207 if (info.nb_dev) {
208 info.nb_type = 1; 208 info.nb_type = 1;
209 } else { 209 } else {
210 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL); 210 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL);
211 if (info.nb_dev) { 211 if (info.nb_dev) {
212 info.nb_type = 2; 212 info.nb_type = 2;
213 } else { 213 } else {
214 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 214 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD,
215 0x9600, NULL); 215 0x9600, NULL);
216 if (info.nb_dev) 216 if (info.nb_dev)
217 info.nb_type = 3; 217 info.nb_type = 3;
218 } 218 }
219 } 219 }
220 220
221 ret = info.probe_result = 1; 221 ret = info.probe_result = 1;
222 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n"); 222 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n");
223 223
224 commit: 224 commit:
225 225
226 spin_lock_irqsave(&amd_lock, flags); 226 spin_lock_irqsave(&amd_lock, flags);
227 if (amd_chipset.probe_count > 0) { 227 if (amd_chipset.probe_count > 0) {
228 /* race - someone else was faster - drop devices */ 228 /* race - someone else was faster - drop devices */
229 229
230 /* Mark that we where here */ 230 /* Mark that we where here */
231 amd_chipset.probe_count++; 231 amd_chipset.probe_count++;
232 ret = amd_chipset.probe_result; 232 ret = amd_chipset.probe_result;
233 233
234 spin_unlock_irqrestore(&amd_lock, flags); 234 spin_unlock_irqrestore(&amd_lock, flags);
235 235
236 if (info.nb_dev) 236 if (info.nb_dev)
237 pci_dev_put(info.nb_dev); 237 pci_dev_put(info.nb_dev);
238 if (info.smbus_dev) 238 if (info.smbus_dev)
239 pci_dev_put(info.smbus_dev); 239 pci_dev_put(info.smbus_dev);
240 240
241 } else { 241 } else {
242 /* no race - commit the result */ 242 /* no race - commit the result */
243 info.probe_count++; 243 info.probe_count++;
244 amd_chipset = info; 244 amd_chipset = info;
245 spin_unlock_irqrestore(&amd_lock, flags); 245 spin_unlock_irqrestore(&amd_lock, flags);
246 } 246 }
247 247
248 return ret; 248 return ret;
249 } 249 }
250 EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info); 250 EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info);
251 251
252 int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev) 252 int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev)
253 { 253 {
254 /* Make sure amd chipset type has already been initialized */ 254 /* Make sure amd chipset type has already been initialized */
255 usb_amd_find_chipset_info(); 255 usb_amd_find_chipset_info();
256 if (amd_chipset.sb_type.gen != AMD_CHIPSET_YANGTZE) 256 if (amd_chipset.sb_type.gen != AMD_CHIPSET_YANGTZE)
257 return 0; 257 return 0;
258 258
259 dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n"); 259 dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n");
260 return 1; 260 return 1;
261 } 261 }
262 EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk); 262 EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk);
263 263
264 bool usb_amd_hang_symptom_quirk(void) 264 bool usb_amd_hang_symptom_quirk(void)
265 { 265 {
266 u8 rev; 266 u8 rev;
267 267
268 usb_amd_find_chipset_info(); 268 usb_amd_find_chipset_info();
269 rev = amd_chipset.sb_type.rev; 269 rev = amd_chipset.sb_type.rev;
270 /* SB600 and old version of SB700 have hang symptom bug */ 270 /* SB600 and old version of SB700 have hang symptom bug */
271 return amd_chipset.sb_type.gen == AMD_CHIPSET_SB600 || 271 return amd_chipset.sb_type.gen == AMD_CHIPSET_SB600 ||
272 (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 && 272 (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 &&
273 rev >= 0x3a && rev <= 0x3b); 273 rev >= 0x3a && rev <= 0x3b);
274 } 274 }
275 EXPORT_SYMBOL_GPL(usb_amd_hang_symptom_quirk); 275 EXPORT_SYMBOL_GPL(usb_amd_hang_symptom_quirk);
276 276
277 bool usb_amd_prefetch_quirk(void) 277 bool usb_amd_prefetch_quirk(void)
278 { 278 {
279 usb_amd_find_chipset_info(); 279 usb_amd_find_chipset_info();
280 /* SB800 needs pre-fetch fix */ 280 /* SB800 needs pre-fetch fix */
281 return amd_chipset.sb_type.gen == AMD_CHIPSET_SB800; 281 return amd_chipset.sb_type.gen == AMD_CHIPSET_SB800;
282 } 282 }
283 EXPORT_SYMBOL_GPL(usb_amd_prefetch_quirk); 283 EXPORT_SYMBOL_GPL(usb_amd_prefetch_quirk);
284 284
285 /* 285 /*
286 * The hardware normally enables the A-link power management feature, which 286 * The hardware normally enables the A-link power management feature, which
287 * lets the system lower the power consumption in idle states. 287 * lets the system lower the power consumption in idle states.
288 * 288 *
289 * This USB quirk prevents the link going into that lower power state 289 * This USB quirk prevents the link going into that lower power state
290 * during isochronous transfers. 290 * during isochronous transfers.
291 * 291 *
292 * Without this quirk, isochronous stream on OHCI/EHCI/xHCI controllers of 292 * Without this quirk, isochronous stream on OHCI/EHCI/xHCI controllers of
293 * some AMD platforms may stutter or have breaks occasionally. 293 * some AMD platforms may stutter or have breaks occasionally.
294 */ 294 */
295 static void usb_amd_quirk_pll(int disable) 295 static void usb_amd_quirk_pll(int disable)
296 { 296 {
297 u32 addr, addr_low, addr_high, val; 297 u32 addr, addr_low, addr_high, val;
298 u32 bit = disable ? 0 : 1; 298 u32 bit = disable ? 0 : 1;
299 unsigned long flags; 299 unsigned long flags;
300 300
301 spin_lock_irqsave(&amd_lock, flags); 301 spin_lock_irqsave(&amd_lock, flags);
302 302
303 if (disable) { 303 if (disable) {
304 amd_chipset.isoc_reqs++; 304 amd_chipset.isoc_reqs++;
305 if (amd_chipset.isoc_reqs > 1) { 305 if (amd_chipset.isoc_reqs > 1) {
306 spin_unlock_irqrestore(&amd_lock, flags); 306 spin_unlock_irqrestore(&amd_lock, flags);
307 return; 307 return;
308 } 308 }
309 } else { 309 } else {
310 amd_chipset.isoc_reqs--; 310 amd_chipset.isoc_reqs--;
311 if (amd_chipset.isoc_reqs > 0) { 311 if (amd_chipset.isoc_reqs > 0) {
312 spin_unlock_irqrestore(&amd_lock, flags); 312 spin_unlock_irqrestore(&amd_lock, flags);
313 return; 313 return;
314 } 314 }
315 } 315 }
316 316
317 if (amd_chipset.sb_type.gen == AMD_CHIPSET_SB800 || 317 if (amd_chipset.sb_type.gen == AMD_CHIPSET_SB800 ||
318 amd_chipset.sb_type.gen == AMD_CHIPSET_HUDSON2 || 318 amd_chipset.sb_type.gen == AMD_CHIPSET_HUDSON2 ||
319 amd_chipset.sb_type.gen == AMD_CHIPSET_BOLTON) { 319 amd_chipset.sb_type.gen == AMD_CHIPSET_BOLTON) {
320 outb_p(AB_REG_BAR_LOW, 0xcd6); 320 outb_p(AB_REG_BAR_LOW, 0xcd6);
321 addr_low = inb_p(0xcd7); 321 addr_low = inb_p(0xcd7);
322 outb_p(AB_REG_BAR_HIGH, 0xcd6); 322 outb_p(AB_REG_BAR_HIGH, 0xcd6);
323 addr_high = inb_p(0xcd7); 323 addr_high = inb_p(0xcd7);
324 addr = addr_high << 8 | addr_low; 324 addr = addr_high << 8 | addr_low;
325 325
326 outl_p(0x30, AB_INDX(addr)); 326 outl_p(0x30, AB_INDX(addr));
327 outl_p(0x40, AB_DATA(addr)); 327 outl_p(0x40, AB_DATA(addr));
328 outl_p(0x34, AB_INDX(addr)); 328 outl_p(0x34, AB_INDX(addr));
329 val = inl_p(AB_DATA(addr)); 329 val = inl_p(AB_DATA(addr));
330 } else if (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 && 330 } else if (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 &&
331 amd_chipset.sb_type.rev <= 0x3b) { 331 amd_chipset.sb_type.rev <= 0x3b) {
332 pci_read_config_dword(amd_chipset.smbus_dev, 332 pci_read_config_dword(amd_chipset.smbus_dev,
333 AB_REG_BAR_SB700, &addr); 333 AB_REG_BAR_SB700, &addr);
334 outl(AX_INDXC, AB_INDX(addr)); 334 outl(AX_INDXC, AB_INDX(addr));
335 outl(0x40, AB_DATA(addr)); 335 outl(0x40, AB_DATA(addr));
336 outl(AX_DATAC, AB_INDX(addr)); 336 outl(AX_DATAC, AB_INDX(addr));
337 val = inl(AB_DATA(addr)); 337 val = inl(AB_DATA(addr));
338 } else { 338 } else {
339 spin_unlock_irqrestore(&amd_lock, flags); 339 spin_unlock_irqrestore(&amd_lock, flags);
340 return; 340 return;
341 } 341 }
342 342
343 if (disable) { 343 if (disable) {
344 val &= ~0x08; 344 val &= ~0x08;
345 val |= (1 << 4) | (1 << 9); 345 val |= (1 << 4) | (1 << 9);
346 } else { 346 } else {
347 val |= 0x08; 347 val |= 0x08;
348 val &= ~((1 << 4) | (1 << 9)); 348 val &= ~((1 << 4) | (1 << 9));
349 } 349 }
350 outl_p(val, AB_DATA(addr)); 350 outl_p(val, AB_DATA(addr));
351 351
352 if (!amd_chipset.nb_dev) { 352 if (!amd_chipset.nb_dev) {
353 spin_unlock_irqrestore(&amd_lock, flags); 353 spin_unlock_irqrestore(&amd_lock, flags);
354 return; 354 return;
355 } 355 }
356 356
357 if (amd_chipset.nb_type == 1 || amd_chipset.nb_type == 3) { 357 if (amd_chipset.nb_type == 1 || amd_chipset.nb_type == 3) {
358 addr = PCIE_P_CNTL; 358 addr = PCIE_P_CNTL;
359 pci_write_config_dword(amd_chipset.nb_dev, 359 pci_write_config_dword(amd_chipset.nb_dev,
360 NB_PCIE_INDX_ADDR, addr); 360 NB_PCIE_INDX_ADDR, addr);
361 pci_read_config_dword(amd_chipset.nb_dev, 361 pci_read_config_dword(amd_chipset.nb_dev,
362 NB_PCIE_INDX_DATA, &val); 362 NB_PCIE_INDX_DATA, &val);
363 363
364 val &= ~(1 | (1 << 3) | (1 << 4) | (1 << 9) | (1 << 12)); 364 val &= ~(1 | (1 << 3) | (1 << 4) | (1 << 9) | (1 << 12));
365 val |= bit | (bit << 3) | (bit << 12); 365 val |= bit | (bit << 3) | (bit << 12);
366 val |= ((!bit) << 4) | ((!bit) << 9); 366 val |= ((!bit) << 4) | ((!bit) << 9);
367 pci_write_config_dword(amd_chipset.nb_dev, 367 pci_write_config_dword(amd_chipset.nb_dev,
368 NB_PCIE_INDX_DATA, val); 368 NB_PCIE_INDX_DATA, val);
369 369
370 addr = BIF_NB; 370 addr = BIF_NB;
371 pci_write_config_dword(amd_chipset.nb_dev, 371 pci_write_config_dword(amd_chipset.nb_dev,
372 NB_PCIE_INDX_ADDR, addr); 372 NB_PCIE_INDX_ADDR, addr);
373 pci_read_config_dword(amd_chipset.nb_dev, 373 pci_read_config_dword(amd_chipset.nb_dev,
374 NB_PCIE_INDX_DATA, &val); 374 NB_PCIE_INDX_DATA, &val);
375 val &= ~(1 << 8); 375 val &= ~(1 << 8);
376 val |= bit << 8; 376 val |= bit << 8;
377 377
378 pci_write_config_dword(amd_chipset.nb_dev, 378 pci_write_config_dword(amd_chipset.nb_dev,
379 NB_PCIE_INDX_DATA, val); 379 NB_PCIE_INDX_DATA, val);
380 } else if (amd_chipset.nb_type == 2) { 380 } else if (amd_chipset.nb_type == 2) {
381 addr = NB_PIF0_PWRDOWN_0; 381 addr = NB_PIF0_PWRDOWN_0;
382 pci_write_config_dword(amd_chipset.nb_dev, 382 pci_write_config_dword(amd_chipset.nb_dev,
383 NB_PCIE_INDX_ADDR, addr); 383 NB_PCIE_INDX_ADDR, addr);
384 pci_read_config_dword(amd_chipset.nb_dev, 384 pci_read_config_dword(amd_chipset.nb_dev,
385 NB_PCIE_INDX_DATA, &val); 385 NB_PCIE_INDX_DATA, &val);
386 if (disable) 386 if (disable)
387 val &= ~(0x3f << 7); 387 val &= ~(0x3f << 7);
388 else 388 else
389 val |= 0x3f << 7; 389 val |= 0x3f << 7;
390 390
391 pci_write_config_dword(amd_chipset.nb_dev, 391 pci_write_config_dword(amd_chipset.nb_dev,
392 NB_PCIE_INDX_DATA, val); 392 NB_PCIE_INDX_DATA, val);
393 393
394 addr = NB_PIF0_PWRDOWN_1; 394 addr = NB_PIF0_PWRDOWN_1;
395 pci_write_config_dword(amd_chipset.nb_dev, 395 pci_write_config_dword(amd_chipset.nb_dev,
396 NB_PCIE_INDX_ADDR, addr); 396 NB_PCIE_INDX_ADDR, addr);
397 pci_read_config_dword(amd_chipset.nb_dev, 397 pci_read_config_dword(amd_chipset.nb_dev,
398 NB_PCIE_INDX_DATA, &val); 398 NB_PCIE_INDX_DATA, &val);
399 if (disable) 399 if (disable)
400 val &= ~(0x3f << 7); 400 val &= ~(0x3f << 7);
401 else 401 else
402 val |= 0x3f << 7; 402 val |= 0x3f << 7;
403 403
404 pci_write_config_dword(amd_chipset.nb_dev, 404 pci_write_config_dword(amd_chipset.nb_dev,
405 NB_PCIE_INDX_DATA, val); 405 NB_PCIE_INDX_DATA, val);
406 } 406 }
407 407
408 spin_unlock_irqrestore(&amd_lock, flags); 408 spin_unlock_irqrestore(&amd_lock, flags);
409 return; 409 return;
410 } 410 }
411 411
412 void usb_amd_quirk_pll_disable(void) 412 void usb_amd_quirk_pll_disable(void)
413 { 413 {
414 usb_amd_quirk_pll(1); 414 usb_amd_quirk_pll(1);
415 } 415 }
416 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_disable); 416 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_disable);
417 417
418 void usb_amd_quirk_pll_enable(void) 418 void usb_amd_quirk_pll_enable(void)
419 { 419 {
420 usb_amd_quirk_pll(0); 420 usb_amd_quirk_pll(0);
421 } 421 }
422 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_enable); 422 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_enable);
423 423
424 void usb_amd_dev_put(void) 424 void usb_amd_dev_put(void)
425 { 425 {
426 struct pci_dev *nb, *smbus; 426 struct pci_dev *nb, *smbus;
427 unsigned long flags; 427 unsigned long flags;
428 428
429 spin_lock_irqsave(&amd_lock, flags); 429 spin_lock_irqsave(&amd_lock, flags);
430 430
431 amd_chipset.probe_count--; 431 amd_chipset.probe_count--;
432 if (amd_chipset.probe_count > 0) { 432 if (amd_chipset.probe_count > 0) {
433 spin_unlock_irqrestore(&amd_lock, flags); 433 spin_unlock_irqrestore(&amd_lock, flags);
434 return; 434 return;
435 } 435 }
436 436
437 /* save them to pci_dev_put outside of spinlock */ 437 /* save them to pci_dev_put outside of spinlock */
438 nb = amd_chipset.nb_dev; 438 nb = amd_chipset.nb_dev;
439 smbus = amd_chipset.smbus_dev; 439 smbus = amd_chipset.smbus_dev;
440 440
441 amd_chipset.nb_dev = NULL; 441 amd_chipset.nb_dev = NULL;
442 amd_chipset.smbus_dev = NULL; 442 amd_chipset.smbus_dev = NULL;
443 amd_chipset.nb_type = 0; 443 amd_chipset.nb_type = 0;
444 memset(&amd_chipset.sb_type, 0, sizeof(amd_chipset.sb_type)); 444 memset(&amd_chipset.sb_type, 0, sizeof(amd_chipset.sb_type));
445 amd_chipset.isoc_reqs = 0; 445 amd_chipset.isoc_reqs = 0;
446 amd_chipset.probe_result = 0; 446 amd_chipset.probe_result = 0;
447 447
448 spin_unlock_irqrestore(&amd_lock, flags); 448 spin_unlock_irqrestore(&amd_lock, flags);
449 449
450 if (nb) 450 if (nb)
451 pci_dev_put(nb); 451 pci_dev_put(nb);
452 if (smbus) 452 if (smbus)
453 pci_dev_put(smbus); 453 pci_dev_put(smbus);
454 } 454 }
455 EXPORT_SYMBOL_GPL(usb_amd_dev_put); 455 EXPORT_SYMBOL_GPL(usb_amd_dev_put);
456 456
457 /* 457 /*
458 * Make sure the controller is completely inactive, unable to 458 * Make sure the controller is completely inactive, unable to
459 * generate interrupts or do DMA. 459 * generate interrupts or do DMA.
460 */ 460 */
461 void uhci_reset_hc(struct pci_dev *pdev, unsigned long base) 461 void uhci_reset_hc(struct pci_dev *pdev, unsigned long base)
462 { 462 {
463 /* Turn off PIRQ enable and SMI enable. (This also turns off the 463 /* Turn off PIRQ enable and SMI enable. (This also turns off the
464 * BIOS's USB Legacy Support.) Turn off all the R/WC bits too. 464 * BIOS's USB Legacy Support.) Turn off all the R/WC bits too.
465 */ 465 */
466 pci_write_config_word(pdev, UHCI_USBLEGSUP, UHCI_USBLEGSUP_RWC); 466 pci_write_config_word(pdev, UHCI_USBLEGSUP, UHCI_USBLEGSUP_RWC);
467 467
468 /* Reset the HC - this will force us to get a 468 /* Reset the HC - this will force us to get a
469 * new notification of any already connected 469 * new notification of any already connected
470 * ports due to the virtual disconnect that it 470 * ports due to the virtual disconnect that it
471 * implies. 471 * implies.
472 */ 472 */
473 outw(UHCI_USBCMD_HCRESET, base + UHCI_USBCMD); 473 outw(UHCI_USBCMD_HCRESET, base + UHCI_USBCMD);
474 mb(); 474 mb();
475 udelay(5); 475 udelay(5);
476 if (inw(base + UHCI_USBCMD) & UHCI_USBCMD_HCRESET) 476 if (inw(base + UHCI_USBCMD) & UHCI_USBCMD_HCRESET)
477 dev_warn(&pdev->dev, "HCRESET not completed yet!\n"); 477 dev_warn(&pdev->dev, "HCRESET not completed yet!\n");
478 478
479 /* Just to be safe, disable interrupt requests and 479 /* Just to be safe, disable interrupt requests and
480 * make sure the controller is stopped. 480 * make sure the controller is stopped.
481 */ 481 */
482 outw(0, base + UHCI_USBINTR); 482 outw(0, base + UHCI_USBINTR);
483 outw(0, base + UHCI_USBCMD); 483 outw(0, base + UHCI_USBCMD);
484 } 484 }
485 EXPORT_SYMBOL_GPL(uhci_reset_hc); 485 EXPORT_SYMBOL_GPL(uhci_reset_hc);
486 486
487 /* 487 /*
488 * Initialize a controller that was newly discovered or has just been 488 * Initialize a controller that was newly discovered or has just been
489 * resumed. In either case we can't be sure of its previous state. 489 * resumed. In either case we can't be sure of its previous state.
490 * 490 *
491 * Returns: 1 if the controller was reset, 0 otherwise. 491 * Returns: 1 if the controller was reset, 0 otherwise.
492 */ 492 */
493 int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base) 493 int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
494 { 494 {
495 u16 legsup; 495 u16 legsup;
496 unsigned int cmd, intr; 496 unsigned int cmd, intr;
497 497
498 /* 498 /*
499 * When restarting a suspended controller, we expect all the 499 * When restarting a suspended controller, we expect all the
500 * settings to be the same as we left them: 500 * settings to be the same as we left them:
501 * 501 *
502 * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP; 502 * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP;
503 * Controller is stopped and configured with EGSM set; 503 * Controller is stopped and configured with EGSM set;
504 * No interrupts enabled except possibly Resume Detect. 504 * No interrupts enabled except possibly Resume Detect.
505 * 505 *
506 * If any of these conditions are violated we do a complete reset. 506 * If any of these conditions are violated we do a complete reset.
507 */ 507 */
508 pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup); 508 pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup);
509 if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) { 509 if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) {
510 dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n", 510 dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n",
511 __func__, legsup); 511 __func__, legsup);
512 goto reset_needed; 512 goto reset_needed;
513 } 513 }
514 514
515 cmd = inw(base + UHCI_USBCMD); 515 cmd = inw(base + UHCI_USBCMD);
516 if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) || 516 if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) ||
517 !(cmd & UHCI_USBCMD_EGSM)) { 517 !(cmd & UHCI_USBCMD_EGSM)) {
518 dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n", 518 dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n",
519 __func__, cmd); 519 __func__, cmd);
520 goto reset_needed; 520 goto reset_needed;
521 } 521 }
522 522
523 intr = inw(base + UHCI_USBINTR); 523 intr = inw(base + UHCI_USBINTR);
524 if (intr & (~UHCI_USBINTR_RESUME)) { 524 if (intr & (~UHCI_USBINTR_RESUME)) {
525 dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n", 525 dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n",
526 __func__, intr); 526 __func__, intr);
527 goto reset_needed; 527 goto reset_needed;
528 } 528 }
529 return 0; 529 return 0;
530 530
531 reset_needed: 531 reset_needed:
532 dev_dbg(&pdev->dev, "Performing full reset\n"); 532 dev_dbg(&pdev->dev, "Performing full reset\n");
533 uhci_reset_hc(pdev, base); 533 uhci_reset_hc(pdev, base);
534 return 1; 534 return 1;
535 } 535 }
536 EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc); 536 EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
537 537
538 static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask) 538 static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask)
539 { 539 {
540 u16 cmd; 540 u16 cmd;
541 return !pci_read_config_word(pdev, PCI_COMMAND, &cmd) && (cmd & mask); 541 return !pci_read_config_word(pdev, PCI_COMMAND, &cmd) && (cmd & mask);
542 } 542 }
543 543
544 #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO) 544 #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO)
545 #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) 545 #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY)
546 546
547 static void quirk_usb_handoff_uhci(struct pci_dev *pdev) 547 static void quirk_usb_handoff_uhci(struct pci_dev *pdev)
548 { 548 {
549 unsigned long base = 0; 549 unsigned long base = 0;
550 int i; 550 int i;
551 551
552 if (!pio_enabled(pdev)) 552 if (!pio_enabled(pdev))
553 return; 553 return;
554 554
555 for (i = 0; i < PCI_ROM_RESOURCE; i++) 555 for (i = 0; i < PCI_ROM_RESOURCE; i++)
556 if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) { 556 if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
557 base = pci_resource_start(pdev, i); 557 base = pci_resource_start(pdev, i);
558 break; 558 break;
559 } 559 }
560 560
561 if (base) 561 if (base)
562 uhci_check_and_reset_hc(pdev, base); 562 uhci_check_and_reset_hc(pdev, base);
563 } 563 }
564 564
565 static int mmio_resource_enabled(struct pci_dev *pdev, int idx) 565 static int mmio_resource_enabled(struct pci_dev *pdev, int idx)
566 { 566 {
567 return pci_resource_start(pdev, idx) && mmio_enabled(pdev); 567 return pci_resource_start(pdev, idx) && mmio_enabled(pdev);
568 } 568 }
569 569
570 static void quirk_usb_handoff_ohci(struct pci_dev *pdev) 570 static void quirk_usb_handoff_ohci(struct pci_dev *pdev)
571 { 571 {
572 void __iomem *base; 572 void __iomem *base;
573 u32 control; 573 u32 control;
574 u32 fminterval; 574 u32 fminterval;
575 int cnt; 575 int cnt;
576 576
577 if (!mmio_resource_enabled(pdev, 0)) 577 if (!mmio_resource_enabled(pdev, 0))
578 return; 578 return;
579 579
580 base = pci_ioremap_bar(pdev, 0); 580 base = pci_ioremap_bar(pdev, 0);
581 if (base == NULL) 581 if (base == NULL)
582 return; 582 return;
583 583
584 control = readl(base + OHCI_CONTROL); 584 control = readl(base + OHCI_CONTROL);
585 585
586 /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */ 586 /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
587 #ifdef __hppa__ 587 #ifdef __hppa__
588 #define OHCI_CTRL_MASK (OHCI_CTRL_RWC | OHCI_CTRL_IR) 588 #define OHCI_CTRL_MASK (OHCI_CTRL_RWC | OHCI_CTRL_IR)
589 #else 589 #else
590 #define OHCI_CTRL_MASK OHCI_CTRL_RWC 590 #define OHCI_CTRL_MASK OHCI_CTRL_RWC
591 591
592 if (control & OHCI_CTRL_IR) { 592 if (control & OHCI_CTRL_IR) {
593 int wait_time = 500; /* arbitrary; 5 seconds */ 593 int wait_time = 500; /* arbitrary; 5 seconds */
594 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE); 594 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
595 writel(OHCI_OCR, base + OHCI_CMDSTATUS); 595 writel(OHCI_OCR, base + OHCI_CMDSTATUS);
596 while (wait_time > 0 && 596 while (wait_time > 0 &&
597 readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) { 597 readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) {
598 wait_time -= 10; 598 wait_time -= 10;
599 msleep(10); 599 msleep(10);
600 } 600 }
601 if (wait_time <= 0) 601 if (wait_time <= 0)
602 dev_warn(&pdev->dev, "OHCI: BIOS handoff failed" 602 dev_warn(&pdev->dev, "OHCI: BIOS handoff failed"
603 " (BIOS bug?) %08x\n", 603 " (BIOS bug?) %08x\n",
604 readl(base + OHCI_CONTROL)); 604 readl(base + OHCI_CONTROL));
605 } 605 }
606 #endif 606 #endif
607 607
608 /* disable interrupts */ 608 /* disable interrupts */
609 writel((u32) ~0, base + OHCI_INTRDISABLE); 609 writel((u32) ~0, base + OHCI_INTRDISABLE);
610 610
611 /* Reset the USB bus, if the controller isn't already in RESET */ 611 /* Reset the USB bus, if the controller isn't already in RESET */
612 if (control & OHCI_HCFS) { 612 if (control & OHCI_HCFS) {
613 /* Go into RESET, preserving RWC (and possibly IR) */ 613 /* Go into RESET, preserving RWC (and possibly IR) */
614 writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL); 614 writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL);
615 readl(base + OHCI_CONTROL); 615 readl(base + OHCI_CONTROL);
616 616
617 /* drive bus reset for at least 50 ms (7.1.7.5) */ 617 /* drive bus reset for at least 50 ms (7.1.7.5) */
618 msleep(50); 618 msleep(50);
619 } 619 }
620 620
621 /* software reset of the controller, preserving HcFmInterval */ 621 /* software reset of the controller, preserving HcFmInterval */
622 fminterval = readl(base + OHCI_FMINTERVAL); 622 fminterval = readl(base + OHCI_FMINTERVAL);
623 writel(OHCI_HCR, base + OHCI_CMDSTATUS); 623 writel(OHCI_HCR, base + OHCI_CMDSTATUS);
624 624
625 /* reset requires max 10 us delay */ 625 /* reset requires max 10 us delay */
626 for (cnt = 30; cnt > 0; --cnt) { /* ... allow extra time */ 626 for (cnt = 30; cnt > 0; --cnt) { /* ... allow extra time */
627 if ((readl(base + OHCI_CMDSTATUS) & OHCI_HCR) == 0) 627 if ((readl(base + OHCI_CMDSTATUS) & OHCI_HCR) == 0)
628 break; 628 break;
629 udelay(1); 629 udelay(1);
630 } 630 }
631 writel(fminterval, base + OHCI_FMINTERVAL); 631 writel(fminterval, base + OHCI_FMINTERVAL);
632 632
633 /* Now the controller is safely in SUSPEND and nothing can wake it up */ 633 /* Now the controller is safely in SUSPEND and nothing can wake it up */
634 iounmap(base); 634 iounmap(base);
635 } 635 }
636 636
637 static const struct dmi_system_id ehci_dmi_nohandoff_table[] = { 637 static const struct dmi_system_id ehci_dmi_nohandoff_table[] = {
638 { 638 {
639 /* Pegatron Lucid (ExoPC) */ 639 /* Pegatron Lucid (ExoPC) */
640 .matches = { 640 .matches = {
641 DMI_MATCH(DMI_BOARD_NAME, "EXOPG06411"), 641 DMI_MATCH(DMI_BOARD_NAME, "EXOPG06411"),
642 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-CE-133"), 642 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-CE-133"),
643 }, 643 },
644 }, 644 },
645 { 645 {
646 /* Pegatron Lucid (Ordissimo AIRIS) */ 646 /* Pegatron Lucid (Ordissimo AIRIS) */
647 .matches = { 647 .matches = {
648 DMI_MATCH(DMI_BOARD_NAME, "M11JB"), 648 DMI_MATCH(DMI_BOARD_NAME, "M11JB"),
649 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"), 649 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"),
650 }, 650 },
651 }, 651 },
652 { 652 {
653 /* Pegatron Lucid (Ordissimo) */ 653 /* Pegatron Lucid (Ordissimo) */
654 .matches = { 654 .matches = {
655 DMI_MATCH(DMI_BOARD_NAME, "Ordissimo"), 655 DMI_MATCH(DMI_BOARD_NAME, "Ordissimo"),
656 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"), 656 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"),
657 }, 657 },
658 }, 658 },
659 { } 659 { }
660 }; 660 };
661 661
662 static void ehci_bios_handoff(struct pci_dev *pdev, 662 static void ehci_bios_handoff(struct pci_dev *pdev,
663 void __iomem *op_reg_base, 663 void __iomem *op_reg_base,
664 u32 cap, u8 offset) 664 u32 cap, u8 offset)
665 { 665 {
666 int try_handoff = 1, tried_handoff = 0; 666 int try_handoff = 1, tried_handoff = 0;
667 667
668 /* The Pegatron Lucid tablet sporadically waits for 98 seconds trying 668 /* The Pegatron Lucid tablet sporadically waits for 98 seconds trying
669 * the handoff on its unused controller. Skip it. */ 669 * the handoff on its unused controller. Skip it. */
670 if (pdev->vendor == 0x8086 && pdev->device == 0x283a) { 670 if (pdev->vendor == 0x8086 && pdev->device == 0x283a) {
671 if (dmi_check_system(ehci_dmi_nohandoff_table)) 671 if (dmi_check_system(ehci_dmi_nohandoff_table))
672 try_handoff = 0; 672 try_handoff = 0;
673 } 673 }
674 674
675 if (try_handoff && (cap & EHCI_USBLEGSUP_BIOS)) { 675 if (try_handoff && (cap & EHCI_USBLEGSUP_BIOS)) {
676 dev_dbg(&pdev->dev, "EHCI: BIOS handoff\n"); 676 dev_dbg(&pdev->dev, "EHCI: BIOS handoff\n");
677 677
678 #if 0 678 #if 0
679 /* aleksey_gorelov@phoenix.com reports that some systems need SMI forced on, 679 /* aleksey_gorelov@phoenix.com reports that some systems need SMI forced on,
680 * but that seems dubious in general (the BIOS left it off intentionally) 680 * but that seems dubious in general (the BIOS left it off intentionally)
681 * and is known to prevent some systems from booting. so we won't do this 681 * and is known to prevent some systems from booting. so we won't do this
682 * unless maybe we can determine when we're on a system that needs SMI forced. 682 * unless maybe we can determine when we're on a system that needs SMI forced.
683 */ 683 */
684 /* BIOS workaround (?): be sure the pre-Linux code 684 /* BIOS workaround (?): be sure the pre-Linux code
685 * receives the SMI 685 * receives the SMI
686 */ 686 */
687 pci_read_config_dword(pdev, offset + EHCI_USBLEGCTLSTS, &val); 687 pci_read_config_dword(pdev, offset + EHCI_USBLEGCTLSTS, &val);
688 pci_write_config_dword(pdev, offset + EHCI_USBLEGCTLSTS, 688 pci_write_config_dword(pdev, offset + EHCI_USBLEGCTLSTS,
689 val | EHCI_USBLEGCTLSTS_SOOE); 689 val | EHCI_USBLEGCTLSTS_SOOE);
690 #endif 690 #endif
691 691
692 /* some systems get upset if this semaphore is 692 /* some systems get upset if this semaphore is
693 * set for any other reason than forcing a BIOS 693 * set for any other reason than forcing a BIOS
694 * handoff.. 694 * handoff..
695 */ 695 */
696 pci_write_config_byte(pdev, offset + 3, 1); 696 pci_write_config_byte(pdev, offset + 3, 1);
697 } 697 }
698 698
699 /* if boot firmware now owns EHCI, spin till it hands it over. */ 699 /* if boot firmware now owns EHCI, spin till it hands it over. */
700 if (try_handoff) { 700 if (try_handoff) {
701 int msec = 1000; 701 int msec = 1000;
702 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) { 702 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) {
703 tried_handoff = 1; 703 tried_handoff = 1;
704 msleep(10); 704 msleep(10);
705 msec -= 10; 705 msec -= 10;
706 pci_read_config_dword(pdev, offset, &cap); 706 pci_read_config_dword(pdev, offset, &cap);
707 } 707 }
708 } 708 }
709 709
710 if (cap & EHCI_USBLEGSUP_BIOS) { 710 if (cap & EHCI_USBLEGSUP_BIOS) {
711 /* well, possibly buggy BIOS... try to shut it down, 711 /* well, possibly buggy BIOS... try to shut it down,
712 * and hope nothing goes too wrong 712 * and hope nothing goes too wrong
713 */ 713 */
714 if (try_handoff) 714 if (try_handoff)
715 dev_warn(&pdev->dev, "EHCI: BIOS handoff failed" 715 dev_warn(&pdev->dev, "EHCI: BIOS handoff failed"
716 " (BIOS bug?) %08x\n", cap); 716 " (BIOS bug?) %08x\n", cap);
717 pci_write_config_byte(pdev, offset + 2, 0); 717 pci_write_config_byte(pdev, offset + 2, 0);
718 } 718 }
719 719
720 /* just in case, always disable EHCI SMIs */ 720 /* just in case, always disable EHCI SMIs */
721 pci_write_config_dword(pdev, offset + EHCI_USBLEGCTLSTS, 0); 721 pci_write_config_dword(pdev, offset + EHCI_USBLEGCTLSTS, 0);
722 722
723 /* If the BIOS ever owned the controller then we can't expect 723 /* If the BIOS ever owned the controller then we can't expect
724 * any power sessions to remain intact. 724 * any power sessions to remain intact.
725 */ 725 */
726 if (tried_handoff) 726 if (tried_handoff)
727 writel(0, op_reg_base + EHCI_CONFIGFLAG); 727 writel(0, op_reg_base + EHCI_CONFIGFLAG);
728 } 728 }
729 729
730 static void quirk_usb_disable_ehci(struct pci_dev *pdev) 730 static void quirk_usb_disable_ehci(struct pci_dev *pdev)
731 { 731 {
732 void __iomem *base, *op_reg_base; 732 void __iomem *base, *op_reg_base;
733 u32 hcc_params, cap, val; 733 u32 hcc_params, cap, val;
734 u8 offset, cap_length; 734 u8 offset, cap_length;
735 int wait_time, count = 256/4; 735 int wait_time, count = 256/4;
736 736
737 if (!mmio_resource_enabled(pdev, 0)) 737 if (!mmio_resource_enabled(pdev, 0))
738 return; 738 return;
739 739
740 base = pci_ioremap_bar(pdev, 0); 740 base = pci_ioremap_bar(pdev, 0);
741 if (base == NULL) 741 if (base == NULL)
742 return; 742 return;
743 743
744 cap_length = readb(base); 744 cap_length = readb(base);
745 op_reg_base = base + cap_length; 745 op_reg_base = base + cap_length;
746 746
747 /* EHCI 0.96 and later may have "extended capabilities" 747 /* EHCI 0.96 and later may have "extended capabilities"
748 * spec section 5.1 explains the bios handoff, e.g. for 748 * spec section 5.1 explains the bios handoff, e.g. for
749 * booting from USB disk or using a usb keyboard 749 * booting from USB disk or using a usb keyboard
750 */ 750 */
751 hcc_params = readl(base + EHCI_HCC_PARAMS); 751 hcc_params = readl(base + EHCI_HCC_PARAMS);
752 offset = (hcc_params >> 8) & 0xff; 752 offset = (hcc_params >> 8) & 0xff;
753 while (offset && --count) { 753 while (offset && --count) {
754 pci_read_config_dword(pdev, offset, &cap); 754 pci_read_config_dword(pdev, offset, &cap);
755 755
756 switch (cap & 0xff) { 756 switch (cap & 0xff) {
757 case 1: 757 case 1:
758 ehci_bios_handoff(pdev, op_reg_base, cap, offset); 758 ehci_bios_handoff(pdev, op_reg_base, cap, offset);
759 break; 759 break;
760 case 0: /* Illegal reserved cap, set cap=0 so we exit */ 760 case 0: /* Illegal reserved cap, set cap=0 so we exit */
761 cap = 0; /* then fallthrough... */ 761 cap = 0; /* then fallthrough... */
762 default: 762 default:
763 dev_warn(&pdev->dev, "EHCI: unrecognized capability " 763 dev_warn(&pdev->dev, "EHCI: unrecognized capability "
764 "%02x\n", cap & 0xff); 764 "%02x\n", cap & 0xff);
765 } 765 }
766 offset = (cap >> 8) & 0xff; 766 offset = (cap >> 8) & 0xff;
767 } 767 }
768 if (!count) 768 if (!count)
769 dev_printk(KERN_DEBUG, &pdev->dev, "EHCI: capability loop?\n"); 769 dev_printk(KERN_DEBUG, &pdev->dev, "EHCI: capability loop?\n");
770 770
771 /* 771 /*
772 * halt EHCI & disable its interrupts in any case 772 * halt EHCI & disable its interrupts in any case
773 */ 773 */
774 val = readl(op_reg_base + EHCI_USBSTS); 774 val = readl(op_reg_base + EHCI_USBSTS);
775 if ((val & EHCI_USBSTS_HALTED) == 0) { 775 if ((val & EHCI_USBSTS_HALTED) == 0) {
776 val = readl(op_reg_base + EHCI_USBCMD); 776 val = readl(op_reg_base + EHCI_USBCMD);
777 val &= ~EHCI_USBCMD_RUN; 777 val &= ~EHCI_USBCMD_RUN;
778 writel(val, op_reg_base + EHCI_USBCMD); 778 writel(val, op_reg_base + EHCI_USBCMD);
779 779
780 wait_time = 2000; 780 wait_time = 2000;
781 do { 781 do {
782 writel(0x3f, op_reg_base + EHCI_USBSTS); 782 writel(0x3f, op_reg_base + EHCI_USBSTS);
783 udelay(100); 783 udelay(100);
784 wait_time -= 100; 784 wait_time -= 100;
785 val = readl(op_reg_base + EHCI_USBSTS); 785 val = readl(op_reg_base + EHCI_USBSTS);
786 if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) { 786 if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) {
787 break; 787 break;
788 } 788 }
789 } while (wait_time > 0); 789 } while (wait_time > 0);
790 } 790 }
791 writel(0, op_reg_base + EHCI_USBINTR); 791 writel(0, op_reg_base + EHCI_USBINTR);
792 writel(0x3f, op_reg_base + EHCI_USBSTS); 792 writel(0x3f, op_reg_base + EHCI_USBSTS);
793 793
794 iounmap(base); 794 iounmap(base);
795 } 795 }
796 796
797 /* 797 /*
798 * handshake - spin reading a register until handshake completes 798 * handshake - spin reading a register until handshake completes
799 * @ptr: address of hc register to be read 799 * @ptr: address of hc register to be read
800 * @mask: bits to look at in result of read 800 * @mask: bits to look at in result of read
801 * @done: value of those bits when handshake succeeds 801 * @done: value of those bits when handshake succeeds
802 * @wait_usec: timeout in microseconds 802 * @wait_usec: timeout in microseconds
803 * @delay_usec: delay in microseconds to wait between polling 803 * @delay_usec: delay in microseconds to wait between polling
804 * 804 *
805 * Polls a register every delay_usec microseconds. 805 * Polls a register every delay_usec microseconds.
806 * Returns 0 when the mask bits have the value done. 806 * Returns 0 when the mask bits have the value done.
807 * Returns -ETIMEDOUT if this condition is not true after 807 * Returns -ETIMEDOUT if this condition is not true after
808 * wait_usec microseconds have passed. 808 * wait_usec microseconds have passed.
809 */ 809 */
810 static int handshake(void __iomem *ptr, u32 mask, u32 done, 810 static int handshake(void __iomem *ptr, u32 mask, u32 done,
811 int wait_usec, int delay_usec) 811 int wait_usec, int delay_usec)
812 { 812 {
813 u32 result; 813 u32 result;
814 814
815 do { 815 do {
816 result = readl(ptr); 816 result = readl(ptr);
817 result &= mask; 817 result &= mask;
818 if (result == done) 818 if (result == done)
819 return 0; 819 return 0;
820 udelay(delay_usec); 820 udelay(delay_usec);
821 wait_usec -= delay_usec; 821 wait_usec -= delay_usec;
822 } while (wait_usec > 0); 822 } while (wait_usec > 0);
823 return -ETIMEDOUT; 823 return -ETIMEDOUT;
824 } 824 }
825 825
826 /* 826 /*
827 * Intel's Panther Point chipset has two host controllers (EHCI and xHCI) that 827 * Intel's Panther Point chipset has two host controllers (EHCI and xHCI) that
828 * share some number of ports. These ports can be switched between either 828 * share some number of ports. These ports can be switched between either
829 * controller. Not all of the ports under the EHCI host controller may be 829 * controller. Not all of the ports under the EHCI host controller may be
830 * switchable. 830 * switchable.
831 * 831 *
832 * The ports should be switched over to xHCI before PCI probes for any device 832 * The ports should be switched over to xHCI before PCI probes for any device
833 * start. This avoids active devices under EHCI being disconnected during the 833 * start. This avoids active devices under EHCI being disconnected during the
834 * port switchover, which could cause loss of data on USB storage devices, or 834 * port switchover, which could cause loss of data on USB storage devices, or
835 * failed boot when the root file system is on a USB mass storage device and is 835 * failed boot when the root file system is on a USB mass storage device and is
836 * enumerated under EHCI first. 836 * enumerated under EHCI first.
837 * 837 *
838 * We write into the xHC's PCI configuration space in some Intel-specific 838 * We write into the xHC's PCI configuration space in some Intel-specific
839 * registers to switch the ports over. The USB 3.0 terminations and the USB 839 * registers to switch the ports over. The USB 3.0 terminations and the USB
840 * 2.0 data wires are switched separately. We want to enable the SuperSpeed 840 * 2.0 data wires are switched separately. We want to enable the SuperSpeed
841 * terminations before switching the USB 2.0 wires over, so that USB 3.0 841 * terminations before switching the USB 2.0 wires over, so that USB 3.0
842 * devices connect at SuperSpeed, rather than at USB 2.0 speeds. 842 * devices connect at SuperSpeed, rather than at USB 2.0 speeds.
843 */ 843 */
844 void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) 844 void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
845 { 845 {
846 u32 ports_available; 846 u32 ports_available;
847 bool ehci_found = false; 847 bool ehci_found = false;
848 struct pci_dev *companion = NULL; 848 struct pci_dev *companion = NULL;
849 849
850 /* Sony VAIO t-series with subsystem device ID 90a8 is not capable of
851 * switching ports from EHCI to xHCI
852 */
853 if (xhci_pdev->subsystem_vendor == PCI_VENDOR_ID_SONY &&
854 xhci_pdev->subsystem_device == 0x90a8)
855 return;
856
850 /* make sure an intel EHCI controller exists */ 857 /* make sure an intel EHCI controller exists */
851 for_each_pci_dev(companion) { 858 for_each_pci_dev(companion) {
852 if (companion->class == PCI_CLASS_SERIAL_USB_EHCI && 859 if (companion->class == PCI_CLASS_SERIAL_USB_EHCI &&
853 companion->vendor == PCI_VENDOR_ID_INTEL) { 860 companion->vendor == PCI_VENDOR_ID_INTEL) {
854 ehci_found = true; 861 ehci_found = true;
855 break; 862 break;
856 } 863 }
857 } 864 }
858 865
859 if (!ehci_found) 866 if (!ehci_found)
860 return; 867 return;
861 868
862 /* Don't switchover the ports if the user hasn't compiled the xHCI 869 /* Don't switchover the ports if the user hasn't compiled the xHCI
863 * driver. Otherwise they will see "dead" USB ports that don't power 870 * driver. Otherwise they will see "dead" USB ports that don't power
864 * the devices. 871 * the devices.
865 */ 872 */
866 if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) { 873 if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) {
867 dev_warn(&xhci_pdev->dev, 874 dev_warn(&xhci_pdev->dev,
868 "CONFIG_USB_XHCI_HCD is turned off, " 875 "CONFIG_USB_XHCI_HCD is turned off, "
869 "defaulting to EHCI.\n"); 876 "defaulting to EHCI.\n");
870 dev_warn(&xhci_pdev->dev, 877 dev_warn(&xhci_pdev->dev,
871 "USB 3.0 devices will work at USB 2.0 speeds.\n"); 878 "USB 3.0 devices will work at USB 2.0 speeds.\n");
872 usb_disable_xhci_ports(xhci_pdev); 879 usb_disable_xhci_ports(xhci_pdev);
873 return; 880 return;
874 } 881 }
875 882
876 /* Read USB3PRM, the USB 3.0 Port Routing Mask Register 883 /* Read USB3PRM, the USB 3.0 Port Routing Mask Register
877 * Indicate the ports that can be changed from OS. 884 * Indicate the ports that can be changed from OS.
878 */ 885 */
879 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3PRM, 886 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3PRM,
880 &ports_available); 887 &ports_available);
881 888
882 dev_dbg(&xhci_pdev->dev, "Configurable ports to enable SuperSpeed: 0x%x\n", 889 dev_dbg(&xhci_pdev->dev, "Configurable ports to enable SuperSpeed: 0x%x\n",
883 ports_available); 890 ports_available);
884 891
885 /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable 892 /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable
886 * Register, to turn on SuperSpeed terminations for the 893 * Register, to turn on SuperSpeed terminations for the
887 * switchable ports. 894 * switchable ports.
888 */ 895 */
889 pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, 896 pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
890 ports_available); 897 ports_available);
891 898
892 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, 899 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
893 &ports_available); 900 &ports_available);
894 dev_dbg(&xhci_pdev->dev, "USB 3.0 ports that are now enabled " 901 dev_dbg(&xhci_pdev->dev, "USB 3.0 ports that are now enabled "
895 "under xHCI: 0x%x\n", ports_available); 902 "under xHCI: 0x%x\n", ports_available);
896 903
897 /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register 904 /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register
898 * Indicate the USB 2.0 ports to be controlled by the xHCI host. 905 * Indicate the USB 2.0 ports to be controlled by the xHCI host.
899 */ 906 */
900 907
901 pci_read_config_dword(xhci_pdev, USB_INTEL_USB2PRM, 908 pci_read_config_dword(xhci_pdev, USB_INTEL_USB2PRM,
902 &ports_available); 909 &ports_available);
903 910
904 dev_dbg(&xhci_pdev->dev, "Configurable USB 2.0 ports to hand over to xCHI: 0x%x\n", 911 dev_dbg(&xhci_pdev->dev, "Configurable USB 2.0 ports to hand over to xCHI: 0x%x\n",
905 ports_available); 912 ports_available);
906 913
907 /* Write XUSB2PR, the xHC USB 2.0 Port Routing Register, to 914 /* Write XUSB2PR, the xHC USB 2.0 Port Routing Register, to
908 * switch the USB 2.0 power and data lines over to the xHCI 915 * switch the USB 2.0 power and data lines over to the xHCI
909 * host. 916 * host.
910 */ 917 */
911 pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, 918 pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
912 ports_available); 919 ports_available);
913 920
914 pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, 921 pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
915 &ports_available); 922 &ports_available);
916 dev_dbg(&xhci_pdev->dev, "USB 2.0 ports that are now switched over " 923 dev_dbg(&xhci_pdev->dev, "USB 2.0 ports that are now switched over "
917 "to xHCI: 0x%x\n", ports_available); 924 "to xHCI: 0x%x\n", ports_available);
918 } 925 }
919 EXPORT_SYMBOL_GPL(usb_enable_intel_xhci_ports); 926 EXPORT_SYMBOL_GPL(usb_enable_intel_xhci_ports);
920 927
921 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) 928 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev)
922 { 929 {
923 pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, 0x0); 930 pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, 0x0);
924 pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, 0x0); 931 pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, 0x0);
925 } 932 }
926 EXPORT_SYMBOL_GPL(usb_disable_xhci_ports); 933 EXPORT_SYMBOL_GPL(usb_disable_xhci_ports);
927 934
928 /** 935 /**
929 * PCI Quirks for xHCI. 936 * PCI Quirks for xHCI.
930 * 937 *
931 * Takes care of the handoff between the Pre-OS (i.e. BIOS) and the OS. 938 * Takes care of the handoff between the Pre-OS (i.e. BIOS) and the OS.
932 * It signals to the BIOS that the OS wants control of the host controller, 939 * It signals to the BIOS that the OS wants control of the host controller,
933 * and then waits 5 seconds for the BIOS to hand over control. 940 * and then waits 5 seconds for the BIOS to hand over control.
934 * If we timeout, assume the BIOS is broken and take control anyway. 941 * If we timeout, assume the BIOS is broken and take control anyway.
935 */ 942 */
936 static void quirk_usb_handoff_xhci(struct pci_dev *pdev) 943 static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
937 { 944 {
938 void __iomem *base; 945 void __iomem *base;
939 int ext_cap_offset; 946 int ext_cap_offset;
940 void __iomem *op_reg_base; 947 void __iomem *op_reg_base;
941 u32 val; 948 u32 val;
942 int timeout; 949 int timeout;
943 int len = pci_resource_len(pdev, 0); 950 int len = pci_resource_len(pdev, 0);
944 951
945 if (!mmio_resource_enabled(pdev, 0)) 952 if (!mmio_resource_enabled(pdev, 0))
946 return; 953 return;
947 954
948 base = ioremap_nocache(pci_resource_start(pdev, 0), len); 955 base = ioremap_nocache(pci_resource_start(pdev, 0), len);
949 if (base == NULL) 956 if (base == NULL)
950 return; 957 return;
951 958
952 /* 959 /*
953 * Find the Legacy Support Capability register - 960 * Find the Legacy Support Capability register -
954 * this is optional for xHCI host controllers. 961 * this is optional for xHCI host controllers.
955 */ 962 */
956 ext_cap_offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET); 963 ext_cap_offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET);
957 do { 964 do {
958 if ((ext_cap_offset + sizeof(val)) > len) { 965 if ((ext_cap_offset + sizeof(val)) > len) {
959 /* We're reading garbage from the controller */ 966 /* We're reading garbage from the controller */
960 dev_warn(&pdev->dev, 967 dev_warn(&pdev->dev,
961 "xHCI controller failing to respond"); 968 "xHCI controller failing to respond");
962 return; 969 return;
963 } 970 }
964 971
965 if (!ext_cap_offset) 972 if (!ext_cap_offset)
966 /* We've reached the end of the extended capabilities */ 973 /* We've reached the end of the extended capabilities */
967 goto hc_init; 974 goto hc_init;
968 975
969 val = readl(base + ext_cap_offset); 976 val = readl(base + ext_cap_offset);
970 if (XHCI_EXT_CAPS_ID(val) == XHCI_EXT_CAPS_LEGACY) 977 if (XHCI_EXT_CAPS_ID(val) == XHCI_EXT_CAPS_LEGACY)
971 break; 978 break;
972 ext_cap_offset = xhci_find_next_cap_offset(base, ext_cap_offset); 979 ext_cap_offset = xhci_find_next_cap_offset(base, ext_cap_offset);
973 } while (1); 980 } while (1);
974 981
975 /* If the BIOS owns the HC, signal that the OS wants it, and wait */ 982 /* If the BIOS owns the HC, signal that the OS wants it, and wait */
976 if (val & XHCI_HC_BIOS_OWNED) { 983 if (val & XHCI_HC_BIOS_OWNED) {
977 writel(val | XHCI_HC_OS_OWNED, base + ext_cap_offset); 984 writel(val | XHCI_HC_OS_OWNED, base + ext_cap_offset);
978 985
979 /* Wait for 5 seconds with 10 microsecond polling interval */ 986 /* Wait for 5 seconds with 10 microsecond polling interval */
980 timeout = handshake(base + ext_cap_offset, XHCI_HC_BIOS_OWNED, 987 timeout = handshake(base + ext_cap_offset, XHCI_HC_BIOS_OWNED,
981 0, 5000, 10); 988 0, 5000, 10);
982 989
983 /* Assume a buggy BIOS and take HC ownership anyway */ 990 /* Assume a buggy BIOS and take HC ownership anyway */
984 if (timeout) { 991 if (timeout) {
985 dev_warn(&pdev->dev, "xHCI BIOS handoff failed" 992 dev_warn(&pdev->dev, "xHCI BIOS handoff failed"
986 " (BIOS bug ?) %08x\n", val); 993 " (BIOS bug ?) %08x\n", val);
987 writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset); 994 writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset);
988 } 995 }
989 } 996 }
990 997
991 val = readl(base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET); 998 val = readl(base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
992 /* Mask off (turn off) any enabled SMIs */ 999 /* Mask off (turn off) any enabled SMIs */
993 val &= XHCI_LEGACY_DISABLE_SMI; 1000 val &= XHCI_LEGACY_DISABLE_SMI;
994 /* Mask all SMI events bits, RW1C */ 1001 /* Mask all SMI events bits, RW1C */
995 val |= XHCI_LEGACY_SMI_EVENTS; 1002 val |= XHCI_LEGACY_SMI_EVENTS;
996 /* Disable any BIOS SMIs and clear all SMI events*/ 1003 /* Disable any BIOS SMIs and clear all SMI events*/
997 writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET); 1004 writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
998 1005
999 hc_init: 1006 hc_init:
1000 if (pdev->vendor == PCI_VENDOR_ID_INTEL) 1007 if (pdev->vendor == PCI_VENDOR_ID_INTEL)
1001 usb_enable_intel_xhci_ports(pdev); 1008 usb_enable_intel_xhci_ports(pdev);
1002 1009
1003 op_reg_base = base + XHCI_HC_LENGTH(readl(base)); 1010 op_reg_base = base + XHCI_HC_LENGTH(readl(base));
1004 1011
1005 /* Wait for the host controller to be ready before writing any 1012 /* Wait for the host controller to be ready before writing any
1006 * operational or runtime registers. Wait 5 seconds and no more. 1013 * operational or runtime registers. Wait 5 seconds and no more.
1007 */ 1014 */
1008 timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_CNR, 0, 1015 timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_CNR, 0,
1009 5000, 10); 1016 5000, 10);
1010 /* Assume a buggy HC and start HC initialization anyway */ 1017 /* Assume a buggy HC and start HC initialization anyway */
1011 if (timeout) { 1018 if (timeout) {
1012 val = readl(op_reg_base + XHCI_STS_OFFSET); 1019 val = readl(op_reg_base + XHCI_STS_OFFSET);
1013 dev_warn(&pdev->dev, 1020 dev_warn(&pdev->dev,
1014 "xHCI HW not ready after 5 sec (HC bug?) " 1021 "xHCI HW not ready after 5 sec (HC bug?) "
1015 "status = 0x%x\n", val); 1022 "status = 0x%x\n", val);
1016 } 1023 }
1017 1024
1018 /* Send the halt and disable interrupts command */ 1025 /* Send the halt and disable interrupts command */
1019 val = readl(op_reg_base + XHCI_CMD_OFFSET); 1026 val = readl(op_reg_base + XHCI_CMD_OFFSET);
1020 val &= ~(XHCI_CMD_RUN | XHCI_IRQS); 1027 val &= ~(XHCI_CMD_RUN | XHCI_IRQS);
1021 writel(val, op_reg_base + XHCI_CMD_OFFSET); 1028 writel(val, op_reg_base + XHCI_CMD_OFFSET);
1022 1029
1023 /* Wait for the HC to halt - poll every 125 usec (one microframe). */ 1030 /* Wait for the HC to halt - poll every 125 usec (one microframe). */
1024 timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_HALT, 1, 1031 timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_HALT, 1,
1025 XHCI_MAX_HALT_USEC, 125); 1032 XHCI_MAX_HALT_USEC, 125);
1026 if (timeout) { 1033 if (timeout) {
1027 val = readl(op_reg_base + XHCI_STS_OFFSET); 1034 val = readl(op_reg_base + XHCI_STS_OFFSET);
1028 dev_warn(&pdev->dev, 1035 dev_warn(&pdev->dev,
1029 "xHCI HW did not halt within %d usec " 1036 "xHCI HW did not halt within %d usec "
1030 "status = 0x%x\n", XHCI_MAX_HALT_USEC, val); 1037 "status = 0x%x\n", XHCI_MAX_HALT_USEC, val);
1031 } 1038 }
1032 1039
1033 iounmap(base); 1040 iounmap(base);
1034 } 1041 }
1035 1042
1036 static void quirk_usb_early_handoff(struct pci_dev *pdev) 1043 static void quirk_usb_early_handoff(struct pci_dev *pdev)
1037 { 1044 {
1038 /* Skip Netlogic mips SoC's internal PCI USB controller. 1045 /* Skip Netlogic mips SoC's internal PCI USB controller.
1039 * This device does not need/support EHCI/OHCI handoff 1046 * This device does not need/support EHCI/OHCI handoff
1040 */ 1047 */
1041 if (pdev->vendor == 0x184e) /* vendor Netlogic */ 1048 if (pdev->vendor == 0x184e) /* vendor Netlogic */
1042 return; 1049 return;
1043 if (pdev->class != PCI_CLASS_SERIAL_USB_UHCI && 1050 if (pdev->class != PCI_CLASS_SERIAL_USB_UHCI &&
1044 pdev->class != PCI_CLASS_SERIAL_USB_OHCI && 1051 pdev->class != PCI_CLASS_SERIAL_USB_OHCI &&
1045 pdev->class != PCI_CLASS_SERIAL_USB_EHCI && 1052 pdev->class != PCI_CLASS_SERIAL_USB_EHCI &&
1046 pdev->class != PCI_CLASS_SERIAL_USB_XHCI) 1053 pdev->class != PCI_CLASS_SERIAL_USB_XHCI)
1047 return; 1054 return;
1048 1055
1049 if (pci_enable_device(pdev) < 0) { 1056 if (pci_enable_device(pdev) < 0) {
1050 dev_warn(&pdev->dev, "Can't enable PCI device, " 1057 dev_warn(&pdev->dev, "Can't enable PCI device, "
1051 "BIOS handoff failed.\n"); 1058 "BIOS handoff failed.\n");
1052 return; 1059 return;
1053 } 1060 }
1054 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI) 1061 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI)
1055 quirk_usb_handoff_uhci(pdev); 1062 quirk_usb_handoff_uhci(pdev);
1056 else if (pdev->class == PCI_CLASS_SERIAL_USB_OHCI) 1063 else if (pdev->class == PCI_CLASS_SERIAL_USB_OHCI)
1057 quirk_usb_handoff_ohci(pdev); 1064 quirk_usb_handoff_ohci(pdev);
1058 else if (pdev->class == PCI_CLASS_SERIAL_USB_EHCI) 1065 else if (pdev->class == PCI_CLASS_SERIAL_USB_EHCI)
1059 quirk_usb_disable_ehci(pdev); 1066 quirk_usb_disable_ehci(pdev);
1060 else if (pdev->class == PCI_CLASS_SERIAL_USB_XHCI) 1067 else if (pdev->class == PCI_CLASS_SERIAL_USB_XHCI)
1061 quirk_usb_handoff_xhci(pdev); 1068 quirk_usb_handoff_xhci(pdev);
1062 pci_disable_device(pdev); 1069 pci_disable_device(pdev);
1063 } 1070 }
1064 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, 1071 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
1065 PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff); 1072 PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
1066 1073
drivers/usb/host/xhci-mem.c
1 /* 1 /*
2 * xHCI host controller driver 2 * xHCI host controller driver
3 * 3 *
4 * Copyright (C) 2008 Intel Corp. 4 * Copyright (C) 2008 Intel Corp.
5 * 5 *
6 * Author: Sarah Sharp 6 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver. 7 * Some code borrowed from the Linux EHCI driver.
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, but 13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details. 16 * for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation, 19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 21 */
22 22
23 #include <linux/usb.h> 23 #include <linux/usb.h>
24 #include <linux/pci.h> 24 #include <linux/pci.h>
25 #include <linux/slab.h> 25 #include <linux/slab.h>
26 #include <linux/dmapool.h> 26 #include <linux/dmapool.h>
27 #include <linux/dma-mapping.h> 27 #include <linux/dma-mapping.h>
28 28
29 #include "xhci.h" 29 #include "xhci.h"
30 #include "xhci-trace.h" 30 #include "xhci-trace.h"
31 31
32 /* 32 /*
33 * Allocates a generic ring segment from the ring pool, sets the dma address, 33 * Allocates a generic ring segment from the ring pool, sets the dma address,
34 * initializes the segment to zero, and sets the private next pointer to NULL. 34 * initializes the segment to zero, and sets the private next pointer to NULL.
35 * 35 *
36 * Section 4.11.1.1: 36 * Section 4.11.1.1:
37 * "All components of all Command and Transfer TRBs shall be initialized to '0'" 37 * "All components of all Command and Transfer TRBs shall be initialized to '0'"
38 */ 38 */
39 static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, 39 static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
40 unsigned int cycle_state, gfp_t flags) 40 unsigned int cycle_state, gfp_t flags)
41 { 41 {
42 struct xhci_segment *seg; 42 struct xhci_segment *seg;
43 dma_addr_t dma; 43 dma_addr_t dma;
44 int i; 44 int i;
45 45
46 seg = kzalloc(sizeof *seg, flags); 46 seg = kzalloc(sizeof *seg, flags);
47 if (!seg) 47 if (!seg)
48 return NULL; 48 return NULL;
49 49
50 seg->trbs = dma_pool_alloc(xhci->segment_pool, flags, &dma); 50 seg->trbs = dma_pool_alloc(xhci->segment_pool, flags, &dma);
51 if (!seg->trbs) { 51 if (!seg->trbs) {
52 kfree(seg); 52 kfree(seg);
53 return NULL; 53 return NULL;
54 } 54 }
55 55
56 memset(seg->trbs, 0, TRB_SEGMENT_SIZE); 56 memset(seg->trbs, 0, TRB_SEGMENT_SIZE);
57 /* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */ 57 /* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */
58 if (cycle_state == 0) { 58 if (cycle_state == 0) {
59 for (i = 0; i < TRBS_PER_SEGMENT; i++) 59 for (i = 0; i < TRBS_PER_SEGMENT; i++)
60 seg->trbs[i].link.control |= cpu_to_le32(TRB_CYCLE); 60 seg->trbs[i].link.control |= cpu_to_le32(TRB_CYCLE);
61 } 61 }
62 seg->dma = dma; 62 seg->dma = dma;
63 seg->next = NULL; 63 seg->next = NULL;
64 64
65 return seg; 65 return seg;
66 } 66 }
67 67
68 static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg) 68 static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg)
69 { 69 {
70 if (seg->trbs) { 70 if (seg->trbs) {
71 dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma); 71 dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma);
72 seg->trbs = NULL; 72 seg->trbs = NULL;
73 } 73 }
74 kfree(seg); 74 kfree(seg);
75 } 75 }
76 76
77 static void xhci_free_segments_for_ring(struct xhci_hcd *xhci, 77 static void xhci_free_segments_for_ring(struct xhci_hcd *xhci,
78 struct xhci_segment *first) 78 struct xhci_segment *first)
79 { 79 {
80 struct xhci_segment *seg; 80 struct xhci_segment *seg;
81 81
82 seg = first->next; 82 seg = first->next;
83 while (seg != first) { 83 while (seg != first) {
84 struct xhci_segment *next = seg->next; 84 struct xhci_segment *next = seg->next;
85 xhci_segment_free(xhci, seg); 85 xhci_segment_free(xhci, seg);
86 seg = next; 86 seg = next;
87 } 87 }
88 xhci_segment_free(xhci, first); 88 xhci_segment_free(xhci, first);
89 } 89 }
90 90
91 /* 91 /*
92 * Make the prev segment point to the next segment. 92 * Make the prev segment point to the next segment.
93 * 93 *
94 * Change the last TRB in the prev segment to be a Link TRB which points to the 94 * Change the last TRB in the prev segment to be a Link TRB which points to the
95 * DMA address of the next segment. The caller needs to set any Link TRB 95 * DMA address of the next segment. The caller needs to set any Link TRB
96 * related flags, such as End TRB, Toggle Cycle, and no snoop. 96 * related flags, such as End TRB, Toggle Cycle, and no snoop.
97 */ 97 */
98 static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, 98 static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev,
99 struct xhci_segment *next, enum xhci_ring_type type) 99 struct xhci_segment *next, enum xhci_ring_type type)
100 { 100 {
101 u32 val; 101 u32 val;
102 102
103 if (!prev || !next) 103 if (!prev || !next)
104 return; 104 return;
105 prev->next = next; 105 prev->next = next;
106 if (type != TYPE_EVENT) { 106 if (type != TYPE_EVENT) {
107 prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr = 107 prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr =
108 cpu_to_le64(next->dma); 108 cpu_to_le64(next->dma);
109 109
110 /* Set the last TRB in the segment to have a TRB type ID of Link TRB */ 110 /* Set the last TRB in the segment to have a TRB type ID of Link TRB */
111 val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control); 111 val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control);
112 val &= ~TRB_TYPE_BITMASK; 112 val &= ~TRB_TYPE_BITMASK;
113 val |= TRB_TYPE(TRB_LINK); 113 val |= TRB_TYPE(TRB_LINK);
114 /* Always set the chain bit with 0.95 hardware */ 114 /* Always set the chain bit with 0.95 hardware */
115 /* Set chain bit for isoc rings on AMD 0.96 host */ 115 /* Set chain bit for isoc rings on AMD 0.96 host */
116 if (xhci_link_trb_quirk(xhci) || 116 if (xhci_link_trb_quirk(xhci) ||
117 (type == TYPE_ISOC && 117 (type == TYPE_ISOC &&
118 (xhci->quirks & XHCI_AMD_0x96_HOST))) 118 (xhci->quirks & XHCI_AMD_0x96_HOST)))
119 val |= TRB_CHAIN; 119 val |= TRB_CHAIN;
120 prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); 120 prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val);
121 } 121 }
122 } 122 }
123 123
124 /* 124 /*
125 * Link the ring to the new segments. 125 * Link the ring to the new segments.
126 * Set Toggle Cycle for the new ring if needed. 126 * Set Toggle Cycle for the new ring if needed.
127 */ 127 */
128 static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, 128 static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring,
129 struct xhci_segment *first, struct xhci_segment *last, 129 struct xhci_segment *first, struct xhci_segment *last,
130 unsigned int num_segs) 130 unsigned int num_segs)
131 { 131 {
132 struct xhci_segment *next; 132 struct xhci_segment *next;
133 133
134 if (!ring || !first || !last) 134 if (!ring || !first || !last)
135 return; 135 return;
136 136
137 next = ring->enq_seg->next; 137 next = ring->enq_seg->next;
138 xhci_link_segments(xhci, ring->enq_seg, first, ring->type); 138 xhci_link_segments(xhci, ring->enq_seg, first, ring->type);
139 xhci_link_segments(xhci, last, next, ring->type); 139 xhci_link_segments(xhci, last, next, ring->type);
140 ring->num_segs += num_segs; 140 ring->num_segs += num_segs;
141 ring->num_trbs_free += (TRBS_PER_SEGMENT - 1) * num_segs; 141 ring->num_trbs_free += (TRBS_PER_SEGMENT - 1) * num_segs;
142 142
143 if (ring->type != TYPE_EVENT && ring->enq_seg == ring->last_seg) { 143 if (ring->type != TYPE_EVENT && ring->enq_seg == ring->last_seg) {
144 ring->last_seg->trbs[TRBS_PER_SEGMENT-1].link.control 144 ring->last_seg->trbs[TRBS_PER_SEGMENT-1].link.control
145 &= ~cpu_to_le32(LINK_TOGGLE); 145 &= ~cpu_to_le32(LINK_TOGGLE);
146 last->trbs[TRBS_PER_SEGMENT-1].link.control 146 last->trbs[TRBS_PER_SEGMENT-1].link.control
147 |= cpu_to_le32(LINK_TOGGLE); 147 |= cpu_to_le32(LINK_TOGGLE);
148 ring->last_seg = last; 148 ring->last_seg = last;
149 } 149 }
150 } 150 }
151 151
152 /* 152 /*
153 * We need a radix tree for mapping physical addresses of TRBs to which stream 153 * We need a radix tree for mapping physical addresses of TRBs to which stream
154 * ID they belong to. We need to do this because the host controller won't tell 154 * ID they belong to. We need to do this because the host controller won't tell
155 * us which stream ring the TRB came from. We could store the stream ID in an 155 * us which stream ring the TRB came from. We could store the stream ID in an
156 * event data TRB, but that doesn't help us for the cancellation case, since the 156 * event data TRB, but that doesn't help us for the cancellation case, since the
157 * endpoint may stop before it reaches that event data TRB. 157 * endpoint may stop before it reaches that event data TRB.
158 * 158 *
159 * The radix tree maps the upper portion of the TRB DMA address to a ring 159 * The radix tree maps the upper portion of the TRB DMA address to a ring
160 * segment that has the same upper portion of DMA addresses. For example, say I 160 * segment that has the same upper portion of DMA addresses. For example, say I
161 * have segments of size 1KB, that are always 1KB aligned. A segment may 161 * have segments of size 1KB, that are always 1KB aligned. A segment may
162 * start at 0x10c91000 and end at 0x10c913f0. If I use the upper 10 bits, the 162 * start at 0x10c91000 and end at 0x10c913f0. If I use the upper 10 bits, the
163 * key to the stream ID is 0x43244. I can use the DMA address of the TRB to 163 * key to the stream ID is 0x43244. I can use the DMA address of the TRB to
164 * pass the radix tree a key to get the right stream ID: 164 * pass the radix tree a key to get the right stream ID:
165 * 165 *
166 * 0x10c90fff >> 10 = 0x43243 166 * 0x10c90fff >> 10 = 0x43243
167 * 0x10c912c0 >> 10 = 0x43244 167 * 0x10c912c0 >> 10 = 0x43244
168 * 0x10c91400 >> 10 = 0x43245 168 * 0x10c91400 >> 10 = 0x43245
169 * 169 *
170 * Obviously, only those TRBs with DMA addresses that are within the segment 170 * Obviously, only those TRBs with DMA addresses that are within the segment
171 * will make the radix tree return the stream ID for that ring. 171 * will make the radix tree return the stream ID for that ring.
172 * 172 *
173 * Caveats for the radix tree: 173 * Caveats for the radix tree:
174 * 174 *
175 * The radix tree uses an unsigned long as a key pair. On 32-bit systems, an 175 * The radix tree uses an unsigned long as a key pair. On 32-bit systems, an
176 * unsigned long will be 32-bits; on a 64-bit system an unsigned long will be 176 * unsigned long will be 32-bits; on a 64-bit system an unsigned long will be
177 * 64-bits. Since we only request 32-bit DMA addresses, we can use that as the 177 * 64-bits. Since we only request 32-bit DMA addresses, we can use that as the
178 * key on 32-bit or 64-bit systems (it would also be fine if we asked for 64-bit 178 * key on 32-bit or 64-bit systems (it would also be fine if we asked for 64-bit
179 * PCI DMA addresses on a 64-bit system). There might be a problem on 32-bit 179 * PCI DMA addresses on a 64-bit system). There might be a problem on 32-bit
180 * extended systems (where the DMA address can be bigger than 32-bits), 180 * extended systems (where the DMA address can be bigger than 32-bits),
181 * if we allow the PCI dma mask to be bigger than 32-bits. So don't do that. 181 * if we allow the PCI dma mask to be bigger than 32-bits. So don't do that.
182 */ 182 */
183 static int xhci_insert_segment_mapping(struct radix_tree_root *trb_address_map, 183 static int xhci_insert_segment_mapping(struct radix_tree_root *trb_address_map,
184 struct xhci_ring *ring, 184 struct xhci_ring *ring,
185 struct xhci_segment *seg, 185 struct xhci_segment *seg,
186 gfp_t mem_flags) 186 gfp_t mem_flags)
187 { 187 {
188 unsigned long key; 188 unsigned long key;
189 int ret; 189 int ret;
190 190
191 key = (unsigned long)(seg->dma >> TRB_SEGMENT_SHIFT); 191 key = (unsigned long)(seg->dma >> TRB_SEGMENT_SHIFT);
192 /* Skip any segments that were already added. */ 192 /* Skip any segments that were already added. */
193 if (radix_tree_lookup(trb_address_map, key)) 193 if (radix_tree_lookup(trb_address_map, key))
194 return 0; 194 return 0;
195 195
196 ret = radix_tree_maybe_preload(mem_flags); 196 ret = radix_tree_maybe_preload(mem_flags);
197 if (ret) 197 if (ret)
198 return ret; 198 return ret;
199 ret = radix_tree_insert(trb_address_map, 199 ret = radix_tree_insert(trb_address_map,
200 key, ring); 200 key, ring);
201 radix_tree_preload_end(); 201 radix_tree_preload_end();
202 return ret; 202 return ret;
203 } 203 }
204 204
205 static void xhci_remove_segment_mapping(struct radix_tree_root *trb_address_map, 205 static void xhci_remove_segment_mapping(struct radix_tree_root *trb_address_map,
206 struct xhci_segment *seg) 206 struct xhci_segment *seg)
207 { 207 {
208 unsigned long key; 208 unsigned long key;
209 209
210 key = (unsigned long)(seg->dma >> TRB_SEGMENT_SHIFT); 210 key = (unsigned long)(seg->dma >> TRB_SEGMENT_SHIFT);
211 if (radix_tree_lookup(trb_address_map, key)) 211 if (radix_tree_lookup(trb_address_map, key))
212 radix_tree_delete(trb_address_map, key); 212 radix_tree_delete(trb_address_map, key);
213 } 213 }
214 214
215 static int xhci_update_stream_segment_mapping( 215 static int xhci_update_stream_segment_mapping(
216 struct radix_tree_root *trb_address_map, 216 struct radix_tree_root *trb_address_map,
217 struct xhci_ring *ring, 217 struct xhci_ring *ring,
218 struct xhci_segment *first_seg, 218 struct xhci_segment *first_seg,
219 struct xhci_segment *last_seg, 219 struct xhci_segment *last_seg,
220 gfp_t mem_flags) 220 gfp_t mem_flags)
221 { 221 {
222 struct xhci_segment *seg; 222 struct xhci_segment *seg;
223 struct xhci_segment *failed_seg; 223 struct xhci_segment *failed_seg;
224 int ret; 224 int ret;
225 225
226 if (WARN_ON_ONCE(trb_address_map == NULL)) 226 if (WARN_ON_ONCE(trb_address_map == NULL))
227 return 0; 227 return 0;
228 228
229 seg = first_seg; 229 seg = first_seg;
230 do { 230 do {
231 ret = xhci_insert_segment_mapping(trb_address_map, 231 ret = xhci_insert_segment_mapping(trb_address_map,
232 ring, seg, mem_flags); 232 ring, seg, mem_flags);
233 if (ret) 233 if (ret)
234 goto remove_streams; 234 goto remove_streams;
235 if (seg == last_seg) 235 if (seg == last_seg)
236 return 0; 236 return 0;
237 seg = seg->next; 237 seg = seg->next;
238 } while (seg != first_seg); 238 } while (seg != first_seg);
239 239
240 return 0; 240 return 0;
241 241
242 remove_streams: 242 remove_streams:
243 failed_seg = seg; 243 failed_seg = seg;
244 seg = first_seg; 244 seg = first_seg;
245 do { 245 do {
246 xhci_remove_segment_mapping(trb_address_map, seg); 246 xhci_remove_segment_mapping(trb_address_map, seg);
247 if (seg == failed_seg) 247 if (seg == failed_seg)
248 return ret; 248 return ret;
249 seg = seg->next; 249 seg = seg->next;
250 } while (seg != first_seg); 250 } while (seg != first_seg);
251 251
252 return ret; 252 return ret;
253 } 253 }
254 254
255 static void xhci_remove_stream_mapping(struct xhci_ring *ring) 255 static void xhci_remove_stream_mapping(struct xhci_ring *ring)
256 { 256 {
257 struct xhci_segment *seg; 257 struct xhci_segment *seg;
258 258
259 if (WARN_ON_ONCE(ring->trb_address_map == NULL)) 259 if (WARN_ON_ONCE(ring->trb_address_map == NULL))
260 return; 260 return;
261 261
262 seg = ring->first_seg; 262 seg = ring->first_seg;
263 do { 263 do {
264 xhci_remove_segment_mapping(ring->trb_address_map, seg); 264 xhci_remove_segment_mapping(ring->trb_address_map, seg);
265 seg = seg->next; 265 seg = seg->next;
266 } while (seg != ring->first_seg); 266 } while (seg != ring->first_seg);
267 } 267 }
268 268
269 static int xhci_update_stream_mapping(struct xhci_ring *ring, gfp_t mem_flags) 269 static int xhci_update_stream_mapping(struct xhci_ring *ring, gfp_t mem_flags)
270 { 270 {
271 return xhci_update_stream_segment_mapping(ring->trb_address_map, ring, 271 return xhci_update_stream_segment_mapping(ring->trb_address_map, ring,
272 ring->first_seg, ring->last_seg, mem_flags); 272 ring->first_seg, ring->last_seg, mem_flags);
273 } 273 }
274 274
275 /* XXX: Do we need the hcd structure in all these functions? */ 275 /* XXX: Do we need the hcd structure in all these functions? */
276 void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) 276 void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring)
277 { 277 {
278 if (!ring) 278 if (!ring)
279 return; 279 return;
280 280
281 if (ring->first_seg) { 281 if (ring->first_seg) {
282 if (ring->type == TYPE_STREAM) 282 if (ring->type == TYPE_STREAM)
283 xhci_remove_stream_mapping(ring); 283 xhci_remove_stream_mapping(ring);
284 xhci_free_segments_for_ring(xhci, ring->first_seg); 284 xhci_free_segments_for_ring(xhci, ring->first_seg);
285 } 285 }
286 286
287 kfree(ring); 287 kfree(ring);
288 } 288 }
289 289
290 static void xhci_initialize_ring_info(struct xhci_ring *ring, 290 static void xhci_initialize_ring_info(struct xhci_ring *ring,
291 unsigned int cycle_state) 291 unsigned int cycle_state)
292 { 292 {
293 /* The ring is empty, so the enqueue pointer == dequeue pointer */ 293 /* The ring is empty, so the enqueue pointer == dequeue pointer */
294 ring->enqueue = ring->first_seg->trbs; 294 ring->enqueue = ring->first_seg->trbs;
295 ring->enq_seg = ring->first_seg; 295 ring->enq_seg = ring->first_seg;
296 ring->dequeue = ring->enqueue; 296 ring->dequeue = ring->enqueue;
297 ring->deq_seg = ring->first_seg; 297 ring->deq_seg = ring->first_seg;
298 /* The ring is initialized to 0. The producer must write 1 to the cycle 298 /* The ring is initialized to 0. The producer must write 1 to the cycle
299 * bit to handover ownership of the TRB, so PCS = 1. The consumer must 299 * bit to handover ownership of the TRB, so PCS = 1. The consumer must
300 * compare CCS to the cycle bit to check ownership, so CCS = 1. 300 * compare CCS to the cycle bit to check ownership, so CCS = 1.
301 * 301 *
302 * New rings are initialized with cycle state equal to 1; if we are 302 * New rings are initialized with cycle state equal to 1; if we are
303 * handling ring expansion, set the cycle state equal to the old ring. 303 * handling ring expansion, set the cycle state equal to the old ring.
304 */ 304 */
305 ring->cycle_state = cycle_state; 305 ring->cycle_state = cycle_state;
306 /* Not necessary for new rings, but needed for re-initialized rings */ 306 /* Not necessary for new rings, but needed for re-initialized rings */
307 ring->enq_updates = 0; 307 ring->enq_updates = 0;
308 ring->deq_updates = 0; 308 ring->deq_updates = 0;
309 309
310 /* 310 /*
311 * Each segment has a link TRB, and leave an extra TRB for SW 311 * Each segment has a link TRB, and leave an extra TRB for SW
312 * accounting purpose 312 * accounting purpose
313 */ 313 */
314 ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1; 314 ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1;
315 } 315 }
316 316
317 /* Allocate segments and link them for a ring */ 317 /* Allocate segments and link them for a ring */
318 static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, 318 static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci,
319 struct xhci_segment **first, struct xhci_segment **last, 319 struct xhci_segment **first, struct xhci_segment **last,
320 unsigned int num_segs, unsigned int cycle_state, 320 unsigned int num_segs, unsigned int cycle_state,
321 enum xhci_ring_type type, gfp_t flags) 321 enum xhci_ring_type type, gfp_t flags)
322 { 322 {
323 struct xhci_segment *prev; 323 struct xhci_segment *prev;
324 324
325 prev = xhci_segment_alloc(xhci, cycle_state, flags); 325 prev = xhci_segment_alloc(xhci, cycle_state, flags);
326 if (!prev) 326 if (!prev)
327 return -ENOMEM; 327 return -ENOMEM;
328 num_segs--; 328 num_segs--;
329 329
330 *first = prev; 330 *first = prev;
331 while (num_segs > 0) { 331 while (num_segs > 0) {
332 struct xhci_segment *next; 332 struct xhci_segment *next;
333 333
334 next = xhci_segment_alloc(xhci, cycle_state, flags); 334 next = xhci_segment_alloc(xhci, cycle_state, flags);
335 if (!next) { 335 if (!next) {
336 prev = *first; 336 prev = *first;
337 while (prev) { 337 while (prev) {
338 next = prev->next; 338 next = prev->next;
339 xhci_segment_free(xhci, prev); 339 xhci_segment_free(xhci, prev);
340 prev = next; 340 prev = next;
341 } 341 }
342 return -ENOMEM; 342 return -ENOMEM;
343 } 343 }
344 xhci_link_segments(xhci, prev, next, type); 344 xhci_link_segments(xhci, prev, next, type);
345 345
346 prev = next; 346 prev = next;
347 num_segs--; 347 num_segs--;
348 } 348 }
349 xhci_link_segments(xhci, prev, *first, type); 349 xhci_link_segments(xhci, prev, *first, type);
350 *last = prev; 350 *last = prev;
351 351
352 return 0; 352 return 0;
353 } 353 }
354 354
355 /** 355 /**
356 * Create a new ring with zero or more segments. 356 * Create a new ring with zero or more segments.
357 * 357 *
358 * Link each segment together into a ring. 358 * Link each segment together into a ring.
359 * Set the end flag and the cycle toggle bit on the last segment. 359 * Set the end flag and the cycle toggle bit on the last segment.
360 * See section 4.9.1 and figures 15 and 16. 360 * See section 4.9.1 and figures 15 and 16.
361 */ 361 */
362 static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, 362 static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
363 unsigned int num_segs, unsigned int cycle_state, 363 unsigned int num_segs, unsigned int cycle_state,
364 enum xhci_ring_type type, gfp_t flags) 364 enum xhci_ring_type type, gfp_t flags)
365 { 365 {
366 struct xhci_ring *ring; 366 struct xhci_ring *ring;
367 int ret; 367 int ret;
368 368
369 ring = kzalloc(sizeof *(ring), flags); 369 ring = kzalloc(sizeof *(ring), flags);
370 if (!ring) 370 if (!ring)
371 return NULL; 371 return NULL;
372 372
373 ring->num_segs = num_segs; 373 ring->num_segs = num_segs;
374 INIT_LIST_HEAD(&ring->td_list); 374 INIT_LIST_HEAD(&ring->td_list);
375 ring->type = type; 375 ring->type = type;
376 if (num_segs == 0) 376 if (num_segs == 0)
377 return ring; 377 return ring;
378 378
379 ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg, 379 ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg,
380 &ring->last_seg, num_segs, cycle_state, type, flags); 380 &ring->last_seg, num_segs, cycle_state, type, flags);
381 if (ret) 381 if (ret)
382 goto fail; 382 goto fail;
383 383
384 /* Only event ring does not use link TRB */ 384 /* Only event ring does not use link TRB */
385 if (type != TYPE_EVENT) { 385 if (type != TYPE_EVENT) {
386 /* See section 4.9.2.1 and 6.4.4.1 */ 386 /* See section 4.9.2.1 and 6.4.4.1 */
387 ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |= 387 ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |=
388 cpu_to_le32(LINK_TOGGLE); 388 cpu_to_le32(LINK_TOGGLE);
389 } 389 }
390 xhci_initialize_ring_info(ring, cycle_state); 390 xhci_initialize_ring_info(ring, cycle_state);
391 return ring; 391 return ring;
392 392
393 fail: 393 fail:
394 kfree(ring); 394 kfree(ring);
395 return NULL; 395 return NULL;
396 } 396 }
397 397
398 void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, 398 void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci,
399 struct xhci_virt_device *virt_dev, 399 struct xhci_virt_device *virt_dev,
400 unsigned int ep_index) 400 unsigned int ep_index)
401 { 401 {
402 int rings_cached; 402 int rings_cached;
403 403
404 rings_cached = virt_dev->num_rings_cached; 404 rings_cached = virt_dev->num_rings_cached;
405 if (rings_cached < XHCI_MAX_RINGS_CACHED) { 405 if (rings_cached < XHCI_MAX_RINGS_CACHED) {
406 virt_dev->ring_cache[rings_cached] = 406 virt_dev->ring_cache[rings_cached] =
407 virt_dev->eps[ep_index].ring; 407 virt_dev->eps[ep_index].ring;
408 virt_dev->num_rings_cached++; 408 virt_dev->num_rings_cached++;
409 xhci_dbg(xhci, "Cached old ring, " 409 xhci_dbg(xhci, "Cached old ring, "
410 "%d ring%s cached\n", 410 "%d ring%s cached\n",
411 virt_dev->num_rings_cached, 411 virt_dev->num_rings_cached,
412 (virt_dev->num_rings_cached > 1) ? "s" : ""); 412 (virt_dev->num_rings_cached > 1) ? "s" : "");
413 } else { 413 } else {
414 xhci_ring_free(xhci, virt_dev->eps[ep_index].ring); 414 xhci_ring_free(xhci, virt_dev->eps[ep_index].ring);
415 xhci_dbg(xhci, "Ring cache full (%d rings), " 415 xhci_dbg(xhci, "Ring cache full (%d rings), "
416 "freeing ring\n", 416 "freeing ring\n",
417 virt_dev->num_rings_cached); 417 virt_dev->num_rings_cached);
418 } 418 }
419 virt_dev->eps[ep_index].ring = NULL; 419 virt_dev->eps[ep_index].ring = NULL;
420 } 420 }
421 421
422 /* Zero an endpoint ring (except for link TRBs) and move the enqueue and dequeue 422 /* Zero an endpoint ring (except for link TRBs) and move the enqueue and dequeue
423 * pointers to the beginning of the ring. 423 * pointers to the beginning of the ring.
424 */ 424 */
425 static void xhci_reinit_cached_ring(struct xhci_hcd *xhci, 425 static void xhci_reinit_cached_ring(struct xhci_hcd *xhci,
426 struct xhci_ring *ring, unsigned int cycle_state, 426 struct xhci_ring *ring, unsigned int cycle_state,
427 enum xhci_ring_type type) 427 enum xhci_ring_type type)
428 { 428 {
429 struct xhci_segment *seg = ring->first_seg; 429 struct xhci_segment *seg = ring->first_seg;
430 int i; 430 int i;
431 431
432 do { 432 do {
433 memset(seg->trbs, 0, 433 memset(seg->trbs, 0,
434 sizeof(union xhci_trb)*TRBS_PER_SEGMENT); 434 sizeof(union xhci_trb)*TRBS_PER_SEGMENT);
435 if (cycle_state == 0) { 435 if (cycle_state == 0) {
436 for (i = 0; i < TRBS_PER_SEGMENT; i++) 436 for (i = 0; i < TRBS_PER_SEGMENT; i++)
437 seg->trbs[i].link.control |= 437 seg->trbs[i].link.control |=
438 cpu_to_le32(TRB_CYCLE); 438 cpu_to_le32(TRB_CYCLE);
439 } 439 }
440 /* All endpoint rings have link TRBs */ 440 /* All endpoint rings have link TRBs */
441 xhci_link_segments(xhci, seg, seg->next, type); 441 xhci_link_segments(xhci, seg, seg->next, type);
442 seg = seg->next; 442 seg = seg->next;
443 } while (seg != ring->first_seg); 443 } while (seg != ring->first_seg);
444 ring->type = type; 444 ring->type = type;
445 xhci_initialize_ring_info(ring, cycle_state); 445 xhci_initialize_ring_info(ring, cycle_state);
446 /* td list should be empty since all URBs have been cancelled, 446 /* td list should be empty since all URBs have been cancelled,
447 * but just in case... 447 * but just in case...
448 */ 448 */
449 INIT_LIST_HEAD(&ring->td_list); 449 INIT_LIST_HEAD(&ring->td_list);
450 } 450 }
451 451
452 /* 452 /*
453 * Expand an existing ring. 453 * Expand an existing ring.
454 * Look for a cached ring or allocate a new ring which has same segment numbers 454 * Look for a cached ring or allocate a new ring which has same segment numbers
455 * and link the two rings. 455 * and link the two rings.
456 */ 456 */
457 int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, 457 int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring,
458 unsigned int num_trbs, gfp_t flags) 458 unsigned int num_trbs, gfp_t flags)
459 { 459 {
460 struct xhci_segment *first; 460 struct xhci_segment *first;
461 struct xhci_segment *last; 461 struct xhci_segment *last;
462 unsigned int num_segs; 462 unsigned int num_segs;
463 unsigned int num_segs_needed; 463 unsigned int num_segs_needed;
464 int ret; 464 int ret;
465 465
466 num_segs_needed = (num_trbs + (TRBS_PER_SEGMENT - 1) - 1) / 466 num_segs_needed = (num_trbs + (TRBS_PER_SEGMENT - 1) - 1) /
467 (TRBS_PER_SEGMENT - 1); 467 (TRBS_PER_SEGMENT - 1);
468 468
469 /* Allocate number of segments we needed, or double the ring size */ 469 /* Allocate number of segments we needed, or double the ring size */
470 num_segs = ring->num_segs > num_segs_needed ? 470 num_segs = ring->num_segs > num_segs_needed ?
471 ring->num_segs : num_segs_needed; 471 ring->num_segs : num_segs_needed;
472 472
473 ret = xhci_alloc_segments_for_ring(xhci, &first, &last, 473 ret = xhci_alloc_segments_for_ring(xhci, &first, &last,
474 num_segs, ring->cycle_state, ring->type, flags); 474 num_segs, ring->cycle_state, ring->type, flags);
475 if (ret) 475 if (ret)
476 return -ENOMEM; 476 return -ENOMEM;
477 477
478 if (ring->type == TYPE_STREAM) 478 if (ring->type == TYPE_STREAM)
479 ret = xhci_update_stream_segment_mapping(ring->trb_address_map, 479 ret = xhci_update_stream_segment_mapping(ring->trb_address_map,
480 ring, first, last, flags); 480 ring, first, last, flags);
481 if (ret) { 481 if (ret) {
482 struct xhci_segment *next; 482 struct xhci_segment *next;
483 do { 483 do {
484 next = first->next; 484 next = first->next;
485 xhci_segment_free(xhci, first); 485 xhci_segment_free(xhci, first);
486 if (first == last) 486 if (first == last)
487 break; 487 break;
488 first = next; 488 first = next;
489 } while (true); 489 } while (true);
490 return ret; 490 return ret;
491 } 491 }
492 492
493 xhci_link_rings(xhci, ring, first, last, num_segs); 493 xhci_link_rings(xhci, ring, first, last, num_segs);
494 xhci_dbg_trace(xhci, trace_xhci_dbg_ring_expansion, 494 xhci_dbg_trace(xhci, trace_xhci_dbg_ring_expansion,
495 "ring expansion succeed, now has %d segments", 495 "ring expansion succeed, now has %d segments",
496 ring->num_segs); 496 ring->num_segs);
497 497
498 return 0; 498 return 0;
499 } 499 }
500 500
501 #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32) 501 #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32)
502 502
503 static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, 503 static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci,
504 int type, gfp_t flags) 504 int type, gfp_t flags)
505 { 505 {
506 struct xhci_container_ctx *ctx; 506 struct xhci_container_ctx *ctx;
507 507
508 if ((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT)) 508 if ((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT))
509 return NULL; 509 return NULL;
510 510
511 ctx = kzalloc(sizeof(*ctx), flags); 511 ctx = kzalloc(sizeof(*ctx), flags);
512 if (!ctx) 512 if (!ctx)
513 return NULL; 513 return NULL;
514 514
515 ctx->type = type; 515 ctx->type = type;
516 ctx->size = HCC_64BYTE_CONTEXT(xhci->hcc_params) ? 2048 : 1024; 516 ctx->size = HCC_64BYTE_CONTEXT(xhci->hcc_params) ? 2048 : 1024;
517 if (type == XHCI_CTX_TYPE_INPUT) 517 if (type == XHCI_CTX_TYPE_INPUT)
518 ctx->size += CTX_SIZE(xhci->hcc_params); 518 ctx->size += CTX_SIZE(xhci->hcc_params);
519 519
520 ctx->bytes = dma_pool_alloc(xhci->device_pool, flags, &ctx->dma); 520 ctx->bytes = dma_pool_alloc(xhci->device_pool, flags, &ctx->dma);
521 if (!ctx->bytes) { 521 if (!ctx->bytes) {
522 kfree(ctx); 522 kfree(ctx);
523 return NULL; 523 return NULL;
524 } 524 }
525 memset(ctx->bytes, 0, ctx->size); 525 memset(ctx->bytes, 0, ctx->size);
526 return ctx; 526 return ctx;
527 } 527 }
528 528
529 static void xhci_free_container_ctx(struct xhci_hcd *xhci, 529 static void xhci_free_container_ctx(struct xhci_hcd *xhci,
530 struct xhci_container_ctx *ctx) 530 struct xhci_container_ctx *ctx)
531 { 531 {
532 if (!ctx) 532 if (!ctx)
533 return; 533 return;
534 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); 534 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma);
535 kfree(ctx); 535 kfree(ctx);
536 } 536 }
537 537
538 struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, 538 struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci,
539 struct xhci_container_ctx *ctx) 539 struct xhci_container_ctx *ctx)
540 { 540 {
541 if (ctx->type != XHCI_CTX_TYPE_INPUT) 541 if (ctx->type != XHCI_CTX_TYPE_INPUT)
542 return NULL; 542 return NULL;
543 543
544 return (struct xhci_input_control_ctx *)ctx->bytes; 544 return (struct xhci_input_control_ctx *)ctx->bytes;
545 } 545 }
546 546
547 struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, 547 struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci,
548 struct xhci_container_ctx *ctx) 548 struct xhci_container_ctx *ctx)
549 { 549 {
550 if (ctx->type == XHCI_CTX_TYPE_DEVICE) 550 if (ctx->type == XHCI_CTX_TYPE_DEVICE)
551 return (struct xhci_slot_ctx *)ctx->bytes; 551 return (struct xhci_slot_ctx *)ctx->bytes;
552 552
553 return (struct xhci_slot_ctx *) 553 return (struct xhci_slot_ctx *)
554 (ctx->bytes + CTX_SIZE(xhci->hcc_params)); 554 (ctx->bytes + CTX_SIZE(xhci->hcc_params));
555 } 555 }
556 556
557 struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, 557 struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci,
558 struct xhci_container_ctx *ctx, 558 struct xhci_container_ctx *ctx,
559 unsigned int ep_index) 559 unsigned int ep_index)
560 { 560 {
561 /* increment ep index by offset of start of ep ctx array */ 561 /* increment ep index by offset of start of ep ctx array */
562 ep_index++; 562 ep_index++;
563 if (ctx->type == XHCI_CTX_TYPE_INPUT) 563 if (ctx->type == XHCI_CTX_TYPE_INPUT)
564 ep_index++; 564 ep_index++;
565 565
566 return (struct xhci_ep_ctx *) 566 return (struct xhci_ep_ctx *)
567 (ctx->bytes + (ep_index * CTX_SIZE(xhci->hcc_params))); 567 (ctx->bytes + (ep_index * CTX_SIZE(xhci->hcc_params)));
568 } 568 }
569 569
570 570
571 /***************** Streams structures manipulation *************************/ 571 /***************** Streams structures manipulation *************************/
572 572
573 static void xhci_free_stream_ctx(struct xhci_hcd *xhci, 573 static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
574 unsigned int num_stream_ctxs, 574 unsigned int num_stream_ctxs,
575 struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) 575 struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
576 { 576 {
577 struct device *dev = xhci_to_hcd(xhci)->self.controller; 577 struct device *dev = xhci_to_hcd(xhci)->self.controller;
578 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; 578 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
579 579
580 if (size > MEDIUM_STREAM_ARRAY_SIZE) 580 if (size > MEDIUM_STREAM_ARRAY_SIZE)
581 dma_free_coherent(dev, size, 581 dma_free_coherent(dev, size,
582 stream_ctx, dma); 582 stream_ctx, dma);
583 else if (size <= SMALL_STREAM_ARRAY_SIZE) 583 else if (size <= SMALL_STREAM_ARRAY_SIZE)
584 return dma_pool_free(xhci->small_streams_pool, 584 return dma_pool_free(xhci->small_streams_pool,
585 stream_ctx, dma); 585 stream_ctx, dma);
586 else 586 else
587 return dma_pool_free(xhci->medium_streams_pool, 587 return dma_pool_free(xhci->medium_streams_pool,
588 stream_ctx, dma); 588 stream_ctx, dma);
589 } 589 }
590 590
591 /* 591 /*
592 * The stream context array for each endpoint with bulk streams enabled can 592 * The stream context array for each endpoint with bulk streams enabled can
593 * vary in size, based on: 593 * vary in size, based on:
594 * - how many streams the endpoint supports, 594 * - how many streams the endpoint supports,
595 * - the maximum primary stream array size the host controller supports, 595 * - the maximum primary stream array size the host controller supports,
596 * - and how many streams the device driver asks for. 596 * - and how many streams the device driver asks for.
597 * 597 *
598 * The stream context array must be a power of 2, and can be as small as 598 * The stream context array must be a power of 2, and can be as small as
599 * 64 bytes or as large as 1MB. 599 * 64 bytes or as large as 1MB.
600 */ 600 */
601 static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, 601 static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci,
602 unsigned int num_stream_ctxs, dma_addr_t *dma, 602 unsigned int num_stream_ctxs, dma_addr_t *dma,
603 gfp_t mem_flags) 603 gfp_t mem_flags)
604 { 604 {
605 struct device *dev = xhci_to_hcd(xhci)->self.controller; 605 struct device *dev = xhci_to_hcd(xhci)->self.controller;
606 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; 606 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
607 607
608 if (size > MEDIUM_STREAM_ARRAY_SIZE) 608 if (size > MEDIUM_STREAM_ARRAY_SIZE)
609 return dma_alloc_coherent(dev, size, 609 return dma_alloc_coherent(dev, size,
610 dma, mem_flags); 610 dma, mem_flags);
611 else if (size <= SMALL_STREAM_ARRAY_SIZE) 611 else if (size <= SMALL_STREAM_ARRAY_SIZE)
612 return dma_pool_alloc(xhci->small_streams_pool, 612 return dma_pool_alloc(xhci->small_streams_pool,
613 mem_flags, dma); 613 mem_flags, dma);
614 else 614 else
615 return dma_pool_alloc(xhci->medium_streams_pool, 615 return dma_pool_alloc(xhci->medium_streams_pool,
616 mem_flags, dma); 616 mem_flags, dma);
617 } 617 }
618 618
619 struct xhci_ring *xhci_dma_to_transfer_ring( 619 struct xhci_ring *xhci_dma_to_transfer_ring(
620 struct xhci_virt_ep *ep, 620 struct xhci_virt_ep *ep,
621 u64 address) 621 u64 address)
622 { 622 {
623 if (ep->ep_state & EP_HAS_STREAMS) 623 if (ep->ep_state & EP_HAS_STREAMS)
624 return radix_tree_lookup(&ep->stream_info->trb_address_map, 624 return radix_tree_lookup(&ep->stream_info->trb_address_map,
625 address >> TRB_SEGMENT_SHIFT); 625 address >> TRB_SEGMENT_SHIFT);
626 return ep->ring; 626 return ep->ring;
627 } 627 }
628 628
629 struct xhci_ring *xhci_stream_id_to_ring( 629 struct xhci_ring *xhci_stream_id_to_ring(
630 struct xhci_virt_device *dev, 630 struct xhci_virt_device *dev,
631 unsigned int ep_index, 631 unsigned int ep_index,
632 unsigned int stream_id) 632 unsigned int stream_id)
633 { 633 {
634 struct xhci_virt_ep *ep = &dev->eps[ep_index]; 634 struct xhci_virt_ep *ep = &dev->eps[ep_index];
635 635
636 if (stream_id == 0) 636 if (stream_id == 0)
637 return ep->ring; 637 return ep->ring;
638 if (!ep->stream_info) 638 if (!ep->stream_info)
639 return NULL; 639 return NULL;
640 640
641 if (stream_id > ep->stream_info->num_streams) 641 if (stream_id > ep->stream_info->num_streams)
642 return NULL; 642 return NULL;
643 return ep->stream_info->stream_rings[stream_id]; 643 return ep->stream_info->stream_rings[stream_id];
644 } 644 }
645 645
646 /* 646 /*
647 * Change an endpoint's internal structure so it supports stream IDs. The 647 * Change an endpoint's internal structure so it supports stream IDs. The
648 * number of requested streams includes stream 0, which cannot be used by device 648 * number of requested streams includes stream 0, which cannot be used by device
649 * drivers. 649 * drivers.
650 * 650 *
651 * The number of stream contexts in the stream context array may be bigger than 651 * The number of stream contexts in the stream context array may be bigger than
652 * the number of streams the driver wants to use. This is because the number of 652 * the number of streams the driver wants to use. This is because the number of
653 * stream context array entries must be a power of two. 653 * stream context array entries must be a power of two.
654 */ 654 */
655 struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, 655 struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
656 unsigned int num_stream_ctxs, 656 unsigned int num_stream_ctxs,
657 unsigned int num_streams, gfp_t mem_flags) 657 unsigned int num_streams, gfp_t mem_flags)
658 { 658 {
659 struct xhci_stream_info *stream_info; 659 struct xhci_stream_info *stream_info;
660 u32 cur_stream; 660 u32 cur_stream;
661 struct xhci_ring *cur_ring; 661 struct xhci_ring *cur_ring;
662 u64 addr; 662 u64 addr;
663 int ret; 663 int ret;
664 664
665 xhci_dbg(xhci, "Allocating %u streams and %u " 665 xhci_dbg(xhci, "Allocating %u streams and %u "
666 "stream context array entries.\n", 666 "stream context array entries.\n",
667 num_streams, num_stream_ctxs); 667 num_streams, num_stream_ctxs);
668 if (xhci->cmd_ring_reserved_trbs == MAX_RSVD_CMD_TRBS) { 668 if (xhci->cmd_ring_reserved_trbs == MAX_RSVD_CMD_TRBS) {
669 xhci_dbg(xhci, "Command ring has no reserved TRBs available\n"); 669 xhci_dbg(xhci, "Command ring has no reserved TRBs available\n");
670 return NULL; 670 return NULL;
671 } 671 }
672 xhci->cmd_ring_reserved_trbs++; 672 xhci->cmd_ring_reserved_trbs++;
673 673
674 stream_info = kzalloc(sizeof(struct xhci_stream_info), mem_flags); 674 stream_info = kzalloc(sizeof(struct xhci_stream_info), mem_flags);
675 if (!stream_info) 675 if (!stream_info)
676 goto cleanup_trbs; 676 goto cleanup_trbs;
677 677
678 stream_info->num_streams = num_streams; 678 stream_info->num_streams = num_streams;
679 stream_info->num_stream_ctxs = num_stream_ctxs; 679 stream_info->num_stream_ctxs = num_stream_ctxs;
680 680
681 /* Initialize the array of virtual pointers to stream rings. */ 681 /* Initialize the array of virtual pointers to stream rings. */
682 stream_info->stream_rings = kzalloc( 682 stream_info->stream_rings = kzalloc(
683 sizeof(struct xhci_ring *)*num_streams, 683 sizeof(struct xhci_ring *)*num_streams,
684 mem_flags); 684 mem_flags);
685 if (!stream_info->stream_rings) 685 if (!stream_info->stream_rings)
686 goto cleanup_info; 686 goto cleanup_info;
687 687
688 /* Initialize the array of DMA addresses for stream rings for the HW. */ 688 /* Initialize the array of DMA addresses for stream rings for the HW. */
689 stream_info->stream_ctx_array = xhci_alloc_stream_ctx(xhci, 689 stream_info->stream_ctx_array = xhci_alloc_stream_ctx(xhci,
690 num_stream_ctxs, &stream_info->ctx_array_dma, 690 num_stream_ctxs, &stream_info->ctx_array_dma,
691 mem_flags); 691 mem_flags);
692 if (!stream_info->stream_ctx_array) 692 if (!stream_info->stream_ctx_array)
693 goto cleanup_ctx; 693 goto cleanup_ctx;
694 memset(stream_info->stream_ctx_array, 0, 694 memset(stream_info->stream_ctx_array, 0,
695 sizeof(struct xhci_stream_ctx)*num_stream_ctxs); 695 sizeof(struct xhci_stream_ctx)*num_stream_ctxs);
696 696
697 /* Allocate everything needed to free the stream rings later */ 697 /* Allocate everything needed to free the stream rings later */
698 stream_info->free_streams_command = 698 stream_info->free_streams_command =
699 xhci_alloc_command(xhci, true, true, mem_flags); 699 xhci_alloc_command(xhci, true, true, mem_flags);
700 if (!stream_info->free_streams_command) 700 if (!stream_info->free_streams_command)
701 goto cleanup_ctx; 701 goto cleanup_ctx;
702 702
703 INIT_RADIX_TREE(&stream_info->trb_address_map, GFP_ATOMIC); 703 INIT_RADIX_TREE(&stream_info->trb_address_map, GFP_ATOMIC);
704 704
705 /* Allocate rings for all the streams that the driver will use, 705 /* Allocate rings for all the streams that the driver will use,
706 * and add their segment DMA addresses to the radix tree. 706 * and add their segment DMA addresses to the radix tree.
707 * Stream 0 is reserved. 707 * Stream 0 is reserved.
708 */ 708 */
709 for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { 709 for (cur_stream = 1; cur_stream < num_streams; cur_stream++) {
710 stream_info->stream_rings[cur_stream] = 710 stream_info->stream_rings[cur_stream] =
711 xhci_ring_alloc(xhci, 2, 1, TYPE_STREAM, mem_flags); 711 xhci_ring_alloc(xhci, 2, 1, TYPE_STREAM, mem_flags);
712 cur_ring = stream_info->stream_rings[cur_stream]; 712 cur_ring = stream_info->stream_rings[cur_stream];
713 if (!cur_ring) 713 if (!cur_ring)
714 goto cleanup_rings; 714 goto cleanup_rings;
715 cur_ring->stream_id = cur_stream; 715 cur_ring->stream_id = cur_stream;
716 cur_ring->trb_address_map = &stream_info->trb_address_map; 716 cur_ring->trb_address_map = &stream_info->trb_address_map;
717 /* Set deq ptr, cycle bit, and stream context type */ 717 /* Set deq ptr, cycle bit, and stream context type */
718 addr = cur_ring->first_seg->dma | 718 addr = cur_ring->first_seg->dma |
719 SCT_FOR_CTX(SCT_PRI_TR) | 719 SCT_FOR_CTX(SCT_PRI_TR) |
720 cur_ring->cycle_state; 720 cur_ring->cycle_state;
721 stream_info->stream_ctx_array[cur_stream].stream_ring = 721 stream_info->stream_ctx_array[cur_stream].stream_ring =
722 cpu_to_le64(addr); 722 cpu_to_le64(addr);
723 xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", 723 xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n",
724 cur_stream, (unsigned long long) addr); 724 cur_stream, (unsigned long long) addr);
725 725
726 ret = xhci_update_stream_mapping(cur_ring, mem_flags); 726 ret = xhci_update_stream_mapping(cur_ring, mem_flags);
727 if (ret) { 727 if (ret) {
728 xhci_ring_free(xhci, cur_ring); 728 xhci_ring_free(xhci, cur_ring);
729 stream_info->stream_rings[cur_stream] = NULL; 729 stream_info->stream_rings[cur_stream] = NULL;
730 goto cleanup_rings; 730 goto cleanup_rings;
731 } 731 }
732 } 732 }
733 /* Leave the other unused stream ring pointers in the stream context 733 /* Leave the other unused stream ring pointers in the stream context
734 * array initialized to zero. This will cause the xHC to give us an 734 * array initialized to zero. This will cause the xHC to give us an
735 * error if the device asks for a stream ID we don't have setup (if it 735 * error if the device asks for a stream ID we don't have setup (if it
736 * was any other way, the host controller would assume the ring is 736 * was any other way, the host controller would assume the ring is
737 * "empty" and wait forever for data to be queued to that stream ID). 737 * "empty" and wait forever for data to be queued to that stream ID).
738 */ 738 */
739 739
740 return stream_info; 740 return stream_info;
741 741
742 cleanup_rings: 742 cleanup_rings:
743 for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { 743 for (cur_stream = 1; cur_stream < num_streams; cur_stream++) {
744 cur_ring = stream_info->stream_rings[cur_stream]; 744 cur_ring = stream_info->stream_rings[cur_stream];
745 if (cur_ring) { 745 if (cur_ring) {
746 xhci_ring_free(xhci, cur_ring); 746 xhci_ring_free(xhci, cur_ring);
747 stream_info->stream_rings[cur_stream] = NULL; 747 stream_info->stream_rings[cur_stream] = NULL;
748 } 748 }
749 } 749 }
750 xhci_free_command(xhci, stream_info->free_streams_command); 750 xhci_free_command(xhci, stream_info->free_streams_command);
751 cleanup_ctx: 751 cleanup_ctx:
752 kfree(stream_info->stream_rings); 752 kfree(stream_info->stream_rings);
753 cleanup_info: 753 cleanup_info:
754 kfree(stream_info); 754 kfree(stream_info);
755 cleanup_trbs: 755 cleanup_trbs:
756 xhci->cmd_ring_reserved_trbs--; 756 xhci->cmd_ring_reserved_trbs--;
757 return NULL; 757 return NULL;
758 } 758 }
759 /* 759 /*
760 * Sets the MaxPStreams field and the Linear Stream Array field. 760 * Sets the MaxPStreams field and the Linear Stream Array field.
761 * Sets the dequeue pointer to the stream context array. 761 * Sets the dequeue pointer to the stream context array.
762 */ 762 */
763 void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci, 763 void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci,
764 struct xhci_ep_ctx *ep_ctx, 764 struct xhci_ep_ctx *ep_ctx,
765 struct xhci_stream_info *stream_info) 765 struct xhci_stream_info *stream_info)
766 { 766 {
767 u32 max_primary_streams; 767 u32 max_primary_streams;
768 /* MaxPStreams is the number of stream context array entries, not the 768 /* MaxPStreams is the number of stream context array entries, not the
769 * number we're actually using. Must be in 2^(MaxPstreams + 1) format. 769 * number we're actually using. Must be in 2^(MaxPstreams + 1) format.
770 * fls(0) = 0, fls(0x1) = 1, fls(0x10) = 2, fls(0x100) = 3, etc. 770 * fls(0) = 0, fls(0x1) = 1, fls(0x10) = 2, fls(0x100) = 3, etc.
771 */ 771 */
772 max_primary_streams = fls(stream_info->num_stream_ctxs) - 2; 772 max_primary_streams = fls(stream_info->num_stream_ctxs) - 2;
773 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, 773 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change,
774 "Setting number of stream ctx array entries to %u", 774 "Setting number of stream ctx array entries to %u",
775 1 << (max_primary_streams + 1)); 775 1 << (max_primary_streams + 1));
776 ep_ctx->ep_info &= cpu_to_le32(~EP_MAXPSTREAMS_MASK); 776 ep_ctx->ep_info &= cpu_to_le32(~EP_MAXPSTREAMS_MASK);
777 ep_ctx->ep_info |= cpu_to_le32(EP_MAXPSTREAMS(max_primary_streams) 777 ep_ctx->ep_info |= cpu_to_le32(EP_MAXPSTREAMS(max_primary_streams)
778 | EP_HAS_LSA); 778 | EP_HAS_LSA);
779 ep_ctx->deq = cpu_to_le64(stream_info->ctx_array_dma); 779 ep_ctx->deq = cpu_to_le64(stream_info->ctx_array_dma);
780 } 780 }
781 781
782 /* 782 /*
783 * Sets the MaxPStreams field and the Linear Stream Array field to 0. 783 * Sets the MaxPStreams field and the Linear Stream Array field to 0.
784 * Reinstalls the "normal" endpoint ring (at its previous dequeue mark, 784 * Reinstalls the "normal" endpoint ring (at its previous dequeue mark,
785 * not at the beginning of the ring). 785 * not at the beginning of the ring).
786 */ 786 */
787 void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, 787 void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci,
788 struct xhci_ep_ctx *ep_ctx, 788 struct xhci_ep_ctx *ep_ctx,
789 struct xhci_virt_ep *ep) 789 struct xhci_virt_ep *ep)
790 { 790 {
791 dma_addr_t addr; 791 dma_addr_t addr;
792 ep_ctx->ep_info &= cpu_to_le32(~(EP_MAXPSTREAMS_MASK | EP_HAS_LSA)); 792 ep_ctx->ep_info &= cpu_to_le32(~(EP_MAXPSTREAMS_MASK | EP_HAS_LSA));
793 addr = xhci_trb_virt_to_dma(ep->ring->deq_seg, ep->ring->dequeue); 793 addr = xhci_trb_virt_to_dma(ep->ring->deq_seg, ep->ring->dequeue);
794 ep_ctx->deq = cpu_to_le64(addr | ep->ring->cycle_state); 794 ep_ctx->deq = cpu_to_le64(addr | ep->ring->cycle_state);
795 } 795 }
796 796
797 /* Frees all stream contexts associated with the endpoint, 797 /* Frees all stream contexts associated with the endpoint,
798 * 798 *
799 * Caller should fix the endpoint context streams fields. 799 * Caller should fix the endpoint context streams fields.
800 */ 800 */
801 void xhci_free_stream_info(struct xhci_hcd *xhci, 801 void xhci_free_stream_info(struct xhci_hcd *xhci,
802 struct xhci_stream_info *stream_info) 802 struct xhci_stream_info *stream_info)
803 { 803 {
804 int cur_stream; 804 int cur_stream;
805 struct xhci_ring *cur_ring; 805 struct xhci_ring *cur_ring;
806 806
807 if (!stream_info) 807 if (!stream_info)
808 return; 808 return;
809 809
810 for (cur_stream = 1; cur_stream < stream_info->num_streams; 810 for (cur_stream = 1; cur_stream < stream_info->num_streams;
811 cur_stream++) { 811 cur_stream++) {
812 cur_ring = stream_info->stream_rings[cur_stream]; 812 cur_ring = stream_info->stream_rings[cur_stream];
813 if (cur_ring) { 813 if (cur_ring) {
814 xhci_ring_free(xhci, cur_ring); 814 xhci_ring_free(xhci, cur_ring);
815 stream_info->stream_rings[cur_stream] = NULL; 815 stream_info->stream_rings[cur_stream] = NULL;
816 } 816 }
817 } 817 }
818 xhci_free_command(xhci, stream_info->free_streams_command); 818 xhci_free_command(xhci, stream_info->free_streams_command);
819 xhci->cmd_ring_reserved_trbs--; 819 xhci->cmd_ring_reserved_trbs--;
820 if (stream_info->stream_ctx_array) 820 if (stream_info->stream_ctx_array)
821 xhci_free_stream_ctx(xhci, 821 xhci_free_stream_ctx(xhci,
822 stream_info->num_stream_ctxs, 822 stream_info->num_stream_ctxs,
823 stream_info->stream_ctx_array, 823 stream_info->stream_ctx_array,
824 stream_info->ctx_array_dma); 824 stream_info->ctx_array_dma);
825 825
826 kfree(stream_info->stream_rings); 826 kfree(stream_info->stream_rings);
827 kfree(stream_info); 827 kfree(stream_info);
828 } 828 }
829 829
830 830
831 /***************** Device context manipulation *************************/ 831 /***************** Device context manipulation *************************/
832 832
833 static void xhci_init_endpoint_timer(struct xhci_hcd *xhci, 833 static void xhci_init_endpoint_timer(struct xhci_hcd *xhci,
834 struct xhci_virt_ep *ep) 834 struct xhci_virt_ep *ep)
835 { 835 {
836 init_timer(&ep->stop_cmd_timer); 836 init_timer(&ep->stop_cmd_timer);
837 ep->stop_cmd_timer.data = (unsigned long) ep; 837 ep->stop_cmd_timer.data = (unsigned long) ep;
838 ep->stop_cmd_timer.function = xhci_stop_endpoint_command_watchdog; 838 ep->stop_cmd_timer.function = xhci_stop_endpoint_command_watchdog;
839 ep->xhci = xhci; 839 ep->xhci = xhci;
840 } 840 }
841 841
842 static void xhci_free_tt_info(struct xhci_hcd *xhci, 842 static void xhci_free_tt_info(struct xhci_hcd *xhci,
843 struct xhci_virt_device *virt_dev, 843 struct xhci_virt_device *virt_dev,
844 int slot_id) 844 int slot_id)
845 { 845 {
846 struct list_head *tt_list_head; 846 struct list_head *tt_list_head;
847 struct xhci_tt_bw_info *tt_info, *next; 847 struct xhci_tt_bw_info *tt_info, *next;
848 bool slot_found = false; 848 bool slot_found = false;
849 849
850 /* If the device never made it past the Set Address stage, 850 /* If the device never made it past the Set Address stage,
851 * it may not have the real_port set correctly. 851 * it may not have the real_port set correctly.
852 */ 852 */
853 if (virt_dev->real_port == 0 || 853 if (virt_dev->real_port == 0 ||
854 virt_dev->real_port > HCS_MAX_PORTS(xhci->hcs_params1)) { 854 virt_dev->real_port > HCS_MAX_PORTS(xhci->hcs_params1)) {
855 xhci_dbg(xhci, "Bad real port.\n"); 855 xhci_dbg(xhci, "Bad real port.\n");
856 return; 856 return;
857 } 857 }
858 858
859 tt_list_head = &(xhci->rh_bw[virt_dev->real_port - 1].tts); 859 tt_list_head = &(xhci->rh_bw[virt_dev->real_port - 1].tts);
860 list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) { 860 list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
861 /* Multi-TT hubs will have more than one entry */ 861 /* Multi-TT hubs will have more than one entry */
862 if (tt_info->slot_id == slot_id) { 862 if (tt_info->slot_id == slot_id) {
863 slot_found = true; 863 slot_found = true;
864 list_del(&tt_info->tt_list); 864 list_del(&tt_info->tt_list);
865 kfree(tt_info); 865 kfree(tt_info);
866 } else if (slot_found) { 866 } else if (slot_found) {
867 break; 867 break;
868 } 868 }
869 } 869 }
870 } 870 }
871 871
872 int xhci_alloc_tt_info(struct xhci_hcd *xhci, 872 int xhci_alloc_tt_info(struct xhci_hcd *xhci,
873 struct xhci_virt_device *virt_dev, 873 struct xhci_virt_device *virt_dev,
874 struct usb_device *hdev, 874 struct usb_device *hdev,
875 struct usb_tt *tt, gfp_t mem_flags) 875 struct usb_tt *tt, gfp_t mem_flags)
876 { 876 {
877 struct xhci_tt_bw_info *tt_info; 877 struct xhci_tt_bw_info *tt_info;
878 unsigned int num_ports; 878 unsigned int num_ports;
879 int i, j; 879 int i, j;
880 880
881 if (!tt->multi) 881 if (!tt->multi)
882 num_ports = 1; 882 num_ports = 1;
883 else 883 else
884 num_ports = hdev->maxchild; 884 num_ports = hdev->maxchild;
885 885
886 for (i = 0; i < num_ports; i++, tt_info++) { 886 for (i = 0; i < num_ports; i++, tt_info++) {
887 struct xhci_interval_bw_table *bw_table; 887 struct xhci_interval_bw_table *bw_table;
888 888
889 tt_info = kzalloc(sizeof(*tt_info), mem_flags); 889 tt_info = kzalloc(sizeof(*tt_info), mem_flags);
890 if (!tt_info) 890 if (!tt_info)
891 goto free_tts; 891 goto free_tts;
892 INIT_LIST_HEAD(&tt_info->tt_list); 892 INIT_LIST_HEAD(&tt_info->tt_list);
893 list_add(&tt_info->tt_list, 893 list_add(&tt_info->tt_list,
894 &xhci->rh_bw[virt_dev->real_port - 1].tts); 894 &xhci->rh_bw[virt_dev->real_port - 1].tts);
895 tt_info->slot_id = virt_dev->udev->slot_id; 895 tt_info->slot_id = virt_dev->udev->slot_id;
896 if (tt->multi) 896 if (tt->multi)
897 tt_info->ttport = i+1; 897 tt_info->ttport = i+1;
898 bw_table = &tt_info->bw_table; 898 bw_table = &tt_info->bw_table;
899 for (j = 0; j < XHCI_MAX_INTERVAL; j++) 899 for (j = 0; j < XHCI_MAX_INTERVAL; j++)
900 INIT_LIST_HEAD(&bw_table->interval_bw[j].endpoints); 900 INIT_LIST_HEAD(&bw_table->interval_bw[j].endpoints);
901 } 901 }
902 return 0; 902 return 0;
903 903
904 free_tts: 904 free_tts:
905 xhci_free_tt_info(xhci, virt_dev, virt_dev->udev->slot_id); 905 xhci_free_tt_info(xhci, virt_dev, virt_dev->udev->slot_id);
906 return -ENOMEM; 906 return -ENOMEM;
907 } 907 }
908 908
909 909
910 /* All the xhci_tds in the ring's TD list should be freed at this point. 910 /* All the xhci_tds in the ring's TD list should be freed at this point.
911 * Should be called with xhci->lock held if there is any chance the TT lists 911 * Should be called with xhci->lock held if there is any chance the TT lists
912 * will be manipulated by the configure endpoint, allocate device, or update 912 * will be manipulated by the configure endpoint, allocate device, or update
913 * hub functions while this function is removing the TT entries from the list. 913 * hub functions while this function is removing the TT entries from the list.
914 */ 914 */
915 void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) 915 void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
916 { 916 {
917 struct xhci_virt_device *dev; 917 struct xhci_virt_device *dev;
918 int i; 918 int i;
919 int old_active_eps = 0; 919 int old_active_eps = 0;
920 920
921 /* Slot ID 0 is reserved */ 921 /* Slot ID 0 is reserved */
922 if (slot_id == 0 || !xhci->devs[slot_id]) 922 if (slot_id == 0 || !xhci->devs[slot_id])
923 return; 923 return;
924 924
925 dev = xhci->devs[slot_id]; 925 dev = xhci->devs[slot_id];
926 xhci->dcbaa->dev_context_ptrs[slot_id] = 0; 926 xhci->dcbaa->dev_context_ptrs[slot_id] = 0;
927 if (!dev) 927 if (!dev)
928 return; 928 return;
929 929
930 if (dev->tt_info) 930 if (dev->tt_info)
931 old_active_eps = dev->tt_info->active_eps; 931 old_active_eps = dev->tt_info->active_eps;
932 932
933 for (i = 0; i < 31; ++i) { 933 for (i = 0; i < 31; ++i) {
934 if (dev->eps[i].ring) 934 if (dev->eps[i].ring)
935 xhci_ring_free(xhci, dev->eps[i].ring); 935 xhci_ring_free(xhci, dev->eps[i].ring);
936 if (dev->eps[i].stream_info) 936 if (dev->eps[i].stream_info)
937 xhci_free_stream_info(xhci, 937 xhci_free_stream_info(xhci,
938 dev->eps[i].stream_info); 938 dev->eps[i].stream_info);
939 /* Endpoints on the TT/root port lists should have been removed 939 /* Endpoints on the TT/root port lists should have been removed
940 * when usb_disable_device() was called for the device. 940 * when usb_disable_device() was called for the device.
941 * We can't drop them anyway, because the udev might have gone 941 * We can't drop them anyway, because the udev might have gone
942 * away by this point, and we can't tell what speed it was. 942 * away by this point, and we can't tell what speed it was.
943 */ 943 */
944 if (!list_empty(&dev->eps[i].bw_endpoint_list)) 944 if (!list_empty(&dev->eps[i].bw_endpoint_list))
945 xhci_warn(xhci, "Slot %u endpoint %u " 945 xhci_warn(xhci, "Slot %u endpoint %u "
946 "not removed from BW list!\n", 946 "not removed from BW list!\n",
947 slot_id, i); 947 slot_id, i);
948 } 948 }
949 /* If this is a hub, free the TT(s) from the TT list */ 949 /* If this is a hub, free the TT(s) from the TT list */
950 xhci_free_tt_info(xhci, dev, slot_id); 950 xhci_free_tt_info(xhci, dev, slot_id);
951 /* If necessary, update the number of active TTs on this root port */ 951 /* If necessary, update the number of active TTs on this root port */
952 xhci_update_tt_active_eps(xhci, dev, old_active_eps); 952 xhci_update_tt_active_eps(xhci, dev, old_active_eps);
953 953
954 if (dev->ring_cache) { 954 if (dev->ring_cache) {
955 for (i = 0; i < dev->num_rings_cached; i++) 955 for (i = 0; i < dev->num_rings_cached; i++)
956 xhci_ring_free(xhci, dev->ring_cache[i]); 956 xhci_ring_free(xhci, dev->ring_cache[i]);
957 kfree(dev->ring_cache); 957 kfree(dev->ring_cache);
958 } 958 }
959 959
960 if (dev->in_ctx) 960 if (dev->in_ctx)
961 xhci_free_container_ctx(xhci, dev->in_ctx); 961 xhci_free_container_ctx(xhci, dev->in_ctx);
962 if (dev->out_ctx) 962 if (dev->out_ctx)
963 xhci_free_container_ctx(xhci, dev->out_ctx); 963 xhci_free_container_ctx(xhci, dev->out_ctx);
964 964
965 kfree(xhci->devs[slot_id]); 965 kfree(xhci->devs[slot_id]);
966 xhci->devs[slot_id] = NULL; 966 xhci->devs[slot_id] = NULL;
967 } 967 }
968 968
969 int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, 969 int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
970 struct usb_device *udev, gfp_t flags) 970 struct usb_device *udev, gfp_t flags)
971 { 971 {
972 struct xhci_virt_device *dev; 972 struct xhci_virt_device *dev;
973 int i; 973 int i;
974 974
975 /* Slot ID 0 is reserved */ 975 /* Slot ID 0 is reserved */
976 if (slot_id == 0 || xhci->devs[slot_id]) { 976 if (slot_id == 0 || xhci->devs[slot_id]) {
977 xhci_warn(xhci, "Bad Slot ID %d\n", slot_id); 977 xhci_warn(xhci, "Bad Slot ID %d\n", slot_id);
978 return 0; 978 return 0;
979 } 979 }
980 980
981 xhci->devs[slot_id] = kzalloc(sizeof(*xhci->devs[slot_id]), flags); 981 xhci->devs[slot_id] = kzalloc(sizeof(*xhci->devs[slot_id]), flags);
982 if (!xhci->devs[slot_id]) 982 if (!xhci->devs[slot_id])
983 return 0; 983 return 0;
984 dev = xhci->devs[slot_id]; 984 dev = xhci->devs[slot_id];
985 985
986 /* Allocate the (output) device context that will be used in the HC. */ 986 /* Allocate the (output) device context that will be used in the HC. */
987 dev->out_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_DEVICE, flags); 987 dev->out_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_DEVICE, flags);
988 if (!dev->out_ctx) 988 if (!dev->out_ctx)
989 goto fail; 989 goto fail;
990 990
991 xhci_dbg(xhci, "Slot %d output ctx = 0x%llx (dma)\n", slot_id, 991 xhci_dbg(xhci, "Slot %d output ctx = 0x%llx (dma)\n", slot_id,
992 (unsigned long long)dev->out_ctx->dma); 992 (unsigned long long)dev->out_ctx->dma);
993 993
994 /* Allocate the (input) device context for address device command */ 994 /* Allocate the (input) device context for address device command */
995 dev->in_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, flags); 995 dev->in_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, flags);
996 if (!dev->in_ctx) 996 if (!dev->in_ctx)
997 goto fail; 997 goto fail;
998 998
999 xhci_dbg(xhci, "Slot %d input ctx = 0x%llx (dma)\n", slot_id, 999 xhci_dbg(xhci, "Slot %d input ctx = 0x%llx (dma)\n", slot_id,
1000 (unsigned long long)dev->in_ctx->dma); 1000 (unsigned long long)dev->in_ctx->dma);
1001 1001
1002 /* Initialize the cancellation list and watchdog timers for each ep */ 1002 /* Initialize the cancellation list and watchdog timers for each ep */
1003 for (i = 0; i < 31; i++) { 1003 for (i = 0; i < 31; i++) {
1004 xhci_init_endpoint_timer(xhci, &dev->eps[i]); 1004 xhci_init_endpoint_timer(xhci, &dev->eps[i]);
1005 INIT_LIST_HEAD(&dev->eps[i].cancelled_td_list); 1005 INIT_LIST_HEAD(&dev->eps[i].cancelled_td_list);
1006 INIT_LIST_HEAD(&dev->eps[i].bw_endpoint_list); 1006 INIT_LIST_HEAD(&dev->eps[i].bw_endpoint_list);
1007 } 1007 }
1008 1008
1009 /* Allocate endpoint 0 ring */ 1009 /* Allocate endpoint 0 ring */
1010 dev->eps[0].ring = xhci_ring_alloc(xhci, 2, 1, TYPE_CTRL, flags); 1010 dev->eps[0].ring = xhci_ring_alloc(xhci, 2, 1, TYPE_CTRL, flags);
1011 if (!dev->eps[0].ring) 1011 if (!dev->eps[0].ring)
1012 goto fail; 1012 goto fail;
1013 1013
1014 /* Allocate pointers to the ring cache */ 1014 /* Allocate pointers to the ring cache */
1015 dev->ring_cache = kzalloc( 1015 dev->ring_cache = kzalloc(
1016 sizeof(struct xhci_ring *)*XHCI_MAX_RINGS_CACHED, 1016 sizeof(struct xhci_ring *)*XHCI_MAX_RINGS_CACHED,
1017 flags); 1017 flags);
1018 if (!dev->ring_cache) 1018 if (!dev->ring_cache)
1019 goto fail; 1019 goto fail;
1020 dev->num_rings_cached = 0; 1020 dev->num_rings_cached = 0;
1021 1021
1022 init_completion(&dev->cmd_completion); 1022 init_completion(&dev->cmd_completion);
1023 INIT_LIST_HEAD(&dev->cmd_list); 1023 INIT_LIST_HEAD(&dev->cmd_list);
1024 dev->udev = udev; 1024 dev->udev = udev;
1025 1025
1026 /* Point to output device context in dcbaa. */ 1026 /* Point to output device context in dcbaa. */
1027 xhci->dcbaa->dev_context_ptrs[slot_id] = cpu_to_le64(dev->out_ctx->dma); 1027 xhci->dcbaa->dev_context_ptrs[slot_id] = cpu_to_le64(dev->out_ctx->dma);
1028 xhci_dbg(xhci, "Set slot id %d dcbaa entry %p to 0x%llx\n", 1028 xhci_dbg(xhci, "Set slot id %d dcbaa entry %p to 0x%llx\n",
1029 slot_id, 1029 slot_id,
1030 &xhci->dcbaa->dev_context_ptrs[slot_id], 1030 &xhci->dcbaa->dev_context_ptrs[slot_id],
1031 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id])); 1031 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id]));
1032 1032
1033 return 1; 1033 return 1;
1034 fail: 1034 fail:
1035 xhci_free_virt_device(xhci, slot_id); 1035 xhci_free_virt_device(xhci, slot_id);
1036 return 0; 1036 return 0;
1037 } 1037 }
1038 1038
1039 void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci, 1039 void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci,
1040 struct usb_device *udev) 1040 struct usb_device *udev)
1041 { 1041 {
1042 struct xhci_virt_device *virt_dev; 1042 struct xhci_virt_device *virt_dev;
1043 struct xhci_ep_ctx *ep0_ctx; 1043 struct xhci_ep_ctx *ep0_ctx;
1044 struct xhci_ring *ep_ring; 1044 struct xhci_ring *ep_ring;
1045 1045
1046 virt_dev = xhci->devs[udev->slot_id]; 1046 virt_dev = xhci->devs[udev->slot_id];
1047 ep0_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, 0); 1047 ep0_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, 0);
1048 ep_ring = virt_dev->eps[0].ring; 1048 ep_ring = virt_dev->eps[0].ring;
1049 /* 1049 /*
1050 * FIXME we don't keep track of the dequeue pointer very well after a 1050 * FIXME we don't keep track of the dequeue pointer very well after a
1051 * Set TR dequeue pointer, so we're setting the dequeue pointer of the 1051 * Set TR dequeue pointer, so we're setting the dequeue pointer of the
1052 * host to our enqueue pointer. This should only be called after a 1052 * host to our enqueue pointer. This should only be called after a
1053 * configured device has reset, so all control transfers should have 1053 * configured device has reset, so all control transfers should have
1054 * been completed or cancelled before the reset. 1054 * been completed or cancelled before the reset.
1055 */ 1055 */
1056 ep0_ctx->deq = cpu_to_le64(xhci_trb_virt_to_dma(ep_ring->enq_seg, 1056 ep0_ctx->deq = cpu_to_le64(xhci_trb_virt_to_dma(ep_ring->enq_seg,
1057 ep_ring->enqueue) 1057 ep_ring->enqueue)
1058 | ep_ring->cycle_state); 1058 | ep_ring->cycle_state);
1059 } 1059 }
1060 1060
1061 /* 1061 /*
1062 * The xHCI roothub may have ports of differing speeds in any order in the port 1062 * The xHCI roothub may have ports of differing speeds in any order in the port
1063 * status registers. xhci->port_array provides an array of the port speed for 1063 * status registers. xhci->port_array provides an array of the port speed for
1064 * each offset into the port status registers. 1064 * each offset into the port status registers.
1065 * 1065 *
1066 * The xHCI hardware wants to know the roothub port number that the USB device 1066 * The xHCI hardware wants to know the roothub port number that the USB device
1067 * is attached to (or the roothub port its ancestor hub is attached to). All we 1067 * is attached to (or the roothub port its ancestor hub is attached to). All we
1068 * know is the index of that port under either the USB 2.0 or the USB 3.0 1068 * know is the index of that port under either the USB 2.0 or the USB 3.0
1069 * roothub, but that doesn't give us the real index into the HW port status 1069 * roothub, but that doesn't give us the real index into the HW port status
1070 * registers. Call xhci_find_raw_port_number() to get real index. 1070 * registers. Call xhci_find_raw_port_number() to get real index.
1071 */ 1071 */
1072 static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, 1072 static u32 xhci_find_real_port_number(struct xhci_hcd *xhci,
1073 struct usb_device *udev) 1073 struct usb_device *udev)
1074 { 1074 {
1075 struct usb_device *top_dev; 1075 struct usb_device *top_dev;
1076 struct usb_hcd *hcd; 1076 struct usb_hcd *hcd;
1077 1077
1078 if (udev->speed == USB_SPEED_SUPER) 1078 if (udev->speed == USB_SPEED_SUPER)
1079 hcd = xhci->shared_hcd; 1079 hcd = xhci->shared_hcd;
1080 else 1080 else
1081 hcd = xhci->main_hcd; 1081 hcd = xhci->main_hcd;
1082 1082
1083 for (top_dev = udev; top_dev->parent && top_dev->parent->parent; 1083 for (top_dev = udev; top_dev->parent && top_dev->parent->parent;
1084 top_dev = top_dev->parent) 1084 top_dev = top_dev->parent)
1085 /* Found device below root hub */; 1085 /* Found device below root hub */;
1086 1086
1087 return xhci_find_raw_port_number(hcd, top_dev->portnum); 1087 return xhci_find_raw_port_number(hcd, top_dev->portnum);
1088 } 1088 }
1089 1089
1090 /* Setup an xHCI virtual device for a Set Address command */ 1090 /* Setup an xHCI virtual device for a Set Address command */
1091 int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev) 1091 int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev)
1092 { 1092 {
1093 struct xhci_virt_device *dev; 1093 struct xhci_virt_device *dev;
1094 struct xhci_ep_ctx *ep0_ctx; 1094 struct xhci_ep_ctx *ep0_ctx;
1095 struct xhci_slot_ctx *slot_ctx; 1095 struct xhci_slot_ctx *slot_ctx;
1096 u32 port_num; 1096 u32 port_num;
1097 u32 max_packets; 1097 u32 max_packets;
1098 struct usb_device *top_dev; 1098 struct usb_device *top_dev;
1099 1099
1100 dev = xhci->devs[udev->slot_id]; 1100 dev = xhci->devs[udev->slot_id];
1101 /* Slot ID 0 is reserved */ 1101 /* Slot ID 0 is reserved */
1102 if (udev->slot_id == 0 || !dev) { 1102 if (udev->slot_id == 0 || !dev) {
1103 xhci_warn(xhci, "Slot ID %d is not assigned to this device\n", 1103 xhci_warn(xhci, "Slot ID %d is not assigned to this device\n",
1104 udev->slot_id); 1104 udev->slot_id);
1105 return -EINVAL; 1105 return -EINVAL;
1106 } 1106 }
1107 ep0_ctx = xhci_get_ep_ctx(xhci, dev->in_ctx, 0); 1107 ep0_ctx = xhci_get_ep_ctx(xhci, dev->in_ctx, 0);
1108 slot_ctx = xhci_get_slot_ctx(xhci, dev->in_ctx); 1108 slot_ctx = xhci_get_slot_ctx(xhci, dev->in_ctx);
1109 1109
1110 /* 3) Only the control endpoint is valid - one endpoint context */ 1110 /* 3) Only the control endpoint is valid - one endpoint context */
1111 slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route); 1111 slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route);
1112 switch (udev->speed) { 1112 switch (udev->speed) {
1113 case USB_SPEED_SUPER: 1113 case USB_SPEED_SUPER:
1114 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS); 1114 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS);
1115 max_packets = MAX_PACKET(512); 1115 max_packets = MAX_PACKET(512);
1116 break; 1116 break;
1117 case USB_SPEED_HIGH: 1117 case USB_SPEED_HIGH:
1118 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_HS); 1118 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_HS);
1119 max_packets = MAX_PACKET(64); 1119 max_packets = MAX_PACKET(64);
1120 break; 1120 break;
1121 /* USB core guesses at a 64-byte max packet first for FS devices */ 1121 /* USB core guesses at a 64-byte max packet first for FS devices */
1122 case USB_SPEED_FULL: 1122 case USB_SPEED_FULL:
1123 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_FS); 1123 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_FS);
1124 max_packets = MAX_PACKET(64); 1124 max_packets = MAX_PACKET(64);
1125 break; 1125 break;
1126 case USB_SPEED_LOW: 1126 case USB_SPEED_LOW:
1127 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_LS); 1127 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_LS);
1128 max_packets = MAX_PACKET(8); 1128 max_packets = MAX_PACKET(8);
1129 break; 1129 break;
1130 case USB_SPEED_WIRELESS: 1130 case USB_SPEED_WIRELESS:
1131 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); 1131 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n");
1132 return -EINVAL; 1132 return -EINVAL;
1133 break; 1133 break;
1134 default: 1134 default:
1135 /* Speed was set earlier, this shouldn't happen. */ 1135 /* Speed was set earlier, this shouldn't happen. */
1136 return -EINVAL; 1136 return -EINVAL;
1137 } 1137 }
1138 /* Find the root hub port this device is under */ 1138 /* Find the root hub port this device is under */
1139 port_num = xhci_find_real_port_number(xhci, udev); 1139 port_num = xhci_find_real_port_number(xhci, udev);
1140 if (!port_num) 1140 if (!port_num)
1141 return -EINVAL; 1141 return -EINVAL;
1142 slot_ctx->dev_info2 |= cpu_to_le32(ROOT_HUB_PORT(port_num)); 1142 slot_ctx->dev_info2 |= cpu_to_le32(ROOT_HUB_PORT(port_num));
1143 /* Set the port number in the virtual_device to the faked port number */ 1143 /* Set the port number in the virtual_device to the faked port number */
1144 for (top_dev = udev; top_dev->parent && top_dev->parent->parent; 1144 for (top_dev = udev; top_dev->parent && top_dev->parent->parent;
1145 top_dev = top_dev->parent) 1145 top_dev = top_dev->parent)
1146 /* Found device below root hub */; 1146 /* Found device below root hub */;
1147 dev->fake_port = top_dev->portnum; 1147 dev->fake_port = top_dev->portnum;
1148 dev->real_port = port_num; 1148 dev->real_port = port_num;
1149 xhci_dbg(xhci, "Set root hub portnum to %d\n", port_num); 1149 xhci_dbg(xhci, "Set root hub portnum to %d\n", port_num);
1150 xhci_dbg(xhci, "Set fake root hub portnum to %d\n", dev->fake_port); 1150 xhci_dbg(xhci, "Set fake root hub portnum to %d\n", dev->fake_port);
1151 1151
1152 /* Find the right bandwidth table that this device will be a part of. 1152 /* Find the right bandwidth table that this device will be a part of.
1153 * If this is a full speed device attached directly to a root port (or a 1153 * If this is a full speed device attached directly to a root port (or a
1154 * decendent of one), it counts as a primary bandwidth domain, not a 1154 * decendent of one), it counts as a primary bandwidth domain, not a
1155 * secondary bandwidth domain under a TT. An xhci_tt_info structure 1155 * secondary bandwidth domain under a TT. An xhci_tt_info structure
1156 * will never be created for the HS root hub. 1156 * will never be created for the HS root hub.
1157 */ 1157 */
1158 if (!udev->tt || !udev->tt->hub->parent) { 1158 if (!udev->tt || !udev->tt->hub->parent) {
1159 dev->bw_table = &xhci->rh_bw[port_num - 1].bw_table; 1159 dev->bw_table = &xhci->rh_bw[port_num - 1].bw_table;
1160 } else { 1160 } else {
1161 struct xhci_root_port_bw_info *rh_bw; 1161 struct xhci_root_port_bw_info *rh_bw;
1162 struct xhci_tt_bw_info *tt_bw; 1162 struct xhci_tt_bw_info *tt_bw;
1163 1163
1164 rh_bw = &xhci->rh_bw[port_num - 1]; 1164 rh_bw = &xhci->rh_bw[port_num - 1];
1165 /* Find the right TT. */ 1165 /* Find the right TT. */
1166 list_for_each_entry(tt_bw, &rh_bw->tts, tt_list) { 1166 list_for_each_entry(tt_bw, &rh_bw->tts, tt_list) {
1167 if (tt_bw->slot_id != udev->tt->hub->slot_id) 1167 if (tt_bw->slot_id != udev->tt->hub->slot_id)
1168 continue; 1168 continue;
1169 1169
1170 if (!dev->udev->tt->multi || 1170 if (!dev->udev->tt->multi ||
1171 (udev->tt->multi && 1171 (udev->tt->multi &&
1172 tt_bw->ttport == dev->udev->ttport)) { 1172 tt_bw->ttport == dev->udev->ttport)) {
1173 dev->bw_table = &tt_bw->bw_table; 1173 dev->bw_table = &tt_bw->bw_table;
1174 dev->tt_info = tt_bw; 1174 dev->tt_info = tt_bw;
1175 break; 1175 break;
1176 } 1176 }
1177 } 1177 }
1178 if (!dev->tt_info) 1178 if (!dev->tt_info)
1179 xhci_warn(xhci, "WARN: Didn't find a matching TT\n"); 1179 xhci_warn(xhci, "WARN: Didn't find a matching TT\n");
1180 } 1180 }
1181 1181
1182 /* Is this a LS/FS device under an external HS hub? */ 1182 /* Is this a LS/FS device under an external HS hub? */
1183 if (udev->tt && udev->tt->hub->parent) { 1183 if (udev->tt && udev->tt->hub->parent) {
1184 slot_ctx->tt_info = cpu_to_le32(udev->tt->hub->slot_id | 1184 slot_ctx->tt_info = cpu_to_le32(udev->tt->hub->slot_id |
1185 (udev->ttport << 8)); 1185 (udev->ttport << 8));
1186 if (udev->tt->multi) 1186 if (udev->tt->multi)
1187 slot_ctx->dev_info |= cpu_to_le32(DEV_MTT); 1187 slot_ctx->dev_info |= cpu_to_le32(DEV_MTT);
1188 } 1188 }
1189 xhci_dbg(xhci, "udev->tt = %p\n", udev->tt); 1189 xhci_dbg(xhci, "udev->tt = %p\n", udev->tt);
1190 xhci_dbg(xhci, "udev->ttport = 0x%x\n", udev->ttport); 1190 xhci_dbg(xhci, "udev->ttport = 0x%x\n", udev->ttport);
1191 1191
1192 /* Step 4 - ring already allocated */ 1192 /* Step 4 - ring already allocated */
1193 /* Step 5 */ 1193 /* Step 5 */
1194 ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP)); 1194 ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
1195 1195
1196 /* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */ 1196 /* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */
1197 ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) | 1197 ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) |
1198 max_packets); 1198 max_packets);
1199 1199
1200 ep0_ctx->deq = cpu_to_le64(dev->eps[0].ring->first_seg->dma | 1200 ep0_ctx->deq = cpu_to_le64(dev->eps[0].ring->first_seg->dma |
1201 dev->eps[0].ring->cycle_state); 1201 dev->eps[0].ring->cycle_state);
1202 1202
1203 /* Steps 7 and 8 were done in xhci_alloc_virt_device() */ 1203 /* Steps 7 and 8 were done in xhci_alloc_virt_device() */
1204 1204
1205 return 0; 1205 return 0;
1206 } 1206 }
1207 1207
1208 /* 1208 /*
1209 * Convert interval expressed as 2^(bInterval - 1) == interval into 1209 * Convert interval expressed as 2^(bInterval - 1) == interval into
1210 * straight exponent value 2^n == interval. 1210 * straight exponent value 2^n == interval.
1211 * 1211 *
1212 */ 1212 */
1213 static unsigned int xhci_parse_exponent_interval(struct usb_device *udev, 1213 static unsigned int xhci_parse_exponent_interval(struct usb_device *udev,
1214 struct usb_host_endpoint *ep) 1214 struct usb_host_endpoint *ep)
1215 { 1215 {
1216 unsigned int interval; 1216 unsigned int interval;
1217 1217
1218 interval = clamp_val(ep->desc.bInterval, 1, 16) - 1; 1218 interval = clamp_val(ep->desc.bInterval, 1, 16) - 1;
1219 if (interval != ep->desc.bInterval - 1) 1219 if (interval != ep->desc.bInterval - 1)
1220 dev_warn(&udev->dev, 1220 dev_warn(&udev->dev,
1221 "ep %#x - rounding interval to %d %sframes\n", 1221 "ep %#x - rounding interval to %d %sframes\n",
1222 ep->desc.bEndpointAddress, 1222 ep->desc.bEndpointAddress,
1223 1 << interval, 1223 1 << interval,
1224 udev->speed == USB_SPEED_FULL ? "" : "micro"); 1224 udev->speed == USB_SPEED_FULL ? "" : "micro");
1225 1225
1226 if (udev->speed == USB_SPEED_FULL) { 1226 if (udev->speed == USB_SPEED_FULL) {
1227 /* 1227 /*
1228 * Full speed isoc endpoints specify interval in frames, 1228 * Full speed isoc endpoints specify interval in frames,
1229 * not microframes. We are using microframes everywhere, 1229 * not microframes. We are using microframes everywhere,
1230 * so adjust accordingly. 1230 * so adjust accordingly.
1231 */ 1231 */
1232 interval += 3; /* 1 frame = 2^3 uframes */ 1232 interval += 3; /* 1 frame = 2^3 uframes */
1233 } 1233 }
1234 1234
1235 return interval; 1235 return interval;
1236 } 1236 }
1237 1237
1238 /* 1238 /*
1239 * Convert bInterval expressed in microframes (in 1-255 range) to exponent of 1239 * Convert bInterval expressed in microframes (in 1-255 range) to exponent of
1240 * microframes, rounded down to nearest power of 2. 1240 * microframes, rounded down to nearest power of 2.
1241 */ 1241 */
1242 static unsigned int xhci_microframes_to_exponent(struct usb_device *udev, 1242 static unsigned int xhci_microframes_to_exponent(struct usb_device *udev,
1243 struct usb_host_endpoint *ep, unsigned int desc_interval, 1243 struct usb_host_endpoint *ep, unsigned int desc_interval,
1244 unsigned int min_exponent, unsigned int max_exponent) 1244 unsigned int min_exponent, unsigned int max_exponent)
1245 { 1245 {
1246 unsigned int interval; 1246 unsigned int interval;
1247 1247
1248 interval = fls(desc_interval) - 1; 1248 interval = fls(desc_interval) - 1;
1249 interval = clamp_val(interval, min_exponent, max_exponent); 1249 interval = clamp_val(interval, min_exponent, max_exponent);
1250 if ((1 << interval) != desc_interval) 1250 if ((1 << interval) != desc_interval)
1251 dev_warn(&udev->dev, 1251 dev_warn(&udev->dev,
1252 "ep %#x - rounding interval to %d microframes, ep desc says %d microframes\n", 1252 "ep %#x - rounding interval to %d microframes, ep desc says %d microframes\n",
1253 ep->desc.bEndpointAddress, 1253 ep->desc.bEndpointAddress,
1254 1 << interval, 1254 1 << interval,
1255 desc_interval); 1255 desc_interval);
1256 1256
1257 return interval; 1257 return interval;
1258 } 1258 }
1259 1259
1260 static unsigned int xhci_parse_microframe_interval(struct usb_device *udev, 1260 static unsigned int xhci_parse_microframe_interval(struct usb_device *udev,
1261 struct usb_host_endpoint *ep) 1261 struct usb_host_endpoint *ep)
1262 { 1262 {
1263 if (ep->desc.bInterval == 0) 1263 if (ep->desc.bInterval == 0)
1264 return 0; 1264 return 0;
1265 return xhci_microframes_to_exponent(udev, ep, 1265 return xhci_microframes_to_exponent(udev, ep,
1266 ep->desc.bInterval, 0, 15); 1266 ep->desc.bInterval, 0, 15);
1267 } 1267 }
1268 1268
1269 1269
1270 static unsigned int xhci_parse_frame_interval(struct usb_device *udev, 1270 static unsigned int xhci_parse_frame_interval(struct usb_device *udev,
1271 struct usb_host_endpoint *ep) 1271 struct usb_host_endpoint *ep)
1272 { 1272 {
1273 return xhci_microframes_to_exponent(udev, ep, 1273 return xhci_microframes_to_exponent(udev, ep,
1274 ep->desc.bInterval * 8, 3, 10); 1274 ep->desc.bInterval * 8, 3, 10);
1275 } 1275 }
1276 1276
1277 /* Return the polling or NAK interval. 1277 /* Return the polling or NAK interval.
1278 * 1278 *
1279 * The polling interval is expressed in "microframes". If xHCI's Interval field 1279 * The polling interval is expressed in "microframes". If xHCI's Interval field
1280 * is set to N, it will service the endpoint every 2^(Interval)*125us. 1280 * is set to N, it will service the endpoint every 2^(Interval)*125us.
1281 * 1281 *
1282 * The NAK interval is one NAK per 1 to 255 microframes, or no NAKs if interval 1282 * The NAK interval is one NAK per 1 to 255 microframes, or no NAKs if interval
1283 * is set to 0. 1283 * is set to 0.
1284 */ 1284 */
1285 static unsigned int xhci_get_endpoint_interval(struct usb_device *udev, 1285 static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
1286 struct usb_host_endpoint *ep) 1286 struct usb_host_endpoint *ep)
1287 { 1287 {
1288 unsigned int interval = 0; 1288 unsigned int interval = 0;
1289 1289
1290 switch (udev->speed) { 1290 switch (udev->speed) {
1291 case USB_SPEED_HIGH: 1291 case USB_SPEED_HIGH:
1292 /* Max NAK rate */ 1292 /* Max NAK rate */
1293 if (usb_endpoint_xfer_control(&ep->desc) || 1293 if (usb_endpoint_xfer_control(&ep->desc) ||
1294 usb_endpoint_xfer_bulk(&ep->desc)) { 1294 usb_endpoint_xfer_bulk(&ep->desc)) {
1295 interval = xhci_parse_microframe_interval(udev, ep); 1295 interval = xhci_parse_microframe_interval(udev, ep);
1296 break; 1296 break;
1297 } 1297 }
1298 /* Fall through - SS and HS isoc/int have same decoding */ 1298 /* Fall through - SS and HS isoc/int have same decoding */
1299 1299
1300 case USB_SPEED_SUPER: 1300 case USB_SPEED_SUPER:
1301 if (usb_endpoint_xfer_int(&ep->desc) || 1301 if (usb_endpoint_xfer_int(&ep->desc) ||
1302 usb_endpoint_xfer_isoc(&ep->desc)) { 1302 usb_endpoint_xfer_isoc(&ep->desc)) {
1303 interval = xhci_parse_exponent_interval(udev, ep); 1303 interval = xhci_parse_exponent_interval(udev, ep);
1304 } 1304 }
1305 break; 1305 break;
1306 1306
1307 case USB_SPEED_FULL: 1307 case USB_SPEED_FULL:
1308 if (usb_endpoint_xfer_isoc(&ep->desc)) { 1308 if (usb_endpoint_xfer_isoc(&ep->desc)) {
1309 interval = xhci_parse_exponent_interval(udev, ep); 1309 interval = xhci_parse_exponent_interval(udev, ep);
1310 break; 1310 break;
1311 } 1311 }
1312 /* 1312 /*
1313 * Fall through for interrupt endpoint interval decoding 1313 * Fall through for interrupt endpoint interval decoding
1314 * since it uses the same rules as low speed interrupt 1314 * since it uses the same rules as low speed interrupt
1315 * endpoints. 1315 * endpoints.
1316 */ 1316 */
1317 1317
1318 case USB_SPEED_LOW: 1318 case USB_SPEED_LOW:
1319 if (usb_endpoint_xfer_int(&ep->desc) || 1319 if (usb_endpoint_xfer_int(&ep->desc) ||
1320 usb_endpoint_xfer_isoc(&ep->desc)) { 1320 usb_endpoint_xfer_isoc(&ep->desc)) {
1321 1321
1322 interval = xhci_parse_frame_interval(udev, ep); 1322 interval = xhci_parse_frame_interval(udev, ep);
1323 } 1323 }
1324 break; 1324 break;
1325 1325
1326 default: 1326 default:
1327 BUG(); 1327 BUG();
1328 } 1328 }
1329 return EP_INTERVAL(interval); 1329 return EP_INTERVAL(interval);
1330 } 1330 }
1331 1331
1332 /* The "Mult" field in the endpoint context is only set for SuperSpeed isoc eps. 1332 /* The "Mult" field in the endpoint context is only set for SuperSpeed isoc eps.
1333 * High speed endpoint descriptors can define "the number of additional 1333 * High speed endpoint descriptors can define "the number of additional
1334 * transaction opportunities per microframe", but that goes in the Max Burst 1334 * transaction opportunities per microframe", but that goes in the Max Burst
1335 * endpoint context field. 1335 * endpoint context field.
1336 */ 1336 */
1337 static u32 xhci_get_endpoint_mult(struct usb_device *udev, 1337 static u32 xhci_get_endpoint_mult(struct usb_device *udev,
1338 struct usb_host_endpoint *ep) 1338 struct usb_host_endpoint *ep)
1339 { 1339 {
1340 if (udev->speed != USB_SPEED_SUPER || 1340 if (udev->speed != USB_SPEED_SUPER ||
1341 !usb_endpoint_xfer_isoc(&ep->desc)) 1341 !usb_endpoint_xfer_isoc(&ep->desc))
1342 return 0; 1342 return 0;
1343 return ep->ss_ep_comp.bmAttributes; 1343 return ep->ss_ep_comp.bmAttributes;
1344 } 1344 }
1345 1345
1346 static u32 xhci_get_endpoint_type(struct usb_device *udev, 1346 static u32 xhci_get_endpoint_type(struct usb_device *udev,
1347 struct usb_host_endpoint *ep) 1347 struct usb_host_endpoint *ep)
1348 { 1348 {
1349 int in; 1349 int in;
1350 u32 type; 1350 u32 type;
1351 1351
1352 in = usb_endpoint_dir_in(&ep->desc); 1352 in = usb_endpoint_dir_in(&ep->desc);
1353 if (usb_endpoint_xfer_control(&ep->desc)) { 1353 if (usb_endpoint_xfer_control(&ep->desc)) {
1354 type = EP_TYPE(CTRL_EP); 1354 type = EP_TYPE(CTRL_EP);
1355 } else if (usb_endpoint_xfer_bulk(&ep->desc)) { 1355 } else if (usb_endpoint_xfer_bulk(&ep->desc)) {
1356 if (in) 1356 if (in)
1357 type = EP_TYPE(BULK_IN_EP); 1357 type = EP_TYPE(BULK_IN_EP);
1358 else 1358 else
1359 type = EP_TYPE(BULK_OUT_EP); 1359 type = EP_TYPE(BULK_OUT_EP);
1360 } else if (usb_endpoint_xfer_isoc(&ep->desc)) { 1360 } else if (usb_endpoint_xfer_isoc(&ep->desc)) {
1361 if (in) 1361 if (in)
1362 type = EP_TYPE(ISOC_IN_EP); 1362 type = EP_TYPE(ISOC_IN_EP);
1363 else 1363 else
1364 type = EP_TYPE(ISOC_OUT_EP); 1364 type = EP_TYPE(ISOC_OUT_EP);
1365 } else if (usb_endpoint_xfer_int(&ep->desc)) { 1365 } else if (usb_endpoint_xfer_int(&ep->desc)) {
1366 if (in) 1366 if (in)
1367 type = EP_TYPE(INT_IN_EP); 1367 type = EP_TYPE(INT_IN_EP);
1368 else 1368 else
1369 type = EP_TYPE(INT_OUT_EP); 1369 type = EP_TYPE(INT_OUT_EP);
1370 } else { 1370 } else {
1371 type = 0; 1371 type = 0;
1372 } 1372 }
1373 return type; 1373 return type;
1374 } 1374 }
1375 1375
1376 /* Return the maximum endpoint service interval time (ESIT) payload. 1376 /* Return the maximum endpoint service interval time (ESIT) payload.
1377 * Basically, this is the maxpacket size, multiplied by the burst size 1377 * Basically, this is the maxpacket size, multiplied by the burst size
1378 * and mult size. 1378 * and mult size.
1379 */ 1379 */
1380 static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci, 1380 static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
1381 struct usb_device *udev, 1381 struct usb_device *udev,
1382 struct usb_host_endpoint *ep) 1382 struct usb_host_endpoint *ep)
1383 { 1383 {
1384 int max_burst; 1384 int max_burst;
1385 int max_packet; 1385 int max_packet;
1386 1386
1387 /* Only applies for interrupt or isochronous endpoints */ 1387 /* Only applies for interrupt or isochronous endpoints */
1388 if (usb_endpoint_xfer_control(&ep->desc) || 1388 if (usb_endpoint_xfer_control(&ep->desc) ||
1389 usb_endpoint_xfer_bulk(&ep->desc)) 1389 usb_endpoint_xfer_bulk(&ep->desc))
1390 return 0; 1390 return 0;
1391 1391
1392 if (udev->speed == USB_SPEED_SUPER) 1392 if (udev->speed == USB_SPEED_SUPER)
1393 return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval); 1393 return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
1394 1394
1395 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc)); 1395 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
1396 max_burst = (usb_endpoint_maxp(&ep->desc) & 0x1800) >> 11; 1396 max_burst = (usb_endpoint_maxp(&ep->desc) & 0x1800) >> 11;
1397 /* A 0 in max burst means 1 transfer per ESIT */ 1397 /* A 0 in max burst means 1 transfer per ESIT */
1398 return max_packet * (max_burst + 1); 1398 return max_packet * (max_burst + 1);
1399 } 1399 }
1400 1400
1401 /* Set up an endpoint with one ring segment. Do not allocate stream rings. 1401 /* Set up an endpoint with one ring segment. Do not allocate stream rings.
1402 * Drivers will have to call usb_alloc_streams() to do that. 1402 * Drivers will have to call usb_alloc_streams() to do that.
1403 */ 1403 */
1404 int xhci_endpoint_init(struct xhci_hcd *xhci, 1404 int xhci_endpoint_init(struct xhci_hcd *xhci,
1405 struct xhci_virt_device *virt_dev, 1405 struct xhci_virt_device *virt_dev,
1406 struct usb_device *udev, 1406 struct usb_device *udev,
1407 struct usb_host_endpoint *ep, 1407 struct usb_host_endpoint *ep,
1408 gfp_t mem_flags) 1408 gfp_t mem_flags)
1409 { 1409 {
1410 unsigned int ep_index; 1410 unsigned int ep_index;
1411 struct xhci_ep_ctx *ep_ctx; 1411 struct xhci_ep_ctx *ep_ctx;
1412 struct xhci_ring *ep_ring; 1412 struct xhci_ring *ep_ring;
1413 unsigned int max_packet; 1413 unsigned int max_packet;
1414 unsigned int max_burst; 1414 unsigned int max_burst;
1415 enum xhci_ring_type type; 1415 enum xhci_ring_type type;
1416 u32 max_esit_payload; 1416 u32 max_esit_payload;
1417 u32 endpoint_type; 1417 u32 endpoint_type;
1418 1418
1419 ep_index = xhci_get_endpoint_index(&ep->desc); 1419 ep_index = xhci_get_endpoint_index(&ep->desc);
1420 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); 1420 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
1421 1421
1422 endpoint_type = xhci_get_endpoint_type(udev, ep); 1422 endpoint_type = xhci_get_endpoint_type(udev, ep);
1423 if (!endpoint_type) 1423 if (!endpoint_type)
1424 return -EINVAL; 1424 return -EINVAL;
1425 ep_ctx->ep_info2 = cpu_to_le32(endpoint_type); 1425 ep_ctx->ep_info2 = cpu_to_le32(endpoint_type);
1426 1426
1427 type = usb_endpoint_type(&ep->desc); 1427 type = usb_endpoint_type(&ep->desc);
1428 /* Set up the endpoint ring */ 1428 /* Set up the endpoint ring */
1429 virt_dev->eps[ep_index].new_ring = 1429 virt_dev->eps[ep_index].new_ring =
1430 xhci_ring_alloc(xhci, 2, 1, type, mem_flags); 1430 xhci_ring_alloc(xhci, 2, 1, type, mem_flags);
1431 if (!virt_dev->eps[ep_index].new_ring) { 1431 if (!virt_dev->eps[ep_index].new_ring) {
1432 /* Attempt to use the ring cache */ 1432 /* Attempt to use the ring cache */
1433 if (virt_dev->num_rings_cached == 0) 1433 if (virt_dev->num_rings_cached == 0)
1434 return -ENOMEM; 1434 return -ENOMEM;
1435 virt_dev->eps[ep_index].new_ring = 1435 virt_dev->eps[ep_index].new_ring =
1436 virt_dev->ring_cache[virt_dev->num_rings_cached]; 1436 virt_dev->ring_cache[virt_dev->num_rings_cached];
1437 virt_dev->ring_cache[virt_dev->num_rings_cached] = NULL; 1437 virt_dev->ring_cache[virt_dev->num_rings_cached] = NULL;
1438 virt_dev->num_rings_cached--; 1438 virt_dev->num_rings_cached--;
1439 xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring, 1439 xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring,
1440 1, type); 1440 1, type);
1441 } 1441 }
1442 virt_dev->eps[ep_index].skip = false; 1442 virt_dev->eps[ep_index].skip = false;
1443 ep_ring = virt_dev->eps[ep_index].new_ring; 1443 ep_ring = virt_dev->eps[ep_index].new_ring;
1444 ep_ctx->deq = cpu_to_le64(ep_ring->first_seg->dma | ep_ring->cycle_state); 1444 ep_ctx->deq = cpu_to_le64(ep_ring->first_seg->dma | ep_ring->cycle_state);
1445 1445
1446 ep_ctx->ep_info = cpu_to_le32(xhci_get_endpoint_interval(udev, ep) 1446 ep_ctx->ep_info = cpu_to_le32(xhci_get_endpoint_interval(udev, ep)
1447 | EP_MULT(xhci_get_endpoint_mult(udev, ep))); 1447 | EP_MULT(xhci_get_endpoint_mult(udev, ep)));
1448 1448
1449 /* FIXME dig Mult and streams info out of ep companion desc */ 1449 /* FIXME dig Mult and streams info out of ep companion desc */
1450 1450
1451 /* Allow 3 retries for everything but isoc; 1451 /* Allow 3 retries for everything but isoc;
1452 * CErr shall be set to 0 for Isoch endpoints. 1452 * CErr shall be set to 0 for Isoch endpoints.
1453 */ 1453 */
1454 if (!usb_endpoint_xfer_isoc(&ep->desc)) 1454 if (!usb_endpoint_xfer_isoc(&ep->desc))
1455 ep_ctx->ep_info2 |= cpu_to_le32(ERROR_COUNT(3)); 1455 ep_ctx->ep_info2 |= cpu_to_le32(ERROR_COUNT(3));
1456 else 1456 else
1457 ep_ctx->ep_info2 |= cpu_to_le32(ERROR_COUNT(0)); 1457 ep_ctx->ep_info2 |= cpu_to_le32(ERROR_COUNT(0));
1458 1458
1459 /* Set the max packet size and max burst */ 1459 /* Set the max packet size and max burst */
1460 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc)); 1460 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
1461 max_burst = 0; 1461 max_burst = 0;
1462 switch (udev->speed) { 1462 switch (udev->speed) {
1463 case USB_SPEED_SUPER: 1463 case USB_SPEED_SUPER:
1464 /* dig out max burst from ep companion desc */ 1464 /* dig out max burst from ep companion desc */
1465 max_burst = ep->ss_ep_comp.bMaxBurst; 1465 max_burst = ep->ss_ep_comp.bMaxBurst;
1466 break; 1466 break;
1467 case USB_SPEED_HIGH: 1467 case USB_SPEED_HIGH:
1468 /* Some devices get this wrong */ 1468 /* Some devices get this wrong */
1469 if (usb_endpoint_xfer_bulk(&ep->desc)) 1469 if (usb_endpoint_xfer_bulk(&ep->desc))
1470 max_packet = 512; 1470 max_packet = 512;
1471 /* bits 11:12 specify the number of additional transaction 1471 /* bits 11:12 specify the number of additional transaction
1472 * opportunities per microframe (USB 2.0, section 9.6.6) 1472 * opportunities per microframe (USB 2.0, section 9.6.6)
1473 */ 1473 */
1474 if (usb_endpoint_xfer_isoc(&ep->desc) || 1474 if (usb_endpoint_xfer_isoc(&ep->desc) ||
1475 usb_endpoint_xfer_int(&ep->desc)) { 1475 usb_endpoint_xfer_int(&ep->desc)) {
1476 max_burst = (usb_endpoint_maxp(&ep->desc) 1476 max_burst = (usb_endpoint_maxp(&ep->desc)
1477 & 0x1800) >> 11; 1477 & 0x1800) >> 11;
1478 } 1478 }
1479 break; 1479 break;
1480 case USB_SPEED_FULL: 1480 case USB_SPEED_FULL:
1481 case USB_SPEED_LOW: 1481 case USB_SPEED_LOW:
1482 break; 1482 break;
1483 default: 1483 default:
1484 BUG(); 1484 BUG();
1485 } 1485 }
1486 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) | 1486 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) |
1487 MAX_BURST(max_burst)); 1487 MAX_BURST(max_burst));
1488 max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep); 1488 max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep);
1489 ep_ctx->tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload)); 1489 ep_ctx->tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload));
1490 1490
1491 /* 1491 /*
1492 * XXX no idea how to calculate the average TRB buffer length for bulk 1492 * XXX no idea how to calculate the average TRB buffer length for bulk
1493 * endpoints, as the driver gives us no clue how big each scatter gather 1493 * endpoints, as the driver gives us no clue how big each scatter gather
1494 * list entry (or buffer) is going to be. 1494 * list entry (or buffer) is going to be.
1495 * 1495 *
1496 * For isochronous and interrupt endpoints, we set it to the max 1496 * For isochronous and interrupt endpoints, we set it to the max
1497 * available, until we have new API in the USB core to allow drivers to 1497 * available, until we have new API in the USB core to allow drivers to
1498 * declare how much bandwidth they actually need. 1498 * declare how much bandwidth they actually need.
1499 * 1499 *
1500 * Normally, it would be calculated by taking the total of the buffer 1500 * Normally, it would be calculated by taking the total of the buffer
1501 * lengths in the TD and then dividing by the number of TRBs in a TD, 1501 * lengths in the TD and then dividing by the number of TRBs in a TD,
1502 * including link TRBs, No-op TRBs, and Event data TRBs. Since we don't 1502 * including link TRBs, No-op TRBs, and Event data TRBs. Since we don't
1503 * use Event Data TRBs, and we don't chain in a link TRB on short 1503 * use Event Data TRBs, and we don't chain in a link TRB on short
1504 * transfers, we're basically dividing by 1. 1504 * transfers, we're basically dividing by 1.
1505 * 1505 *
1506 * xHCI 1.0 specification indicates that the Average TRB Length should 1506 * xHCI 1.0 specification indicates that the Average TRB Length should
1507 * be set to 8 for control endpoints. 1507 * be set to 8 for control endpoints.
1508 */ 1508 */
1509 if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version == 0x100) 1509 if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version == 0x100)
1510 ep_ctx->tx_info |= cpu_to_le32(AVG_TRB_LENGTH_FOR_EP(8)); 1510 ep_ctx->tx_info |= cpu_to_le32(AVG_TRB_LENGTH_FOR_EP(8));
1511 else 1511 else
1512 ep_ctx->tx_info |= 1512 ep_ctx->tx_info |=
1513 cpu_to_le32(AVG_TRB_LENGTH_FOR_EP(max_esit_payload)); 1513 cpu_to_le32(AVG_TRB_LENGTH_FOR_EP(max_esit_payload));
1514 1514
1515 /* FIXME Debug endpoint context */ 1515 /* FIXME Debug endpoint context */
1516 return 0; 1516 return 0;
1517 } 1517 }
1518 1518
1519 void xhci_endpoint_zero(struct xhci_hcd *xhci, 1519 void xhci_endpoint_zero(struct xhci_hcd *xhci,
1520 struct xhci_virt_device *virt_dev, 1520 struct xhci_virt_device *virt_dev,
1521 struct usb_host_endpoint *ep) 1521 struct usb_host_endpoint *ep)
1522 { 1522 {
1523 unsigned int ep_index; 1523 unsigned int ep_index;
1524 struct xhci_ep_ctx *ep_ctx; 1524 struct xhci_ep_ctx *ep_ctx;
1525 1525
1526 ep_index = xhci_get_endpoint_index(&ep->desc); 1526 ep_index = xhci_get_endpoint_index(&ep->desc);
1527 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); 1527 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
1528 1528
1529 ep_ctx->ep_info = 0; 1529 ep_ctx->ep_info = 0;
1530 ep_ctx->ep_info2 = 0; 1530 ep_ctx->ep_info2 = 0;
1531 ep_ctx->deq = 0; 1531 ep_ctx->deq = 0;
1532 ep_ctx->tx_info = 0; 1532 ep_ctx->tx_info = 0;
1533 /* Don't free the endpoint ring until the set interface or configuration 1533 /* Don't free the endpoint ring until the set interface or configuration
1534 * request succeeds. 1534 * request succeeds.
1535 */ 1535 */
1536 } 1536 }
1537 1537
1538 void xhci_clear_endpoint_bw_info(struct xhci_bw_info *bw_info) 1538 void xhci_clear_endpoint_bw_info(struct xhci_bw_info *bw_info)
1539 { 1539 {
1540 bw_info->ep_interval = 0; 1540 bw_info->ep_interval = 0;
1541 bw_info->mult = 0; 1541 bw_info->mult = 0;
1542 bw_info->num_packets = 0; 1542 bw_info->num_packets = 0;
1543 bw_info->max_packet_size = 0; 1543 bw_info->max_packet_size = 0;
1544 bw_info->type = 0; 1544 bw_info->type = 0;
1545 bw_info->max_esit_payload = 0; 1545 bw_info->max_esit_payload = 0;
1546 } 1546 }
1547 1547
1548 void xhci_update_bw_info(struct xhci_hcd *xhci, 1548 void xhci_update_bw_info(struct xhci_hcd *xhci,
1549 struct xhci_container_ctx *in_ctx, 1549 struct xhci_container_ctx *in_ctx,
1550 struct xhci_input_control_ctx *ctrl_ctx, 1550 struct xhci_input_control_ctx *ctrl_ctx,
1551 struct xhci_virt_device *virt_dev) 1551 struct xhci_virt_device *virt_dev)
1552 { 1552 {
1553 struct xhci_bw_info *bw_info; 1553 struct xhci_bw_info *bw_info;
1554 struct xhci_ep_ctx *ep_ctx; 1554 struct xhci_ep_ctx *ep_ctx;
1555 unsigned int ep_type; 1555 unsigned int ep_type;
1556 int i; 1556 int i;
1557 1557
1558 for (i = 1; i < 31; ++i) { 1558 for (i = 1; i < 31; ++i) {
1559 bw_info = &virt_dev->eps[i].bw_info; 1559 bw_info = &virt_dev->eps[i].bw_info;
1560 1560
1561 /* We can't tell what endpoint type is being dropped, but 1561 /* We can't tell what endpoint type is being dropped, but
1562 * unconditionally clearing the bandwidth info for non-periodic 1562 * unconditionally clearing the bandwidth info for non-periodic
1563 * endpoints should be harmless because the info will never be 1563 * endpoints should be harmless because the info will never be
1564 * set in the first place. 1564 * set in the first place.
1565 */ 1565 */
1566 if (!EP_IS_ADDED(ctrl_ctx, i) && EP_IS_DROPPED(ctrl_ctx, i)) { 1566 if (!EP_IS_ADDED(ctrl_ctx, i) && EP_IS_DROPPED(ctrl_ctx, i)) {
1567 /* Dropped endpoint */ 1567 /* Dropped endpoint */
1568 xhci_clear_endpoint_bw_info(bw_info); 1568 xhci_clear_endpoint_bw_info(bw_info);
1569 continue; 1569 continue;
1570 } 1570 }
1571 1571
1572 if (EP_IS_ADDED(ctrl_ctx, i)) { 1572 if (EP_IS_ADDED(ctrl_ctx, i)) {
1573 ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, i); 1573 ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, i);
1574 ep_type = CTX_TO_EP_TYPE(le32_to_cpu(ep_ctx->ep_info2)); 1574 ep_type = CTX_TO_EP_TYPE(le32_to_cpu(ep_ctx->ep_info2));
1575 1575
1576 /* Ignore non-periodic endpoints */ 1576 /* Ignore non-periodic endpoints */
1577 if (ep_type != ISOC_OUT_EP && ep_type != INT_OUT_EP && 1577 if (ep_type != ISOC_OUT_EP && ep_type != INT_OUT_EP &&
1578 ep_type != ISOC_IN_EP && 1578 ep_type != ISOC_IN_EP &&
1579 ep_type != INT_IN_EP) 1579 ep_type != INT_IN_EP)
1580 continue; 1580 continue;
1581 1581
1582 /* Added or changed endpoint */ 1582 /* Added or changed endpoint */
1583 bw_info->ep_interval = CTX_TO_EP_INTERVAL( 1583 bw_info->ep_interval = CTX_TO_EP_INTERVAL(
1584 le32_to_cpu(ep_ctx->ep_info)); 1584 le32_to_cpu(ep_ctx->ep_info));
1585 /* Number of packets and mult are zero-based in the 1585 /* Number of packets and mult are zero-based in the
1586 * input context, but we want one-based for the 1586 * input context, but we want one-based for the
1587 * interval table. 1587 * interval table.
1588 */ 1588 */
1589 bw_info->mult = CTX_TO_EP_MULT( 1589 bw_info->mult = CTX_TO_EP_MULT(
1590 le32_to_cpu(ep_ctx->ep_info)) + 1; 1590 le32_to_cpu(ep_ctx->ep_info)) + 1;
1591 bw_info->num_packets = CTX_TO_MAX_BURST( 1591 bw_info->num_packets = CTX_TO_MAX_BURST(
1592 le32_to_cpu(ep_ctx->ep_info2)) + 1; 1592 le32_to_cpu(ep_ctx->ep_info2)) + 1;
1593 bw_info->max_packet_size = MAX_PACKET_DECODED( 1593 bw_info->max_packet_size = MAX_PACKET_DECODED(
1594 le32_to_cpu(ep_ctx->ep_info2)); 1594 le32_to_cpu(ep_ctx->ep_info2));
1595 bw_info->type = ep_type; 1595 bw_info->type = ep_type;
1596 bw_info->max_esit_payload = CTX_TO_MAX_ESIT_PAYLOAD( 1596 bw_info->max_esit_payload = CTX_TO_MAX_ESIT_PAYLOAD(
1597 le32_to_cpu(ep_ctx->tx_info)); 1597 le32_to_cpu(ep_ctx->tx_info));
1598 } 1598 }
1599 } 1599 }
1600 } 1600 }
1601 1601
1602 /* Copy output xhci_ep_ctx to the input xhci_ep_ctx copy. 1602 /* Copy output xhci_ep_ctx to the input xhci_ep_ctx copy.
1603 * Useful when you want to change one particular aspect of the endpoint and then 1603 * Useful when you want to change one particular aspect of the endpoint and then
1604 * issue a configure endpoint command. 1604 * issue a configure endpoint command.
1605 */ 1605 */
1606 void xhci_endpoint_copy(struct xhci_hcd *xhci, 1606 void xhci_endpoint_copy(struct xhci_hcd *xhci,
1607 struct xhci_container_ctx *in_ctx, 1607 struct xhci_container_ctx *in_ctx,
1608 struct xhci_container_ctx *out_ctx, 1608 struct xhci_container_ctx *out_ctx,
1609 unsigned int ep_index) 1609 unsigned int ep_index)
1610 { 1610 {
1611 struct xhci_ep_ctx *out_ep_ctx; 1611 struct xhci_ep_ctx *out_ep_ctx;
1612 struct xhci_ep_ctx *in_ep_ctx; 1612 struct xhci_ep_ctx *in_ep_ctx;
1613 1613
1614 out_ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); 1614 out_ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
1615 in_ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index); 1615 in_ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index);
1616 1616
1617 in_ep_ctx->ep_info = out_ep_ctx->ep_info; 1617 in_ep_ctx->ep_info = out_ep_ctx->ep_info;
1618 in_ep_ctx->ep_info2 = out_ep_ctx->ep_info2; 1618 in_ep_ctx->ep_info2 = out_ep_ctx->ep_info2;
1619 in_ep_ctx->deq = out_ep_ctx->deq; 1619 in_ep_ctx->deq = out_ep_ctx->deq;
1620 in_ep_ctx->tx_info = out_ep_ctx->tx_info; 1620 in_ep_ctx->tx_info = out_ep_ctx->tx_info;
1621 } 1621 }
1622 1622
1623 /* Copy output xhci_slot_ctx to the input xhci_slot_ctx. 1623 /* Copy output xhci_slot_ctx to the input xhci_slot_ctx.
1624 * Useful when you want to change one particular aspect of the endpoint and then 1624 * Useful when you want to change one particular aspect of the endpoint and then
1625 * issue a configure endpoint command. Only the context entries field matters, 1625 * issue a configure endpoint command. Only the context entries field matters,
1626 * but we'll copy the whole thing anyway. 1626 * but we'll copy the whole thing anyway.
1627 */ 1627 */
1628 void xhci_slot_copy(struct xhci_hcd *xhci, 1628 void xhci_slot_copy(struct xhci_hcd *xhci,
1629 struct xhci_container_ctx *in_ctx, 1629 struct xhci_container_ctx *in_ctx,
1630 struct xhci_container_ctx *out_ctx) 1630 struct xhci_container_ctx *out_ctx)
1631 { 1631 {
1632 struct xhci_slot_ctx *in_slot_ctx; 1632 struct xhci_slot_ctx *in_slot_ctx;
1633 struct xhci_slot_ctx *out_slot_ctx; 1633 struct xhci_slot_ctx *out_slot_ctx;
1634 1634
1635 in_slot_ctx = xhci_get_slot_ctx(xhci, in_ctx); 1635 in_slot_ctx = xhci_get_slot_ctx(xhci, in_ctx);
1636 out_slot_ctx = xhci_get_slot_ctx(xhci, out_ctx); 1636 out_slot_ctx = xhci_get_slot_ctx(xhci, out_ctx);
1637 1637
1638 in_slot_ctx->dev_info = out_slot_ctx->dev_info; 1638 in_slot_ctx->dev_info = out_slot_ctx->dev_info;
1639 in_slot_ctx->dev_info2 = out_slot_ctx->dev_info2; 1639 in_slot_ctx->dev_info2 = out_slot_ctx->dev_info2;
1640 in_slot_ctx->tt_info = out_slot_ctx->tt_info; 1640 in_slot_ctx->tt_info = out_slot_ctx->tt_info;
1641 in_slot_ctx->dev_state = out_slot_ctx->dev_state; 1641 in_slot_ctx->dev_state = out_slot_ctx->dev_state;
1642 } 1642 }
1643 1643
1644 /* Set up the scratchpad buffer array and scratchpad buffers, if needed. */ 1644 /* Set up the scratchpad buffer array and scratchpad buffers, if needed. */
1645 static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) 1645 static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
1646 { 1646 {
1647 int i; 1647 int i;
1648 struct device *dev = xhci_to_hcd(xhci)->self.controller; 1648 struct device *dev = xhci_to_hcd(xhci)->self.controller;
1649 int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); 1649 int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
1650 1650
1651 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 1651 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
1652 "Allocating %d scratchpad buffers", num_sp); 1652 "Allocating %d scratchpad buffers", num_sp);
1653 1653
1654 if (!num_sp) 1654 if (!num_sp)
1655 return 0; 1655 return 0;
1656 1656
1657 xhci->scratchpad = kzalloc(sizeof(*xhci->scratchpad), flags); 1657 xhci->scratchpad = kzalloc(sizeof(*xhci->scratchpad), flags);
1658 if (!xhci->scratchpad) 1658 if (!xhci->scratchpad)
1659 goto fail_sp; 1659 goto fail_sp;
1660 1660
1661 xhci->scratchpad->sp_array = dma_alloc_coherent(dev, 1661 xhci->scratchpad->sp_array = dma_alloc_coherent(dev,
1662 num_sp * sizeof(u64), 1662 num_sp * sizeof(u64),
1663 &xhci->scratchpad->sp_dma, flags); 1663 &xhci->scratchpad->sp_dma, flags);
1664 if (!xhci->scratchpad->sp_array) 1664 if (!xhci->scratchpad->sp_array)
1665 goto fail_sp2; 1665 goto fail_sp2;
1666 1666
1667 xhci->scratchpad->sp_buffers = kzalloc(sizeof(void *) * num_sp, flags); 1667 xhci->scratchpad->sp_buffers = kzalloc(sizeof(void *) * num_sp, flags);
1668 if (!xhci->scratchpad->sp_buffers) 1668 if (!xhci->scratchpad->sp_buffers)
1669 goto fail_sp3; 1669 goto fail_sp3;
1670 1670
1671 xhci->scratchpad->sp_dma_buffers = 1671 xhci->scratchpad->sp_dma_buffers =
1672 kzalloc(sizeof(dma_addr_t) * num_sp, flags); 1672 kzalloc(sizeof(dma_addr_t) * num_sp, flags);
1673 1673
1674 if (!xhci->scratchpad->sp_dma_buffers) 1674 if (!xhci->scratchpad->sp_dma_buffers)
1675 goto fail_sp4; 1675 goto fail_sp4;
1676 1676
1677 xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma); 1677 xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma);
1678 for (i = 0; i < num_sp; i++) { 1678 for (i = 0; i < num_sp; i++) {
1679 dma_addr_t dma; 1679 dma_addr_t dma;
1680 void *buf = dma_alloc_coherent(dev, xhci->page_size, &dma, 1680 void *buf = dma_alloc_coherent(dev, xhci->page_size, &dma,
1681 flags); 1681 flags);
1682 if (!buf) 1682 if (!buf)
1683 goto fail_sp5; 1683 goto fail_sp5;
1684 1684
1685 xhci->scratchpad->sp_array[i] = dma; 1685 xhci->scratchpad->sp_array[i] = dma;
1686 xhci->scratchpad->sp_buffers[i] = buf; 1686 xhci->scratchpad->sp_buffers[i] = buf;
1687 xhci->scratchpad->sp_dma_buffers[i] = dma; 1687 xhci->scratchpad->sp_dma_buffers[i] = dma;
1688 } 1688 }
1689 1689
1690 return 0; 1690 return 0;
1691 1691
1692 fail_sp5: 1692 fail_sp5:
1693 for (i = i - 1; i >= 0; i--) { 1693 for (i = i - 1; i >= 0; i--) {
1694 dma_free_coherent(dev, xhci->page_size, 1694 dma_free_coherent(dev, xhci->page_size,
1695 xhci->scratchpad->sp_buffers[i], 1695 xhci->scratchpad->sp_buffers[i],
1696 xhci->scratchpad->sp_dma_buffers[i]); 1696 xhci->scratchpad->sp_dma_buffers[i]);
1697 } 1697 }
1698 kfree(xhci->scratchpad->sp_dma_buffers); 1698 kfree(xhci->scratchpad->sp_dma_buffers);
1699 1699
1700 fail_sp4: 1700 fail_sp4:
1701 kfree(xhci->scratchpad->sp_buffers); 1701 kfree(xhci->scratchpad->sp_buffers);
1702 1702
1703 fail_sp3: 1703 fail_sp3:
1704 dma_free_coherent(dev, num_sp * sizeof(u64), 1704 dma_free_coherent(dev, num_sp * sizeof(u64),
1705 xhci->scratchpad->sp_array, 1705 xhci->scratchpad->sp_array,
1706 xhci->scratchpad->sp_dma); 1706 xhci->scratchpad->sp_dma);
1707 1707
1708 fail_sp2: 1708 fail_sp2:
1709 kfree(xhci->scratchpad); 1709 kfree(xhci->scratchpad);
1710 xhci->scratchpad = NULL; 1710 xhci->scratchpad = NULL;
1711 1711
1712 fail_sp: 1712 fail_sp:
1713 return -ENOMEM; 1713 return -ENOMEM;
1714 } 1714 }
1715 1715
1716 static void scratchpad_free(struct xhci_hcd *xhci) 1716 static void scratchpad_free(struct xhci_hcd *xhci)
1717 { 1717 {
1718 int num_sp; 1718 int num_sp;
1719 int i; 1719 int i;
1720 struct device *dev = xhci_to_hcd(xhci)->self.controller; 1720 struct device *dev = xhci_to_hcd(xhci)->self.controller;
1721 1721
1722 if (!xhci->scratchpad) 1722 if (!xhci->scratchpad)
1723 return; 1723 return;
1724 1724
1725 num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); 1725 num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
1726 1726
1727 for (i = 0; i < num_sp; i++) { 1727 for (i = 0; i < num_sp; i++) {
1728 dma_free_coherent(dev, xhci->page_size, 1728 dma_free_coherent(dev, xhci->page_size,
1729 xhci->scratchpad->sp_buffers[i], 1729 xhci->scratchpad->sp_buffers[i],
1730 xhci->scratchpad->sp_dma_buffers[i]); 1730 xhci->scratchpad->sp_dma_buffers[i]);
1731 } 1731 }
1732 kfree(xhci->scratchpad->sp_dma_buffers); 1732 kfree(xhci->scratchpad->sp_dma_buffers);
1733 kfree(xhci->scratchpad->sp_buffers); 1733 kfree(xhci->scratchpad->sp_buffers);
1734 dma_free_coherent(dev, num_sp * sizeof(u64), 1734 dma_free_coherent(dev, num_sp * sizeof(u64),
1735 xhci->scratchpad->sp_array, 1735 xhci->scratchpad->sp_array,
1736 xhci->scratchpad->sp_dma); 1736 xhci->scratchpad->sp_dma);
1737 kfree(xhci->scratchpad); 1737 kfree(xhci->scratchpad);
1738 xhci->scratchpad = NULL; 1738 xhci->scratchpad = NULL;
1739 } 1739 }
1740 1740
1741 struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 1741 struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1742 bool allocate_in_ctx, bool allocate_completion, 1742 bool allocate_in_ctx, bool allocate_completion,
1743 gfp_t mem_flags) 1743 gfp_t mem_flags)
1744 { 1744 {
1745 struct xhci_command *command; 1745 struct xhci_command *command;
1746 1746
1747 command = kzalloc(sizeof(*command), mem_flags); 1747 command = kzalloc(sizeof(*command), mem_flags);
1748 if (!command) 1748 if (!command)
1749 return NULL; 1749 return NULL;
1750 1750
1751 if (allocate_in_ctx) { 1751 if (allocate_in_ctx) {
1752 command->in_ctx = 1752 command->in_ctx =
1753 xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, 1753 xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT,
1754 mem_flags); 1754 mem_flags);
1755 if (!command->in_ctx) { 1755 if (!command->in_ctx) {
1756 kfree(command); 1756 kfree(command);
1757 return NULL; 1757 return NULL;
1758 } 1758 }
1759 } 1759 }
1760 1760
1761 if (allocate_completion) { 1761 if (allocate_completion) {
1762 command->completion = 1762 command->completion =
1763 kzalloc(sizeof(struct completion), mem_flags); 1763 kzalloc(sizeof(struct completion), mem_flags);
1764 if (!command->completion) { 1764 if (!command->completion) {
1765 xhci_free_container_ctx(xhci, command->in_ctx); 1765 xhci_free_container_ctx(xhci, command->in_ctx);
1766 kfree(command); 1766 kfree(command);
1767 return NULL; 1767 return NULL;
1768 } 1768 }
1769 init_completion(command->completion); 1769 init_completion(command->completion);
1770 } 1770 }
1771 1771
1772 command->status = 0; 1772 command->status = 0;
1773 INIT_LIST_HEAD(&command->cmd_list); 1773 INIT_LIST_HEAD(&command->cmd_list);
1774 return command; 1774 return command;
1775 } 1775 }
1776 1776
1777 void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv) 1777 void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv)
1778 { 1778 {
1779 if (urb_priv) { 1779 if (urb_priv) {
1780 kfree(urb_priv->td[0]); 1780 kfree(urb_priv->td[0]);
1781 kfree(urb_priv); 1781 kfree(urb_priv);
1782 } 1782 }
1783 } 1783 }
1784 1784
1785 void xhci_free_command(struct xhci_hcd *xhci, 1785 void xhci_free_command(struct xhci_hcd *xhci,
1786 struct xhci_command *command) 1786 struct xhci_command *command)
1787 { 1787 {
1788 xhci_free_container_ctx(xhci, 1788 xhci_free_container_ctx(xhci,
1789 command->in_ctx); 1789 command->in_ctx);
1790 kfree(command->completion); 1790 kfree(command->completion);
1791 kfree(command); 1791 kfree(command);
1792 } 1792 }
1793 1793
1794 void xhci_mem_cleanup(struct xhci_hcd *xhci) 1794 void xhci_mem_cleanup(struct xhci_hcd *xhci)
1795 { 1795 {
1796 struct device *dev = xhci_to_hcd(xhci)->self.controller; 1796 struct device *dev = xhci_to_hcd(xhci)->self.controller;
1797 struct xhci_cd *cur_cd, *next_cd; 1797 struct xhci_cd *cur_cd, *next_cd;
1798 int size; 1798 int size;
1799 int i, j, num_ports; 1799 int i, j, num_ports;
1800 1800
1801 /* Free the Event Ring Segment Table and the actual Event Ring */ 1801 /* Free the Event Ring Segment Table and the actual Event Ring */
1802 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 1802 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
1803 if (xhci->erst.entries) 1803 if (xhci->erst.entries)
1804 dma_free_coherent(dev, size, 1804 dma_free_coherent(dev, size,
1805 xhci->erst.entries, xhci->erst.erst_dma_addr); 1805 xhci->erst.entries, xhci->erst.erst_dma_addr);
1806 xhci->erst.entries = NULL; 1806 xhci->erst.entries = NULL;
1807 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed ERST"); 1807 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed ERST");
1808 if (xhci->event_ring) 1808 if (xhci->event_ring)
1809 xhci_ring_free(xhci, xhci->event_ring); 1809 xhci_ring_free(xhci, xhci->event_ring);
1810 xhci->event_ring = NULL; 1810 xhci->event_ring = NULL;
1811 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed event ring"); 1811 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed event ring");
1812 1812
1813 if (xhci->lpm_command) 1813 if (xhci->lpm_command)
1814 xhci_free_command(xhci, xhci->lpm_command); 1814 xhci_free_command(xhci, xhci->lpm_command);
1815 if (xhci->cmd_ring) 1815 if (xhci->cmd_ring)
1816 xhci_ring_free(xhci, xhci->cmd_ring); 1816 xhci_ring_free(xhci, xhci->cmd_ring);
1817 xhci->cmd_ring = NULL; 1817 xhci->cmd_ring = NULL;
1818 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed command ring"); 1818 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed command ring");
1819 list_for_each_entry_safe(cur_cd, next_cd, 1819 list_for_each_entry_safe(cur_cd, next_cd,
1820 &xhci->cancel_cmd_list, cancel_cmd_list) { 1820 &xhci->cancel_cmd_list, cancel_cmd_list) {
1821 list_del(&cur_cd->cancel_cmd_list); 1821 list_del(&cur_cd->cancel_cmd_list);
1822 kfree(cur_cd); 1822 kfree(cur_cd);
1823 } 1823 }
1824 1824
1825 num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
1826 for (i = 0; i < num_ports; i++) {
1827 struct xhci_interval_bw_table *bwt = &xhci->rh_bw[i].bw_table;
1828 for (j = 0; j < XHCI_MAX_INTERVAL; j++) {
1829 struct list_head *ep = &bwt->interval_bw[j].endpoints;
1830 while (!list_empty(ep))
1831 list_del_init(ep->next);
1832 }
1833 }
1834
1825 for (i = 1; i < MAX_HC_SLOTS; ++i) 1835 for (i = 1; i < MAX_HC_SLOTS; ++i)
1826 xhci_free_virt_device(xhci, i); 1836 xhci_free_virt_device(xhci, i);
1827 1837
1828 if (xhci->segment_pool) 1838 if (xhci->segment_pool)
1829 dma_pool_destroy(xhci->segment_pool); 1839 dma_pool_destroy(xhci->segment_pool);
1830 xhci->segment_pool = NULL; 1840 xhci->segment_pool = NULL;
1831 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed segment pool"); 1841 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed segment pool");
1832 1842
1833 if (xhci->device_pool) 1843 if (xhci->device_pool)
1834 dma_pool_destroy(xhci->device_pool); 1844 dma_pool_destroy(xhci->device_pool);
1835 xhci->device_pool = NULL; 1845 xhci->device_pool = NULL;
1836 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed device context pool"); 1846 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed device context pool");
1837 1847
1838 if (xhci->small_streams_pool) 1848 if (xhci->small_streams_pool)
1839 dma_pool_destroy(xhci->small_streams_pool); 1849 dma_pool_destroy(xhci->small_streams_pool);
1840 xhci->small_streams_pool = NULL; 1850 xhci->small_streams_pool = NULL;
1841 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 1851 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
1842 "Freed small stream array pool"); 1852 "Freed small stream array pool");
1843 1853
1844 if (xhci->medium_streams_pool) 1854 if (xhci->medium_streams_pool)
1845 dma_pool_destroy(xhci->medium_streams_pool); 1855 dma_pool_destroy(xhci->medium_streams_pool);
1846 xhci->medium_streams_pool = NULL; 1856 xhci->medium_streams_pool = NULL;
1847 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 1857 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
1848 "Freed medium stream array pool"); 1858 "Freed medium stream array pool");
1849 1859
1850 if (xhci->dcbaa) 1860 if (xhci->dcbaa)
1851 dma_free_coherent(dev, sizeof(*xhci->dcbaa), 1861 dma_free_coherent(dev, sizeof(*xhci->dcbaa),
1852 xhci->dcbaa, xhci->dcbaa->dma); 1862 xhci->dcbaa, xhci->dcbaa->dma);
1853 xhci->dcbaa = NULL; 1863 xhci->dcbaa = NULL;
1854 1864
1855 scratchpad_free(xhci); 1865 scratchpad_free(xhci);
1856 1866
1857 if (!xhci->rh_bw) 1867 if (!xhci->rh_bw)
1858 goto no_bw; 1868 goto no_bw;
1859
1860 num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
1861 for (i = 0; i < num_ports; i++) {
1862 struct xhci_interval_bw_table *bwt = &xhci->rh_bw[i].bw_table;
1863 for (j = 0; j < XHCI_MAX_INTERVAL; j++) {
1864 struct list_head *ep = &bwt->interval_bw[j].endpoints;
1865 while (!list_empty(ep))
1866 list_del_init(ep->next);
1867 }
1868 }
1869 1869
1870 for (i = 0; i < num_ports; i++) { 1870 for (i = 0; i < num_ports; i++) {
1871 struct xhci_tt_bw_info *tt, *n; 1871 struct xhci_tt_bw_info *tt, *n;
1872 list_for_each_entry_safe(tt, n, &xhci->rh_bw[i].tts, tt_list) { 1872 list_for_each_entry_safe(tt, n, &xhci->rh_bw[i].tts, tt_list) {
1873 list_del(&tt->tt_list); 1873 list_del(&tt->tt_list);
1874 kfree(tt); 1874 kfree(tt);
1875 } 1875 }
1876 } 1876 }
1877 1877
1878 no_bw: 1878 no_bw:
1879 xhci->cmd_ring_reserved_trbs = 0; 1879 xhci->cmd_ring_reserved_trbs = 0;
1880 xhci->num_usb2_ports = 0; 1880 xhci->num_usb2_ports = 0;
1881 xhci->num_usb3_ports = 0; 1881 xhci->num_usb3_ports = 0;
1882 xhci->num_active_eps = 0; 1882 xhci->num_active_eps = 0;
1883 kfree(xhci->usb2_ports); 1883 kfree(xhci->usb2_ports);
1884 kfree(xhci->usb3_ports); 1884 kfree(xhci->usb3_ports);
1885 kfree(xhci->port_array); 1885 kfree(xhci->port_array);
1886 kfree(xhci->rh_bw); 1886 kfree(xhci->rh_bw);
1887 kfree(xhci->ext_caps); 1887 kfree(xhci->ext_caps);
1888 1888
1889 xhci->page_size = 0; 1889 xhci->page_size = 0;
1890 xhci->page_shift = 0; 1890 xhci->page_shift = 0;
1891 xhci->bus_state[0].bus_suspended = 0; 1891 xhci->bus_state[0].bus_suspended = 0;
1892 xhci->bus_state[1].bus_suspended = 0; 1892 xhci->bus_state[1].bus_suspended = 0;
1893 } 1893 }
1894 1894
1895 static int xhci_test_trb_in_td(struct xhci_hcd *xhci, 1895 static int xhci_test_trb_in_td(struct xhci_hcd *xhci,
1896 struct xhci_segment *input_seg, 1896 struct xhci_segment *input_seg,
1897 union xhci_trb *start_trb, 1897 union xhci_trb *start_trb,
1898 union xhci_trb *end_trb, 1898 union xhci_trb *end_trb,
1899 dma_addr_t input_dma, 1899 dma_addr_t input_dma,
1900 struct xhci_segment *result_seg, 1900 struct xhci_segment *result_seg,
1901 char *test_name, int test_number) 1901 char *test_name, int test_number)
1902 { 1902 {
1903 unsigned long long start_dma; 1903 unsigned long long start_dma;
1904 unsigned long long end_dma; 1904 unsigned long long end_dma;
1905 struct xhci_segment *seg; 1905 struct xhci_segment *seg;
1906 1906
1907 start_dma = xhci_trb_virt_to_dma(input_seg, start_trb); 1907 start_dma = xhci_trb_virt_to_dma(input_seg, start_trb);
1908 end_dma = xhci_trb_virt_to_dma(input_seg, end_trb); 1908 end_dma = xhci_trb_virt_to_dma(input_seg, end_trb);
1909 1909
1910 seg = trb_in_td(input_seg, start_trb, end_trb, input_dma); 1910 seg = trb_in_td(input_seg, start_trb, end_trb, input_dma);
1911 if (seg != result_seg) { 1911 if (seg != result_seg) {
1912 xhci_warn(xhci, "WARN: %s TRB math test %d failed!\n", 1912 xhci_warn(xhci, "WARN: %s TRB math test %d failed!\n",
1913 test_name, test_number); 1913 test_name, test_number);
1914 xhci_warn(xhci, "Tested TRB math w/ seg %p and " 1914 xhci_warn(xhci, "Tested TRB math w/ seg %p and "
1915 "input DMA 0x%llx\n", 1915 "input DMA 0x%llx\n",
1916 input_seg, 1916 input_seg,
1917 (unsigned long long) input_dma); 1917 (unsigned long long) input_dma);
1918 xhci_warn(xhci, "starting TRB %p (0x%llx DMA), " 1918 xhci_warn(xhci, "starting TRB %p (0x%llx DMA), "
1919 "ending TRB %p (0x%llx DMA)\n", 1919 "ending TRB %p (0x%llx DMA)\n",
1920 start_trb, start_dma, 1920 start_trb, start_dma,
1921 end_trb, end_dma); 1921 end_trb, end_dma);
1922 xhci_warn(xhci, "Expected seg %p, got seg %p\n", 1922 xhci_warn(xhci, "Expected seg %p, got seg %p\n",
1923 result_seg, seg); 1923 result_seg, seg);
1924 return -1; 1924 return -1;
1925 } 1925 }
1926 return 0; 1926 return 0;
1927 } 1927 }
1928 1928
1929 /* TRB math checks for xhci_trb_in_td(), using the command and event rings. */ 1929 /* TRB math checks for xhci_trb_in_td(), using the command and event rings. */
1930 static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags) 1930 static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags)
1931 { 1931 {
1932 struct { 1932 struct {
1933 dma_addr_t input_dma; 1933 dma_addr_t input_dma;
1934 struct xhci_segment *result_seg; 1934 struct xhci_segment *result_seg;
1935 } simple_test_vector [] = { 1935 } simple_test_vector [] = {
1936 /* A zeroed DMA field should fail */ 1936 /* A zeroed DMA field should fail */
1937 { 0, NULL }, 1937 { 0, NULL },
1938 /* One TRB before the ring start should fail */ 1938 /* One TRB before the ring start should fail */
1939 { xhci->event_ring->first_seg->dma - 16, NULL }, 1939 { xhci->event_ring->first_seg->dma - 16, NULL },
1940 /* One byte before the ring start should fail */ 1940 /* One byte before the ring start should fail */
1941 { xhci->event_ring->first_seg->dma - 1, NULL }, 1941 { xhci->event_ring->first_seg->dma - 1, NULL },
1942 /* Starting TRB should succeed */ 1942 /* Starting TRB should succeed */
1943 { xhci->event_ring->first_seg->dma, xhci->event_ring->first_seg }, 1943 { xhci->event_ring->first_seg->dma, xhci->event_ring->first_seg },
1944 /* Ending TRB should succeed */ 1944 /* Ending TRB should succeed */
1945 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16, 1945 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16,
1946 xhci->event_ring->first_seg }, 1946 xhci->event_ring->first_seg },
1947 /* One byte after the ring end should fail */ 1947 /* One byte after the ring end should fail */
1948 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16 + 1, NULL }, 1948 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16 + 1, NULL },
1949 /* One TRB after the ring end should fail */ 1949 /* One TRB after the ring end should fail */
1950 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT)*16, NULL }, 1950 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT)*16, NULL },
1951 /* An address of all ones should fail */ 1951 /* An address of all ones should fail */
1952 { (dma_addr_t) (~0), NULL }, 1952 { (dma_addr_t) (~0), NULL },
1953 }; 1953 };
1954 struct { 1954 struct {
1955 struct xhci_segment *input_seg; 1955 struct xhci_segment *input_seg;
1956 union xhci_trb *start_trb; 1956 union xhci_trb *start_trb;
1957 union xhci_trb *end_trb; 1957 union xhci_trb *end_trb;
1958 dma_addr_t input_dma; 1958 dma_addr_t input_dma;
1959 struct xhci_segment *result_seg; 1959 struct xhci_segment *result_seg;
1960 } complex_test_vector [] = { 1960 } complex_test_vector [] = {
1961 /* Test feeding a valid DMA address from a different ring */ 1961 /* Test feeding a valid DMA address from a different ring */
1962 { .input_seg = xhci->event_ring->first_seg, 1962 { .input_seg = xhci->event_ring->first_seg,
1963 .start_trb = xhci->event_ring->first_seg->trbs, 1963 .start_trb = xhci->event_ring->first_seg->trbs,
1964 .end_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1], 1964 .end_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
1965 .input_dma = xhci->cmd_ring->first_seg->dma, 1965 .input_dma = xhci->cmd_ring->first_seg->dma,
1966 .result_seg = NULL, 1966 .result_seg = NULL,
1967 }, 1967 },
1968 /* Test feeding a valid end TRB from a different ring */ 1968 /* Test feeding a valid end TRB from a different ring */
1969 { .input_seg = xhci->event_ring->first_seg, 1969 { .input_seg = xhci->event_ring->first_seg,
1970 .start_trb = xhci->event_ring->first_seg->trbs, 1970 .start_trb = xhci->event_ring->first_seg->trbs,
1971 .end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1], 1971 .end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
1972 .input_dma = xhci->cmd_ring->first_seg->dma, 1972 .input_dma = xhci->cmd_ring->first_seg->dma,
1973 .result_seg = NULL, 1973 .result_seg = NULL,
1974 }, 1974 },
1975 /* Test feeding a valid start and end TRB from a different ring */ 1975 /* Test feeding a valid start and end TRB from a different ring */
1976 { .input_seg = xhci->event_ring->first_seg, 1976 { .input_seg = xhci->event_ring->first_seg,
1977 .start_trb = xhci->cmd_ring->first_seg->trbs, 1977 .start_trb = xhci->cmd_ring->first_seg->trbs,
1978 .end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1], 1978 .end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
1979 .input_dma = xhci->cmd_ring->first_seg->dma, 1979 .input_dma = xhci->cmd_ring->first_seg->dma,
1980 .result_seg = NULL, 1980 .result_seg = NULL,
1981 }, 1981 },
1982 /* TRB in this ring, but after this TD */ 1982 /* TRB in this ring, but after this TD */
1983 { .input_seg = xhci->event_ring->first_seg, 1983 { .input_seg = xhci->event_ring->first_seg,
1984 .start_trb = &xhci->event_ring->first_seg->trbs[0], 1984 .start_trb = &xhci->event_ring->first_seg->trbs[0],
1985 .end_trb = &xhci->event_ring->first_seg->trbs[3], 1985 .end_trb = &xhci->event_ring->first_seg->trbs[3],
1986 .input_dma = xhci->event_ring->first_seg->dma + 4*16, 1986 .input_dma = xhci->event_ring->first_seg->dma + 4*16,
1987 .result_seg = NULL, 1987 .result_seg = NULL,
1988 }, 1988 },
1989 /* TRB in this ring, but before this TD */ 1989 /* TRB in this ring, but before this TD */
1990 { .input_seg = xhci->event_ring->first_seg, 1990 { .input_seg = xhci->event_ring->first_seg,
1991 .start_trb = &xhci->event_ring->first_seg->trbs[3], 1991 .start_trb = &xhci->event_ring->first_seg->trbs[3],
1992 .end_trb = &xhci->event_ring->first_seg->trbs[6], 1992 .end_trb = &xhci->event_ring->first_seg->trbs[6],
1993 .input_dma = xhci->event_ring->first_seg->dma + 2*16, 1993 .input_dma = xhci->event_ring->first_seg->dma + 2*16,
1994 .result_seg = NULL, 1994 .result_seg = NULL,
1995 }, 1995 },
1996 /* TRB in this ring, but after this wrapped TD */ 1996 /* TRB in this ring, but after this wrapped TD */
1997 { .input_seg = xhci->event_ring->first_seg, 1997 { .input_seg = xhci->event_ring->first_seg,
1998 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3], 1998 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
1999 .end_trb = &xhci->event_ring->first_seg->trbs[1], 1999 .end_trb = &xhci->event_ring->first_seg->trbs[1],
2000 .input_dma = xhci->event_ring->first_seg->dma + 2*16, 2000 .input_dma = xhci->event_ring->first_seg->dma + 2*16,
2001 .result_seg = NULL, 2001 .result_seg = NULL,
2002 }, 2002 },
2003 /* TRB in this ring, but before this wrapped TD */ 2003 /* TRB in this ring, but before this wrapped TD */
2004 { .input_seg = xhci->event_ring->first_seg, 2004 { .input_seg = xhci->event_ring->first_seg,
2005 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3], 2005 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
2006 .end_trb = &xhci->event_ring->first_seg->trbs[1], 2006 .end_trb = &xhci->event_ring->first_seg->trbs[1],
2007 .input_dma = xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 4)*16, 2007 .input_dma = xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 4)*16,
2008 .result_seg = NULL, 2008 .result_seg = NULL,
2009 }, 2009 },
2010 /* TRB not in this ring, and we have a wrapped TD */ 2010 /* TRB not in this ring, and we have a wrapped TD */
2011 { .input_seg = xhci->event_ring->first_seg, 2011 { .input_seg = xhci->event_ring->first_seg,
2012 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3], 2012 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
2013 .end_trb = &xhci->event_ring->first_seg->trbs[1], 2013 .end_trb = &xhci->event_ring->first_seg->trbs[1],
2014 .input_dma = xhci->cmd_ring->first_seg->dma + 2*16, 2014 .input_dma = xhci->cmd_ring->first_seg->dma + 2*16,
2015 .result_seg = NULL, 2015 .result_seg = NULL,
2016 }, 2016 },
2017 }; 2017 };
2018 2018
2019 unsigned int num_tests; 2019 unsigned int num_tests;
2020 int i, ret; 2020 int i, ret;
2021 2021
2022 num_tests = ARRAY_SIZE(simple_test_vector); 2022 num_tests = ARRAY_SIZE(simple_test_vector);
2023 for (i = 0; i < num_tests; i++) { 2023 for (i = 0; i < num_tests; i++) {
2024 ret = xhci_test_trb_in_td(xhci, 2024 ret = xhci_test_trb_in_td(xhci,
2025 xhci->event_ring->first_seg, 2025 xhci->event_ring->first_seg,
2026 xhci->event_ring->first_seg->trbs, 2026 xhci->event_ring->first_seg->trbs,
2027 &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1], 2027 &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
2028 simple_test_vector[i].input_dma, 2028 simple_test_vector[i].input_dma,
2029 simple_test_vector[i].result_seg, 2029 simple_test_vector[i].result_seg,
2030 "Simple", i); 2030 "Simple", i);
2031 if (ret < 0) 2031 if (ret < 0)
2032 return ret; 2032 return ret;
2033 } 2033 }
2034 2034
2035 num_tests = ARRAY_SIZE(complex_test_vector); 2035 num_tests = ARRAY_SIZE(complex_test_vector);
2036 for (i = 0; i < num_tests; i++) { 2036 for (i = 0; i < num_tests; i++) {
2037 ret = xhci_test_trb_in_td(xhci, 2037 ret = xhci_test_trb_in_td(xhci,
2038 complex_test_vector[i].input_seg, 2038 complex_test_vector[i].input_seg,
2039 complex_test_vector[i].start_trb, 2039 complex_test_vector[i].start_trb,
2040 complex_test_vector[i].end_trb, 2040 complex_test_vector[i].end_trb,
2041 complex_test_vector[i].input_dma, 2041 complex_test_vector[i].input_dma,
2042 complex_test_vector[i].result_seg, 2042 complex_test_vector[i].result_seg,
2043 "Complex", i); 2043 "Complex", i);
2044 if (ret < 0) 2044 if (ret < 0)
2045 return ret; 2045 return ret;
2046 } 2046 }
2047 xhci_dbg(xhci, "TRB math tests passed.\n"); 2047 xhci_dbg(xhci, "TRB math tests passed.\n");
2048 return 0; 2048 return 0;
2049 } 2049 }
2050 2050
2051 static void xhci_set_hc_event_deq(struct xhci_hcd *xhci) 2051 static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
2052 { 2052 {
2053 u64 temp; 2053 u64 temp;
2054 dma_addr_t deq; 2054 dma_addr_t deq;
2055 2055
2056 deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, 2056 deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg,
2057 xhci->event_ring->dequeue); 2057 xhci->event_ring->dequeue);
2058 if (deq == 0 && !in_interrupt()) 2058 if (deq == 0 && !in_interrupt())
2059 xhci_warn(xhci, "WARN something wrong with SW event ring " 2059 xhci_warn(xhci, "WARN something wrong with SW event ring "
2060 "dequeue ptr.\n"); 2060 "dequeue ptr.\n");
2061 /* Update HC event ring dequeue pointer */ 2061 /* Update HC event ring dequeue pointer */
2062 temp = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); 2062 temp = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
2063 temp &= ERST_PTR_MASK; 2063 temp &= ERST_PTR_MASK;
2064 /* Don't clear the EHB bit (which is RW1C) because 2064 /* Don't clear the EHB bit (which is RW1C) because
2065 * there might be more events to service. 2065 * there might be more events to service.
2066 */ 2066 */
2067 temp &= ~ERST_EHB; 2067 temp &= ~ERST_EHB;
2068 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2068 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2069 "// Write event ring dequeue pointer, " 2069 "// Write event ring dequeue pointer, "
2070 "preserving EHB bit"); 2070 "preserving EHB bit");
2071 xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp, 2071 xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp,
2072 &xhci->ir_set->erst_dequeue); 2072 &xhci->ir_set->erst_dequeue);
2073 } 2073 }
2074 2074
2075 static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, 2075 static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
2076 __le32 __iomem *addr, u8 major_revision, int max_caps) 2076 __le32 __iomem *addr, u8 major_revision, int max_caps)
2077 { 2077 {
2078 u32 temp, port_offset, port_count; 2078 u32 temp, port_offset, port_count;
2079 int i; 2079 int i;
2080 2080
2081 if (major_revision > 0x03) { 2081 if (major_revision > 0x03) {
2082 xhci_warn(xhci, "Ignoring unknown port speed, " 2082 xhci_warn(xhci, "Ignoring unknown port speed, "
2083 "Ext Cap %p, revision = 0x%x\n", 2083 "Ext Cap %p, revision = 0x%x\n",
2084 addr, major_revision); 2084 addr, major_revision);
2085 /* Ignoring port protocol we can't understand. FIXME */ 2085 /* Ignoring port protocol we can't understand. FIXME */
2086 return; 2086 return;
2087 } 2087 }
2088 2088
2089 /* Port offset and count in the third dword, see section 7.2 */ 2089 /* Port offset and count in the third dword, see section 7.2 */
2090 temp = readl(addr + 2); 2090 temp = readl(addr + 2);
2091 port_offset = XHCI_EXT_PORT_OFF(temp); 2091 port_offset = XHCI_EXT_PORT_OFF(temp);
2092 port_count = XHCI_EXT_PORT_COUNT(temp); 2092 port_count = XHCI_EXT_PORT_COUNT(temp);
2093 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2093 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2094 "Ext Cap %p, port offset = %u, " 2094 "Ext Cap %p, port offset = %u, "
2095 "count = %u, revision = 0x%x", 2095 "count = %u, revision = 0x%x",
2096 addr, port_offset, port_count, major_revision); 2096 addr, port_offset, port_count, major_revision);
2097 /* Port count includes the current port offset */ 2097 /* Port count includes the current port offset */
2098 if (port_offset == 0 || (port_offset + port_count - 1) > num_ports) 2098 if (port_offset == 0 || (port_offset + port_count - 1) > num_ports)
2099 /* WTF? "Valid values are โ€˜1โ€™ to MaxPorts" */ 2099 /* WTF? "Valid values are โ€˜1โ€™ to MaxPorts" */
2100 return; 2100 return;
2101 2101
2102 /* cache usb2 port capabilities */ 2102 /* cache usb2 port capabilities */
2103 if (major_revision < 0x03 && xhci->num_ext_caps < max_caps) 2103 if (major_revision < 0x03 && xhci->num_ext_caps < max_caps)
2104 xhci->ext_caps[xhci->num_ext_caps++] = temp; 2104 xhci->ext_caps[xhci->num_ext_caps++] = temp;
2105 2105
2106 /* Check the host's USB2 LPM capability */ 2106 /* Check the host's USB2 LPM capability */
2107 if ((xhci->hci_version == 0x96) && (major_revision != 0x03) && 2107 if ((xhci->hci_version == 0x96) && (major_revision != 0x03) &&
2108 (temp & XHCI_L1C)) { 2108 (temp & XHCI_L1C)) {
2109 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2109 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2110 "xHCI 0.96: support USB2 software lpm"); 2110 "xHCI 0.96: support USB2 software lpm");
2111 xhci->sw_lpm_support = 1; 2111 xhci->sw_lpm_support = 1;
2112 } 2112 }
2113 2113
2114 if ((xhci->hci_version >= 0x100) && (major_revision != 0x03)) { 2114 if ((xhci->hci_version >= 0x100) && (major_revision != 0x03)) {
2115 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2115 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2116 "xHCI 1.0: support USB2 software lpm"); 2116 "xHCI 1.0: support USB2 software lpm");
2117 xhci->sw_lpm_support = 1; 2117 xhci->sw_lpm_support = 1;
2118 if (temp & XHCI_HLC) { 2118 if (temp & XHCI_HLC) {
2119 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2119 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2120 "xHCI 1.0: support USB2 hardware lpm"); 2120 "xHCI 1.0: support USB2 hardware lpm");
2121 xhci->hw_lpm_support = 1; 2121 xhci->hw_lpm_support = 1;
2122 } 2122 }
2123 } 2123 }
2124 2124
2125 port_offset--; 2125 port_offset--;
2126 for (i = port_offset; i < (port_offset + port_count); i++) { 2126 for (i = port_offset; i < (port_offset + port_count); i++) {
2127 /* Duplicate entry. Ignore the port if the revisions differ. */ 2127 /* Duplicate entry. Ignore the port if the revisions differ. */
2128 if (xhci->port_array[i] != 0) { 2128 if (xhci->port_array[i] != 0) {
2129 xhci_warn(xhci, "Duplicate port entry, Ext Cap %p," 2129 xhci_warn(xhci, "Duplicate port entry, Ext Cap %p,"
2130 " port %u\n", addr, i); 2130 " port %u\n", addr, i);
2131 xhci_warn(xhci, "Port was marked as USB %u, " 2131 xhci_warn(xhci, "Port was marked as USB %u, "
2132 "duplicated as USB %u\n", 2132 "duplicated as USB %u\n",
2133 xhci->port_array[i], major_revision); 2133 xhci->port_array[i], major_revision);
2134 /* Only adjust the roothub port counts if we haven't 2134 /* Only adjust the roothub port counts if we haven't
2135 * found a similar duplicate. 2135 * found a similar duplicate.
2136 */ 2136 */
2137 if (xhci->port_array[i] != major_revision && 2137 if (xhci->port_array[i] != major_revision &&
2138 xhci->port_array[i] != DUPLICATE_ENTRY) { 2138 xhci->port_array[i] != DUPLICATE_ENTRY) {
2139 if (xhci->port_array[i] == 0x03) 2139 if (xhci->port_array[i] == 0x03)
2140 xhci->num_usb3_ports--; 2140 xhci->num_usb3_ports--;
2141 else 2141 else
2142 xhci->num_usb2_ports--; 2142 xhci->num_usb2_ports--;
2143 xhci->port_array[i] = DUPLICATE_ENTRY; 2143 xhci->port_array[i] = DUPLICATE_ENTRY;
2144 } 2144 }
2145 /* FIXME: Should we disable the port? */ 2145 /* FIXME: Should we disable the port? */
2146 continue; 2146 continue;
2147 } 2147 }
2148 xhci->port_array[i] = major_revision; 2148 xhci->port_array[i] = major_revision;
2149 if (major_revision == 0x03) 2149 if (major_revision == 0x03)
2150 xhci->num_usb3_ports++; 2150 xhci->num_usb3_ports++;
2151 else 2151 else
2152 xhci->num_usb2_ports++; 2152 xhci->num_usb2_ports++;
2153 } 2153 }
2154 /* FIXME: Should we disable ports not in the Extended Capabilities? */ 2154 /* FIXME: Should we disable ports not in the Extended Capabilities? */
2155 } 2155 }
2156 2156
2157 /* 2157 /*
2158 * Scan the Extended Capabilities for the "Supported Protocol Capabilities" that 2158 * Scan the Extended Capabilities for the "Supported Protocol Capabilities" that
2159 * specify what speeds each port is supposed to be. We can't count on the port 2159 * specify what speeds each port is supposed to be. We can't count on the port
2160 * speed bits in the PORTSC register being correct until a device is connected, 2160 * speed bits in the PORTSC register being correct until a device is connected,
2161 * but we need to set up the two fake roothubs with the correct number of USB 2161 * but we need to set up the two fake roothubs with the correct number of USB
2162 * 3.0 and USB 2.0 ports at host controller initialization time. 2162 * 3.0 and USB 2.0 ports at host controller initialization time.
2163 */ 2163 */
2164 static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) 2164 static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
2165 { 2165 {
2166 __le32 __iomem *addr, *tmp_addr; 2166 __le32 __iomem *addr, *tmp_addr;
2167 u32 offset, tmp_offset; 2167 u32 offset, tmp_offset;
2168 unsigned int num_ports; 2168 unsigned int num_ports;
2169 int i, j, port_index; 2169 int i, j, port_index;
2170 int cap_count = 0; 2170 int cap_count = 0;
2171 2171
2172 addr = &xhci->cap_regs->hcc_params; 2172 addr = &xhci->cap_regs->hcc_params;
2173 offset = XHCI_HCC_EXT_CAPS(readl(addr)); 2173 offset = XHCI_HCC_EXT_CAPS(readl(addr));
2174 if (offset == 0) { 2174 if (offset == 0) {
2175 xhci_err(xhci, "No Extended Capability registers, " 2175 xhci_err(xhci, "No Extended Capability registers, "
2176 "unable to set up roothub.\n"); 2176 "unable to set up roothub.\n");
2177 return -ENODEV; 2177 return -ENODEV;
2178 } 2178 }
2179 2179
2180 num_ports = HCS_MAX_PORTS(xhci->hcs_params1); 2180 num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
2181 xhci->port_array = kzalloc(sizeof(*xhci->port_array)*num_ports, flags); 2181 xhci->port_array = kzalloc(sizeof(*xhci->port_array)*num_ports, flags);
2182 if (!xhci->port_array) 2182 if (!xhci->port_array)
2183 return -ENOMEM; 2183 return -ENOMEM;
2184 2184
2185 xhci->rh_bw = kzalloc(sizeof(*xhci->rh_bw)*num_ports, flags); 2185 xhci->rh_bw = kzalloc(sizeof(*xhci->rh_bw)*num_ports, flags);
2186 if (!xhci->rh_bw) 2186 if (!xhci->rh_bw)
2187 return -ENOMEM; 2187 return -ENOMEM;
2188 for (i = 0; i < num_ports; i++) { 2188 for (i = 0; i < num_ports; i++) {
2189 struct xhci_interval_bw_table *bw_table; 2189 struct xhci_interval_bw_table *bw_table;
2190 2190
2191 INIT_LIST_HEAD(&xhci->rh_bw[i].tts); 2191 INIT_LIST_HEAD(&xhci->rh_bw[i].tts);
2192 bw_table = &xhci->rh_bw[i].bw_table; 2192 bw_table = &xhci->rh_bw[i].bw_table;
2193 for (j = 0; j < XHCI_MAX_INTERVAL; j++) 2193 for (j = 0; j < XHCI_MAX_INTERVAL; j++)
2194 INIT_LIST_HEAD(&bw_table->interval_bw[j].endpoints); 2194 INIT_LIST_HEAD(&bw_table->interval_bw[j].endpoints);
2195 } 2195 }
2196 2196
2197 /* 2197 /*
2198 * For whatever reason, the first capability offset is from the 2198 * For whatever reason, the first capability offset is from the
2199 * capability register base, not from the HCCPARAMS register. 2199 * capability register base, not from the HCCPARAMS register.
2200 * See section 5.3.6 for offset calculation. 2200 * See section 5.3.6 for offset calculation.
2201 */ 2201 */
2202 addr = &xhci->cap_regs->hc_capbase + offset; 2202 addr = &xhci->cap_regs->hc_capbase + offset;
2203 2203
2204 tmp_addr = addr; 2204 tmp_addr = addr;
2205 tmp_offset = offset; 2205 tmp_offset = offset;
2206 2206
2207 /* count extended protocol capability entries for later caching */ 2207 /* count extended protocol capability entries for later caching */
2208 do { 2208 do {
2209 u32 cap_id; 2209 u32 cap_id;
2210 cap_id = readl(tmp_addr); 2210 cap_id = readl(tmp_addr);
2211 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL) 2211 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL)
2212 cap_count++; 2212 cap_count++;
2213 tmp_offset = XHCI_EXT_CAPS_NEXT(cap_id); 2213 tmp_offset = XHCI_EXT_CAPS_NEXT(cap_id);
2214 tmp_addr += tmp_offset; 2214 tmp_addr += tmp_offset;
2215 } while (tmp_offset); 2215 } while (tmp_offset);
2216 2216
2217 xhci->ext_caps = kzalloc(sizeof(*xhci->ext_caps) * cap_count, flags); 2217 xhci->ext_caps = kzalloc(sizeof(*xhci->ext_caps) * cap_count, flags);
2218 if (!xhci->ext_caps) 2218 if (!xhci->ext_caps)
2219 return -ENOMEM; 2219 return -ENOMEM;
2220 2220
2221 while (1) { 2221 while (1) {
2222 u32 cap_id; 2222 u32 cap_id;
2223 2223
2224 cap_id = readl(addr); 2224 cap_id = readl(addr);
2225 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL) 2225 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL)
2226 xhci_add_in_port(xhci, num_ports, addr, 2226 xhci_add_in_port(xhci, num_ports, addr,
2227 (u8) XHCI_EXT_PORT_MAJOR(cap_id), 2227 (u8) XHCI_EXT_PORT_MAJOR(cap_id),
2228 cap_count); 2228 cap_count);
2229 offset = XHCI_EXT_CAPS_NEXT(cap_id); 2229 offset = XHCI_EXT_CAPS_NEXT(cap_id);
2230 if (!offset || (xhci->num_usb2_ports + xhci->num_usb3_ports) 2230 if (!offset || (xhci->num_usb2_ports + xhci->num_usb3_ports)
2231 == num_ports) 2231 == num_ports)
2232 break; 2232 break;
2233 /* 2233 /*
2234 * Once you're into the Extended Capabilities, the offset is 2234 * Once you're into the Extended Capabilities, the offset is
2235 * always relative to the register holding the offset. 2235 * always relative to the register holding the offset.
2236 */ 2236 */
2237 addr += offset; 2237 addr += offset;
2238 } 2238 }
2239 2239
2240 if (xhci->num_usb2_ports == 0 && xhci->num_usb3_ports == 0) { 2240 if (xhci->num_usb2_ports == 0 && xhci->num_usb3_ports == 0) {
2241 xhci_warn(xhci, "No ports on the roothubs?\n"); 2241 xhci_warn(xhci, "No ports on the roothubs?\n");
2242 return -ENODEV; 2242 return -ENODEV;
2243 } 2243 }
2244 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2244 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2245 "Found %u USB 2.0 ports and %u USB 3.0 ports.", 2245 "Found %u USB 2.0 ports and %u USB 3.0 ports.",
2246 xhci->num_usb2_ports, xhci->num_usb3_ports); 2246 xhci->num_usb2_ports, xhci->num_usb3_ports);
2247 2247
2248 /* Place limits on the number of roothub ports so that the hub 2248 /* Place limits on the number of roothub ports so that the hub
2249 * descriptors aren't longer than the USB core will allocate. 2249 * descriptors aren't longer than the USB core will allocate.
2250 */ 2250 */
2251 if (xhci->num_usb3_ports > 15) { 2251 if (xhci->num_usb3_ports > 15) {
2252 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2252 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2253 "Limiting USB 3.0 roothub ports to 15."); 2253 "Limiting USB 3.0 roothub ports to 15.");
2254 xhci->num_usb3_ports = 15; 2254 xhci->num_usb3_ports = 15;
2255 } 2255 }
2256 if (xhci->num_usb2_ports > USB_MAXCHILDREN) { 2256 if (xhci->num_usb2_ports > USB_MAXCHILDREN) {
2257 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2257 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2258 "Limiting USB 2.0 roothub ports to %u.", 2258 "Limiting USB 2.0 roothub ports to %u.",
2259 USB_MAXCHILDREN); 2259 USB_MAXCHILDREN);
2260 xhci->num_usb2_ports = USB_MAXCHILDREN; 2260 xhci->num_usb2_ports = USB_MAXCHILDREN;
2261 } 2261 }
2262 2262
2263 /* 2263 /*
2264 * Note we could have all USB 3.0 ports, or all USB 2.0 ports. 2264 * Note we could have all USB 3.0 ports, or all USB 2.0 ports.
2265 * Not sure how the USB core will handle a hub with no ports... 2265 * Not sure how the USB core will handle a hub with no ports...
2266 */ 2266 */
2267 if (xhci->num_usb2_ports) { 2267 if (xhci->num_usb2_ports) {
2268 xhci->usb2_ports = kmalloc(sizeof(*xhci->usb2_ports)* 2268 xhci->usb2_ports = kmalloc(sizeof(*xhci->usb2_ports)*
2269 xhci->num_usb2_ports, flags); 2269 xhci->num_usb2_ports, flags);
2270 if (!xhci->usb2_ports) 2270 if (!xhci->usb2_ports)
2271 return -ENOMEM; 2271 return -ENOMEM;
2272 2272
2273 port_index = 0; 2273 port_index = 0;
2274 for (i = 0; i < num_ports; i++) { 2274 for (i = 0; i < num_ports; i++) {
2275 if (xhci->port_array[i] == 0x03 || 2275 if (xhci->port_array[i] == 0x03 ||
2276 xhci->port_array[i] == 0 || 2276 xhci->port_array[i] == 0 ||
2277 xhci->port_array[i] == DUPLICATE_ENTRY) 2277 xhci->port_array[i] == DUPLICATE_ENTRY)
2278 continue; 2278 continue;
2279 2279
2280 xhci->usb2_ports[port_index] = 2280 xhci->usb2_ports[port_index] =
2281 &xhci->op_regs->port_status_base + 2281 &xhci->op_regs->port_status_base +
2282 NUM_PORT_REGS*i; 2282 NUM_PORT_REGS*i;
2283 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2283 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2284 "USB 2.0 port at index %u, " 2284 "USB 2.0 port at index %u, "
2285 "addr = %p", i, 2285 "addr = %p", i,
2286 xhci->usb2_ports[port_index]); 2286 xhci->usb2_ports[port_index]);
2287 port_index++; 2287 port_index++;
2288 if (port_index == xhci->num_usb2_ports) 2288 if (port_index == xhci->num_usb2_ports)
2289 break; 2289 break;
2290 } 2290 }
2291 } 2291 }
2292 if (xhci->num_usb3_ports) { 2292 if (xhci->num_usb3_ports) {
2293 xhci->usb3_ports = kmalloc(sizeof(*xhci->usb3_ports)* 2293 xhci->usb3_ports = kmalloc(sizeof(*xhci->usb3_ports)*
2294 xhci->num_usb3_ports, flags); 2294 xhci->num_usb3_ports, flags);
2295 if (!xhci->usb3_ports) 2295 if (!xhci->usb3_ports)
2296 return -ENOMEM; 2296 return -ENOMEM;
2297 2297
2298 port_index = 0; 2298 port_index = 0;
2299 for (i = 0; i < num_ports; i++) 2299 for (i = 0; i < num_ports; i++)
2300 if (xhci->port_array[i] == 0x03) { 2300 if (xhci->port_array[i] == 0x03) {
2301 xhci->usb3_ports[port_index] = 2301 xhci->usb3_ports[port_index] =
2302 &xhci->op_regs->port_status_base + 2302 &xhci->op_regs->port_status_base +
2303 NUM_PORT_REGS*i; 2303 NUM_PORT_REGS*i;
2304 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2304 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2305 "USB 3.0 port at index %u, " 2305 "USB 3.0 port at index %u, "
2306 "addr = %p", i, 2306 "addr = %p", i,
2307 xhci->usb3_ports[port_index]); 2307 xhci->usb3_ports[port_index]);
2308 port_index++; 2308 port_index++;
2309 if (port_index == xhci->num_usb3_ports) 2309 if (port_index == xhci->num_usb3_ports)
2310 break; 2310 break;
2311 } 2311 }
2312 } 2312 }
2313 return 0; 2313 return 0;
2314 } 2314 }
2315 2315
2316 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) 2316 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2317 { 2317 {
2318 dma_addr_t dma; 2318 dma_addr_t dma;
2319 struct device *dev = xhci_to_hcd(xhci)->self.controller; 2319 struct device *dev = xhci_to_hcd(xhci)->self.controller;
2320 unsigned int val, val2; 2320 unsigned int val, val2;
2321 u64 val_64; 2321 u64 val_64;
2322 struct xhci_segment *seg; 2322 struct xhci_segment *seg;
2323 u32 page_size, temp; 2323 u32 page_size, temp;
2324 int i; 2324 int i;
2325 2325
2326 INIT_LIST_HEAD(&xhci->cancel_cmd_list); 2326 INIT_LIST_HEAD(&xhci->cancel_cmd_list);
2327 2327
2328 page_size = readl(&xhci->op_regs->page_size); 2328 page_size = readl(&xhci->op_regs->page_size);
2329 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2329 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2330 "Supported page size register = 0x%x", page_size); 2330 "Supported page size register = 0x%x", page_size);
2331 for (i = 0; i < 16; i++) { 2331 for (i = 0; i < 16; i++) {
2332 if ((0x1 & page_size) != 0) 2332 if ((0x1 & page_size) != 0)
2333 break; 2333 break;
2334 page_size = page_size >> 1; 2334 page_size = page_size >> 1;
2335 } 2335 }
2336 if (i < 16) 2336 if (i < 16)
2337 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2337 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2338 "Supported page size of %iK", (1 << (i+12)) / 1024); 2338 "Supported page size of %iK", (1 << (i+12)) / 1024);
2339 else 2339 else
2340 xhci_warn(xhci, "WARN: no supported page size\n"); 2340 xhci_warn(xhci, "WARN: no supported page size\n");
2341 /* Use 4K pages, since that's common and the minimum the HC supports */ 2341 /* Use 4K pages, since that's common and the minimum the HC supports */
2342 xhci->page_shift = 12; 2342 xhci->page_shift = 12;
2343 xhci->page_size = 1 << xhci->page_shift; 2343 xhci->page_size = 1 << xhci->page_shift;
2344 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2344 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2345 "HCD page size set to %iK", xhci->page_size / 1024); 2345 "HCD page size set to %iK", xhci->page_size / 1024);
2346 2346
2347 /* 2347 /*
2348 * Program the Number of Device Slots Enabled field in the CONFIG 2348 * Program the Number of Device Slots Enabled field in the CONFIG
2349 * register with the max value of slots the HC can handle. 2349 * register with the max value of slots the HC can handle.
2350 */ 2350 */
2351 val = HCS_MAX_SLOTS(readl(&xhci->cap_regs->hcs_params1)); 2351 val = HCS_MAX_SLOTS(readl(&xhci->cap_regs->hcs_params1));
2352 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2352 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2353 "// xHC can handle at most %d device slots.", val); 2353 "// xHC can handle at most %d device slots.", val);
2354 val2 = readl(&xhci->op_regs->config_reg); 2354 val2 = readl(&xhci->op_regs->config_reg);
2355 val |= (val2 & ~HCS_SLOTS_MASK); 2355 val |= (val2 & ~HCS_SLOTS_MASK);
2356 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2356 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2357 "// Setting Max device slots reg = 0x%x.", val); 2357 "// Setting Max device slots reg = 0x%x.", val);
2358 writel(val, &xhci->op_regs->config_reg); 2358 writel(val, &xhci->op_regs->config_reg);
2359 2359
2360 /* 2360 /*
2361 * Section 5.4.8 - doorbell array must be 2361 * Section 5.4.8 - doorbell array must be
2362 * "physically contiguous and 64-byte (cache line) aligned". 2362 * "physically contiguous and 64-byte (cache line) aligned".
2363 */ 2363 */
2364 xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma, 2364 xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma,
2365 GFP_KERNEL); 2365 GFP_KERNEL);
2366 if (!xhci->dcbaa) 2366 if (!xhci->dcbaa)
2367 goto fail; 2367 goto fail;
2368 memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa)); 2368 memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa));
2369 xhci->dcbaa->dma = dma; 2369 xhci->dcbaa->dma = dma;
2370 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2370 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2371 "// Device context base array address = 0x%llx (DMA), %p (virt)", 2371 "// Device context base array address = 0x%llx (DMA), %p (virt)",
2372 (unsigned long long)xhci->dcbaa->dma, xhci->dcbaa); 2372 (unsigned long long)xhci->dcbaa->dma, xhci->dcbaa);
2373 xhci_write_64(xhci, dma, &xhci->op_regs->dcbaa_ptr); 2373 xhci_write_64(xhci, dma, &xhci->op_regs->dcbaa_ptr);
2374 2374
2375 /* 2375 /*
2376 * Initialize the ring segment pool. The ring must be a contiguous 2376 * Initialize the ring segment pool. The ring must be a contiguous
2377 * structure comprised of TRBs. The TRBs must be 16 byte aligned, 2377 * structure comprised of TRBs. The TRBs must be 16 byte aligned,
2378 * however, the command ring segment needs 64-byte aligned segments 2378 * however, the command ring segment needs 64-byte aligned segments
2379 * and our use of dma addresses in the trb_address_map radix tree needs 2379 * and our use of dma addresses in the trb_address_map radix tree needs
2380 * TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need. 2380 * TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need.
2381 */ 2381 */
2382 xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, 2382 xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
2383 TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size); 2383 TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size);
2384 2384
2385 /* See Table 46 and Note on Figure 55 */ 2385 /* See Table 46 and Note on Figure 55 */
2386 xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev, 2386 xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev,
2387 2112, 64, xhci->page_size); 2387 2112, 64, xhci->page_size);
2388 if (!xhci->segment_pool || !xhci->device_pool) 2388 if (!xhci->segment_pool || !xhci->device_pool)
2389 goto fail; 2389 goto fail;
2390 2390
2391 /* Linear stream context arrays don't have any boundary restrictions, 2391 /* Linear stream context arrays don't have any boundary restrictions,
2392 * and only need to be 16-byte aligned. 2392 * and only need to be 16-byte aligned.
2393 */ 2393 */
2394 xhci->small_streams_pool = 2394 xhci->small_streams_pool =
2395 dma_pool_create("xHCI 256 byte stream ctx arrays", 2395 dma_pool_create("xHCI 256 byte stream ctx arrays",
2396 dev, SMALL_STREAM_ARRAY_SIZE, 16, 0); 2396 dev, SMALL_STREAM_ARRAY_SIZE, 16, 0);
2397 xhci->medium_streams_pool = 2397 xhci->medium_streams_pool =
2398 dma_pool_create("xHCI 1KB stream ctx arrays", 2398 dma_pool_create("xHCI 1KB stream ctx arrays",
2399 dev, MEDIUM_STREAM_ARRAY_SIZE, 16, 0); 2399 dev, MEDIUM_STREAM_ARRAY_SIZE, 16, 0);
2400 /* Any stream context array bigger than MEDIUM_STREAM_ARRAY_SIZE 2400 /* Any stream context array bigger than MEDIUM_STREAM_ARRAY_SIZE
2401 * will be allocated with dma_alloc_coherent() 2401 * will be allocated with dma_alloc_coherent()
2402 */ 2402 */
2403 2403
2404 if (!xhci->small_streams_pool || !xhci->medium_streams_pool) 2404 if (!xhci->small_streams_pool || !xhci->medium_streams_pool)
2405 goto fail; 2405 goto fail;
2406 2406
2407 /* Set up the command ring to have one segments for now. */ 2407 /* Set up the command ring to have one segments for now. */
2408 xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags); 2408 xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags);
2409 if (!xhci->cmd_ring) 2409 if (!xhci->cmd_ring)
2410 goto fail; 2410 goto fail;
2411 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2411 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2412 "Allocated command ring at %p", xhci->cmd_ring); 2412 "Allocated command ring at %p", xhci->cmd_ring);
2413 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "First segment DMA is 0x%llx", 2413 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "First segment DMA is 0x%llx",
2414 (unsigned long long)xhci->cmd_ring->first_seg->dma); 2414 (unsigned long long)xhci->cmd_ring->first_seg->dma);
2415 2415
2416 /* Set the address in the Command Ring Control register */ 2416 /* Set the address in the Command Ring Control register */
2417 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 2417 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
2418 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) | 2418 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) |
2419 (xhci->cmd_ring->first_seg->dma & (u64) ~CMD_RING_RSVD_BITS) | 2419 (xhci->cmd_ring->first_seg->dma & (u64) ~CMD_RING_RSVD_BITS) |
2420 xhci->cmd_ring->cycle_state; 2420 xhci->cmd_ring->cycle_state;
2421 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2421 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2422 "// Setting command ring address to 0x%x", val); 2422 "// Setting command ring address to 0x%x", val);
2423 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring); 2423 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring);
2424 xhci_dbg_cmd_ptrs(xhci); 2424 xhci_dbg_cmd_ptrs(xhci);
2425 2425
2426 xhci->lpm_command = xhci_alloc_command(xhci, true, true, flags); 2426 xhci->lpm_command = xhci_alloc_command(xhci, true, true, flags);
2427 if (!xhci->lpm_command) 2427 if (!xhci->lpm_command)
2428 goto fail; 2428 goto fail;
2429 2429
2430 /* Reserve one command ring TRB for disabling LPM. 2430 /* Reserve one command ring TRB for disabling LPM.
2431 * Since the USB core grabs the shared usb_bus bandwidth mutex before 2431 * Since the USB core grabs the shared usb_bus bandwidth mutex before
2432 * disabling LPM, we only need to reserve one TRB for all devices. 2432 * disabling LPM, we only need to reserve one TRB for all devices.
2433 */ 2433 */
2434 xhci->cmd_ring_reserved_trbs++; 2434 xhci->cmd_ring_reserved_trbs++;
2435 2435
2436 val = readl(&xhci->cap_regs->db_off); 2436 val = readl(&xhci->cap_regs->db_off);
2437 val &= DBOFF_MASK; 2437 val &= DBOFF_MASK;
2438 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2438 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2439 "// Doorbell array is located at offset 0x%x" 2439 "// Doorbell array is located at offset 0x%x"
2440 " from cap regs base addr", val); 2440 " from cap regs base addr", val);
2441 xhci->dba = (void __iomem *) xhci->cap_regs + val; 2441 xhci->dba = (void __iomem *) xhci->cap_regs + val;
2442 xhci_dbg_regs(xhci); 2442 xhci_dbg_regs(xhci);
2443 xhci_print_run_regs(xhci); 2443 xhci_print_run_regs(xhci);
2444 /* Set ir_set to interrupt register set 0 */ 2444 /* Set ir_set to interrupt register set 0 */
2445 xhci->ir_set = &xhci->run_regs->ir_set[0]; 2445 xhci->ir_set = &xhci->run_regs->ir_set[0];
2446 2446
2447 /* 2447 /*
2448 * Event ring setup: Allocate a normal ring, but also setup 2448 * Event ring setup: Allocate a normal ring, but also setup
2449 * the event ring segment table (ERST). Section 4.9.3. 2449 * the event ring segment table (ERST). Section 4.9.3.
2450 */ 2450 */
2451 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Allocating event ring"); 2451 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Allocating event ring");
2452 xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT, 2452 xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT,
2453 flags); 2453 flags);
2454 if (!xhci->event_ring) 2454 if (!xhci->event_ring)
2455 goto fail; 2455 goto fail;
2456 if (xhci_check_trb_in_td_math(xhci, flags) < 0) 2456 if (xhci_check_trb_in_td_math(xhci, flags) < 0)
2457 goto fail; 2457 goto fail;
2458 2458
2459 xhci->erst.entries = dma_alloc_coherent(dev, 2459 xhci->erst.entries = dma_alloc_coherent(dev,
2460 sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS, &dma, 2460 sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS, &dma,
2461 GFP_KERNEL); 2461 GFP_KERNEL);
2462 if (!xhci->erst.entries) 2462 if (!xhci->erst.entries)
2463 goto fail; 2463 goto fail;
2464 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2464 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2465 "// Allocated event ring segment table at 0x%llx", 2465 "// Allocated event ring segment table at 0x%llx",
2466 (unsigned long long)dma); 2466 (unsigned long long)dma);
2467 2467
2468 memset(xhci->erst.entries, 0, sizeof(struct xhci_erst_entry)*ERST_NUM_SEGS); 2468 memset(xhci->erst.entries, 0, sizeof(struct xhci_erst_entry)*ERST_NUM_SEGS);
2469 xhci->erst.num_entries = ERST_NUM_SEGS; 2469 xhci->erst.num_entries = ERST_NUM_SEGS;
2470 xhci->erst.erst_dma_addr = dma; 2470 xhci->erst.erst_dma_addr = dma;
2471 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2471 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2472 "Set ERST to 0; private num segs = %i, virt addr = %p, dma addr = 0x%llx", 2472 "Set ERST to 0; private num segs = %i, virt addr = %p, dma addr = 0x%llx",
2473 xhci->erst.num_entries, 2473 xhci->erst.num_entries,
2474 xhci->erst.entries, 2474 xhci->erst.entries,
2475 (unsigned long long)xhci->erst.erst_dma_addr); 2475 (unsigned long long)xhci->erst.erst_dma_addr);
2476 2476
2477 /* set ring base address and size for each segment table entry */ 2477 /* set ring base address and size for each segment table entry */
2478 for (val = 0, seg = xhci->event_ring->first_seg; val < ERST_NUM_SEGS; val++) { 2478 for (val = 0, seg = xhci->event_ring->first_seg; val < ERST_NUM_SEGS; val++) {
2479 struct xhci_erst_entry *entry = &xhci->erst.entries[val]; 2479 struct xhci_erst_entry *entry = &xhci->erst.entries[val];
2480 entry->seg_addr = cpu_to_le64(seg->dma); 2480 entry->seg_addr = cpu_to_le64(seg->dma);
2481 entry->seg_size = cpu_to_le32(TRBS_PER_SEGMENT); 2481 entry->seg_size = cpu_to_le32(TRBS_PER_SEGMENT);
2482 entry->rsvd = 0; 2482 entry->rsvd = 0;
2483 seg = seg->next; 2483 seg = seg->next;
2484 } 2484 }
2485 2485
2486 /* set ERST count with the number of entries in the segment table */ 2486 /* set ERST count with the number of entries in the segment table */
2487 val = readl(&xhci->ir_set->erst_size); 2487 val = readl(&xhci->ir_set->erst_size);
2488 val &= ERST_SIZE_MASK; 2488 val &= ERST_SIZE_MASK;
2489 val |= ERST_NUM_SEGS; 2489 val |= ERST_NUM_SEGS;
2490 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2490 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2491 "// Write ERST size = %i to ir_set 0 (some bits preserved)", 2491 "// Write ERST size = %i to ir_set 0 (some bits preserved)",
2492 val); 2492 val);
2493 writel(val, &xhci->ir_set->erst_size); 2493 writel(val, &xhci->ir_set->erst_size);
2494 2494
2495 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2495 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2496 "// Set ERST entries to point to event ring."); 2496 "// Set ERST entries to point to event ring.");
2497 /* set the segment table base address */ 2497 /* set the segment table base address */
2498 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2498 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2499 "// Set ERST base address for ir_set 0 = 0x%llx", 2499 "// Set ERST base address for ir_set 0 = 0x%llx",
2500 (unsigned long long)xhci->erst.erst_dma_addr); 2500 (unsigned long long)xhci->erst.erst_dma_addr);
2501 val_64 = xhci_read_64(xhci, &xhci->ir_set->erst_base); 2501 val_64 = xhci_read_64(xhci, &xhci->ir_set->erst_base);
2502 val_64 &= ERST_PTR_MASK; 2502 val_64 &= ERST_PTR_MASK;
2503 val_64 |= (xhci->erst.erst_dma_addr & (u64) ~ERST_PTR_MASK); 2503 val_64 |= (xhci->erst.erst_dma_addr & (u64) ~ERST_PTR_MASK);
2504 xhci_write_64(xhci, val_64, &xhci->ir_set->erst_base); 2504 xhci_write_64(xhci, val_64, &xhci->ir_set->erst_base);
2505 2505
2506 /* Set the event ring dequeue address */ 2506 /* Set the event ring dequeue address */
2507 xhci_set_hc_event_deq(xhci); 2507 xhci_set_hc_event_deq(xhci);
2508 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2508 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2509 "Wrote ERST address to ir_set 0."); 2509 "Wrote ERST address to ir_set 0.");
2510 xhci_print_ir_set(xhci, 0); 2510 xhci_print_ir_set(xhci, 0);
2511 2511
2512 /* 2512 /*
2513 * XXX: Might need to set the Interrupter Moderation Register to 2513 * XXX: Might need to set the Interrupter Moderation Register to
2514 * something other than the default (~1ms minimum between interrupts). 2514 * something other than the default (~1ms minimum between interrupts).
2515 * See section 5.5.1.2. 2515 * See section 5.5.1.2.
2516 */ 2516 */
2517 init_completion(&xhci->addr_dev); 2517 init_completion(&xhci->addr_dev);
2518 for (i = 0; i < MAX_HC_SLOTS; ++i) 2518 for (i = 0; i < MAX_HC_SLOTS; ++i)
2519 xhci->devs[i] = NULL; 2519 xhci->devs[i] = NULL;
2520 for (i = 0; i < USB_MAXCHILDREN; ++i) { 2520 for (i = 0; i < USB_MAXCHILDREN; ++i) {
2521 xhci->bus_state[0].resume_done[i] = 0; 2521 xhci->bus_state[0].resume_done[i] = 0;
2522 xhci->bus_state[1].resume_done[i] = 0; 2522 xhci->bus_state[1].resume_done[i] = 0;
2523 /* Only the USB 2.0 completions will ever be used. */ 2523 /* Only the USB 2.0 completions will ever be used. */
2524 init_completion(&xhci->bus_state[1].rexit_done[i]); 2524 init_completion(&xhci->bus_state[1].rexit_done[i]);
2525 } 2525 }
2526 2526
2527 if (scratchpad_alloc(xhci, flags)) 2527 if (scratchpad_alloc(xhci, flags))
2528 goto fail; 2528 goto fail;
2529 if (xhci_setup_port_arrays(xhci, flags)) 2529 if (xhci_setup_port_arrays(xhci, flags))
2530 goto fail; 2530 goto fail;
2531 2531
2532 /* Enable USB 3.0 device notifications for function remote wake, which 2532 /* Enable USB 3.0 device notifications for function remote wake, which
2533 * is necessary for allowing USB 3.0 devices to do remote wakeup from 2533 * is necessary for allowing USB 3.0 devices to do remote wakeup from
2534 * U3 (device suspend). 2534 * U3 (device suspend).
2535 */ 2535 */
2536 temp = readl(&xhci->op_regs->dev_notification); 2536 temp = readl(&xhci->op_regs->dev_notification);
2537 temp &= ~DEV_NOTE_MASK; 2537 temp &= ~DEV_NOTE_MASK;
2538 temp |= DEV_NOTE_FWAKE; 2538 temp |= DEV_NOTE_FWAKE;
2539 writel(temp, &xhci->op_regs->dev_notification); 2539 writel(temp, &xhci->op_regs->dev_notification);
2540 2540
drivers/usb/serial/ftdi_sio.c
1 /* 1 /*
2 * USB FTDI SIO driver 2 * USB FTDI SIO driver
3 * 3 *
4 * Copyright (C) 2009 - 2013 4 * Copyright (C) 2009 - 2013
5 * Johan Hovold (jhovold@gmail.com) 5 * Johan Hovold (jhovold@gmail.com)
6 * Copyright (C) 1999 - 2001 6 * Copyright (C) 1999 - 2001
7 * Greg Kroah-Hartman (greg@kroah.com) 7 * Greg Kroah-Hartman (greg@kroah.com)
8 * Bill Ryder (bryder@sgi.com) 8 * Bill Ryder (bryder@sgi.com)
9 * Copyright (C) 2002 9 * Copyright (C) 2002
10 * Kuba Ober (kuba@mareimbrium.org) 10 * Kuba Ober (kuba@mareimbrium.org)
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or 14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version. 15 * (at your option) any later version.
16 * 16 *
17 * See Documentation/usb/usb-serial.txt for more information on using this 17 * See Documentation/usb/usb-serial.txt for more information on using this
18 * driver 18 * driver
19 * 19 *
20 * See http://ftdi-usb-sio.sourceforge.net for up to date testing info 20 * See http://ftdi-usb-sio.sourceforge.net for up to date testing info
21 * and extra documentation 21 * and extra documentation
22 * 22 *
23 * Change entries from 2004 and earlier can be found in versions of this 23 * Change entries from 2004 and earlier can be found in versions of this
24 * file in kernel versions prior to the 2.6.24 release. 24 * file in kernel versions prior to the 2.6.24 release.
25 * 25 *
26 */ 26 */
27 27
28 /* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */ 28 /* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */
29 /* Thanx to FTDI for so kindly providing details of the protocol required */ 29 /* Thanx to FTDI for so kindly providing details of the protocol required */
30 /* to talk to the device */ 30 /* to talk to the device */
31 /* Thanx to gkh and the rest of the usb dev group for all code I have 31 /* Thanx to gkh and the rest of the usb dev group for all code I have
32 assimilated :-) */ 32 assimilated :-) */
33 33
34 #include <linux/kernel.h> 34 #include <linux/kernel.h>
35 #include <linux/errno.h> 35 #include <linux/errno.h>
36 #include <linux/slab.h> 36 #include <linux/slab.h>
37 #include <linux/tty.h> 37 #include <linux/tty.h>
38 #include <linux/tty_driver.h> 38 #include <linux/tty_driver.h>
39 #include <linux/tty_flip.h> 39 #include <linux/tty_flip.h>
40 #include <linux/module.h> 40 #include <linux/module.h>
41 #include <linux/spinlock.h> 41 #include <linux/spinlock.h>
42 #include <linux/mutex.h> 42 #include <linux/mutex.h>
43 #include <linux/uaccess.h> 43 #include <linux/uaccess.h>
44 #include <linux/usb.h> 44 #include <linux/usb.h>
45 #include <linux/serial.h> 45 #include <linux/serial.h>
46 #include <linux/usb/serial.h> 46 #include <linux/usb/serial.h>
47 #include "ftdi_sio.h" 47 #include "ftdi_sio.h"
48 #include "ftdi_sio_ids.h" 48 #include "ftdi_sio_ids.h"
49 49
50 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr, Johan Hovold <jhovold@gmail.com>" 50 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr, Johan Hovold <jhovold@gmail.com>"
51 #define DRIVER_DESC "USB FTDI Serial Converters Driver" 51 #define DRIVER_DESC "USB FTDI Serial Converters Driver"
52 52
53 53
54 struct ftdi_private { 54 struct ftdi_private {
55 enum ftdi_chip_type chip_type; 55 enum ftdi_chip_type chip_type;
56 /* type of device, either SIO or FT8U232AM */ 56 /* type of device, either SIO or FT8U232AM */
57 int baud_base; /* baud base clock for divisor setting */ 57 int baud_base; /* baud base clock for divisor setting */
58 int custom_divisor; /* custom_divisor kludge, this is for 58 int custom_divisor; /* custom_divisor kludge, this is for
59 baud_base (different from what goes to the 59 baud_base (different from what goes to the
60 chip!) */ 60 chip!) */
61 __u16 last_set_data_urb_value ; 61 __u16 last_set_data_urb_value ;
62 /* the last data state set - needed for doing 62 /* the last data state set - needed for doing
63 * a break 63 * a break
64 */ 64 */
65 int flags; /* some ASYNC_xxxx flags are supported */ 65 int flags; /* some ASYNC_xxxx flags are supported */
66 unsigned long last_dtr_rts; /* saved modem control outputs */ 66 unsigned long last_dtr_rts; /* saved modem control outputs */
67 char prev_status; /* Used for TIOCMIWAIT */ 67 char prev_status; /* Used for TIOCMIWAIT */
68 char transmit_empty; /* If transmitter is empty or not */ 68 char transmit_empty; /* If transmitter is empty or not */
69 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface 69 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface
70 (0 for FT232/245) */ 70 (0 for FT232/245) */
71 71
72 speed_t force_baud; /* if non-zero, force the baud rate to 72 speed_t force_baud; /* if non-zero, force the baud rate to
73 this value */ 73 this value */
74 int force_rtscts; /* if non-zero, force RTS-CTS to always 74 int force_rtscts; /* if non-zero, force RTS-CTS to always
75 be enabled */ 75 be enabled */
76 76
77 unsigned int latency; /* latency setting in use */ 77 unsigned int latency; /* latency setting in use */
78 unsigned short max_packet_size; 78 unsigned short max_packet_size;
79 struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() and change_speed() */ 79 struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() and change_speed() */
80 }; 80 };
81 81
82 /* struct ftdi_sio_quirk is used by devices requiring special attention. */ 82 /* struct ftdi_sio_quirk is used by devices requiring special attention. */
83 struct ftdi_sio_quirk { 83 struct ftdi_sio_quirk {
84 int (*probe)(struct usb_serial *); 84 int (*probe)(struct usb_serial *);
85 /* Special settings for probed ports. */ 85 /* Special settings for probed ports. */
86 void (*port_probe)(struct ftdi_private *); 86 void (*port_probe)(struct ftdi_private *);
87 }; 87 };
88 88
89 static int ftdi_jtag_probe(struct usb_serial *serial); 89 static int ftdi_jtag_probe(struct usb_serial *serial);
90 static int ftdi_mtxorb_hack_setup(struct usb_serial *serial); 90 static int ftdi_mtxorb_hack_setup(struct usb_serial *serial);
91 static int ftdi_NDI_device_setup(struct usb_serial *serial); 91 static int ftdi_NDI_device_setup(struct usb_serial *serial);
92 static int ftdi_stmclite_probe(struct usb_serial *serial); 92 static int ftdi_stmclite_probe(struct usb_serial *serial);
93 static int ftdi_8u2232c_probe(struct usb_serial *serial); 93 static int ftdi_8u2232c_probe(struct usb_serial *serial);
94 static void ftdi_USB_UIRT_setup(struct ftdi_private *priv); 94 static void ftdi_USB_UIRT_setup(struct ftdi_private *priv);
95 static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv); 95 static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv);
96 96
97 static struct ftdi_sio_quirk ftdi_jtag_quirk = { 97 static struct ftdi_sio_quirk ftdi_jtag_quirk = {
98 .probe = ftdi_jtag_probe, 98 .probe = ftdi_jtag_probe,
99 }; 99 };
100 100
101 static struct ftdi_sio_quirk ftdi_mtxorb_hack_quirk = { 101 static struct ftdi_sio_quirk ftdi_mtxorb_hack_quirk = {
102 .probe = ftdi_mtxorb_hack_setup, 102 .probe = ftdi_mtxorb_hack_setup,
103 }; 103 };
104 104
105 static struct ftdi_sio_quirk ftdi_NDI_device_quirk = { 105 static struct ftdi_sio_quirk ftdi_NDI_device_quirk = {
106 .probe = ftdi_NDI_device_setup, 106 .probe = ftdi_NDI_device_setup,
107 }; 107 };
108 108
109 static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = { 109 static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
110 .port_probe = ftdi_USB_UIRT_setup, 110 .port_probe = ftdi_USB_UIRT_setup,
111 }; 111 };
112 112
113 static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = { 113 static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {
114 .port_probe = ftdi_HE_TIRA1_setup, 114 .port_probe = ftdi_HE_TIRA1_setup,
115 }; 115 };
116 116
117 static struct ftdi_sio_quirk ftdi_stmclite_quirk = { 117 static struct ftdi_sio_quirk ftdi_stmclite_quirk = {
118 .probe = ftdi_stmclite_probe, 118 .probe = ftdi_stmclite_probe,
119 }; 119 };
120 120
121 static struct ftdi_sio_quirk ftdi_8u2232c_quirk = { 121 static struct ftdi_sio_quirk ftdi_8u2232c_quirk = {
122 .probe = ftdi_8u2232c_probe, 122 .probe = ftdi_8u2232c_probe,
123 }; 123 };
124 124
125 /* 125 /*
126 * The 8U232AM has the same API as the sio except for: 126 * The 8U232AM has the same API as the sio except for:
127 * - it can support MUCH higher baudrates; up to: 127 * - it can support MUCH higher baudrates; up to:
128 * o 921600 for RS232 and 2000000 for RS422/485 at 48MHz 128 * o 921600 for RS232 and 2000000 for RS422/485 at 48MHz
129 * o 230400 at 12MHz 129 * o 230400 at 12MHz
130 * so .. 8U232AM's baudrate setting codes are different 130 * so .. 8U232AM's baudrate setting codes are different
131 * - it has a two byte status code. 131 * - it has a two byte status code.
132 * - it returns characters every 16ms (the FTDI does it every 40ms) 132 * - it returns characters every 16ms (the FTDI does it every 40ms)
133 * 133 *
134 * the bcdDevice value is used to differentiate FT232BM and FT245BM from 134 * the bcdDevice value is used to differentiate FT232BM and FT245BM from
135 * the earlier FT8U232AM and FT8U232BM. For now, include all known VID/PID 135 * the earlier FT8U232AM and FT8U232BM. For now, include all known VID/PID
136 * combinations in both tables. 136 * combinations in both tables.
137 * FIXME: perhaps bcdDevice can also identify 12MHz FT8U232AM devices, 137 * FIXME: perhaps bcdDevice can also identify 12MHz FT8U232AM devices,
138 * but I don't know if those ever went into mass production. [Ian Abbott] 138 * but I don't know if those ever went into mass production. [Ian Abbott]
139 */ 139 */
140 140
141 141
142 142
143 /* 143 /*
144 * Device ID not listed? Test it using 144 * Device ID not listed? Test it using
145 * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report. 145 * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report.
146 */ 146 */
147 static const struct usb_device_id id_table_combined[] = { 147 static const struct usb_device_id id_table_combined[] = {
148 { USB_DEVICE(FTDI_VID, FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID) }, 148 { USB_DEVICE(FTDI_VID, FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID) },
149 { USB_DEVICE(FTDI_VID, FTDI_CTI_MINI_PID) }, 149 { USB_DEVICE(FTDI_VID, FTDI_CTI_MINI_PID) },
150 { USB_DEVICE(FTDI_VID, FTDI_CTI_NANO_PID) }, 150 { USB_DEVICE(FTDI_VID, FTDI_CTI_NANO_PID) },
151 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, 151 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
152 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, 152 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
153 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) }, 153 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
154 { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) }, 154 { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) },
155 { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) }, 155 { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) },
156 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) }, 156 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
157 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_1_PID) }, 157 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_1_PID) },
158 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_2_PID) }, 158 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_2_PID) },
159 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_3_PID) }, 159 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_3_PID) },
160 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_4_PID) }, 160 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_4_PID) },
161 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_5_PID) }, 161 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_5_PID) },
162 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_6_PID) }, 162 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_6_PID) },
163 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_7_PID) }, 163 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_7_PID) },
164 { USB_DEVICE(FTDI_VID, FTDI_USINT_CAT_PID) }, 164 { USB_DEVICE(FTDI_VID, FTDI_USINT_CAT_PID) },
165 { USB_DEVICE(FTDI_VID, FTDI_USINT_WKEY_PID) }, 165 { USB_DEVICE(FTDI_VID, FTDI_USINT_WKEY_PID) },
166 { USB_DEVICE(FTDI_VID, FTDI_USINT_RS232_PID) }, 166 { USB_DEVICE(FTDI_VID, FTDI_USINT_RS232_PID) },
167 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, 167 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) },
168 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, 168 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
169 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, 169 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) },
170 { USB_DEVICE(FTDI_VID, FTDI_IPLUS2_PID) }, 170 { USB_DEVICE(FTDI_VID, FTDI_IPLUS2_PID) },
171 { USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) }, 171 { USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) },
172 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 172 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
173 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 173 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
174 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 174 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
175 { USB_DEVICE(FTDI_VID, FTDI_232RL_PID) }, 175 { USB_DEVICE(FTDI_VID, FTDI_232RL_PID) },
176 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) , 176 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) ,
177 .driver_info = (kernel_ulong_t)&ftdi_8u2232c_quirk }, 177 .driver_info = (kernel_ulong_t)&ftdi_8u2232c_quirk },
178 { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) }, 178 { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) },
179 { USB_DEVICE(FTDI_VID, FTDI_232H_PID) }, 179 { USB_DEVICE(FTDI_VID, FTDI_232H_PID) },
180 { USB_DEVICE(FTDI_VID, FTDI_FTX_PID) }, 180 { USB_DEVICE(FTDI_VID, FTDI_FTX_PID) },
181 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, 181 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
182 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, 182 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
183 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, 183 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) },
184 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_SNIFFER_PID) }, 184 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_SNIFFER_PID) },
185 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) }, 185 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) },
186 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) }, 186 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) },
187 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) }, 187 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) },
188 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_BOOST_PID) }, 188 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_BOOST_PID) },
189 { USB_DEVICE(NEWPORT_VID, NEWPORT_AGILIS_PID) }, 189 { USB_DEVICE(NEWPORT_VID, NEWPORT_AGILIS_PID) },
190 { USB_DEVICE(NEWPORT_VID, NEWPORT_CONEX_CC_PID) }, 190 { USB_DEVICE(NEWPORT_VID, NEWPORT_CONEX_CC_PID) },
191 { USB_DEVICE(NEWPORT_VID, NEWPORT_CONEX_AGP_PID) }, 191 { USB_DEVICE(NEWPORT_VID, NEWPORT_CONEX_AGP_PID) },
192 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 192 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
193 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 193 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
194 { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) }, 194 { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) },
195 { USB_DEVICE(FTDI_VID, FTDI_TAGSYS_LP101_PID) }, 195 { USB_DEVICE(FTDI_VID, FTDI_TAGSYS_LP101_PID) },
196 { USB_DEVICE(FTDI_VID, FTDI_TAGSYS_P200X_PID) }, 196 { USB_DEVICE(FTDI_VID, FTDI_TAGSYS_P200X_PID) },
197 { USB_DEVICE(FTDI_VID, FTDI_LENZ_LIUSB_PID) }, 197 { USB_DEVICE(FTDI_VID, FTDI_LENZ_LIUSB_PID) },
198 { USB_DEVICE(FTDI_VID, FTDI_XF_632_PID) }, 198 { USB_DEVICE(FTDI_VID, FTDI_XF_632_PID) },
199 { USB_DEVICE(FTDI_VID, FTDI_XF_634_PID) }, 199 { USB_DEVICE(FTDI_VID, FTDI_XF_634_PID) },
200 { USB_DEVICE(FTDI_VID, FTDI_XF_547_PID) }, 200 { USB_DEVICE(FTDI_VID, FTDI_XF_547_PID) },
201 { USB_DEVICE(FTDI_VID, FTDI_XF_633_PID) }, 201 { USB_DEVICE(FTDI_VID, FTDI_XF_633_PID) },
202 { USB_DEVICE(FTDI_VID, FTDI_XF_631_PID) }, 202 { USB_DEVICE(FTDI_VID, FTDI_XF_631_PID) },
203 { USB_DEVICE(FTDI_VID, FTDI_XF_635_PID) }, 203 { USB_DEVICE(FTDI_VID, FTDI_XF_635_PID) },
204 { USB_DEVICE(FTDI_VID, FTDI_XF_640_PID) }, 204 { USB_DEVICE(FTDI_VID, FTDI_XF_640_PID) },
205 { USB_DEVICE(FTDI_VID, FTDI_XF_642_PID) }, 205 { USB_DEVICE(FTDI_VID, FTDI_XF_642_PID) },
206 { USB_DEVICE(FTDI_VID, FTDI_DSS20_PID) }, 206 { USB_DEVICE(FTDI_VID, FTDI_DSS20_PID) },
207 { USB_DEVICE(FTDI_VID, FTDI_URBAN_0_PID) }, 207 { USB_DEVICE(FTDI_VID, FTDI_URBAN_0_PID) },
208 { USB_DEVICE(FTDI_VID, FTDI_URBAN_1_PID) }, 208 { USB_DEVICE(FTDI_VID, FTDI_URBAN_1_PID) },
209 { USB_DEVICE(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID) }, 209 { USB_DEVICE(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID) },
210 { USB_DEVICE(FTDI_VID, FTDI_VNHCPCUSB_D_PID) }, 210 { USB_DEVICE(FTDI_VID, FTDI_VNHCPCUSB_D_PID) },
211 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_0_PID) }, 211 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_0_PID) },
212 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_1_PID) }, 212 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_1_PID) },
213 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_2_PID) }, 213 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_2_PID) },
214 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_3_PID) }, 214 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_3_PID) },
215 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) }, 215 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
216 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) }, 216 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
217 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, 217 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
218 { USB_DEVICE(FTDI_VID, FTDI_R2000KU_TRUE_RNG) }, 218 { USB_DEVICE(FTDI_VID, FTDI_R2000KU_TRUE_RNG) },
219 { USB_DEVICE(FTDI_VID, FTDI_VARDAAN_PID) }, 219 { USB_DEVICE(FTDI_VID, FTDI_VARDAAN_PID) },
220 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) }, 220 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) },
221 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) }, 221 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) },
222 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) }, 222 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) },
223 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0103_PID) }, 223 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0103_PID) },
224 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0104_PID) }, 224 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0104_PID) },
225 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0105_PID) }, 225 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0105_PID) },
226 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0106_PID) }, 226 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0106_PID) },
227 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0107_PID) }, 227 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0107_PID) },
228 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0108_PID) }, 228 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0108_PID) },
229 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0109_PID) }, 229 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0109_PID) },
230 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010A_PID) }, 230 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010A_PID) },
231 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010B_PID) }, 231 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010B_PID) },
232 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010C_PID) }, 232 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010C_PID) },
233 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010D_PID) }, 233 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010D_PID) },
234 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010E_PID) }, 234 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010E_PID) },
235 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010F_PID) }, 235 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010F_PID) },
236 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0110_PID) }, 236 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0110_PID) },
237 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0111_PID) }, 237 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0111_PID) },
238 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0112_PID) }, 238 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0112_PID) },
239 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0113_PID) }, 239 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0113_PID) },
240 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0114_PID) }, 240 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0114_PID) },
241 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0115_PID) }, 241 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0115_PID) },
242 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0116_PID) }, 242 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0116_PID) },
243 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0117_PID) }, 243 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0117_PID) },
244 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0118_PID) }, 244 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0118_PID) },
245 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0119_PID) }, 245 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0119_PID) },
246 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011A_PID) }, 246 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011A_PID) },
247 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011B_PID) }, 247 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011B_PID) },
248 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011C_PID) }, 248 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011C_PID) },
249 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011D_PID) }, 249 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011D_PID) },
250 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011E_PID) }, 250 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011E_PID) },
251 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011F_PID) }, 251 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011F_PID) },
252 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0120_PID) }, 252 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0120_PID) },
253 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0121_PID) }, 253 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0121_PID) },
254 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0122_PID) }, 254 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0122_PID) },
255 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0123_PID) }, 255 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0123_PID) },
256 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0124_PID) }, 256 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0124_PID) },
257 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0125_PID) }, 257 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0125_PID) },
258 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0126_PID) }, 258 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0126_PID) },
259 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0127_PID), 259 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0127_PID),
260 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 260 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
261 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0128_PID) }, 261 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0128_PID) },
262 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0129_PID) }, 262 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0129_PID) },
263 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012A_PID) }, 263 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012A_PID) },
264 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012B_PID) }, 264 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012B_PID) },
265 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012C_PID), 265 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012C_PID),
266 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 266 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
267 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012D_PID) }, 267 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012D_PID) },
268 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012E_PID) }, 268 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012E_PID) },
269 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012F_PID) }, 269 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012F_PID) },
270 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0130_PID) }, 270 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0130_PID) },
271 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0131_PID) }, 271 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0131_PID) },
272 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0132_PID) }, 272 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0132_PID) },
273 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0133_PID) }, 273 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0133_PID) },
274 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0134_PID) }, 274 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0134_PID) },
275 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0135_PID) }, 275 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0135_PID) },
276 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0136_PID) }, 276 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0136_PID) },
277 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0137_PID) }, 277 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0137_PID) },
278 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0138_PID) }, 278 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0138_PID) },
279 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0139_PID) }, 279 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0139_PID) },
280 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013A_PID) }, 280 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013A_PID) },
281 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013B_PID) }, 281 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013B_PID) },
282 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013C_PID) }, 282 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013C_PID) },
283 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013D_PID) }, 283 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013D_PID) },
284 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013E_PID) }, 284 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013E_PID) },
285 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013F_PID) }, 285 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013F_PID) },
286 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0140_PID) }, 286 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0140_PID) },
287 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0141_PID) }, 287 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0141_PID) },
288 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0142_PID) }, 288 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0142_PID) },
289 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0143_PID) }, 289 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0143_PID) },
290 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0144_PID) }, 290 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0144_PID) },
291 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0145_PID) }, 291 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0145_PID) },
292 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0146_PID) }, 292 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0146_PID) },
293 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0147_PID) }, 293 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0147_PID) },
294 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0148_PID) }, 294 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0148_PID) },
295 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0149_PID) }, 295 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0149_PID) },
296 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014A_PID) }, 296 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014A_PID) },
297 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014B_PID) }, 297 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014B_PID) },
298 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014C_PID) }, 298 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014C_PID) },
299 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014D_PID) }, 299 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014D_PID) },
300 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014E_PID) }, 300 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014E_PID) },
301 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014F_PID) }, 301 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014F_PID) },
302 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0150_PID) }, 302 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0150_PID) },
303 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0151_PID) }, 303 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0151_PID) },
304 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0152_PID) }, 304 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0152_PID) },
305 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0153_PID), 305 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0153_PID),
306 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 306 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
307 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0154_PID), 307 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0154_PID),
308 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 308 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
309 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0155_PID), 309 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0155_PID),
310 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 310 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
311 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0156_PID), 311 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0156_PID),
312 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 312 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
313 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0157_PID), 313 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0157_PID),
314 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 314 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
315 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0158_PID), 315 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0158_PID),
316 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 316 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
317 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0159_PID) }, 317 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0159_PID) },
318 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015A_PID) }, 318 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015A_PID) },
319 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015B_PID) }, 319 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015B_PID) },
320 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015C_PID) }, 320 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015C_PID) },
321 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015D_PID) }, 321 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015D_PID) },
322 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015E_PID) }, 322 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015E_PID) },
323 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015F_PID) }, 323 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015F_PID) },
324 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0160_PID) }, 324 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0160_PID) },
325 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0161_PID) }, 325 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0161_PID) },
326 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0162_PID) }, 326 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0162_PID) },
327 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0163_PID) }, 327 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0163_PID) },
328 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0164_PID) }, 328 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0164_PID) },
329 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0165_PID) }, 329 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0165_PID) },
330 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0166_PID) }, 330 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0166_PID) },
331 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0167_PID) }, 331 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0167_PID) },
332 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0168_PID) }, 332 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0168_PID) },
333 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0169_PID) }, 333 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0169_PID) },
334 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016A_PID) }, 334 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016A_PID) },
335 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016B_PID) }, 335 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016B_PID) },
336 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016C_PID) }, 336 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016C_PID) },
337 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016D_PID) }, 337 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016D_PID) },
338 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016E_PID) }, 338 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016E_PID) },
339 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016F_PID) }, 339 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016F_PID) },
340 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0170_PID) }, 340 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0170_PID) },
341 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0171_PID) }, 341 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0171_PID) },
342 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0172_PID) }, 342 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0172_PID) },
343 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0173_PID) }, 343 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0173_PID) },
344 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0174_PID) }, 344 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0174_PID) },
345 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0175_PID) }, 345 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0175_PID) },
346 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0176_PID) }, 346 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0176_PID) },
347 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0177_PID) }, 347 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0177_PID) },
348 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0178_PID) }, 348 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0178_PID) },
349 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0179_PID) }, 349 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0179_PID) },
350 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017A_PID) }, 350 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017A_PID) },
351 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017B_PID) }, 351 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017B_PID) },
352 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017C_PID) }, 352 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017C_PID) },
353 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017D_PID) }, 353 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017D_PID) },
354 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017E_PID) }, 354 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017E_PID) },
355 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017F_PID) }, 355 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017F_PID) },
356 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0180_PID) }, 356 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0180_PID) },
357 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0181_PID) }, 357 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0181_PID) },
358 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0182_PID) }, 358 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0182_PID) },
359 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0183_PID) }, 359 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0183_PID) },
360 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0184_PID) }, 360 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0184_PID) },
361 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0185_PID) }, 361 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0185_PID) },
362 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0186_PID) }, 362 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0186_PID) },
363 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0187_PID) }, 363 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0187_PID) },
364 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0188_PID) }, 364 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0188_PID) },
365 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0189_PID) }, 365 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0189_PID) },
366 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018A_PID) }, 366 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018A_PID) },
367 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018B_PID) }, 367 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018B_PID) },
368 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018C_PID) }, 368 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018C_PID) },
369 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018D_PID) }, 369 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018D_PID) },
370 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018E_PID) }, 370 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018E_PID) },
371 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018F_PID) }, 371 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018F_PID) },
372 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0190_PID) }, 372 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0190_PID) },
373 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0191_PID) }, 373 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0191_PID) },
374 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0192_PID) }, 374 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0192_PID) },
375 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0193_PID) }, 375 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0193_PID) },
376 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0194_PID) }, 376 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0194_PID) },
377 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0195_PID) }, 377 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0195_PID) },
378 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0196_PID) }, 378 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0196_PID) },
379 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0197_PID) }, 379 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0197_PID) },
380 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0198_PID) }, 380 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0198_PID) },
381 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0199_PID) }, 381 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0199_PID) },
382 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019A_PID) }, 382 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019A_PID) },
383 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019B_PID) }, 383 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019B_PID) },
384 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019C_PID) }, 384 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019C_PID) },
385 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019D_PID) }, 385 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019D_PID) },
386 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019E_PID) }, 386 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019E_PID) },
387 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019F_PID) }, 387 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019F_PID) },
388 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A0_PID) }, 388 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A0_PID) },
389 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A1_PID) }, 389 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A1_PID) },
390 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A2_PID) }, 390 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A2_PID) },
391 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A3_PID) }, 391 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A3_PID) },
392 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A4_PID) }, 392 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A4_PID) },
393 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A5_PID) }, 393 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A5_PID) },
394 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A6_PID) }, 394 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A6_PID) },
395 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A7_PID) }, 395 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A7_PID) },
396 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A8_PID) }, 396 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A8_PID) },
397 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A9_PID) }, 397 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A9_PID) },
398 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AA_PID) }, 398 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AA_PID) },
399 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AB_PID) }, 399 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AB_PID) },
400 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AC_PID) }, 400 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AC_PID) },
401 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AD_PID) }, 401 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AD_PID) },
402 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AE_PID) }, 402 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AE_PID) },
403 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AF_PID) }, 403 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AF_PID) },
404 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B0_PID) }, 404 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B0_PID) },
405 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B1_PID) }, 405 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B1_PID) },
406 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B2_PID) }, 406 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B2_PID) },
407 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B3_PID) }, 407 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B3_PID) },
408 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B4_PID) }, 408 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B4_PID) },
409 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B5_PID) }, 409 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B5_PID) },
410 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B6_PID) }, 410 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B6_PID) },
411 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B7_PID) }, 411 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B7_PID) },
412 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B8_PID) }, 412 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B8_PID) },
413 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B9_PID) }, 413 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B9_PID) },
414 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BA_PID) }, 414 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BA_PID) },
415 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BB_PID) }, 415 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BB_PID) },
416 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BC_PID) }, 416 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BC_PID) },
417 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BD_PID) }, 417 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BD_PID) },
418 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BE_PID) }, 418 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BE_PID) },
419 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BF_PID) }, 419 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BF_PID) },
420 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C0_PID) }, 420 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C0_PID) },
421 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C1_PID) }, 421 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C1_PID) },
422 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C2_PID) }, 422 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C2_PID) },
423 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C3_PID) }, 423 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C3_PID) },
424 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C4_PID) }, 424 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C4_PID) },
425 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C5_PID) }, 425 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C5_PID) },
426 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C6_PID) }, 426 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C6_PID) },
427 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C7_PID) }, 427 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C7_PID) },
428 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C8_PID) }, 428 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C8_PID) },
429 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C9_PID) }, 429 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C9_PID) },
430 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CA_PID) }, 430 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CA_PID) },
431 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CB_PID) }, 431 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CB_PID) },
432 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CC_PID) }, 432 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CC_PID) },
433 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CD_PID) }, 433 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CD_PID) },
434 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CE_PID) }, 434 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CE_PID) },
435 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CF_PID) }, 435 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CF_PID) },
436 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D0_PID) }, 436 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D0_PID) },
437 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D1_PID) }, 437 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D1_PID) },
438 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D2_PID) }, 438 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D2_PID) },
439 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D3_PID) }, 439 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D3_PID) },
440 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D4_PID) }, 440 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D4_PID) },
441 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D5_PID) }, 441 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D5_PID) },
442 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D6_PID) }, 442 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D6_PID) },
443 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D7_PID) }, 443 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D7_PID) },
444 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D8_PID) }, 444 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D8_PID) },
445 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D9_PID) }, 445 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D9_PID) },
446 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DA_PID) }, 446 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DA_PID) },
447 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DB_PID) }, 447 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DB_PID) },
448 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DC_PID) }, 448 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DC_PID) },
449 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DD_PID) }, 449 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DD_PID) },
450 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DE_PID) }, 450 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DE_PID) },
451 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DF_PID) }, 451 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DF_PID) },
452 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E0_PID) }, 452 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E0_PID) },
453 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E1_PID) }, 453 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E1_PID) },
454 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E2_PID) }, 454 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E2_PID) },
455 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E3_PID) }, 455 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E3_PID) },
456 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E4_PID) }, 456 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E4_PID) },
457 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E5_PID) }, 457 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E5_PID) },
458 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E6_PID) }, 458 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E6_PID) },
459 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E7_PID) }, 459 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E7_PID) },
460 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E8_PID) }, 460 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E8_PID) },
461 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E9_PID) }, 461 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E9_PID) },
462 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EA_PID) }, 462 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EA_PID) },
463 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EB_PID) }, 463 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EB_PID) },
464 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EC_PID) }, 464 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EC_PID) },
465 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01ED_PID) }, 465 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01ED_PID) },
466 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EE_PID) }, 466 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EE_PID) },
467 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EF_PID) }, 467 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EF_PID) },
468 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F0_PID) }, 468 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F0_PID) },
469 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F1_PID) }, 469 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F1_PID) },
470 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F2_PID) }, 470 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F2_PID) },
471 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F3_PID) }, 471 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F3_PID) },
472 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F4_PID) }, 472 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F4_PID) },
473 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F5_PID) }, 473 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F5_PID) },
474 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F6_PID) }, 474 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F6_PID) },
475 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F7_PID) }, 475 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F7_PID) },
476 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F8_PID) }, 476 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F8_PID) },
477 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F9_PID) }, 477 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F9_PID) },
478 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FA_PID) }, 478 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FA_PID) },
479 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FB_PID) }, 479 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FB_PID) },
480 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FC_PID) }, 480 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FC_PID) },
481 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) }, 481 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) },
482 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) }, 482 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) },
483 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) }, 483 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) },
484 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) }, 484 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
485 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, 485 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
486 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) }, 486 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
487 { USB_DEVICE(FTDI_VID, FTDI_USBX_707_PID) }, 487 { USB_DEVICE(FTDI_VID, FTDI_USBX_707_PID) },
488 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) }, 488 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) },
489 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) }, 489 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) },
490 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2103_PID) }, 490 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2103_PID) },
491 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2104_PID) }, 491 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2104_PID) },
492 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2106_PID) }, 492 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2106_PID) },
493 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2201_1_PID) }, 493 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2201_1_PID) },
494 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2201_2_PID) }, 494 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2201_2_PID) },
495 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2202_1_PID) }, 495 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2202_1_PID) },
496 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2202_2_PID) }, 496 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2202_2_PID) },
497 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2203_1_PID) }, 497 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2203_1_PID) },
498 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2203_2_PID) }, 498 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2203_2_PID) },
499 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_1_PID) }, 499 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_1_PID) },
500 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_2_PID) }, 500 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_2_PID) },
501 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_3_PID) }, 501 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_3_PID) },
502 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_4_PID) }, 502 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_4_PID) },
503 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_1_PID) }, 503 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_1_PID) },
504 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_2_PID) }, 504 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_2_PID) },
505 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_3_PID) }, 505 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_3_PID) },
506 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_4_PID) }, 506 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_4_PID) },
507 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_1_PID) }, 507 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_1_PID) },
508 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_2_PID) }, 508 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_2_PID) },
509 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_3_PID) }, 509 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_3_PID) },
510 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_4_PID) }, 510 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_4_PID) },
511 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_1_PID) }, 511 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_1_PID) },
512 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_2_PID) }, 512 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_2_PID) },
513 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_3_PID) }, 513 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_3_PID) },
514 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_4_PID) }, 514 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_4_PID) },
515 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_5_PID) }, 515 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_5_PID) },
516 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_6_PID) }, 516 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_6_PID) },
517 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_7_PID) }, 517 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_7_PID) },
518 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_8_PID) }, 518 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_8_PID) },
519 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_1_PID) }, 519 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_1_PID) },
520 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_2_PID) }, 520 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_2_PID) },
521 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_3_PID) }, 521 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_3_PID) },
522 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_4_PID) }, 522 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_4_PID) },
523 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_5_PID) }, 523 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_5_PID) },
524 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_6_PID) }, 524 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_6_PID) },
525 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_7_PID) }, 525 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_7_PID) },
526 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_8_PID) }, 526 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_8_PID) },
527 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_1_PID) }, 527 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_1_PID) },
528 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_2_PID) }, 528 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_2_PID) },
529 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_3_PID) }, 529 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_3_PID) },
530 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_4_PID) }, 530 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_4_PID) },
531 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_5_PID) }, 531 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_5_PID) },
532 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_6_PID) }, 532 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_6_PID) },
533 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_7_PID) }, 533 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_7_PID) },
534 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) }, 534 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) },
535 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_1_PID) }, 535 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_1_PID) },
536 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_2_PID) }, 536 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_2_PID) },
537 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_3_PID) }, 537 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_3_PID) },
538 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_4_PID) }, 538 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_4_PID) },
539 { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) }, 539 { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) },
540 { USB_DEVICE(OCT_VID, OCT_US101_PID) }, 540 { USB_DEVICE(OCT_VID, OCT_US101_PID) },
541 { USB_DEVICE(OCT_VID, OCT_DK201_PID) }, 541 { USB_DEVICE(OCT_VID, OCT_DK201_PID) },
542 { USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID), 542 { USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
543 .driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk }, 543 .driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
544 { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID), 544 { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
545 .driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk }, 545 .driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },
546 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) }, 546 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },
547 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) }, 547 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
548 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) }, 548 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
549 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) }, 549 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) },
550 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E808_PID) }, 550 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E808_PID) },
551 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E809_PID) }, 551 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E809_PID) },
552 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80A_PID) }, 552 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80A_PID) },
553 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80B_PID) }, 553 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80B_PID) },
554 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80C_PID) }, 554 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80C_PID) },
555 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80D_PID) }, 555 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80D_PID) },
556 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80E_PID) }, 556 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80E_PID) },
557 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80F_PID) }, 557 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80F_PID) },
558 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E888_PID) }, 558 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E888_PID) },
559 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E889_PID) }, 559 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E889_PID) },
560 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88A_PID) }, 560 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88A_PID) },
561 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88B_PID) }, 561 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88B_PID) },
562 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88C_PID) }, 562 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88C_PID) },
563 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88D_PID) }, 563 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88D_PID) },
564 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88E_PID) }, 564 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88E_PID) },
565 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88F_PID) }, 565 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88F_PID) },
566 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, 566 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) },
567 { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) }, 567 { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) },
568 { USB_DEVICE(FTDI_VID, FTDI_ELV_UR100_PID) }, 568 { USB_DEVICE(FTDI_VID, FTDI_ELV_UR100_PID) },
569 { USB_DEVICE(FTDI_VID, FTDI_ELV_ALC8500_PID) }, 569 { USB_DEVICE(FTDI_VID, FTDI_ELV_ALC8500_PID) },
570 { USB_DEVICE(FTDI_VID, FTDI_PYRAMID_PID) }, 570 { USB_DEVICE(FTDI_VID, FTDI_PYRAMID_PID) },
571 { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1000PC_PID) }, 571 { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1000PC_PID) },
572 { USB_DEVICE(FTDI_VID, FTDI_IBS_US485_PID) }, 572 { USB_DEVICE(FTDI_VID, FTDI_IBS_US485_PID) },
573 { USB_DEVICE(FTDI_VID, FTDI_IBS_PICPRO_PID) }, 573 { USB_DEVICE(FTDI_VID, FTDI_IBS_PICPRO_PID) },
574 { USB_DEVICE(FTDI_VID, FTDI_IBS_PCMCIA_PID) }, 574 { USB_DEVICE(FTDI_VID, FTDI_IBS_PCMCIA_PID) },
575 { USB_DEVICE(FTDI_VID, FTDI_IBS_PK1_PID) }, 575 { USB_DEVICE(FTDI_VID, FTDI_IBS_PK1_PID) },
576 { USB_DEVICE(FTDI_VID, FTDI_IBS_RS232MON_PID) }, 576 { USB_DEVICE(FTDI_VID, FTDI_IBS_RS232MON_PID) },
577 { USB_DEVICE(FTDI_VID, FTDI_IBS_APP70_PID) }, 577 { USB_DEVICE(FTDI_VID, FTDI_IBS_APP70_PID) },
578 { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) }, 578 { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) },
579 { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) }, 579 { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) },
580 { USB_DEVICE(FTDI_VID, FTDI_TAVIR_STK500_PID) }, 580 { USB_DEVICE(FTDI_VID, FTDI_TAVIR_STK500_PID) },
581 { USB_DEVICE(FTDI_VID, FTDI_TIAO_UMPA_PID), 581 { USB_DEVICE(FTDI_VID, FTDI_TIAO_UMPA_PID),
582 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 582 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
583 { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLXM_PID),
584 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
583 /* 585 /*
584 * ELV devices: 586 * ELV devices:
585 */ 587 */
586 { USB_DEVICE(FTDI_ELV_VID, FTDI_ELV_WS300_PID) }, 588 { USB_DEVICE(FTDI_ELV_VID, FTDI_ELV_WS300_PID) },
587 { USB_DEVICE(FTDI_VID, FTDI_ELV_USR_PID) }, 589 { USB_DEVICE(FTDI_VID, FTDI_ELV_USR_PID) },
588 { USB_DEVICE(FTDI_VID, FTDI_ELV_MSM1_PID) }, 590 { USB_DEVICE(FTDI_VID, FTDI_ELV_MSM1_PID) },
589 { USB_DEVICE(FTDI_VID, FTDI_ELV_KL100_PID) }, 591 { USB_DEVICE(FTDI_VID, FTDI_ELV_KL100_PID) },
590 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS550_PID) }, 592 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS550_PID) },
591 { USB_DEVICE(FTDI_VID, FTDI_ELV_EC3000_PID) }, 593 { USB_DEVICE(FTDI_VID, FTDI_ELV_EC3000_PID) },
592 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS888_PID) }, 594 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS888_PID) },
593 { USB_DEVICE(FTDI_VID, FTDI_ELV_TWS550_PID) }, 595 { USB_DEVICE(FTDI_VID, FTDI_ELV_TWS550_PID) },
594 { USB_DEVICE(FTDI_VID, FTDI_ELV_FEM_PID) }, 596 { USB_DEVICE(FTDI_VID, FTDI_ELV_FEM_PID) },
595 { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) }, 597 { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) },
596 { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) }, 598 { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) },
597 { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) }, 599 { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) },
598 { USB_DEVICE(FTDI_VID, FTDI_ELV_UDF77_PID) }, 600 { USB_DEVICE(FTDI_VID, FTDI_ELV_UDF77_PID) },
599 { USB_DEVICE(FTDI_VID, FTDI_ELV_UIO88_PID) }, 601 { USB_DEVICE(FTDI_VID, FTDI_ELV_UIO88_PID) },
600 { USB_DEVICE(FTDI_VID, FTDI_ELV_UAD8_PID) }, 602 { USB_DEVICE(FTDI_VID, FTDI_ELV_UAD8_PID) },
601 { USB_DEVICE(FTDI_VID, FTDI_ELV_UDA7_PID) }, 603 { USB_DEVICE(FTDI_VID, FTDI_ELV_UDA7_PID) },
602 { USB_DEVICE(FTDI_VID, FTDI_ELV_USI2_PID) }, 604 { USB_DEVICE(FTDI_VID, FTDI_ELV_USI2_PID) },
603 { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, 605 { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) },
604 { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, 606 { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) },
605 { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, 607 { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) },
606 { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, 608 { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) },
607 { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, 609 { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) },
608 { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, 610 { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) },
609 { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) }, 611 { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) },
610 { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) }, 612 { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) },
611 { USB_DEVICE(FTDI_VID, FTDI_ELV_UTP8_PID) }, 613 { USB_DEVICE(FTDI_VID, FTDI_ELV_UTP8_PID) },
612 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, 614 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) },
613 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS444PC_PID) }, 615 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS444PC_PID) },
614 { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, 616 { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) },
615 { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1010PC_PID) }, 617 { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1010PC_PID) },
616 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, 618 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) },
617 { USB_DEVICE(FTDI_VID, FTDI_ELV_HS485_PID) }, 619 { USB_DEVICE(FTDI_VID, FTDI_ELV_HS485_PID) },
618 { USB_DEVICE(FTDI_VID, FTDI_ELV_UMS100_PID) }, 620 { USB_DEVICE(FTDI_VID, FTDI_ELV_UMS100_PID) },
619 { USB_DEVICE(FTDI_VID, FTDI_ELV_TFD128_PID) }, 621 { USB_DEVICE(FTDI_VID, FTDI_ELV_TFD128_PID) },
620 { USB_DEVICE(FTDI_VID, FTDI_ELV_FM3RX_PID) }, 622 { USB_DEVICE(FTDI_VID, FTDI_ELV_FM3RX_PID) },
621 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS777_PID) }, 623 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS777_PID) },
622 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, 624 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
623 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, 625 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
624 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, 626 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
625 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) }, 627 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) },
626 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) }, 628 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
627 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) }, 629 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
628 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) }, 630 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
629 { USB_DEVICE(FTDI_VID, FTDI_CCSMACHX_2_PID) }, 631 { USB_DEVICE(FTDI_VID, FTDI_CCSMACHX_2_PID) },
630 { USB_DEVICE(FTDI_VID, FTDI_CCSLOAD_N_GO_3_PID) }, 632 { USB_DEVICE(FTDI_VID, FTDI_CCSLOAD_N_GO_3_PID) },
631 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU64_4_PID) }, 633 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU64_4_PID) },
632 { USB_DEVICE(FTDI_VID, FTDI_CCSPRIME8_5_PID) }, 634 { USB_DEVICE(FTDI_VID, FTDI_CCSPRIME8_5_PID) },
633 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) }, 635 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
634 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) }, 636 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) },
635 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 637 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
636 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, 638 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) },
637 { USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) }, 639 { USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) },
638 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, 640 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) },
639 { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) }, 641 { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) },
640 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, 642 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) },
641 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, 643 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) },
642 { USB_DEVICE(ACTON_VID, ACTON_SPECTRAPRO_PID) }, 644 { USB_DEVICE(ACTON_VID, ACTON_SPECTRAPRO_PID) },
643 { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) }, 645 { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
644 { USB_DEVICE(MITSUBISHI_VID, MITSUBISHI_FXUSB_PID) }, 646 { USB_DEVICE(MITSUBISHI_VID, MITSUBISHI_FXUSB_PID) },
645 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, 647 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
646 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, 648 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
647 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) }, 649 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
648 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4_PID) }, 650 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4_PID) },
649 { USB_DEVICE(BANDB_VID, BANDB_USPTL4_PID) }, 651 { USB_DEVICE(BANDB_VID, BANDB_USPTL4_PID) },
650 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2DR_2_PID) }, 652 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2DR_2_PID) },
651 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2DR_PID) }, 653 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2DR_PID) },
652 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4DR2_PID) }, 654 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4DR2_PID) },
653 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4DR_PID) }, 655 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4DR_PID) },
654 { USB_DEVICE(BANDB_VID, BANDB_485USB9F_2W_PID) }, 656 { USB_DEVICE(BANDB_VID, BANDB_485USB9F_2W_PID) },
655 { USB_DEVICE(BANDB_VID, BANDB_485USB9F_4W_PID) }, 657 { USB_DEVICE(BANDB_VID, BANDB_485USB9F_4W_PID) },
656 { USB_DEVICE(BANDB_VID, BANDB_232USB9M_PID) }, 658 { USB_DEVICE(BANDB_VID, BANDB_232USB9M_PID) },
657 { USB_DEVICE(BANDB_VID, BANDB_485USBTB_2W_PID) }, 659 { USB_DEVICE(BANDB_VID, BANDB_485USBTB_2W_PID) },
658 { USB_DEVICE(BANDB_VID, BANDB_485USBTB_4W_PID) }, 660 { USB_DEVICE(BANDB_VID, BANDB_485USBTB_4W_PID) },
659 { USB_DEVICE(BANDB_VID, BANDB_TTL5USB9M_PID) }, 661 { USB_DEVICE(BANDB_VID, BANDB_TTL5USB9M_PID) },
660 { USB_DEVICE(BANDB_VID, BANDB_TTL3USB9M_PID) }, 662 { USB_DEVICE(BANDB_VID, BANDB_TTL3USB9M_PID) },
661 { USB_DEVICE(BANDB_VID, BANDB_ZZ_PROG1_USB_PID) }, 663 { USB_DEVICE(BANDB_VID, BANDB_ZZ_PROG1_USB_PID) },
662 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) }, 664 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) },
663 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) }, 665 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) },
664 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) }, 666 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
665 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_3_PID) }, 667 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_3_PID) },
666 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_0_PID) }, 668 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_0_PID) },
667 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_1_PID) }, 669 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_1_PID) },
668 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_2_PID) }, 670 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_2_PID) },
669 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_3_PID) }, 671 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_3_PID) },
670 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_4_PID) }, 672 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_4_PID) },
671 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) }, 673 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) },
672 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) }, 674 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) },
673 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) }, 675 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) },
674 { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) }, 676 { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
675 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) }, 677 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
676 { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) }, 678 { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
677 { USB_DEVICE(FTDI_VID, FTDI_MHAM_KW_PID) }, 679 { USB_DEVICE(FTDI_VID, FTDI_MHAM_KW_PID) },
678 { USB_DEVICE(FTDI_VID, FTDI_MHAM_YS_PID) }, 680 { USB_DEVICE(FTDI_VID, FTDI_MHAM_YS_PID) },
679 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) }, 681 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) },
680 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) }, 682 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) },
681 { USB_DEVICE(FTDI_VID, FTDI_MHAM_IC_PID) }, 683 { USB_DEVICE(FTDI_VID, FTDI_MHAM_IC_PID) },
682 { USB_DEVICE(FTDI_VID, FTDI_MHAM_DB9_PID) }, 684 { USB_DEVICE(FTDI_VID, FTDI_MHAM_DB9_PID) },
683 { USB_DEVICE(FTDI_VID, FTDI_MHAM_RS232_PID) }, 685 { USB_DEVICE(FTDI_VID, FTDI_MHAM_RS232_PID) },
684 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y9_PID) }, 686 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y9_PID) },
685 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) }, 687 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) },
686 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) }, 688 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) },
687 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 689 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
688 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) }, 690 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) },
689 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) }, 691 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) },
690 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 692 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
691 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 693 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
692 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, 694 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
693 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, 695 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) },
694 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HRC_PID) }, 696 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HRC_PID) },
695 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16IC_PID) }, 697 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16IC_PID) },
696 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, 698 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) },
697 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, 699 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) },
698 { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) }, 700 { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) },
699 { USB_DEVICE(FTDI_VID, FTDI_TTUSB_PID) }, 701 { USB_DEVICE(FTDI_VID, FTDI_TTUSB_PID) },
700 { USB_DEVICE(FTDI_VID, FTDI_ECLO_COM_1WIRE_PID) }, 702 { USB_DEVICE(FTDI_VID, FTDI_ECLO_COM_1WIRE_PID) },
701 { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_777_PID) }, 703 { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_777_PID) },
702 { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_8900F_PID) }, 704 { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_8900F_PID) },
703 { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) }, 705 { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) },
704 { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) }, 706 { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) },
705 { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) }, 707 { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) },
706 { USB_DEVICE(FTDI_VID, FTDI_NZR_SEM_USB_PID) }, 708 { USB_DEVICE(FTDI_VID, FTDI_NZR_SEM_USB_PID) },
707 { USB_DEVICE(ICOM_VID, ICOM_ID_1_PID) }, 709 { USB_DEVICE(ICOM_VID, ICOM_ID_1_PID) },
708 { USB_DEVICE(ICOM_VID, ICOM_OPC_U_UC_PID) }, 710 { USB_DEVICE(ICOM_VID, ICOM_OPC_U_UC_PID) },
709 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2C1_PID) }, 711 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2C1_PID) },
710 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2C2_PID) }, 712 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2C2_PID) },
711 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2D_PID) }, 713 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2D_PID) },
712 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2VT_PID) }, 714 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2VT_PID) },
713 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2VR_PID) }, 715 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2VR_PID) },
714 { USB_DEVICE(ICOM_VID, ICOM_ID_RP4KVT_PID) }, 716 { USB_DEVICE(ICOM_VID, ICOM_ID_RP4KVT_PID) },
715 { USB_DEVICE(ICOM_VID, ICOM_ID_RP4KVR_PID) }, 717 { USB_DEVICE(ICOM_VID, ICOM_ID_RP4KVR_PID) },
716 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2KVT_PID) }, 718 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2KVT_PID) },
717 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2KVR_PID) }, 719 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2KVR_PID) },
718 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) }, 720 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) },
719 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) }, 721 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) },
720 { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) }, 722 { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) },
721 { USB_DEVICE(TESTO_VID, TESTO_USB_INTERFACE_PID) }, 723 { USB_DEVICE(TESTO_VID, TESTO_USB_INTERFACE_PID) },
722 { USB_DEVICE(FTDI_VID, FTDI_GAMMA_SCOUT_PID) }, 724 { USB_DEVICE(FTDI_VID, FTDI_GAMMA_SCOUT_PID) },
723 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, 725 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
724 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, 726 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
725 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 727 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
726 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) }, 728 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
727 { USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID), 729 { USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID),
728 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk }, 730 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
729 { USB_DEVICE(FTDI_VID, FTDI_NDI_SPECTRA_SCU_PID), 731 { USB_DEVICE(FTDI_VID, FTDI_NDI_SPECTRA_SCU_PID),
730 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk }, 732 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
731 { USB_DEVICE(FTDI_VID, FTDI_NDI_FUTURE_2_PID), 733 { USB_DEVICE(FTDI_VID, FTDI_NDI_FUTURE_2_PID),
732 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk }, 734 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
733 { USB_DEVICE(FTDI_VID, FTDI_NDI_FUTURE_3_PID), 735 { USB_DEVICE(FTDI_VID, FTDI_NDI_FUTURE_3_PID),
734 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk }, 736 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
735 { USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID), 737 { USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID),
736 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk }, 738 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
737 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, 739 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
738 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S03_PID) }, 740 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S03_PID) },
739 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_59_PID) }, 741 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_59_PID) },
740 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57A_PID) }, 742 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57A_PID) },
741 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57B_PID) }, 743 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57B_PID) },
742 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29A_PID) }, 744 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29A_PID) },
743 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29B_PID) }, 745 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29B_PID) },
744 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29F_PID) }, 746 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29F_PID) },
745 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_62B_PID) }, 747 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_62B_PID) },
746 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S01_PID) }, 748 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S01_PID) },
747 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_63_PID) }, 749 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_63_PID) },
748 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29C_PID) }, 750 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29C_PID) },
749 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_81B_PID) }, 751 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_81B_PID) },
750 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_82B_PID) }, 752 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_82B_PID) },
751 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K5D_PID) }, 753 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K5D_PID) },
752 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K4Y_PID) }, 754 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K4Y_PID) },
753 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K5G_PID) }, 755 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K5G_PID) },
754 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S05_PID) }, 756 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S05_PID) },
755 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_60_PID) }, 757 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_60_PID) },
756 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_61_PID) }, 758 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_61_PID) },
757 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_62_PID) }, 759 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_62_PID) },
758 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_63B_PID) }, 760 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_63B_PID) },
759 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_64_PID) }, 761 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_64_PID) },
760 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_65_PID) }, 762 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_65_PID) },
761 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_92_PID) }, 763 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_92_PID) },
762 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_92D_PID) }, 764 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_92D_PID) },
763 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_W5R_PID) }, 765 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_W5R_PID) },
764 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_A5R_PID) }, 766 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_A5R_PID) },
765 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_PW1_PID) }, 767 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_PW1_PID) },
766 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, 768 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) },
767 { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) }, 769 { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) },
768 { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, 770 { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) },
769 { USB_DEVICE(FTDI_VID, FTDI_ELSTER_UNICOM_PID) }, 771 { USB_DEVICE(FTDI_VID, FTDI_ELSTER_UNICOM_PID) },
770 { USB_DEVICE(FTDI_VID, FTDI_PROPOX_JTAGCABLEII_PID) }, 772 { USB_DEVICE(FTDI_VID, FTDI_PROPOX_JTAGCABLEII_PID) },
771 { USB_DEVICE(FTDI_VID, FTDI_PROPOX_ISPCABLEIII_PID) }, 773 { USB_DEVICE(FTDI_VID, FTDI_PROPOX_ISPCABLEIII_PID) },
772 { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), 774 { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID),
773 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 775 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
774 { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID), 776 { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID),
775 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 777 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
776 { USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID), 778 { USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID),
777 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 779 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
778 { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID), 780 { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID),
779 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 781 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
780 { USB_DEVICE(FTDI_VID, LMI_LM3S_DEVEL_BOARD_PID), 782 { USB_DEVICE(FTDI_VID, LMI_LM3S_DEVEL_BOARD_PID),
781 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 783 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
782 { USB_DEVICE(FTDI_VID, LMI_LM3S_EVAL_BOARD_PID), 784 { USB_DEVICE(FTDI_VID, LMI_LM3S_EVAL_BOARD_PID),
783 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 785 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
784 { USB_DEVICE(FTDI_VID, LMI_LM3S_ICDI_BOARD_PID), 786 { USB_DEVICE(FTDI_VID, LMI_LM3S_ICDI_BOARD_PID),
785 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 787 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
786 { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID), 788 { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID),
787 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 789 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
788 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, 790 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
789 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, 791 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
790 792
791 /* Papouch devices based on FTDI chip */ 793 /* Papouch devices based on FTDI chip */
792 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_PID) }, 794 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_PID) },
793 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_PID) }, 795 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_PID) },
794 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_PID) }, 796 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_PID) },
795 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_2_PID) }, 797 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_2_PID) },
796 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_2_PID) }, 798 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_2_PID) },
797 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_2_PID) }, 799 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_2_PID) },
798 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485S_PID) }, 800 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485S_PID) },
799 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485C_PID) }, 801 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485C_PID) },
800 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_LEC_PID) }, 802 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_LEC_PID) },
801 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB232_PID) }, 803 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB232_PID) },
802 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) }, 804 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) },
803 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_IRAMP_PID) }, 805 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_IRAMP_PID) },
804 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK5_PID) }, 806 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK5_PID) },
805 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO8x8_PID) }, 807 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO8x8_PID) },
806 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) }, 808 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
807 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x2_PID) }, 809 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x2_PID) },
808 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO10x1_PID) }, 810 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO10x1_PID) },
809 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO30x3_PID) }, 811 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO30x3_PID) },
810 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO60x3_PID) }, 812 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO60x3_PID) },
811 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x16_PID) }, 813 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x16_PID) },
812 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO3x32_PID) }, 814 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO3x32_PID) },
813 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK6_PID) }, 815 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK6_PID) },
814 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_UPSUSB_PID) }, 816 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_UPSUSB_PID) },
815 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_MU_PID) }, 817 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_MU_PID) },
816 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SIMUKEY_PID) }, 818 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SIMUKEY_PID) },
817 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AD4USB_PID) }, 819 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AD4USB_PID) },
818 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMUX_PID) }, 820 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMUX_PID) },
819 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMSR_PID) }, 821 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMSR_PID) },
820 822
821 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) }, 823 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) },
822 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, 824 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
823 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) }, 825 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
824 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) }, 826 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) },
825 { USB_DEVICE(ATMEL_VID, STK541_PID) }, 827 { USB_DEVICE(ATMEL_VID, STK541_PID) },
826 { USB_DEVICE(DE_VID, STB_PID) }, 828 { USB_DEVICE(DE_VID, STB_PID) },
827 { USB_DEVICE(DE_VID, WHT_PID) }, 829 { USB_DEVICE(DE_VID, WHT_PID) },
828 { USB_DEVICE(ADI_VID, ADI_GNICE_PID), 830 { USB_DEVICE(ADI_VID, ADI_GNICE_PID),
829 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 831 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
830 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), 832 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID),
831 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 833 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
832 { USB_DEVICE_AND_INTERFACE_INFO(MICROCHIP_VID, MICROCHIP_USB_BOARD_PID, 834 { USB_DEVICE_AND_INTERFACE_INFO(MICROCHIP_VID, MICROCHIP_USB_BOARD_PID,
833 USB_CLASS_VENDOR_SPEC, 835 USB_CLASS_VENDOR_SPEC,
834 USB_SUBCLASS_VENDOR_SPEC, 0x00) }, 836 USB_SUBCLASS_VENDOR_SPEC, 0x00) },
835 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, 837 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
836 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), 838 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
837 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 839 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
838 { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) }, 840 { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) },
839 { USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) }, 841 { USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) },
840 { USB_DEVICE(FTDI_VID, PI_C865_PID) }, 842 { USB_DEVICE(FTDI_VID, PI_C865_PID) },
841 { USB_DEVICE(FTDI_VID, PI_C857_PID) }, 843 { USB_DEVICE(FTDI_VID, PI_C857_PID) },
842 { USB_DEVICE(PI_VID, PI_C866_PID) }, 844 { USB_DEVICE(PI_VID, PI_C866_PID) },
843 { USB_DEVICE(PI_VID, PI_C663_PID) }, 845 { USB_DEVICE(PI_VID, PI_C663_PID) },
844 { USB_DEVICE(PI_VID, PI_C725_PID) }, 846 { USB_DEVICE(PI_VID, PI_C725_PID) },
845 { USB_DEVICE(PI_VID, PI_E517_PID) }, 847 { USB_DEVICE(PI_VID, PI_E517_PID) },
846 { USB_DEVICE(PI_VID, PI_C863_PID) }, 848 { USB_DEVICE(PI_VID, PI_C863_PID) },
847 { USB_DEVICE(PI_VID, PI_E861_PID) }, 849 { USB_DEVICE(PI_VID, PI_E861_PID) },
848 { USB_DEVICE(PI_VID, PI_C867_PID) }, 850 { USB_DEVICE(PI_VID, PI_C867_PID) },
849 { USB_DEVICE(PI_VID, PI_E609_PID) }, 851 { USB_DEVICE(PI_VID, PI_E609_PID) },
850 { USB_DEVICE(PI_VID, PI_E709_PID) }, 852 { USB_DEVICE(PI_VID, PI_E709_PID) },
851 { USB_DEVICE(PI_VID, PI_100F_PID) }, 853 { USB_DEVICE(PI_VID, PI_100F_PID) },
852 { USB_DEVICE(PI_VID, PI_1011_PID) }, 854 { USB_DEVICE(PI_VID, PI_1011_PID) },
853 { USB_DEVICE(PI_VID, PI_1012_PID) }, 855 { USB_DEVICE(PI_VID, PI_1012_PID) },
854 { USB_DEVICE(PI_VID, PI_1013_PID) }, 856 { USB_DEVICE(PI_VID, PI_1013_PID) },
855 { USB_DEVICE(PI_VID, PI_1014_PID) }, 857 { USB_DEVICE(PI_VID, PI_1014_PID) },
856 { USB_DEVICE(PI_VID, PI_1015_PID) }, 858 { USB_DEVICE(PI_VID, PI_1015_PID) },
857 { USB_DEVICE(PI_VID, PI_1016_PID) }, 859 { USB_DEVICE(PI_VID, PI_1016_PID) },
858 { USB_DEVICE(KONDO_VID, KONDO_USB_SERIAL_PID) }, 860 { USB_DEVICE(KONDO_VID, KONDO_USB_SERIAL_PID) },
859 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) }, 861 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
860 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID), 862 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
861 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 863 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
862 { USB_DEVICE(FTDI_VID, TI_XDS100V2_PID), 864 { USB_DEVICE(FTDI_VID, TI_XDS100V2_PID),
863 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 865 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
864 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, 866 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
865 { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) }, 867 { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) },
866 { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) }, 868 { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) },
867 { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) }, 869 { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) },
868 { USB_DEVICE(FTDI_VID, MJSG_GENERIC_PID) }, 870 { USB_DEVICE(FTDI_VID, MJSG_GENERIC_PID) },
869 { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) }, 871 { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) },
870 { USB_DEVICE(FTDI_VID, MJSG_HD_RADIO_PID) }, 872 { USB_DEVICE(FTDI_VID, MJSG_HD_RADIO_PID) },
871 { USB_DEVICE(FTDI_VID, MJSG_XM_RADIO_PID) }, 873 { USB_DEVICE(FTDI_VID, MJSG_XM_RADIO_PID) },
872 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_ST_PID), 874 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_ST_PID),
873 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 875 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
874 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SLITE_PID), 876 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SLITE_PID),
875 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 877 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
876 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH2_PID), 878 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH2_PID),
877 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 879 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
878 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID), 880 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID),
879 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 881 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
880 { USB_DEVICE(FTDI_VID, SEGWAY_RMP200_PID) }, 882 { USB_DEVICE(FTDI_VID, SEGWAY_RMP200_PID) },
881 { USB_DEVICE(FTDI_VID, ACCESIO_COM4SM_PID) }, 883 { USB_DEVICE(FTDI_VID, ACCESIO_COM4SM_PID) },
882 { USB_DEVICE(IONICS_VID, IONICS_PLUGCOMPUTER_PID), 884 { USB_DEVICE(IONICS_VID, IONICS_PLUGCOMPUTER_PID),
883 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 885 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
884 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_24_MASTER_WING_PID) }, 886 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_24_MASTER_WING_PID) },
885 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_PC_WING_PID) }, 887 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_PC_WING_PID) },
886 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_USB_DMX_PID) }, 888 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_USB_DMX_PID) },
887 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MIDI_TIMECODE_PID) }, 889 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MIDI_TIMECODE_PID) },
888 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MINI_WING_PID) }, 890 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MINI_WING_PID) },
889 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MAXI_WING_PID) }, 891 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MAXI_WING_PID) },
890 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MEDIA_WING_PID) }, 892 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MEDIA_WING_PID) },
891 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_WING_PID) }, 893 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_WING_PID) },
892 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LOGBOOKML_PID) }, 894 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LOGBOOKML_PID) },
893 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LS_LOGBOOK_PID) }, 895 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LS_LOGBOOK_PID) },
894 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_HS_LOGBOOK_PID) }, 896 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_HS_LOGBOOK_PID) },
895 { USB_DEVICE(FTDI_VID, FTDI_CINTERION_MC55I_PID) }, 897 { USB_DEVICE(FTDI_VID, FTDI_CINTERION_MC55I_PID) },
896 { USB_DEVICE(FTDI_VID, FTDI_DOTEC_PID) }, 898 { USB_DEVICE(FTDI_VID, FTDI_DOTEC_PID) },
897 { USB_DEVICE(QIHARDWARE_VID, MILKYMISTONE_JTAGSERIAL_PID), 899 { USB_DEVICE(QIHARDWARE_VID, MILKYMISTONE_JTAGSERIAL_PID),
898 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 900 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
899 { USB_DEVICE(ST_VID, ST_STMCLT_2232_PID), 901 { USB_DEVICE(ST_VID, ST_STMCLT_2232_PID),
900 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 902 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
901 { USB_DEVICE(ST_VID, ST_STMCLT_4232_PID), 903 { USB_DEVICE(ST_VID, ST_STMCLT_4232_PID),
902 .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk }, 904 .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk },
903 { USB_DEVICE(FTDI_VID, FTDI_RF_R106) }, 905 { USB_DEVICE(FTDI_VID, FTDI_RF_R106) },
904 { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID), 906 { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID),
905 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 907 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
906 { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) }, 908 { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) },
907 /* Crucible Devices */ 909 /* Crucible Devices */
908 { USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) }, 910 { USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) },
909 { USB_DEVICE(FTDI_VID, FTDI_Z3X_PID) }, 911 { USB_DEVICE(FTDI_VID, FTDI_Z3X_PID) },
910 /* Cressi Devices */ 912 /* Cressi Devices */
911 { USB_DEVICE(FTDI_VID, FTDI_CRESSI_PID) }, 913 { USB_DEVICE(FTDI_VID, FTDI_CRESSI_PID) },
912 /* Brainboxes Devices */ 914 /* Brainboxes Devices */
913 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_VX_001_PID) }, 915 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_VX_001_PID) },
914 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_VX_012_PID) }, 916 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_VX_012_PID) },
915 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_VX_023_PID) }, 917 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_VX_023_PID) },
916 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_VX_034_PID) }, 918 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_VX_034_PID) },
917 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_101_PID) }, 919 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_101_PID) },
918 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_1_PID) }, 920 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_1_PID) },
919 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_2_PID) }, 921 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_2_PID) },
920 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_3_PID) }, 922 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_3_PID) },
921 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_4_PID) }, 923 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_4_PID) },
922 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_5_PID) }, 924 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_5_PID) },
923 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_6_PID) }, 925 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_6_PID) },
924 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_7_PID) }, 926 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_7_PID) },
925 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_8_PID) }, 927 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_160_8_PID) },
926 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_257_PID) }, 928 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_257_PID) },
927 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_279_1_PID) }, 929 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_279_1_PID) },
928 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_279_2_PID) }, 930 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_279_2_PID) },
929 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_279_3_PID) }, 931 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_279_3_PID) },
930 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_279_4_PID) }, 932 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_279_4_PID) },
931 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_313_PID) }, 933 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_313_PID) },
932 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_324_PID) }, 934 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_324_PID) },
933 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_346_1_PID) }, 935 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_346_1_PID) },
934 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_346_2_PID) }, 936 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_346_2_PID) },
935 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_357_PID) }, 937 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_357_PID) },
936 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_606_1_PID) }, 938 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_606_1_PID) },
937 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_606_2_PID) }, 939 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_606_2_PID) },
938 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_606_3_PID) }, 940 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_606_3_PID) },
939 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_701_1_PID) }, 941 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_701_1_PID) },
940 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_701_2_PID) }, 942 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_701_2_PID) },
941 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_1_PID) }, 943 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_1_PID) },
942 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) }, 944 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) },
943 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) }, 945 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) },
944 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) }, 946 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) },
945 { } /* Terminating entry */ 947 { } /* Terminating entry */
946 }; 948 };
947 949
948 MODULE_DEVICE_TABLE(usb, id_table_combined); 950 MODULE_DEVICE_TABLE(usb, id_table_combined);
949 951
950 static const char *ftdi_chip_name[] = { 952 static const char *ftdi_chip_name[] = {
951 [SIO] = "SIO", /* the serial part of FT8U100AX */ 953 [SIO] = "SIO", /* the serial part of FT8U100AX */
952 [FT8U232AM] = "FT8U232AM", 954 [FT8U232AM] = "FT8U232AM",
953 [FT232BM] = "FT232BM", 955 [FT232BM] = "FT232BM",
954 [FT2232C] = "FT2232C", 956 [FT2232C] = "FT2232C",
955 [FT232RL] = "FT232RL", 957 [FT232RL] = "FT232RL",
956 [FT2232H] = "FT2232H", 958 [FT2232H] = "FT2232H",
957 [FT4232H] = "FT4232H", 959 [FT4232H] = "FT4232H",
958 [FT232H] = "FT232H", 960 [FT232H] = "FT232H",
959 [FTX] = "FT-X" 961 [FTX] = "FT-X"
960 }; 962 };
961 963
962 964
963 /* Used for TIOCMIWAIT */ 965 /* Used for TIOCMIWAIT */
964 #define FTDI_STATUS_B0_MASK (FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD) 966 #define FTDI_STATUS_B0_MASK (FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD)
965 #define FTDI_STATUS_B1_MASK (FTDI_RS_BI) 967 #define FTDI_STATUS_B1_MASK (FTDI_RS_BI)
966 /* End TIOCMIWAIT */ 968 /* End TIOCMIWAIT */
967 969
968 /* function prototypes for a FTDI serial converter */ 970 /* function prototypes for a FTDI serial converter */
969 static int ftdi_sio_probe(struct usb_serial *serial, 971 static int ftdi_sio_probe(struct usb_serial *serial,
970 const struct usb_device_id *id); 972 const struct usb_device_id *id);
971 static int ftdi_sio_port_probe(struct usb_serial_port *port); 973 static int ftdi_sio_port_probe(struct usb_serial_port *port);
972 static int ftdi_sio_port_remove(struct usb_serial_port *port); 974 static int ftdi_sio_port_remove(struct usb_serial_port *port);
973 static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port); 975 static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port);
974 static void ftdi_dtr_rts(struct usb_serial_port *port, int on); 976 static void ftdi_dtr_rts(struct usb_serial_port *port, int on);
975 static void ftdi_process_read_urb(struct urb *urb); 977 static void ftdi_process_read_urb(struct urb *urb);
976 static int ftdi_prepare_write_buffer(struct usb_serial_port *port, 978 static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
977 void *dest, size_t size); 979 void *dest, size_t size);
978 static void ftdi_set_termios(struct tty_struct *tty, 980 static void ftdi_set_termios(struct tty_struct *tty,
979 struct usb_serial_port *port, struct ktermios *old); 981 struct usb_serial_port *port, struct ktermios *old);
980 static int ftdi_tiocmget(struct tty_struct *tty); 982 static int ftdi_tiocmget(struct tty_struct *tty);
981 static int ftdi_tiocmset(struct tty_struct *tty, 983 static int ftdi_tiocmset(struct tty_struct *tty,
982 unsigned int set, unsigned int clear); 984 unsigned int set, unsigned int clear);
983 static int ftdi_ioctl(struct tty_struct *tty, 985 static int ftdi_ioctl(struct tty_struct *tty,
984 unsigned int cmd, unsigned long arg); 986 unsigned int cmd, unsigned long arg);
985 static void ftdi_break_ctl(struct tty_struct *tty, int break_state); 987 static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
986 static bool ftdi_tx_empty(struct usb_serial_port *port); 988 static bool ftdi_tx_empty(struct usb_serial_port *port);
987 static int ftdi_get_modem_status(struct usb_serial_port *port, 989 static int ftdi_get_modem_status(struct usb_serial_port *port,
988 unsigned char status[2]); 990 unsigned char status[2]);
989 991
990 static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); 992 static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base);
991 static unsigned short int ftdi_232am_baud_to_divisor(int baud); 993 static unsigned short int ftdi_232am_baud_to_divisor(int baud);
992 static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base); 994 static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base);
993 static __u32 ftdi_232bm_baud_to_divisor(int baud); 995 static __u32 ftdi_232bm_baud_to_divisor(int baud);
994 static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base); 996 static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base);
995 static __u32 ftdi_2232h_baud_to_divisor(int baud); 997 static __u32 ftdi_2232h_baud_to_divisor(int baud);
996 998
997 static struct usb_serial_driver ftdi_sio_device = { 999 static struct usb_serial_driver ftdi_sio_device = {
998 .driver = { 1000 .driver = {
999 .owner = THIS_MODULE, 1001 .owner = THIS_MODULE,
1000 .name = "ftdi_sio", 1002 .name = "ftdi_sio",
1001 }, 1003 },
1002 .description = "FTDI USB Serial Device", 1004 .description = "FTDI USB Serial Device",
1003 .id_table = id_table_combined, 1005 .id_table = id_table_combined,
1004 .num_ports = 1, 1006 .num_ports = 1,
1005 .bulk_in_size = 512, 1007 .bulk_in_size = 512,
1006 .bulk_out_size = 256, 1008 .bulk_out_size = 256,
1007 .probe = ftdi_sio_probe, 1009 .probe = ftdi_sio_probe,
1008 .port_probe = ftdi_sio_port_probe, 1010 .port_probe = ftdi_sio_port_probe,
1009 .port_remove = ftdi_sio_port_remove, 1011 .port_remove = ftdi_sio_port_remove,
1010 .open = ftdi_open, 1012 .open = ftdi_open,
1011 .dtr_rts = ftdi_dtr_rts, 1013 .dtr_rts = ftdi_dtr_rts,
1012 .throttle = usb_serial_generic_throttle, 1014 .throttle = usb_serial_generic_throttle,
1013 .unthrottle = usb_serial_generic_unthrottle, 1015 .unthrottle = usb_serial_generic_unthrottle,
1014 .process_read_urb = ftdi_process_read_urb, 1016 .process_read_urb = ftdi_process_read_urb,
1015 .prepare_write_buffer = ftdi_prepare_write_buffer, 1017 .prepare_write_buffer = ftdi_prepare_write_buffer,
1016 .tiocmget = ftdi_tiocmget, 1018 .tiocmget = ftdi_tiocmget,
1017 .tiocmset = ftdi_tiocmset, 1019 .tiocmset = ftdi_tiocmset,
1018 .tiocmiwait = usb_serial_generic_tiocmiwait, 1020 .tiocmiwait = usb_serial_generic_tiocmiwait,
1019 .get_icount = usb_serial_generic_get_icount, 1021 .get_icount = usb_serial_generic_get_icount,
1020 .ioctl = ftdi_ioctl, 1022 .ioctl = ftdi_ioctl,
1021 .set_termios = ftdi_set_termios, 1023 .set_termios = ftdi_set_termios,
1022 .break_ctl = ftdi_break_ctl, 1024 .break_ctl = ftdi_break_ctl,
1023 .tx_empty = ftdi_tx_empty, 1025 .tx_empty = ftdi_tx_empty,
1024 }; 1026 };
1025 1027
1026 static struct usb_serial_driver * const serial_drivers[] = { 1028 static struct usb_serial_driver * const serial_drivers[] = {
1027 &ftdi_sio_device, NULL 1029 &ftdi_sio_device, NULL
1028 }; 1030 };
1029 1031
1030 1032
1031 #define WDR_TIMEOUT 5000 /* default urb timeout */ 1033 #define WDR_TIMEOUT 5000 /* default urb timeout */
1032 #define WDR_SHORT_TIMEOUT 1000 /* shorter urb timeout */ 1034 #define WDR_SHORT_TIMEOUT 1000 /* shorter urb timeout */
1033 1035
1034 /* 1036 /*
1035 * *************************************************************************** 1037 * ***************************************************************************
1036 * Utility functions 1038 * Utility functions
1037 * *************************************************************************** 1039 * ***************************************************************************
1038 */ 1040 */
1039 1041
1040 static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base) 1042 static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base)
1041 { 1043 {
1042 unsigned short int divisor; 1044 unsigned short int divisor;
1043 /* divisor shifted 3 bits to the left */ 1045 /* divisor shifted 3 bits to the left */
1044 int divisor3 = base / 2 / baud; 1046 int divisor3 = base / 2 / baud;
1045 if ((divisor3 & 0x7) == 7) 1047 if ((divisor3 & 0x7) == 7)
1046 divisor3++; /* round x.7/8 up to x+1 */ 1048 divisor3++; /* round x.7/8 up to x+1 */
1047 divisor = divisor3 >> 3; 1049 divisor = divisor3 >> 3;
1048 divisor3 &= 0x7; 1050 divisor3 &= 0x7;
1049 if (divisor3 == 1) 1051 if (divisor3 == 1)
1050 divisor |= 0xc000; 1052 divisor |= 0xc000;
1051 else if (divisor3 >= 4) 1053 else if (divisor3 >= 4)
1052 divisor |= 0x4000; 1054 divisor |= 0x4000;
1053 else if (divisor3 != 0) 1055 else if (divisor3 != 0)
1054 divisor |= 0x8000; 1056 divisor |= 0x8000;
1055 else if (divisor == 1) 1057 else if (divisor == 1)
1056 divisor = 0; /* special case for maximum baud rate */ 1058 divisor = 0; /* special case for maximum baud rate */
1057 return divisor; 1059 return divisor;
1058 } 1060 }
1059 1061
1060 static unsigned short int ftdi_232am_baud_to_divisor(int baud) 1062 static unsigned short int ftdi_232am_baud_to_divisor(int baud)
1061 { 1063 {
1062 return ftdi_232am_baud_base_to_divisor(baud, 48000000); 1064 return ftdi_232am_baud_base_to_divisor(baud, 48000000);
1063 } 1065 }
1064 1066
1065 static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base) 1067 static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base)
1066 { 1068 {
1067 static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 }; 1069 static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
1068 __u32 divisor; 1070 __u32 divisor;
1069 /* divisor shifted 3 bits to the left */ 1071 /* divisor shifted 3 bits to the left */
1070 int divisor3 = base / 2 / baud; 1072 int divisor3 = base / 2 / baud;
1071 divisor = divisor3 >> 3; 1073 divisor = divisor3 >> 3;
1072 divisor |= (__u32)divfrac[divisor3 & 0x7] << 14; 1074 divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
1073 /* Deal with special cases for highest baud rates. */ 1075 /* Deal with special cases for highest baud rates. */
1074 if (divisor == 1) 1076 if (divisor == 1)
1075 divisor = 0; 1077 divisor = 0;
1076 else if (divisor == 0x4001) 1078 else if (divisor == 0x4001)
1077 divisor = 1; 1079 divisor = 1;
1078 return divisor; 1080 return divisor;
1079 } 1081 }
1080 1082
1081 static __u32 ftdi_232bm_baud_to_divisor(int baud) 1083 static __u32 ftdi_232bm_baud_to_divisor(int baud)
1082 { 1084 {
1083 return ftdi_232bm_baud_base_to_divisor(baud, 48000000); 1085 return ftdi_232bm_baud_base_to_divisor(baud, 48000000);
1084 } 1086 }
1085 1087
1086 static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base) 1088 static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base)
1087 { 1089 {
1088 static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 }; 1090 static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
1089 __u32 divisor; 1091 __u32 divisor;
1090 int divisor3; 1092 int divisor3;
1091 1093
1092 /* hi-speed baud rate is 10-bit sampling instead of 16-bit */ 1094 /* hi-speed baud rate is 10-bit sampling instead of 16-bit */
1093 divisor3 = base * 8 / (baud * 10); 1095 divisor3 = base * 8 / (baud * 10);
1094 1096
1095 divisor = divisor3 >> 3; 1097 divisor = divisor3 >> 3;
1096 divisor |= (__u32)divfrac[divisor3 & 0x7] << 14; 1098 divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
1097 /* Deal with special cases for highest baud rates. */ 1099 /* Deal with special cases for highest baud rates. */
1098 if (divisor == 1) 1100 if (divisor == 1)
1099 divisor = 0; 1101 divisor = 0;
1100 else if (divisor == 0x4001) 1102 else if (divisor == 0x4001)
1101 divisor = 1; 1103 divisor = 1;
1102 /* 1104 /*
1103 * Set this bit to turn off a divide by 2.5 on baud rate generator 1105 * Set this bit to turn off a divide by 2.5 on baud rate generator
1104 * This enables baud rates up to 12Mbaud but cannot reach below 1200 1106 * This enables baud rates up to 12Mbaud but cannot reach below 1200
1105 * baud with this bit set 1107 * baud with this bit set
1106 */ 1108 */
1107 divisor |= 0x00020000; 1109 divisor |= 0x00020000;
1108 return divisor; 1110 return divisor;
1109 } 1111 }
1110 1112
1111 static __u32 ftdi_2232h_baud_to_divisor(int baud) 1113 static __u32 ftdi_2232h_baud_to_divisor(int baud)
1112 { 1114 {
1113 return ftdi_2232h_baud_base_to_divisor(baud, 120000000); 1115 return ftdi_2232h_baud_base_to_divisor(baud, 120000000);
1114 } 1116 }
1115 1117
1116 #define set_mctrl(port, set) update_mctrl((port), (set), 0) 1118 #define set_mctrl(port, set) update_mctrl((port), (set), 0)
1117 #define clear_mctrl(port, clear) update_mctrl((port), 0, (clear)) 1119 #define clear_mctrl(port, clear) update_mctrl((port), 0, (clear))
1118 1120
1119 static int update_mctrl(struct usb_serial_port *port, unsigned int set, 1121 static int update_mctrl(struct usb_serial_port *port, unsigned int set,
1120 unsigned int clear) 1122 unsigned int clear)
1121 { 1123 {
1122 struct ftdi_private *priv = usb_get_serial_port_data(port); 1124 struct ftdi_private *priv = usb_get_serial_port_data(port);
1123 struct device *dev = &port->dev; 1125 struct device *dev = &port->dev;
1124 unsigned urb_value; 1126 unsigned urb_value;
1125 int rv; 1127 int rv;
1126 1128
1127 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { 1129 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) {
1128 dev_dbg(dev, "%s - DTR|RTS not being set|cleared\n", __func__); 1130 dev_dbg(dev, "%s - DTR|RTS not being set|cleared\n", __func__);
1129 return 0; /* no change */ 1131 return 0; /* no change */
1130 } 1132 }
1131 1133
1132 clear &= ~set; /* 'set' takes precedence over 'clear' */ 1134 clear &= ~set; /* 'set' takes precedence over 'clear' */
1133 urb_value = 0; 1135 urb_value = 0;
1134 if (clear & TIOCM_DTR) 1136 if (clear & TIOCM_DTR)
1135 urb_value |= FTDI_SIO_SET_DTR_LOW; 1137 urb_value |= FTDI_SIO_SET_DTR_LOW;
1136 if (clear & TIOCM_RTS) 1138 if (clear & TIOCM_RTS)
1137 urb_value |= FTDI_SIO_SET_RTS_LOW; 1139 urb_value |= FTDI_SIO_SET_RTS_LOW;
1138 if (set & TIOCM_DTR) 1140 if (set & TIOCM_DTR)
1139 urb_value |= FTDI_SIO_SET_DTR_HIGH; 1141 urb_value |= FTDI_SIO_SET_DTR_HIGH;
1140 if (set & TIOCM_RTS) 1142 if (set & TIOCM_RTS)
1141 urb_value |= FTDI_SIO_SET_RTS_HIGH; 1143 urb_value |= FTDI_SIO_SET_RTS_HIGH;
1142 rv = usb_control_msg(port->serial->dev, 1144 rv = usb_control_msg(port->serial->dev,
1143 usb_sndctrlpipe(port->serial->dev, 0), 1145 usb_sndctrlpipe(port->serial->dev, 0),
1144 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 1146 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
1145 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 1147 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
1146 urb_value, priv->interface, 1148 urb_value, priv->interface,
1147 NULL, 0, WDR_TIMEOUT); 1149 NULL, 0, WDR_TIMEOUT);
1148 if (rv < 0) { 1150 if (rv < 0) {
1149 dev_dbg(dev, "%s Error from MODEM_CTRL urb: DTR %s, RTS %s\n", 1151 dev_dbg(dev, "%s Error from MODEM_CTRL urb: DTR %s, RTS %s\n",
1150 __func__, 1152 __func__,
1151 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", 1153 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged",
1152 (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); 1154 (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged");
1153 rv = usb_translate_errors(rv); 1155 rv = usb_translate_errors(rv);
1154 } else { 1156 } else {
1155 dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, 1157 dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__,
1156 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", 1158 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged",
1157 (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); 1159 (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged");
1158 /* FIXME: locking on last_dtr_rts */ 1160 /* FIXME: locking on last_dtr_rts */
1159 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; 1161 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set;
1160 } 1162 }
1161 return rv; 1163 return rv;
1162 } 1164 }
1163 1165
1164 1166
1165 static __u32 get_ftdi_divisor(struct tty_struct *tty, 1167 static __u32 get_ftdi_divisor(struct tty_struct *tty,
1166 struct usb_serial_port *port) 1168 struct usb_serial_port *port)
1167 { 1169 {
1168 struct ftdi_private *priv = usb_get_serial_port_data(port); 1170 struct ftdi_private *priv = usb_get_serial_port_data(port);
1169 struct device *dev = &port->dev; 1171 struct device *dev = &port->dev;
1170 __u32 div_value = 0; 1172 __u32 div_value = 0;
1171 int div_okay = 1; 1173 int div_okay = 1;
1172 int baud; 1174 int baud;
1173 1175
1174 /* 1176 /*
1175 * The logic involved in setting the baudrate can be cleanly split into 1177 * The logic involved in setting the baudrate can be cleanly split into
1176 * 3 steps. 1178 * 3 steps.
1177 * 1. Standard baud rates are set in tty->termios->c_cflag 1179 * 1. Standard baud rates are set in tty->termios->c_cflag
1178 * 2. If these are not enough, you can set any speed using alt_speed as 1180 * 2. If these are not enough, you can set any speed using alt_speed as
1179 * follows: 1181 * follows:
1180 * - set tty->termios->c_cflag speed to B38400 1182 * - set tty->termios->c_cflag speed to B38400
1181 * - set your real speed in tty->alt_speed; it gets ignored when 1183 * - set your real speed in tty->alt_speed; it gets ignored when
1182 * alt_speed==0, (or) 1184 * alt_speed==0, (or)
1183 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as 1185 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as
1184 * follows: 1186 * follows:
1185 * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP], 1187 * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP],
1186 * this just sets alt_speed to (HI: 57600, VHI: 115200, 1188 * this just sets alt_speed to (HI: 57600, VHI: 115200,
1187 * SHI: 230400, WARP: 460800) 1189 * SHI: 230400, WARP: 460800)
1188 * ** Steps 1, 2 are done courtesy of tty_get_baud_rate 1190 * ** Steps 1, 2 are done courtesy of tty_get_baud_rate
1189 * 3. You can also set baud rate by setting custom divisor as follows 1191 * 3. You can also set baud rate by setting custom divisor as follows
1190 * - set tty->termios->c_cflag speed to B38400 1192 * - set tty->termios->c_cflag speed to B38400
1191 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as 1193 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as
1192 * follows: 1194 * follows:
1193 * o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST 1195 * o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST
1194 * o custom_divisor set to baud_base / your_new_baudrate 1196 * o custom_divisor set to baud_base / your_new_baudrate
1195 * ** Step 3 is done courtesy of code borrowed from serial.c 1197 * ** Step 3 is done courtesy of code borrowed from serial.c
1196 * I should really spend some time and separate + move this common 1198 * I should really spend some time and separate + move this common
1197 * code to serial.c, it is replicated in nearly every serial driver 1199 * code to serial.c, it is replicated in nearly every serial driver
1198 * you see. 1200 * you see.
1199 */ 1201 */
1200 1202
1201 /* 1. Get the baud rate from the tty settings, this observes 1203 /* 1. Get the baud rate from the tty settings, this observes
1202 alt_speed hack */ 1204 alt_speed hack */
1203 1205
1204 baud = tty_get_baud_rate(tty); 1206 baud = tty_get_baud_rate(tty);
1205 dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud); 1207 dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud);
1206 1208
1207 /* 2. Observe async-compatible custom_divisor hack, update baudrate 1209 /* 2. Observe async-compatible custom_divisor hack, update baudrate
1208 if needed */ 1210 if needed */
1209 1211
1210 if (baud == 38400 && 1212 if (baud == 38400 &&
1211 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1213 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
1212 (priv->custom_divisor)) { 1214 (priv->custom_divisor)) {
1213 baud = priv->baud_base / priv->custom_divisor; 1215 baud = priv->baud_base / priv->custom_divisor;
1214 dev_dbg(dev, "%s - custom divisor %d sets baud rate to %d\n", 1216 dev_dbg(dev, "%s - custom divisor %d sets baud rate to %d\n",
1215 __func__, priv->custom_divisor, baud); 1217 __func__, priv->custom_divisor, baud);
1216 } 1218 }
1217 1219
1218 /* 3. Convert baudrate to device-specific divisor */ 1220 /* 3. Convert baudrate to device-specific divisor */
1219 1221
1220 if (!baud) 1222 if (!baud)
1221 baud = 9600; 1223 baud = 9600;
1222 switch (priv->chip_type) { 1224 switch (priv->chip_type) {
1223 case SIO: /* SIO chip */ 1225 case SIO: /* SIO chip */
1224 switch (baud) { 1226 switch (baud) {
1225 case 300: div_value = ftdi_sio_b300; break; 1227 case 300: div_value = ftdi_sio_b300; break;
1226 case 600: div_value = ftdi_sio_b600; break; 1228 case 600: div_value = ftdi_sio_b600; break;
1227 case 1200: div_value = ftdi_sio_b1200; break; 1229 case 1200: div_value = ftdi_sio_b1200; break;
1228 case 2400: div_value = ftdi_sio_b2400; break; 1230 case 2400: div_value = ftdi_sio_b2400; break;
1229 case 4800: div_value = ftdi_sio_b4800; break; 1231 case 4800: div_value = ftdi_sio_b4800; break;
1230 case 9600: div_value = ftdi_sio_b9600; break; 1232 case 9600: div_value = ftdi_sio_b9600; break;
1231 case 19200: div_value = ftdi_sio_b19200; break; 1233 case 19200: div_value = ftdi_sio_b19200; break;
1232 case 38400: div_value = ftdi_sio_b38400; break; 1234 case 38400: div_value = ftdi_sio_b38400; break;
1233 case 57600: div_value = ftdi_sio_b57600; break; 1235 case 57600: div_value = ftdi_sio_b57600; break;
1234 case 115200: div_value = ftdi_sio_b115200; break; 1236 case 115200: div_value = ftdi_sio_b115200; break;
1235 } /* baud */ 1237 } /* baud */
1236 if (div_value == 0) { 1238 if (div_value == 0) {
1237 dev_dbg(dev, "%s - Baudrate (%d) requested is not supported\n", 1239 dev_dbg(dev, "%s - Baudrate (%d) requested is not supported\n",
1238 __func__, baud); 1240 __func__, baud);
1239 div_value = ftdi_sio_b9600; 1241 div_value = ftdi_sio_b9600;
1240 baud = 9600; 1242 baud = 9600;
1241 div_okay = 0; 1243 div_okay = 0;
1242 } 1244 }
1243 break; 1245 break;
1244 case FT8U232AM: /* 8U232AM chip */ 1246 case FT8U232AM: /* 8U232AM chip */
1245 if (baud <= 3000000) { 1247 if (baud <= 3000000) {
1246 div_value = ftdi_232am_baud_to_divisor(baud); 1248 div_value = ftdi_232am_baud_to_divisor(baud);
1247 } else { 1249 } else {
1248 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); 1250 dev_dbg(dev, "%s - Baud rate too high!\n", __func__);
1249 baud = 9600; 1251 baud = 9600;
1250 div_value = ftdi_232am_baud_to_divisor(9600); 1252 div_value = ftdi_232am_baud_to_divisor(9600);
1251 div_okay = 0; 1253 div_okay = 0;
1252 } 1254 }
1253 break; 1255 break;
1254 case FT232BM: /* FT232BM chip */ 1256 case FT232BM: /* FT232BM chip */
1255 case FT2232C: /* FT2232C chip */ 1257 case FT2232C: /* FT2232C chip */
1256 case FT232RL: /* FT232RL chip */ 1258 case FT232RL: /* FT232RL chip */
1257 case FTX: /* FT-X series */ 1259 case FTX: /* FT-X series */
1258 if (baud <= 3000000) { 1260 if (baud <= 3000000) {
1259 __u16 product_id = le16_to_cpu( 1261 __u16 product_id = le16_to_cpu(
1260 port->serial->dev->descriptor.idProduct); 1262 port->serial->dev->descriptor.idProduct);
1261 if (((FTDI_NDI_HUC_PID == product_id) || 1263 if (((FTDI_NDI_HUC_PID == product_id) ||
1262 (FTDI_NDI_SPECTRA_SCU_PID == product_id) || 1264 (FTDI_NDI_SPECTRA_SCU_PID == product_id) ||
1263 (FTDI_NDI_FUTURE_2_PID == product_id) || 1265 (FTDI_NDI_FUTURE_2_PID == product_id) ||
1264 (FTDI_NDI_FUTURE_3_PID == product_id) || 1266 (FTDI_NDI_FUTURE_3_PID == product_id) ||
1265 (FTDI_NDI_AURORA_SCU_PID == product_id)) && 1267 (FTDI_NDI_AURORA_SCU_PID == product_id)) &&
1266 (baud == 19200)) { 1268 (baud == 19200)) {
1267 baud = 1200000; 1269 baud = 1200000;
1268 } 1270 }
1269 div_value = ftdi_232bm_baud_to_divisor(baud); 1271 div_value = ftdi_232bm_baud_to_divisor(baud);
1270 } else { 1272 } else {
1271 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); 1273 dev_dbg(dev, "%s - Baud rate too high!\n", __func__);
1272 div_value = ftdi_232bm_baud_to_divisor(9600); 1274 div_value = ftdi_232bm_baud_to_divisor(9600);
1273 div_okay = 0; 1275 div_okay = 0;
1274 baud = 9600; 1276 baud = 9600;
1275 } 1277 }
1276 break; 1278 break;
1277 case FT2232H: /* FT2232H chip */ 1279 case FT2232H: /* FT2232H chip */
1278 case FT4232H: /* FT4232H chip */ 1280 case FT4232H: /* FT4232H chip */
1279 case FT232H: /* FT232H chip */ 1281 case FT232H: /* FT232H chip */
1280 if ((baud <= 12000000) && (baud >= 1200)) { 1282 if ((baud <= 12000000) && (baud >= 1200)) {
1281 div_value = ftdi_2232h_baud_to_divisor(baud); 1283 div_value = ftdi_2232h_baud_to_divisor(baud);
1282 } else if (baud < 1200) { 1284 } else if (baud < 1200) {
1283 div_value = ftdi_232bm_baud_to_divisor(baud); 1285 div_value = ftdi_232bm_baud_to_divisor(baud);
1284 } else { 1286 } else {
1285 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); 1287 dev_dbg(dev, "%s - Baud rate too high!\n", __func__);
1286 div_value = ftdi_232bm_baud_to_divisor(9600); 1288 div_value = ftdi_232bm_baud_to_divisor(9600);
1287 div_okay = 0; 1289 div_okay = 0;
1288 baud = 9600; 1290 baud = 9600;
1289 } 1291 }
1290 break; 1292 break;
1291 } /* priv->chip_type */ 1293 } /* priv->chip_type */
1292 1294
1293 if (div_okay) { 1295 if (div_okay) {
1294 dev_dbg(dev, "%s - Baud rate set to %d (divisor 0x%lX) on chip %s\n", 1296 dev_dbg(dev, "%s - Baud rate set to %d (divisor 0x%lX) on chip %s\n",
1295 __func__, baud, (unsigned long)div_value, 1297 __func__, baud, (unsigned long)div_value,
1296 ftdi_chip_name[priv->chip_type]); 1298 ftdi_chip_name[priv->chip_type]);
1297 } 1299 }
1298 1300
1299 tty_encode_baud_rate(tty, baud, baud); 1301 tty_encode_baud_rate(tty, baud, baud);
1300 return div_value; 1302 return div_value;
1301 } 1303 }
1302 1304
1303 static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) 1305 static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
1304 { 1306 {
1305 struct ftdi_private *priv = usb_get_serial_port_data(port); 1307 struct ftdi_private *priv = usb_get_serial_port_data(port);
1306 __u16 urb_value; 1308 __u16 urb_value;
1307 __u16 urb_index; 1309 __u16 urb_index;
1308 __u32 urb_index_value; 1310 __u32 urb_index_value;
1309 int rv; 1311 int rv;
1310 1312
1311 urb_index_value = get_ftdi_divisor(tty, port); 1313 urb_index_value = get_ftdi_divisor(tty, port);
1312 urb_value = (__u16)urb_index_value; 1314 urb_value = (__u16)urb_index_value;
1313 urb_index = (__u16)(urb_index_value >> 16); 1315 urb_index = (__u16)(urb_index_value >> 16);
1314 if ((priv->chip_type == FT2232C) || (priv->chip_type == FT2232H) || 1316 if ((priv->chip_type == FT2232C) || (priv->chip_type == FT2232H) ||
1315 (priv->chip_type == FT4232H) || (priv->chip_type == FT232H)) { 1317 (priv->chip_type == FT4232H) || (priv->chip_type == FT232H)) {
1316 /* Probably the BM type needs the MSB of the encoded fractional 1318 /* Probably the BM type needs the MSB of the encoded fractional
1317 * divider also moved like for the chips above. Any infos? */ 1319 * divider also moved like for the chips above. Any infos? */
1318 urb_index = (__u16)((urb_index << 8) | priv->interface); 1320 urb_index = (__u16)((urb_index << 8) | priv->interface);
1319 } 1321 }
1320 1322
1321 rv = usb_control_msg(port->serial->dev, 1323 rv = usb_control_msg(port->serial->dev,
1322 usb_sndctrlpipe(port->serial->dev, 0), 1324 usb_sndctrlpipe(port->serial->dev, 0),
1323 FTDI_SIO_SET_BAUDRATE_REQUEST, 1325 FTDI_SIO_SET_BAUDRATE_REQUEST,
1324 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, 1326 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
1325 urb_value, urb_index, 1327 urb_value, urb_index,
1326 NULL, 0, WDR_SHORT_TIMEOUT); 1328 NULL, 0, WDR_SHORT_TIMEOUT);
1327 return rv; 1329 return rv;
1328 } 1330 }
1329 1331
1330 static int write_latency_timer(struct usb_serial_port *port) 1332 static int write_latency_timer(struct usb_serial_port *port)
1331 { 1333 {
1332 struct ftdi_private *priv = usb_get_serial_port_data(port); 1334 struct ftdi_private *priv = usb_get_serial_port_data(port);
1333 struct usb_device *udev = port->serial->dev; 1335 struct usb_device *udev = port->serial->dev;
1334 int rv; 1336 int rv;
1335 int l = priv->latency; 1337 int l = priv->latency;
1336 1338
1337 if (priv->flags & ASYNC_LOW_LATENCY) 1339 if (priv->flags & ASYNC_LOW_LATENCY)
1338 l = 1; 1340 l = 1;
1339 1341
1340 dev_dbg(&port->dev, "%s: setting latency timer = %i\n", __func__, l); 1342 dev_dbg(&port->dev, "%s: setting latency timer = %i\n", __func__, l);
1341 1343
1342 rv = usb_control_msg(udev, 1344 rv = usb_control_msg(udev,
1343 usb_sndctrlpipe(udev, 0), 1345 usb_sndctrlpipe(udev, 0),
1344 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1346 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1345 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1347 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1346 l, priv->interface, 1348 l, priv->interface,
1347 NULL, 0, WDR_TIMEOUT); 1349 NULL, 0, WDR_TIMEOUT);
1348 if (rv < 0) 1350 if (rv < 0)
1349 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); 1351 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv);
1350 return rv; 1352 return rv;
1351 } 1353 }
1352 1354
1353 static int read_latency_timer(struct usb_serial_port *port) 1355 static int read_latency_timer(struct usb_serial_port *port)
1354 { 1356 {
1355 struct ftdi_private *priv = usb_get_serial_port_data(port); 1357 struct ftdi_private *priv = usb_get_serial_port_data(port);
1356 struct usb_device *udev = port->serial->dev; 1358 struct usb_device *udev = port->serial->dev;
1357 unsigned char *buf; 1359 unsigned char *buf;
1358 int rv; 1360 int rv;
1359 1361
1360 buf = kmalloc(1, GFP_KERNEL); 1362 buf = kmalloc(1, GFP_KERNEL);
1361 if (!buf) 1363 if (!buf)
1362 return -ENOMEM; 1364 return -ENOMEM;
1363 1365
1364 rv = usb_control_msg(udev, 1366 rv = usb_control_msg(udev,
1365 usb_rcvctrlpipe(udev, 0), 1367 usb_rcvctrlpipe(udev, 0),
1366 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1368 FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1367 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1369 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1368 0, priv->interface, 1370 0, priv->interface,
1369 buf, 1, WDR_TIMEOUT); 1371 buf, 1, WDR_TIMEOUT);
1370 if (rv < 0) 1372 if (rv < 0)
1371 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv); 1373 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv);
1372 else 1374 else
1373 priv->latency = buf[0]; 1375 priv->latency = buf[0];
1374 1376
1375 kfree(buf); 1377 kfree(buf);
1376 1378
1377 return rv; 1379 return rv;
1378 } 1380 }
1379 1381
1380 static int get_serial_info(struct usb_serial_port *port, 1382 static int get_serial_info(struct usb_serial_port *port,
1381 struct serial_struct __user *retinfo) 1383 struct serial_struct __user *retinfo)
1382 { 1384 {
1383 struct ftdi_private *priv = usb_get_serial_port_data(port); 1385 struct ftdi_private *priv = usb_get_serial_port_data(port);
1384 struct serial_struct tmp; 1386 struct serial_struct tmp;
1385 1387
1386 if (!retinfo) 1388 if (!retinfo)
1387 return -EFAULT; 1389 return -EFAULT;
1388 memset(&tmp, 0, sizeof(tmp)); 1390 memset(&tmp, 0, sizeof(tmp));
1389 tmp.flags = priv->flags; 1391 tmp.flags = priv->flags;
1390 tmp.baud_base = priv->baud_base; 1392 tmp.baud_base = priv->baud_base;
1391 tmp.custom_divisor = priv->custom_divisor; 1393 tmp.custom_divisor = priv->custom_divisor;
1392 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1394 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1393 return -EFAULT; 1395 return -EFAULT;
1394 return 0; 1396 return 0;
1395 } 1397 }
1396 1398
1397 static int set_serial_info(struct tty_struct *tty, 1399 static int set_serial_info(struct tty_struct *tty,
1398 struct usb_serial_port *port, struct serial_struct __user *newinfo) 1400 struct usb_serial_port *port, struct serial_struct __user *newinfo)
1399 { 1401 {
1400 struct ftdi_private *priv = usb_get_serial_port_data(port); 1402 struct ftdi_private *priv = usb_get_serial_port_data(port);
1401 struct serial_struct new_serial; 1403 struct serial_struct new_serial;
1402 struct ftdi_private old_priv; 1404 struct ftdi_private old_priv;
1403 1405
1404 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 1406 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
1405 return -EFAULT; 1407 return -EFAULT;
1406 1408
1407 mutex_lock(&priv->cfg_lock); 1409 mutex_lock(&priv->cfg_lock);
1408 old_priv = *priv; 1410 old_priv = *priv;
1409 1411
1410 /* Do error checking and permission checking */ 1412 /* Do error checking and permission checking */
1411 1413
1412 if (!capable(CAP_SYS_ADMIN)) { 1414 if (!capable(CAP_SYS_ADMIN)) {
1413 if (((new_serial.flags & ~ASYNC_USR_MASK) != 1415 if (((new_serial.flags & ~ASYNC_USR_MASK) !=
1414 (priv->flags & ~ASYNC_USR_MASK))) { 1416 (priv->flags & ~ASYNC_USR_MASK))) {
1415 mutex_unlock(&priv->cfg_lock); 1417 mutex_unlock(&priv->cfg_lock);
1416 return -EPERM; 1418 return -EPERM;
1417 } 1419 }
1418 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | 1420 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) |
1419 (new_serial.flags & ASYNC_USR_MASK)); 1421 (new_serial.flags & ASYNC_USR_MASK));
1420 priv->custom_divisor = new_serial.custom_divisor; 1422 priv->custom_divisor = new_serial.custom_divisor;
1421 goto check_and_exit; 1423 goto check_and_exit;
1422 } 1424 }
1423 1425
1424 if (new_serial.baud_base != priv->baud_base) { 1426 if (new_serial.baud_base != priv->baud_base) {
1425 mutex_unlock(&priv->cfg_lock); 1427 mutex_unlock(&priv->cfg_lock);
1426 return -EINVAL; 1428 return -EINVAL;
1427 } 1429 }
1428 1430
1429 /* Make the changes - these are privileged changes! */ 1431 /* Make the changes - these are privileged changes! */
1430 1432
1431 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 1433 priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
1432 (new_serial.flags & ASYNC_FLAGS)); 1434 (new_serial.flags & ASYNC_FLAGS));
1433 priv->custom_divisor = new_serial.custom_divisor; 1435 priv->custom_divisor = new_serial.custom_divisor;
1434 1436
1435 write_latency_timer(port); 1437 write_latency_timer(port);
1436 1438
1437 check_and_exit: 1439 check_and_exit:
1438 if ((old_priv.flags & ASYNC_SPD_MASK) != 1440 if ((old_priv.flags & ASYNC_SPD_MASK) !=
1439 (priv->flags & ASYNC_SPD_MASK)) { 1441 (priv->flags & ASYNC_SPD_MASK)) {
1440 if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 1442 if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
1441 tty->alt_speed = 57600; 1443 tty->alt_speed = 57600;
1442 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 1444 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
1443 tty->alt_speed = 115200; 1445 tty->alt_speed = 115200;
1444 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 1446 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
1445 tty->alt_speed = 230400; 1447 tty->alt_speed = 230400;
1446 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 1448 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
1447 tty->alt_speed = 460800; 1449 tty->alt_speed = 460800;
1448 else 1450 else
1449 tty->alt_speed = 0; 1451 tty->alt_speed = 0;
1450 } 1452 }
1451 if (((old_priv.flags & ASYNC_SPD_MASK) != 1453 if (((old_priv.flags & ASYNC_SPD_MASK) !=
1452 (priv->flags & ASYNC_SPD_MASK)) || 1454 (priv->flags & ASYNC_SPD_MASK)) ||
1453 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1455 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
1454 (old_priv.custom_divisor != priv->custom_divisor))) { 1456 (old_priv.custom_divisor != priv->custom_divisor))) {
1455 change_speed(tty, port); 1457 change_speed(tty, port);
1456 mutex_unlock(&priv->cfg_lock); 1458 mutex_unlock(&priv->cfg_lock);
1457 } 1459 }
1458 else 1460 else
1459 mutex_unlock(&priv->cfg_lock); 1461 mutex_unlock(&priv->cfg_lock);
1460 return 0; 1462 return 0;
1461 } 1463 }
1462 1464
1463 static int get_lsr_info(struct usb_serial_port *port, 1465 static int get_lsr_info(struct usb_serial_port *port,
1464 struct serial_struct __user *retinfo) 1466 struct serial_struct __user *retinfo)
1465 { 1467 {
1466 struct ftdi_private *priv = usb_get_serial_port_data(port); 1468 struct ftdi_private *priv = usb_get_serial_port_data(port);
1467 unsigned int result = 0; 1469 unsigned int result = 0;
1468 1470
1469 if (!retinfo) 1471 if (!retinfo)
1470 return -EFAULT; 1472 return -EFAULT;
1471 1473
1472 if (priv->transmit_empty) 1474 if (priv->transmit_empty)
1473 result = TIOCSER_TEMT; 1475 result = TIOCSER_TEMT;
1474 1476
1475 if (copy_to_user(retinfo, &result, sizeof(unsigned int))) 1477 if (copy_to_user(retinfo, &result, sizeof(unsigned int)))
1476 return -EFAULT; 1478 return -EFAULT;
1477 return 0; 1479 return 0;
1478 } 1480 }
1479 1481
1480 1482
1481 /* Determine type of FTDI chip based on USB config and descriptor. */ 1483 /* Determine type of FTDI chip based on USB config and descriptor. */
1482 static void ftdi_determine_type(struct usb_serial_port *port) 1484 static void ftdi_determine_type(struct usb_serial_port *port)
1483 { 1485 {
1484 struct ftdi_private *priv = usb_get_serial_port_data(port); 1486 struct ftdi_private *priv = usb_get_serial_port_data(port);
1485 struct usb_serial *serial = port->serial; 1487 struct usb_serial *serial = port->serial;
1486 struct usb_device *udev = serial->dev; 1488 struct usb_device *udev = serial->dev;
1487 unsigned version; 1489 unsigned version;
1488 unsigned interfaces; 1490 unsigned interfaces;
1489 1491
1490 /* Assume it is not the original SIO device for now. */ 1492 /* Assume it is not the original SIO device for now. */
1491 priv->baud_base = 48000000 / 2; 1493 priv->baud_base = 48000000 / 2;
1492 1494
1493 version = le16_to_cpu(udev->descriptor.bcdDevice); 1495 version = le16_to_cpu(udev->descriptor.bcdDevice);
1494 interfaces = udev->actconfig->desc.bNumInterfaces; 1496 interfaces = udev->actconfig->desc.bNumInterfaces;
1495 dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__, 1497 dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__,
1496 version, interfaces); 1498 version, interfaces);
1497 if (interfaces > 1) { 1499 if (interfaces > 1) {
1498 int inter; 1500 int inter;
1499 1501
1500 /* Multiple interfaces.*/ 1502 /* Multiple interfaces.*/
1501 if (version == 0x0800) { 1503 if (version == 0x0800) {
1502 priv->chip_type = FT4232H; 1504 priv->chip_type = FT4232H;
1503 /* Hi-speed - baud clock runs at 120MHz */ 1505 /* Hi-speed - baud clock runs at 120MHz */
1504 priv->baud_base = 120000000 / 2; 1506 priv->baud_base = 120000000 / 2;
1505 } else if (version == 0x0700) { 1507 } else if (version == 0x0700) {
1506 priv->chip_type = FT2232H; 1508 priv->chip_type = FT2232H;
1507 /* Hi-speed - baud clock runs at 120MHz */ 1509 /* Hi-speed - baud clock runs at 120MHz */
1508 priv->baud_base = 120000000 / 2; 1510 priv->baud_base = 120000000 / 2;
1509 } else 1511 } else
1510 priv->chip_type = FT2232C; 1512 priv->chip_type = FT2232C;
1511 1513
1512 /* Determine interface code. */ 1514 /* Determine interface code. */
1513 inter = serial->interface->altsetting->desc.bInterfaceNumber; 1515 inter = serial->interface->altsetting->desc.bInterfaceNumber;
1514 if (inter == 0) { 1516 if (inter == 0) {
1515 priv->interface = INTERFACE_A; 1517 priv->interface = INTERFACE_A;
1516 } else if (inter == 1) { 1518 } else if (inter == 1) {
1517 priv->interface = INTERFACE_B; 1519 priv->interface = INTERFACE_B;
1518 } else if (inter == 2) { 1520 } else if (inter == 2) {
1519 priv->interface = INTERFACE_C; 1521 priv->interface = INTERFACE_C;
1520 } else if (inter == 3) { 1522 } else if (inter == 3) {
1521 priv->interface = INTERFACE_D; 1523 priv->interface = INTERFACE_D;
1522 } 1524 }
1523 /* BM-type devices have a bug where bcdDevice gets set 1525 /* BM-type devices have a bug where bcdDevice gets set
1524 * to 0x200 when iSerialNumber is 0. */ 1526 * to 0x200 when iSerialNumber is 0. */
1525 if (version < 0x500) { 1527 if (version < 0x500) {
1526 dev_dbg(&port->dev, 1528 dev_dbg(&port->dev,
1527 "%s: something fishy - bcdDevice too low for multi-interface device\n", 1529 "%s: something fishy - bcdDevice too low for multi-interface device\n",
1528 __func__); 1530 __func__);
1529 } 1531 }
1530 } else if (version < 0x200) { 1532 } else if (version < 0x200) {
1531 /* Old device. Assume it's the original SIO. */ 1533 /* Old device. Assume it's the original SIO. */
1532 priv->chip_type = SIO; 1534 priv->chip_type = SIO;
1533 priv->baud_base = 12000000 / 16; 1535 priv->baud_base = 12000000 / 16;
1534 } else if (version < 0x400) { 1536 } else if (version < 0x400) {
1535 /* Assume it's an FT8U232AM (or FT8U245AM) */ 1537 /* Assume it's an FT8U232AM (or FT8U245AM) */
1536 /* (It might be a BM because of the iSerialNumber bug, 1538 /* (It might be a BM because of the iSerialNumber bug,
1537 * but it will still work as an AM device.) */ 1539 * but it will still work as an AM device.) */
1538 priv->chip_type = FT8U232AM; 1540 priv->chip_type = FT8U232AM;
1539 } else if (version < 0x600) { 1541 } else if (version < 0x600) {
1540 /* Assume it's an FT232BM (or FT245BM) */ 1542 /* Assume it's an FT232BM (or FT245BM) */
1541 priv->chip_type = FT232BM; 1543 priv->chip_type = FT232BM;
1542 } else if (version < 0x900) { 1544 } else if (version < 0x900) {
1543 /* Assume it's an FT232RL */ 1545 /* Assume it's an FT232RL */
1544 priv->chip_type = FT232RL; 1546 priv->chip_type = FT232RL;
1545 } else if (version < 0x1000) { 1547 } else if (version < 0x1000) {
1546 /* Assume it's an FT232H */ 1548 /* Assume it's an FT232H */
1547 priv->chip_type = FT232H; 1549 priv->chip_type = FT232H;
1548 } else { 1550 } else {
1549 /* Assume it's an FT-X series device */ 1551 /* Assume it's an FT-X series device */
1550 priv->chip_type = FTX; 1552 priv->chip_type = FTX;
1551 } 1553 }
1552 1554
1553 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); 1555 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]);
1554 } 1556 }
1555 1557
1556 1558
1557 /* Determine the maximum packet size for the device. This depends on the chip 1559 /* Determine the maximum packet size for the device. This depends on the chip
1558 * type and the USB host capabilities. The value should be obtained from the 1560 * type and the USB host capabilities. The value should be obtained from the
1559 * device descriptor as the chip will use the appropriate values for the host.*/ 1561 * device descriptor as the chip will use the appropriate values for the host.*/
1560 static void ftdi_set_max_packet_size(struct usb_serial_port *port) 1562 static void ftdi_set_max_packet_size(struct usb_serial_port *port)
1561 { 1563 {
1562 struct ftdi_private *priv = usb_get_serial_port_data(port); 1564 struct ftdi_private *priv = usb_get_serial_port_data(port);
1563 struct usb_serial *serial = port->serial; 1565 struct usb_serial *serial = port->serial;
1564 struct usb_device *udev = serial->dev; 1566 struct usb_device *udev = serial->dev;
1565 1567
1566 struct usb_interface *interface = serial->interface; 1568 struct usb_interface *interface = serial->interface;
1567 struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc; 1569 struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc;
1568 1570
1569 unsigned num_endpoints; 1571 unsigned num_endpoints;
1570 int i; 1572 int i;
1571 1573
1572 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; 1574 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
1573 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); 1575 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
1574 1576
1575 /* NOTE: some customers have programmed FT232R/FT245R devices 1577 /* NOTE: some customers have programmed FT232R/FT245R devices
1576 * with an endpoint size of 0 - not good. In this case, we 1578 * with an endpoint size of 0 - not good. In this case, we
1577 * want to override the endpoint descriptor setting and use a 1579 * want to override the endpoint descriptor setting and use a
1578 * value of 64 for wMaxPacketSize */ 1580 * value of 64 for wMaxPacketSize */
1579 for (i = 0; i < num_endpoints; i++) { 1581 for (i = 0; i < num_endpoints; i++) {
1580 dev_info(&udev->dev, "Endpoint %d MaxPacketSize %d\n", i+1, 1582 dev_info(&udev->dev, "Endpoint %d MaxPacketSize %d\n", i+1,
1581 interface->cur_altsetting->endpoint[i].desc.wMaxPacketSize); 1583 interface->cur_altsetting->endpoint[i].desc.wMaxPacketSize);
1582 ep_desc = &interface->cur_altsetting->endpoint[i].desc; 1584 ep_desc = &interface->cur_altsetting->endpoint[i].desc;
1583 if (ep_desc->wMaxPacketSize == 0) { 1585 if (ep_desc->wMaxPacketSize == 0) {
1584 ep_desc->wMaxPacketSize = cpu_to_le16(0x40); 1586 ep_desc->wMaxPacketSize = cpu_to_le16(0x40);
1585 dev_info(&udev->dev, "Overriding wMaxPacketSize on endpoint %d\n", i); 1587 dev_info(&udev->dev, "Overriding wMaxPacketSize on endpoint %d\n", i);
1586 } 1588 }
1587 } 1589 }
1588 1590
1589 /* set max packet size based on descriptor */ 1591 /* set max packet size based on descriptor */
1590 priv->max_packet_size = usb_endpoint_maxp(ep_desc); 1592 priv->max_packet_size = usb_endpoint_maxp(ep_desc);
1591 1593
1592 dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size); 1594 dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size);
1593 } 1595 }
1594 1596
1595 1597
1596 /* 1598 /*
1597 * *************************************************************************** 1599 * ***************************************************************************
1598 * Sysfs Attribute 1600 * Sysfs Attribute
1599 * *************************************************************************** 1601 * ***************************************************************************
1600 */ 1602 */
1601 1603
1602 static ssize_t latency_timer_show(struct device *dev, 1604 static ssize_t latency_timer_show(struct device *dev,
1603 struct device_attribute *attr, char *buf) 1605 struct device_attribute *attr, char *buf)
1604 { 1606 {
1605 struct usb_serial_port *port = to_usb_serial_port(dev); 1607 struct usb_serial_port *port = to_usb_serial_port(dev);
1606 struct ftdi_private *priv = usb_get_serial_port_data(port); 1608 struct ftdi_private *priv = usb_get_serial_port_data(port);
1607 if (priv->flags & ASYNC_LOW_LATENCY) 1609 if (priv->flags & ASYNC_LOW_LATENCY)
1608 return sprintf(buf, "1\n"); 1610 return sprintf(buf, "1\n");
1609 else 1611 else
1610 return sprintf(buf, "%i\n", priv->latency); 1612 return sprintf(buf, "%i\n", priv->latency);
1611 } 1613 }
1612 1614
1613 /* Write a new value of the latency timer, in units of milliseconds. */ 1615 /* Write a new value of the latency timer, in units of milliseconds. */
1614 static ssize_t latency_timer_store(struct device *dev, 1616 static ssize_t latency_timer_store(struct device *dev,
1615 struct device_attribute *attr, 1617 struct device_attribute *attr,
1616 const char *valbuf, size_t count) 1618 const char *valbuf, size_t count)
1617 { 1619 {
1618 struct usb_serial_port *port = to_usb_serial_port(dev); 1620 struct usb_serial_port *port = to_usb_serial_port(dev);
1619 struct ftdi_private *priv = usb_get_serial_port_data(port); 1621 struct ftdi_private *priv = usb_get_serial_port_data(port);
1620 int v = simple_strtoul(valbuf, NULL, 10); 1622 int v = simple_strtoul(valbuf, NULL, 10);
1621 int rv; 1623 int rv;
1622 1624
1623 priv->latency = v; 1625 priv->latency = v;
1624 rv = write_latency_timer(port); 1626 rv = write_latency_timer(port);
1625 if (rv < 0) 1627 if (rv < 0)
1626 return -EIO; 1628 return -EIO;
1627 return count; 1629 return count;
1628 } 1630 }
1629 static DEVICE_ATTR_RW(latency_timer); 1631 static DEVICE_ATTR_RW(latency_timer);
1630 1632
1631 /* Write an event character directly to the FTDI register. The ASCII 1633 /* Write an event character directly to the FTDI register. The ASCII
1632 value is in the low 8 bits, with the enable bit in the 9th bit. */ 1634 value is in the low 8 bits, with the enable bit in the 9th bit. */
1633 static ssize_t store_event_char(struct device *dev, 1635 static ssize_t store_event_char(struct device *dev,
1634 struct device_attribute *attr, const char *valbuf, size_t count) 1636 struct device_attribute *attr, const char *valbuf, size_t count)
1635 { 1637 {
1636 struct usb_serial_port *port = to_usb_serial_port(dev); 1638 struct usb_serial_port *port = to_usb_serial_port(dev);
1637 struct ftdi_private *priv = usb_get_serial_port_data(port); 1639 struct ftdi_private *priv = usb_get_serial_port_data(port);
1638 struct usb_device *udev = port->serial->dev; 1640 struct usb_device *udev = port->serial->dev;
1639 int v = simple_strtoul(valbuf, NULL, 10); 1641 int v = simple_strtoul(valbuf, NULL, 10);
1640 int rv; 1642 int rv;
1641 1643
1642 dev_dbg(&port->dev, "%s: setting event char = %i\n", __func__, v); 1644 dev_dbg(&port->dev, "%s: setting event char = %i\n", __func__, v);
1643 1645
1644 rv = usb_control_msg(udev, 1646 rv = usb_control_msg(udev,
1645 usb_sndctrlpipe(udev, 0), 1647 usb_sndctrlpipe(udev, 0),
1646 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1648 FTDI_SIO_SET_EVENT_CHAR_REQUEST,
1647 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1649 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE,
1648 v, priv->interface, 1650 v, priv->interface,
1649 NULL, 0, WDR_TIMEOUT); 1651 NULL, 0, WDR_TIMEOUT);
1650 if (rv < 0) { 1652 if (rv < 0) {
1651 dev_dbg(&port->dev, "Unable to write event character: %i\n", rv); 1653 dev_dbg(&port->dev, "Unable to write event character: %i\n", rv);
1652 return -EIO; 1654 return -EIO;
1653 } 1655 }
1654 1656
1655 return count; 1657 return count;
1656 } 1658 }
1657 static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char); 1659 static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char);
1658 1660
1659 static int create_sysfs_attrs(struct usb_serial_port *port) 1661 static int create_sysfs_attrs(struct usb_serial_port *port)
1660 { 1662 {
1661 struct ftdi_private *priv = usb_get_serial_port_data(port); 1663 struct ftdi_private *priv = usb_get_serial_port_data(port);
1662 int retval = 0; 1664 int retval = 0;
1663 1665
1664 /* XXX I've no idea if the original SIO supports the event_char 1666 /* XXX I've no idea if the original SIO supports the event_char
1665 * sysfs parameter, so I'm playing it safe. */ 1667 * sysfs parameter, so I'm playing it safe. */
1666 if (priv->chip_type != SIO) { 1668 if (priv->chip_type != SIO) {
1667 dev_dbg(&port->dev, "sysfs attributes for %s\n", ftdi_chip_name[priv->chip_type]); 1669 dev_dbg(&port->dev, "sysfs attributes for %s\n", ftdi_chip_name[priv->chip_type]);
1668 retval = device_create_file(&port->dev, &dev_attr_event_char); 1670 retval = device_create_file(&port->dev, &dev_attr_event_char);
1669 if ((!retval) && 1671 if ((!retval) &&
1670 (priv->chip_type == FT232BM || 1672 (priv->chip_type == FT232BM ||
1671 priv->chip_type == FT2232C || 1673 priv->chip_type == FT2232C ||
1672 priv->chip_type == FT232RL || 1674 priv->chip_type == FT232RL ||
1673 priv->chip_type == FT2232H || 1675 priv->chip_type == FT2232H ||
1674 priv->chip_type == FT4232H || 1676 priv->chip_type == FT4232H ||
1675 priv->chip_type == FT232H || 1677 priv->chip_type == FT232H ||
1676 priv->chip_type == FTX)) { 1678 priv->chip_type == FTX)) {
1677 retval = device_create_file(&port->dev, 1679 retval = device_create_file(&port->dev,
1678 &dev_attr_latency_timer); 1680 &dev_attr_latency_timer);
1679 } 1681 }
1680 } 1682 }
1681 return retval; 1683 return retval;
1682 } 1684 }
1683 1685
1684 static void remove_sysfs_attrs(struct usb_serial_port *port) 1686 static void remove_sysfs_attrs(struct usb_serial_port *port)
1685 { 1687 {
1686 struct ftdi_private *priv = usb_get_serial_port_data(port); 1688 struct ftdi_private *priv = usb_get_serial_port_data(port);
1687 1689
1688 /* XXX see create_sysfs_attrs */ 1690 /* XXX see create_sysfs_attrs */
1689 if (priv->chip_type != SIO) { 1691 if (priv->chip_type != SIO) {
1690 device_remove_file(&port->dev, &dev_attr_event_char); 1692 device_remove_file(&port->dev, &dev_attr_event_char);
1691 if (priv->chip_type == FT232BM || 1693 if (priv->chip_type == FT232BM ||
1692 priv->chip_type == FT2232C || 1694 priv->chip_type == FT2232C ||
1693 priv->chip_type == FT232RL || 1695 priv->chip_type == FT232RL ||
1694 priv->chip_type == FT2232H || 1696 priv->chip_type == FT2232H ||
1695 priv->chip_type == FT4232H || 1697 priv->chip_type == FT4232H ||
1696 priv->chip_type == FT232H || 1698 priv->chip_type == FT232H ||
1697 priv->chip_type == FTX) { 1699 priv->chip_type == FTX) {
1698 device_remove_file(&port->dev, &dev_attr_latency_timer); 1700 device_remove_file(&port->dev, &dev_attr_latency_timer);
1699 } 1701 }
1700 } 1702 }
1701 1703
1702 } 1704 }
1703 1705
1704 /* 1706 /*
1705 * *************************************************************************** 1707 * ***************************************************************************
1706 * FTDI driver specific functions 1708 * FTDI driver specific functions
1707 * *************************************************************************** 1709 * ***************************************************************************
1708 */ 1710 */
1709 1711
1710 /* Probe function to check for special devices */ 1712 /* Probe function to check for special devices */
1711 static int ftdi_sio_probe(struct usb_serial *serial, 1713 static int ftdi_sio_probe(struct usb_serial *serial,
1712 const struct usb_device_id *id) 1714 const struct usb_device_id *id)
1713 { 1715 {
1714 struct ftdi_sio_quirk *quirk = 1716 struct ftdi_sio_quirk *quirk =
1715 (struct ftdi_sio_quirk *)id->driver_info; 1717 (struct ftdi_sio_quirk *)id->driver_info;
1716 1718
1717 if (quirk && quirk->probe) { 1719 if (quirk && quirk->probe) {
1718 int ret = quirk->probe(serial); 1720 int ret = quirk->probe(serial);
1719 if (ret != 0) 1721 if (ret != 0)
1720 return ret; 1722 return ret;
1721 } 1723 }
1722 1724
1723 usb_set_serial_data(serial, (void *)id->driver_info); 1725 usb_set_serial_data(serial, (void *)id->driver_info);
1724 1726
1725 return 0; 1727 return 0;
1726 } 1728 }
1727 1729
1728 static int ftdi_sio_port_probe(struct usb_serial_port *port) 1730 static int ftdi_sio_port_probe(struct usb_serial_port *port)
1729 { 1731 {
1730 struct ftdi_private *priv; 1732 struct ftdi_private *priv;
1731 struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial); 1733 struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial);
1732 1734
1733 1735
1734 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); 1736 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
1735 if (!priv) 1737 if (!priv)
1736 return -ENOMEM; 1738 return -ENOMEM;
1737 1739
1738 mutex_init(&priv->cfg_lock); 1740 mutex_init(&priv->cfg_lock);
1739 1741
1740 priv->flags = ASYNC_LOW_LATENCY; 1742 priv->flags = ASYNC_LOW_LATENCY;
1741 1743
1742 if (quirk && quirk->port_probe) 1744 if (quirk && quirk->port_probe)
1743 quirk->port_probe(priv); 1745 quirk->port_probe(priv);
1744 1746
1745 usb_set_serial_port_data(port, priv); 1747 usb_set_serial_port_data(port, priv);
1746 1748
1747 ftdi_determine_type(port); 1749 ftdi_determine_type(port);
1748 ftdi_set_max_packet_size(port); 1750 ftdi_set_max_packet_size(port);
1749 if (read_latency_timer(port) < 0) 1751 if (read_latency_timer(port) < 0)
1750 priv->latency = 16; 1752 priv->latency = 16;
1751 write_latency_timer(port); 1753 write_latency_timer(port);
1752 create_sysfs_attrs(port); 1754 create_sysfs_attrs(port);
1753 return 0; 1755 return 0;
1754 } 1756 }
1755 1757
1756 /* Setup for the USB-UIRT device, which requires hardwired 1758 /* Setup for the USB-UIRT device, which requires hardwired
1757 * baudrate (38400 gets mapped to 312500) */ 1759 * baudrate (38400 gets mapped to 312500) */
1758 /* Called from usbserial:serial_probe */ 1760 /* Called from usbserial:serial_probe */
1759 static void ftdi_USB_UIRT_setup(struct ftdi_private *priv) 1761 static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
1760 { 1762 {
1761 priv->flags |= ASYNC_SPD_CUST; 1763 priv->flags |= ASYNC_SPD_CUST;
1762 priv->custom_divisor = 77; 1764 priv->custom_divisor = 77;
1763 priv->force_baud = 38400; 1765 priv->force_baud = 38400;
1764 } 1766 }
1765 1767
1766 /* Setup for the HE-TIRA1 device, which requires hardwired 1768 /* Setup for the HE-TIRA1 device, which requires hardwired
1767 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */ 1769 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
1768 1770
1769 static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv) 1771 static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv)
1770 { 1772 {
1771 priv->flags |= ASYNC_SPD_CUST; 1773 priv->flags |= ASYNC_SPD_CUST;
1772 priv->custom_divisor = 240; 1774 priv->custom_divisor = 240;
1773 priv->force_baud = 38400; 1775 priv->force_baud = 38400;
1774 priv->force_rtscts = 1; 1776 priv->force_rtscts = 1;
1775 } 1777 }
1776 1778
1777 /* 1779 /*
1778 * Module parameter to control latency timer for NDI FTDI-based USB devices. 1780 * Module parameter to control latency timer for NDI FTDI-based USB devices.
1779 * If this value is not set in /etc/modprobe.d/ its value will be set 1781 * If this value is not set in /etc/modprobe.d/ its value will be set
1780 * to 1ms. 1782 * to 1ms.
1781 */ 1783 */
1782 static int ndi_latency_timer = 1; 1784 static int ndi_latency_timer = 1;
1783 1785
1784 /* Setup for the NDI FTDI-based USB devices, which requires hardwired 1786 /* Setup for the NDI FTDI-based USB devices, which requires hardwired
1785 * baudrate (19200 gets mapped to 1200000). 1787 * baudrate (19200 gets mapped to 1200000).
1786 * 1788 *
1787 * Called from usbserial:serial_probe. 1789 * Called from usbserial:serial_probe.
1788 */ 1790 */
1789 static int ftdi_NDI_device_setup(struct usb_serial *serial) 1791 static int ftdi_NDI_device_setup(struct usb_serial *serial)
1790 { 1792 {
1791 struct usb_device *udev = serial->dev; 1793 struct usb_device *udev = serial->dev;
1792 int latency = ndi_latency_timer; 1794 int latency = ndi_latency_timer;
1793 1795
1794 if (latency == 0) 1796 if (latency == 0)
1795 latency = 1; 1797 latency = 1;
1796 if (latency > 99) 1798 if (latency > 99)
1797 latency = 99; 1799 latency = 99;
1798 1800
1799 dev_dbg(&udev->dev, "%s setting NDI device latency to %d\n", __func__, latency); 1801 dev_dbg(&udev->dev, "%s setting NDI device latency to %d\n", __func__, latency);
1800 dev_info(&udev->dev, "NDI device with a latency value of %d\n", latency); 1802 dev_info(&udev->dev, "NDI device with a latency value of %d\n", latency);
1801 1803
1802 /* FIXME: errors are not returned */ 1804 /* FIXME: errors are not returned */
1803 usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 1805 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
1804 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1806 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1805 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1807 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1806 latency, 0, NULL, 0, WDR_TIMEOUT); 1808 latency, 0, NULL, 0, WDR_TIMEOUT);
1807 return 0; 1809 return 0;
1808 } 1810 }
1809 1811
1810 /* 1812 /*
1811 * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko 1813 * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko
1812 * Neo1973 Debug Board is reserved for JTAG interface and can be accessed from 1814 * Neo1973 Debug Board is reserved for JTAG interface and can be accessed from
1813 * userspace using openocd. 1815 * userspace using openocd.
1814 */ 1816 */
1815 static int ftdi_jtag_probe(struct usb_serial *serial) 1817 static int ftdi_jtag_probe(struct usb_serial *serial)
1816 { 1818 {
1817 struct usb_device *udev = serial->dev; 1819 struct usb_device *udev = serial->dev;
1818 struct usb_interface *interface = serial->interface; 1820 struct usb_interface *interface = serial->interface;
1819 1821
1820 if (interface == udev->actconfig->interface[0]) { 1822 if (interface == udev->actconfig->interface[0]) {
1821 dev_info(&udev->dev, 1823 dev_info(&udev->dev,
1822 "Ignoring serial port reserved for JTAG\n"); 1824 "Ignoring serial port reserved for JTAG\n");
1823 return -ENODEV; 1825 return -ENODEV;
1824 } 1826 }
1825 1827
1826 return 0; 1828 return 0;
1827 } 1829 }
1828 1830
1829 static int ftdi_8u2232c_probe(struct usb_serial *serial) 1831 static int ftdi_8u2232c_probe(struct usb_serial *serial)
1830 { 1832 {
1831 struct usb_device *udev = serial->dev; 1833 struct usb_device *udev = serial->dev;
1832 1834
1833 if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) || 1835 if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) ||
1834 (udev->product && !strcmp(udev->product, "BeagleBone/XDS100V2"))) 1836 (udev->product && !strcmp(udev->product, "BeagleBone/XDS100V2")))
1835 return ftdi_jtag_probe(serial); 1837 return ftdi_jtag_probe(serial);
1836 1838
1837 return 0; 1839 return 0;
1838 } 1840 }
1839 1841
1840 /* 1842 /*
1841 * First two ports on JTAG adaptors using an FT4232 such as STMicroelectronics's 1843 * First two ports on JTAG adaptors using an FT4232 such as STMicroelectronics's
1842 * ST Micro Connect Lite are reserved for JTAG or other non-UART interfaces and 1844 * ST Micro Connect Lite are reserved for JTAG or other non-UART interfaces and
1843 * can be accessed from userspace. 1845 * can be accessed from userspace.
1844 * The next two ports are enabled as UARTs by default, where port 2 is 1846 * The next two ports are enabled as UARTs by default, where port 2 is
1845 * a conventional RS-232 UART. 1847 * a conventional RS-232 UART.
1846 */ 1848 */
1847 static int ftdi_stmclite_probe(struct usb_serial *serial) 1849 static int ftdi_stmclite_probe(struct usb_serial *serial)
1848 { 1850 {
1849 struct usb_device *udev = serial->dev; 1851 struct usb_device *udev = serial->dev;
1850 struct usb_interface *interface = serial->interface; 1852 struct usb_interface *interface = serial->interface;
1851 1853
1852 if (interface == udev->actconfig->interface[0] || 1854 if (interface == udev->actconfig->interface[0] ||
1853 interface == udev->actconfig->interface[1]) { 1855 interface == udev->actconfig->interface[1]) {
1854 dev_info(&udev->dev, "Ignoring serial port reserved for JTAG\n"); 1856 dev_info(&udev->dev, "Ignoring serial port reserved for JTAG\n");
1855 return -ENODEV; 1857 return -ENODEV;
1856 } 1858 }
1857 1859
1858 return 0; 1860 return 0;
1859 } 1861 }
1860 1862
1861 /* 1863 /*
1862 * The Matrix Orbital VK204-25-USB has an invalid IN endpoint. 1864 * The Matrix Orbital VK204-25-USB has an invalid IN endpoint.
1863 * We have to correct it if we want to read from it. 1865 * We have to correct it if we want to read from it.
1864 */ 1866 */
1865 static int ftdi_mtxorb_hack_setup(struct usb_serial *serial) 1867 static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
1866 { 1868 {
1867 struct usb_host_endpoint *ep = serial->dev->ep_in[1]; 1869 struct usb_host_endpoint *ep = serial->dev->ep_in[1];
1868 struct usb_endpoint_descriptor *ep_desc = &ep->desc; 1870 struct usb_endpoint_descriptor *ep_desc = &ep->desc;
1869 1871
1870 if (ep->enabled && ep_desc->wMaxPacketSize == 0) { 1872 if (ep->enabled && ep_desc->wMaxPacketSize == 0) {
1871 ep_desc->wMaxPacketSize = cpu_to_le16(0x40); 1873 ep_desc->wMaxPacketSize = cpu_to_le16(0x40);
1872 dev_info(&serial->dev->dev, 1874 dev_info(&serial->dev->dev,
1873 "Fixing invalid wMaxPacketSize on read pipe\n"); 1875 "Fixing invalid wMaxPacketSize on read pipe\n");
1874 } 1876 }
1875 1877
1876 return 0; 1878 return 0;
1877 } 1879 }
1878 1880
1879 static int ftdi_sio_port_remove(struct usb_serial_port *port) 1881 static int ftdi_sio_port_remove(struct usb_serial_port *port)
1880 { 1882 {
1881 struct ftdi_private *priv = usb_get_serial_port_data(port); 1883 struct ftdi_private *priv = usb_get_serial_port_data(port);
1882 1884
1883 remove_sysfs_attrs(port); 1885 remove_sysfs_attrs(port);
1884 1886
1885 kfree(priv); 1887 kfree(priv);
1886 1888
1887 return 0; 1889 return 0;
1888 } 1890 }
1889 1891
1890 static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) 1892 static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1891 { 1893 {
1892 struct usb_device *dev = port->serial->dev; 1894 struct usb_device *dev = port->serial->dev;
1893 struct ftdi_private *priv = usb_get_serial_port_data(port); 1895 struct ftdi_private *priv = usb_get_serial_port_data(port);
1894 1896
1895 /* No error checking for this (will get errors later anyway) */ 1897 /* No error checking for this (will get errors later anyway) */
1896 /* See ftdi_sio.h for description of what is reset */ 1898 /* See ftdi_sio.h for description of what is reset */
1897 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1899 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1898 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1900 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE,
1899 FTDI_SIO_RESET_SIO, 1901 FTDI_SIO_RESET_SIO,
1900 priv->interface, NULL, 0, WDR_TIMEOUT); 1902 priv->interface, NULL, 0, WDR_TIMEOUT);
1901 1903
1902 /* Termios defaults are set by usb_serial_init. We don't change 1904 /* Termios defaults are set by usb_serial_init. We don't change
1903 port->tty->termios - this would lose speed settings, etc. 1905 port->tty->termios - this would lose speed settings, etc.
1904 This is same behaviour as serial.c/rs_open() - Kuba */ 1906 This is same behaviour as serial.c/rs_open() - Kuba */
1905 1907
1906 /* ftdi_set_termios will send usb control messages */ 1908 /* ftdi_set_termios will send usb control messages */
1907 if (tty) 1909 if (tty)
1908 ftdi_set_termios(tty, port, NULL); 1910 ftdi_set_termios(tty, port, NULL);
1909 1911
1910 return usb_serial_generic_open(tty, port); 1912 return usb_serial_generic_open(tty, port);
1911 } 1913 }
1912 1914
1913 static void ftdi_dtr_rts(struct usb_serial_port *port, int on) 1915 static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
1914 { 1916 {
1915 struct ftdi_private *priv = usb_get_serial_port_data(port); 1917 struct ftdi_private *priv = usb_get_serial_port_data(port);
1916 1918
1917 /* Disable flow control */ 1919 /* Disable flow control */
1918 if (!on) { 1920 if (!on) {
1919 if (usb_control_msg(port->serial->dev, 1921 if (usb_control_msg(port->serial->dev,
1920 usb_sndctrlpipe(port->serial->dev, 0), 1922 usb_sndctrlpipe(port->serial->dev, 0),
1921 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1923 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1922 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1924 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1923 0, priv->interface, NULL, 0, 1925 0, priv->interface, NULL, 0,
1924 WDR_TIMEOUT) < 0) { 1926 WDR_TIMEOUT) < 0) {
1925 dev_err(&port->dev, "error from flowcontrol urb\n"); 1927 dev_err(&port->dev, "error from flowcontrol urb\n");
1926 } 1928 }
1927 } 1929 }
1928 /* drop RTS and DTR */ 1930 /* drop RTS and DTR */
1929 if (on) 1931 if (on)
1930 set_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1932 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1931 else 1933 else
1932 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1934 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1933 } 1935 }
1934 1936
1935 /* The SIO requires the first byte to have: 1937 /* The SIO requires the first byte to have:
1936 * B0 1 1938 * B0 1
1937 * B1 0 1939 * B1 0
1938 * B2..7 length of message excluding byte 0 1940 * B2..7 length of message excluding byte 0
1939 * 1941 *
1940 * The new devices do not require this byte 1942 * The new devices do not require this byte
1941 */ 1943 */
1942 static int ftdi_prepare_write_buffer(struct usb_serial_port *port, 1944 static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
1943 void *dest, size_t size) 1945 void *dest, size_t size)
1944 { 1946 {
1945 struct ftdi_private *priv; 1947 struct ftdi_private *priv;
1946 int count; 1948 int count;
1947 unsigned long flags; 1949 unsigned long flags;
1948 1950
1949 priv = usb_get_serial_port_data(port); 1951 priv = usb_get_serial_port_data(port);
1950 1952
1951 if (priv->chip_type == SIO) { 1953 if (priv->chip_type == SIO) {
1952 unsigned char *buffer = dest; 1954 unsigned char *buffer = dest;
1953 int i, len, c; 1955 int i, len, c;
1954 1956
1955 count = 0; 1957 count = 0;
1956 spin_lock_irqsave(&port->lock, flags); 1958 spin_lock_irqsave(&port->lock, flags);
1957 for (i = 0; i < size - 1; i += priv->max_packet_size) { 1959 for (i = 0; i < size - 1; i += priv->max_packet_size) {
1958 len = min_t(int, size - i, priv->max_packet_size) - 1; 1960 len = min_t(int, size - i, priv->max_packet_size) - 1;
1959 c = kfifo_out(&port->write_fifo, &buffer[i + 1], len); 1961 c = kfifo_out(&port->write_fifo, &buffer[i + 1], len);
1960 if (!c) 1962 if (!c)
1961 break; 1963 break;
1962 port->icount.tx += c; 1964 port->icount.tx += c;
1963 buffer[i] = (c << 2) + 1; 1965 buffer[i] = (c << 2) + 1;
1964 count += c + 1; 1966 count += c + 1;
1965 } 1967 }
1966 spin_unlock_irqrestore(&port->lock, flags); 1968 spin_unlock_irqrestore(&port->lock, flags);
1967 } else { 1969 } else {
1968 count = kfifo_out_locked(&port->write_fifo, dest, size, 1970 count = kfifo_out_locked(&port->write_fifo, dest, size,
1969 &port->lock); 1971 &port->lock);
1970 port->icount.tx += count; 1972 port->icount.tx += count;
1971 } 1973 }
1972 1974
1973 return count; 1975 return count;
1974 } 1976 }
1975 1977
1976 #define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE) 1978 #define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE)
1977 1979
1978 static int ftdi_process_packet(struct usb_serial_port *port, 1980 static int ftdi_process_packet(struct usb_serial_port *port,
1979 struct ftdi_private *priv, char *packet, int len) 1981 struct ftdi_private *priv, char *packet, int len)
1980 { 1982 {
1981 int i; 1983 int i;
1982 char status; 1984 char status;
1983 char flag; 1985 char flag;
1984 char *ch; 1986 char *ch;
1985 1987
1986 if (len < 2) { 1988 if (len < 2) {
1987 dev_dbg(&port->dev, "malformed packet\n"); 1989 dev_dbg(&port->dev, "malformed packet\n");
1988 return 0; 1990 return 0;
1989 } 1991 }
1990 1992
1991 /* Compare new line status to the old one, signal if different/ 1993 /* Compare new line status to the old one, signal if different/
1992 N.B. packet may be processed more than once, but differences 1994 N.B. packet may be processed more than once, but differences
1993 are only processed once. */ 1995 are only processed once. */
1994 status = packet[0] & FTDI_STATUS_B0_MASK; 1996 status = packet[0] & FTDI_STATUS_B0_MASK;
1995 if (status != priv->prev_status) { 1997 if (status != priv->prev_status) {
1996 char diff_status = status ^ priv->prev_status; 1998 char diff_status = status ^ priv->prev_status;
1997 1999
1998 if (diff_status & FTDI_RS0_CTS) 2000 if (diff_status & FTDI_RS0_CTS)
1999 port->icount.cts++; 2001 port->icount.cts++;
2000 if (diff_status & FTDI_RS0_DSR) 2002 if (diff_status & FTDI_RS0_DSR)
2001 port->icount.dsr++; 2003 port->icount.dsr++;
2002 if (diff_status & FTDI_RS0_RI) 2004 if (diff_status & FTDI_RS0_RI)
2003 port->icount.rng++; 2005 port->icount.rng++;
2004 if (diff_status & FTDI_RS0_RLSD) { 2006 if (diff_status & FTDI_RS0_RLSD) {
2005 struct tty_struct *tty; 2007 struct tty_struct *tty;
2006 2008
2007 port->icount.dcd++; 2009 port->icount.dcd++;
2008 tty = tty_port_tty_get(&port->port); 2010 tty = tty_port_tty_get(&port->port);
2009 if (tty) 2011 if (tty)
2010 usb_serial_handle_dcd_change(port, tty, 2012 usb_serial_handle_dcd_change(port, tty,
2011 status & FTDI_RS0_RLSD); 2013 status & FTDI_RS0_RLSD);
2012 tty_kref_put(tty); 2014 tty_kref_put(tty);
2013 } 2015 }
2014 2016
2015 wake_up_interruptible(&port->port.delta_msr_wait); 2017 wake_up_interruptible(&port->port.delta_msr_wait);
2016 priv->prev_status = status; 2018 priv->prev_status = status;
2017 } 2019 }
2018 2020
2019 flag = TTY_NORMAL; 2021 flag = TTY_NORMAL;
2020 if (packet[1] & FTDI_RS_ERR_MASK) { 2022 if (packet[1] & FTDI_RS_ERR_MASK) {
2021 /* Break takes precedence over parity, which takes precedence 2023 /* Break takes precedence over parity, which takes precedence
2022 * over framing errors */ 2024 * over framing errors */
2023 if (packet[1] & FTDI_RS_BI) { 2025 if (packet[1] & FTDI_RS_BI) {
2024 flag = TTY_BREAK; 2026 flag = TTY_BREAK;
2025 port->icount.brk++; 2027 port->icount.brk++;
2026 usb_serial_handle_break(port); 2028 usb_serial_handle_break(port);
2027 } else if (packet[1] & FTDI_RS_PE) { 2029 } else if (packet[1] & FTDI_RS_PE) {
2028 flag = TTY_PARITY; 2030 flag = TTY_PARITY;
2029 port->icount.parity++; 2031 port->icount.parity++;
2030 } else if (packet[1] & FTDI_RS_FE) { 2032 } else if (packet[1] & FTDI_RS_FE) {
2031 flag = TTY_FRAME; 2033 flag = TTY_FRAME;
2032 port->icount.frame++; 2034 port->icount.frame++;
2033 } 2035 }
2034 /* Overrun is special, not associated with a char */ 2036 /* Overrun is special, not associated with a char */
2035 if (packet[1] & FTDI_RS_OE) { 2037 if (packet[1] & FTDI_RS_OE) {
2036 port->icount.overrun++; 2038 port->icount.overrun++;
2037 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 2039 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
2038 } 2040 }
2039 } 2041 }
2040 2042
2041 /* save if the transmitter is empty or not */ 2043 /* save if the transmitter is empty or not */
2042 if (packet[1] & FTDI_RS_TEMT) 2044 if (packet[1] & FTDI_RS_TEMT)
2043 priv->transmit_empty = 1; 2045 priv->transmit_empty = 1;
2044 else 2046 else
2045 priv->transmit_empty = 0; 2047 priv->transmit_empty = 0;
2046 2048
2047 len -= 2; 2049 len -= 2;
2048 if (!len) 2050 if (!len)
2049 return 0; /* status only */ 2051 return 0; /* status only */
2050 port->icount.rx += len; 2052 port->icount.rx += len;
2051 ch = packet + 2; 2053 ch = packet + 2;
2052 2054
2053 if (port->port.console && port->sysrq) { 2055 if (port->port.console && port->sysrq) {
2054 for (i = 0; i < len; i++, ch++) { 2056 for (i = 0; i < len; i++, ch++) {
2055 if (!usb_serial_handle_sysrq_char(port, *ch)) 2057 if (!usb_serial_handle_sysrq_char(port, *ch))
2056 tty_insert_flip_char(&port->port, *ch, flag); 2058 tty_insert_flip_char(&port->port, *ch, flag);
2057 } 2059 }
2058 } else { 2060 } else {
2059 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); 2061 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
2060 } 2062 }
2061 2063
2062 return len; 2064 return len;
2063 } 2065 }
2064 2066
2065 static void ftdi_process_read_urb(struct urb *urb) 2067 static void ftdi_process_read_urb(struct urb *urb)
2066 { 2068 {
2067 struct usb_serial_port *port = urb->context; 2069 struct usb_serial_port *port = urb->context;
2068 struct ftdi_private *priv = usb_get_serial_port_data(port); 2070 struct ftdi_private *priv = usb_get_serial_port_data(port);
2069 char *data = (char *)urb->transfer_buffer; 2071 char *data = (char *)urb->transfer_buffer;
2070 int i; 2072 int i;
2071 int len; 2073 int len;
2072 int count = 0; 2074 int count = 0;
2073 2075
2074 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { 2076 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) {
2075 len = min_t(int, urb->actual_length - i, priv->max_packet_size); 2077 len = min_t(int, urb->actual_length - i, priv->max_packet_size);
2076 count += ftdi_process_packet(port, priv, &data[i], len); 2078 count += ftdi_process_packet(port, priv, &data[i], len);
2077 } 2079 }
2078 2080
2079 if (count) 2081 if (count)
2080 tty_flip_buffer_push(&port->port); 2082 tty_flip_buffer_push(&port->port);
2081 } 2083 }
2082 2084
2083 static void ftdi_break_ctl(struct tty_struct *tty, int break_state) 2085 static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2084 { 2086 {
2085 struct usb_serial_port *port = tty->driver_data; 2087 struct usb_serial_port *port = tty->driver_data;
2086 struct ftdi_private *priv = usb_get_serial_port_data(port); 2088 struct ftdi_private *priv = usb_get_serial_port_data(port);
2087 __u16 urb_value; 2089 __u16 urb_value;
2088 2090
2089 /* break_state = -1 to turn on break, and 0 to turn off break */ 2091 /* break_state = -1 to turn on break, and 0 to turn off break */
2090 /* see drivers/char/tty_io.c to see it used */ 2092 /* see drivers/char/tty_io.c to see it used */
2091 /* last_set_data_urb_value NEVER has the break bit set in it */ 2093 /* last_set_data_urb_value NEVER has the break bit set in it */
2092 2094
2093 if (break_state) 2095 if (break_state)
2094 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK; 2096 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
2095 else 2097 else
2096 urb_value = priv->last_set_data_urb_value; 2098 urb_value = priv->last_set_data_urb_value;
2097 2099
2098 if (usb_control_msg(port->serial->dev, 2100 if (usb_control_msg(port->serial->dev,
2099 usb_sndctrlpipe(port->serial->dev, 0), 2101 usb_sndctrlpipe(port->serial->dev, 0),
2100 FTDI_SIO_SET_DATA_REQUEST, 2102 FTDI_SIO_SET_DATA_REQUEST,
2101 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2103 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2102 urb_value , priv->interface, 2104 urb_value , priv->interface,
2103 NULL, 0, WDR_TIMEOUT) < 0) { 2105 NULL, 0, WDR_TIMEOUT) < 0) {
2104 dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n", 2106 dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n",
2105 __func__, break_state); 2107 __func__, break_state);
2106 } 2108 }
2107 2109
2108 dev_dbg(&port->dev, "%s break state is %d - urb is %d\n", __func__, 2110 dev_dbg(&port->dev, "%s break state is %d - urb is %d\n", __func__,
2109 break_state, urb_value); 2111 break_state, urb_value);
2110 2112
2111 } 2113 }
2112 2114
2113 static bool ftdi_tx_empty(struct usb_serial_port *port) 2115 static bool ftdi_tx_empty(struct usb_serial_port *port)
2114 { 2116 {
2115 unsigned char buf[2]; 2117 unsigned char buf[2];
2116 int ret; 2118 int ret;
2117 2119
2118 ret = ftdi_get_modem_status(port, buf); 2120 ret = ftdi_get_modem_status(port, buf);
2119 if (ret == 2) { 2121 if (ret == 2) {
2120 if (!(buf[1] & FTDI_RS_TEMT)) 2122 if (!(buf[1] & FTDI_RS_TEMT))
2121 return false; 2123 return false;
2122 } 2124 }
2123 2125
2124 return true; 2126 return true;
2125 } 2127 }
2126 2128
2127 /* old_termios contains the original termios settings and tty->termios contains 2129 /* old_termios contains the original termios settings and tty->termios contains
2128 * the new setting to be used 2130 * the new setting to be used
2129 * WARNING: set_termios calls this with old_termios in kernel space 2131 * WARNING: set_termios calls this with old_termios in kernel space
2130 */ 2132 */
2131 static void ftdi_set_termios(struct tty_struct *tty, 2133 static void ftdi_set_termios(struct tty_struct *tty,
2132 struct usb_serial_port *port, struct ktermios *old_termios) 2134 struct usb_serial_port *port, struct ktermios *old_termios)
2133 { 2135 {
2134 struct usb_device *dev = port->serial->dev; 2136 struct usb_device *dev = port->serial->dev;
2135 struct device *ddev = &port->dev; 2137 struct device *ddev = &port->dev;
2136 struct ftdi_private *priv = usb_get_serial_port_data(port); 2138 struct ftdi_private *priv = usb_get_serial_port_data(port);
2137 struct ktermios *termios = &tty->termios; 2139 struct ktermios *termios = &tty->termios;
2138 unsigned int cflag = termios->c_cflag; 2140 unsigned int cflag = termios->c_cflag;
2139 __u16 urb_value; /* will hold the new flags */ 2141 __u16 urb_value; /* will hold the new flags */
2140 2142
2141 /* Added for xon/xoff support */ 2143 /* Added for xon/xoff support */
2142 unsigned int iflag = termios->c_iflag; 2144 unsigned int iflag = termios->c_iflag;
2143 unsigned char vstop; 2145 unsigned char vstop;
2144 unsigned char vstart; 2146 unsigned char vstart;
2145 2147
2146 /* Force baud rate if this device requires it, unless it is set to 2148 /* Force baud rate if this device requires it, unless it is set to
2147 B0. */ 2149 B0. */
2148 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { 2150 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
2149 dev_dbg(ddev, "%s: forcing baud rate for this device\n", __func__); 2151 dev_dbg(ddev, "%s: forcing baud rate for this device\n", __func__);
2150 tty_encode_baud_rate(tty, priv->force_baud, 2152 tty_encode_baud_rate(tty, priv->force_baud,
2151 priv->force_baud); 2153 priv->force_baud);
2152 } 2154 }
2153 2155
2154 /* Force RTS-CTS if this device requires it. */ 2156 /* Force RTS-CTS if this device requires it. */
2155 if (priv->force_rtscts) { 2157 if (priv->force_rtscts) {
2156 dev_dbg(ddev, "%s: forcing rtscts for this device\n", __func__); 2158 dev_dbg(ddev, "%s: forcing rtscts for this device\n", __func__);
2157 termios->c_cflag |= CRTSCTS; 2159 termios->c_cflag |= CRTSCTS;
2158 } 2160 }
2159 2161
2160 /* 2162 /*
2161 * All FTDI UART chips are limited to CS7/8. We shouldn't pretend to 2163 * All FTDI UART chips are limited to CS7/8. We shouldn't pretend to
2162 * support CS5/6 and revert the CSIZE setting instead. 2164 * support CS5/6 and revert the CSIZE setting instead.
2163 * 2165 *
2164 * CS5 however is used to control some smartcard readers which abuse 2166 * CS5 however is used to control some smartcard readers which abuse
2165 * this limitation to switch modes. Original FTDI chips fall back to 2167 * this limitation to switch modes. Original FTDI chips fall back to
2166 * eight data bits. 2168 * eight data bits.
2167 * 2169 *
2168 * TODO: Implement a quirk to only allow this with mentioned 2170 * TODO: Implement a quirk to only allow this with mentioned
2169 * readers. One I know of (Argolis Smartreader V1) 2171 * readers. One I know of (Argolis Smartreader V1)
2170 * returns "USB smartcard server" as iInterface string. 2172 * returns "USB smartcard server" as iInterface string.
2171 * The vendor didn't bother with a custom VID/PID of 2173 * The vendor didn't bother with a custom VID/PID of
2172 * course. 2174 * course.
2173 */ 2175 */
2174 if (C_CSIZE(tty) == CS6) { 2176 if (C_CSIZE(tty) == CS6) {
2175 dev_warn(ddev, "requested CSIZE setting not supported\n"); 2177 dev_warn(ddev, "requested CSIZE setting not supported\n");
2176 2178
2177 termios->c_cflag &= ~CSIZE; 2179 termios->c_cflag &= ~CSIZE;
2178 if (old_termios) 2180 if (old_termios)
2179 termios->c_cflag |= old_termios->c_cflag & CSIZE; 2181 termios->c_cflag |= old_termios->c_cflag & CSIZE;
2180 else 2182 else
2181 termios->c_cflag |= CS8; 2183 termios->c_cflag |= CS8;
2182 } 2184 }
2183 2185
2184 cflag = termios->c_cflag; 2186 cflag = termios->c_cflag;
2185 2187
2186 if (!old_termios) 2188 if (!old_termios)
2187 goto no_skip; 2189 goto no_skip;
2188 2190
2189 if (old_termios->c_cflag == termios->c_cflag 2191 if (old_termios->c_cflag == termios->c_cflag
2190 && old_termios->c_ispeed == termios->c_ispeed 2192 && old_termios->c_ispeed == termios->c_ispeed
2191 && old_termios->c_ospeed == termios->c_ospeed) 2193 && old_termios->c_ospeed == termios->c_ospeed)
2192 goto no_c_cflag_changes; 2194 goto no_c_cflag_changes;
2193 2195
2194 /* NOTE These routines can get interrupted by 2196 /* NOTE These routines can get interrupted by
2195 ftdi_sio_read_bulk_callback - need to examine what this means - 2197 ftdi_sio_read_bulk_callback - need to examine what this means -
2196 don't see any problems yet */ 2198 don't see any problems yet */
2197 2199
2198 if ((old_termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)) == 2200 if ((old_termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)) ==
2199 (termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB))) 2201 (termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)))
2200 goto no_data_parity_stop_changes; 2202 goto no_data_parity_stop_changes;
2201 2203
2202 no_skip: 2204 no_skip:
2203 /* Set number of data bits, parity, stop bits */ 2205 /* Set number of data bits, parity, stop bits */
2204 2206
2205 urb_value = 0; 2207 urb_value = 0;
2206 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : 2208 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 :
2207 FTDI_SIO_SET_DATA_STOP_BITS_1); 2209 FTDI_SIO_SET_DATA_STOP_BITS_1);
2208 if (cflag & PARENB) { 2210 if (cflag & PARENB) {
2209 if (cflag & CMSPAR) 2211 if (cflag & CMSPAR)
2210 urb_value |= cflag & PARODD ? 2212 urb_value |= cflag & PARODD ?
2211 FTDI_SIO_SET_DATA_PARITY_MARK : 2213 FTDI_SIO_SET_DATA_PARITY_MARK :
2212 FTDI_SIO_SET_DATA_PARITY_SPACE; 2214 FTDI_SIO_SET_DATA_PARITY_SPACE;
2213 else 2215 else
2214 urb_value |= cflag & PARODD ? 2216 urb_value |= cflag & PARODD ?
2215 FTDI_SIO_SET_DATA_PARITY_ODD : 2217 FTDI_SIO_SET_DATA_PARITY_ODD :
2216 FTDI_SIO_SET_DATA_PARITY_EVEN; 2218 FTDI_SIO_SET_DATA_PARITY_EVEN;
2217 } else { 2219 } else {
2218 urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE; 2220 urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE;
2219 } 2221 }
2220 switch (cflag & CSIZE) { 2222 switch (cflag & CSIZE) {
2221 case CS5: 2223 case CS5:
2222 dev_dbg(ddev, "Setting CS5 quirk\n"); 2224 dev_dbg(ddev, "Setting CS5 quirk\n");
2223 break; 2225 break;
2224 case CS7: 2226 case CS7:
2225 urb_value |= 7; 2227 urb_value |= 7;
2226 dev_dbg(ddev, "Setting CS7\n"); 2228 dev_dbg(ddev, "Setting CS7\n");
2227 break; 2229 break;
2228 default: 2230 default:
2229 case CS8: 2231 case CS8:
2230 urb_value |= 8; 2232 urb_value |= 8;
2231 dev_dbg(ddev, "Setting CS8\n"); 2233 dev_dbg(ddev, "Setting CS8\n");
2232 break; 2234 break;
2233 } 2235 }
2234 2236
2235 /* This is needed by the break command since it uses the same command 2237 /* This is needed by the break command since it uses the same command
2236 - but is or'ed with this value */ 2238 - but is or'ed with this value */
2237 priv->last_set_data_urb_value = urb_value; 2239 priv->last_set_data_urb_value = urb_value;
2238 2240
2239 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2241 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
2240 FTDI_SIO_SET_DATA_REQUEST, 2242 FTDI_SIO_SET_DATA_REQUEST,
2241 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2243 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2242 urb_value , priv->interface, 2244 urb_value , priv->interface,
2243 NULL, 0, WDR_SHORT_TIMEOUT) < 0) { 2245 NULL, 0, WDR_SHORT_TIMEOUT) < 0) {
2244 dev_err(ddev, "%s FAILED to set databits/stopbits/parity\n", 2246 dev_err(ddev, "%s FAILED to set databits/stopbits/parity\n",
2245 __func__); 2247 __func__);
2246 } 2248 }
2247 2249
2248 /* Now do the baudrate */ 2250 /* Now do the baudrate */
2249 no_data_parity_stop_changes: 2251 no_data_parity_stop_changes:
2250 if ((cflag & CBAUD) == B0) { 2252 if ((cflag & CBAUD) == B0) {
2251 /* Disable flow control */ 2253 /* Disable flow control */
2252 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2254 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
2253 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2255 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2254 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2256 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2255 0, priv->interface, 2257 0, priv->interface,
2256 NULL, 0, WDR_TIMEOUT) < 0) { 2258 NULL, 0, WDR_TIMEOUT) < 0) {
2257 dev_err(ddev, "%s error from disable flowcontrol urb\n", 2259 dev_err(ddev, "%s error from disable flowcontrol urb\n",
2258 __func__); 2260 __func__);
2259 } 2261 }
2260 /* Drop RTS and DTR */ 2262 /* Drop RTS and DTR */
2261 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2263 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2262 } else { 2264 } else {
2263 /* set the baudrate determined before */ 2265 /* set the baudrate determined before */
2264 mutex_lock(&priv->cfg_lock); 2266 mutex_lock(&priv->cfg_lock);
2265 if (change_speed(tty, port)) 2267 if (change_speed(tty, port))
2266 dev_err(ddev, "%s urb failed to set baudrate\n", __func__); 2268 dev_err(ddev, "%s urb failed to set baudrate\n", __func__);
2267 mutex_unlock(&priv->cfg_lock); 2269 mutex_unlock(&priv->cfg_lock);
2268 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2270 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
2269 if (old_termios && (old_termios->c_cflag & CBAUD) == B0) 2271 if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
2270 set_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2272 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2271 } 2273 }
2272 2274
2273 /* Set flow control */ 2275 /* Set flow control */
2274 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ 2276 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
2275 no_c_cflag_changes: 2277 no_c_cflag_changes:
2276 if (cflag & CRTSCTS) { 2278 if (cflag & CRTSCTS) {
2277 dev_dbg(ddev, "%s Setting to CRTSCTS flow control\n", __func__); 2279 dev_dbg(ddev, "%s Setting to CRTSCTS flow control\n", __func__);
2278 if (usb_control_msg(dev, 2280 if (usb_control_msg(dev,
2279 usb_sndctrlpipe(dev, 0), 2281 usb_sndctrlpipe(dev, 0),
2280 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2282 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2281 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2283 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2282 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 2284 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
2283 NULL, 0, WDR_TIMEOUT) < 0) { 2285 NULL, 0, WDR_TIMEOUT) < 0) {
2284 dev_err(ddev, "urb failed to set to rts/cts flow control\n"); 2286 dev_err(ddev, "urb failed to set to rts/cts flow control\n");
2285 } 2287 }
2286 } else { 2288 } else {
2287 /* 2289 /*
2288 * Xon/Xoff code 2290 * Xon/Xoff code
2289 * 2291 *
2290 * Check the IXOFF status in the iflag component of the 2292 * Check the IXOFF status in the iflag component of the
2291 * termios structure. If IXOFF is not set, the pre-xon/xoff 2293 * termios structure. If IXOFF is not set, the pre-xon/xoff
2292 * code is executed. 2294 * code is executed.
2293 */ 2295 */
2294 if (iflag & IXOFF) { 2296 if (iflag & IXOFF) {
2295 dev_dbg(ddev, "%s request to enable xonxoff iflag=%04x\n", 2297 dev_dbg(ddev, "%s request to enable xonxoff iflag=%04x\n",
2296 __func__, iflag); 2298 __func__, iflag);
2297 /* Try to enable the XON/XOFF on the ftdi_sio 2299 /* Try to enable the XON/XOFF on the ftdi_sio
2298 * Set the vstart and vstop -- could have been done up 2300 * Set the vstart and vstop -- could have been done up
2299 * above where a lot of other dereferencing is done but 2301 * above where a lot of other dereferencing is done but
2300 * that would be very inefficient as vstart and vstop 2302 * that would be very inefficient as vstart and vstop
2301 * are not always needed. 2303 * are not always needed.
2302 */ 2304 */
2303 vstart = termios->c_cc[VSTART]; 2305 vstart = termios->c_cc[VSTART];
2304 vstop = termios->c_cc[VSTOP]; 2306 vstop = termios->c_cc[VSTOP];
2305 urb_value = (vstop << 8) | (vstart); 2307 urb_value = (vstop << 8) | (vstart);
2306 2308
2307 if (usb_control_msg(dev, 2309 if (usb_control_msg(dev,
2308 usb_sndctrlpipe(dev, 0), 2310 usb_sndctrlpipe(dev, 0),
2309 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2311 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2310 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2312 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2311 urb_value , (FTDI_SIO_XON_XOFF_HS 2313 urb_value , (FTDI_SIO_XON_XOFF_HS
2312 | priv->interface), 2314 | priv->interface),
2313 NULL, 0, WDR_TIMEOUT) < 0) { 2315 NULL, 0, WDR_TIMEOUT) < 0) {
2314 dev_err(&port->dev, "urb failed to set to " 2316 dev_err(&port->dev, "urb failed to set to "
2315 "xon/xoff flow control\n"); 2317 "xon/xoff flow control\n");
2316 } 2318 }
2317 } else { 2319 } else {
2318 /* else clause to only run if cflag ! CRTSCTS and iflag 2320 /* else clause to only run if cflag ! CRTSCTS and iflag
2319 * ! XOFF. CHECKME Assuming XON/XOFF handled by tty 2321 * ! XOFF. CHECKME Assuming XON/XOFF handled by tty
2320 * stack - not by device */ 2322 * stack - not by device */
2321 dev_dbg(ddev, "%s Turning off hardware flow control\n", __func__); 2323 dev_dbg(ddev, "%s Turning off hardware flow control\n", __func__);
2322 if (usb_control_msg(dev, 2324 if (usb_control_msg(dev,
2323 usb_sndctrlpipe(dev, 0), 2325 usb_sndctrlpipe(dev, 0),
2324 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2326 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2325 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2327 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2326 0, priv->interface, 2328 0, priv->interface,
2327 NULL, 0, WDR_TIMEOUT) < 0) { 2329 NULL, 0, WDR_TIMEOUT) < 0) {
2328 dev_err(ddev, "urb failed to clear flow control\n"); 2330 dev_err(ddev, "urb failed to clear flow control\n");
2329 } 2331 }
2330 } 2332 }
2331 } 2333 }
2332 } 2334 }
2333 2335
2334 /* 2336 /*
2335 * Get modem-control status. 2337 * Get modem-control status.
2336 * 2338 *
2337 * Returns the number of status bytes retrieved (device dependant), or 2339 * Returns the number of status bytes retrieved (device dependant), or
2338 * negative error code. 2340 * negative error code.
2339 */ 2341 */
2340 static int ftdi_get_modem_status(struct usb_serial_port *port, 2342 static int ftdi_get_modem_status(struct usb_serial_port *port,
2341 unsigned char status[2]) 2343 unsigned char status[2])
2342 { 2344 {
2343 struct ftdi_private *priv = usb_get_serial_port_data(port); 2345 struct ftdi_private *priv = usb_get_serial_port_data(port);
2344 unsigned char *buf; 2346 unsigned char *buf;
2345 int len; 2347 int len;
2346 int ret; 2348 int ret;
2347 2349
2348 buf = kmalloc(2, GFP_KERNEL); 2350 buf = kmalloc(2, GFP_KERNEL);
2349 if (!buf) 2351 if (!buf)
2350 return -ENOMEM; 2352 return -ENOMEM;
2351 /* 2353 /*
2352 * The 8U232AM returns a two byte value (the SIO a 1 byte value) in 2354 * The 8U232AM returns a two byte value (the SIO a 1 byte value) in
2353 * the same format as the data returned from the in point. 2355 * the same format as the data returned from the in point.
2354 */ 2356 */
2355 switch (priv->chip_type) { 2357 switch (priv->chip_type) {
2356 case SIO: 2358 case SIO:
2357 len = 1; 2359 len = 1;
2358 break; 2360 break;
2359 case FT8U232AM: 2361 case FT8U232AM:
2360 case FT232BM: 2362 case FT232BM:
2361 case FT2232C: 2363 case FT2232C:
2362 case FT232RL: 2364 case FT232RL:
2363 case FT2232H: 2365 case FT2232H:
2364 case FT4232H: 2366 case FT4232H:
2365 case FT232H: 2367 case FT232H:
2366 case FTX: 2368 case FTX:
2367 len = 2; 2369 len = 2;
2368 break; 2370 break;
2369 default: 2371 default:
2370 ret = -EFAULT; 2372 ret = -EFAULT;
2371 goto out; 2373 goto out;
2372 } 2374 }
2373 2375
2374 ret = usb_control_msg(port->serial->dev, 2376 ret = usb_control_msg(port->serial->dev,
2375 usb_rcvctrlpipe(port->serial->dev, 0), 2377 usb_rcvctrlpipe(port->serial->dev, 0),
2376 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2378 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2377 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2379 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2378 0, priv->interface, 2380 0, priv->interface,
2379 buf, len, WDR_TIMEOUT); 2381 buf, len, WDR_TIMEOUT);
2380 if (ret < 0) { 2382 if (ret < 0) {
2381 dev_err(&port->dev, "failed to get modem status: %d\n", ret); 2383 dev_err(&port->dev, "failed to get modem status: %d\n", ret);
2382 ret = usb_translate_errors(ret); 2384 ret = usb_translate_errors(ret);
2383 goto out; 2385 goto out;
2384 } 2386 }
2385 2387
2386 status[0] = buf[0]; 2388 status[0] = buf[0];
2387 if (ret > 1) 2389 if (ret > 1)
2388 status[1] = buf[1]; 2390 status[1] = buf[1];
2389 else 2391 else
2390 status[1] = 0; 2392 status[1] = 0;
2391 2393
2392 dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0], 2394 dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0],
2393 status[1]); 2395 status[1]);
2394 out: 2396 out:
2395 kfree(buf); 2397 kfree(buf);
2396 2398
2397 return ret; 2399 return ret;
2398 } 2400 }
2399 2401
2400 static int ftdi_tiocmget(struct tty_struct *tty) 2402 static int ftdi_tiocmget(struct tty_struct *tty)
2401 { 2403 {
2402 struct usb_serial_port *port = tty->driver_data; 2404 struct usb_serial_port *port = tty->driver_data;
2403 struct ftdi_private *priv = usb_get_serial_port_data(port); 2405 struct ftdi_private *priv = usb_get_serial_port_data(port);
2404 unsigned char buf[2]; 2406 unsigned char buf[2];
2405 int ret; 2407 int ret;
2406 2408
2407 ret = ftdi_get_modem_status(port, buf); 2409 ret = ftdi_get_modem_status(port, buf);
2408 if (ret < 0) 2410 if (ret < 0)
2409 return ret; 2411 return ret;
2410 2412
2411 ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2413 ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
2412 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2414 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2413 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2415 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
2414 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2416 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
2415 priv->last_dtr_rts; 2417 priv->last_dtr_rts;
2416 2418
2417 return ret; 2419 return ret;
2418 } 2420 }
2419 2421
2420 static int ftdi_tiocmset(struct tty_struct *tty, 2422 static int ftdi_tiocmset(struct tty_struct *tty,
2421 unsigned int set, unsigned int clear) 2423 unsigned int set, unsigned int clear)
2422 { 2424 {
2423 struct usb_serial_port *port = tty->driver_data; 2425 struct usb_serial_port *port = tty->driver_data;
2424 2426
2425 return update_mctrl(port, set, clear); 2427 return update_mctrl(port, set, clear);
2426 } 2428 }
2427 2429
2428 static int ftdi_ioctl(struct tty_struct *tty, 2430 static int ftdi_ioctl(struct tty_struct *tty,
2429 unsigned int cmd, unsigned long arg) 2431 unsigned int cmd, unsigned long arg)
2430 { 2432 {
2431 struct usb_serial_port *port = tty->driver_data; 2433 struct usb_serial_port *port = tty->driver_data;
2432 2434
2433 /* Based on code from acm.c and others */ 2435 /* Based on code from acm.c and others */
2434 switch (cmd) { 2436 switch (cmd) {
2435 2437
2436 case TIOCGSERIAL: /* gets serial port data */ 2438 case TIOCGSERIAL: /* gets serial port data */
2437 return get_serial_info(port, 2439 return get_serial_info(port,
2438 (struct serial_struct __user *) arg); 2440 (struct serial_struct __user *) arg);
2439 2441
2440 case TIOCSSERIAL: /* sets serial port data */ 2442 case TIOCSSERIAL: /* sets serial port data */
2441 return set_serial_info(tty, port, 2443 return set_serial_info(tty, port,
2442 (struct serial_struct __user *) arg); 2444 (struct serial_struct __user *) arg);
2443 case TIOCSERGETLSR: 2445 case TIOCSERGETLSR:
2444 return get_lsr_info(port, (struct serial_struct __user *)arg); 2446 return get_lsr_info(port, (struct serial_struct __user *)arg);
2445 break; 2447 break;
2446 default: 2448 default:
2447 break; 2449 break;
2448 } 2450 }
2449 2451
2450 return -ENOIOCTLCMD; 2452 return -ENOIOCTLCMD;
2451 } 2453 }
2452 2454
2453 module_usb_serial_driver(serial_drivers, id_table_combined); 2455 module_usb_serial_driver(serial_drivers, id_table_combined);
2454 2456
2455 MODULE_AUTHOR(DRIVER_AUTHOR); 2457 MODULE_AUTHOR(DRIVER_AUTHOR);
2456 MODULE_DESCRIPTION(DRIVER_DESC); 2458 MODULE_DESCRIPTION(DRIVER_DESC);
2457 MODULE_LICENSE("GPL"); 2459 MODULE_LICENSE("GPL");
2458 2460
2459 module_param(ndi_latency_timer, int, S_IRUGO | S_IWUSR); 2461 module_param(ndi_latency_timer, int, S_IRUGO | S_IWUSR);
2460 MODULE_PARM_DESC(ndi_latency_timer, "NDI device latency timer override"); 2462 MODULE_PARM_DESC(ndi_latency_timer, "NDI device latency timer override");
2461 2463
drivers/usb/serial/ftdi_sio_ids.h
1 /* 1 /*
2 * vendor/product IDs (VID/PID) of devices using FTDI USB serial converters. 2 * vendor/product IDs (VID/PID) of devices using FTDI USB serial converters.
3 * Please keep numerically sorted within individual areas, thanks! 3 * Please keep numerically sorted within individual areas, thanks!
4 * 4 *
5 * Philipp Gรผhring - pg@futureware.at - added the Device ID of the USB relais 5 * Philipp Gรผhring - pg@futureware.at - added the Device ID of the USB relais
6 * from Rudolf Gugler 6 * from Rudolf Gugler
7 * 7 *
8 */ 8 */
9 9
10 10
11 /**********************************/ 11 /**********************************/
12 /***** devices using FTDI VID *****/ 12 /***** devices using FTDI VID *****/
13 /**********************************/ 13 /**********************************/
14 14
15 15
16 #define FTDI_VID 0x0403 /* Vendor Id */ 16 #define FTDI_VID 0x0403 /* Vendor Id */
17 17
18 18
19 /*** "original" FTDI device PIDs ***/ 19 /*** "original" FTDI device PIDs ***/
20 20
21 #define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */ 21 #define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
22 #define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ 22 #define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
23 #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ 23 #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
24 #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ 24 #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
25 #define FTDI_232H_PID 0x6014 /* Single channel hi-speed device */ 25 #define FTDI_232H_PID 0x6014 /* Single channel hi-speed device */
26 #define FTDI_FTX_PID 0x6015 /* FT-X series (FT201X, FT230X, FT231X, etc) */ 26 #define FTDI_FTX_PID 0x6015 /* FT-X series (FT201X, FT230X, FT231X, etc) */
27 #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ 27 #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
28 #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ 28 #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */
29 29
30 30
31 /*** third-party PIDs (using FTDI_VID) ***/ 31 /*** third-party PIDs (using FTDI_VID) ***/
32 32
33 #define FTDI_LUMEL_PD12_PID 0x6002 33 #define FTDI_LUMEL_PD12_PID 0x6002
34 34
35 /* 35 /*
36 * Marvell OpenRD Base, Client 36 * Marvell OpenRD Base, Client
37 * http://www.open-rd.org 37 * http://www.open-rd.org
38 * OpenRD Base, Client use VID 0x0403 38 * OpenRD Base, Client use VID 0x0403
39 */ 39 */
40 #define MARVELL_OPENRD_PID 0x9e90 40 #define MARVELL_OPENRD_PID 0x9e90
41 41
42 /* www.candapter.com Ewert Energy Systems CANdapter device */ 42 /* www.candapter.com Ewert Energy Systems CANdapter device */
43 #define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */ 43 #define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
44 44
45 /* 45 /*
46 * Texas Instruments XDS100v2 JTAG / BeagleBone A3 46 * Texas Instruments XDS100v2 JTAG / BeagleBone A3
47 * http://processors.wiki.ti.com/index.php/XDS100 47 * http://processors.wiki.ti.com/index.php/XDS100
48 * http://beagleboard.org/bone 48 * http://beagleboard.org/bone
49 */ 49 */
50 #define TI_XDS100V2_PID 0xa6d0 50 #define TI_XDS100V2_PID 0xa6d0
51 51
52 #define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */ 52 #define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */
53 #define FTDI_EV3CON_PID 0xABB9 /* Mindstorms EV3 Console Adapter */ 53 #define FTDI_EV3CON_PID 0xABB9 /* Mindstorms EV3 Console Adapter */
54 54
55 /* US Interface Navigator (http://www.usinterface.com/) */ 55 /* US Interface Navigator (http://www.usinterface.com/) */
56 #define FTDI_USINT_CAT_PID 0xb810 /* Navigator CAT and 2nd PTT lines */ 56 #define FTDI_USINT_CAT_PID 0xb810 /* Navigator CAT and 2nd PTT lines */
57 #define FTDI_USINT_WKEY_PID 0xb811 /* Navigator WKEY and FSK lines */ 57 #define FTDI_USINT_WKEY_PID 0xb811 /* Navigator WKEY and FSK lines */
58 #define FTDI_USINT_RS232_PID 0xb812 /* Navigator RS232 and CONFIG lines */ 58 #define FTDI_USINT_RS232_PID 0xb812 /* Navigator RS232 and CONFIG lines */
59 59
60 /* OOCDlink by Joern Kaipf <joernk@web.de> 60 /* OOCDlink by Joern Kaipf <joernk@web.de>
61 * (http://www.joernonline.de/) */ 61 * (http://www.joernonline.de/) */
62 #define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */ 62 #define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */
63 63
64 /* Luminary Micro Stellaris Boards, VID = FTDI_VID */ 64 /* Luminary Micro Stellaris Boards, VID = FTDI_VID */
65 /* FTDI 2332C Dual channel device, side A=245 FIFO (JTAG), Side B=RS232 UART */ 65 /* FTDI 2332C Dual channel device, side A=245 FIFO (JTAG), Side B=RS232 UART */
66 #define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8 66 #define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8
67 #define LMI_LM3S_EVAL_BOARD_PID 0xbcd9 67 #define LMI_LM3S_EVAL_BOARD_PID 0xbcd9
68 #define LMI_LM3S_ICDI_BOARD_PID 0xbcda 68 #define LMI_LM3S_ICDI_BOARD_PID 0xbcda
69 69
70 #define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmbH */ 70 #define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmbH */
71 71
72 /* OpenDCC (www.opendcc.de) product id */ 72 /* OpenDCC (www.opendcc.de) product id */
73 #define FTDI_OPENDCC_PID 0xBFD8 73 #define FTDI_OPENDCC_PID 0xBFD8
74 #define FTDI_OPENDCC_SNIFFER_PID 0xBFD9 74 #define FTDI_OPENDCC_SNIFFER_PID 0xBFD9
75 #define FTDI_OPENDCC_THROTTLE_PID 0xBFDA 75 #define FTDI_OPENDCC_THROTTLE_PID 0xBFDA
76 #define FTDI_OPENDCC_GATEWAY_PID 0xBFDB 76 #define FTDI_OPENDCC_GATEWAY_PID 0xBFDB
77 #define FTDI_OPENDCC_GBM_PID 0xBFDC 77 #define FTDI_OPENDCC_GBM_PID 0xBFDC
78 #define FTDI_OPENDCC_GBM_BOOST_PID 0xBFDD 78 #define FTDI_OPENDCC_GBM_BOOST_PID 0xBFDD
79 79
80 /* NZR SEM 16+ USB (http://www.nzr.de) */ 80 /* NZR SEM 16+ USB (http://www.nzr.de) */
81 #define FTDI_NZR_SEM_USB_PID 0xC1E0 /* NZR SEM-LOG16+ */ 81 #define FTDI_NZR_SEM_USB_PID 0xC1E0 /* NZR SEM-LOG16+ */
82 82
83 /* 83 /*
84 * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com) 84 * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
85 */ 85 */
86 #define FTDI_RRCIRKITS_LOCOBUFFER_PID 0xc7d0 /* LocoBuffer USB */ 86 #define FTDI_RRCIRKITS_LOCOBUFFER_PID 0xc7d0 /* LocoBuffer USB */
87 87
88 /* DMX4ALL DMX Interfaces */ 88 /* DMX4ALL DMX Interfaces */
89 #define FTDI_DMX4ALL 0xC850 89 #define FTDI_DMX4ALL 0xC850
90 90
91 /* 91 /*
92 * ASK.fr devices 92 * ASK.fr devices
93 */ 93 */
94 #define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ 94 #define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */
95 95
96 /* www.starting-point-systems.com ยตChameleon device */ 96 /* www.starting-point-systems.com ยตChameleon device */
97 #define FTDI_MICRO_CHAMELEON_PID 0xCAA0 /* Product Id */ 97 #define FTDI_MICRO_CHAMELEON_PID 0xCAA0 /* Product Id */
98 98
99 /* 99 /*
100 * Tactrix OpenPort (ECU) devices. 100 * Tactrix OpenPort (ECU) devices.
101 * OpenPort 1.3M submitted by Donour Sizemore. 101 * OpenPort 1.3M submitted by Donour Sizemore.
102 * OpenPort 1.3S and 1.3U submitted by Ian Abbott. 102 * OpenPort 1.3S and 1.3U submitted by Ian Abbott.
103 */ 103 */
104 #define FTDI_TACTRIX_OPENPORT_13M_PID 0xCC48 /* OpenPort 1.3 Mitsubishi */ 104 #define FTDI_TACTRIX_OPENPORT_13M_PID 0xCC48 /* OpenPort 1.3 Mitsubishi */
105 #define FTDI_TACTRIX_OPENPORT_13S_PID 0xCC49 /* OpenPort 1.3 Subaru */ 105 #define FTDI_TACTRIX_OPENPORT_13S_PID 0xCC49 /* OpenPort 1.3 Subaru */
106 #define FTDI_TACTRIX_OPENPORT_13U_PID 0xCC4A /* OpenPort 1.3 Universal */ 106 #define FTDI_TACTRIX_OPENPORT_13U_PID 0xCC4A /* OpenPort 1.3 Universal */
107 107
108 #define FTDI_DISTORTEC_JTAG_LOCK_PICK_PID 0xCFF8 108 #define FTDI_DISTORTEC_JTAG_LOCK_PICK_PID 0xCFF8
109 109
110 /* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */ 110 /* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */
111 /* the VID is the standard ftdi vid (FTDI_VID) */ 111 /* the VID is the standard ftdi vid (FTDI_VID) */
112 #define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */ 112 #define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */
113 #define FTDI_SCS_DEVICE_1_PID 0xD011 /* SCS Tracker / DSP TNC */ 113 #define FTDI_SCS_DEVICE_1_PID 0xD011 /* SCS Tracker / DSP TNC */
114 #define FTDI_SCS_DEVICE_2_PID 0xD012 114 #define FTDI_SCS_DEVICE_2_PID 0xD012
115 #define FTDI_SCS_DEVICE_3_PID 0xD013 115 #define FTDI_SCS_DEVICE_3_PID 0xD013
116 #define FTDI_SCS_DEVICE_4_PID 0xD014 116 #define FTDI_SCS_DEVICE_4_PID 0xD014
117 #define FTDI_SCS_DEVICE_5_PID 0xD015 117 #define FTDI_SCS_DEVICE_5_PID 0xD015
118 #define FTDI_SCS_DEVICE_6_PID 0xD016 118 #define FTDI_SCS_DEVICE_6_PID 0xD016
119 #define FTDI_SCS_DEVICE_7_PID 0xD017 119 #define FTDI_SCS_DEVICE_7_PID 0xD017
120 120
121 /* iPlus device */ 121 /* iPlus device */
122 #define FTDI_IPLUS_PID 0xD070 /* Product Id */ 122 #define FTDI_IPLUS_PID 0xD070 /* Product Id */
123 #define FTDI_IPLUS2_PID 0xD071 /* Product Id */ 123 #define FTDI_IPLUS2_PID 0xD071 /* Product Id */
124 124
125 /* 125 /*
126 * Gamma Scout (http://gamma-scout.com/). Submitted by rsc@runtux.com. 126 * Gamma Scout (http://gamma-scout.com/). Submitted by rsc@runtux.com.
127 */ 127 */
128 #define FTDI_GAMMA_SCOUT_PID 0xD678 /* Gamma Scout online */ 128 #define FTDI_GAMMA_SCOUT_PID 0xD678 /* Gamma Scout online */
129 129
130 /* Propox devices */ 130 /* Propox devices */
131 #define FTDI_PROPOX_JTAGCABLEII_PID 0xD738 131 #define FTDI_PROPOX_JTAGCABLEII_PID 0xD738
132 #define FTDI_PROPOX_ISPCABLEIII_PID 0xD739 132 #define FTDI_PROPOX_ISPCABLEIII_PID 0xD739
133 133
134 /* Lenz LI-USB Computer Interface. */ 134 /* Lenz LI-USB Computer Interface. */
135 #define FTDI_LENZ_LIUSB_PID 0xD780 135 #define FTDI_LENZ_LIUSB_PID 0xD780
136 136
137 /* Vardaan Enterprises Serial Interface VEUSB422R3 */ 137 /* Vardaan Enterprises Serial Interface VEUSB422R3 */
138 #define FTDI_VARDAAN_PID 0xF070 138 #define FTDI_VARDAAN_PID 0xF070
139 139
140 /* 140 /*
141 * Xsens Technologies BV products (http://www.xsens.com). 141 * Xsens Technologies BV products (http://www.xsens.com).
142 */ 142 */
143 #define XSENS_CONVERTER_0_PID 0xD388 143 #define XSENS_CONVERTER_0_PID 0xD388
144 #define XSENS_CONVERTER_1_PID 0xD389 144 #define XSENS_CONVERTER_1_PID 0xD389
145 #define XSENS_CONVERTER_2_PID 0xD38A 145 #define XSENS_CONVERTER_2_PID 0xD38A
146 #define XSENS_CONVERTER_3_PID 0xD38B 146 #define XSENS_CONVERTER_3_PID 0xD38B
147 #define XSENS_CONVERTER_4_PID 0xD38C 147 #define XSENS_CONVERTER_4_PID 0xD38C
148 #define XSENS_CONVERTER_5_PID 0xD38D 148 #define XSENS_CONVERTER_5_PID 0xD38D
149 #define XSENS_CONVERTER_6_PID 0xD38E 149 #define XSENS_CONVERTER_6_PID 0xD38E
150 #define XSENS_CONVERTER_7_PID 0xD38F 150 #define XSENS_CONVERTER_7_PID 0xD38F
151 151
152 /** 152 /**
153 * Zolix (www.zolix.com.cb) product ids 153 * Zolix (www.zolix.com.cb) product ids
154 */ 154 */
155 #define FTDI_OMNI1509 0xD491 /* Omni1509 embedded USB-serial */ 155 #define FTDI_OMNI1509 0xD491 /* Omni1509 embedded USB-serial */
156 156
157 /* 157 /*
158 * NDI (www.ndigital.com) product ids 158 * NDI (www.ndigital.com) product ids
159 */ 159 */
160 #define FTDI_NDI_HUC_PID 0xDA70 /* NDI Host USB Converter */ 160 #define FTDI_NDI_HUC_PID 0xDA70 /* NDI Host USB Converter */
161 #define FTDI_NDI_SPECTRA_SCU_PID 0xDA71 /* NDI Spectra SCU */ 161 #define FTDI_NDI_SPECTRA_SCU_PID 0xDA71 /* NDI Spectra SCU */
162 #define FTDI_NDI_FUTURE_2_PID 0xDA72 /* NDI future device #2 */ 162 #define FTDI_NDI_FUTURE_2_PID 0xDA72 /* NDI future device #2 */
163 #define FTDI_NDI_FUTURE_3_PID 0xDA73 /* NDI future device #3 */ 163 #define FTDI_NDI_FUTURE_3_PID 0xDA73 /* NDI future device #3 */
164 #define FTDI_NDI_AURORA_SCU_PID 0xDA74 /* NDI Aurora SCU */ 164 #define FTDI_NDI_AURORA_SCU_PID 0xDA74 /* NDI Aurora SCU */
165 165
166 /* 166 /*
167 * ChamSys Limited (www.chamsys.co.uk) USB wing/interface product IDs 167 * ChamSys Limited (www.chamsys.co.uk) USB wing/interface product IDs
168 */ 168 */
169 #define FTDI_CHAMSYS_24_MASTER_WING_PID 0xDAF8 169 #define FTDI_CHAMSYS_24_MASTER_WING_PID 0xDAF8
170 #define FTDI_CHAMSYS_PC_WING_PID 0xDAF9 170 #define FTDI_CHAMSYS_PC_WING_PID 0xDAF9
171 #define FTDI_CHAMSYS_USB_DMX_PID 0xDAFA 171 #define FTDI_CHAMSYS_USB_DMX_PID 0xDAFA
172 #define FTDI_CHAMSYS_MIDI_TIMECODE_PID 0xDAFB 172 #define FTDI_CHAMSYS_MIDI_TIMECODE_PID 0xDAFB
173 #define FTDI_CHAMSYS_MINI_WING_PID 0xDAFC 173 #define FTDI_CHAMSYS_MINI_WING_PID 0xDAFC
174 #define FTDI_CHAMSYS_MAXI_WING_PID 0xDAFD 174 #define FTDI_CHAMSYS_MAXI_WING_PID 0xDAFD
175 #define FTDI_CHAMSYS_MEDIA_WING_PID 0xDAFE 175 #define FTDI_CHAMSYS_MEDIA_WING_PID 0xDAFE
176 #define FTDI_CHAMSYS_WING_PID 0xDAFF 176 #define FTDI_CHAMSYS_WING_PID 0xDAFF
177 177
178 /* 178 /*
179 * Westrex International devices submitted by Cory Lee 179 * Westrex International devices submitted by Cory Lee
180 */ 180 */
181 #define FTDI_WESTREX_MODEL_777_PID 0xDC00 /* Model 777 */ 181 #define FTDI_WESTREX_MODEL_777_PID 0xDC00 /* Model 777 */
182 #define FTDI_WESTREX_MODEL_8900F_PID 0xDC01 /* Model 8900F */ 182 #define FTDI_WESTREX_MODEL_8900F_PID 0xDC01 /* Model 8900F */
183 183
184 /* 184 /*
185 * ACG Identification Technologies GmbH products (http://www.acg.de/). 185 * ACG Identification Technologies GmbH products (http://www.acg.de/).
186 * Submitted by anton -at- goto10 -dot- org. 186 * Submitted by anton -at- goto10 -dot- org.
187 */ 187 */
188 #define FTDI_ACG_HFDUAL_PID 0xDD20 /* HF Dual ISO Reader (RFID) */ 188 #define FTDI_ACG_HFDUAL_PID 0xDD20 /* HF Dual ISO Reader (RFID) */
189 189
190 /* 190 /*
191 * Definitions for Artemis astronomical USB based cameras 191 * Definitions for Artemis astronomical USB based cameras
192 * Check it at http://www.artemisccd.co.uk/ 192 * Check it at http://www.artemisccd.co.uk/
193 */ 193 */
194 #define FTDI_ARTEMIS_PID 0xDF28 /* All Artemis Cameras */ 194 #define FTDI_ARTEMIS_PID 0xDF28 /* All Artemis Cameras */
195 195
196 /* 196 /*
197 * Definitions for ATIK Instruments astronomical USB based cameras 197 * Definitions for ATIK Instruments astronomical USB based cameras
198 * Check it at http://www.atik-instruments.com/ 198 * Check it at http://www.atik-instruments.com/
199 */ 199 */
200 #define FTDI_ATIK_ATK16_PID 0xDF30 /* ATIK ATK-16 Grayscale Camera */ 200 #define FTDI_ATIK_ATK16_PID 0xDF30 /* ATIK ATK-16 Grayscale Camera */
201 #define FTDI_ATIK_ATK16C_PID 0xDF32 /* ATIK ATK-16C Colour Camera */ 201 #define FTDI_ATIK_ATK16C_PID 0xDF32 /* ATIK ATK-16C Colour Camera */
202 #define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Grayscale Camera */ 202 #define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Grayscale Camera */
203 #define FTDI_ATIK_ATK16HRC_PID 0xDF33 /* ATIK ATK-16HRC Colour Camera */ 203 #define FTDI_ATIK_ATK16HRC_PID 0xDF33 /* ATIK ATK-16HRC Colour Camera */
204 #define FTDI_ATIK_ATK16IC_PID 0xDF35 /* ATIK ATK-16IC Grayscale Camera */ 204 #define FTDI_ATIK_ATK16IC_PID 0xDF35 /* ATIK ATK-16IC Grayscale Camera */
205 205
206 /* 206 /*
207 * Yost Engineering, Inc. products (www.yostengineering.com). 207 * Yost Engineering, Inc. products (www.yostengineering.com).
208 * PID 0xE050 submitted by Aaron Prose. 208 * PID 0xE050 submitted by Aaron Prose.
209 */ 209 */
210 #define FTDI_YEI_SERVOCENTER31_PID 0xE050 /* YEI ServoCenter3.1 USB */ 210 #define FTDI_YEI_SERVOCENTER31_PID 0xE050 /* YEI ServoCenter3.1 USB */
211 211
212 /* 212 /*
213 * ELV USB devices submitted by Christian Abt of ELV (www.elv.de). 213 * ELV USB devices submitted by Christian Abt of ELV (www.elv.de).
214 * Almost all of these devices use FTDI's vendor ID (0x0403). 214 * Almost all of these devices use FTDI's vendor ID (0x0403).
215 * Further IDs taken from ELV Windows .inf file. 215 * Further IDs taken from ELV Windows .inf file.
216 * 216 *
217 * The previously included PID for the UO 100 module was incorrect. 217 * The previously included PID for the UO 100 module was incorrect.
218 * In fact, that PID was for ELV's UR 100 USB-RS232 converter (0xFB58). 218 * In fact, that PID was for ELV's UR 100 USB-RS232 converter (0xFB58).
219 * 219 *
220 * Armin Laeuger originally sent the PID for the UM 100 module. 220 * Armin Laeuger originally sent the PID for the UM 100 module.
221 */ 221 */
222 #define FTDI_ELV_VID 0x1B1F /* ELV AG */ 222 #define FTDI_ELV_VID 0x1B1F /* ELV AG */
223 #define FTDI_ELV_WS300_PID 0xC006 /* eQ3 WS 300 PC II */ 223 #define FTDI_ELV_WS300_PID 0xC006 /* eQ3 WS 300 PC II */
224 #define FTDI_ELV_USR_PID 0xE000 /* ELV Universal-Sound-Recorder */ 224 #define FTDI_ELV_USR_PID 0xE000 /* ELV Universal-Sound-Recorder */
225 #define FTDI_ELV_MSM1_PID 0xE001 /* ELV Mini-Sound-Modul */ 225 #define FTDI_ELV_MSM1_PID 0xE001 /* ELV Mini-Sound-Modul */
226 #define FTDI_ELV_KL100_PID 0xE002 /* ELV Kfz-Leistungsmesser KL 100 */ 226 #define FTDI_ELV_KL100_PID 0xE002 /* ELV Kfz-Leistungsmesser KL 100 */
227 #define FTDI_ELV_WS550_PID 0xE004 /* WS 550 */ 227 #define FTDI_ELV_WS550_PID 0xE004 /* WS 550 */
228 #define FTDI_ELV_EC3000_PID 0xE006 /* ENERGY CONTROL 3000 USB */ 228 #define FTDI_ELV_EC3000_PID 0xE006 /* ENERGY CONTROL 3000 USB */
229 #define FTDI_ELV_WS888_PID 0xE008 /* WS 888 */ 229 #define FTDI_ELV_WS888_PID 0xE008 /* WS 888 */
230 #define FTDI_ELV_TWS550_PID 0xE009 /* Technoline WS 550 */ 230 #define FTDI_ELV_TWS550_PID 0xE009 /* Technoline WS 550 */
231 #define FTDI_ELV_FEM_PID 0xE00A /* Funk Energie Monitor */ 231 #define FTDI_ELV_FEM_PID 0xE00A /* Funk Energie Monitor */
232 #define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */ 232 #define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */
233 #define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */ 233 #define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */
234 #define FTDI_ELV_HS485_PID 0xE0EA /* USB to RS-485 adapter */ 234 #define FTDI_ELV_HS485_PID 0xE0EA /* USB to RS-485 adapter */
235 #define FTDI_ELV_UMS100_PID 0xE0EB /* ELV USB Master-Slave Schaltsteckdose UMS 100 */ 235 #define FTDI_ELV_UMS100_PID 0xE0EB /* ELV USB Master-Slave Schaltsteckdose UMS 100 */
236 #define FTDI_ELV_TFD128_PID 0xE0EC /* ELV Temperatur-Feuchte-Datenlogger TFD 128 */ 236 #define FTDI_ELV_TFD128_PID 0xE0EC /* ELV Temperatur-Feuchte-Datenlogger TFD 128 */
237 #define FTDI_ELV_FM3RX_PID 0xE0ED /* ELV Messwertuebertragung FM3 RX */ 237 #define FTDI_ELV_FM3RX_PID 0xE0ED /* ELV Messwertuebertragung FM3 RX */
238 #define FTDI_ELV_WS777_PID 0xE0EE /* Conrad WS 777 */ 238 #define FTDI_ELV_WS777_PID 0xE0EE /* Conrad WS 777 */
239 #define FTDI_ELV_EM1010PC_PID 0xE0EF /* Energy monitor EM 1010 PC */ 239 #define FTDI_ELV_EM1010PC_PID 0xE0EF /* Energy monitor EM 1010 PC */
240 #define FTDI_ELV_CSI8_PID 0xE0F0 /* Computer-Schalt-Interface (CSI 8) */ 240 #define FTDI_ELV_CSI8_PID 0xE0F0 /* Computer-Schalt-Interface (CSI 8) */
241 #define FTDI_ELV_EM1000DL_PID 0xE0F1 /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */ 241 #define FTDI_ELV_EM1000DL_PID 0xE0F1 /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */
242 #define FTDI_ELV_PCK100_PID 0xE0F2 /* PC-Kabeltester (PCK 100) */ 242 #define FTDI_ELV_PCK100_PID 0xE0F2 /* PC-Kabeltester (PCK 100) */
243 #define FTDI_ELV_RFP500_PID 0xE0F3 /* HF-Leistungsmesser (RFP 500) */ 243 #define FTDI_ELV_RFP500_PID 0xE0F3 /* HF-Leistungsmesser (RFP 500) */
244 #define FTDI_ELV_FS20SIG_PID 0xE0F4 /* Signalgeber (FS 20 SIG) */ 244 #define FTDI_ELV_FS20SIG_PID 0xE0F4 /* Signalgeber (FS 20 SIG) */
245 #define FTDI_ELV_UTP8_PID 0xE0F5 /* ELV UTP 8 */ 245 #define FTDI_ELV_UTP8_PID 0xE0F5 /* ELV UTP 8 */
246 #define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */ 246 #define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */
247 #define FTDI_ELV_WS444PC_PID 0xE0F7 /* Conrad WS 444 PC */ 247 #define FTDI_ELV_WS444PC_PID 0xE0F7 /* Conrad WS 444 PC */
248 #define FTDI_PHI_FISCO_PID 0xE40B /* PHI Fisco USB to Serial cable */ 248 #define FTDI_PHI_FISCO_PID 0xE40B /* PHI Fisco USB to Serial cable */
249 #define FTDI_ELV_UAD8_PID 0xF068 /* USB-AD-Wandler (UAD 8) */ 249 #define FTDI_ELV_UAD8_PID 0xF068 /* USB-AD-Wandler (UAD 8) */
250 #define FTDI_ELV_UDA7_PID 0xF069 /* USB-DA-Wandler (UDA 7) */ 250 #define FTDI_ELV_UDA7_PID 0xF069 /* USB-DA-Wandler (UDA 7) */
251 #define FTDI_ELV_USI2_PID 0xF06A /* USB-Schrittmotoren-Interface (USI 2) */ 251 #define FTDI_ELV_USI2_PID 0xF06A /* USB-Schrittmotoren-Interface (USI 2) */
252 #define FTDI_ELV_T1100_PID 0xF06B /* Thermometer (T 1100) */ 252 #define FTDI_ELV_T1100_PID 0xF06B /* Thermometer (T 1100) */
253 #define FTDI_ELV_PCD200_PID 0xF06C /* PC-Datenlogger (PCD 200) */ 253 #define FTDI_ELV_PCD200_PID 0xF06C /* PC-Datenlogger (PCD 200) */
254 #define FTDI_ELV_ULA200_PID 0xF06D /* USB-LCD-Ansteuerung (ULA 200) */ 254 #define FTDI_ELV_ULA200_PID 0xF06D /* USB-LCD-Ansteuerung (ULA 200) */
255 #define FTDI_ELV_ALC8500_PID 0xF06E /* ALC 8500 Expert */ 255 #define FTDI_ELV_ALC8500_PID 0xF06E /* ALC 8500 Expert */
256 #define FTDI_ELV_FHZ1000PC_PID 0xF06F /* FHZ 1000 PC */ 256 #define FTDI_ELV_FHZ1000PC_PID 0xF06F /* FHZ 1000 PC */
257 #define FTDI_ELV_UR100_PID 0xFB58 /* USB-RS232-Umsetzer (UR 100) */ 257 #define FTDI_ELV_UR100_PID 0xFB58 /* USB-RS232-Umsetzer (UR 100) */
258 #define FTDI_ELV_UM100_PID 0xFB5A /* USB-Modul UM 100 */ 258 #define FTDI_ELV_UM100_PID 0xFB5A /* USB-Modul UM 100 */
259 #define FTDI_ELV_UO100_PID 0xFB5B /* USB-Modul UO 100 */ 259 #define FTDI_ELV_UO100_PID 0xFB5B /* USB-Modul UO 100 */
260 /* Additional ELV PIDs that default to using the FTDI D2XX drivers on 260 /* Additional ELV PIDs that default to using the FTDI D2XX drivers on
261 * MS Windows, rather than the FTDI Virtual Com Port drivers. 261 * MS Windows, rather than the FTDI Virtual Com Port drivers.
262 * Maybe these will be easier to use with the libftdi/libusb user-space 262 * Maybe these will be easier to use with the libftdi/libusb user-space
263 * drivers, or possibly the Comedi drivers in some cases. */ 263 * drivers, or possibly the Comedi drivers in some cases. */
264 #define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */ 264 #define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */
265 #define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */ 265 #define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */
266 #define FTDI_ELV_TFM100_PID 0xFB5D /* Temperatur-Feuchte-Messgeraet (TFM 100) */ 266 #define FTDI_ELV_TFM100_PID 0xFB5D /* Temperatur-Feuchte-Messgeraet (TFM 100) */
267 #define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkuhr (UDF 77) */ 267 #define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkuhr (UDF 77) */
268 #define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */ 268 #define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */
269 269
270 /* 270 /*
271 * EVER Eco Pro UPS (http://www.ever.com.pl/) 271 * EVER Eco Pro UPS (http://www.ever.com.pl/)
272 */ 272 */
273 273
274 #define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */ 274 #define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */
275 275
276 /* 276 /*
277 * Active Robots product ids. 277 * Active Robots product ids.
278 */ 278 */
279 #define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */ 279 #define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */
280 280
281 /* Pyramid Computer GmbH */ 281 /* Pyramid Computer GmbH */
282 #define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ 282 #define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */
283 283
284 /* www.elsterelectricity.com Elster Unicom III Optical Probe */ 284 /* www.elsterelectricity.com Elster Unicom III Optical Probe */
285 #define FTDI_ELSTER_UNICOM_PID 0xE700 /* Product Id */ 285 #define FTDI_ELSTER_UNICOM_PID 0xE700 /* Product Id */
286 286
287 /* 287 /*
288 * Gude Analog- und Digitalsysteme GmbH 288 * Gude Analog- und Digitalsysteme GmbH
289 */ 289 */
290 #define FTDI_GUDEADS_E808_PID 0xE808 290 #define FTDI_GUDEADS_E808_PID 0xE808
291 #define FTDI_GUDEADS_E809_PID 0xE809 291 #define FTDI_GUDEADS_E809_PID 0xE809
292 #define FTDI_GUDEADS_E80A_PID 0xE80A 292 #define FTDI_GUDEADS_E80A_PID 0xE80A
293 #define FTDI_GUDEADS_E80B_PID 0xE80B 293 #define FTDI_GUDEADS_E80B_PID 0xE80B
294 #define FTDI_GUDEADS_E80C_PID 0xE80C 294 #define FTDI_GUDEADS_E80C_PID 0xE80C
295 #define FTDI_GUDEADS_E80D_PID 0xE80D 295 #define FTDI_GUDEADS_E80D_PID 0xE80D
296 #define FTDI_GUDEADS_E80E_PID 0xE80E 296 #define FTDI_GUDEADS_E80E_PID 0xE80E
297 #define FTDI_GUDEADS_E80F_PID 0xE80F 297 #define FTDI_GUDEADS_E80F_PID 0xE80F
298 #define FTDI_GUDEADS_E888_PID 0xE888 /* Expert ISDN Control USB */ 298 #define FTDI_GUDEADS_E888_PID 0xE888 /* Expert ISDN Control USB */
299 #define FTDI_GUDEADS_E889_PID 0xE889 /* USB RS-232 OptoBridge */ 299 #define FTDI_GUDEADS_E889_PID 0xE889 /* USB RS-232 OptoBridge */
300 #define FTDI_GUDEADS_E88A_PID 0xE88A 300 #define FTDI_GUDEADS_E88A_PID 0xE88A
301 #define FTDI_GUDEADS_E88B_PID 0xE88B 301 #define FTDI_GUDEADS_E88B_PID 0xE88B
302 #define FTDI_GUDEADS_E88C_PID 0xE88C 302 #define FTDI_GUDEADS_E88C_PID 0xE88C
303 #define FTDI_GUDEADS_E88D_PID 0xE88D 303 #define FTDI_GUDEADS_E88D_PID 0xE88D
304 #define FTDI_GUDEADS_E88E_PID 0xE88E 304 #define FTDI_GUDEADS_E88E_PID 0xE88E
305 #define FTDI_GUDEADS_E88F_PID 0xE88F 305 #define FTDI_GUDEADS_E88F_PID 0xE88F
306 306
307 /* 307 /*
308 * Eclo (http://www.eclo.pt/) product IDs. 308 * Eclo (http://www.eclo.pt/) product IDs.
309 * PID 0xEA90 submitted by Martin Grill. 309 * PID 0xEA90 submitted by Martin Grill.
310 */ 310 */
311 #define FTDI_ECLO_COM_1WIRE_PID 0xEA90 /* COM to 1-Wire USB adaptor */ 311 #define FTDI_ECLO_COM_1WIRE_PID 0xEA90 /* COM to 1-Wire USB adaptor */
312 312
313 /* TNC-X USB-to-packet-radio adapter, versions prior to 3.0 (DLP module) */ 313 /* TNC-X USB-to-packet-radio adapter, versions prior to 3.0 (DLP module) */
314 #define FTDI_TNC_X_PID 0xEBE0 314 #define FTDI_TNC_X_PID 0xEBE0
315 315
316 /* 316 /*
317 * Teratronik product ids. 317 * Teratronik product ids.
318 * Submitted by O. Wรถlfelschneider. 318 * Submitted by O. Wรถlfelschneider.
319 */ 319 */
320 #define FTDI_TERATRONIK_VCP_PID 0xEC88 /* Teratronik device (preferring VCP driver on windows) */ 320 #define FTDI_TERATRONIK_VCP_PID 0xEC88 /* Teratronik device (preferring VCP driver on windows) */
321 #define FTDI_TERATRONIK_D2XX_PID 0xEC89 /* Teratronik device (preferring D2XX driver on windows) */ 321 #define FTDI_TERATRONIK_D2XX_PID 0xEC89 /* Teratronik device (preferring D2XX driver on windows) */
322 322
323 /* Rig Expert Ukraine devices */ 323 /* Rig Expert Ukraine devices */
324 #define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */ 324 #define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */
325 325
326 /* 326 /*
327 * Hameg HO820 and HO870 interface (using VID 0x0403) 327 * Hameg HO820 and HO870 interface (using VID 0x0403)
328 */ 328 */
329 #define HAMEG_HO820_PID 0xed74 329 #define HAMEG_HO820_PID 0xed74
330 #define HAMEG_HO730_PID 0xed73 330 #define HAMEG_HO730_PID 0xed73
331 #define HAMEG_HO720_PID 0xed72 331 #define HAMEG_HO720_PID 0xed72
332 #define HAMEG_HO870_PID 0xed71 332 #define HAMEG_HO870_PID 0xed71
333 333
334 /* 334 /*
335 * MaxStream devices www.maxstream.net 335 * MaxStream devices www.maxstream.net
336 */ 336 */
337 #define FTDI_MAXSTREAM_PID 0xEE18 /* Xbee PKG-U Module */ 337 #define FTDI_MAXSTREAM_PID 0xEE18 /* Xbee PKG-U Module */
338 338
339 /* 339 /*
340 * microHAM product IDs (http://www.microham.com). 340 * microHAM product IDs (http://www.microham.com).
341 * Submitted by Justin Burket (KL1RL) <zorton@jtan.com> 341 * Submitted by Justin Burket (KL1RL) <zorton@jtan.com>
342 * and Mike Studer (K6EEP) <k6eep@hamsoftware.org>. 342 * and Mike Studer (K6EEP) <k6eep@hamsoftware.org>.
343 * Ian Abbott <abbotti@mev.co.uk> added a few more from the driver INF file. 343 * Ian Abbott <abbotti@mev.co.uk> added a few more from the driver INF file.
344 */ 344 */
345 #define FTDI_MHAM_KW_PID 0xEEE8 /* USB-KW interface */ 345 #define FTDI_MHAM_KW_PID 0xEEE8 /* USB-KW interface */
346 #define FTDI_MHAM_YS_PID 0xEEE9 /* USB-YS interface */ 346 #define FTDI_MHAM_YS_PID 0xEEE9 /* USB-YS interface */
347 #define FTDI_MHAM_Y6_PID 0xEEEA /* USB-Y6 interface */ 347 #define FTDI_MHAM_Y6_PID 0xEEEA /* USB-Y6 interface */
348 #define FTDI_MHAM_Y8_PID 0xEEEB /* USB-Y8 interface */ 348 #define FTDI_MHAM_Y8_PID 0xEEEB /* USB-Y8 interface */
349 #define FTDI_MHAM_IC_PID 0xEEEC /* USB-IC interface */ 349 #define FTDI_MHAM_IC_PID 0xEEEC /* USB-IC interface */
350 #define FTDI_MHAM_DB9_PID 0xEEED /* USB-DB9 interface */ 350 #define FTDI_MHAM_DB9_PID 0xEEED /* USB-DB9 interface */
351 #define FTDI_MHAM_RS232_PID 0xEEEE /* USB-RS232 interface */ 351 #define FTDI_MHAM_RS232_PID 0xEEEE /* USB-RS232 interface */
352 #define FTDI_MHAM_Y9_PID 0xEEEF /* USB-Y9 interface */ 352 #define FTDI_MHAM_Y9_PID 0xEEEF /* USB-Y9 interface */
353 353
354 /* Domintell products http://www.domintell.com */ 354 /* Domintell products http://www.domintell.com */
355 #define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */ 355 #define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */
356 #define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */ 356 #define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */
357 357
358 /* 358 /*
359 * The following are the values for the Perle Systems 359 * The following are the values for the Perle Systems
360 * UltraPort USB serial converters 360 * UltraPort USB serial converters
361 */ 361 */
362 #define FTDI_PERLE_ULTRAPORT_PID 0xF0C0 /* Perle UltraPort Product Id */ 362 #define FTDI_PERLE_ULTRAPORT_PID 0xF0C0 /* Perle UltraPort Product Id */
363 363
364 /* Sprog II (Andrew Crosland's SprogII DCC interface) */ 364 /* Sprog II (Andrew Crosland's SprogII DCC interface) */
365 #define FTDI_SPROG_II 0xF0C8 365 #define FTDI_SPROG_II 0xF0C8
366 366
367 /* 367 /*
368 * Two of the Tagsys RFID Readers 368 * Two of the Tagsys RFID Readers
369 */ 369 */
370 #define FTDI_TAGSYS_LP101_PID 0xF0E9 /* Tagsys L-P101 RFID*/ 370 #define FTDI_TAGSYS_LP101_PID 0xF0E9 /* Tagsys L-P101 RFID*/
371 #define FTDI_TAGSYS_P200X_PID 0xF0EE /* Tagsys Medio P200x RFID*/ 371 #define FTDI_TAGSYS_P200X_PID 0xF0EE /* Tagsys Medio P200x RFID*/
372 372
373 /* an infrared receiver for user access control with IR tags */ 373 /* an infrared receiver for user access control with IR tags */
374 #define FTDI_PIEGROUP_PID 0xF208 /* Product Id */ 374 #define FTDI_PIEGROUP_PID 0xF208 /* Product Id */
375 375
376 /* ACT Solutions HomePro ZWave interface 376 /* ACT Solutions HomePro ZWave interface
377 (http://www.act-solutions.com/HomePro-Product-Matrix.html) */ 377 (http://www.act-solutions.com/HomePro-Product-Matrix.html) */
378 #define FTDI_ACTZWAVE_PID 0xF2D0 378 #define FTDI_ACTZWAVE_PID 0xF2D0
379 379
380 /* 380 /*
381 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485, 381 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
382 * USB-TTY aktiv, USB-TTY passiv. Some PIDs are used by several devices 382 * USB-TTY aktiv, USB-TTY passiv. Some PIDs are used by several devices
383 * and I'm not entirely sure which are used by which. 383 * and I'm not entirely sure which are used by which.
384 */ 384 */
385 #define FTDI_4N_GALAXY_DE_1_PID 0xF3C0 385 #define FTDI_4N_GALAXY_DE_1_PID 0xF3C0
386 #define FTDI_4N_GALAXY_DE_2_PID 0xF3C1 386 #define FTDI_4N_GALAXY_DE_2_PID 0xF3C1
387 #define FTDI_4N_GALAXY_DE_3_PID 0xF3C2 387 #define FTDI_4N_GALAXY_DE_3_PID 0xF3C2
388 388
389 /* 389 /*
390 * Linx Technologies product ids 390 * Linx Technologies product ids
391 */ 391 */
392 #define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */ 392 #define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */
393 #define LINX_MASTERDEVEL2_PID 0xF449 /* Linx Master Development 2.0 */ 393 #define LINX_MASTERDEVEL2_PID 0xF449 /* Linx Master Development 2.0 */
394 #define LINX_FUTURE_0_PID 0xF44A /* Linx future device */ 394 #define LINX_FUTURE_0_PID 0xF44A /* Linx future device */
395 #define LINX_FUTURE_1_PID 0xF44B /* Linx future device */ 395 #define LINX_FUTURE_1_PID 0xF44B /* Linx future device */
396 #define LINX_FUTURE_2_PID 0xF44C /* Linx future device */ 396 #define LINX_FUTURE_2_PID 0xF44C /* Linx future device */
397 397
398 /* 398 /*
399 * Oceanic product ids 399 * Oceanic product ids
400 */ 400 */
401 #define FTDI_OCEANIC_PID 0xF460 /* Oceanic dive instrument */ 401 #define FTDI_OCEANIC_PID 0xF460 /* Oceanic dive instrument */
402 402
403 /* 403 /*
404 * SUUNTO product ids 404 * SUUNTO product ids
405 */ 405 */
406 #define FTDI_SUUNTO_SPORTS_PID 0xF680 /* Suunto Sports instrument */ 406 #define FTDI_SUUNTO_SPORTS_PID 0xF680 /* Suunto Sports instrument */
407 407
408 /* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */ 408 /* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */
409 /* http://www.usbuirt.com/ */ 409 /* http://www.usbuirt.com/ */
410 #define FTDI_USB_UIRT_PID 0xF850 /* Product Id */ 410 #define FTDI_USB_UIRT_PID 0xF850 /* Product Id */
411 411
412 /* CCS Inc. ICDU/ICDU40 product ID - 412 /* CCS Inc. ICDU/ICDU40 product ID -
413 * the FT232BM is used in an in-circuit-debugger unit for PIC16's/PIC18's */ 413 * the FT232BM is used in an in-circuit-debugger unit for PIC16's/PIC18's */
414 #define FTDI_CCSICDU20_0_PID 0xF9D0 414 #define FTDI_CCSICDU20_0_PID 0xF9D0
415 #define FTDI_CCSICDU40_1_PID 0xF9D1 415 #define FTDI_CCSICDU40_1_PID 0xF9D1
416 #define FTDI_CCSMACHX_2_PID 0xF9D2 416 #define FTDI_CCSMACHX_2_PID 0xF9D2
417 #define FTDI_CCSLOAD_N_GO_3_PID 0xF9D3 417 #define FTDI_CCSLOAD_N_GO_3_PID 0xF9D3
418 #define FTDI_CCSICDU64_4_PID 0xF9D4 418 #define FTDI_CCSICDU64_4_PID 0xF9D4
419 #define FTDI_CCSPRIME8_5_PID 0xF9D5 419 #define FTDI_CCSPRIME8_5_PID 0xF9D5
420 420
421 /* 421 /*
422 * The following are the values for the Matrix Orbital LCD displays, 422 * The following are the values for the Matrix Orbital LCD displays,
423 * which are the FT232BM ( similar to the 8U232AM ) 423 * which are the FT232BM ( similar to the 8U232AM )
424 */ 424 */
425 #define FTDI_MTXORB_0_PID 0xFA00 /* Matrix Orbital Product Id */ 425 #define FTDI_MTXORB_0_PID 0xFA00 /* Matrix Orbital Product Id */
426 #define FTDI_MTXORB_1_PID 0xFA01 /* Matrix Orbital Product Id */ 426 #define FTDI_MTXORB_1_PID 0xFA01 /* Matrix Orbital Product Id */
427 #define FTDI_MTXORB_2_PID 0xFA02 /* Matrix Orbital Product Id */ 427 #define FTDI_MTXORB_2_PID 0xFA02 /* Matrix Orbital Product Id */
428 #define FTDI_MTXORB_3_PID 0xFA03 /* Matrix Orbital Product Id */ 428 #define FTDI_MTXORB_3_PID 0xFA03 /* Matrix Orbital Product Id */
429 #define FTDI_MTXORB_4_PID 0xFA04 /* Matrix Orbital Product Id */ 429 #define FTDI_MTXORB_4_PID 0xFA04 /* Matrix Orbital Product Id */
430 #define FTDI_MTXORB_5_PID 0xFA05 /* Matrix Orbital Product Id */ 430 #define FTDI_MTXORB_5_PID 0xFA05 /* Matrix Orbital Product Id */
431 #define FTDI_MTXORB_6_PID 0xFA06 /* Matrix Orbital Product Id */ 431 #define FTDI_MTXORB_6_PID 0xFA06 /* Matrix Orbital Product Id */
432 432
433 /* 433 /*
434 * Home Electronics (www.home-electro.com) USB gadgets 434 * Home Electronics (www.home-electro.com) USB gadgets
435 */ 435 */
436 #define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR transceiver */ 436 #define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR transceiver */
437 437
438 /* Inside Accesso contactless reader (http://www.insidecontactless.com/) */ 438 /* Inside Accesso contactless reader (http://www.insidecontactless.com/) */
439 #define INSIDE_ACCESSO 0xFAD0 439 #define INSIDE_ACCESSO 0xFAD0
440 440
441 /* 441 /*
442 * ThorLabs USB motor drivers 442 * ThorLabs USB motor drivers
443 */ 443 */
444 #define FTDI_THORLABS_PID 0xfaf0 /* ThorLabs USB motor drivers */ 444 #define FTDI_THORLABS_PID 0xfaf0 /* ThorLabs USB motor drivers */
445 445
446 /* 446 /*
447 * Protego product ids 447 * Protego product ids
448 */ 448 */
449 #define PROTEGO_SPECIAL_1 0xFC70 /* special/unknown device */ 449 #define PROTEGO_SPECIAL_1 0xFC70 /* special/unknown device */
450 #define PROTEGO_R2X0 0xFC71 /* R200-USB TRNG unit (R210, R220, and R230) */ 450 #define PROTEGO_R2X0 0xFC71 /* R200-USB TRNG unit (R210, R220, and R230) */
451 #define PROTEGO_SPECIAL_3 0xFC72 /* special/unknown device */ 451 #define PROTEGO_SPECIAL_3 0xFC72 /* special/unknown device */
452 #define PROTEGO_SPECIAL_4 0xFC73 /* special/unknown device */ 452 #define PROTEGO_SPECIAL_4 0xFC73 /* special/unknown device */
453 453
454 /* 454 /*
455 * Sony Ericsson product ids 455 * Sony Ericsson product ids
456 */ 456 */
457 #define FTDI_DSS20_PID 0xFC82 /* DSS-20 Sync Station for Sony Ericsson P800 */ 457 #define FTDI_DSS20_PID 0xFC82 /* DSS-20 Sync Station for Sony Ericsson P800 */
458 #define FTDI_URBAN_0_PID 0xFC8A /* Sony Ericsson Urban, uart #0 */ 458 #define FTDI_URBAN_0_PID 0xFC8A /* Sony Ericsson Urban, uart #0 */
459 #define FTDI_URBAN_1_PID 0xFC8B /* Sony Ericsson Urban, uart #1 */ 459 #define FTDI_URBAN_1_PID 0xFC8B /* Sony Ericsson Urban, uart #1 */
460 460
461 /* www.irtrans.de device */ 461 /* www.irtrans.de device */
462 #define FTDI_IRTRANS_PID 0xFC60 /* Product Id */ 462 #define FTDI_IRTRANS_PID 0xFC60 /* Product Id */
463 463
464 /* 464 /*
465 * RM Michaelides CANview USB (http://www.rmcan.com) (FTDI_VID) 465 * RM Michaelides CANview USB (http://www.rmcan.com) (FTDI_VID)
466 * CAN fieldbus interface adapter, added by port GmbH www.port.de) 466 * CAN fieldbus interface adapter, added by port GmbH www.port.de)
467 * Ian Abbott changed the macro names for consistency. 467 * Ian Abbott changed the macro names for consistency.
468 */ 468 */
469 #define FTDI_RM_CANVIEW_PID 0xfd60 /* Product Id */ 469 #define FTDI_RM_CANVIEW_PID 0xfd60 /* Product Id */
470 /* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */ 470 /* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */
471 #define FTDI_TTUSB_PID 0xFF20 /* Product Id */ 471 #define FTDI_TTUSB_PID 0xFF20 /* Product Id */
472 472
473 #define FTDI_USBX_707_PID 0xF857 /* ADSTech IR Blaster USBX-707 (FTDI_VID) */ 473 #define FTDI_USBX_707_PID 0xF857 /* ADSTech IR Blaster USBX-707 (FTDI_VID) */
474 474
475 #define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */ 475 #define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */
476 476
477 /* 477 /*
478 * PCDJ use ftdi based dj-controllers. The following PID is 478 * PCDJ use ftdi based dj-controllers. The following PID is
479 * for their DAC-2 device http://www.pcdjhardware.com/DAC2.asp 479 * for their DAC-2 device http://www.pcdjhardware.com/DAC2.asp
480 * (the VID is the standard ftdi vid (FTDI_VID), PID sent by Wouter Paesen) 480 * (the VID is the standard ftdi vid (FTDI_VID), PID sent by Wouter Paesen)
481 */ 481 */
482 #define FTDI_PCDJ_DAC2_PID 0xFA88 482 #define FTDI_PCDJ_DAC2_PID 0xFA88
483 483
484 #define FTDI_R2000KU_TRUE_RNG 0xFB80 /* R2000KU TRUE RNG (FTDI_VID) */ 484 #define FTDI_R2000KU_TRUE_RNG 0xFB80 /* R2000KU TRUE RNG (FTDI_VID) */
485 485
486 /* 486 /*
487 * DIEBOLD BCS SE923 (FTDI_VID) 487 * DIEBOLD BCS SE923 (FTDI_VID)
488 */ 488 */
489 #define DIEBOLD_BCS_SE923_PID 0xfb99 489 #define DIEBOLD_BCS_SE923_PID 0xfb99
490 490
491 /* www.crystalfontz.com devices 491 /* www.crystalfontz.com devices
492 * - thanx for providing free devices for evaluation ! 492 * - thanx for providing free devices for evaluation !
493 * they use the ftdi chipset for the USB interface 493 * they use the ftdi chipset for the USB interface
494 * and the vendor id is the same 494 * and the vendor id is the same
495 */ 495 */
496 #define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 496 #define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
497 #define FTDI_XF_634_PID 0xFC09 /* 634: 20x4 Character Display */ 497 #define FTDI_XF_634_PID 0xFC09 /* 634: 20x4 Character Display */
498 #define FTDI_XF_547_PID 0xFC0A /* 547: Two line Display */ 498 #define FTDI_XF_547_PID 0xFC0A /* 547: Two line Display */
499 #define FTDI_XF_633_PID 0xFC0B /* 633: 16x2 Character Display with Keys */ 499 #define FTDI_XF_633_PID 0xFC0B /* 633: 16x2 Character Display with Keys */
500 #define FTDI_XF_631_PID 0xFC0C /* 631: 20x2 Character Display */ 500 #define FTDI_XF_631_PID 0xFC0C /* 631: 20x2 Character Display */
501 #define FTDI_XF_635_PID 0xFC0D /* 635: 20x4 Character Display */ 501 #define FTDI_XF_635_PID 0xFC0D /* 635: 20x4 Character Display */
502 #define FTDI_XF_640_PID 0xFC0E /* 640: Two line Display */ 502 #define FTDI_XF_640_PID 0xFC0E /* 640: Two line Display */
503 #define FTDI_XF_642_PID 0xFC0F /* 642: Two line Display */ 503 #define FTDI_XF_642_PID 0xFC0F /* 642: Two line Display */
504 504
505 /* 505 /*
506 * Video Networks Limited / Homechoice in the UK use an ftdi-based device 506 * Video Networks Limited / Homechoice in the UK use an ftdi-based device
507 * for their 1Mb broadband internet service. The following PID is exhibited 507 * for their 1Mb broadband internet service. The following PID is exhibited
508 * by the usb device supplied (the VID is the standard ftdi vid (FTDI_VID) 508 * by the usb device supplied (the VID is the standard ftdi vid (FTDI_VID)
509 */ 509 */
510 #define FTDI_VNHCPCUSB_D_PID 0xfe38 /* Product Id */ 510 #define FTDI_VNHCPCUSB_D_PID 0xfe38 /* Product Id */
511 511
512 /* AlphaMicro Components AMC-232USB01 device (FTDI_VID) */ 512 /* AlphaMicro Components AMC-232USB01 device (FTDI_VID) */
513 #define FTDI_AMC232_PID 0xFF00 /* Product Id */ 513 #define FTDI_AMC232_PID 0xFF00 /* Product Id */
514 514
515 /* 515 /*
516 * IBS elektronik product ids (FTDI_VID) 516 * IBS elektronik product ids (FTDI_VID)
517 * Submitted by Thomas Schleusener 517 * Submitted by Thomas Schleusener
518 */ 518 */
519 #define FTDI_IBS_US485_PID 0xff38 /* IBS US485 (USB<-->RS422/485 interface) */ 519 #define FTDI_IBS_US485_PID 0xff38 /* IBS US485 (USB<-->RS422/485 interface) */
520 #define FTDI_IBS_PICPRO_PID 0xff39 /* IBS PIC-Programmer */ 520 #define FTDI_IBS_PICPRO_PID 0xff39 /* IBS PIC-Programmer */
521 #define FTDI_IBS_PCMCIA_PID 0xff3a /* IBS Card reader for PCMCIA SRAM-cards */ 521 #define FTDI_IBS_PCMCIA_PID 0xff3a /* IBS Card reader for PCMCIA SRAM-cards */
522 #define FTDI_IBS_PK1_PID 0xff3b /* IBS PK1 - Particel counter */ 522 #define FTDI_IBS_PK1_PID 0xff3b /* IBS PK1 - Particel counter */
523 #define FTDI_IBS_RS232MON_PID 0xff3c /* IBS RS232 - Monitor */ 523 #define FTDI_IBS_RS232MON_PID 0xff3c /* IBS RS232 - Monitor */
524 #define FTDI_IBS_APP70_PID 0xff3d /* APP 70 (dust monitoring system) */ 524 #define FTDI_IBS_APP70_PID 0xff3d /* APP 70 (dust monitoring system) */
525 #define FTDI_IBS_PEDO_PID 0xff3e /* IBS PEDO-Modem (RF modem 868.35 MHz) */ 525 #define FTDI_IBS_PEDO_PID 0xff3e /* IBS PEDO-Modem (RF modem 868.35 MHz) */
526 #define FTDI_IBS_PROD_PID 0xff3f /* future device */ 526 #define FTDI_IBS_PROD_PID 0xff3f /* future device */
527 /* www.canusb.com Lawicel CANUSB device (FTDI_VID) */ 527 /* www.canusb.com Lawicel CANUSB device (FTDI_VID) */
528 #define FTDI_CANUSB_PID 0xFFA8 /* Product Id */ 528 #define FTDI_CANUSB_PID 0xFFA8 /* Product Id */
529 529
530 /* 530 /*
531 * TavIR AVR product ids (FTDI_VID) 531 * TavIR AVR product ids (FTDI_VID)
532 */ 532 */
533 #define FTDI_TAVIR_STK500_PID 0xFA33 /* STK500 AVR programmer */ 533 #define FTDI_TAVIR_STK500_PID 0xFA33 /* STK500 AVR programmer */
534 534
535 /* 535 /*
536 * TIAO product ids (FTDI_VID) 536 * TIAO product ids (FTDI_VID)
537 * http://www.tiaowiki.com/w/Main_Page 537 * http://www.tiaowiki.com/w/Main_Page
538 */ 538 */
539 #define FTDI_TIAO_UMPA_PID 0x8a98 /* TIAO/DIYGADGET USB Multi-Protocol Adapter */ 539 #define FTDI_TIAO_UMPA_PID 0x8a98 /* TIAO/DIYGADGET USB Multi-Protocol Adapter */
540 540
541 /*
542 * NovaTech product ids (FTDI_VID)
543 */
544 #define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */
545
541 546
542 /********************************/ 547 /********************************/
543 /** third-party VID/PID combos **/ 548 /** third-party VID/PID combos **/
544 /********************************/ 549 /********************************/
545 550
546 551
547 552
548 /* 553 /*
549 * Atmel STK541 554 * Atmel STK541
550 */ 555 */
551 #define ATMEL_VID 0x03eb /* Vendor ID */ 556 #define ATMEL_VID 0x03eb /* Vendor ID */
552 #define STK541_PID 0x2109 /* Zigbee Controller */ 557 #define STK541_PID 0x2109 /* Zigbee Controller */
553 558
554 /* 559 /*
555 * Blackfin gnICE JTAG 560 * Blackfin gnICE JTAG
556 * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice 561 * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice
557 */ 562 */
558 #define ADI_VID 0x0456 563 #define ADI_VID 0x0456
559 #define ADI_GNICE_PID 0xF000 564 #define ADI_GNICE_PID 0xF000
560 #define ADI_GNICEPLUS_PID 0xF001 565 #define ADI_GNICEPLUS_PID 0xF001
561 566
562 /* 567 /*
563 * Microchip Technology, Inc. 568 * Microchip Technology, Inc.
564 * 569 *
565 * MICROCHIP_VID (0x04D8) and MICROCHIP_USB_BOARD_PID (0x000A) are 570 * MICROCHIP_VID (0x04D8) and MICROCHIP_USB_BOARD_PID (0x000A) are
566 * used by single function CDC ACM class based firmware demo 571 * used by single function CDC ACM class based firmware demo
567 * applications. The VID/PID has also been used in firmware 572 * applications. The VID/PID has also been used in firmware
568 * emulating FTDI serial chips by: 573 * emulating FTDI serial chips by:
569 * Hornby Elite - Digital Command Control Console 574 * Hornby Elite - Digital Command Control Console
570 * http://www.hornby.com/hornby-dcc/controllers/ 575 * http://www.hornby.com/hornby-dcc/controllers/
571 */ 576 */
572 #define MICROCHIP_VID 0x04D8 577 #define MICROCHIP_VID 0x04D8
573 #define MICROCHIP_USB_BOARD_PID 0x000A /* CDC RS-232 Emulation Demo */ 578 #define MICROCHIP_USB_BOARD_PID 0x000A /* CDC RS-232 Emulation Demo */
574 579
575 /* 580 /*
576 * RATOC REX-USB60F 581 * RATOC REX-USB60F
577 */ 582 */
578 #define RATOC_VENDOR_ID 0x0584 583 #define RATOC_VENDOR_ID 0x0584
579 #define RATOC_PRODUCT_ID_USB60F 0xb020 584 #define RATOC_PRODUCT_ID_USB60F 0xb020
580 585
581 /* 586 /*
582 * Acton Research Corp. 587 * Acton Research Corp.
583 */ 588 */
584 #define ACTON_VID 0x0647 /* Vendor ID */ 589 #define ACTON_VID 0x0647 /* Vendor ID */
585 #define ACTON_SPECTRAPRO_PID 0x0100 590 #define ACTON_SPECTRAPRO_PID 0x0100
586 591
587 /* 592 /*
588 * Contec products (http://www.contec.com) 593 * Contec products (http://www.contec.com)
589 * Submitted by Daniel Sangorrin 594 * Submitted by Daniel Sangorrin
590 */ 595 */
591 #define CONTEC_VID 0x06CE /* Vendor ID */ 596 #define CONTEC_VID 0x06CE /* Vendor ID */
592 #define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */ 597 #define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */
593 598
594 /* 599 /*
595 * Mitsubishi Electric Corp. (http://www.meau.com) 600 * Mitsubishi Electric Corp. (http://www.meau.com)
596 * Submitted by Konstantin Holoborodko 601 * Submitted by Konstantin Holoborodko
597 */ 602 */
598 #define MITSUBISHI_VID 0x06D3 603 #define MITSUBISHI_VID 0x06D3
599 #define MITSUBISHI_FXUSB_PID 0x0284 /* USB/RS422 converters: FX-USB-AW/-BD */ 604 #define MITSUBISHI_FXUSB_PID 0x0284 /* USB/RS422 converters: FX-USB-AW/-BD */
600 605
601 /* 606 /*
602 * Definitions for B&B Electronics products. 607 * Definitions for B&B Electronics products.
603 */ 608 */
604 #define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */ 609 #define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */
605 #define BANDB_USOTL4_PID 0xAC01 /* USOTL4 Isolated RS-485 Converter */ 610 #define BANDB_USOTL4_PID 0xAC01 /* USOTL4 Isolated RS-485 Converter */
606 #define BANDB_USTL4_PID 0xAC02 /* USTL4 RS-485 Converter */ 611 #define BANDB_USTL4_PID 0xAC02 /* USTL4 RS-485 Converter */
607 #define BANDB_USO9ML2_PID 0xAC03 /* USO9ML2 Isolated RS-232 Converter */ 612 #define BANDB_USO9ML2_PID 0xAC03 /* USO9ML2 Isolated RS-232 Converter */
608 #define BANDB_USOPTL4_PID 0xAC11 613 #define BANDB_USOPTL4_PID 0xAC11
609 #define BANDB_USPTL4_PID 0xAC12 614 #define BANDB_USPTL4_PID 0xAC12
610 #define BANDB_USO9ML2DR_2_PID 0xAC16 615 #define BANDB_USO9ML2DR_2_PID 0xAC16
611 #define BANDB_USO9ML2DR_PID 0xAC17 616 #define BANDB_USO9ML2DR_PID 0xAC17
612 #define BANDB_USOPTL4DR2_PID 0xAC18 /* USOPTL4R-2 2-port Isolated RS-232 Converter */ 617 #define BANDB_USOPTL4DR2_PID 0xAC18 /* USOPTL4R-2 2-port Isolated RS-232 Converter */
613 #define BANDB_USOPTL4DR_PID 0xAC19 618 #define BANDB_USOPTL4DR_PID 0xAC19
614 #define BANDB_485USB9F_2W_PID 0xAC25 619 #define BANDB_485USB9F_2W_PID 0xAC25
615 #define BANDB_485USB9F_4W_PID 0xAC26 620 #define BANDB_485USB9F_4W_PID 0xAC26
616 #define BANDB_232USB9M_PID 0xAC27 621 #define BANDB_232USB9M_PID 0xAC27
617 #define BANDB_485USBTB_2W_PID 0xAC33 622 #define BANDB_485USBTB_2W_PID 0xAC33
618 #define BANDB_485USBTB_4W_PID 0xAC34 623 #define BANDB_485USBTB_4W_PID 0xAC34
619 #define BANDB_TTL5USB9M_PID 0xAC49 624 #define BANDB_TTL5USB9M_PID 0xAC49
620 #define BANDB_TTL3USB9M_PID 0xAC50 625 #define BANDB_TTL3USB9M_PID 0xAC50
621 #define BANDB_ZZ_PROG1_USB_PID 0xBA02 626 #define BANDB_ZZ_PROG1_USB_PID 0xBA02
622 627
623 /* 628 /*
624 * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI 629 * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
625 */ 630 */
626 #define INTREPID_VID 0x093C 631 #define INTREPID_VID 0x093C
627 #define INTREPID_VALUECAN_PID 0x0601 632 #define INTREPID_VALUECAN_PID 0x0601
628 #define INTREPID_NEOVI_PID 0x0701 633 #define INTREPID_NEOVI_PID 0x0701
629 634
630 /* 635 /*
631 * Definitions for ID TECH (www.idt-net.com) devices 636 * Definitions for ID TECH (www.idt-net.com) devices
632 */ 637 */
633 #define IDTECH_VID 0x0ACD /* ID TECH Vendor ID */ 638 #define IDTECH_VID 0x0ACD /* ID TECH Vendor ID */
634 #define IDTECH_IDT1221U_PID 0x0300 /* IDT1221U USB to RS-232 adapter */ 639 #define IDTECH_IDT1221U_PID 0x0300 /* IDT1221U USB to RS-232 adapter */
635 640
636 /* 641 /*
637 * Definitions for Omnidirectional Control Technology, Inc. devices 642 * Definitions for Omnidirectional Control Technology, Inc. devices
638 */ 643 */
639 #define OCT_VID 0x0B39 /* OCT vendor ID */ 644 #define OCT_VID 0x0B39 /* OCT vendor ID */
640 /* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */ 645 /* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
641 /* Also rebadged as Dick Smith Electronics (Aus) XH6451 */ 646 /* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
642 /* Also rebadged as SIIG Inc. model US2308 hardware version 1 */ 647 /* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
643 #define OCT_DK201_PID 0x0103 /* OCT DK201 USB docking station */ 648 #define OCT_DK201_PID 0x0103 /* OCT DK201 USB docking station */
644 #define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */ 649 #define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */
645 650
646 /* 651 /*
647 * Definitions for Icom Inc. devices 652 * Definitions for Icom Inc. devices
648 */ 653 */
649 #define ICOM_VID 0x0C26 /* Icom vendor ID */ 654 #define ICOM_VID 0x0C26 /* Icom vendor ID */
650 /* Note: ID-1 is a communications tranceiver for HAM-radio operators */ 655 /* Note: ID-1 is a communications tranceiver for HAM-radio operators */
651 #define ICOM_ID_1_PID 0x0004 /* ID-1 USB to RS-232 */ 656 #define ICOM_ID_1_PID 0x0004 /* ID-1 USB to RS-232 */
652 /* Note: OPC is an Optional cable to connect an Icom Tranceiver */ 657 /* Note: OPC is an Optional cable to connect an Icom Tranceiver */
653 #define ICOM_OPC_U_UC_PID 0x0018 /* OPC-478UC, OPC-1122U cloning cable */ 658 #define ICOM_OPC_U_UC_PID 0x0018 /* OPC-478UC, OPC-1122U cloning cable */
654 /* Note: ID-RP* devices are Icom Repeater Devices for HAM-radio */ 659 /* Note: ID-RP* devices are Icom Repeater Devices for HAM-radio */
655 #define ICOM_ID_RP2C1_PID 0x0009 /* ID-RP2C Asset 1 to RS-232 */ 660 #define ICOM_ID_RP2C1_PID 0x0009 /* ID-RP2C Asset 1 to RS-232 */
656 #define ICOM_ID_RP2C2_PID 0x000A /* ID-RP2C Asset 2 to RS-232 */ 661 #define ICOM_ID_RP2C2_PID 0x000A /* ID-RP2C Asset 2 to RS-232 */
657 #define ICOM_ID_RP2D_PID 0x000B /* ID-RP2D configuration port*/ 662 #define ICOM_ID_RP2D_PID 0x000B /* ID-RP2D configuration port*/
658 #define ICOM_ID_RP2VT_PID 0x000C /* ID-RP2V Transmit config port */ 663 #define ICOM_ID_RP2VT_PID 0x000C /* ID-RP2V Transmit config port */
659 #define ICOM_ID_RP2VR_PID 0x000D /* ID-RP2V Receive config port */ 664 #define ICOM_ID_RP2VR_PID 0x000D /* ID-RP2V Receive config port */
660 #define ICOM_ID_RP4KVT_PID 0x0010 /* ID-RP4000V Transmit config port */ 665 #define ICOM_ID_RP4KVT_PID 0x0010 /* ID-RP4000V Transmit config port */
661 #define ICOM_ID_RP4KVR_PID 0x0011 /* ID-RP4000V Receive config port */ 666 #define ICOM_ID_RP4KVR_PID 0x0011 /* ID-RP4000V Receive config port */
662 #define ICOM_ID_RP2KVT_PID 0x0012 /* ID-RP2000V Transmit config port */ 667 #define ICOM_ID_RP2KVT_PID 0x0012 /* ID-RP2000V Transmit config port */
663 #define ICOM_ID_RP2KVR_PID 0x0013 /* ID-RP2000V Receive config port */ 668 #define ICOM_ID_RP2KVR_PID 0x0013 /* ID-RP2000V Receive config port */
664 669
665 /* 670 /*
666 * GN Otometrics (http://www.otometrics.com) 671 * GN Otometrics (http://www.otometrics.com)
667 * Submitted by Ville Sundberg. 672 * Submitted by Ville Sundberg.
668 */ 673 */
669 #define GN_OTOMETRICS_VID 0x0c33 /* Vendor ID */ 674 #define GN_OTOMETRICS_VID 0x0c33 /* Vendor ID */
670 #define AURICAL_USB_PID 0x0010 /* Aurical USB Audiometer */ 675 #define AURICAL_USB_PID 0x0010 /* Aurical USB Audiometer */
671 676
672 /* 677 /*
673 * The following are the values for the Sealevel SeaLINK+ adapters. 678 * The following are the values for the Sealevel SeaLINK+ adapters.
674 * (Original list sent by Tuan Hoang. Ian Abbott renamed the macros and 679 * (Original list sent by Tuan Hoang. Ian Abbott renamed the macros and
675 * removed some PIDs that don't seem to match any existing products.) 680 * removed some PIDs that don't seem to match any existing products.)
676 */ 681 */
677 #define SEALEVEL_VID 0x0c52 /* Sealevel Vendor ID */ 682 #define SEALEVEL_VID 0x0c52 /* Sealevel Vendor ID */
678 #define SEALEVEL_2101_PID 0x2101 /* SeaLINK+232 (2101/2105) */ 683 #define SEALEVEL_2101_PID 0x2101 /* SeaLINK+232 (2101/2105) */
679 #define SEALEVEL_2102_PID 0x2102 /* SeaLINK+485 (2102) */ 684 #define SEALEVEL_2102_PID 0x2102 /* SeaLINK+485 (2102) */
680 #define SEALEVEL_2103_PID 0x2103 /* SeaLINK+232I (2103) */ 685 #define SEALEVEL_2103_PID 0x2103 /* SeaLINK+232I (2103) */
681 #define SEALEVEL_2104_PID 0x2104 /* SeaLINK+485I (2104) */ 686 #define SEALEVEL_2104_PID 0x2104 /* SeaLINK+485I (2104) */
682 #define SEALEVEL_2106_PID 0x9020 /* SeaLINK+422 (2106) */ 687 #define SEALEVEL_2106_PID 0x9020 /* SeaLINK+422 (2106) */
683 #define SEALEVEL_2201_1_PID 0x2211 /* SeaPORT+2/232 (2201) Port 1 */ 688 #define SEALEVEL_2201_1_PID 0x2211 /* SeaPORT+2/232 (2201) Port 1 */
684 #define SEALEVEL_2201_2_PID 0x2221 /* SeaPORT+2/232 (2201) Port 2 */ 689 #define SEALEVEL_2201_2_PID 0x2221 /* SeaPORT+2/232 (2201) Port 2 */
685 #define SEALEVEL_2202_1_PID 0x2212 /* SeaPORT+2/485 (2202) Port 1 */ 690 #define SEALEVEL_2202_1_PID 0x2212 /* SeaPORT+2/485 (2202) Port 1 */
686 #define SEALEVEL_2202_2_PID 0x2222 /* SeaPORT+2/485 (2202) Port 2 */ 691 #define SEALEVEL_2202_2_PID 0x2222 /* SeaPORT+2/485 (2202) Port 2 */
687 #define SEALEVEL_2203_1_PID 0x2213 /* SeaPORT+2 (2203) Port 1 */ 692 #define SEALEVEL_2203_1_PID 0x2213 /* SeaPORT+2 (2203) Port 1 */
688 #define SEALEVEL_2203_2_PID 0x2223 /* SeaPORT+2 (2203) Port 2 */ 693 #define SEALEVEL_2203_2_PID 0x2223 /* SeaPORT+2 (2203) Port 2 */
689 #define SEALEVEL_2401_1_PID 0x2411 /* SeaPORT+4/232 (2401) Port 1 */ 694 #define SEALEVEL_2401_1_PID 0x2411 /* SeaPORT+4/232 (2401) Port 1 */
690 #define SEALEVEL_2401_2_PID 0x2421 /* SeaPORT+4/232 (2401) Port 2 */ 695 #define SEALEVEL_2401_2_PID 0x2421 /* SeaPORT+4/232 (2401) Port 2 */
691 #define SEALEVEL_2401_3_PID 0x2431 /* SeaPORT+4/232 (2401) Port 3 */ 696 #define SEALEVEL_2401_3_PID 0x2431 /* SeaPORT+4/232 (2401) Port 3 */
692 #define SEALEVEL_2401_4_PID 0x2441 /* SeaPORT+4/232 (2401) Port 4 */ 697 #define SEALEVEL_2401_4_PID 0x2441 /* SeaPORT+4/232 (2401) Port 4 */
693 #define SEALEVEL_2402_1_PID 0x2412 /* SeaPORT+4/485 (2402) Port 1 */ 698 #define SEALEVEL_2402_1_PID 0x2412 /* SeaPORT+4/485 (2402) Port 1 */
694 #define SEALEVEL_2402_2_PID 0x2422 /* SeaPORT+4/485 (2402) Port 2 */ 699 #define SEALEVEL_2402_2_PID 0x2422 /* SeaPORT+4/485 (2402) Port 2 */
695 #define SEALEVEL_2402_3_PID 0x2432 /* SeaPORT+4/485 (2402) Port 3 */ 700 #define SEALEVEL_2402_3_PID 0x2432 /* SeaPORT+4/485 (2402) Port 3 */
696 #define SEALEVEL_2402_4_PID 0x2442 /* SeaPORT+4/485 (2402) Port 4 */ 701 #define SEALEVEL_2402_4_PID 0x2442 /* SeaPORT+4/485 (2402) Port 4 */
697 #define SEALEVEL_2403_1_PID 0x2413 /* SeaPORT+4 (2403) Port 1 */ 702 #define SEALEVEL_2403_1_PID 0x2413 /* SeaPORT+4 (2403) Port 1 */
698 #define SEALEVEL_2403_2_PID 0x2423 /* SeaPORT+4 (2403) Port 2 */ 703 #define SEALEVEL_2403_2_PID 0x2423 /* SeaPORT+4 (2403) Port 2 */
699 #define SEALEVEL_2403_3_PID 0x2433 /* SeaPORT+4 (2403) Port 3 */ 704 #define SEALEVEL_2403_3_PID 0x2433 /* SeaPORT+4 (2403) Port 3 */
700 #define SEALEVEL_2403_4_PID 0x2443 /* SeaPORT+4 (2403) Port 4 */ 705 #define SEALEVEL_2403_4_PID 0x2443 /* SeaPORT+4 (2403) Port 4 */
701 #define SEALEVEL_2801_1_PID 0X2811 /* SeaLINK+8/232 (2801) Port 1 */ 706 #define SEALEVEL_2801_1_PID 0X2811 /* SeaLINK+8/232 (2801) Port 1 */
702 #define SEALEVEL_2801_2_PID 0X2821 /* SeaLINK+8/232 (2801) Port 2 */ 707 #define SEALEVEL_2801_2_PID 0X2821 /* SeaLINK+8/232 (2801) Port 2 */
703 #define SEALEVEL_2801_3_PID 0X2831 /* SeaLINK+8/232 (2801) Port 3 */ 708 #define SEALEVEL_2801_3_PID 0X2831 /* SeaLINK+8/232 (2801) Port 3 */
704 #define SEALEVEL_2801_4_PID 0X2841 /* SeaLINK+8/232 (2801) Port 4 */ 709 #define SEALEVEL_2801_4_PID 0X2841 /* SeaLINK+8/232 (2801) Port 4 */
705 #define SEALEVEL_2801_5_PID 0X2851 /* SeaLINK+8/232 (2801) Port 5 */ 710 #define SEALEVEL_2801_5_PID 0X2851 /* SeaLINK+8/232 (2801) Port 5 */
706 #define SEALEVEL_2801_6_PID 0X2861 /* SeaLINK+8/232 (2801) Port 6 */ 711 #define SEALEVEL_2801_6_PID 0X2861 /* SeaLINK+8/232 (2801) Port 6 */
707 #define SEALEVEL_2801_7_PID 0X2871 /* SeaLINK+8/232 (2801) Port 7 */ 712 #define SEALEVEL_2801_7_PID 0X2871 /* SeaLINK+8/232 (2801) Port 7 */
708 #define SEALEVEL_2801_8_PID 0X2881 /* SeaLINK+8/232 (2801) Port 8 */ 713 #define SEALEVEL_2801_8_PID 0X2881 /* SeaLINK+8/232 (2801) Port 8 */
709 #define SEALEVEL_2802_1_PID 0X2812 /* SeaLINK+8/485 (2802) Port 1 */ 714 #define SEALEVEL_2802_1_PID 0X2812 /* SeaLINK+8/485 (2802) Port 1 */
710 #define SEALEVEL_2802_2_PID 0X2822 /* SeaLINK+8/485 (2802) Port 2 */ 715 #define SEALEVEL_2802_2_PID 0X2822 /* SeaLINK+8/485 (2802) Port 2 */
711 #define SEALEVEL_2802_3_PID 0X2832 /* SeaLINK+8/485 (2802) Port 3 */ 716 #define SEALEVEL_2802_3_PID 0X2832 /* SeaLINK+8/485 (2802) Port 3 */
712 #define SEALEVEL_2802_4_PID 0X2842 /* SeaLINK+8/485 (2802) Port 4 */ 717 #define SEALEVEL_2802_4_PID 0X2842 /* SeaLINK+8/485 (2802) Port 4 */
713 #define SEALEVEL_2802_5_PID 0X2852 /* SeaLINK+8/485 (2802) Port 5 */ 718 #define SEALEVEL_2802_5_PID 0X2852 /* SeaLINK+8/485 (2802) Port 5 */
714 #define SEALEVEL_2802_6_PID 0X2862 /* SeaLINK+8/485 (2802) Port 6 */ 719 #define SEALEVEL_2802_6_PID 0X2862 /* SeaLINK+8/485 (2802) Port 6 */
715 #define SEALEVEL_2802_7_PID 0X2872 /* SeaLINK+8/485 (2802) Port 7 */ 720 #define SEALEVEL_2802_7_PID 0X2872 /* SeaLINK+8/485 (2802) Port 7 */
716 #define SEALEVEL_2802_8_PID 0X2882 /* SeaLINK+8/485 (2802) Port 8 */ 721 #define SEALEVEL_2802_8_PID 0X2882 /* SeaLINK+8/485 (2802) Port 8 */
717 #define SEALEVEL_2803_1_PID 0X2813 /* SeaLINK+8 (2803) Port 1 */ 722 #define SEALEVEL_2803_1_PID 0X2813 /* SeaLINK+8 (2803) Port 1 */
718 #define SEALEVEL_2803_2_PID 0X2823 /* SeaLINK+8 (2803) Port 2 */ 723 #define SEALEVEL_2803_2_PID 0X2823 /* SeaLINK+8 (2803) Port 2 */
719 #define SEALEVEL_2803_3_PID 0X2833 /* SeaLINK+8 (2803) Port 3 */ 724 #define SEALEVEL_2803_3_PID 0X2833 /* SeaLINK+8 (2803) Port 3 */
720 #define SEALEVEL_2803_4_PID 0X2843 /* SeaLINK+8 (2803) Port 4 */ 725 #define SEALEVEL_2803_4_PID 0X2843 /* SeaLINK+8 (2803) Port 4 */
721 #define SEALEVEL_2803_5_PID 0X2853 /* SeaLINK+8 (2803) Port 5 */ 726 #define SEALEVEL_2803_5_PID 0X2853 /* SeaLINK+8 (2803) Port 5 */
722 #define SEALEVEL_2803_6_PID 0X2863 /* SeaLINK+8 (2803) Port 6 */ 727 #define SEALEVEL_2803_6_PID 0X2863 /* SeaLINK+8 (2803) Port 6 */
723 #define SEALEVEL_2803_7_PID 0X2873 /* SeaLINK+8 (2803) Port 7 */ 728 #define SEALEVEL_2803_7_PID 0X2873 /* SeaLINK+8 (2803) Port 7 */
724 #define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */ 729 #define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */
725 #define SEALEVEL_2803R_1_PID 0Xa02a /* SeaLINK+8 (2803-ROHS) Port 1+2 */ 730 #define SEALEVEL_2803R_1_PID 0Xa02a /* SeaLINK+8 (2803-ROHS) Port 1+2 */
726 #define SEALEVEL_2803R_2_PID 0Xa02b /* SeaLINK+8 (2803-ROHS) Port 3+4 */ 731 #define SEALEVEL_2803R_2_PID 0Xa02b /* SeaLINK+8 (2803-ROHS) Port 3+4 */
727 #define SEALEVEL_2803R_3_PID 0Xa02c /* SeaLINK+8 (2803-ROHS) Port 5+6 */ 732 #define SEALEVEL_2803R_3_PID 0Xa02c /* SeaLINK+8 (2803-ROHS) Port 5+6 */
728 #define SEALEVEL_2803R_4_PID 0Xa02d /* SeaLINK+8 (2803-ROHS) Port 7+8 */ 733 #define SEALEVEL_2803R_4_PID 0Xa02d /* SeaLINK+8 (2803-ROHS) Port 7+8 */
729 734
730 /* 735 /*
731 * JETI SPECTROMETER SPECBOS 1201 736 * JETI SPECTROMETER SPECBOS 1201
732 * http://www.jeti.com/cms/index.php/instruments/other-instruments/specbos-2101 737 * http://www.jeti.com/cms/index.php/instruments/other-instruments/specbos-2101
733 */ 738 */
734 #define JETI_VID 0x0c6c 739 #define JETI_VID 0x0c6c
735 #define JETI_SPC1201_PID 0x04b2 740 #define JETI_SPC1201_PID 0x04b2
736 741
737 /* 742 /*
738 * FTDI USB UART chips used in construction projects from the 743 * FTDI USB UART chips used in construction projects from the
739 * Elektor Electronics magazine (http://www.elektor.com/) 744 * Elektor Electronics magazine (http://www.elektor.com/)
740 */ 745 */
741 #define ELEKTOR_VID 0x0C7D 746 #define ELEKTOR_VID 0x0C7D
742 #define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */ 747 #define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */
743 748
744 /* 749 /*
745 * Posiflex inc retail equipment (http://www.posiflex.com.tw) 750 * Posiflex inc retail equipment (http://www.posiflex.com.tw)
746 */ 751 */
747 #define POSIFLEX_VID 0x0d3a /* Vendor ID */ 752 #define POSIFLEX_VID 0x0d3a /* Vendor ID */
748 #define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */ 753 #define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */
749 754
750 /* 755 /*
751 * The following are the values for two KOBIL chipcard terminals. 756 * The following are the values for two KOBIL chipcard terminals.
752 */ 757 */
753 #define KOBIL_VID 0x0d46 /* KOBIL Vendor ID */ 758 #define KOBIL_VID 0x0d46 /* KOBIL Vendor ID */
754 #define KOBIL_CONV_B1_PID 0x2020 /* KOBIL Konverter for B1 */ 759 #define KOBIL_CONV_B1_PID 0x2020 /* KOBIL Konverter for B1 */
755 #define KOBIL_CONV_KAAN_PID 0x2021 /* KOBIL_Konverter for KAAN */ 760 #define KOBIL_CONV_KAAN_PID 0x2021 /* KOBIL_Konverter for KAAN */
756 761
757 #define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */ 762 #define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
758 #define FTDI_NF_RIC_PID 0x0001 /* Product Id */ 763 #define FTDI_NF_RIC_PID 0x0001 /* Product Id */
759 764
760 /* 765 /*
761 * Falcom Wireless Communications GmbH 766 * Falcom Wireless Communications GmbH
762 */ 767 */
763 #define FALCOM_VID 0x0F94 /* Vendor Id */ 768 #define FALCOM_VID 0x0F94 /* Vendor Id */
764 #define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */ 769 #define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */
765 #define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */ 770 #define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */
766 771
767 /* Larsen and Brusgaard AltiTrack/USBtrack */ 772 /* Larsen and Brusgaard AltiTrack/USBtrack */
768 #define LARSENBRUSGAARD_VID 0x0FD8 773 #define LARSENBRUSGAARD_VID 0x0FD8
769 #define LB_ALTITRACK_PID 0x0001 774 #define LB_ALTITRACK_PID 0x0001
770 775
771 /* 776 /*
772 * TTi (Thurlby Thandar Instruments) 777 * TTi (Thurlby Thandar Instruments)
773 */ 778 */
774 #define TTI_VID 0x103E /* Vendor Id */ 779 #define TTI_VID 0x103E /* Vendor Id */
775 #define TTI_QL355P_PID 0x03E8 /* TTi QL355P power supply */ 780 #define TTI_QL355P_PID 0x03E8 /* TTi QL355P power supply */
776 781
777 /* 782 /*
778 * Newport Cooperation (www.newport.com) 783 * Newport Cooperation (www.newport.com)
779 */ 784 */
780 #define NEWPORT_VID 0x104D 785 #define NEWPORT_VID 0x104D
781 #define NEWPORT_AGILIS_PID 0x3000 786 #define NEWPORT_AGILIS_PID 0x3000
782 #define NEWPORT_CONEX_CC_PID 0x3002 787 #define NEWPORT_CONEX_CC_PID 0x3002
783 #define NEWPORT_CONEX_AGP_PID 0x3006 788 #define NEWPORT_CONEX_AGP_PID 0x3006
784 789
785 /* Interbiometrics USB I/O Board */ 790 /* Interbiometrics USB I/O Board */
786 /* Developed for Interbiometrics by Rudolf Gugler */ 791 /* Developed for Interbiometrics by Rudolf Gugler */
787 #define INTERBIOMETRICS_VID 0x1209 792 #define INTERBIOMETRICS_VID 0x1209
788 #define INTERBIOMETRICS_IOBOARD_PID 0x1002 793 #define INTERBIOMETRICS_IOBOARD_PID 0x1002
789 #define INTERBIOMETRICS_MINI_IOBOARD_PID 0x1006 794 #define INTERBIOMETRICS_MINI_IOBOARD_PID 0x1006
790 795
791 /* 796 /*
792 * Testo products (http://www.testo.com/) 797 * Testo products (http://www.testo.com/)
793 * Submitted by Colin Leroy 798 * Submitted by Colin Leroy
794 */ 799 */
795 #define TESTO_VID 0x128D 800 #define TESTO_VID 0x128D
796 #define TESTO_USB_INTERFACE_PID 0x0001 801 #define TESTO_USB_INTERFACE_PID 0x0001
797 802
798 /* 803 /*
799 * Mobility Electronics products. 804 * Mobility Electronics products.
800 */ 805 */
801 #define MOBILITY_VID 0x1342 806 #define MOBILITY_VID 0x1342
802 #define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */ 807 #define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */
803 808
804 /* 809 /*
805 * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3 810 * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3
806 * Submitted by Harald Welte <laforge@openmoko.org> 811 * Submitted by Harald Welte <laforge@openmoko.org>
807 */ 812 */
808 #define FIC_VID 0x1457 813 #define FIC_VID 0x1457
809 #define FIC_NEO1973_DEBUG_PID 0x5118 814 #define FIC_NEO1973_DEBUG_PID 0x5118
810 815
811 /* Olimex */ 816 /* Olimex */
812 #define OLIMEX_VID 0x15BA 817 #define OLIMEX_VID 0x15BA
813 #define OLIMEX_ARM_USB_OCD_PID 0x0003 818 #define OLIMEX_ARM_USB_OCD_PID 0x0003
814 #define OLIMEX_ARM_USB_OCD_H_PID 0x002b 819 #define OLIMEX_ARM_USB_OCD_H_PID 0x002b
815 820
816 /* 821 /*
817 * Telldus Technologies 822 * Telldus Technologies
818 */ 823 */
819 #define TELLDUS_VID 0x1781 /* Vendor ID */ 824 #define TELLDUS_VID 0x1781 /* Vendor ID */
820 #define TELLDUS_TELLSTICK_PID 0x0C30 /* RF control dongle 433 MHz using FT232RL */ 825 #define TELLDUS_TELLSTICK_PID 0x0C30 /* RF control dongle 433 MHz using FT232RL */
821 826
822 /* 827 /*
823 * RT Systems programming cables for various ham radios 828 * RT Systems programming cables for various ham radios
824 */ 829 */
825 #define RTSYSTEMS_VID 0x2100 /* Vendor ID */ 830 #define RTSYSTEMS_VID 0x2100 /* Vendor ID */
826 #define RTSYSTEMS_USB_S03_PID 0x9001 /* RTS-03 USB to Serial Adapter */ 831 #define RTSYSTEMS_USB_S03_PID 0x9001 /* RTS-03 USB to Serial Adapter */
827 #define RTSYSTEMS_USB_59_PID 0x9e50 /* USB-59 USB to 8 pin plug */ 832 #define RTSYSTEMS_USB_59_PID 0x9e50 /* USB-59 USB to 8 pin plug */
828 #define RTSYSTEMS_USB_57A_PID 0x9e51 /* USB-57A USB to 4pin 3.5mm plug */ 833 #define RTSYSTEMS_USB_57A_PID 0x9e51 /* USB-57A USB to 4pin 3.5mm plug */
829 #define RTSYSTEMS_USB_57B_PID 0x9e52 /* USB-57B USB to extended 4pin 3.5mm plug */ 834 #define RTSYSTEMS_USB_57B_PID 0x9e52 /* USB-57B USB to extended 4pin 3.5mm plug */
830 #define RTSYSTEMS_USB_29A_PID 0x9e53 /* USB-29A USB to 3.5mm stereo plug */ 835 #define RTSYSTEMS_USB_29A_PID 0x9e53 /* USB-29A USB to 3.5mm stereo plug */
831 #define RTSYSTEMS_USB_29B_PID 0x9e54 /* USB-29B USB to 6 pin mini din */ 836 #define RTSYSTEMS_USB_29B_PID 0x9e54 /* USB-29B USB to 6 pin mini din */
832 #define RTSYSTEMS_USB_29F_PID 0x9e55 /* USB-29F USB to 6 pin modular plug */ 837 #define RTSYSTEMS_USB_29F_PID 0x9e55 /* USB-29F USB to 6 pin modular plug */
833 #define RTSYSTEMS_USB_62B_PID 0x9e56 /* USB-62B USB to 8 pin mini din plug*/ 838 #define RTSYSTEMS_USB_62B_PID 0x9e56 /* USB-62B USB to 8 pin mini din plug*/
834 #define RTSYSTEMS_USB_S01_PID 0x9e57 /* USB-RTS01 USB to 3.5 mm stereo plug*/ 839 #define RTSYSTEMS_USB_S01_PID 0x9e57 /* USB-RTS01 USB to 3.5 mm stereo plug*/
835 #define RTSYSTEMS_USB_63_PID 0x9e58 /* USB-63 USB to 9 pin female*/ 840 #define RTSYSTEMS_USB_63_PID 0x9e58 /* USB-63 USB to 9 pin female*/
836 #define RTSYSTEMS_USB_29C_PID 0x9e59 /* USB-29C USB to 4 pin modular plug*/ 841 #define RTSYSTEMS_USB_29C_PID 0x9e59 /* USB-29C USB to 4 pin modular plug*/
837 #define RTSYSTEMS_USB_81B_PID 0x9e5A /* USB-81 USB to 8 pin mini din plug*/ 842 #define RTSYSTEMS_USB_81B_PID 0x9e5A /* USB-81 USB to 8 pin mini din plug*/
838 #define RTSYSTEMS_USB_82B_PID 0x9e5B /* USB-82 USB to 2.5 mm stereo plug*/ 843 #define RTSYSTEMS_USB_82B_PID 0x9e5B /* USB-82 USB to 2.5 mm stereo plug*/
839 #define RTSYSTEMS_USB_K5D_PID 0x9e5C /* USB-K5D USB to 8 pin modular plug*/ 844 #define RTSYSTEMS_USB_K5D_PID 0x9e5C /* USB-K5D USB to 8 pin modular plug*/
840 #define RTSYSTEMS_USB_K4Y_PID 0x9e5D /* USB-K4Y USB to 2.5/3.5 mm plugs*/ 845 #define RTSYSTEMS_USB_K4Y_PID 0x9e5D /* USB-K4Y USB to 2.5/3.5 mm plugs*/
841 #define RTSYSTEMS_USB_K5G_PID 0x9e5E /* USB-K5G USB to 8 pin modular plug*/ 846 #define RTSYSTEMS_USB_K5G_PID 0x9e5E /* USB-K5G USB to 8 pin modular plug*/
842 #define RTSYSTEMS_USB_S05_PID 0x9e5F /* USB-RTS05 USB to 2.5 mm stereo plug*/ 847 #define RTSYSTEMS_USB_S05_PID 0x9e5F /* USB-RTS05 USB to 2.5 mm stereo plug*/
843 #define RTSYSTEMS_USB_60_PID 0x9e60 /* USB-60 USB to 6 pin din*/ 848 #define RTSYSTEMS_USB_60_PID 0x9e60 /* USB-60 USB to 6 pin din*/
844 #define RTSYSTEMS_USB_61_PID 0x9e61 /* USB-61 USB to 6 pin mini din*/ 849 #define RTSYSTEMS_USB_61_PID 0x9e61 /* USB-61 USB to 6 pin mini din*/
845 #define RTSYSTEMS_USB_62_PID 0x9e62 /* USB-62 USB to 8 pin mini din*/ 850 #define RTSYSTEMS_USB_62_PID 0x9e62 /* USB-62 USB to 8 pin mini din*/
846 #define RTSYSTEMS_USB_63B_PID 0x9e63 /* USB-63 USB to 9 pin female*/ 851 #define RTSYSTEMS_USB_63B_PID 0x9e63 /* USB-63 USB to 9 pin female*/
847 #define RTSYSTEMS_USB_64_PID 0x9e64 /* USB-64 USB to 9 pin male*/ 852 #define RTSYSTEMS_USB_64_PID 0x9e64 /* USB-64 USB to 9 pin male*/
848 #define RTSYSTEMS_USB_65_PID 0x9e65 /* USB-65 USB to 9 pin female null modem*/ 853 #define RTSYSTEMS_USB_65_PID 0x9e65 /* USB-65 USB to 9 pin female null modem*/
849 #define RTSYSTEMS_USB_92_PID 0x9e66 /* USB-92 USB to 12 pin plug*/ 854 #define RTSYSTEMS_USB_92_PID 0x9e66 /* USB-92 USB to 12 pin plug*/
850 #define RTSYSTEMS_USB_92D_PID 0x9e67 /* USB-92D USB to 12 pin plug data*/ 855 #define RTSYSTEMS_USB_92D_PID 0x9e67 /* USB-92D USB to 12 pin plug data*/
851 #define RTSYSTEMS_USB_W5R_PID 0x9e68 /* USB-W5R USB to 8 pin modular plug*/ 856 #define RTSYSTEMS_USB_W5R_PID 0x9e68 /* USB-W5R USB to 8 pin modular plug*/
852 #define RTSYSTEMS_USB_A5R_PID 0x9e69 /* USB-A5R USB to 8 pin modular plug*/ 857 #define RTSYSTEMS_USB_A5R_PID 0x9e69 /* USB-A5R USB to 8 pin modular plug*/
853 #define RTSYSTEMS_USB_PW1_PID 0x9e6A /* USB-PW1 USB to 8 pin modular plug*/ 858 #define RTSYSTEMS_USB_PW1_PID 0x9e6A /* USB-PW1 USB to 8 pin modular plug*/
854 859
855 /* 860 /*
856 * Physik Instrumente 861 * Physik Instrumente
857 * http://www.physikinstrumente.com/en/products/ 862 * http://www.physikinstrumente.com/en/products/
858 */ 863 */
859 /* These two devices use the VID of FTDI */ 864 /* These two devices use the VID of FTDI */
860 #define PI_C865_PID 0xe0a0 /* PI C-865 Piezomotor Controller */ 865 #define PI_C865_PID 0xe0a0 /* PI C-865 Piezomotor Controller */
861 #define PI_C857_PID 0xe0a1 /* PI Encoder Trigger Box */ 866 #define PI_C857_PID 0xe0a1 /* PI Encoder Trigger Box */
862 867
863 #define PI_VID 0x1a72 /* Vendor ID */ 868 #define PI_VID 0x1a72 /* Vendor ID */
864 #define PI_C866_PID 0x1000 /* PI C-866 Piezomotor Controller */ 869 #define PI_C866_PID 0x1000 /* PI C-866 Piezomotor Controller */
865 #define PI_C663_PID 0x1001 /* PI C-663 Mercury-Step */ 870 #define PI_C663_PID 0x1001 /* PI C-663 Mercury-Step */
866 #define PI_C725_PID 0x1002 /* PI C-725 Piezomotor Controller */ 871 #define PI_C725_PID 0x1002 /* PI C-725 Piezomotor Controller */
867 #define PI_E517_PID 0x1005 /* PI E-517 Digital Piezo Controller Operation Module */ 872 #define PI_E517_PID 0x1005 /* PI E-517 Digital Piezo Controller Operation Module */
868 #define PI_C863_PID 0x1007 /* PI C-863 */ 873 #define PI_C863_PID 0x1007 /* PI C-863 */
869 #define PI_E861_PID 0x1008 /* PI E-861 Piezomotor Controller */ 874 #define PI_E861_PID 0x1008 /* PI E-861 Piezomotor Controller */
870 #define PI_C867_PID 0x1009 /* PI C-867 Piezomotor Controller */ 875 #define PI_C867_PID 0x1009 /* PI C-867 Piezomotor Controller */
871 #define PI_E609_PID 0x100D /* PI E-609 Digital Piezo Controller */ 876 #define PI_E609_PID 0x100D /* PI E-609 Digital Piezo Controller */
872 #define PI_E709_PID 0x100E /* PI E-709 Digital Piezo Controller */ 877 #define PI_E709_PID 0x100E /* PI E-709 Digital Piezo Controller */
873 #define PI_100F_PID 0x100F /* PI Digital Piezo Controller */ 878 #define PI_100F_PID 0x100F /* PI Digital Piezo Controller */
874 #define PI_1011_PID 0x1011 /* PI Digital Piezo Controller */ 879 #define PI_1011_PID 0x1011 /* PI Digital Piezo Controller */
875 #define PI_1012_PID 0x1012 /* PI Motion Controller */ 880 #define PI_1012_PID 0x1012 /* PI Motion Controller */
876 #define PI_1013_PID 0x1013 /* PI Motion Controller */ 881 #define PI_1013_PID 0x1013 /* PI Motion Controller */
877 #define PI_1014_PID 0x1014 /* PI Device */ 882 #define PI_1014_PID 0x1014 /* PI Device */
878 #define PI_1015_PID 0x1015 /* PI Device */ 883 #define PI_1015_PID 0x1015 /* PI Device */
879 #define PI_1016_PID 0x1016 /* PI Digital Servo Module */ 884 #define PI_1016_PID 0x1016 /* PI Digital Servo Module */
880 885
881 /* 886 /*
882 * Kondo Kagaku Co.Ltd. 887 * Kondo Kagaku Co.Ltd.
883 * http://www.kondo-robot.com/EN 888 * http://www.kondo-robot.com/EN
884 */ 889 */
885 #define KONDO_VID 0x165c 890 #define KONDO_VID 0x165c
886 #define KONDO_USB_SERIAL_PID 0x0002 891 #define KONDO_USB_SERIAL_PID 0x0002
887 892
888 /* 893 /*
889 * Bayer Ascensia Contour blood glucose meter USB-converter cable. 894 * Bayer Ascensia Contour blood glucose meter USB-converter cable.
890 * http://winglucofacts.com/cables/ 895 * http://winglucofacts.com/cables/
891 */ 896 */
892 #define BAYER_VID 0x1A79 897 #define BAYER_VID 0x1A79
893 #define BAYER_CONTOUR_CABLE_PID 0x6001 898 #define BAYER_CONTOUR_CABLE_PID 0x6001
894 899
895 /* 900 /*
896 * The following are the values for the Matrix Orbital FTDI Range 901 * The following are the values for the Matrix Orbital FTDI Range
897 * Anything in this range will use an FT232RL. 902 * Anything in this range will use an FT232RL.
898 */ 903 */
899 #define MTXORB_VID 0x1B3D 904 #define MTXORB_VID 0x1B3D
900 #define MTXORB_FTDI_RANGE_0100_PID 0x0100 905 #define MTXORB_FTDI_RANGE_0100_PID 0x0100
901 #define MTXORB_FTDI_RANGE_0101_PID 0x0101 906 #define MTXORB_FTDI_RANGE_0101_PID 0x0101
902 #define MTXORB_FTDI_RANGE_0102_PID 0x0102 907 #define MTXORB_FTDI_RANGE_0102_PID 0x0102
903 #define MTXORB_FTDI_RANGE_0103_PID 0x0103 908 #define MTXORB_FTDI_RANGE_0103_PID 0x0103
904 #define MTXORB_FTDI_RANGE_0104_PID 0x0104 909 #define MTXORB_FTDI_RANGE_0104_PID 0x0104
905 #define MTXORB_FTDI_RANGE_0105_PID 0x0105 910 #define MTXORB_FTDI_RANGE_0105_PID 0x0105
906 #define MTXORB_FTDI_RANGE_0106_PID 0x0106 911 #define MTXORB_FTDI_RANGE_0106_PID 0x0106
907 #define MTXORB_FTDI_RANGE_0107_PID 0x0107 912 #define MTXORB_FTDI_RANGE_0107_PID 0x0107
908 #define MTXORB_FTDI_RANGE_0108_PID 0x0108 913 #define MTXORB_FTDI_RANGE_0108_PID 0x0108
909 #define MTXORB_FTDI_RANGE_0109_PID 0x0109 914 #define MTXORB_FTDI_RANGE_0109_PID 0x0109
910 #define MTXORB_FTDI_RANGE_010A_PID 0x010A 915 #define MTXORB_FTDI_RANGE_010A_PID 0x010A
911 #define MTXORB_FTDI_RANGE_010B_PID 0x010B 916 #define MTXORB_FTDI_RANGE_010B_PID 0x010B
912 #define MTXORB_FTDI_RANGE_010C_PID 0x010C 917 #define MTXORB_FTDI_RANGE_010C_PID 0x010C
913 #define MTXORB_FTDI_RANGE_010D_PID 0x010D 918 #define MTXORB_FTDI_RANGE_010D_PID 0x010D
914 #define MTXORB_FTDI_RANGE_010E_PID 0x010E 919 #define MTXORB_FTDI_RANGE_010E_PID 0x010E
915 #define MTXORB_FTDI_RANGE_010F_PID 0x010F 920 #define MTXORB_FTDI_RANGE_010F_PID 0x010F
916 #define MTXORB_FTDI_RANGE_0110_PID 0x0110 921 #define MTXORB_FTDI_RANGE_0110_PID 0x0110
917 #define MTXORB_FTDI_RANGE_0111_PID 0x0111 922 #define MTXORB_FTDI_RANGE_0111_PID 0x0111
918 #define MTXORB_FTDI_RANGE_0112_PID 0x0112 923 #define MTXORB_FTDI_RANGE_0112_PID 0x0112
919 #define MTXORB_FTDI_RANGE_0113_PID 0x0113 924 #define MTXORB_FTDI_RANGE_0113_PID 0x0113
920 #define MTXORB_FTDI_RANGE_0114_PID 0x0114 925 #define MTXORB_FTDI_RANGE_0114_PID 0x0114
921 #define MTXORB_FTDI_RANGE_0115_PID 0x0115 926 #define MTXORB_FTDI_RANGE_0115_PID 0x0115
922 #define MTXORB_FTDI_RANGE_0116_PID 0x0116 927 #define MTXORB_FTDI_RANGE_0116_PID 0x0116
923 #define MTXORB_FTDI_RANGE_0117_PID 0x0117 928 #define MTXORB_FTDI_RANGE_0117_PID 0x0117
924 #define MTXORB_FTDI_RANGE_0118_PID 0x0118 929 #define MTXORB_FTDI_RANGE_0118_PID 0x0118
925 #define MTXORB_FTDI_RANGE_0119_PID 0x0119 930 #define MTXORB_FTDI_RANGE_0119_PID 0x0119
926 #define MTXORB_FTDI_RANGE_011A_PID 0x011A 931 #define MTXORB_FTDI_RANGE_011A_PID 0x011A
927 #define MTXORB_FTDI_RANGE_011B_PID 0x011B 932 #define MTXORB_FTDI_RANGE_011B_PID 0x011B
928 #define MTXORB_FTDI_RANGE_011C_PID 0x011C 933 #define MTXORB_FTDI_RANGE_011C_PID 0x011C
929 #define MTXORB_FTDI_RANGE_011D_PID 0x011D 934 #define MTXORB_FTDI_RANGE_011D_PID 0x011D
930 #define MTXORB_FTDI_RANGE_011E_PID 0x011E 935 #define MTXORB_FTDI_RANGE_011E_PID 0x011E
931 #define MTXORB_FTDI_RANGE_011F_PID 0x011F 936 #define MTXORB_FTDI_RANGE_011F_PID 0x011F
932 #define MTXORB_FTDI_RANGE_0120_PID 0x0120 937 #define MTXORB_FTDI_RANGE_0120_PID 0x0120
933 #define MTXORB_FTDI_RANGE_0121_PID 0x0121 938 #define MTXORB_FTDI_RANGE_0121_PID 0x0121
934 #define MTXORB_FTDI_RANGE_0122_PID 0x0122 939 #define MTXORB_FTDI_RANGE_0122_PID 0x0122
935 #define MTXORB_FTDI_RANGE_0123_PID 0x0123 940 #define MTXORB_FTDI_RANGE_0123_PID 0x0123
936 #define MTXORB_FTDI_RANGE_0124_PID 0x0124 941 #define MTXORB_FTDI_RANGE_0124_PID 0x0124
937 #define MTXORB_FTDI_RANGE_0125_PID 0x0125 942 #define MTXORB_FTDI_RANGE_0125_PID 0x0125
938 #define MTXORB_FTDI_RANGE_0126_PID 0x0126 943 #define MTXORB_FTDI_RANGE_0126_PID 0x0126
939 #define MTXORB_FTDI_RANGE_0127_PID 0x0127 944 #define MTXORB_FTDI_RANGE_0127_PID 0x0127
940 #define MTXORB_FTDI_RANGE_0128_PID 0x0128 945 #define MTXORB_FTDI_RANGE_0128_PID 0x0128
941 #define MTXORB_FTDI_RANGE_0129_PID 0x0129 946 #define MTXORB_FTDI_RANGE_0129_PID 0x0129
942 #define MTXORB_FTDI_RANGE_012A_PID 0x012A 947 #define MTXORB_FTDI_RANGE_012A_PID 0x012A
943 #define MTXORB_FTDI_RANGE_012B_PID 0x012B 948 #define MTXORB_FTDI_RANGE_012B_PID 0x012B
944 #define MTXORB_FTDI_RANGE_012C_PID 0x012C 949 #define MTXORB_FTDI_RANGE_012C_PID 0x012C
945 #define MTXORB_FTDI_RANGE_012D_PID 0x012D 950 #define MTXORB_FTDI_RANGE_012D_PID 0x012D
946 #define MTXORB_FTDI_RANGE_012E_PID 0x012E 951 #define MTXORB_FTDI_RANGE_012E_PID 0x012E
947 #define MTXORB_FTDI_RANGE_012F_PID 0x012F 952 #define MTXORB_FTDI_RANGE_012F_PID 0x012F
948 #define MTXORB_FTDI_RANGE_0130_PID 0x0130 953 #define MTXORB_FTDI_RANGE_0130_PID 0x0130
949 #define MTXORB_FTDI_RANGE_0131_PID 0x0131 954 #define MTXORB_FTDI_RANGE_0131_PID 0x0131
950 #define MTXORB_FTDI_RANGE_0132_PID 0x0132 955 #define MTXORB_FTDI_RANGE_0132_PID 0x0132
951 #define MTXORB_FTDI_RANGE_0133_PID 0x0133 956 #define MTXORB_FTDI_RANGE_0133_PID 0x0133
952 #define MTXORB_FTDI_RANGE_0134_PID 0x0134 957 #define MTXORB_FTDI_RANGE_0134_PID 0x0134
953 #define MTXORB_FTDI_RANGE_0135_PID 0x0135 958 #define MTXORB_FTDI_RANGE_0135_PID 0x0135
954 #define MTXORB_FTDI_RANGE_0136_PID 0x0136 959 #define MTXORB_FTDI_RANGE_0136_PID 0x0136
955 #define MTXORB_FTDI_RANGE_0137_PID 0x0137 960 #define MTXORB_FTDI_RANGE_0137_PID 0x0137
956 #define MTXORB_FTDI_RANGE_0138_PID 0x0138 961 #define MTXORB_FTDI_RANGE_0138_PID 0x0138
957 #define MTXORB_FTDI_RANGE_0139_PID 0x0139 962 #define MTXORB_FTDI_RANGE_0139_PID 0x0139
958 #define MTXORB_FTDI_RANGE_013A_PID 0x013A 963 #define MTXORB_FTDI_RANGE_013A_PID 0x013A
959 #define MTXORB_FTDI_RANGE_013B_PID 0x013B 964 #define MTXORB_FTDI_RANGE_013B_PID 0x013B
960 #define MTXORB_FTDI_RANGE_013C_PID 0x013C 965 #define MTXORB_FTDI_RANGE_013C_PID 0x013C
961 #define MTXORB_FTDI_RANGE_013D_PID 0x013D 966 #define MTXORB_FTDI_RANGE_013D_PID 0x013D
962 #define MTXORB_FTDI_RANGE_013E_PID 0x013E 967 #define MTXORB_FTDI_RANGE_013E_PID 0x013E
963 #define MTXORB_FTDI_RANGE_013F_PID 0x013F 968 #define MTXORB_FTDI_RANGE_013F_PID 0x013F
964 #define MTXORB_FTDI_RANGE_0140_PID 0x0140 969 #define MTXORB_FTDI_RANGE_0140_PID 0x0140
965 #define MTXORB_FTDI_RANGE_0141_PID 0x0141 970 #define MTXORB_FTDI_RANGE_0141_PID 0x0141
966 #define MTXORB_FTDI_RANGE_0142_PID 0x0142 971 #define MTXORB_FTDI_RANGE_0142_PID 0x0142
967 #define MTXORB_FTDI_RANGE_0143_PID 0x0143 972 #define MTXORB_FTDI_RANGE_0143_PID 0x0143
968 #define MTXORB_FTDI_RANGE_0144_PID 0x0144 973 #define MTXORB_FTDI_RANGE_0144_PID 0x0144
969 #define MTXORB_FTDI_RANGE_0145_PID 0x0145 974 #define MTXORB_FTDI_RANGE_0145_PID 0x0145
970 #define MTXORB_FTDI_RANGE_0146_PID 0x0146 975 #define MTXORB_FTDI_RANGE_0146_PID 0x0146
971 #define MTXORB_FTDI_RANGE_0147_PID 0x0147 976 #define MTXORB_FTDI_RANGE_0147_PID 0x0147
972 #define MTXORB_FTDI_RANGE_0148_PID 0x0148 977 #define MTXORB_FTDI_RANGE_0148_PID 0x0148
973 #define MTXORB_FTDI_RANGE_0149_PID 0x0149 978 #define MTXORB_FTDI_RANGE_0149_PID 0x0149
974 #define MTXORB_FTDI_RANGE_014A_PID 0x014A 979 #define MTXORB_FTDI_RANGE_014A_PID 0x014A
975 #define MTXORB_FTDI_RANGE_014B_PID 0x014B 980 #define MTXORB_FTDI_RANGE_014B_PID 0x014B
976 #define MTXORB_FTDI_RANGE_014C_PID 0x014C 981 #define MTXORB_FTDI_RANGE_014C_PID 0x014C
977 #define MTXORB_FTDI_RANGE_014D_PID 0x014D 982 #define MTXORB_FTDI_RANGE_014D_PID 0x014D
978 #define MTXORB_FTDI_RANGE_014E_PID 0x014E 983 #define MTXORB_FTDI_RANGE_014E_PID 0x014E
979 #define MTXORB_FTDI_RANGE_014F_PID 0x014F 984 #define MTXORB_FTDI_RANGE_014F_PID 0x014F
980 #define MTXORB_FTDI_RANGE_0150_PID 0x0150 985 #define MTXORB_FTDI_RANGE_0150_PID 0x0150
981 #define MTXORB_FTDI_RANGE_0151_PID 0x0151 986 #define MTXORB_FTDI_RANGE_0151_PID 0x0151
982 #define MTXORB_FTDI_RANGE_0152_PID 0x0152 987 #define MTXORB_FTDI_RANGE_0152_PID 0x0152
983 #define MTXORB_FTDI_RANGE_0153_PID 0x0153 988 #define MTXORB_FTDI_RANGE_0153_PID 0x0153
984 #define MTXORB_FTDI_RANGE_0154_PID 0x0154 989 #define MTXORB_FTDI_RANGE_0154_PID 0x0154
985 #define MTXORB_FTDI_RANGE_0155_PID 0x0155 990 #define MTXORB_FTDI_RANGE_0155_PID 0x0155
986 #define MTXORB_FTDI_RANGE_0156_PID 0x0156 991 #define MTXORB_FTDI_RANGE_0156_PID 0x0156
987 #define MTXORB_FTDI_RANGE_0157_PID 0x0157 992 #define MTXORB_FTDI_RANGE_0157_PID 0x0157
988 #define MTXORB_FTDI_RANGE_0158_PID 0x0158 993 #define MTXORB_FTDI_RANGE_0158_PID 0x0158
989 #define MTXORB_FTDI_RANGE_0159_PID 0x0159 994 #define MTXORB_FTDI_RANGE_0159_PID 0x0159
990 #define MTXORB_FTDI_RANGE_015A_PID 0x015A 995 #define MTXORB_FTDI_RANGE_015A_PID 0x015A
991 #define MTXORB_FTDI_RANGE_015B_PID 0x015B 996 #define MTXORB_FTDI_RANGE_015B_PID 0x015B
992 #define MTXORB_FTDI_RANGE_015C_PID 0x015C 997 #define MTXORB_FTDI_RANGE_015C_PID 0x015C
993 #define MTXORB_FTDI_RANGE_015D_PID 0x015D 998 #define MTXORB_FTDI_RANGE_015D_PID 0x015D
994 #define MTXORB_FTDI_RANGE_015E_PID 0x015E 999 #define MTXORB_FTDI_RANGE_015E_PID 0x015E
995 #define MTXORB_FTDI_RANGE_015F_PID 0x015F 1000 #define MTXORB_FTDI_RANGE_015F_PID 0x015F
996 #define MTXORB_FTDI_RANGE_0160_PID 0x0160 1001 #define MTXORB_FTDI_RANGE_0160_PID 0x0160
997 #define MTXORB_FTDI_RANGE_0161_PID 0x0161 1002 #define MTXORB_FTDI_RANGE_0161_PID 0x0161
998 #define MTXORB_FTDI_RANGE_0162_PID 0x0162 1003 #define MTXORB_FTDI_RANGE_0162_PID 0x0162
999 #define MTXORB_FTDI_RANGE_0163_PID 0x0163 1004 #define MTXORB_FTDI_RANGE_0163_PID 0x0163
1000 #define MTXORB_FTDI_RANGE_0164_PID 0x0164 1005 #define MTXORB_FTDI_RANGE_0164_PID 0x0164
1001 #define MTXORB_FTDI_RANGE_0165_PID 0x0165 1006 #define MTXORB_FTDI_RANGE_0165_PID 0x0165
1002 #define MTXORB_FTDI_RANGE_0166_PID 0x0166 1007 #define MTXORB_FTDI_RANGE_0166_PID 0x0166
1003 #define MTXORB_FTDI_RANGE_0167_PID 0x0167 1008 #define MTXORB_FTDI_RANGE_0167_PID 0x0167
1004 #define MTXORB_FTDI_RANGE_0168_PID 0x0168 1009 #define MTXORB_FTDI_RANGE_0168_PID 0x0168
1005 #define MTXORB_FTDI_RANGE_0169_PID 0x0169 1010 #define MTXORB_FTDI_RANGE_0169_PID 0x0169
1006 #define MTXORB_FTDI_RANGE_016A_PID 0x016A 1011 #define MTXORB_FTDI_RANGE_016A_PID 0x016A
1007 #define MTXORB_FTDI_RANGE_016B_PID 0x016B 1012 #define MTXORB_FTDI_RANGE_016B_PID 0x016B
1008 #define MTXORB_FTDI_RANGE_016C_PID 0x016C 1013 #define MTXORB_FTDI_RANGE_016C_PID 0x016C
1009 #define MTXORB_FTDI_RANGE_016D_PID 0x016D 1014 #define MTXORB_FTDI_RANGE_016D_PID 0x016D
1010 #define MTXORB_FTDI_RANGE_016E_PID 0x016E 1015 #define MTXORB_FTDI_RANGE_016E_PID 0x016E
1011 #define MTXORB_FTDI_RANGE_016F_PID 0x016F 1016 #define MTXORB_FTDI_RANGE_016F_PID 0x016F
1012 #define MTXORB_FTDI_RANGE_0170_PID 0x0170 1017 #define MTXORB_FTDI_RANGE_0170_PID 0x0170
1013 #define MTXORB_FTDI_RANGE_0171_PID 0x0171 1018 #define MTXORB_FTDI_RANGE_0171_PID 0x0171
1014 #define MTXORB_FTDI_RANGE_0172_PID 0x0172 1019 #define MTXORB_FTDI_RANGE_0172_PID 0x0172
1015 #define MTXORB_FTDI_RANGE_0173_PID 0x0173 1020 #define MTXORB_FTDI_RANGE_0173_PID 0x0173
1016 #define MTXORB_FTDI_RANGE_0174_PID 0x0174 1021 #define MTXORB_FTDI_RANGE_0174_PID 0x0174
1017 #define MTXORB_FTDI_RANGE_0175_PID 0x0175 1022 #define MTXORB_FTDI_RANGE_0175_PID 0x0175
1018 #define MTXORB_FTDI_RANGE_0176_PID 0x0176 1023 #define MTXORB_FTDI_RANGE_0176_PID 0x0176
1019 #define MTXORB_FTDI_RANGE_0177_PID 0x0177 1024 #define MTXORB_FTDI_RANGE_0177_PID 0x0177
1020 #define MTXORB_FTDI_RANGE_0178_PID 0x0178 1025 #define MTXORB_FTDI_RANGE_0178_PID 0x0178
1021 #define MTXORB_FTDI_RANGE_0179_PID 0x0179 1026 #define MTXORB_FTDI_RANGE_0179_PID 0x0179
1022 #define MTXORB_FTDI_RANGE_017A_PID 0x017A 1027 #define MTXORB_FTDI_RANGE_017A_PID 0x017A
1023 #define MTXORB_FTDI_RANGE_017B_PID 0x017B 1028 #define MTXORB_FTDI_RANGE_017B_PID 0x017B
1024 #define MTXORB_FTDI_RANGE_017C_PID 0x017C 1029 #define MTXORB_FTDI_RANGE_017C_PID 0x017C
1025 #define MTXORB_FTDI_RANGE_017D_PID 0x017D 1030 #define MTXORB_FTDI_RANGE_017D_PID 0x017D
1026 #define MTXORB_FTDI_RANGE_017E_PID 0x017E 1031 #define MTXORB_FTDI_RANGE_017E_PID 0x017E
1027 #define MTXORB_FTDI_RANGE_017F_PID 0x017F 1032 #define MTXORB_FTDI_RANGE_017F_PID 0x017F
1028 #define MTXORB_FTDI_RANGE_0180_PID 0x0180 1033 #define MTXORB_FTDI_RANGE_0180_PID 0x0180
1029 #define MTXORB_FTDI_RANGE_0181_PID 0x0181 1034 #define MTXORB_FTDI_RANGE_0181_PID 0x0181
1030 #define MTXORB_FTDI_RANGE_0182_PID 0x0182 1035 #define MTXORB_FTDI_RANGE_0182_PID 0x0182
1031 #define MTXORB_FTDI_RANGE_0183_PID 0x0183 1036 #define MTXORB_FTDI_RANGE_0183_PID 0x0183
1032 #define MTXORB_FTDI_RANGE_0184_PID 0x0184 1037 #define MTXORB_FTDI_RANGE_0184_PID 0x0184
1033 #define MTXORB_FTDI_RANGE_0185_PID 0x0185 1038 #define MTXORB_FTDI_RANGE_0185_PID 0x0185
1034 #define MTXORB_FTDI_RANGE_0186_PID 0x0186 1039 #define MTXORB_FTDI_RANGE_0186_PID 0x0186
1035 #define MTXORB_FTDI_RANGE_0187_PID 0x0187 1040 #define MTXORB_FTDI_RANGE_0187_PID 0x0187
1036 #define MTXORB_FTDI_RANGE_0188_PID 0x0188 1041 #define MTXORB_FTDI_RANGE_0188_PID 0x0188
1037 #define MTXORB_FTDI_RANGE_0189_PID 0x0189 1042 #define MTXORB_FTDI_RANGE_0189_PID 0x0189
1038 #define MTXORB_FTDI_RANGE_018A_PID 0x018A 1043 #define MTXORB_FTDI_RANGE_018A_PID 0x018A
1039 #define MTXORB_FTDI_RANGE_018B_PID 0x018B 1044 #define MTXORB_FTDI_RANGE_018B_PID 0x018B
1040 #define MTXORB_FTDI_RANGE_018C_PID 0x018C 1045 #define MTXORB_FTDI_RANGE_018C_PID 0x018C
1041 #define MTXORB_FTDI_RANGE_018D_PID 0x018D 1046 #define MTXORB_FTDI_RANGE_018D_PID 0x018D
1042 #define MTXORB_FTDI_RANGE_018E_PID 0x018E 1047 #define MTXORB_FTDI_RANGE_018E_PID 0x018E
1043 #define MTXORB_FTDI_RANGE_018F_PID 0x018F 1048 #define MTXORB_FTDI_RANGE_018F_PID 0x018F
1044 #define MTXORB_FTDI_RANGE_0190_PID 0x0190 1049 #define MTXORB_FTDI_RANGE_0190_PID 0x0190
1045 #define MTXORB_FTDI_RANGE_0191_PID 0x0191 1050 #define MTXORB_FTDI_RANGE_0191_PID 0x0191
1046 #define MTXORB_FTDI_RANGE_0192_PID 0x0192 1051 #define MTXORB_FTDI_RANGE_0192_PID 0x0192
1047 #define MTXORB_FTDI_RANGE_0193_PID 0x0193 1052 #define MTXORB_FTDI_RANGE_0193_PID 0x0193
1048 #define MTXORB_FTDI_RANGE_0194_PID 0x0194 1053 #define MTXORB_FTDI_RANGE_0194_PID 0x0194
1049 #define MTXORB_FTDI_RANGE_0195_PID 0x0195 1054 #define MTXORB_FTDI_RANGE_0195_PID 0x0195
1050 #define MTXORB_FTDI_RANGE_0196_PID 0x0196 1055 #define MTXORB_FTDI_RANGE_0196_PID 0x0196
1051 #define MTXORB_FTDI_RANGE_0197_PID 0x0197 1056 #define MTXORB_FTDI_RANGE_0197_PID 0x0197
1052 #define MTXORB_FTDI_RANGE_0198_PID 0x0198 1057 #define MTXORB_FTDI_RANGE_0198_PID 0x0198
1053 #define MTXORB_FTDI_RANGE_0199_PID 0x0199 1058 #define MTXORB_FTDI_RANGE_0199_PID 0x0199
1054 #define MTXORB_FTDI_RANGE_019A_PID 0x019A 1059 #define MTXORB_FTDI_RANGE_019A_PID 0x019A
1055 #define MTXORB_FTDI_RANGE_019B_PID 0x019B 1060 #define MTXORB_FTDI_RANGE_019B_PID 0x019B
1056 #define MTXORB_FTDI_RANGE_019C_PID 0x019C 1061 #define MTXORB_FTDI_RANGE_019C_PID 0x019C
1057 #define MTXORB_FTDI_RANGE_019D_PID 0x019D 1062 #define MTXORB_FTDI_RANGE_019D_PID 0x019D
1058 #define MTXORB_FTDI_RANGE_019E_PID 0x019E 1063 #define MTXORB_FTDI_RANGE_019E_PID 0x019E
1059 #define MTXORB_FTDI_RANGE_019F_PID 0x019F 1064 #define MTXORB_FTDI_RANGE_019F_PID 0x019F
1060 #define MTXORB_FTDI_RANGE_01A0_PID 0x01A0 1065 #define MTXORB_FTDI_RANGE_01A0_PID 0x01A0
1061 #define MTXORB_FTDI_RANGE_01A1_PID 0x01A1 1066 #define MTXORB_FTDI_RANGE_01A1_PID 0x01A1
1062 #define MTXORB_FTDI_RANGE_01A2_PID 0x01A2 1067 #define MTXORB_FTDI_RANGE_01A2_PID 0x01A2
1063 #define MTXORB_FTDI_RANGE_01A3_PID 0x01A3 1068 #define MTXORB_FTDI_RANGE_01A3_PID 0x01A3
1064 #define MTXORB_FTDI_RANGE_01A4_PID 0x01A4 1069 #define MTXORB_FTDI_RANGE_01A4_PID 0x01A4
1065 #define MTXORB_FTDI_RANGE_01A5_PID 0x01A5 1070 #define MTXORB_FTDI_RANGE_01A5_PID 0x01A5
1066 #define MTXORB_FTDI_RANGE_01A6_PID 0x01A6 1071 #define MTXORB_FTDI_RANGE_01A6_PID 0x01A6
1067 #define MTXORB_FTDI_RANGE_01A7_PID 0x01A7 1072 #define MTXORB_FTDI_RANGE_01A7_PID 0x01A7
1068 #define MTXORB_FTDI_RANGE_01A8_PID 0x01A8 1073 #define MTXORB_FTDI_RANGE_01A8_PID 0x01A8
1069 #define MTXORB_FTDI_RANGE_01A9_PID 0x01A9 1074 #define MTXORB_FTDI_RANGE_01A9_PID 0x01A9
1070 #define MTXORB_FTDI_RANGE_01AA_PID 0x01AA 1075 #define MTXORB_FTDI_RANGE_01AA_PID 0x01AA
1071 #define MTXORB_FTDI_RANGE_01AB_PID 0x01AB 1076 #define MTXORB_FTDI_RANGE_01AB_PID 0x01AB
1072 #define MTXORB_FTDI_RANGE_01AC_PID 0x01AC 1077 #define MTXORB_FTDI_RANGE_01AC_PID 0x01AC
1073 #define MTXORB_FTDI_RANGE_01AD_PID 0x01AD 1078 #define MTXORB_FTDI_RANGE_01AD_PID 0x01AD
1074 #define MTXORB_FTDI_RANGE_01AE_PID 0x01AE 1079 #define MTXORB_FTDI_RANGE_01AE_PID 0x01AE
1075 #define MTXORB_FTDI_RANGE_01AF_PID 0x01AF 1080 #define MTXORB_FTDI_RANGE_01AF_PID 0x01AF
1076 #define MTXORB_FTDI_RANGE_01B0_PID 0x01B0 1081 #define MTXORB_FTDI_RANGE_01B0_PID 0x01B0
1077 #define MTXORB_FTDI_RANGE_01B1_PID 0x01B1 1082 #define MTXORB_FTDI_RANGE_01B1_PID 0x01B1
1078 #define MTXORB_FTDI_RANGE_01B2_PID 0x01B2 1083 #define MTXORB_FTDI_RANGE_01B2_PID 0x01B2
1079 #define MTXORB_FTDI_RANGE_01B3_PID 0x01B3 1084 #define MTXORB_FTDI_RANGE_01B3_PID 0x01B3
1080 #define MTXORB_FTDI_RANGE_01B4_PID 0x01B4 1085 #define MTXORB_FTDI_RANGE_01B4_PID 0x01B4
1081 #define MTXORB_FTDI_RANGE_01B5_PID 0x01B5 1086 #define MTXORB_FTDI_RANGE_01B5_PID 0x01B5
1082 #define MTXORB_FTDI_RANGE_01B6_PID 0x01B6 1087 #define MTXORB_FTDI_RANGE_01B6_PID 0x01B6
1083 #define MTXORB_FTDI_RANGE_01B7_PID 0x01B7 1088 #define MTXORB_FTDI_RANGE_01B7_PID 0x01B7
1084 #define MTXORB_FTDI_RANGE_01B8_PID 0x01B8 1089 #define MTXORB_FTDI_RANGE_01B8_PID 0x01B8
1085 #define MTXORB_FTDI_RANGE_01B9_PID 0x01B9 1090 #define MTXORB_FTDI_RANGE_01B9_PID 0x01B9
1086 #define MTXORB_FTDI_RANGE_01BA_PID 0x01BA 1091 #define MTXORB_FTDI_RANGE_01BA_PID 0x01BA
1087 #define MTXORB_FTDI_RANGE_01BB_PID 0x01BB 1092 #define MTXORB_FTDI_RANGE_01BB_PID 0x01BB
1088 #define MTXORB_FTDI_RANGE_01BC_PID 0x01BC 1093 #define MTXORB_FTDI_RANGE_01BC_PID 0x01BC
1089 #define MTXORB_FTDI_RANGE_01BD_PID 0x01BD 1094 #define MTXORB_FTDI_RANGE_01BD_PID 0x01BD
1090 #define MTXORB_FTDI_RANGE_01BE_PID 0x01BE 1095 #define MTXORB_FTDI_RANGE_01BE_PID 0x01BE
1091 #define MTXORB_FTDI_RANGE_01BF_PID 0x01BF 1096 #define MTXORB_FTDI_RANGE_01BF_PID 0x01BF
1092 #define MTXORB_FTDI_RANGE_01C0_PID 0x01C0 1097 #define MTXORB_FTDI_RANGE_01C0_PID 0x01C0
1093 #define MTXORB_FTDI_RANGE_01C1_PID 0x01C1 1098 #define MTXORB_FTDI_RANGE_01C1_PID 0x01C1
1094 #define MTXORB_FTDI_RANGE_01C2_PID 0x01C2 1099 #define MTXORB_FTDI_RANGE_01C2_PID 0x01C2
1095 #define MTXORB_FTDI_RANGE_01C3_PID 0x01C3 1100 #define MTXORB_FTDI_RANGE_01C3_PID 0x01C3
1096 #define MTXORB_FTDI_RANGE_01C4_PID 0x01C4 1101 #define MTXORB_FTDI_RANGE_01C4_PID 0x01C4
1097 #define MTXORB_FTDI_RANGE_01C5_PID 0x01C5 1102 #define MTXORB_FTDI_RANGE_01C5_PID 0x01C5
1098 #define MTXORB_FTDI_RANGE_01C6_PID 0x01C6 1103 #define MTXORB_FTDI_RANGE_01C6_PID 0x01C6
1099 #define MTXORB_FTDI_RANGE_01C7_PID 0x01C7 1104 #define MTXORB_FTDI_RANGE_01C7_PID 0x01C7
1100 #define MTXORB_FTDI_RANGE_01C8_PID 0x01C8 1105 #define MTXORB_FTDI_RANGE_01C8_PID 0x01C8
1101 #define MTXORB_FTDI_RANGE_01C9_PID 0x01C9 1106 #define MTXORB_FTDI_RANGE_01C9_PID 0x01C9
1102 #define MTXORB_FTDI_RANGE_01CA_PID 0x01CA 1107 #define MTXORB_FTDI_RANGE_01CA_PID 0x01CA
1103 #define MTXORB_FTDI_RANGE_01CB_PID 0x01CB 1108 #define MTXORB_FTDI_RANGE_01CB_PID 0x01CB
1104 #define MTXORB_FTDI_RANGE_01CC_PID 0x01CC 1109 #define MTXORB_FTDI_RANGE_01CC_PID 0x01CC
1105 #define MTXORB_FTDI_RANGE_01CD_PID 0x01CD 1110 #define MTXORB_FTDI_RANGE_01CD_PID 0x01CD
1106 #define MTXORB_FTDI_RANGE_01CE_PID 0x01CE 1111 #define MTXORB_FTDI_RANGE_01CE_PID 0x01CE
1107 #define MTXORB_FTDI_RANGE_01CF_PID 0x01CF 1112 #define MTXORB_FTDI_RANGE_01CF_PID 0x01CF
1108 #define MTXORB_FTDI_RANGE_01D0_PID 0x01D0 1113 #define MTXORB_FTDI_RANGE_01D0_PID 0x01D0
1109 #define MTXORB_FTDI_RANGE_01D1_PID 0x01D1 1114 #define MTXORB_FTDI_RANGE_01D1_PID 0x01D1
1110 #define MTXORB_FTDI_RANGE_01D2_PID 0x01D2 1115 #define MTXORB_FTDI_RANGE_01D2_PID 0x01D2
1111 #define MTXORB_FTDI_RANGE_01D3_PID 0x01D3 1116 #define MTXORB_FTDI_RANGE_01D3_PID 0x01D3
1112 #define MTXORB_FTDI_RANGE_01D4_PID 0x01D4 1117 #define MTXORB_FTDI_RANGE_01D4_PID 0x01D4
1113 #define MTXORB_FTDI_RANGE_01D5_PID 0x01D5 1118 #define MTXORB_FTDI_RANGE_01D5_PID 0x01D5
1114 #define MTXORB_FTDI_RANGE_01D6_PID 0x01D6 1119 #define MTXORB_FTDI_RANGE_01D6_PID 0x01D6
1115 #define MTXORB_FTDI_RANGE_01D7_PID 0x01D7 1120 #define MTXORB_FTDI_RANGE_01D7_PID 0x01D7
1116 #define MTXORB_FTDI_RANGE_01D8_PID 0x01D8 1121 #define MTXORB_FTDI_RANGE_01D8_PID 0x01D8
1117 #define MTXORB_FTDI_RANGE_01D9_PID 0x01D9 1122 #define MTXORB_FTDI_RANGE_01D9_PID 0x01D9
1118 #define MTXORB_FTDI_RANGE_01DA_PID 0x01DA 1123 #define MTXORB_FTDI_RANGE_01DA_PID 0x01DA
1119 #define MTXORB_FTDI_RANGE_01DB_PID 0x01DB 1124 #define MTXORB_FTDI_RANGE_01DB_PID 0x01DB
1120 #define MTXORB_FTDI_RANGE_01DC_PID 0x01DC 1125 #define MTXORB_FTDI_RANGE_01DC_PID 0x01DC
1121 #define MTXORB_FTDI_RANGE_01DD_PID 0x01DD 1126 #define MTXORB_FTDI_RANGE_01DD_PID 0x01DD
1122 #define MTXORB_FTDI_RANGE_01DE_PID 0x01DE 1127 #define MTXORB_FTDI_RANGE_01DE_PID 0x01DE
1123 #define MTXORB_FTDI_RANGE_01DF_PID 0x01DF 1128 #define MTXORB_FTDI_RANGE_01DF_PID 0x01DF
1124 #define MTXORB_FTDI_RANGE_01E0_PID 0x01E0 1129 #define MTXORB_FTDI_RANGE_01E0_PID 0x01E0
1125 #define MTXORB_FTDI_RANGE_01E1_PID 0x01E1 1130 #define MTXORB_FTDI_RANGE_01E1_PID 0x01E1
1126 #define MTXORB_FTDI_RANGE_01E2_PID 0x01E2 1131 #define MTXORB_FTDI_RANGE_01E2_PID 0x01E2
1127 #define MTXORB_FTDI_RANGE_01E3_PID 0x01E3 1132 #define MTXORB_FTDI_RANGE_01E3_PID 0x01E3
1128 #define MTXORB_FTDI_RANGE_01E4_PID 0x01E4 1133 #define MTXORB_FTDI_RANGE_01E4_PID 0x01E4
1129 #define MTXORB_FTDI_RANGE_01E5_PID 0x01E5 1134 #define MTXORB_FTDI_RANGE_01E5_PID 0x01E5
1130 #define MTXORB_FTDI_RANGE_01E6_PID 0x01E6 1135 #define MTXORB_FTDI_RANGE_01E6_PID 0x01E6
1131 #define MTXORB_FTDI_RANGE_01E7_PID 0x01E7 1136 #define MTXORB_FTDI_RANGE_01E7_PID 0x01E7
1132 #define MTXORB_FTDI_RANGE_01E8_PID 0x01E8 1137 #define MTXORB_FTDI_RANGE_01E8_PID 0x01E8
1133 #define MTXORB_FTDI_RANGE_01E9_PID 0x01E9 1138 #define MTXORB_FTDI_RANGE_01E9_PID 0x01E9
1134 #define MTXORB_FTDI_RANGE_01EA_PID 0x01EA 1139 #define MTXORB_FTDI_RANGE_01EA_PID 0x01EA
1135 #define MTXORB_FTDI_RANGE_01EB_PID 0x01EB 1140 #define MTXORB_FTDI_RANGE_01EB_PID 0x01EB
1136 #define MTXORB_FTDI_RANGE_01EC_PID 0x01EC 1141 #define MTXORB_FTDI_RANGE_01EC_PID 0x01EC
1137 #define MTXORB_FTDI_RANGE_01ED_PID 0x01ED 1142 #define MTXORB_FTDI_RANGE_01ED_PID 0x01ED
1138 #define MTXORB_FTDI_RANGE_01EE_PID 0x01EE 1143 #define MTXORB_FTDI_RANGE_01EE_PID 0x01EE
1139 #define MTXORB_FTDI_RANGE_01EF_PID 0x01EF 1144 #define MTXORB_FTDI_RANGE_01EF_PID 0x01EF
1140 #define MTXORB_FTDI_RANGE_01F0_PID 0x01F0 1145 #define MTXORB_FTDI_RANGE_01F0_PID 0x01F0
1141 #define MTXORB_FTDI_RANGE_01F1_PID 0x01F1 1146 #define MTXORB_FTDI_RANGE_01F1_PID 0x01F1
1142 #define MTXORB_FTDI_RANGE_01F2_PID 0x01F2 1147 #define MTXORB_FTDI_RANGE_01F2_PID 0x01F2
1143 #define MTXORB_FTDI_RANGE_01F3_PID 0x01F3 1148 #define MTXORB_FTDI_RANGE_01F3_PID 0x01F3
1144 #define MTXORB_FTDI_RANGE_01F4_PID 0x01F4 1149 #define MTXORB_FTDI_RANGE_01F4_PID 0x01F4
1145 #define MTXORB_FTDI_RANGE_01F5_PID 0x01F5 1150 #define MTXORB_FTDI_RANGE_01F5_PID 0x01F5
1146 #define MTXORB_FTDI_RANGE_01F6_PID 0x01F6 1151 #define MTXORB_FTDI_RANGE_01F6_PID 0x01F6
1147 #define MTXORB_FTDI_RANGE_01F7_PID 0x01F7 1152 #define MTXORB_FTDI_RANGE_01F7_PID 0x01F7
1148 #define MTXORB_FTDI_RANGE_01F8_PID 0x01F8 1153 #define MTXORB_FTDI_RANGE_01F8_PID 0x01F8
1149 #define MTXORB_FTDI_RANGE_01F9_PID 0x01F9 1154 #define MTXORB_FTDI_RANGE_01F9_PID 0x01F9
1150 #define MTXORB_FTDI_RANGE_01FA_PID 0x01FA 1155 #define MTXORB_FTDI_RANGE_01FA_PID 0x01FA
1151 #define MTXORB_FTDI_RANGE_01FB_PID 0x01FB 1156 #define MTXORB_FTDI_RANGE_01FB_PID 0x01FB
1152 #define MTXORB_FTDI_RANGE_01FC_PID 0x01FC 1157 #define MTXORB_FTDI_RANGE_01FC_PID 0x01FC
1153 #define MTXORB_FTDI_RANGE_01FD_PID 0x01FD 1158 #define MTXORB_FTDI_RANGE_01FD_PID 0x01FD
1154 #define MTXORB_FTDI_RANGE_01FE_PID 0x01FE 1159 #define MTXORB_FTDI_RANGE_01FE_PID 0x01FE
1155 #define MTXORB_FTDI_RANGE_01FF_PID 0x01FF 1160 #define MTXORB_FTDI_RANGE_01FF_PID 0x01FF
1156 1161
1157 1162
1158 1163
1159 /* 1164 /*
1160 * The Mobility Lab (TML) 1165 * The Mobility Lab (TML)
1161 * Submitted by Pierre Castella 1166 * Submitted by Pierre Castella
1162 */ 1167 */
1163 #define TML_VID 0x1B91 /* Vendor ID */ 1168 #define TML_VID 0x1B91 /* Vendor ID */
1164 #define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */ 1169 #define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */
1165 1170
1166 /* Alti-2 products http://www.alti-2.com */ 1171 /* Alti-2 products http://www.alti-2.com */
1167 #define ALTI2_VID 0x1BC9 1172 #define ALTI2_VID 0x1BC9
1168 #define ALTI2_N3_PID 0x6001 /* Neptune 3 */ 1173 #define ALTI2_N3_PID 0x6001 /* Neptune 3 */
1169 1174
1170 /* 1175 /*
1171 * Ionics PlugComputer 1176 * Ionics PlugComputer
1172 */ 1177 */
1173 #define IONICS_VID 0x1c0c 1178 #define IONICS_VID 0x1c0c
1174 #define IONICS_PLUGCOMPUTER_PID 0x0102 1179 #define IONICS_PLUGCOMPUTER_PID 0x0102
1175 1180
1176 /* 1181 /*
1177 * Dresden Elektronik Sensor Terminal Board 1182 * Dresden Elektronik Sensor Terminal Board
1178 */ 1183 */
1179 #define DE_VID 0x1cf1 /* Vendor ID */ 1184 #define DE_VID 0x1cf1 /* Vendor ID */
1180 #define STB_PID 0x0001 /* Sensor Terminal Board */ 1185 #define STB_PID 0x0001 /* Sensor Terminal Board */
1181 #define WHT_PID 0x0004 /* Wireless Handheld Terminal */ 1186 #define WHT_PID 0x0004 /* Wireless Handheld Terminal */
1182 1187
1183 /* 1188 /*
1184 * STMicroelectonics 1189 * STMicroelectonics
1185 */ 1190 */
1186 #define ST_VID 0x0483 1191 #define ST_VID 0x0483
1187 #define ST_STMCLT_2232_PID 0x3746 1192 #define ST_STMCLT_2232_PID 0x3746
1188 #define ST_STMCLT_4232_PID 0x3747 1193 #define ST_STMCLT_4232_PID 0x3747
1189 1194
1190 /* 1195 /*
1191 * Papouch products (http://www.papouch.com/) 1196 * Papouch products (http://www.papouch.com/)
1192 * Submitted by Folkert van Heusden 1197 * Submitted by Folkert van Heusden
1193 */ 1198 */
1194 1199
1195 #define PAPOUCH_VID 0x5050 /* Vendor ID */ 1200 #define PAPOUCH_VID 0x5050 /* Vendor ID */
1196 #define PAPOUCH_SB485_PID 0x0100 /* Papouch SB485 USB-485/422 Converter */ 1201 #define PAPOUCH_SB485_PID 0x0100 /* Papouch SB485 USB-485/422 Converter */
1197 #define PAPOUCH_AP485_PID 0x0101 /* AP485 USB-RS485 Converter */ 1202 #define PAPOUCH_AP485_PID 0x0101 /* AP485 USB-RS485 Converter */
1198 #define PAPOUCH_SB422_PID 0x0102 /* Papouch SB422 USB-RS422 Converter */ 1203 #define PAPOUCH_SB422_PID 0x0102 /* Papouch SB422 USB-RS422 Converter */
1199 #define PAPOUCH_SB485_2_PID 0x0103 /* Papouch SB485 USB-485/422 Converter */ 1204 #define PAPOUCH_SB485_2_PID 0x0103 /* Papouch SB485 USB-485/422 Converter */
1200 #define PAPOUCH_AP485_2_PID 0x0104 /* AP485 USB-RS485 Converter */ 1205 #define PAPOUCH_AP485_2_PID 0x0104 /* AP485 USB-RS485 Converter */
1201 #define PAPOUCH_SB422_2_PID 0x0105 /* Papouch SB422 USB-RS422 Converter */ 1206 #define PAPOUCH_SB422_2_PID 0x0105 /* Papouch SB422 USB-RS422 Converter */
1202 #define PAPOUCH_SB485S_PID 0x0106 /* Papouch SB485S USB-485/422 Converter */ 1207 #define PAPOUCH_SB485S_PID 0x0106 /* Papouch SB485S USB-485/422 Converter */
1203 #define PAPOUCH_SB485C_PID 0x0107 /* Papouch SB485C USB-485/422 Converter */ 1208 #define PAPOUCH_SB485C_PID 0x0107 /* Papouch SB485C USB-485/422 Converter */
1204 #define PAPOUCH_LEC_PID 0x0300 /* LEC USB Converter */ 1209 #define PAPOUCH_LEC_PID 0x0300 /* LEC USB Converter */
1205 #define PAPOUCH_SB232_PID 0x0301 /* Papouch SB232 USB-RS232 Converter */ 1210 #define PAPOUCH_SB232_PID 0x0301 /* Papouch SB232 USB-RS232 Converter */
1206 #define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ 1211 #define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */
1207 #define PAPOUCH_IRAMP_PID 0x0500 /* Papouch IRAmp Duplex */ 1212 #define PAPOUCH_IRAMP_PID 0x0500 /* Papouch IRAmp Duplex */
1208 #define PAPOUCH_DRAK5_PID 0x0700 /* Papouch DRAK5 */ 1213 #define PAPOUCH_DRAK5_PID 0x0700 /* Papouch DRAK5 */
1209 #define PAPOUCH_QUIDO8x8_PID 0x0800 /* Papouch Quido 8/8 Module */ 1214 #define PAPOUCH_QUIDO8x8_PID 0x0800 /* Papouch Quido 8/8 Module */
1210 #define PAPOUCH_QUIDO4x4_PID 0x0900 /* Papouch Quido 4/4 Module */ 1215 #define PAPOUCH_QUIDO4x4_PID 0x0900 /* Papouch Quido 4/4 Module */
1211 #define PAPOUCH_QUIDO2x2_PID 0x0a00 /* Papouch Quido 2/2 Module */ 1216 #define PAPOUCH_QUIDO2x2_PID 0x0a00 /* Papouch Quido 2/2 Module */
1212 #define PAPOUCH_QUIDO10x1_PID 0x0b00 /* Papouch Quido 10/1 Module */ 1217 #define PAPOUCH_QUIDO10x1_PID 0x0b00 /* Papouch Quido 10/1 Module */
1213 #define PAPOUCH_QUIDO30x3_PID 0x0c00 /* Papouch Quido 30/3 Module */ 1218 #define PAPOUCH_QUIDO30x3_PID 0x0c00 /* Papouch Quido 30/3 Module */
1214 #define PAPOUCH_QUIDO60x3_PID 0x0d00 /* Papouch Quido 60(100)/3 Module */ 1219 #define PAPOUCH_QUIDO60x3_PID 0x0d00 /* Papouch Quido 60(100)/3 Module */
1215 #define PAPOUCH_QUIDO2x16_PID 0x0e00 /* Papouch Quido 2/16 Module */ 1220 #define PAPOUCH_QUIDO2x16_PID 0x0e00 /* Papouch Quido 2/16 Module */
1216 #define PAPOUCH_QUIDO3x32_PID 0x0f00 /* Papouch Quido 3/32 Module */ 1221 #define PAPOUCH_QUIDO3x32_PID 0x0f00 /* Papouch Quido 3/32 Module */
1217 #define PAPOUCH_DRAK6_PID 0x1000 /* Papouch DRAK6 */ 1222 #define PAPOUCH_DRAK6_PID 0x1000 /* Papouch DRAK6 */
1218 #define PAPOUCH_UPSUSB_PID 0x8000 /* Papouch UPS-USB adapter */ 1223 #define PAPOUCH_UPSUSB_PID 0x8000 /* Papouch UPS-USB adapter */
1219 #define PAPOUCH_MU_PID 0x8001 /* MU controller */ 1224 #define PAPOUCH_MU_PID 0x8001 /* MU controller */
1220 #define PAPOUCH_SIMUKEY_PID 0x8002 /* Papouch SimuKey */ 1225 #define PAPOUCH_SIMUKEY_PID 0x8002 /* Papouch SimuKey */
1221 #define PAPOUCH_AD4USB_PID 0x8003 /* AD4USB Measurement Module */ 1226 #define PAPOUCH_AD4USB_PID 0x8003 /* AD4USB Measurement Module */
1222 #define PAPOUCH_GMUX_PID 0x8004 /* Papouch GOLIATH MUX */ 1227 #define PAPOUCH_GMUX_PID 0x8004 /* Papouch GOLIATH MUX */
1223 #define PAPOUCH_GMSR_PID 0x8005 /* Papouch GOLIATH MSR */ 1228 #define PAPOUCH_GMSR_PID 0x8005 /* Papouch GOLIATH MSR */
1224 1229
1225 /* 1230 /*
1226 * Marvell SheevaPlug 1231 * Marvell SheevaPlug
1227 */ 1232 */
1228 #define MARVELL_VID 0x9e88 1233 #define MARVELL_VID 0x9e88
1229 #define MARVELL_SHEEVAPLUG_PID 0x9e8f 1234 #define MARVELL_SHEEVAPLUG_PID 0x9e8f
1230 1235
1231 /* 1236 /*
1232 * Evolution Robotics products (http://www.evolution.com/). 1237 * Evolution Robotics products (http://www.evolution.com/).
1233 * Submitted by Shawn M. Lavelle. 1238 * Submitted by Shawn M. Lavelle.
1234 */ 1239 */
1235 #define EVOLUTION_VID 0xDEEE /* Vendor ID */ 1240 #define EVOLUTION_VID 0xDEEE /* Vendor ID */
1236 #define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */ 1241 #define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */
1237 #define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/ 1242 #define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/
1238 #define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/ 1243 #define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/
1239 #define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */ 1244 #define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */
1240 1245
1241 /* 1246 /*
1242 * MJS Gadgets HD Radio / XM Radio / Sirius Radio interfaces (using VID 0x0403) 1247 * MJS Gadgets HD Radio / XM Radio / Sirius Radio interfaces (using VID 0x0403)
1243 */ 1248 */
1244 #define MJSG_GENERIC_PID 0x9378 1249 #define MJSG_GENERIC_PID 0x9378
1245 #define MJSG_SR_RADIO_PID 0x9379 1250 #define MJSG_SR_RADIO_PID 0x9379
1246 #define MJSG_XM_RADIO_PID 0x937A 1251 #define MJSG_XM_RADIO_PID 0x937A
1247 #define MJSG_HD_RADIO_PID 0x937C 1252 #define MJSG_HD_RADIO_PID 0x937C
1248 1253
1249 /* 1254 /*
1250 * D.O.Tec products (http://www.directout.eu) 1255 * D.O.Tec products (http://www.directout.eu)
1251 */ 1256 */
1252 #define FTDI_DOTEC_PID 0x9868 1257 #define FTDI_DOTEC_PID 0x9868
1253 1258
1254 /* 1259 /*
1255 * Xverve Signalyzer tools (http://www.signalyzer.com/) 1260 * Xverve Signalyzer tools (http://www.signalyzer.com/)
1256 */ 1261 */
1257 #define XVERVE_SIGNALYZER_ST_PID 0xBCA0 1262 #define XVERVE_SIGNALYZER_ST_PID 0xBCA0
1258 #define XVERVE_SIGNALYZER_SLITE_PID 0xBCA1 1263 #define XVERVE_SIGNALYZER_SLITE_PID 0xBCA1
1259 #define XVERVE_SIGNALYZER_SH2_PID 0xBCA2 1264 #define XVERVE_SIGNALYZER_SH2_PID 0xBCA2
1260 #define XVERVE_SIGNALYZER_SH4_PID 0xBCA4 1265 #define XVERVE_SIGNALYZER_SH4_PID 0xBCA4
1261 1266
1262 /* 1267 /*
1263 * Segway Robotic Mobility Platform USB interface (using VID 0x0403) 1268 * Segway Robotic Mobility Platform USB interface (using VID 0x0403)
1264 * Submitted by John G. Rogers 1269 * Submitted by John G. Rogers
1265 */ 1270 */
1266 #define SEGWAY_RMP200_PID 0xe729 1271 #define SEGWAY_RMP200_PID 0xe729
1267 1272
1268 1273
1269 /* 1274 /*
1270 * Accesio USB Data Acquisition products (http://www.accesio.com/) 1275 * Accesio USB Data Acquisition products (http://www.accesio.com/)
1271 */ 1276 */
1272 #define ACCESIO_COM4SM_PID 0xD578 1277 #define ACCESIO_COM4SM_PID 0xD578
1273 1278
1274 /* www.sciencescope.co.uk educational dataloggers */ 1279 /* www.sciencescope.co.uk educational dataloggers */
1275 #define FTDI_SCIENCESCOPE_LOGBOOKML_PID 0xFF18 1280 #define FTDI_SCIENCESCOPE_LOGBOOKML_PID 0xFF18
1276 #define FTDI_SCIENCESCOPE_LS_LOGBOOK_PID 0xFF1C 1281 #define FTDI_SCIENCESCOPE_LS_LOGBOOK_PID 0xFF1C
1277 #define FTDI_SCIENCESCOPE_HS_LOGBOOK_PID 0xFF1D 1282 #define FTDI_SCIENCESCOPE_HS_LOGBOOK_PID 0xFF1D
1278 1283
1279 /* 1284 /*
1280 * Milkymist One JTAG/Serial 1285 * Milkymist One JTAG/Serial
1281 */ 1286 */
1282 #define QIHARDWARE_VID 0x20B7 1287 #define QIHARDWARE_VID 0x20B7
1283 #define MILKYMISTONE_JTAGSERIAL_PID 0x0713 1288 #define MILKYMISTONE_JTAGSERIAL_PID 0x0713
1284 1289
1285 /* 1290 /*
1286 * CTI GmbH RS485 Converter http://www.cti-lean.com/ 1291 * CTI GmbH RS485 Converter http://www.cti-lean.com/
1287 */ 1292 */
1288 /* USB-485-Mini*/ 1293 /* USB-485-Mini*/
1289 #define FTDI_CTI_MINI_PID 0xF608 1294 #define FTDI_CTI_MINI_PID 0xF608
1290 /* USB-Nano-485*/ 1295 /* USB-Nano-485*/
1291 #define FTDI_CTI_NANO_PID 0xF60B 1296 #define FTDI_CTI_NANO_PID 0xF60B
1292 1297
1293 /* 1298 /*
1294 * ZeitControl cardsystems GmbH rfid-readers http://zeitconrol.de 1299 * ZeitControl cardsystems GmbH rfid-readers http://zeitconrol.de
1295 */ 1300 */
1296 /* TagTracer MIFARE*/ 1301 /* TagTracer MIFARE*/
1297 #define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0 1302 #define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0
1298 1303
1299 /* 1304 /*
1300 * Rainforest Automation 1305 * Rainforest Automation
1301 */ 1306 */
1302 /* ZigBee controller */ 1307 /* ZigBee controller */
1303 #define FTDI_RF_R106 0x8A28 1308 #define FTDI_RF_R106 0x8A28
1304 1309
1305 /* 1310 /*
1306 * Product: HCP HIT GPRS modem 1311 * Product: HCP HIT GPRS modem
1307 * Manufacturer: HCP d.o.o. 1312 * Manufacturer: HCP d.o.o.
1308 * ATI command output: Cinterion MC55i 1313 * ATI command output: Cinterion MC55i
1309 */ 1314 */
1310 #define FTDI_CINTERION_MC55I_PID 0xA951 1315 #define FTDI_CINTERION_MC55I_PID 0xA951
1311 1316
1312 /* 1317 /*
1313 * Product: Comet Caller ID decoder 1318 * Product: Comet Caller ID decoder
1314 * Manufacturer: Crucible Technologies 1319 * Manufacturer: Crucible Technologies
1315 */ 1320 */
1316 #define FTDI_CT_COMET_PID 0x8e08 1321 #define FTDI_CT_COMET_PID 0x8e08
1317 1322
1318 /* 1323 /*
1319 * Product: Z3X Box 1324 * Product: Z3X Box
1320 * Manufacturer: Smart GSM Team 1325 * Manufacturer: Smart GSM Team
1321 */ 1326 */
1322 #define FTDI_Z3X_PID 0x0011 1327 #define FTDI_Z3X_PID 0x0011
1323 1328
1324 /* 1329 /*
1325 * Product: Cressi PC Interface 1330 * Product: Cressi PC Interface
1326 * Manufacturer: Cressi 1331 * Manufacturer: Cressi
1327 */ 1332 */
1328 #define FTDI_CRESSI_PID 0x87d0 1333 #define FTDI_CRESSI_PID 0x87d0
1329 1334
1330 /* 1335 /*
1331 * Brainboxes devices 1336 * Brainboxes devices
1332 */ 1337 */
1333 #define BRAINBOXES_VID 0x05d1 1338 #define BRAINBOXES_VID 0x05d1
1334 #define BRAINBOXES_VX_001_PID 0x1001 /* VX-001 ExpressCard 1 Port RS232 */ 1339 #define BRAINBOXES_VX_001_PID 0x1001 /* VX-001 ExpressCard 1 Port RS232 */
1335 #define BRAINBOXES_VX_012_PID 0x1002 /* VX-012 ExpressCard 2 Port RS232 */ 1340 #define BRAINBOXES_VX_012_PID 0x1002 /* VX-012 ExpressCard 2 Port RS232 */
1336 #define BRAINBOXES_VX_023_PID 0x1003 /* VX-023 ExpressCard 1 Port RS422/485 */ 1341 #define BRAINBOXES_VX_023_PID 0x1003 /* VX-023 ExpressCard 1 Port RS422/485 */
1337 #define BRAINBOXES_VX_034_PID 0x1004 /* VX-034 ExpressCard 2 Port RS422/485 */ 1342 #define BRAINBOXES_VX_034_PID 0x1004 /* VX-034 ExpressCard 2 Port RS422/485 */
1338 #define BRAINBOXES_US_101_PID 0x1011 /* US-101 1xRS232 */ 1343 #define BRAINBOXES_US_101_PID 0x1011 /* US-101 1xRS232 */
1339 #define BRAINBOXES_US_324_PID 0x1013 /* US-324 1xRS422/485 1Mbaud */ 1344 #define BRAINBOXES_US_324_PID 0x1013 /* US-324 1xRS422/485 1Mbaud */
1340 #define BRAINBOXES_US_606_1_PID 0x2001 /* US-606 6 Port RS232 Serial Port 1 and 2 */ 1345 #define BRAINBOXES_US_606_1_PID 0x2001 /* US-606 6 Port RS232 Serial Port 1 and 2 */
1341 #define BRAINBOXES_US_606_2_PID 0x2002 /* US-606 6 Port RS232 Serial Port 3 and 4 */ 1346 #define BRAINBOXES_US_606_2_PID 0x2002 /* US-606 6 Port RS232 Serial Port 3 and 4 */
1342 #define BRAINBOXES_US_606_3_PID 0x2003 /* US-606 6 Port RS232 Serial Port 4 and 6 */ 1347 #define BRAINBOXES_US_606_3_PID 0x2003 /* US-606 6 Port RS232 Serial Port 4 and 6 */
1343 #define BRAINBOXES_US_701_1_PID 0x2011 /* US-701 4xRS232 1Mbaud Port 1 and 2 */ 1348 #define BRAINBOXES_US_701_1_PID 0x2011 /* US-701 4xRS232 1Mbaud Port 1 and 2 */
1344 #define BRAINBOXES_US_701_2_PID 0x2012 /* US-701 4xRS422 1Mbaud Port 3 and 4 */ 1349 #define BRAINBOXES_US_701_2_PID 0x2012 /* US-701 4xRS422 1Mbaud Port 3 and 4 */
1345 #define BRAINBOXES_US_279_1_PID 0x2021 /* US-279 8xRS422 1Mbaud Port 1 and 2 */ 1350 #define BRAINBOXES_US_279_1_PID 0x2021 /* US-279 8xRS422 1Mbaud Port 1 and 2 */
1346 #define BRAINBOXES_US_279_2_PID 0x2022 /* US-279 8xRS422 1Mbaud Port 3 and 4 */ 1351 #define BRAINBOXES_US_279_2_PID 0x2022 /* US-279 8xRS422 1Mbaud Port 3 and 4 */
1347 #define BRAINBOXES_US_279_3_PID 0x2023 /* US-279 8xRS422 1Mbaud Port 5 and 6 */ 1352 #define BRAINBOXES_US_279_3_PID 0x2023 /* US-279 8xRS422 1Mbaud Port 5 and 6 */
1348 #define BRAINBOXES_US_279_4_PID 0x2024 /* US-279 8xRS422 1Mbaud Port 7 and 8 */ 1353 #define BRAINBOXES_US_279_4_PID 0x2024 /* US-279 8xRS422 1Mbaud Port 7 and 8 */
1349 #define BRAINBOXES_US_346_1_PID 0x3011 /* US-346 4xRS422/485 1Mbaud Port 1 and 2 */ 1354 #define BRAINBOXES_US_346_1_PID 0x3011 /* US-346 4xRS422/485 1Mbaud Port 1 and 2 */
1350 #define BRAINBOXES_US_346_2_PID 0x3012 /* US-346 4xRS422/485 1Mbaud Port 3 and 4 */ 1355 #define BRAINBOXES_US_346_2_PID 0x3012 /* US-346 4xRS422/485 1Mbaud Port 3 and 4 */
1351 #define BRAINBOXES_US_257_PID 0x5001 /* US-257 2xRS232 1Mbaud */ 1356 #define BRAINBOXES_US_257_PID 0x5001 /* US-257 2xRS232 1Mbaud */
1352 #define BRAINBOXES_US_313_PID 0x6001 /* US-313 2xRS422/485 1Mbaud */ 1357 #define BRAINBOXES_US_313_PID 0x6001 /* US-313 2xRS422/485 1Mbaud */
1353 #define BRAINBOXES_US_357_PID 0x7001 /* US_357 1xRS232/422/485 */ 1358 #define BRAINBOXES_US_357_PID 0x7001 /* US_357 1xRS232/422/485 */
1354 #define BRAINBOXES_US_842_1_PID 0x8001 /* US-842 8xRS422/485 1Mbaud Port 1 and 2 */ 1359 #define BRAINBOXES_US_842_1_PID 0x8001 /* US-842 8xRS422/485 1Mbaud Port 1 and 2 */
1355 #define BRAINBOXES_US_842_2_PID 0x8002 /* US-842 8xRS422/485 1Mbaud Port 3 and 4 */ 1360 #define BRAINBOXES_US_842_2_PID 0x8002 /* US-842 8xRS422/485 1Mbaud Port 3 and 4 */
1356 #define BRAINBOXES_US_842_3_PID 0x8003 /* US-842 8xRS422/485 1Mbaud Port 5 and 6 */ 1361 #define BRAINBOXES_US_842_3_PID 0x8003 /* US-842 8xRS422/485 1Mbaud Port 5 and 6 */
1357 #define BRAINBOXES_US_842_4_PID 0x8004 /* US-842 8xRS422/485 1Mbaud Port 7 and 8 */ 1362 #define BRAINBOXES_US_842_4_PID 0x8004 /* US-842 8xRS422/485 1Mbaud Port 7 and 8 */
1358 #define BRAINBOXES_US_160_1_PID 0x9001 /* US-160 16xRS232 1Mbaud Port 1 and 2 */ 1363 #define BRAINBOXES_US_160_1_PID 0x9001 /* US-160 16xRS232 1Mbaud Port 1 and 2 */
1359 #define BRAINBOXES_US_160_2_PID 0x9002 /* US-160 16xRS232 1Mbaud Port 3 and 4 */ 1364 #define BRAINBOXES_US_160_2_PID 0x9002 /* US-160 16xRS232 1Mbaud Port 3 and 4 */
1360 #define BRAINBOXES_US_160_3_PID 0x9003 /* US-160 16xRS232 1Mbaud Port 5 and 6 */ 1365 #define BRAINBOXES_US_160_3_PID 0x9003 /* US-160 16xRS232 1Mbaud Port 5 and 6 */
1361 #define BRAINBOXES_US_160_4_PID 0x9004 /* US-160 16xRS232 1Mbaud Port 7 and 8 */ 1366 #define BRAINBOXES_US_160_4_PID 0x9004 /* US-160 16xRS232 1Mbaud Port 7 and 8 */
1362 #define BRAINBOXES_US_160_5_PID 0x9005 /* US-160 16xRS232 1Mbaud Port 9 and 10 */ 1367 #define BRAINBOXES_US_160_5_PID 0x9005 /* US-160 16xRS232 1Mbaud Port 9 and 10 */
1363 #define BRAINBOXES_US_160_6_PID 0x9006 /* US-160 16xRS232 1Mbaud Port 11 and 12 */ 1368 #define BRAINBOXES_US_160_6_PID 0x9006 /* US-160 16xRS232 1Mbaud Port 11 and 12 */
1364 #define BRAINBOXES_US_160_7_PID 0x9007 /* US-160 16xRS232 1Mbaud Port 13 and 14 */ 1369 #define BRAINBOXES_US_160_7_PID 0x9007 /* US-160 16xRS232 1Mbaud Port 13 and 14 */
1365 #define BRAINBOXES_US_160_8_PID 0x9008 /* US-160 16xRS232 1Mbaud Port 15 and 16 */ 1370 #define BRAINBOXES_US_160_8_PID 0x9008 /* US-160 16xRS232 1Mbaud Port 15 and 16 */
1366 1371
drivers/usb/serial/io_ti.c
1 /* 1 /*
2 * Edgeport USB Serial Converter driver 2 * Edgeport USB Serial Converter driver
3 * 3 *
4 * Copyright (C) 2000-2002 Inside Out Networks, All rights reserved. 4 * Copyright (C) 2000-2002 Inside Out Networks, All rights reserved.
5 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com> 5 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version. 10 * (at your option) any later version.
11 * 11 *
12 * Supports the following devices: 12 * Supports the following devices:
13 * EP/1 EP/2 EP/4 EP/21 EP/22 EP/221 EP/42 EP/421 WATCHPORT 13 * EP/1 EP/2 EP/4 EP/21 EP/22 EP/221 EP/42 EP/421 WATCHPORT
14 * 14 *
15 * For questions or problems with this driver, contact Inside Out 15 * For questions or problems with this driver, contact Inside Out
16 * Networks technical support, or Peter Berger <pberger@brimson.com>, 16 * Networks technical support, or Peter Berger <pberger@brimson.com>,
17 * or Al Borchers <alborchers@steinerpoint.com>. 17 * or Al Borchers <alborchers@steinerpoint.com>.
18 */ 18 */
19 19
20 #include <linux/kernel.h> 20 #include <linux/kernel.h>
21 #include <linux/jiffies.h> 21 #include <linux/jiffies.h>
22 #include <linux/errno.h> 22 #include <linux/errno.h>
23 #include <linux/slab.h> 23 #include <linux/slab.h>
24 #include <linux/tty.h> 24 #include <linux/tty.h>
25 #include <linux/tty_driver.h> 25 #include <linux/tty_driver.h>
26 #include <linux/tty_flip.h> 26 #include <linux/tty_flip.h>
27 #include <linux/module.h> 27 #include <linux/module.h>
28 #include <linux/spinlock.h> 28 #include <linux/spinlock.h>
29 #include <linux/mutex.h> 29 #include <linux/mutex.h>
30 #include <linux/serial.h> 30 #include <linux/serial.h>
31 #include <linux/swab.h> 31 #include <linux/swab.h>
32 #include <linux/kfifo.h> 32 #include <linux/kfifo.h>
33 #include <linux/ioctl.h> 33 #include <linux/ioctl.h>
34 #include <linux/firmware.h> 34 #include <linux/firmware.h>
35 #include <linux/uaccess.h> 35 #include <linux/uaccess.h>
36 #include <linux/usb.h> 36 #include <linux/usb.h>
37 #include <linux/usb/serial.h> 37 #include <linux/usb/serial.h>
38 38
39 #include "io_16654.h" 39 #include "io_16654.h"
40 #include "io_usbvend.h" 40 #include "io_usbvend.h"
41 #include "io_ti.h" 41 #include "io_ti.h"
42 42
43 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli" 43 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli"
44 #define DRIVER_DESC "Edgeport USB Serial Driver" 44 #define DRIVER_DESC "Edgeport USB Serial Driver"
45 45
46 #define EPROM_PAGE_SIZE 64 46 #define EPROM_PAGE_SIZE 64
47 47
48 48
49 /* different hardware types */ 49 /* different hardware types */
50 #define HARDWARE_TYPE_930 0 50 #define HARDWARE_TYPE_930 0
51 #define HARDWARE_TYPE_TIUMP 1 51 #define HARDWARE_TYPE_TIUMP 1
52 52
53 /* IOCTL_PRIVATE_TI_GET_MODE Definitions */ 53 /* IOCTL_PRIVATE_TI_GET_MODE Definitions */
54 #define TI_MODE_CONFIGURING 0 /* Device has not entered start device */ 54 #define TI_MODE_CONFIGURING 0 /* Device has not entered start device */
55 #define TI_MODE_BOOT 1 /* Staying in boot mode */ 55 #define TI_MODE_BOOT 1 /* Staying in boot mode */
56 #define TI_MODE_DOWNLOAD 2 /* Made it to download mode */ 56 #define TI_MODE_DOWNLOAD 2 /* Made it to download mode */
57 #define TI_MODE_TRANSITIONING 3 /* Currently in boot mode but 57 #define TI_MODE_TRANSITIONING 3 /* Currently in boot mode but
58 transitioning to download mode */ 58 transitioning to download mode */
59 59
60 /* read urb state */ 60 /* read urb state */
61 #define EDGE_READ_URB_RUNNING 0 61 #define EDGE_READ_URB_RUNNING 0
62 #define EDGE_READ_URB_STOPPING 1 62 #define EDGE_READ_URB_STOPPING 1
63 #define EDGE_READ_URB_STOPPED 2 63 #define EDGE_READ_URB_STOPPED 2
64 64
65 #define EDGE_CLOSING_WAIT 4000 /* in .01 sec */ 65 #define EDGE_CLOSING_WAIT 4000 /* in .01 sec */
66 66
67 67
68 /* Product information read from the Edgeport */ 68 /* Product information read from the Edgeport */
69 struct product_info { 69 struct product_info {
70 int TiMode; /* Current TI Mode */ 70 int TiMode; /* Current TI Mode */
71 __u8 hardware_type; /* Type of hardware */ 71 __u8 hardware_type; /* Type of hardware */
72 } __attribute__((packed)); 72 } __attribute__((packed));
73 73
74 struct edgeport_port { 74 struct edgeport_port {
75 __u16 uart_base; 75 __u16 uart_base;
76 __u16 dma_address; 76 __u16 dma_address;
77 __u8 shadow_msr; 77 __u8 shadow_msr;
78 __u8 shadow_mcr; 78 __u8 shadow_mcr;
79 __u8 shadow_lsr; 79 __u8 shadow_lsr;
80 __u8 lsr_mask; 80 __u8 lsr_mask;
81 __u32 ump_read_timeout; /* Number of milliseconds the UMP will 81 __u32 ump_read_timeout; /* Number of milliseconds the UMP will
82 wait without data before completing 82 wait without data before completing
83 a read short */ 83 a read short */
84 int baud_rate; 84 int baud_rate;
85 int close_pending; 85 int close_pending;
86 int lsr_event; 86 int lsr_event;
87 87
88 struct edgeport_serial *edge_serial; 88 struct edgeport_serial *edge_serial;
89 struct usb_serial_port *port; 89 struct usb_serial_port *port;
90 __u8 bUartMode; /* Port type, 0: RS232, etc. */ 90 __u8 bUartMode; /* Port type, 0: RS232, etc. */
91 spinlock_t ep_lock; 91 spinlock_t ep_lock;
92 int ep_read_urb_state; 92 int ep_read_urb_state;
93 int ep_write_urb_in_use; 93 int ep_write_urb_in_use;
94 }; 94 };
95 95
96 struct edgeport_serial { 96 struct edgeport_serial {
97 struct product_info product_info; 97 struct product_info product_info;
98 u8 TI_I2C_Type; /* Type of I2C in UMP */ 98 u8 TI_I2C_Type; /* Type of I2C in UMP */
99 u8 TiReadI2C; /* Set to TRUE if we have read the 99 u8 TiReadI2C; /* Set to TRUE if we have read the
100 I2c in Boot Mode */ 100 I2c in Boot Mode */
101 struct mutex es_lock; 101 struct mutex es_lock;
102 int num_ports_open; 102 int num_ports_open;
103 struct usb_serial *serial; 103 struct usb_serial *serial;
104 }; 104 };
105 105
106 106
107 /* Devices that this driver supports */ 107 /* Devices that this driver supports */
108 static const struct usb_device_id edgeport_1port_id_table[] = { 108 static const struct usb_device_id edgeport_1port_id_table[] = {
109 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) }, 109 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) },
110 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) }, 110 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) },
111 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) }, 111 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) },
112 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROXIMITY) }, 112 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROXIMITY) },
113 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOTION) }, 113 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOTION) },
114 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOISTURE) }, 114 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOISTURE) },
115 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_TEMPERATURE) }, 115 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_TEMPERATURE) },
116 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_HUMIDITY) }, 116 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_HUMIDITY) },
117 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_POWER) }, 117 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_POWER) },
118 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_LIGHT) }, 118 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_LIGHT) },
119 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_RADIATION) }, 119 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_RADIATION) },
120 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_DISTANCE) }, 120 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_DISTANCE) },
121 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_ACCELERATION) }, 121 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_ACCELERATION) },
122 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROX_DIST) }, 122 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROX_DIST) },
123 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_HP4CD) }, 123 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_HP4CD) },
124 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_PCI) }, 124 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_PCI) },
125 { } 125 { }
126 }; 126 };
127 127
128 static const struct usb_device_id edgeport_2port_id_table[] = { 128 static const struct usb_device_id edgeport_2port_id_table[] = {
129 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) }, 129 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) },
130 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) }, 130 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) },
131 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) }, 131 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) },
132 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421) }, 132 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421) },
133 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21) }, 133 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21) },
134 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_42) }, 134 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_42) },
135 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4) }, 135 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4) },
136 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4I) }, 136 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4I) },
137 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22I) }, 137 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22I) },
138 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_221C) }, 138 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_221C) },
139 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22C) }, 139 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22C) },
140 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21C) }, 140 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21C) },
141 /* The 4, 8 and 16 port devices show up as multiple 2 port devices */ 141 /* The 4, 8 and 16 port devices show up as multiple 2 port devices */
142 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4S) }, 142 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4S) },
143 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8) }, 143 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8) },
144 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8S) }, 144 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8S) },
145 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416) }, 145 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416) },
146 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416B) }, 146 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416B) },
147 { } 147 { }
148 }; 148 };
149 149
150 /* Devices that this driver supports */ 150 /* Devices that this driver supports */
151 static const struct usb_device_id id_table_combined[] = { 151 static const struct usb_device_id id_table_combined[] = {
152 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) }, 152 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) },
153 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) }, 153 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) },
154 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) }, 154 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) },
155 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROXIMITY) }, 155 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROXIMITY) },
156 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOTION) }, 156 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOTION) },
157 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOISTURE) }, 157 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOISTURE) },
158 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_TEMPERATURE) }, 158 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_TEMPERATURE) },
159 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_HUMIDITY) }, 159 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_HUMIDITY) },
160 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_POWER) }, 160 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_POWER) },
161 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_LIGHT) }, 161 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_LIGHT) },
162 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_RADIATION) }, 162 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_RADIATION) },
163 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_DISTANCE) }, 163 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_DISTANCE) },
164 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_ACCELERATION) }, 164 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_ACCELERATION) },
165 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROX_DIST) }, 165 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROX_DIST) },
166 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_HP4CD) }, 166 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_HP4CD) },
167 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_PCI) }, 167 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_PCI) },
168 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) }, 168 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) },
169 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) }, 169 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) },
170 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) }, 170 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) },
171 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421) }, 171 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421) },
172 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21) }, 172 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21) },
173 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_42) }, 173 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_42) },
174 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4) }, 174 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4) },
175 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4I) }, 175 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4I) },
176 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22I) }, 176 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22I) },
177 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_221C) }, 177 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_221C) },
178 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22C) }, 178 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22C) },
179 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21C) }, 179 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21C) },
180 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4S) }, 180 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4S) },
181 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8) }, 181 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8) },
182 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8S) }, 182 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8S) },
183 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416) }, 183 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416) },
184 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416B) }, 184 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416B) },
185 { } 185 { }
186 }; 186 };
187 187
188 MODULE_DEVICE_TABLE(usb, id_table_combined); 188 MODULE_DEVICE_TABLE(usb, id_table_combined);
189 189
190 static unsigned char OperationalMajorVersion; 190 static unsigned char OperationalMajorVersion;
191 static unsigned char OperationalMinorVersion; 191 static unsigned char OperationalMinorVersion;
192 static unsigned short OperationalBuildNumber; 192 static unsigned short OperationalBuildNumber;
193 193
194 static int closing_wait = EDGE_CLOSING_WAIT; 194 static int closing_wait = EDGE_CLOSING_WAIT;
195 static bool ignore_cpu_rev; 195 static bool ignore_cpu_rev;
196 static int default_uart_mode; /* RS232 */ 196 static int default_uart_mode; /* RS232 */
197 197
198 static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, 198 static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data,
199 int length); 199 int length);
200 200
201 static void stop_read(struct edgeport_port *edge_port); 201 static void stop_read(struct edgeport_port *edge_port);
202 static int restart_read(struct edgeport_port *edge_port); 202 static int restart_read(struct edgeport_port *edge_port);
203 203
204 static void edge_set_termios(struct tty_struct *tty, 204 static void edge_set_termios(struct tty_struct *tty,
205 struct usb_serial_port *port, struct ktermios *old_termios); 205 struct usb_serial_port *port, struct ktermios *old_termios);
206 static void edge_send(struct usb_serial_port *port, struct tty_struct *tty); 206 static void edge_send(struct usb_serial_port *port, struct tty_struct *tty);
207 207
208 /* sysfs attributes */ 208 /* sysfs attributes */
209 static int edge_create_sysfs_attrs(struct usb_serial_port *port); 209 static int edge_create_sysfs_attrs(struct usb_serial_port *port);
210 static int edge_remove_sysfs_attrs(struct usb_serial_port *port); 210 static int edge_remove_sysfs_attrs(struct usb_serial_port *port);
211 211
212 212
213 static int ti_vread_sync(struct usb_device *dev, __u8 request, 213 static int ti_vread_sync(struct usb_device *dev, __u8 request,
214 __u16 value, __u16 index, u8 *data, int size) 214 __u16 value, __u16 index, u8 *data, int size)
215 { 215 {
216 int status; 216 int status;
217 217
218 status = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, 218 status = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
219 (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN), 219 (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN),
220 value, index, data, size, 1000); 220 value, index, data, size, 1000);
221 if (status < 0) 221 if (status < 0)
222 return status; 222 return status;
223 if (status != size) { 223 if (status != size) {
224 dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n", 224 dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n",
225 __func__, size, status); 225 __func__, size, status);
226 return -ECOMM; 226 return -ECOMM;
227 } 227 }
228 return 0; 228 return 0;
229 } 229 }
230 230
231 static int ti_vsend_sync(struct usb_device *dev, __u8 request, 231 static int ti_vsend_sync(struct usb_device *dev, __u8 request,
232 __u16 value, __u16 index, u8 *data, int size) 232 __u16 value, __u16 index, u8 *data, int size)
233 { 233 {
234 int status; 234 int status;
235 235
236 status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, 236 status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
237 (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT), 237 (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT),
238 value, index, data, size, 1000); 238 value, index, data, size, 1000);
239 if (status < 0) 239 if (status < 0)
240 return status; 240 return status;
241 if (status != size) { 241 if (status != size) {
242 dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n", 242 dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n",
243 __func__, size, status); 243 __func__, size, status);
244 return -ECOMM; 244 return -ECOMM;
245 } 245 }
246 return 0; 246 return 0;
247 } 247 }
248 248
249 static int send_cmd(struct usb_device *dev, __u8 command, 249 static int send_cmd(struct usb_device *dev, __u8 command,
250 __u8 moduleid, __u16 value, u8 *data, 250 __u8 moduleid, __u16 value, u8 *data,
251 int size) 251 int size)
252 { 252 {
253 return ti_vsend_sync(dev, command, value, moduleid, data, size); 253 return ti_vsend_sync(dev, command, value, moduleid, data, size);
254 } 254 }
255 255
256 /* clear tx/rx buffers and fifo in TI UMP */ 256 /* clear tx/rx buffers and fifo in TI UMP */
257 static int purge_port(struct usb_serial_port *port, __u16 mask) 257 static int purge_port(struct usb_serial_port *port, __u16 mask)
258 { 258 {
259 int port_number = port->port_number; 259 int port_number = port->port_number;
260 260
261 dev_dbg(&port->dev, "%s - port %d, mask %x\n", __func__, port_number, mask); 261 dev_dbg(&port->dev, "%s - port %d, mask %x\n", __func__, port_number, mask);
262 262
263 return send_cmd(port->serial->dev, 263 return send_cmd(port->serial->dev,
264 UMPC_PURGE_PORT, 264 UMPC_PURGE_PORT,
265 (__u8)(UMPM_UART1_PORT + port_number), 265 (__u8)(UMPM_UART1_PORT + port_number),
266 mask, 266 mask,
267 NULL, 267 NULL,
268 0); 268 0);
269 } 269 }
270 270
271 /** 271 /**
272 * read_download_mem - Read edgeport memory from TI chip 272 * read_download_mem - Read edgeport memory from TI chip
273 * @dev: usb device pointer 273 * @dev: usb device pointer
274 * @start_address: Device CPU address at which to read 274 * @start_address: Device CPU address at which to read
275 * @length: Length of above data 275 * @length: Length of above data
276 * @address_type: Can read both XDATA and I2C 276 * @address_type: Can read both XDATA and I2C
277 * @buffer: pointer to input data buffer 277 * @buffer: pointer to input data buffer
278 */ 278 */
279 static int read_download_mem(struct usb_device *dev, int start_address, 279 static int read_download_mem(struct usb_device *dev, int start_address,
280 int length, __u8 address_type, __u8 *buffer) 280 int length, __u8 address_type, __u8 *buffer)
281 { 281 {
282 int status = 0; 282 int status = 0;
283 __u8 read_length; 283 __u8 read_length;
284 u16 be_start_address; 284 u16 be_start_address;
285 285
286 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length); 286 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length);
287 287
288 /* Read in blocks of 64 bytes 288 /* Read in blocks of 64 bytes
289 * (TI firmware can't handle more than 64 byte reads) 289 * (TI firmware can't handle more than 64 byte reads)
290 */ 290 */
291 while (length) { 291 while (length) {
292 if (length > 64) 292 if (length > 64)
293 read_length = 64; 293 read_length = 64;
294 else 294 else
295 read_length = (__u8)length; 295 read_length = (__u8)length;
296 296
297 if (read_length > 1) { 297 if (read_length > 1) {
298 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, read_length); 298 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, read_length);
299 } 299 }
300 /* 300 /*
301 * NOTE: Must use swab as wIndex is sent in little-endian 301 * NOTE: Must use swab as wIndex is sent in little-endian
302 * byte order regardless of host byte order. 302 * byte order regardless of host byte order.
303 */ 303 */
304 be_start_address = swab16((u16)start_address); 304 be_start_address = swab16((u16)start_address);
305 status = ti_vread_sync(dev, UMPC_MEMORY_READ, 305 status = ti_vread_sync(dev, UMPC_MEMORY_READ,
306 (__u16)address_type, 306 (__u16)address_type,
307 be_start_address, 307 be_start_address,
308 buffer, read_length); 308 buffer, read_length);
309 309
310 if (status) { 310 if (status) {
311 dev_dbg(&dev->dev, "%s - ERROR %x\n", __func__, status); 311 dev_dbg(&dev->dev, "%s - ERROR %x\n", __func__, status);
312 return status; 312 return status;
313 } 313 }
314 314
315 if (read_length > 1) 315 if (read_length > 1)
316 usb_serial_debug_data(&dev->dev, __func__, read_length, buffer); 316 usb_serial_debug_data(&dev->dev, __func__, read_length, buffer);
317 317
318 /* Update pointers/length */ 318 /* Update pointers/length */
319 start_address += read_length; 319 start_address += read_length;
320 buffer += read_length; 320 buffer += read_length;
321 length -= read_length; 321 length -= read_length;
322 } 322 }
323 323
324 return status; 324 return status;
325 } 325 }
326 326
327 static int read_ram(struct usb_device *dev, int start_address, 327 static int read_ram(struct usb_device *dev, int start_address,
328 int length, __u8 *buffer) 328 int length, __u8 *buffer)
329 { 329 {
330 return read_download_mem(dev, start_address, length, 330 return read_download_mem(dev, start_address, length,
331 DTK_ADDR_SPACE_XDATA, buffer); 331 DTK_ADDR_SPACE_XDATA, buffer);
332 } 332 }
333 333
334 /* Read edgeport memory to a given block */ 334 /* Read edgeport memory to a given block */
335 static int read_boot_mem(struct edgeport_serial *serial, 335 static int read_boot_mem(struct edgeport_serial *serial,
336 int start_address, int length, __u8 *buffer) 336 int start_address, int length, __u8 *buffer)
337 { 337 {
338 int status = 0; 338 int status = 0;
339 int i; 339 int i;
340 340
341 for (i = 0; i < length; i++) { 341 for (i = 0; i < length; i++) {
342 status = ti_vread_sync(serial->serial->dev, 342 status = ti_vread_sync(serial->serial->dev,
343 UMPC_MEMORY_READ, serial->TI_I2C_Type, 343 UMPC_MEMORY_READ, serial->TI_I2C_Type,
344 (__u16)(start_address+i), &buffer[i], 0x01); 344 (__u16)(start_address+i), &buffer[i], 0x01);
345 if (status) { 345 if (status) {
346 dev_dbg(&serial->serial->dev->dev, "%s - ERROR %x\n", __func__, status); 346 dev_dbg(&serial->serial->dev->dev, "%s - ERROR %x\n", __func__, status);
347 return status; 347 return status;
348 } 348 }
349 } 349 }
350 350
351 dev_dbg(&serial->serial->dev->dev, "%s - start_address = %x, length = %d\n", 351 dev_dbg(&serial->serial->dev->dev, "%s - start_address = %x, length = %d\n",
352 __func__, start_address, length); 352 __func__, start_address, length);
353 usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer); 353 usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer);
354 354
355 serial->TiReadI2C = 1; 355 serial->TiReadI2C = 1;
356 356
357 return status; 357 return status;
358 } 358 }
359 359
360 /* Write given block to TI EPROM memory */ 360 /* Write given block to TI EPROM memory */
361 static int write_boot_mem(struct edgeport_serial *serial, 361 static int write_boot_mem(struct edgeport_serial *serial,
362 int start_address, int length, __u8 *buffer) 362 int start_address, int length, __u8 *buffer)
363 { 363 {
364 int status = 0; 364 int status = 0;
365 int i; 365 int i;
366 u8 *temp; 366 u8 *temp;
367 367
368 /* Must do a read before write */ 368 /* Must do a read before write */
369 if (!serial->TiReadI2C) { 369 if (!serial->TiReadI2C) {
370 temp = kmalloc(1, GFP_KERNEL); 370 temp = kmalloc(1, GFP_KERNEL);
371 if (!temp) 371 if (!temp)
372 return -ENOMEM; 372 return -ENOMEM;
373 373
374 status = read_boot_mem(serial, 0, 1, temp); 374 status = read_boot_mem(serial, 0, 1, temp);
375 kfree(temp); 375 kfree(temp);
376 if (status) 376 if (status)
377 return status; 377 return status;
378 } 378 }
379 379
380 for (i = 0; i < length; ++i) { 380 for (i = 0; i < length; ++i) {
381 status = ti_vsend_sync(serial->serial->dev, 381 status = ti_vsend_sync(serial->serial->dev,
382 UMPC_MEMORY_WRITE, buffer[i], 382 UMPC_MEMORY_WRITE, buffer[i],
383 (__u16)(i + start_address), NULL, 0); 383 (__u16)(i + start_address), NULL, 0);
384 if (status) 384 if (status)
385 return status; 385 return status;
386 } 386 }
387 387
388 dev_dbg(&serial->serial->dev->dev, "%s - start_sddr = %x, length = %d\n", __func__, start_address, length); 388 dev_dbg(&serial->serial->dev->dev, "%s - start_sddr = %x, length = %d\n", __func__, start_address, length);
389 usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer); 389 usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer);
390 390
391 return status; 391 return status;
392 } 392 }
393 393
394 394
395 /* Write edgeport I2C memory to TI chip */ 395 /* Write edgeport I2C memory to TI chip */
396 static int write_i2c_mem(struct edgeport_serial *serial, 396 static int write_i2c_mem(struct edgeport_serial *serial,
397 int start_address, int length, __u8 address_type, __u8 *buffer) 397 int start_address, int length, __u8 address_type, __u8 *buffer)
398 { 398 {
399 struct device *dev = &serial->serial->dev->dev; 399 struct device *dev = &serial->serial->dev->dev;
400 int status = 0; 400 int status = 0;
401 int write_length; 401 int write_length;
402 u16 be_start_address; 402 u16 be_start_address;
403 403
404 /* We can only send a maximum of 1 aligned byte page at a time */ 404 /* We can only send a maximum of 1 aligned byte page at a time */
405 405
406 /* calculate the number of bytes left in the first page */ 406 /* calculate the number of bytes left in the first page */
407 write_length = EPROM_PAGE_SIZE - 407 write_length = EPROM_PAGE_SIZE -
408 (start_address & (EPROM_PAGE_SIZE - 1)); 408 (start_address & (EPROM_PAGE_SIZE - 1));
409 409
410 if (write_length > length) 410 if (write_length > length)
411 write_length = length; 411 write_length = length;
412 412
413 dev_dbg(dev, "%s - BytesInFirstPage Addr = %x, length = %d\n", 413 dev_dbg(dev, "%s - BytesInFirstPage Addr = %x, length = %d\n",
414 __func__, start_address, write_length); 414 __func__, start_address, write_length);
415 usb_serial_debug_data(dev, __func__, write_length, buffer); 415 usb_serial_debug_data(dev, __func__, write_length, buffer);
416 416
417 /* 417 /*
418 * Write first page. 418 * Write first page.
419 * 419 *
420 * NOTE: Must use swab as wIndex is sent in little-endian byte order 420 * NOTE: Must use swab as wIndex is sent in little-endian byte order
421 * regardless of host byte order. 421 * regardless of host byte order.
422 */ 422 */
423 be_start_address = swab16((u16)start_address); 423 be_start_address = swab16((u16)start_address);
424 status = ti_vsend_sync(serial->serial->dev, 424 status = ti_vsend_sync(serial->serial->dev,
425 UMPC_MEMORY_WRITE, (__u16)address_type, 425 UMPC_MEMORY_WRITE, (__u16)address_type,
426 be_start_address, 426 be_start_address,
427 buffer, write_length); 427 buffer, write_length);
428 if (status) { 428 if (status) {
429 dev_dbg(dev, "%s - ERROR %d\n", __func__, status); 429 dev_dbg(dev, "%s - ERROR %d\n", __func__, status);
430 return status; 430 return status;
431 } 431 }
432 432
433 length -= write_length; 433 length -= write_length;
434 start_address += write_length; 434 start_address += write_length;
435 buffer += write_length; 435 buffer += write_length;
436 436
437 /* We should be aligned now -- can write 437 /* We should be aligned now -- can write
438 max page size bytes at a time */ 438 max page size bytes at a time */
439 while (length) { 439 while (length) {
440 if (length > EPROM_PAGE_SIZE) 440 if (length > EPROM_PAGE_SIZE)
441 write_length = EPROM_PAGE_SIZE; 441 write_length = EPROM_PAGE_SIZE;
442 else 442 else
443 write_length = length; 443 write_length = length;
444 444
445 dev_dbg(dev, "%s - Page Write Addr = %x, length = %d\n", 445 dev_dbg(dev, "%s - Page Write Addr = %x, length = %d\n",
446 __func__, start_address, write_length); 446 __func__, start_address, write_length);
447 usb_serial_debug_data(dev, __func__, write_length, buffer); 447 usb_serial_debug_data(dev, __func__, write_length, buffer);
448 448
449 /* 449 /*
450 * Write next page. 450 * Write next page.
451 * 451 *
452 * NOTE: Must use swab as wIndex is sent in little-endian byte 452 * NOTE: Must use swab as wIndex is sent in little-endian byte
453 * order regardless of host byte order. 453 * order regardless of host byte order.
454 */ 454 */
455 be_start_address = swab16((u16)start_address); 455 be_start_address = swab16((u16)start_address);
456 status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE, 456 status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE,
457 (__u16)address_type, 457 (__u16)address_type,
458 be_start_address, 458 be_start_address,
459 buffer, write_length); 459 buffer, write_length);
460 if (status) { 460 if (status) {
461 dev_err(dev, "%s - ERROR %d\n", __func__, status); 461 dev_err(dev, "%s - ERROR %d\n", __func__, status);
462 return status; 462 return status;
463 } 463 }
464 464
465 length -= write_length; 465 length -= write_length;
466 start_address += write_length; 466 start_address += write_length;
467 buffer += write_length; 467 buffer += write_length;
468 } 468 }
469 return status; 469 return status;
470 } 470 }
471 471
472 /* Examine the UMP DMA registers and LSR 472 /* Examine the UMP DMA registers and LSR
473 * 473 *
474 * Check the MSBit of the X and Y DMA byte count registers. 474 * Check the MSBit of the X and Y DMA byte count registers.
475 * A zero in this bit indicates that the TX DMA buffers are empty 475 * A zero in this bit indicates that the TX DMA buffers are empty
476 * then check the TX Empty bit in the UART. 476 * then check the TX Empty bit in the UART.
477 */ 477 */
478 static int tx_active(struct edgeport_port *port) 478 static int tx_active(struct edgeport_port *port)
479 { 479 {
480 int status; 480 int status;
481 struct out_endpoint_desc_block *oedb; 481 struct out_endpoint_desc_block *oedb;
482 __u8 *lsr; 482 __u8 *lsr;
483 int bytes_left = 0; 483 int bytes_left = 0;
484 484
485 oedb = kmalloc(sizeof(*oedb), GFP_KERNEL); 485 oedb = kmalloc(sizeof(*oedb), GFP_KERNEL);
486 if (!oedb) 486 if (!oedb)
487 return -ENOMEM; 487 return -ENOMEM;
488 488
489 lsr = kmalloc(1, GFP_KERNEL); /* Sigh, that's right, just one byte, 489 lsr = kmalloc(1, GFP_KERNEL); /* Sigh, that's right, just one byte,
490 as not all platforms can do DMA 490 as not all platforms can do DMA
491 from stack */ 491 from stack */
492 if (!lsr) { 492 if (!lsr) {
493 kfree(oedb); 493 kfree(oedb);
494 return -ENOMEM; 494 return -ENOMEM;
495 } 495 }
496 /* Read the DMA Count Registers */ 496 /* Read the DMA Count Registers */
497 status = read_ram(port->port->serial->dev, port->dma_address, 497 status = read_ram(port->port->serial->dev, port->dma_address,
498 sizeof(*oedb), (void *)oedb); 498 sizeof(*oedb), (void *)oedb);
499 if (status) 499 if (status)
500 goto exit_is_tx_active; 500 goto exit_is_tx_active;
501 501
502 dev_dbg(&port->port->dev, "%s - XByteCount 0x%X\n", __func__, oedb->XByteCount); 502 dev_dbg(&port->port->dev, "%s - XByteCount 0x%X\n", __func__, oedb->XByteCount);
503 503
504 /* and the LSR */ 504 /* and the LSR */
505 status = read_ram(port->port->serial->dev, 505 status = read_ram(port->port->serial->dev,
506 port->uart_base + UMPMEM_OFFS_UART_LSR, 1, lsr); 506 port->uart_base + UMPMEM_OFFS_UART_LSR, 1, lsr);
507 507
508 if (status) 508 if (status)
509 goto exit_is_tx_active; 509 goto exit_is_tx_active;
510 dev_dbg(&port->port->dev, "%s - LSR = 0x%X\n", __func__, *lsr); 510 dev_dbg(&port->port->dev, "%s - LSR = 0x%X\n", __func__, *lsr);
511 511
512 /* If either buffer has data or we are transmitting then return TRUE */ 512 /* If either buffer has data or we are transmitting then return TRUE */
513 if ((oedb->XByteCount & 0x80) != 0) 513 if ((oedb->XByteCount & 0x80) != 0)
514 bytes_left += 64; 514 bytes_left += 64;
515 515
516 if ((*lsr & UMP_UART_LSR_TX_MASK) == 0) 516 if ((*lsr & UMP_UART_LSR_TX_MASK) == 0)
517 bytes_left += 1; 517 bytes_left += 1;
518 518
519 /* We return Not Active if we get any kind of error */ 519 /* We return Not Active if we get any kind of error */
520 exit_is_tx_active: 520 exit_is_tx_active:
521 dev_dbg(&port->port->dev, "%s - return %d\n", __func__, bytes_left); 521 dev_dbg(&port->port->dev, "%s - return %d\n", __func__, bytes_left);
522 522
523 kfree(lsr); 523 kfree(lsr);
524 kfree(oedb); 524 kfree(oedb);
525 return bytes_left; 525 return bytes_left;
526 } 526 }
527 527
528 static int choose_config(struct usb_device *dev) 528 static int choose_config(struct usb_device *dev)
529 { 529 {
530 /* 530 /*
531 * There may be multiple configurations on this device, in which case 531 * There may be multiple configurations on this device, in which case
532 * we would need to read and parse all of them to find out which one 532 * we would need to read and parse all of them to find out which one
533 * we want. However, we just support one config at this point, 533 * we want. However, we just support one config at this point,
534 * configuration # 1, which is Config Descriptor 0. 534 * configuration # 1, which is Config Descriptor 0.
535 */ 535 */
536 536
537 dev_dbg(&dev->dev, "%s - Number of Interfaces = %d\n", 537 dev_dbg(&dev->dev, "%s - Number of Interfaces = %d\n",
538 __func__, dev->config->desc.bNumInterfaces); 538 __func__, dev->config->desc.bNumInterfaces);
539 dev_dbg(&dev->dev, "%s - MAX Power = %d\n", 539 dev_dbg(&dev->dev, "%s - MAX Power = %d\n",
540 __func__, dev->config->desc.bMaxPower * 2); 540 __func__, dev->config->desc.bMaxPower * 2);
541 541
542 if (dev->config->desc.bNumInterfaces != 1) { 542 if (dev->config->desc.bNumInterfaces != 1) {
543 dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__); 543 dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__);
544 return -ENODEV; 544 return -ENODEV;
545 } 545 }
546 546
547 return 0; 547 return 0;
548 } 548 }
549 549
550 static int read_rom(struct edgeport_serial *serial, 550 static int read_rom(struct edgeport_serial *serial,
551 int start_address, int length, __u8 *buffer) 551 int start_address, int length, __u8 *buffer)
552 { 552 {
553 int status; 553 int status;
554 554
555 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { 555 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) {
556 status = read_download_mem(serial->serial->dev, 556 status = read_download_mem(serial->serial->dev,
557 start_address, 557 start_address,
558 length, 558 length,
559 serial->TI_I2C_Type, 559 serial->TI_I2C_Type,
560 buffer); 560 buffer);
561 } else { 561 } else {
562 status = read_boot_mem(serial, start_address, length, 562 status = read_boot_mem(serial, start_address, length,
563 buffer); 563 buffer);
564 } 564 }
565 return status; 565 return status;
566 } 566 }
567 567
568 static int write_rom(struct edgeport_serial *serial, int start_address, 568 static int write_rom(struct edgeport_serial *serial, int start_address,
569 int length, __u8 *buffer) 569 int length, __u8 *buffer)
570 { 570 {
571 if (serial->product_info.TiMode == TI_MODE_BOOT) 571 if (serial->product_info.TiMode == TI_MODE_BOOT)
572 return write_boot_mem(serial, start_address, length, 572 return write_boot_mem(serial, start_address, length,
573 buffer); 573 buffer);
574 574
575 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) 575 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD)
576 return write_i2c_mem(serial, start_address, length, 576 return write_i2c_mem(serial, start_address, length,
577 serial->TI_I2C_Type, buffer); 577 serial->TI_I2C_Type, buffer);
578 return -EINVAL; 578 return -EINVAL;
579 } 579 }
580 580
581 581
582 582
583 /* Read a descriptor header from I2C based on type */ 583 /* Read a descriptor header from I2C based on type */
584 static int get_descriptor_addr(struct edgeport_serial *serial, 584 static int get_descriptor_addr(struct edgeport_serial *serial,
585 int desc_type, struct ti_i2c_desc *rom_desc) 585 int desc_type, struct ti_i2c_desc *rom_desc)
586 { 586 {
587 int start_address; 587 int start_address;
588 int status; 588 int status;
589 589
590 /* Search for requested descriptor in I2C */ 590 /* Search for requested descriptor in I2C */
591 start_address = 2; 591 start_address = 2;
592 do { 592 do {
593 status = read_rom(serial, 593 status = read_rom(serial,
594 start_address, 594 start_address,
595 sizeof(struct ti_i2c_desc), 595 sizeof(struct ti_i2c_desc),
596 (__u8 *)rom_desc); 596 (__u8 *)rom_desc);
597 if (status) 597 if (status)
598 return 0; 598 return 0;
599 599
600 if (rom_desc->Type == desc_type) 600 if (rom_desc->Type == desc_type)
601 return start_address; 601 return start_address;
602 602
603 start_address = start_address + sizeof(struct ti_i2c_desc) + 603 start_address = start_address + sizeof(struct ti_i2c_desc) +
604 le16_to_cpu(rom_desc->Size); 604 le16_to_cpu(rom_desc->Size);
605 605
606 } while ((start_address < TI_MAX_I2C_SIZE) && rom_desc->Type); 606 } while ((start_address < TI_MAX_I2C_SIZE) && rom_desc->Type);
607 607
608 return 0; 608 return 0;
609 } 609 }
610 610
611 /* Validate descriptor checksum */ 611 /* Validate descriptor checksum */
612 static int valid_csum(struct ti_i2c_desc *rom_desc, __u8 *buffer) 612 static int valid_csum(struct ti_i2c_desc *rom_desc, __u8 *buffer)
613 { 613 {
614 __u16 i; 614 __u16 i;
615 __u8 cs = 0; 615 __u8 cs = 0;
616 616
617 for (i = 0; i < le16_to_cpu(rom_desc->Size); i++) 617 for (i = 0; i < le16_to_cpu(rom_desc->Size); i++)
618 cs = (__u8)(cs + buffer[i]); 618 cs = (__u8)(cs + buffer[i]);
619 619
620 if (cs != rom_desc->CheckSum) { 620 if (cs != rom_desc->CheckSum) {
621 pr_debug("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); 621 pr_debug("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs);
622 return -EINVAL; 622 return -EINVAL;
623 } 623 }
624 return 0; 624 return 0;
625 } 625 }
626 626
627 /* Make sure that the I2C image is good */ 627 /* Make sure that the I2C image is good */
628 static int check_i2c_image(struct edgeport_serial *serial) 628 static int check_i2c_image(struct edgeport_serial *serial)
629 { 629 {
630 struct device *dev = &serial->serial->dev->dev; 630 struct device *dev = &serial->serial->dev->dev;
631 int status = 0; 631 int status = 0;
632 struct ti_i2c_desc *rom_desc; 632 struct ti_i2c_desc *rom_desc;
633 int start_address = 2; 633 int start_address = 2;
634 __u8 *buffer; 634 __u8 *buffer;
635 __u16 ttype; 635 __u16 ttype;
636 636
637 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); 637 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL);
638 if (!rom_desc) 638 if (!rom_desc)
639 return -ENOMEM; 639 return -ENOMEM;
640 640
641 buffer = kmalloc(TI_MAX_I2C_SIZE, GFP_KERNEL); 641 buffer = kmalloc(TI_MAX_I2C_SIZE, GFP_KERNEL);
642 if (!buffer) { 642 if (!buffer) {
643 kfree(rom_desc); 643 kfree(rom_desc);
644 return -ENOMEM; 644 return -ENOMEM;
645 } 645 }
646 646
647 /* Read the first byte (Signature0) must be 0x52 or 0x10 */ 647 /* Read the first byte (Signature0) must be 0x52 or 0x10 */
648 status = read_rom(serial, 0, 1, buffer); 648 status = read_rom(serial, 0, 1, buffer);
649 if (status) 649 if (status)
650 goto out; 650 goto out;
651 651
652 if (*buffer != UMP5152 && *buffer != UMP3410) { 652 if (*buffer != UMP5152 && *buffer != UMP3410) {
653 dev_err(dev, "%s - invalid buffer signature\n", __func__); 653 dev_err(dev, "%s - invalid buffer signature\n", __func__);
654 status = -ENODEV; 654 status = -ENODEV;
655 goto out; 655 goto out;
656 } 656 }
657 657
658 do { 658 do {
659 /* Validate the I2C */ 659 /* Validate the I2C */
660 status = read_rom(serial, 660 status = read_rom(serial,
661 start_address, 661 start_address,
662 sizeof(struct ti_i2c_desc), 662 sizeof(struct ti_i2c_desc),
663 (__u8 *)rom_desc); 663 (__u8 *)rom_desc);
664 if (status) 664 if (status)
665 break; 665 break;
666 666
667 if ((start_address + sizeof(struct ti_i2c_desc) + 667 if ((start_address + sizeof(struct ti_i2c_desc) +
668 le16_to_cpu(rom_desc->Size)) > TI_MAX_I2C_SIZE) { 668 le16_to_cpu(rom_desc->Size)) > TI_MAX_I2C_SIZE) {
669 status = -ENODEV; 669 status = -ENODEV;
670 dev_dbg(dev, "%s - structure too big, erroring out.\n", __func__); 670 dev_dbg(dev, "%s - structure too big, erroring out.\n", __func__);
671 break; 671 break;
672 } 672 }
673 673
674 dev_dbg(dev, "%s Type = 0x%x\n", __func__, rom_desc->Type); 674 dev_dbg(dev, "%s Type = 0x%x\n", __func__, rom_desc->Type);
675 675
676 /* Skip type 2 record */ 676 /* Skip type 2 record */
677 ttype = rom_desc->Type & 0x0f; 677 ttype = rom_desc->Type & 0x0f;
678 if (ttype != I2C_DESC_TYPE_FIRMWARE_BASIC 678 if (ttype != I2C_DESC_TYPE_FIRMWARE_BASIC
679 && ttype != I2C_DESC_TYPE_FIRMWARE_AUTO) { 679 && ttype != I2C_DESC_TYPE_FIRMWARE_AUTO) {
680 /* Read the descriptor data */ 680 /* Read the descriptor data */
681 status = read_rom(serial, start_address + 681 status = read_rom(serial, start_address +
682 sizeof(struct ti_i2c_desc), 682 sizeof(struct ti_i2c_desc),
683 le16_to_cpu(rom_desc->Size), 683 le16_to_cpu(rom_desc->Size),
684 buffer); 684 buffer);
685 if (status) 685 if (status)
686 break; 686 break;
687 687
688 status = valid_csum(rom_desc, buffer); 688 status = valid_csum(rom_desc, buffer);
689 if (status) 689 if (status)
690 break; 690 break;
691 } 691 }
692 start_address = start_address + sizeof(struct ti_i2c_desc) + 692 start_address = start_address + sizeof(struct ti_i2c_desc) +
693 le16_to_cpu(rom_desc->Size); 693 le16_to_cpu(rom_desc->Size);
694 694
695 } while ((rom_desc->Type != I2C_DESC_TYPE_ION) && 695 } while ((rom_desc->Type != I2C_DESC_TYPE_ION) &&
696 (start_address < TI_MAX_I2C_SIZE)); 696 (start_address < TI_MAX_I2C_SIZE));
697 697
698 if ((rom_desc->Type != I2C_DESC_TYPE_ION) || 698 if ((rom_desc->Type != I2C_DESC_TYPE_ION) ||
699 (start_address > TI_MAX_I2C_SIZE)) 699 (start_address > TI_MAX_I2C_SIZE))
700 status = -ENODEV; 700 status = -ENODEV;
701 701
702 out: 702 out:
703 kfree(buffer); 703 kfree(buffer);
704 kfree(rom_desc); 704 kfree(rom_desc);
705 return status; 705 return status;
706 } 706 }
707 707
708 static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer) 708 static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer)
709 { 709 {
710 int status; 710 int status;
711 int start_address; 711 int start_address;
712 struct ti_i2c_desc *rom_desc; 712 struct ti_i2c_desc *rom_desc;
713 struct edge_ti_manuf_descriptor *desc; 713 struct edge_ti_manuf_descriptor *desc;
714 struct device *dev = &serial->serial->dev->dev; 714 struct device *dev = &serial->serial->dev->dev;
715 715
716 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); 716 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL);
717 if (!rom_desc) 717 if (!rom_desc)
718 return -ENOMEM; 718 return -ENOMEM;
719 719
720 start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION, 720 start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION,
721 rom_desc); 721 rom_desc);
722 722
723 if (!start_address) { 723 if (!start_address) {
724 dev_dbg(dev, "%s - Edge Descriptor not found in I2C\n", __func__); 724 dev_dbg(dev, "%s - Edge Descriptor not found in I2C\n", __func__);
725 status = -ENODEV; 725 status = -ENODEV;
726 goto exit; 726 goto exit;
727 } 727 }
728 728
729 /* Read the descriptor data */ 729 /* Read the descriptor data */
730 status = read_rom(serial, start_address+sizeof(struct ti_i2c_desc), 730 status = read_rom(serial, start_address+sizeof(struct ti_i2c_desc),
731 le16_to_cpu(rom_desc->Size), buffer); 731 le16_to_cpu(rom_desc->Size), buffer);
732 if (status) 732 if (status)
733 goto exit; 733 goto exit;
734 734
735 status = valid_csum(rom_desc, buffer); 735 status = valid_csum(rom_desc, buffer);
736 736
737 desc = (struct edge_ti_manuf_descriptor *)buffer; 737 desc = (struct edge_ti_manuf_descriptor *)buffer;
738 dev_dbg(dev, "%s - IonConfig 0x%x\n", __func__, desc->IonConfig); 738 dev_dbg(dev, "%s - IonConfig 0x%x\n", __func__, desc->IonConfig);
739 dev_dbg(dev, "%s - Version %d\n", __func__, desc->Version); 739 dev_dbg(dev, "%s - Version %d\n", __func__, desc->Version);
740 dev_dbg(dev, "%s - Cpu/Board 0x%x\n", __func__, desc->CpuRev_BoardRev); 740 dev_dbg(dev, "%s - Cpu/Board 0x%x\n", __func__, desc->CpuRev_BoardRev);
741 dev_dbg(dev, "%s - NumPorts %d\n", __func__, desc->NumPorts); 741 dev_dbg(dev, "%s - NumPorts %d\n", __func__, desc->NumPorts);
742 dev_dbg(dev, "%s - NumVirtualPorts %d\n", __func__, desc->NumVirtualPorts); 742 dev_dbg(dev, "%s - NumVirtualPorts %d\n", __func__, desc->NumVirtualPorts);
743 dev_dbg(dev, "%s - TotalPorts %d\n", __func__, desc->TotalPorts); 743 dev_dbg(dev, "%s - TotalPorts %d\n", __func__, desc->TotalPorts);
744 744
745 exit: 745 exit:
746 kfree(rom_desc); 746 kfree(rom_desc);
747 return status; 747 return status;
748 } 748 }
749 749
750 /* Build firmware header used for firmware update */ 750 /* Build firmware header used for firmware update */
751 static int build_i2c_fw_hdr(__u8 *header, struct device *dev) 751 static int build_i2c_fw_hdr(__u8 *header, struct device *dev)
752 { 752 {
753 __u8 *buffer; 753 __u8 *buffer;
754 int buffer_size; 754 int buffer_size;
755 int i; 755 int i;
756 int err; 756 int err;
757 __u8 cs = 0; 757 __u8 cs = 0;
758 struct ti_i2c_desc *i2c_header; 758 struct ti_i2c_desc *i2c_header;
759 struct ti_i2c_image_header *img_header; 759 struct ti_i2c_image_header *img_header;
760 struct ti_i2c_firmware_rec *firmware_rec; 760 struct ti_i2c_firmware_rec *firmware_rec;
761 const struct firmware *fw; 761 const struct firmware *fw;
762 const char *fw_name = "edgeport/down3.bin"; 762 const char *fw_name = "edgeport/down3.bin";
763 763
764 /* In order to update the I2C firmware we must change the type 2 record 764 /* In order to update the I2C firmware we must change the type 2 record
765 * to type 0xF2. This will force the UMP to come up in Boot Mode. 765 * to type 0xF2. This will force the UMP to come up in Boot Mode.
766 * Then while in boot mode, the driver will download the latest 766 * Then while in boot mode, the driver will download the latest
767 * firmware (padded to 15.5k) into the UMP ram. And finally when the 767 * firmware (padded to 15.5k) into the UMP ram. And finally when the
768 * device comes back up in download mode the driver will cause the new 768 * device comes back up in download mode the driver will cause the new
769 * firmware to be copied from the UMP Ram to I2C and the firmware will 769 * firmware to be copied from the UMP Ram to I2C and the firmware will
770 * update the record type from 0xf2 to 0x02. 770 * update the record type from 0xf2 to 0x02.
771 */ 771 */
772 772
773 /* Allocate a 15.5k buffer + 2 bytes for version number 773 /* Allocate a 15.5k buffer + 2 bytes for version number
774 * (Firmware Record) */ 774 * (Firmware Record) */
775 buffer_size = (((1024 * 16) - 512 ) + 775 buffer_size = (((1024 * 16) - 512 ) +
776 sizeof(struct ti_i2c_firmware_rec)); 776 sizeof(struct ti_i2c_firmware_rec));
777 777
778 buffer = kmalloc(buffer_size, GFP_KERNEL); 778 buffer = kmalloc(buffer_size, GFP_KERNEL);
779 if (!buffer) 779 if (!buffer)
780 return -ENOMEM; 780 return -ENOMEM;
781 781
782 // Set entire image of 0xffs 782 // Set entire image of 0xffs
783 memset(buffer, 0xff, buffer_size); 783 memset(buffer, 0xff, buffer_size);
784 784
785 err = request_firmware(&fw, fw_name, dev); 785 err = request_firmware(&fw, fw_name, dev);
786 if (err) { 786 if (err) {
787 dev_err(dev, "Failed to load image \"%s\" err %d\n", 787 dev_err(dev, "Failed to load image \"%s\" err %d\n",
788 fw_name, err); 788 fw_name, err);
789 kfree(buffer); 789 kfree(buffer);
790 return err; 790 return err;
791 } 791 }
792 792
793 /* Save Download Version Number */ 793 /* Save Download Version Number */
794 OperationalMajorVersion = fw->data[0]; 794 OperationalMajorVersion = fw->data[0];
795 OperationalMinorVersion = fw->data[1]; 795 OperationalMinorVersion = fw->data[1];
796 OperationalBuildNumber = fw->data[2] | (fw->data[3] << 8); 796 OperationalBuildNumber = fw->data[2] | (fw->data[3] << 8);
797 797
798 /* Copy version number into firmware record */ 798 /* Copy version number into firmware record */
799 firmware_rec = (struct ti_i2c_firmware_rec *)buffer; 799 firmware_rec = (struct ti_i2c_firmware_rec *)buffer;
800 800
801 firmware_rec->Ver_Major = OperationalMajorVersion; 801 firmware_rec->Ver_Major = OperationalMajorVersion;
802 firmware_rec->Ver_Minor = OperationalMinorVersion; 802 firmware_rec->Ver_Minor = OperationalMinorVersion;
803 803
804 /* Pointer to fw_down memory image */ 804 /* Pointer to fw_down memory image */
805 img_header = (struct ti_i2c_image_header *)&fw->data[4]; 805 img_header = (struct ti_i2c_image_header *)&fw->data[4];
806 806
807 memcpy(buffer + sizeof(struct ti_i2c_firmware_rec), 807 memcpy(buffer + sizeof(struct ti_i2c_firmware_rec),
808 &fw->data[4 + sizeof(struct ti_i2c_image_header)], 808 &fw->data[4 + sizeof(struct ti_i2c_image_header)],
809 le16_to_cpu(img_header->Length)); 809 le16_to_cpu(img_header->Length));
810 810
811 release_firmware(fw); 811 release_firmware(fw);
812 812
813 for (i=0; i < buffer_size; i++) { 813 for (i=0; i < buffer_size; i++) {
814 cs = (__u8)(cs + buffer[i]); 814 cs = (__u8)(cs + buffer[i]);
815 } 815 }
816 816
817 kfree(buffer); 817 kfree(buffer);
818 818
819 /* Build new header */ 819 /* Build new header */
820 i2c_header = (struct ti_i2c_desc *)header; 820 i2c_header = (struct ti_i2c_desc *)header;
821 firmware_rec = (struct ti_i2c_firmware_rec*)i2c_header->Data; 821 firmware_rec = (struct ti_i2c_firmware_rec*)i2c_header->Data;
822 822
823 i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK; 823 i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK;
824 i2c_header->Size = (__u16)buffer_size; 824 i2c_header->Size = cpu_to_le16(buffer_size);
825 i2c_header->CheckSum = cs; 825 i2c_header->CheckSum = cs;
826 firmware_rec->Ver_Major = OperationalMajorVersion; 826 firmware_rec->Ver_Major = OperationalMajorVersion;
827 firmware_rec->Ver_Minor = OperationalMinorVersion; 827 firmware_rec->Ver_Minor = OperationalMinorVersion;
828 828
829 return 0; 829 return 0;
830 } 830 }
831 831
832 /* Try to figure out what type of I2c we have */ 832 /* Try to figure out what type of I2c we have */
833 static int i2c_type_bootmode(struct edgeport_serial *serial) 833 static int i2c_type_bootmode(struct edgeport_serial *serial)
834 { 834 {
835 struct device *dev = &serial->serial->dev->dev; 835 struct device *dev = &serial->serial->dev->dev;
836 int status; 836 int status;
837 u8 *data; 837 u8 *data;
838 838
839 data = kmalloc(1, GFP_KERNEL); 839 data = kmalloc(1, GFP_KERNEL);
840 if (!data) 840 if (!data)
841 return -ENOMEM; 841 return -ENOMEM;
842 842
843 /* Try to read type 2 */ 843 /* Try to read type 2 */
844 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 844 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ,
845 DTK_ADDR_SPACE_I2C_TYPE_II, 0, data, 0x01); 845 DTK_ADDR_SPACE_I2C_TYPE_II, 0, data, 0x01);
846 if (status) 846 if (status)
847 dev_dbg(dev, "%s - read 2 status error = %d\n", __func__, status); 847 dev_dbg(dev, "%s - read 2 status error = %d\n", __func__, status);
848 else 848 else
849 dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data); 849 dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data);
850 if ((!status) && (*data == UMP5152 || *data == UMP3410)) { 850 if ((!status) && (*data == UMP5152 || *data == UMP3410)) {
851 dev_dbg(dev, "%s - ROM_TYPE_II\n", __func__); 851 dev_dbg(dev, "%s - ROM_TYPE_II\n", __func__);
852 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 852 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
853 goto out; 853 goto out;
854 } 854 }
855 855
856 /* Try to read type 3 */ 856 /* Try to read type 3 */
857 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 857 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ,
858 DTK_ADDR_SPACE_I2C_TYPE_III, 0, data, 0x01); 858 DTK_ADDR_SPACE_I2C_TYPE_III, 0, data, 0x01);
859 if (status) 859 if (status)
860 dev_dbg(dev, "%s - read 3 status error = %d\n", __func__, status); 860 dev_dbg(dev, "%s - read 3 status error = %d\n", __func__, status);
861 else 861 else
862 dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data); 862 dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data);
863 if ((!status) && (*data == UMP5152 || *data == UMP3410)) { 863 if ((!status) && (*data == UMP5152 || *data == UMP3410)) {
864 dev_dbg(dev, "%s - ROM_TYPE_III\n", __func__); 864 dev_dbg(dev, "%s - ROM_TYPE_III\n", __func__);
865 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; 865 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III;
866 goto out; 866 goto out;
867 } 867 }
868 868
869 dev_dbg(dev, "%s - Unknown\n", __func__); 869 dev_dbg(dev, "%s - Unknown\n", __func__);
870 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 870 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
871 status = -ENODEV; 871 status = -ENODEV;
872 out: 872 out:
873 kfree(data); 873 kfree(data);
874 return status; 874 return status;
875 } 875 }
876 876
877 static int bulk_xfer(struct usb_serial *serial, void *buffer, 877 static int bulk_xfer(struct usb_serial *serial, void *buffer,
878 int length, int *num_sent) 878 int length, int *num_sent)
879 { 879 {
880 int status; 880 int status;
881 881
882 status = usb_bulk_msg(serial->dev, 882 status = usb_bulk_msg(serial->dev,
883 usb_sndbulkpipe(serial->dev, 883 usb_sndbulkpipe(serial->dev,
884 serial->port[0]->bulk_out_endpointAddress), 884 serial->port[0]->bulk_out_endpointAddress),
885 buffer, length, num_sent, 1000); 885 buffer, length, num_sent, 1000);
886 return status; 886 return status;
887 } 887 }
888 888
889 /* Download given firmware image to the device (IN BOOT MODE) */ 889 /* Download given firmware image to the device (IN BOOT MODE) */
890 static int download_code(struct edgeport_serial *serial, __u8 *image, 890 static int download_code(struct edgeport_serial *serial, __u8 *image,
891 int image_length) 891 int image_length)
892 { 892 {
893 int status = 0; 893 int status = 0;
894 int pos; 894 int pos;
895 int transfer; 895 int transfer;
896 int done; 896 int done;
897 897
898 /* Transfer firmware image */ 898 /* Transfer firmware image */
899 for (pos = 0; pos < image_length; ) { 899 for (pos = 0; pos < image_length; ) {
900 /* Read the next buffer from file */ 900 /* Read the next buffer from file */
901 transfer = image_length - pos; 901 transfer = image_length - pos;
902 if (transfer > EDGE_FW_BULK_MAX_PACKET_SIZE) 902 if (transfer > EDGE_FW_BULK_MAX_PACKET_SIZE)
903 transfer = EDGE_FW_BULK_MAX_PACKET_SIZE; 903 transfer = EDGE_FW_BULK_MAX_PACKET_SIZE;
904 904
905 /* Transfer data */ 905 /* Transfer data */
906 status = bulk_xfer(serial->serial, &image[pos], 906 status = bulk_xfer(serial->serial, &image[pos],
907 transfer, &done); 907 transfer, &done);
908 if (status) 908 if (status)
909 break; 909 break;
910 /* Advance buffer pointer */ 910 /* Advance buffer pointer */
911 pos += done; 911 pos += done;
912 } 912 }
913 913
914 return status; 914 return status;
915 } 915 }
916 916
917 /* FIXME!!! */ 917 /* FIXME!!! */
918 static int config_boot_dev(struct usb_device *dev) 918 static int config_boot_dev(struct usb_device *dev)
919 { 919 {
920 return 0; 920 return 0;
921 } 921 }
922 922
923 static int ti_cpu_rev(struct edge_ti_manuf_descriptor *desc) 923 static int ti_cpu_rev(struct edge_ti_manuf_descriptor *desc)
924 { 924 {
925 return TI_GET_CPU_REVISION(desc->CpuRev_BoardRev); 925 return TI_GET_CPU_REVISION(desc->CpuRev_BoardRev);
926 } 926 }
927 927
928 /** 928 /**
929 * DownloadTIFirmware - Download run-time operating firmware to the TI5052 929 * DownloadTIFirmware - Download run-time operating firmware to the TI5052
930 * 930 *
931 * This routine downloads the main operating code into the TI5052, using the 931 * This routine downloads the main operating code into the TI5052, using the
932 * boot code already burned into E2PROM or ROM. 932 * boot code already burned into E2PROM or ROM.
933 */ 933 */
934 static int download_fw(struct edgeport_serial *serial) 934 static int download_fw(struct edgeport_serial *serial)
935 { 935 {
936 struct device *dev = &serial->serial->dev->dev; 936 struct device *dev = &serial->serial->dev->dev;
937 int status = 0; 937 int status = 0;
938 int start_address; 938 int start_address;
939 struct edge_ti_manuf_descriptor *ti_manuf_desc; 939 struct edge_ti_manuf_descriptor *ti_manuf_desc;
940 struct usb_interface_descriptor *interface; 940 struct usb_interface_descriptor *interface;
941 int download_cur_ver; 941 int download_cur_ver;
942 int download_new_ver; 942 int download_new_ver;
943 943
944 /* This routine is entered by both the BOOT mode and the Download mode 944 /* This routine is entered by both the BOOT mode and the Download mode
945 * We can determine which code is running by the reading the config 945 * We can determine which code is running by the reading the config
946 * descriptor and if we have only one bulk pipe it is in boot mode 946 * descriptor and if we have only one bulk pipe it is in boot mode
947 */ 947 */
948 serial->product_info.hardware_type = HARDWARE_TYPE_TIUMP; 948 serial->product_info.hardware_type = HARDWARE_TYPE_TIUMP;
949 949
950 /* Default to type 2 i2c */ 950 /* Default to type 2 i2c */
951 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 951 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
952 952
953 status = choose_config(serial->serial->dev); 953 status = choose_config(serial->serial->dev);
954 if (status) 954 if (status)
955 return status; 955 return status;
956 956
957 interface = &serial->serial->interface->cur_altsetting->desc; 957 interface = &serial->serial->interface->cur_altsetting->desc;
958 if (!interface) { 958 if (!interface) {
959 dev_err(dev, "%s - no interface set, error!\n", __func__); 959 dev_err(dev, "%s - no interface set, error!\n", __func__);
960 return -ENODEV; 960 return -ENODEV;
961 } 961 }
962 962
963 /* 963 /*
964 * Setup initial mode -- the default mode 0 is TI_MODE_CONFIGURING 964 * Setup initial mode -- the default mode 0 is TI_MODE_CONFIGURING
965 * if we have more than one endpoint we are definitely in download 965 * if we have more than one endpoint we are definitely in download
966 * mode 966 * mode
967 */ 967 */
968 if (interface->bNumEndpoints > 1) 968 if (interface->bNumEndpoints > 1)
969 serial->product_info.TiMode = TI_MODE_DOWNLOAD; 969 serial->product_info.TiMode = TI_MODE_DOWNLOAD;
970 else 970 else
971 /* Otherwise we will remain in configuring mode */ 971 /* Otherwise we will remain in configuring mode */
972 serial->product_info.TiMode = TI_MODE_CONFIGURING; 972 serial->product_info.TiMode = TI_MODE_CONFIGURING;
973 973
974 /********************************************************************/ 974 /********************************************************************/
975 /* Download Mode */ 975 /* Download Mode */
976 /********************************************************************/ 976 /********************************************************************/
977 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { 977 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) {
978 struct ti_i2c_desc *rom_desc; 978 struct ti_i2c_desc *rom_desc;
979 979
980 dev_dbg(dev, "%s - RUNNING IN DOWNLOAD MODE\n", __func__); 980 dev_dbg(dev, "%s - RUNNING IN DOWNLOAD MODE\n", __func__);
981 981
982 status = check_i2c_image(serial); 982 status = check_i2c_image(serial);
983 if (status) { 983 if (status) {
984 dev_dbg(dev, "%s - DOWNLOAD MODE -- BAD I2C\n", __func__); 984 dev_dbg(dev, "%s - DOWNLOAD MODE -- BAD I2C\n", __func__);
985 return status; 985 return status;
986 } 986 }
987 987
988 /* Validate Hardware version number 988 /* Validate Hardware version number
989 * Read Manufacturing Descriptor from TI Based Edgeport 989 * Read Manufacturing Descriptor from TI Based Edgeport
990 */ 990 */
991 ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL); 991 ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL);
992 if (!ti_manuf_desc) 992 if (!ti_manuf_desc)
993 return -ENOMEM; 993 return -ENOMEM;
994 994
995 status = get_manuf_info(serial, (__u8 *)ti_manuf_desc); 995 status = get_manuf_info(serial, (__u8 *)ti_manuf_desc);
996 if (status) { 996 if (status) {
997 kfree(ti_manuf_desc); 997 kfree(ti_manuf_desc);
998 return status; 998 return status;
999 } 999 }
1000 1000
1001 /* Check version number of ION descriptor */ 1001 /* Check version number of ION descriptor */
1002 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { 1002 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) {
1003 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n", 1003 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n",
1004 __func__, ti_cpu_rev(ti_manuf_desc)); 1004 __func__, ti_cpu_rev(ti_manuf_desc));
1005 kfree(ti_manuf_desc); 1005 kfree(ti_manuf_desc);
1006 return -EINVAL; 1006 return -EINVAL;
1007 } 1007 }
1008 1008
1009 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); 1009 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL);
1010 if (!rom_desc) { 1010 if (!rom_desc) {
1011 kfree(ti_manuf_desc); 1011 kfree(ti_manuf_desc);
1012 return -ENOMEM; 1012 return -ENOMEM;
1013 } 1013 }
1014 1014
1015 /* Search for type 2 record (firmware record) */ 1015 /* Search for type 2 record (firmware record) */
1016 start_address = get_descriptor_addr(serial, 1016 start_address = get_descriptor_addr(serial,
1017 I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc); 1017 I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc);
1018 if (start_address != 0) { 1018 if (start_address != 0) {
1019 struct ti_i2c_firmware_rec *firmware_version; 1019 struct ti_i2c_firmware_rec *firmware_version;
1020 u8 *record; 1020 u8 *record;
1021 1021
1022 dev_dbg(dev, "%s - Found Type FIRMWARE (Type 2) record\n", __func__); 1022 dev_dbg(dev, "%s - Found Type FIRMWARE (Type 2) record\n", __func__);
1023 1023
1024 firmware_version = kmalloc(sizeof(*firmware_version), 1024 firmware_version = kmalloc(sizeof(*firmware_version),
1025 GFP_KERNEL); 1025 GFP_KERNEL);
1026 if (!firmware_version) { 1026 if (!firmware_version) {
1027 kfree(rom_desc); 1027 kfree(rom_desc);
1028 kfree(ti_manuf_desc); 1028 kfree(ti_manuf_desc);
1029 return -ENOMEM; 1029 return -ENOMEM;
1030 } 1030 }
1031 1031
1032 /* Validate version number 1032 /* Validate version number
1033 * Read the descriptor data 1033 * Read the descriptor data
1034 */ 1034 */
1035 status = read_rom(serial, start_address + 1035 status = read_rom(serial, start_address +
1036 sizeof(struct ti_i2c_desc), 1036 sizeof(struct ti_i2c_desc),
1037 sizeof(struct ti_i2c_firmware_rec), 1037 sizeof(struct ti_i2c_firmware_rec),
1038 (__u8 *)firmware_version); 1038 (__u8 *)firmware_version);
1039 if (status) { 1039 if (status) {
1040 kfree(firmware_version); 1040 kfree(firmware_version);
1041 kfree(rom_desc); 1041 kfree(rom_desc);
1042 kfree(ti_manuf_desc); 1042 kfree(ti_manuf_desc);
1043 return status; 1043 return status;
1044 } 1044 }
1045 1045
1046 /* Check version number of download with current 1046 /* Check version number of download with current
1047 version in I2c */ 1047 version in I2c */
1048 download_cur_ver = (firmware_version->Ver_Major << 8) + 1048 download_cur_ver = (firmware_version->Ver_Major << 8) +
1049 (firmware_version->Ver_Minor); 1049 (firmware_version->Ver_Minor);
1050 download_new_ver = (OperationalMajorVersion << 8) + 1050 download_new_ver = (OperationalMajorVersion << 8) +
1051 (OperationalMinorVersion); 1051 (OperationalMinorVersion);
1052 1052
1053 dev_dbg(dev, "%s - >> FW Versions Device %d.%d Driver %d.%d\n", 1053 dev_dbg(dev, "%s - >> FW Versions Device %d.%d Driver %d.%d\n",
1054 __func__, firmware_version->Ver_Major, 1054 __func__, firmware_version->Ver_Major,
1055 firmware_version->Ver_Minor, 1055 firmware_version->Ver_Minor,
1056 OperationalMajorVersion, 1056 OperationalMajorVersion,
1057 OperationalMinorVersion); 1057 OperationalMinorVersion);
1058 1058
1059 /* Check if we have an old version in the I2C and 1059 /* Check if we have an old version in the I2C and
1060 update if necessary */ 1060 update if necessary */
1061 if (download_cur_ver < download_new_ver) { 1061 if (download_cur_ver < download_new_ver) {
1062 dev_dbg(dev, "%s - Update I2C dld from %d.%d to %d.%d\n", 1062 dev_dbg(dev, "%s - Update I2C dld from %d.%d to %d.%d\n",
1063 __func__, 1063 __func__,
1064 firmware_version->Ver_Major, 1064 firmware_version->Ver_Major,
1065 firmware_version->Ver_Minor, 1065 firmware_version->Ver_Minor,
1066 OperationalMajorVersion, 1066 OperationalMajorVersion,
1067 OperationalMinorVersion); 1067 OperationalMinorVersion);
1068 1068
1069 record = kmalloc(1, GFP_KERNEL); 1069 record = kmalloc(1, GFP_KERNEL);
1070 if (!record) { 1070 if (!record) {
1071 kfree(firmware_version); 1071 kfree(firmware_version);
1072 kfree(rom_desc); 1072 kfree(rom_desc);
1073 kfree(ti_manuf_desc); 1073 kfree(ti_manuf_desc);
1074 return -ENOMEM; 1074 return -ENOMEM;
1075 } 1075 }
1076 /* In order to update the I2C firmware we must 1076 /* In order to update the I2C firmware we must
1077 * change the type 2 record to type 0xF2. This 1077 * change the type 2 record to type 0xF2. This
1078 * will force the UMP to come up in Boot Mode. 1078 * will force the UMP to come up in Boot Mode.
1079 * Then while in boot mode, the driver will 1079 * Then while in boot mode, the driver will
1080 * download the latest firmware (padded to 1080 * download the latest firmware (padded to
1081 * 15.5k) into the UMP ram. Finally when the 1081 * 15.5k) into the UMP ram. Finally when the
1082 * device comes back up in download mode the 1082 * device comes back up in download mode the
1083 * driver will cause the new firmware to be 1083 * driver will cause the new firmware to be
1084 * copied from the UMP Ram to I2C and the 1084 * copied from the UMP Ram to I2C and the
1085 * firmware will update the record type from 1085 * firmware will update the record type from
1086 * 0xf2 to 0x02. 1086 * 0xf2 to 0x02.
1087 */ 1087 */
1088 *record = I2C_DESC_TYPE_FIRMWARE_BLANK; 1088 *record = I2C_DESC_TYPE_FIRMWARE_BLANK;
1089 1089
1090 /* Change the I2C Firmware record type to 1090 /* Change the I2C Firmware record type to
1091 0xf2 to trigger an update */ 1091 0xf2 to trigger an update */
1092 status = write_rom(serial, start_address, 1092 status = write_rom(serial, start_address,
1093 sizeof(*record), record); 1093 sizeof(*record), record);
1094 if (status) { 1094 if (status) {
1095 kfree(record); 1095 kfree(record);
1096 kfree(firmware_version); 1096 kfree(firmware_version);
1097 kfree(rom_desc); 1097 kfree(rom_desc);
1098 kfree(ti_manuf_desc); 1098 kfree(ti_manuf_desc);
1099 return status; 1099 return status;
1100 } 1100 }
1101 1101
1102 /* verify the write -- must do this in order 1102 /* verify the write -- must do this in order
1103 * for write to complete before we do the 1103 * for write to complete before we do the
1104 * hardware reset 1104 * hardware reset
1105 */ 1105 */
1106 status = read_rom(serial, 1106 status = read_rom(serial,
1107 start_address, 1107 start_address,
1108 sizeof(*record), 1108 sizeof(*record),
1109 record); 1109 record);
1110 if (status) { 1110 if (status) {
1111 kfree(record); 1111 kfree(record);
1112 kfree(firmware_version); 1112 kfree(firmware_version);
1113 kfree(rom_desc); 1113 kfree(rom_desc);
1114 kfree(ti_manuf_desc); 1114 kfree(ti_manuf_desc);
1115 return status; 1115 return status;
1116 } 1116 }
1117 1117
1118 if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) { 1118 if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) {
1119 dev_err(dev, "%s - error resetting device\n", __func__); 1119 dev_err(dev, "%s - error resetting device\n", __func__);
1120 kfree(record); 1120 kfree(record);
1121 kfree(firmware_version); 1121 kfree(firmware_version);
1122 kfree(rom_desc); 1122 kfree(rom_desc);
1123 kfree(ti_manuf_desc); 1123 kfree(ti_manuf_desc);
1124 return -ENODEV; 1124 return -ENODEV;
1125 } 1125 }
1126 1126
1127 dev_dbg(dev, "%s - HARDWARE RESET\n", __func__); 1127 dev_dbg(dev, "%s - HARDWARE RESET\n", __func__);
1128 1128
1129 /* Reset UMP -- Back to BOOT MODE */ 1129 /* Reset UMP -- Back to BOOT MODE */
1130 status = ti_vsend_sync(serial->serial->dev, 1130 status = ti_vsend_sync(serial->serial->dev,
1131 UMPC_HARDWARE_RESET, 1131 UMPC_HARDWARE_RESET,
1132 0, 0, NULL, 0); 1132 0, 0, NULL, 0);
1133 1133
1134 dev_dbg(dev, "%s - HARDWARE RESET return %d\n", __func__, status); 1134 dev_dbg(dev, "%s - HARDWARE RESET return %d\n", __func__, status);
1135 1135
1136 /* return an error on purpose. */ 1136 /* return an error on purpose. */
1137 kfree(record); 1137 kfree(record);
1138 kfree(firmware_version); 1138 kfree(firmware_version);
1139 kfree(rom_desc); 1139 kfree(rom_desc);
1140 kfree(ti_manuf_desc); 1140 kfree(ti_manuf_desc);
1141 return -ENODEV; 1141 return -ENODEV;
1142 } 1142 }
1143 kfree(firmware_version); 1143 kfree(firmware_version);
1144 } 1144 }
1145 /* Search for type 0xF2 record (firmware blank record) */ 1145 /* Search for type 0xF2 record (firmware blank record) */
1146 else if ((start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_FIRMWARE_BLANK, rom_desc)) != 0) { 1146 else if ((start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_FIRMWARE_BLANK, rom_desc)) != 0) {
1147 #define HEADER_SIZE (sizeof(struct ti_i2c_desc) + \ 1147 #define HEADER_SIZE (sizeof(struct ti_i2c_desc) + \
1148 sizeof(struct ti_i2c_firmware_rec)) 1148 sizeof(struct ti_i2c_firmware_rec))
1149 __u8 *header; 1149 __u8 *header;
1150 __u8 *vheader; 1150 __u8 *vheader;
1151 1151
1152 header = kmalloc(HEADER_SIZE, GFP_KERNEL); 1152 header = kmalloc(HEADER_SIZE, GFP_KERNEL);
1153 if (!header) { 1153 if (!header) {
1154 kfree(rom_desc); 1154 kfree(rom_desc);
1155 kfree(ti_manuf_desc); 1155 kfree(ti_manuf_desc);
1156 return -ENOMEM; 1156 return -ENOMEM;
1157 } 1157 }
1158 1158
1159 vheader = kmalloc(HEADER_SIZE, GFP_KERNEL); 1159 vheader = kmalloc(HEADER_SIZE, GFP_KERNEL);
1160 if (!vheader) { 1160 if (!vheader) {
1161 kfree(header); 1161 kfree(header);
1162 kfree(rom_desc); 1162 kfree(rom_desc);
1163 kfree(ti_manuf_desc); 1163 kfree(ti_manuf_desc);
1164 return -ENOMEM; 1164 return -ENOMEM;
1165 } 1165 }
1166 1166
1167 dev_dbg(dev, "%s - Found Type BLANK FIRMWARE (Type F2) record\n", __func__); 1167 dev_dbg(dev, "%s - Found Type BLANK FIRMWARE (Type F2) record\n", __func__);
1168 1168
1169 /* 1169 /*
1170 * In order to update the I2C firmware we must change 1170 * In order to update the I2C firmware we must change
1171 * the type 2 record to type 0xF2. This will force the 1171 * the type 2 record to type 0xF2. This will force the
1172 * UMP to come up in Boot Mode. Then while in boot 1172 * UMP to come up in Boot Mode. Then while in boot
1173 * mode, the driver will download the latest firmware 1173 * mode, the driver will download the latest firmware
1174 * (padded to 15.5k) into the UMP ram. Finally when the 1174 * (padded to 15.5k) into the UMP ram. Finally when the
1175 * device comes back up in download mode the driver 1175 * device comes back up in download mode the driver
1176 * will cause the new firmware to be copied from the 1176 * will cause the new firmware to be copied from the
1177 * UMP Ram to I2C and the firmware will update the 1177 * UMP Ram to I2C and the firmware will update the
1178 * record type from 0xf2 to 0x02. 1178 * record type from 0xf2 to 0x02.
1179 */ 1179 */
1180 status = build_i2c_fw_hdr(header, dev); 1180 status = build_i2c_fw_hdr(header, dev);
1181 if (status) { 1181 if (status) {
1182 kfree(vheader); 1182 kfree(vheader);
1183 kfree(header); 1183 kfree(header);
1184 kfree(rom_desc); 1184 kfree(rom_desc);
1185 kfree(ti_manuf_desc); 1185 kfree(ti_manuf_desc);
1186 return -EINVAL; 1186 return -EINVAL;
1187 } 1187 }
1188 1188
1189 /* Update I2C with type 0xf2 record with correct 1189 /* Update I2C with type 0xf2 record with correct
1190 size and checksum */ 1190 size and checksum */
1191 status = write_rom(serial, 1191 status = write_rom(serial,
1192 start_address, 1192 start_address,
1193 HEADER_SIZE, 1193 HEADER_SIZE,
1194 header); 1194 header);
1195 if (status) { 1195 if (status) {
1196 kfree(vheader); 1196 kfree(vheader);
1197 kfree(header); 1197 kfree(header);
1198 kfree(rom_desc); 1198 kfree(rom_desc);
1199 kfree(ti_manuf_desc); 1199 kfree(ti_manuf_desc);
1200 return -EINVAL; 1200 return -EINVAL;
1201 } 1201 }
1202 1202
1203 /* verify the write -- must do this in order for 1203 /* verify the write -- must do this in order for
1204 write to complete before we do the hardware reset */ 1204 write to complete before we do the hardware reset */
1205 status = read_rom(serial, start_address, 1205 status = read_rom(serial, start_address,
1206 HEADER_SIZE, vheader); 1206 HEADER_SIZE, vheader);
1207 1207
1208 if (status) { 1208 if (status) {
1209 dev_dbg(dev, "%s - can't read header back\n", __func__); 1209 dev_dbg(dev, "%s - can't read header back\n", __func__);
1210 kfree(vheader); 1210 kfree(vheader);
1211 kfree(header); 1211 kfree(header);
1212 kfree(rom_desc); 1212 kfree(rom_desc);
1213 kfree(ti_manuf_desc); 1213 kfree(ti_manuf_desc);
1214 return status; 1214 return status;
1215 } 1215 }
1216 if (memcmp(vheader, header, HEADER_SIZE)) { 1216 if (memcmp(vheader, header, HEADER_SIZE)) {
1217 dev_dbg(dev, "%s - write download record failed\n", __func__); 1217 dev_dbg(dev, "%s - write download record failed\n", __func__);
1218 kfree(vheader); 1218 kfree(vheader);
1219 kfree(header); 1219 kfree(header);
1220 kfree(rom_desc); 1220 kfree(rom_desc);
1221 kfree(ti_manuf_desc); 1221 kfree(ti_manuf_desc);
1222 return -EINVAL; 1222 return -EINVAL;
1223 } 1223 }
1224 1224
1225 kfree(vheader); 1225 kfree(vheader);
1226 kfree(header); 1226 kfree(header);
1227 1227
1228 dev_dbg(dev, "%s - Start firmware update\n", __func__); 1228 dev_dbg(dev, "%s - Start firmware update\n", __func__);
1229 1229
1230 /* Tell firmware to copy download image into I2C */ 1230 /* Tell firmware to copy download image into I2C */
1231 status = ti_vsend_sync(serial->serial->dev, 1231 status = ti_vsend_sync(serial->serial->dev,
1232 UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0); 1232 UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0);
1233 1233
1234 dev_dbg(dev, "%s - Update complete 0x%x\n", __func__, status); 1234 dev_dbg(dev, "%s - Update complete 0x%x\n", __func__, status);
1235 if (status) { 1235 if (status) {
1236 dev_err(dev, 1236 dev_err(dev,
1237 "%s - UMPC_COPY_DNLD_TO_I2C failed\n", 1237 "%s - UMPC_COPY_DNLD_TO_I2C failed\n",
1238 __func__); 1238 __func__);
1239 kfree(rom_desc); 1239 kfree(rom_desc);
1240 kfree(ti_manuf_desc); 1240 kfree(ti_manuf_desc);
1241 return status; 1241 return status;
1242 } 1242 }
1243 } 1243 }
1244 1244
1245 // The device is running the download code 1245 // The device is running the download code
1246 kfree(rom_desc); 1246 kfree(rom_desc);
1247 kfree(ti_manuf_desc); 1247 kfree(ti_manuf_desc);
1248 return 0; 1248 return 0;
1249 } 1249 }
1250 1250
1251 /********************************************************************/ 1251 /********************************************************************/
1252 /* Boot Mode */ 1252 /* Boot Mode */
1253 /********************************************************************/ 1253 /********************************************************************/
1254 dev_dbg(dev, "%s - RUNNING IN BOOT MODE\n", __func__); 1254 dev_dbg(dev, "%s - RUNNING IN BOOT MODE\n", __func__);
1255 1255
1256 /* Configure the TI device so we can use the BULK pipes for download */ 1256 /* Configure the TI device so we can use the BULK pipes for download */
1257 status = config_boot_dev(serial->serial->dev); 1257 status = config_boot_dev(serial->serial->dev);
1258 if (status) 1258 if (status)
1259 return status; 1259 return status;
1260 1260
1261 if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) 1261 if (le16_to_cpu(serial->serial->dev->descriptor.idVendor)
1262 != USB_VENDOR_ID_ION) { 1262 != USB_VENDOR_ID_ION) {
1263 dev_dbg(dev, "%s - VID = 0x%x\n", __func__, 1263 dev_dbg(dev, "%s - VID = 0x%x\n", __func__,
1264 le16_to_cpu(serial->serial->dev->descriptor.idVendor)); 1264 le16_to_cpu(serial->serial->dev->descriptor.idVendor));
1265 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 1265 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
1266 goto stayinbootmode; 1266 goto stayinbootmode;
1267 } 1267 }
1268 1268
1269 /* We have an ION device (I2c Must be programmed) 1269 /* We have an ION device (I2c Must be programmed)
1270 Determine I2C image type */ 1270 Determine I2C image type */
1271 if (i2c_type_bootmode(serial)) 1271 if (i2c_type_bootmode(serial))
1272 goto stayinbootmode; 1272 goto stayinbootmode;
1273 1273
1274 /* Check for ION Vendor ID and that the I2C is valid */ 1274 /* Check for ION Vendor ID and that the I2C is valid */
1275 if (!check_i2c_image(serial)) { 1275 if (!check_i2c_image(serial)) {
1276 struct ti_i2c_image_header *header; 1276 struct ti_i2c_image_header *header;
1277 int i; 1277 int i;
1278 __u8 cs = 0; 1278 __u8 cs = 0;
1279 __u8 *buffer; 1279 __u8 *buffer;
1280 int buffer_size; 1280 int buffer_size;
1281 int err; 1281 int err;
1282 const struct firmware *fw; 1282 const struct firmware *fw;
1283 const char *fw_name = "edgeport/down3.bin"; 1283 const char *fw_name = "edgeport/down3.bin";
1284 1284
1285 /* Validate Hardware version number 1285 /* Validate Hardware version number
1286 * Read Manufacturing Descriptor from TI Based Edgeport 1286 * Read Manufacturing Descriptor from TI Based Edgeport
1287 */ 1287 */
1288 ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL); 1288 ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL);
1289 if (!ti_manuf_desc) 1289 if (!ti_manuf_desc)
1290 return -ENOMEM; 1290 return -ENOMEM;
1291 1291
1292 status = get_manuf_info(serial, (__u8 *)ti_manuf_desc); 1292 status = get_manuf_info(serial, (__u8 *)ti_manuf_desc);
1293 if (status) { 1293 if (status) {
1294 kfree(ti_manuf_desc); 1294 kfree(ti_manuf_desc);
1295 goto stayinbootmode; 1295 goto stayinbootmode;
1296 } 1296 }
1297 1297
1298 /* Check for version 2 */ 1298 /* Check for version 2 */
1299 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { 1299 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) {
1300 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n", 1300 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n",
1301 __func__, ti_cpu_rev(ti_manuf_desc)); 1301 __func__, ti_cpu_rev(ti_manuf_desc));
1302 kfree(ti_manuf_desc); 1302 kfree(ti_manuf_desc);
1303 goto stayinbootmode; 1303 goto stayinbootmode;
1304 } 1304 }
1305 1305
1306 kfree(ti_manuf_desc); 1306 kfree(ti_manuf_desc);
1307 1307
1308 /* 1308 /*
1309 * In order to update the I2C firmware we must change the type 1309 * In order to update the I2C firmware we must change the type
1310 * 2 record to type 0xF2. This will force the UMP to come up 1310 * 2 record to type 0xF2. This will force the UMP to come up
1311 * in Boot Mode. Then while in boot mode, the driver will 1311 * in Boot Mode. Then while in boot mode, the driver will
1312 * download the latest firmware (padded to 15.5k) into the 1312 * download the latest firmware (padded to 15.5k) into the
1313 * UMP ram. Finally when the device comes back up in download 1313 * UMP ram. Finally when the device comes back up in download
1314 * mode the driver will cause the new firmware to be copied 1314 * mode the driver will cause the new firmware to be copied
1315 * from the UMP Ram to I2C and the firmware will update the 1315 * from the UMP Ram to I2C and the firmware will update the
1316 * record type from 0xf2 to 0x02. 1316 * record type from 0xf2 to 0x02.
1317 * 1317 *
1318 * Do we really have to copy the whole firmware image, 1318 * Do we really have to copy the whole firmware image,
1319 * or could we do this in place! 1319 * or could we do this in place!
1320 */ 1320 */
1321 1321
1322 /* Allocate a 15.5k buffer + 3 byte header */ 1322 /* Allocate a 15.5k buffer + 3 byte header */
1323 buffer_size = (((1024 * 16) - 512) + 1323 buffer_size = (((1024 * 16) - 512) +
1324 sizeof(struct ti_i2c_image_header)); 1324 sizeof(struct ti_i2c_image_header));
1325 buffer = kmalloc(buffer_size, GFP_KERNEL); 1325 buffer = kmalloc(buffer_size, GFP_KERNEL);
1326 if (!buffer) 1326 if (!buffer)
1327 return -ENOMEM; 1327 return -ENOMEM;
1328 1328
1329 /* Initialize the buffer to 0xff (pad the buffer) */ 1329 /* Initialize the buffer to 0xff (pad the buffer) */
1330 memset(buffer, 0xff, buffer_size); 1330 memset(buffer, 0xff, buffer_size);
1331 1331
1332 err = request_firmware(&fw, fw_name, dev); 1332 err = request_firmware(&fw, fw_name, dev);
1333 if (err) { 1333 if (err) {
1334 dev_err(dev, "Failed to load image \"%s\" err %d\n", 1334 dev_err(dev, "Failed to load image \"%s\" err %d\n",
1335 fw_name, err); 1335 fw_name, err);
1336 kfree(buffer); 1336 kfree(buffer);
1337 return err; 1337 return err;
1338 } 1338 }
1339 memcpy(buffer, &fw->data[4], fw->size - 4); 1339 memcpy(buffer, &fw->data[4], fw->size - 4);
1340 release_firmware(fw); 1340 release_firmware(fw);
1341 1341
1342 for (i = sizeof(struct ti_i2c_image_header); 1342 for (i = sizeof(struct ti_i2c_image_header);
1343 i < buffer_size; i++) { 1343 i < buffer_size; i++) {
1344 cs = (__u8)(cs + buffer[i]); 1344 cs = (__u8)(cs + buffer[i]);
1345 } 1345 }
1346 1346
1347 header = (struct ti_i2c_image_header *)buffer; 1347 header = (struct ti_i2c_image_header *)buffer;
1348 1348
1349 /* update length and checksum after padding */ 1349 /* update length and checksum after padding */
1350 header->Length = cpu_to_le16((__u16)(buffer_size - 1350 header->Length = cpu_to_le16((__u16)(buffer_size -
1351 sizeof(struct ti_i2c_image_header))); 1351 sizeof(struct ti_i2c_image_header)));
1352 header->CheckSum = cs; 1352 header->CheckSum = cs;
1353 1353
1354 /* Download the operational code */ 1354 /* Download the operational code */
1355 dev_dbg(dev, "%s - Downloading operational code image (TI UMP)\n", __func__); 1355 dev_dbg(dev, "%s - Downloading operational code image (TI UMP)\n", __func__);
1356 status = download_code(serial, buffer, buffer_size); 1356 status = download_code(serial, buffer, buffer_size);
1357 1357
1358 kfree(buffer); 1358 kfree(buffer);
1359 1359
1360 if (status) { 1360 if (status) {
1361 dev_dbg(dev, "%s - Error downloading operational code image\n", __func__); 1361 dev_dbg(dev, "%s - Error downloading operational code image\n", __func__);
1362 return status; 1362 return status;
1363 } 1363 }
1364 1364
1365 /* Device will reboot */ 1365 /* Device will reboot */
1366 serial->product_info.TiMode = TI_MODE_TRANSITIONING; 1366 serial->product_info.TiMode = TI_MODE_TRANSITIONING;
1367 1367
1368 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__); 1368 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__);
1369 1369
1370 /* return an error on purpose */ 1370 /* return an error on purpose */
1371 return -ENODEV; 1371 return -ENODEV;
1372 } 1372 }
1373 1373
1374 stayinbootmode: 1374 stayinbootmode:
1375 /* Eprom is invalid or blank stay in boot mode */ 1375 /* Eprom is invalid or blank stay in boot mode */
1376 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__); 1376 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__);
1377 serial->product_info.TiMode = TI_MODE_BOOT; 1377 serial->product_info.TiMode = TI_MODE_BOOT;
1378 1378
1379 return 0; 1379 return 0;
1380 } 1380 }
1381 1381
1382 1382
1383 static int ti_do_config(struct edgeport_port *port, int feature, int on) 1383 static int ti_do_config(struct edgeport_port *port, int feature, int on)
1384 { 1384 {
1385 int port_number = port->port->port_number; 1385 int port_number = port->port->port_number;
1386 1386
1387 on = !!on; /* 1 or 0 not bitmask */ 1387 on = !!on; /* 1 or 0 not bitmask */
1388 return send_cmd(port->port->serial->dev, 1388 return send_cmd(port->port->serial->dev,
1389 feature, (__u8)(UMPM_UART1_PORT + port_number), 1389 feature, (__u8)(UMPM_UART1_PORT + port_number),
1390 on, NULL, 0); 1390 on, NULL, 0);
1391 } 1391 }
1392 1392
1393 1393
1394 static int restore_mcr(struct edgeport_port *port, __u8 mcr) 1394 static int restore_mcr(struct edgeport_port *port, __u8 mcr)
1395 { 1395 {
1396 int status = 0; 1396 int status = 0;
1397 1397
1398 dev_dbg(&port->port->dev, "%s - %x\n", __func__, mcr); 1398 dev_dbg(&port->port->dev, "%s - %x\n", __func__, mcr);
1399 1399
1400 status = ti_do_config(port, UMPC_SET_CLR_DTR, mcr & MCR_DTR); 1400 status = ti_do_config(port, UMPC_SET_CLR_DTR, mcr & MCR_DTR);
1401 if (status) 1401 if (status)
1402 return status; 1402 return status;
1403 status = ti_do_config(port, UMPC_SET_CLR_RTS, mcr & MCR_RTS); 1403 status = ti_do_config(port, UMPC_SET_CLR_RTS, mcr & MCR_RTS);
1404 if (status) 1404 if (status)
1405 return status; 1405 return status;
1406 return ti_do_config(port, UMPC_SET_CLR_LOOPBACK, mcr & MCR_LOOPBACK); 1406 return ti_do_config(port, UMPC_SET_CLR_LOOPBACK, mcr & MCR_LOOPBACK);
1407 } 1407 }
1408 1408
1409 /* Convert TI LSR to standard UART flags */ 1409 /* Convert TI LSR to standard UART flags */
1410 static __u8 map_line_status(__u8 ti_lsr) 1410 static __u8 map_line_status(__u8 ti_lsr)
1411 { 1411 {
1412 __u8 lsr = 0; 1412 __u8 lsr = 0;
1413 1413
1414 #define MAP_FLAG(flagUmp, flagUart) \ 1414 #define MAP_FLAG(flagUmp, flagUart) \
1415 if (ti_lsr & flagUmp) \ 1415 if (ti_lsr & flagUmp) \
1416 lsr |= flagUart; 1416 lsr |= flagUart;
1417 1417
1418 MAP_FLAG(UMP_UART_LSR_OV_MASK, LSR_OVER_ERR) /* overrun */ 1418 MAP_FLAG(UMP_UART_LSR_OV_MASK, LSR_OVER_ERR) /* overrun */
1419 MAP_FLAG(UMP_UART_LSR_PE_MASK, LSR_PAR_ERR) /* parity error */ 1419 MAP_FLAG(UMP_UART_LSR_PE_MASK, LSR_PAR_ERR) /* parity error */
1420 MAP_FLAG(UMP_UART_LSR_FE_MASK, LSR_FRM_ERR) /* framing error */ 1420 MAP_FLAG(UMP_UART_LSR_FE_MASK, LSR_FRM_ERR) /* framing error */
1421 MAP_FLAG(UMP_UART_LSR_BR_MASK, LSR_BREAK) /* break detected */ 1421 MAP_FLAG(UMP_UART_LSR_BR_MASK, LSR_BREAK) /* break detected */
1422 MAP_FLAG(UMP_UART_LSR_RX_MASK, LSR_RX_AVAIL) /* rx data available */ 1422 MAP_FLAG(UMP_UART_LSR_RX_MASK, LSR_RX_AVAIL) /* rx data available */
1423 MAP_FLAG(UMP_UART_LSR_TX_MASK, LSR_TX_EMPTY) /* tx hold reg empty */ 1423 MAP_FLAG(UMP_UART_LSR_TX_MASK, LSR_TX_EMPTY) /* tx hold reg empty */
1424 1424
1425 #undef MAP_FLAG 1425 #undef MAP_FLAG
1426 1426
1427 return lsr; 1427 return lsr;
1428 } 1428 }
1429 1429
1430 static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) 1430 static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
1431 { 1431 {
1432 struct async_icount *icount; 1432 struct async_icount *icount;
1433 struct tty_struct *tty; 1433 struct tty_struct *tty;
1434 1434
1435 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, msr); 1435 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, msr);
1436 1436
1437 if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | 1437 if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR |
1438 EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { 1438 EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
1439 icount = &edge_port->port->icount; 1439 icount = &edge_port->port->icount;
1440 1440
1441 /* update input line counters */ 1441 /* update input line counters */
1442 if (msr & EDGEPORT_MSR_DELTA_CTS) 1442 if (msr & EDGEPORT_MSR_DELTA_CTS)
1443 icount->cts++; 1443 icount->cts++;
1444 if (msr & EDGEPORT_MSR_DELTA_DSR) 1444 if (msr & EDGEPORT_MSR_DELTA_DSR)
1445 icount->dsr++; 1445 icount->dsr++;
1446 if (msr & EDGEPORT_MSR_DELTA_CD) 1446 if (msr & EDGEPORT_MSR_DELTA_CD)
1447 icount->dcd++; 1447 icount->dcd++;
1448 if (msr & EDGEPORT_MSR_DELTA_RI) 1448 if (msr & EDGEPORT_MSR_DELTA_RI)
1449 icount->rng++; 1449 icount->rng++;
1450 wake_up_interruptible(&edge_port->port->port.delta_msr_wait); 1450 wake_up_interruptible(&edge_port->port->port.delta_msr_wait);
1451 } 1451 }
1452 1452
1453 /* Save the new modem status */ 1453 /* Save the new modem status */
1454 edge_port->shadow_msr = msr & 0xf0; 1454 edge_port->shadow_msr = msr & 0xf0;
1455 1455
1456 tty = tty_port_tty_get(&edge_port->port->port); 1456 tty = tty_port_tty_get(&edge_port->port->port);
1457 /* handle CTS flow control */ 1457 /* handle CTS flow control */
1458 if (tty && C_CRTSCTS(tty)) { 1458 if (tty && C_CRTSCTS(tty)) {
1459 if (msr & EDGEPORT_MSR_CTS) { 1459 if (msr & EDGEPORT_MSR_CTS) {
1460 tty->hw_stopped = 0; 1460 tty->hw_stopped = 0;
1461 tty_wakeup(tty); 1461 tty_wakeup(tty);
1462 } else { 1462 } else {
1463 tty->hw_stopped = 1; 1463 tty->hw_stopped = 1;
1464 } 1464 }
1465 } 1465 }
1466 tty_kref_put(tty); 1466 tty_kref_put(tty);
1467 } 1467 }
1468 1468
1469 static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, 1469 static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1470 __u8 lsr, __u8 data) 1470 __u8 lsr, __u8 data)
1471 { 1471 {
1472 struct async_icount *icount; 1472 struct async_icount *icount;
1473 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | 1473 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR |
1474 LSR_FRM_ERR | LSR_BREAK)); 1474 LSR_FRM_ERR | LSR_BREAK));
1475 1475
1476 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); 1476 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr);
1477 1477
1478 edge_port->shadow_lsr = lsr; 1478 edge_port->shadow_lsr = lsr;
1479 1479
1480 if (new_lsr & LSR_BREAK) 1480 if (new_lsr & LSR_BREAK)
1481 /* 1481 /*
1482 * Parity and Framing errors only count if they 1482 * Parity and Framing errors only count if they
1483 * occur exclusive of a break being received. 1483 * occur exclusive of a break being received.
1484 */ 1484 */
1485 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); 1485 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
1486 1486
1487 /* Place LSR data byte into Rx buffer */ 1487 /* Place LSR data byte into Rx buffer */
1488 if (lsr_data) 1488 if (lsr_data)
1489 edge_tty_recv(edge_port->port, &data, 1); 1489 edge_tty_recv(edge_port->port, &data, 1);
1490 1490
1491 /* update input line counters */ 1491 /* update input line counters */
1492 icount = &edge_port->port->icount; 1492 icount = &edge_port->port->icount;
1493 if (new_lsr & LSR_BREAK) 1493 if (new_lsr & LSR_BREAK)
1494 icount->brk++; 1494 icount->brk++;
1495 if (new_lsr & LSR_OVER_ERR) 1495 if (new_lsr & LSR_OVER_ERR)
1496 icount->overrun++; 1496 icount->overrun++;
1497 if (new_lsr & LSR_PAR_ERR) 1497 if (new_lsr & LSR_PAR_ERR)
1498 icount->parity++; 1498 icount->parity++;
1499 if (new_lsr & LSR_FRM_ERR) 1499 if (new_lsr & LSR_FRM_ERR)
1500 icount->frame++; 1500 icount->frame++;
1501 } 1501 }
1502 1502
1503 1503
1504 static void edge_interrupt_callback(struct urb *urb) 1504 static void edge_interrupt_callback(struct urb *urb)
1505 { 1505 {
1506 struct edgeport_serial *edge_serial = urb->context; 1506 struct edgeport_serial *edge_serial = urb->context;
1507 struct usb_serial_port *port; 1507 struct usb_serial_port *port;
1508 struct edgeport_port *edge_port; 1508 struct edgeport_port *edge_port;
1509 struct device *dev; 1509 struct device *dev;
1510 unsigned char *data = urb->transfer_buffer; 1510 unsigned char *data = urb->transfer_buffer;
1511 int length = urb->actual_length; 1511 int length = urb->actual_length;
1512 int port_number; 1512 int port_number;
1513 int function; 1513 int function;
1514 int retval; 1514 int retval;
1515 __u8 lsr; 1515 __u8 lsr;
1516 __u8 msr; 1516 __u8 msr;
1517 int status = urb->status; 1517 int status = urb->status;
1518 1518
1519 switch (status) { 1519 switch (status) {
1520 case 0: 1520 case 0:
1521 /* success */ 1521 /* success */
1522 break; 1522 break;
1523 case -ECONNRESET: 1523 case -ECONNRESET:
1524 case -ENOENT: 1524 case -ENOENT:
1525 case -ESHUTDOWN: 1525 case -ESHUTDOWN:
1526 /* this urb is terminated, clean up */ 1526 /* this urb is terminated, clean up */
1527 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", 1527 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
1528 __func__, status); 1528 __func__, status);
1529 return; 1529 return;
1530 default: 1530 default:
1531 dev_err(&urb->dev->dev, "%s - nonzero urb status received: " 1531 dev_err(&urb->dev->dev, "%s - nonzero urb status received: "
1532 "%d\n", __func__, status); 1532 "%d\n", __func__, status);
1533 goto exit; 1533 goto exit;
1534 } 1534 }
1535 1535
1536 if (!length) { 1536 if (!length) {
1537 dev_dbg(&urb->dev->dev, "%s - no data in urb\n", __func__); 1537 dev_dbg(&urb->dev->dev, "%s - no data in urb\n", __func__);
1538 goto exit; 1538 goto exit;
1539 } 1539 }
1540 1540
1541 dev = &edge_serial->serial->dev->dev; 1541 dev = &edge_serial->serial->dev->dev;
1542 usb_serial_debug_data(dev, __func__, length, data); 1542 usb_serial_debug_data(dev, __func__, length, data);
1543 1543
1544 if (length != 2) { 1544 if (length != 2) {
1545 dev_dbg(dev, "%s - expecting packet of size 2, got %d\n", __func__, length); 1545 dev_dbg(dev, "%s - expecting packet of size 2, got %d\n", __func__, length);
1546 goto exit; 1546 goto exit;
1547 } 1547 }
1548 1548
1549 port_number = TIUMP_GET_PORT_FROM_CODE(data[0]); 1549 port_number = TIUMP_GET_PORT_FROM_CODE(data[0]);
1550 function = TIUMP_GET_FUNC_FROM_CODE(data[0]); 1550 function = TIUMP_GET_FUNC_FROM_CODE(data[0]);
1551 dev_dbg(dev, "%s - port_number %d, function %d, info 0x%x\n", __func__, 1551 dev_dbg(dev, "%s - port_number %d, function %d, info 0x%x\n", __func__,
1552 port_number, function, data[1]); 1552 port_number, function, data[1]);
1553 port = edge_serial->serial->port[port_number]; 1553 port = edge_serial->serial->port[port_number];
1554 edge_port = usb_get_serial_port_data(port); 1554 edge_port = usb_get_serial_port_data(port);
1555 if (!edge_port) { 1555 if (!edge_port) {
1556 dev_dbg(dev, "%s - edge_port not found\n", __func__); 1556 dev_dbg(dev, "%s - edge_port not found\n", __func__);
1557 return; 1557 return;
1558 } 1558 }
1559 switch (function) { 1559 switch (function) {
1560 case TIUMP_INTERRUPT_CODE_LSR: 1560 case TIUMP_INTERRUPT_CODE_LSR:
1561 lsr = map_line_status(data[1]); 1561 lsr = map_line_status(data[1]);
1562 if (lsr & UMP_UART_LSR_DATA_MASK) { 1562 if (lsr & UMP_UART_LSR_DATA_MASK) {
1563 /* Save the LSR event for bulk read 1563 /* Save the LSR event for bulk read
1564 completion routine */ 1564 completion routine */
1565 dev_dbg(dev, "%s - LSR Event Port %u LSR Status = %02x\n", 1565 dev_dbg(dev, "%s - LSR Event Port %u LSR Status = %02x\n",
1566 __func__, port_number, lsr); 1566 __func__, port_number, lsr);
1567 edge_port->lsr_event = 1; 1567 edge_port->lsr_event = 1;
1568 edge_port->lsr_mask = lsr; 1568 edge_port->lsr_mask = lsr;
1569 } else { 1569 } else {
1570 dev_dbg(dev, "%s - ===== Port %d LSR Status = %02x ======\n", 1570 dev_dbg(dev, "%s - ===== Port %d LSR Status = %02x ======\n",
1571 __func__, port_number, lsr); 1571 __func__, port_number, lsr);
1572 handle_new_lsr(edge_port, 0, lsr, 0); 1572 handle_new_lsr(edge_port, 0, lsr, 0);
1573 } 1573 }
1574 break; 1574 break;
1575 1575
1576 case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ 1576 case TIUMP_INTERRUPT_CODE_MSR: /* MSR */
1577 /* Copy MSR from UMP */ 1577 /* Copy MSR from UMP */
1578 msr = data[1]; 1578 msr = data[1];
1579 dev_dbg(dev, "%s - ===== Port %u MSR Status = %02x ======\n", 1579 dev_dbg(dev, "%s - ===== Port %u MSR Status = %02x ======\n",
1580 __func__, port_number, msr); 1580 __func__, port_number, msr);
1581 handle_new_msr(edge_port, msr); 1581 handle_new_msr(edge_port, msr);
1582 break; 1582 break;
1583 1583
1584 default: 1584 default:
1585 dev_err(&urb->dev->dev, 1585 dev_err(&urb->dev->dev,
1586 "%s - Unknown Interrupt code from UMP %x\n", 1586 "%s - Unknown Interrupt code from UMP %x\n",
1587 __func__, data[1]); 1587 __func__, data[1]);
1588 break; 1588 break;
1589 1589
1590 } 1590 }
1591 1591
1592 exit: 1592 exit:
1593 retval = usb_submit_urb(urb, GFP_ATOMIC); 1593 retval = usb_submit_urb(urb, GFP_ATOMIC);
1594 if (retval) 1594 if (retval)
1595 dev_err(&urb->dev->dev, 1595 dev_err(&urb->dev->dev,
1596 "%s - usb_submit_urb failed with result %d\n", 1596 "%s - usb_submit_urb failed with result %d\n",
1597 __func__, retval); 1597 __func__, retval);
1598 } 1598 }
1599 1599
1600 static void edge_bulk_in_callback(struct urb *urb) 1600 static void edge_bulk_in_callback(struct urb *urb)
1601 { 1601 {
1602 struct edgeport_port *edge_port = urb->context; 1602 struct edgeport_port *edge_port = urb->context;
1603 struct device *dev = &edge_port->port->dev; 1603 struct device *dev = &edge_port->port->dev;
1604 unsigned char *data = urb->transfer_buffer; 1604 unsigned char *data = urb->transfer_buffer;
1605 int retval = 0; 1605 int retval = 0;
1606 int port_number; 1606 int port_number;
1607 int status = urb->status; 1607 int status = urb->status;
1608 1608
1609 switch (status) { 1609 switch (status) {
1610 case 0: 1610 case 0:
1611 /* success */ 1611 /* success */
1612 break; 1612 break;
1613 case -ECONNRESET: 1613 case -ECONNRESET:
1614 case -ENOENT: 1614 case -ENOENT:
1615 case -ESHUTDOWN: 1615 case -ESHUTDOWN:
1616 /* this urb is terminated, clean up */ 1616 /* this urb is terminated, clean up */
1617 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status); 1617 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status);
1618 return; 1618 return;
1619 default: 1619 default:
1620 dev_err(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", __func__, status); 1620 dev_err(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", __func__, status);
1621 } 1621 }
1622 1622
1623 if (status == -EPIPE) 1623 if (status == -EPIPE)
1624 goto exit; 1624 goto exit;
1625 1625
1626 if (status) { 1626 if (status) {
1627 dev_err(&urb->dev->dev, "%s - stopping read!\n", __func__); 1627 dev_err(&urb->dev->dev, "%s - stopping read!\n", __func__);
1628 return; 1628 return;
1629 } 1629 }
1630 1630
1631 port_number = edge_port->port->port_number; 1631 port_number = edge_port->port->port_number;
1632 1632
1633 if (edge_port->lsr_event) { 1633 if (edge_port->lsr_event) {
1634 edge_port->lsr_event = 0; 1634 edge_port->lsr_event = 0;
1635 dev_dbg(dev, "%s ===== Port %u LSR Status = %02x, Data = %02x ======\n", 1635 dev_dbg(dev, "%s ===== Port %u LSR Status = %02x, Data = %02x ======\n",
1636 __func__, port_number, edge_port->lsr_mask, *data); 1636 __func__, port_number, edge_port->lsr_mask, *data);
1637 handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data); 1637 handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data);
1638 /* Adjust buffer length/pointer */ 1638 /* Adjust buffer length/pointer */
1639 --urb->actual_length; 1639 --urb->actual_length;
1640 ++data; 1640 ++data;
1641 } 1641 }
1642 1642
1643 if (urb->actual_length) { 1643 if (urb->actual_length) {
1644 usb_serial_debug_data(dev, __func__, urb->actual_length, data); 1644 usb_serial_debug_data(dev, __func__, urb->actual_length, data);
1645 if (edge_port->close_pending) 1645 if (edge_port->close_pending)
1646 dev_dbg(dev, "%s - close pending, dropping data on the floor\n", 1646 dev_dbg(dev, "%s - close pending, dropping data on the floor\n",
1647 __func__); 1647 __func__);
1648 else 1648 else
1649 edge_tty_recv(edge_port->port, data, 1649 edge_tty_recv(edge_port->port, data,
1650 urb->actual_length); 1650 urb->actual_length);
1651 edge_port->port->icount.rx += urb->actual_length; 1651 edge_port->port->icount.rx += urb->actual_length;
1652 } 1652 }
1653 1653
1654 exit: 1654 exit:
1655 /* continue read unless stopped */ 1655 /* continue read unless stopped */
1656 spin_lock(&edge_port->ep_lock); 1656 spin_lock(&edge_port->ep_lock);
1657 if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING) 1657 if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING)
1658 retval = usb_submit_urb(urb, GFP_ATOMIC); 1658 retval = usb_submit_urb(urb, GFP_ATOMIC);
1659 else if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPING) 1659 else if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPING)
1660 edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPED; 1660 edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPED;
1661 1661
1662 spin_unlock(&edge_port->ep_lock); 1662 spin_unlock(&edge_port->ep_lock);
1663 if (retval) 1663 if (retval)
1664 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); 1664 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval);
1665 } 1665 }
1666 1666
1667 static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, 1667 static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data,
1668 int length) 1668 int length)
1669 { 1669 {
1670 int queued; 1670 int queued;
1671 1671
1672 queued = tty_insert_flip_string(&port->port, data, length); 1672 queued = tty_insert_flip_string(&port->port, data, length);
1673 if (queued < length) 1673 if (queued < length)
1674 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", 1674 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
1675 __func__, length - queued); 1675 __func__, length - queued);
1676 tty_flip_buffer_push(&port->port); 1676 tty_flip_buffer_push(&port->port);
1677 } 1677 }
1678 1678
1679 static void edge_bulk_out_callback(struct urb *urb) 1679 static void edge_bulk_out_callback(struct urb *urb)
1680 { 1680 {
1681 struct usb_serial_port *port = urb->context; 1681 struct usb_serial_port *port = urb->context;
1682 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1682 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1683 int status = urb->status; 1683 int status = urb->status;
1684 struct tty_struct *tty; 1684 struct tty_struct *tty;
1685 1685
1686 edge_port->ep_write_urb_in_use = 0; 1686 edge_port->ep_write_urb_in_use = 0;
1687 1687
1688 switch (status) { 1688 switch (status) {
1689 case 0: 1689 case 0:
1690 /* success */ 1690 /* success */
1691 break; 1691 break;
1692 case -ECONNRESET: 1692 case -ECONNRESET:
1693 case -ENOENT: 1693 case -ENOENT:
1694 case -ESHUTDOWN: 1694 case -ESHUTDOWN:
1695 /* this urb is terminated, clean up */ 1695 /* this urb is terminated, clean up */
1696 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", 1696 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
1697 __func__, status); 1697 __func__, status);
1698 return; 1698 return;
1699 default: 1699 default:
1700 dev_err_console(port, "%s - nonzero write bulk status " 1700 dev_err_console(port, "%s - nonzero write bulk status "
1701 "received: %d\n", __func__, status); 1701 "received: %d\n", __func__, status);
1702 } 1702 }
1703 1703
1704 /* send any buffered data */ 1704 /* send any buffered data */
1705 tty = tty_port_tty_get(&port->port); 1705 tty = tty_port_tty_get(&port->port);
1706 edge_send(port, tty); 1706 edge_send(port, tty);
1707 tty_kref_put(tty); 1707 tty_kref_put(tty);
1708 } 1708 }
1709 1709
1710 static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) 1710 static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
1711 { 1711 {
1712 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1712 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1713 struct edgeport_serial *edge_serial; 1713 struct edgeport_serial *edge_serial;
1714 struct usb_device *dev; 1714 struct usb_device *dev;
1715 struct urb *urb; 1715 struct urb *urb;
1716 int port_number; 1716 int port_number;
1717 int status; 1717 int status;
1718 u16 open_settings; 1718 u16 open_settings;
1719 u8 transaction_timeout; 1719 u8 transaction_timeout;
1720 1720
1721 if (edge_port == NULL) 1721 if (edge_port == NULL)
1722 return -ENODEV; 1722 return -ENODEV;
1723 1723
1724 port_number = port->port_number; 1724 port_number = port->port_number;
1725 1725
1726 dev = port->serial->dev; 1726 dev = port->serial->dev;
1727 1727
1728 /* turn off loopback */ 1728 /* turn off loopback */
1729 status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0); 1729 status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0);
1730 if (status) { 1730 if (status) {
1731 dev_err(&port->dev, 1731 dev_err(&port->dev,
1732 "%s - cannot send clear loopback command, %d\n", 1732 "%s - cannot send clear loopback command, %d\n",
1733 __func__, status); 1733 __func__, status);
1734 return status; 1734 return status;
1735 } 1735 }
1736 1736
1737 /* set up the port settings */ 1737 /* set up the port settings */
1738 if (tty) 1738 if (tty)
1739 edge_set_termios(tty, port, &tty->termios); 1739 edge_set_termios(tty, port, &tty->termios);
1740 1740
1741 /* open up the port */ 1741 /* open up the port */
1742 1742
1743 /* milliseconds to timeout for DMA transfer */ 1743 /* milliseconds to timeout for DMA transfer */
1744 transaction_timeout = 2; 1744 transaction_timeout = 2;
1745 1745
1746 edge_port->ump_read_timeout = 1746 edge_port->ump_read_timeout =
1747 max(20, ((transaction_timeout * 3) / 2)); 1747 max(20, ((transaction_timeout * 3) / 2));
1748 1748
1749 /* milliseconds to timeout for DMA transfer */ 1749 /* milliseconds to timeout for DMA transfer */
1750 open_settings = (u8)(UMP_DMA_MODE_CONTINOUS | 1750 open_settings = (u8)(UMP_DMA_MODE_CONTINOUS |
1751 UMP_PIPE_TRANS_TIMEOUT_ENA | 1751 UMP_PIPE_TRANS_TIMEOUT_ENA |
1752 (transaction_timeout << 2)); 1752 (transaction_timeout << 2));
1753 1753
1754 dev_dbg(&port->dev, "%s - Sending UMPC_OPEN_PORT\n", __func__); 1754 dev_dbg(&port->dev, "%s - Sending UMPC_OPEN_PORT\n", __func__);
1755 1755
1756 /* Tell TI to open and start the port */ 1756 /* Tell TI to open and start the port */
1757 status = send_cmd(dev, UMPC_OPEN_PORT, 1757 status = send_cmd(dev, UMPC_OPEN_PORT,
1758 (u8)(UMPM_UART1_PORT + port_number), open_settings, NULL, 0); 1758 (u8)(UMPM_UART1_PORT + port_number), open_settings, NULL, 0);
1759 if (status) { 1759 if (status) {
1760 dev_err(&port->dev, "%s - cannot send open command, %d\n", 1760 dev_err(&port->dev, "%s - cannot send open command, %d\n",
1761 __func__, status); 1761 __func__, status);
1762 return status; 1762 return status;
1763 } 1763 }
1764 1764
1765 /* Start the DMA? */ 1765 /* Start the DMA? */
1766 status = send_cmd(dev, UMPC_START_PORT, 1766 status = send_cmd(dev, UMPC_START_PORT,
1767 (u8)(UMPM_UART1_PORT + port_number), 0, NULL, 0); 1767 (u8)(UMPM_UART1_PORT + port_number), 0, NULL, 0);
1768 if (status) { 1768 if (status) {
1769 dev_err(&port->dev, "%s - cannot send start DMA command, %d\n", 1769 dev_err(&port->dev, "%s - cannot send start DMA command, %d\n",
1770 __func__, status); 1770 __func__, status);
1771 return status; 1771 return status;
1772 } 1772 }
1773 1773
1774 /* Clear TX and RX buffers in UMP */ 1774 /* Clear TX and RX buffers in UMP */
1775 status = purge_port(port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN); 1775 status = purge_port(port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN);
1776 if (status) { 1776 if (status) {
1777 dev_err(&port->dev, 1777 dev_err(&port->dev,
1778 "%s - cannot send clear buffers command, %d\n", 1778 "%s - cannot send clear buffers command, %d\n",
1779 __func__, status); 1779 __func__, status);
1780 return status; 1780 return status;
1781 } 1781 }
1782 1782
1783 /* Read Initial MSR */ 1783 /* Read Initial MSR */
1784 status = ti_vread_sync(dev, UMPC_READ_MSR, 0, 1784 status = ti_vread_sync(dev, UMPC_READ_MSR, 0,
1785 (__u16)(UMPM_UART1_PORT + port_number), 1785 (__u16)(UMPM_UART1_PORT + port_number),
1786 &edge_port->shadow_msr, 1); 1786 &edge_port->shadow_msr, 1);
1787 if (status) { 1787 if (status) {
1788 dev_err(&port->dev, "%s - cannot send read MSR command, %d\n", 1788 dev_err(&port->dev, "%s - cannot send read MSR command, %d\n",
1789 __func__, status); 1789 __func__, status);
1790 return status; 1790 return status;
1791 } 1791 }
1792 1792
1793 dev_dbg(&port->dev, "ShadowMSR 0x%X\n", edge_port->shadow_msr); 1793 dev_dbg(&port->dev, "ShadowMSR 0x%X\n", edge_port->shadow_msr);
1794 1794
1795 /* Set Initial MCR */ 1795 /* Set Initial MCR */
1796 edge_port->shadow_mcr = MCR_RTS | MCR_DTR; 1796 edge_port->shadow_mcr = MCR_RTS | MCR_DTR;
1797 dev_dbg(&port->dev, "ShadowMCR 0x%X\n", edge_port->shadow_mcr); 1797 dev_dbg(&port->dev, "ShadowMCR 0x%X\n", edge_port->shadow_mcr);
1798 1798
1799 edge_serial = edge_port->edge_serial; 1799 edge_serial = edge_port->edge_serial;
1800 if (mutex_lock_interruptible(&edge_serial->es_lock)) 1800 if (mutex_lock_interruptible(&edge_serial->es_lock))
1801 return -ERESTARTSYS; 1801 return -ERESTARTSYS;
1802 if (edge_serial->num_ports_open == 0) { 1802 if (edge_serial->num_ports_open == 0) {
1803 /* we are the first port to open, post the interrupt urb */ 1803 /* we are the first port to open, post the interrupt urb */
1804 urb = edge_serial->serial->port[0]->interrupt_in_urb; 1804 urb = edge_serial->serial->port[0]->interrupt_in_urb;
1805 if (!urb) { 1805 if (!urb) {
1806 dev_err(&port->dev, 1806 dev_err(&port->dev,
1807 "%s - no interrupt urb present, exiting\n", 1807 "%s - no interrupt urb present, exiting\n",
1808 __func__); 1808 __func__);
1809 status = -EINVAL; 1809 status = -EINVAL;
1810 goto release_es_lock; 1810 goto release_es_lock;
1811 } 1811 }
1812 urb->context = edge_serial; 1812 urb->context = edge_serial;
1813 status = usb_submit_urb(urb, GFP_KERNEL); 1813 status = usb_submit_urb(urb, GFP_KERNEL);
1814 if (status) { 1814 if (status) {
1815 dev_err(&port->dev, 1815 dev_err(&port->dev,
1816 "%s - usb_submit_urb failed with value %d\n", 1816 "%s - usb_submit_urb failed with value %d\n",
1817 __func__, status); 1817 __func__, status);
1818 goto release_es_lock; 1818 goto release_es_lock;
1819 } 1819 }
1820 } 1820 }
1821 1821
1822 /* 1822 /*
1823 * reset the data toggle on the bulk endpoints to work around bug in 1823 * reset the data toggle on the bulk endpoints to work around bug in
1824 * host controllers where things get out of sync some times 1824 * host controllers where things get out of sync some times
1825 */ 1825 */
1826 usb_clear_halt(dev, port->write_urb->pipe); 1826 usb_clear_halt(dev, port->write_urb->pipe);
1827 usb_clear_halt(dev, port->read_urb->pipe); 1827 usb_clear_halt(dev, port->read_urb->pipe);
1828 1828
1829 /* start up our bulk read urb */ 1829 /* start up our bulk read urb */
1830 urb = port->read_urb; 1830 urb = port->read_urb;
1831 if (!urb) { 1831 if (!urb) {
1832 dev_err(&port->dev, "%s - no read urb present, exiting\n", 1832 dev_err(&port->dev, "%s - no read urb present, exiting\n",
1833 __func__); 1833 __func__);
1834 status = -EINVAL; 1834 status = -EINVAL;
1835 goto unlink_int_urb; 1835 goto unlink_int_urb;
1836 } 1836 }
1837 edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING; 1837 edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING;
1838 urb->context = edge_port; 1838 urb->context = edge_port;
1839 status = usb_submit_urb(urb, GFP_KERNEL); 1839 status = usb_submit_urb(urb, GFP_KERNEL);
1840 if (status) { 1840 if (status) {
1841 dev_err(&port->dev, 1841 dev_err(&port->dev,
1842 "%s - read bulk usb_submit_urb failed with value %d\n", 1842 "%s - read bulk usb_submit_urb failed with value %d\n",
1843 __func__, status); 1843 __func__, status);
1844 goto unlink_int_urb; 1844 goto unlink_int_urb;
1845 } 1845 }
1846 1846
1847 ++edge_serial->num_ports_open; 1847 ++edge_serial->num_ports_open;
1848 1848
1849 goto release_es_lock; 1849 goto release_es_lock;
1850 1850
1851 unlink_int_urb: 1851 unlink_int_urb:
1852 if (edge_port->edge_serial->num_ports_open == 0) 1852 if (edge_port->edge_serial->num_ports_open == 0)
1853 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 1853 usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
1854 release_es_lock: 1854 release_es_lock:
1855 mutex_unlock(&edge_serial->es_lock); 1855 mutex_unlock(&edge_serial->es_lock);
1856 return status; 1856 return status;
1857 } 1857 }
1858 1858
1859 static void edge_close(struct usb_serial_port *port) 1859 static void edge_close(struct usb_serial_port *port)
1860 { 1860 {
1861 struct edgeport_serial *edge_serial; 1861 struct edgeport_serial *edge_serial;
1862 struct edgeport_port *edge_port; 1862 struct edgeport_port *edge_port;
1863 struct usb_serial *serial = port->serial; 1863 struct usb_serial *serial = port->serial;
1864 unsigned long flags; 1864 unsigned long flags;
1865 int port_number; 1865 int port_number;
1866 1866
1867 edge_serial = usb_get_serial_data(port->serial); 1867 edge_serial = usb_get_serial_data(port->serial);
1868 edge_port = usb_get_serial_port_data(port); 1868 edge_port = usb_get_serial_port_data(port);
1869 if (edge_serial == NULL || edge_port == NULL) 1869 if (edge_serial == NULL || edge_port == NULL)
1870 return; 1870 return;
1871 1871
1872 /* The bulkreadcompletion routine will check 1872 /* The bulkreadcompletion routine will check
1873 * this flag and dump add read data */ 1873 * this flag and dump add read data */
1874 edge_port->close_pending = 1; 1874 edge_port->close_pending = 1;
1875 1875
1876 usb_kill_urb(port->read_urb); 1876 usb_kill_urb(port->read_urb);
1877 usb_kill_urb(port->write_urb); 1877 usb_kill_urb(port->write_urb);
1878 edge_port->ep_write_urb_in_use = 0; 1878 edge_port->ep_write_urb_in_use = 0;
1879 spin_lock_irqsave(&edge_port->ep_lock, flags); 1879 spin_lock_irqsave(&edge_port->ep_lock, flags);
1880 kfifo_reset_out(&port->write_fifo); 1880 kfifo_reset_out(&port->write_fifo);
1881 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1881 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1882 1882
1883 dev_dbg(&port->dev, "%s - send umpc_close_port\n", __func__); 1883 dev_dbg(&port->dev, "%s - send umpc_close_port\n", __func__);
1884 port_number = port->port_number; 1884 port_number = port->port_number;
1885 send_cmd(serial->dev, UMPC_CLOSE_PORT, 1885 send_cmd(serial->dev, UMPC_CLOSE_PORT,
1886 (__u8)(UMPM_UART1_PORT + port_number), 0, NULL, 0); 1886 (__u8)(UMPM_UART1_PORT + port_number), 0, NULL, 0);
1887 1887
1888 mutex_lock(&edge_serial->es_lock); 1888 mutex_lock(&edge_serial->es_lock);
1889 --edge_port->edge_serial->num_ports_open; 1889 --edge_port->edge_serial->num_ports_open;
1890 if (edge_port->edge_serial->num_ports_open <= 0) { 1890 if (edge_port->edge_serial->num_ports_open <= 0) {
1891 /* last port is now closed, let's shut down our interrupt urb */ 1891 /* last port is now closed, let's shut down our interrupt urb */
1892 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 1892 usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
1893 edge_port->edge_serial->num_ports_open = 0; 1893 edge_port->edge_serial->num_ports_open = 0;
1894 } 1894 }
1895 mutex_unlock(&edge_serial->es_lock); 1895 mutex_unlock(&edge_serial->es_lock);
1896 edge_port->close_pending = 0; 1896 edge_port->close_pending = 0;
1897 } 1897 }
1898 1898
1899 static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, 1899 static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
1900 const unsigned char *data, int count) 1900 const unsigned char *data, int count)
1901 { 1901 {
1902 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1902 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1903 1903
1904 if (count == 0) { 1904 if (count == 0) {
1905 dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__); 1905 dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__);
1906 return 0; 1906 return 0;
1907 } 1907 }
1908 1908
1909 if (edge_port == NULL) 1909 if (edge_port == NULL)
1910 return -ENODEV; 1910 return -ENODEV;
1911 if (edge_port->close_pending == 1) 1911 if (edge_port->close_pending == 1)
1912 return -ENODEV; 1912 return -ENODEV;
1913 1913
1914 count = kfifo_in_locked(&port->write_fifo, data, count, 1914 count = kfifo_in_locked(&port->write_fifo, data, count,
1915 &edge_port->ep_lock); 1915 &edge_port->ep_lock);
1916 edge_send(port, tty); 1916 edge_send(port, tty);
1917 1917
1918 return count; 1918 return count;
1919 } 1919 }
1920 1920
1921 static void edge_send(struct usb_serial_port *port, struct tty_struct *tty) 1921 static void edge_send(struct usb_serial_port *port, struct tty_struct *tty)
1922 { 1922 {
1923 int count, result; 1923 int count, result;
1924 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1924 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1925 unsigned long flags; 1925 unsigned long flags;
1926 1926
1927 spin_lock_irqsave(&edge_port->ep_lock, flags); 1927 spin_lock_irqsave(&edge_port->ep_lock, flags);
1928 1928
1929 if (edge_port->ep_write_urb_in_use) { 1929 if (edge_port->ep_write_urb_in_use) {
1930 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1930 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1931 return; 1931 return;
1932 } 1932 }
1933 1933
1934 count = kfifo_out(&port->write_fifo, 1934 count = kfifo_out(&port->write_fifo,
1935 port->write_urb->transfer_buffer, 1935 port->write_urb->transfer_buffer,
1936 port->bulk_out_size); 1936 port->bulk_out_size);
1937 1937
1938 if (count == 0) { 1938 if (count == 0) {
1939 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1939 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1940 return; 1940 return;
1941 } 1941 }
1942 1942
1943 edge_port->ep_write_urb_in_use = 1; 1943 edge_port->ep_write_urb_in_use = 1;
1944 1944
1945 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1945 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1946 1946
1947 usb_serial_debug_data(&port->dev, __func__, count, port->write_urb->transfer_buffer); 1947 usb_serial_debug_data(&port->dev, __func__, count, port->write_urb->transfer_buffer);
1948 1948
1949 /* set up our urb */ 1949 /* set up our urb */
1950 port->write_urb->transfer_buffer_length = count; 1950 port->write_urb->transfer_buffer_length = count;
1951 1951
1952 /* send the data out the bulk port */ 1952 /* send the data out the bulk port */
1953 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 1953 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
1954 if (result) { 1954 if (result) {
1955 dev_err_console(port, 1955 dev_err_console(port,
1956 "%s - failed submitting write urb, error %d\n", 1956 "%s - failed submitting write urb, error %d\n",
1957 __func__, result); 1957 __func__, result);
1958 edge_port->ep_write_urb_in_use = 0; 1958 edge_port->ep_write_urb_in_use = 0;
1959 /* TODO: reschedule edge_send */ 1959 /* TODO: reschedule edge_send */
1960 } else 1960 } else
1961 edge_port->port->icount.tx += count; 1961 edge_port->port->icount.tx += count;
1962 1962
1963 /* wakeup any process waiting for writes to complete */ 1963 /* wakeup any process waiting for writes to complete */
1964 /* there is now more room in the buffer for new writes */ 1964 /* there is now more room in the buffer for new writes */
1965 if (tty) 1965 if (tty)
1966 tty_wakeup(tty); 1966 tty_wakeup(tty);
1967 } 1967 }
1968 1968
1969 static int edge_write_room(struct tty_struct *tty) 1969 static int edge_write_room(struct tty_struct *tty)
1970 { 1970 {
1971 struct usb_serial_port *port = tty->driver_data; 1971 struct usb_serial_port *port = tty->driver_data;
1972 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1972 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1973 int room = 0; 1973 int room = 0;
1974 unsigned long flags; 1974 unsigned long flags;
1975 1975
1976 if (edge_port == NULL) 1976 if (edge_port == NULL)
1977 return 0; 1977 return 0;
1978 if (edge_port->close_pending == 1) 1978 if (edge_port->close_pending == 1)
1979 return 0; 1979 return 0;
1980 1980
1981 spin_lock_irqsave(&edge_port->ep_lock, flags); 1981 spin_lock_irqsave(&edge_port->ep_lock, flags);
1982 room = kfifo_avail(&port->write_fifo); 1982 room = kfifo_avail(&port->write_fifo);
1983 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1983 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1984 1984
1985 dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); 1985 dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
1986 return room; 1986 return room;
1987 } 1987 }
1988 1988
1989 static int edge_chars_in_buffer(struct tty_struct *tty) 1989 static int edge_chars_in_buffer(struct tty_struct *tty)
1990 { 1990 {
1991 struct usb_serial_port *port = tty->driver_data; 1991 struct usb_serial_port *port = tty->driver_data;
1992 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1992 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1993 int chars = 0; 1993 int chars = 0;
1994 unsigned long flags; 1994 unsigned long flags;
1995 if (edge_port == NULL) 1995 if (edge_port == NULL)
1996 return 0; 1996 return 0;
1997 1997
1998 spin_lock_irqsave(&edge_port->ep_lock, flags); 1998 spin_lock_irqsave(&edge_port->ep_lock, flags);
1999 chars = kfifo_len(&port->write_fifo); 1999 chars = kfifo_len(&port->write_fifo);
2000 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2000 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2001 2001
2002 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); 2002 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
2003 return chars; 2003 return chars;
2004 } 2004 }
2005 2005
2006 static bool edge_tx_empty(struct usb_serial_port *port) 2006 static bool edge_tx_empty(struct usb_serial_port *port)
2007 { 2007 {
2008 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2008 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2009 int ret; 2009 int ret;
2010 2010
2011 ret = tx_active(edge_port); 2011 ret = tx_active(edge_port);
2012 if (ret > 0) 2012 if (ret > 0)
2013 return false; 2013 return false;
2014 2014
2015 return true; 2015 return true;
2016 } 2016 }
2017 2017
2018 static void edge_throttle(struct tty_struct *tty) 2018 static void edge_throttle(struct tty_struct *tty)
2019 { 2019 {
2020 struct usb_serial_port *port = tty->driver_data; 2020 struct usb_serial_port *port = tty->driver_data;
2021 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2021 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2022 int status; 2022 int status;
2023 2023
2024 if (edge_port == NULL) 2024 if (edge_port == NULL)
2025 return; 2025 return;
2026 2026
2027 /* if we are implementing XON/XOFF, send the stop character */ 2027 /* if we are implementing XON/XOFF, send the stop character */
2028 if (I_IXOFF(tty)) { 2028 if (I_IXOFF(tty)) {
2029 unsigned char stop_char = STOP_CHAR(tty); 2029 unsigned char stop_char = STOP_CHAR(tty);
2030 status = edge_write(tty, port, &stop_char, 1); 2030 status = edge_write(tty, port, &stop_char, 1);
2031 if (status <= 0) { 2031 if (status <= 0) {
2032 dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status); 2032 dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status);
2033 } 2033 }
2034 } 2034 }
2035 2035
2036 /* if we are implementing RTS/CTS, stop reads */ 2036 /* if we are implementing RTS/CTS, stop reads */
2037 /* and the Edgeport will clear the RTS line */ 2037 /* and the Edgeport will clear the RTS line */
2038 if (C_CRTSCTS(tty)) 2038 if (C_CRTSCTS(tty))
2039 stop_read(edge_port); 2039 stop_read(edge_port);
2040 2040
2041 } 2041 }
2042 2042
2043 static void edge_unthrottle(struct tty_struct *tty) 2043 static void edge_unthrottle(struct tty_struct *tty)
2044 { 2044 {
2045 struct usb_serial_port *port = tty->driver_data; 2045 struct usb_serial_port *port = tty->driver_data;
2046 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2046 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2047 int status; 2047 int status;
2048 2048
2049 if (edge_port == NULL) 2049 if (edge_port == NULL)
2050 return; 2050 return;
2051 2051
2052 /* if we are implementing XON/XOFF, send the start character */ 2052 /* if we are implementing XON/XOFF, send the start character */
2053 if (I_IXOFF(tty)) { 2053 if (I_IXOFF(tty)) {
2054 unsigned char start_char = START_CHAR(tty); 2054 unsigned char start_char = START_CHAR(tty);
2055 status = edge_write(tty, port, &start_char, 1); 2055 status = edge_write(tty, port, &start_char, 1);
2056 if (status <= 0) { 2056 if (status <= 0) {
2057 dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status); 2057 dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status);
2058 } 2058 }
2059 } 2059 }
2060 /* if we are implementing RTS/CTS, restart reads */ 2060 /* if we are implementing RTS/CTS, restart reads */
2061 /* are the Edgeport will assert the RTS line */ 2061 /* are the Edgeport will assert the RTS line */
2062 if (C_CRTSCTS(tty)) { 2062 if (C_CRTSCTS(tty)) {
2063 status = restart_read(edge_port); 2063 status = restart_read(edge_port);
2064 if (status) 2064 if (status)
2065 dev_err(&port->dev, 2065 dev_err(&port->dev,
2066 "%s - read bulk usb_submit_urb failed: %d\n", 2066 "%s - read bulk usb_submit_urb failed: %d\n",
2067 __func__, status); 2067 __func__, status);
2068 } 2068 }
2069 2069
2070 } 2070 }
2071 2071
2072 static void stop_read(struct edgeport_port *edge_port) 2072 static void stop_read(struct edgeport_port *edge_port)
2073 { 2073 {
2074 unsigned long flags; 2074 unsigned long flags;
2075 2075
2076 spin_lock_irqsave(&edge_port->ep_lock, flags); 2076 spin_lock_irqsave(&edge_port->ep_lock, flags);
2077 2077
2078 if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING) 2078 if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING)
2079 edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPING; 2079 edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPING;
2080 edge_port->shadow_mcr &= ~MCR_RTS; 2080 edge_port->shadow_mcr &= ~MCR_RTS;
2081 2081
2082 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2082 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2083 } 2083 }
2084 2084
2085 static int restart_read(struct edgeport_port *edge_port) 2085 static int restart_read(struct edgeport_port *edge_port)
2086 { 2086 {
2087 struct urb *urb; 2087 struct urb *urb;
2088 int status = 0; 2088 int status = 0;
2089 unsigned long flags; 2089 unsigned long flags;
2090 2090
2091 spin_lock_irqsave(&edge_port->ep_lock, flags); 2091 spin_lock_irqsave(&edge_port->ep_lock, flags);
2092 2092
2093 if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPED) { 2093 if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPED) {
2094 urb = edge_port->port->read_urb; 2094 urb = edge_port->port->read_urb;
2095 status = usb_submit_urb(urb, GFP_ATOMIC); 2095 status = usb_submit_urb(urb, GFP_ATOMIC);
2096 } 2096 }
2097 edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING; 2097 edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING;
2098 edge_port->shadow_mcr |= MCR_RTS; 2098 edge_port->shadow_mcr |= MCR_RTS;
2099 2099
2100 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2100 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2101 2101
2102 return status; 2102 return status;
2103 } 2103 }
2104 2104
2105 static void change_port_settings(struct tty_struct *tty, 2105 static void change_port_settings(struct tty_struct *tty,
2106 struct edgeport_port *edge_port, struct ktermios *old_termios) 2106 struct edgeport_port *edge_port, struct ktermios *old_termios)
2107 { 2107 {
2108 struct device *dev = &edge_port->port->dev; 2108 struct device *dev = &edge_port->port->dev;
2109 struct ump_uart_config *config; 2109 struct ump_uart_config *config;
2110 int baud; 2110 int baud;
2111 unsigned cflag; 2111 unsigned cflag;
2112 int status; 2112 int status;
2113 int port_number = edge_port->port->port_number; 2113 int port_number = edge_port->port->port_number;
2114 2114
2115 config = kmalloc (sizeof (*config), GFP_KERNEL); 2115 config = kmalloc (sizeof (*config), GFP_KERNEL);
2116 if (!config) { 2116 if (!config) {
2117 tty->termios = *old_termios; 2117 tty->termios = *old_termios;
2118 return; 2118 return;
2119 } 2119 }
2120 2120
2121 cflag = tty->termios.c_cflag; 2121 cflag = tty->termios.c_cflag;
2122 2122
2123 config->wFlags = 0; 2123 config->wFlags = 0;
2124 2124
2125 /* These flags must be set */ 2125 /* These flags must be set */
2126 config->wFlags |= UMP_MASK_UART_FLAGS_RECEIVE_MS_INT; 2126 config->wFlags |= UMP_MASK_UART_FLAGS_RECEIVE_MS_INT;
2127 config->wFlags |= UMP_MASK_UART_FLAGS_AUTO_START_ON_ERR; 2127 config->wFlags |= UMP_MASK_UART_FLAGS_AUTO_START_ON_ERR;
2128 config->bUartMode = (__u8)(edge_port->bUartMode); 2128 config->bUartMode = (__u8)(edge_port->bUartMode);
2129 2129
2130 switch (cflag & CSIZE) { 2130 switch (cflag & CSIZE) {
2131 case CS5: 2131 case CS5:
2132 config->bDataBits = UMP_UART_CHAR5BITS; 2132 config->bDataBits = UMP_UART_CHAR5BITS;
2133 dev_dbg(dev, "%s - data bits = 5\n", __func__); 2133 dev_dbg(dev, "%s - data bits = 5\n", __func__);
2134 break; 2134 break;
2135 case CS6: 2135 case CS6:
2136 config->bDataBits = UMP_UART_CHAR6BITS; 2136 config->bDataBits = UMP_UART_CHAR6BITS;
2137 dev_dbg(dev, "%s - data bits = 6\n", __func__); 2137 dev_dbg(dev, "%s - data bits = 6\n", __func__);
2138 break; 2138 break;
2139 case CS7: 2139 case CS7:
2140 config->bDataBits = UMP_UART_CHAR7BITS; 2140 config->bDataBits = UMP_UART_CHAR7BITS;
2141 dev_dbg(dev, "%s - data bits = 7\n", __func__); 2141 dev_dbg(dev, "%s - data bits = 7\n", __func__);
2142 break; 2142 break;
2143 default: 2143 default:
2144 case CS8: 2144 case CS8:
2145 config->bDataBits = UMP_UART_CHAR8BITS; 2145 config->bDataBits = UMP_UART_CHAR8BITS;
2146 dev_dbg(dev, "%s - data bits = 8\n", __func__); 2146 dev_dbg(dev, "%s - data bits = 8\n", __func__);
2147 break; 2147 break;
2148 } 2148 }
2149 2149
2150 if (cflag & PARENB) { 2150 if (cflag & PARENB) {
2151 if (cflag & PARODD) { 2151 if (cflag & PARODD) {
2152 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; 2152 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY;
2153 config->bParity = UMP_UART_ODDPARITY; 2153 config->bParity = UMP_UART_ODDPARITY;
2154 dev_dbg(dev, "%s - parity = odd\n", __func__); 2154 dev_dbg(dev, "%s - parity = odd\n", __func__);
2155 } else { 2155 } else {
2156 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; 2156 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY;
2157 config->bParity = UMP_UART_EVENPARITY; 2157 config->bParity = UMP_UART_EVENPARITY;
2158 dev_dbg(dev, "%s - parity = even\n", __func__); 2158 dev_dbg(dev, "%s - parity = even\n", __func__);
2159 } 2159 }
2160 } else { 2160 } else {
2161 config->bParity = UMP_UART_NOPARITY; 2161 config->bParity = UMP_UART_NOPARITY;
2162 dev_dbg(dev, "%s - parity = none\n", __func__); 2162 dev_dbg(dev, "%s - parity = none\n", __func__);
2163 } 2163 }
2164 2164
2165 if (cflag & CSTOPB) { 2165 if (cflag & CSTOPB) {
2166 config->bStopBits = UMP_UART_STOPBIT2; 2166 config->bStopBits = UMP_UART_STOPBIT2;
2167 dev_dbg(dev, "%s - stop bits = 2\n", __func__); 2167 dev_dbg(dev, "%s - stop bits = 2\n", __func__);
2168 } else { 2168 } else {
2169 config->bStopBits = UMP_UART_STOPBIT1; 2169 config->bStopBits = UMP_UART_STOPBIT1;
2170 dev_dbg(dev, "%s - stop bits = 1\n", __func__); 2170 dev_dbg(dev, "%s - stop bits = 1\n", __func__);
2171 } 2171 }
2172 2172
2173 /* figure out the flow control settings */ 2173 /* figure out the flow control settings */
2174 if (cflag & CRTSCTS) { 2174 if (cflag & CRTSCTS) {
2175 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW; 2175 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW;
2176 config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW; 2176 config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW;
2177 dev_dbg(dev, "%s - RTS/CTS is enabled\n", __func__); 2177 dev_dbg(dev, "%s - RTS/CTS is enabled\n", __func__);
2178 } else { 2178 } else {
2179 dev_dbg(dev, "%s - RTS/CTS is disabled\n", __func__); 2179 dev_dbg(dev, "%s - RTS/CTS is disabled\n", __func__);
2180 tty->hw_stopped = 0; 2180 tty->hw_stopped = 0;
2181 restart_read(edge_port); 2181 restart_read(edge_port);
2182 } 2182 }
2183 2183
2184 /* if we are implementing XON/XOFF, set the start and stop 2184 /* if we are implementing XON/XOFF, set the start and stop
2185 character in the device */ 2185 character in the device */
2186 config->cXon = START_CHAR(tty); 2186 config->cXon = START_CHAR(tty);
2187 config->cXoff = STOP_CHAR(tty); 2187 config->cXoff = STOP_CHAR(tty);
2188 2188
2189 /* if we are implementing INBOUND XON/XOFF */ 2189 /* if we are implementing INBOUND XON/XOFF */
2190 if (I_IXOFF(tty)) { 2190 if (I_IXOFF(tty)) {
2191 config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; 2191 config->wFlags |= UMP_MASK_UART_FLAGS_IN_X;
2192 dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", 2192 dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
2193 __func__, config->cXon, config->cXoff); 2193 __func__, config->cXon, config->cXoff);
2194 } else 2194 } else
2195 dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__); 2195 dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__);
2196 2196
2197 /* if we are implementing OUTBOUND XON/XOFF */ 2197 /* if we are implementing OUTBOUND XON/XOFF */
2198 if (I_IXON(tty)) { 2198 if (I_IXON(tty)) {
2199 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; 2199 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X;
2200 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", 2200 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
2201 __func__, config->cXon, config->cXoff); 2201 __func__, config->cXon, config->cXoff);
2202 } else 2202 } else
2203 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is disabled\n", __func__); 2203 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is disabled\n", __func__);
2204 2204
2205 tty->termios.c_cflag &= ~CMSPAR; 2205 tty->termios.c_cflag &= ~CMSPAR;
2206 2206
2207 /* Round the baud rate */ 2207 /* Round the baud rate */
2208 baud = tty_get_baud_rate(tty); 2208 baud = tty_get_baud_rate(tty);
2209 if (!baud) { 2209 if (!baud) {
2210 /* pick a default, any default... */ 2210 /* pick a default, any default... */
2211 baud = 9600; 2211 baud = 9600;
2212 } else 2212 } else
2213 tty_encode_baud_rate(tty, baud, baud); 2213 tty_encode_baud_rate(tty, baud, baud);
2214 2214
2215 edge_port->baud_rate = baud; 2215 edge_port->baud_rate = baud;
2216 config->wBaudRate = (__u16)((461550L + baud/2) / baud); 2216 config->wBaudRate = (__u16)((461550L + baud/2) / baud);
2217 2217
2218 /* FIXME: Recompute actual baud from divisor here */ 2218 /* FIXME: Recompute actual baud from divisor here */
2219 2219
2220 dev_dbg(dev, "%s - baud rate = %d, wBaudRate = %d\n", __func__, baud, config->wBaudRate); 2220 dev_dbg(dev, "%s - baud rate = %d, wBaudRate = %d\n", __func__, baud, config->wBaudRate);
2221 2221
2222 dev_dbg(dev, "wBaudRate: %d\n", (int)(461550L / config->wBaudRate)); 2222 dev_dbg(dev, "wBaudRate: %d\n", (int)(461550L / config->wBaudRate));
2223 dev_dbg(dev, "wFlags: 0x%x\n", config->wFlags); 2223 dev_dbg(dev, "wFlags: 0x%x\n", config->wFlags);
2224 dev_dbg(dev, "bDataBits: %d\n", config->bDataBits); 2224 dev_dbg(dev, "bDataBits: %d\n", config->bDataBits);
2225 dev_dbg(dev, "bParity: %d\n", config->bParity); 2225 dev_dbg(dev, "bParity: %d\n", config->bParity);
2226 dev_dbg(dev, "bStopBits: %d\n", config->bStopBits); 2226 dev_dbg(dev, "bStopBits: %d\n", config->bStopBits);
2227 dev_dbg(dev, "cXon: %d\n", config->cXon); 2227 dev_dbg(dev, "cXon: %d\n", config->cXon);
2228 dev_dbg(dev, "cXoff: %d\n", config->cXoff); 2228 dev_dbg(dev, "cXoff: %d\n", config->cXoff);
2229 dev_dbg(dev, "bUartMode: %d\n", config->bUartMode); 2229 dev_dbg(dev, "bUartMode: %d\n", config->bUartMode);
2230 2230
2231 /* move the word values into big endian mode */ 2231 /* move the word values into big endian mode */
2232 cpu_to_be16s(&config->wFlags); 2232 cpu_to_be16s(&config->wFlags);
2233 cpu_to_be16s(&config->wBaudRate); 2233 cpu_to_be16s(&config->wBaudRate);
2234 2234
2235 status = send_cmd(edge_port->port->serial->dev, UMPC_SET_CONFIG, 2235 status = send_cmd(edge_port->port->serial->dev, UMPC_SET_CONFIG,
2236 (__u8)(UMPM_UART1_PORT + port_number), 2236 (__u8)(UMPM_UART1_PORT + port_number),
2237 0, (__u8 *)config, sizeof(*config)); 2237 0, (__u8 *)config, sizeof(*config));
2238 if (status) 2238 if (status)
2239 dev_dbg(dev, "%s - error %d when trying to write config to device\n", 2239 dev_dbg(dev, "%s - error %d when trying to write config to device\n",
2240 __func__, status); 2240 __func__, status);
2241 kfree(config); 2241 kfree(config);
2242 } 2242 }
2243 2243
2244 static void edge_set_termios(struct tty_struct *tty, 2244 static void edge_set_termios(struct tty_struct *tty,
2245 struct usb_serial_port *port, struct ktermios *old_termios) 2245 struct usb_serial_port *port, struct ktermios *old_termios)
2246 { 2246 {
2247 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2247 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2248 unsigned int cflag; 2248 unsigned int cflag;
2249 2249
2250 cflag = tty->termios.c_cflag; 2250 cflag = tty->termios.c_cflag;
2251 2251
2252 dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__, 2252 dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__,
2253 tty->termios.c_cflag, tty->termios.c_iflag); 2253 tty->termios.c_cflag, tty->termios.c_iflag);
2254 dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__, 2254 dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__,
2255 old_termios->c_cflag, old_termios->c_iflag); 2255 old_termios->c_cflag, old_termios->c_iflag);
2256 2256
2257 if (edge_port == NULL) 2257 if (edge_port == NULL)
2258 return; 2258 return;
2259 /* change the port settings to the new ones specified */ 2259 /* change the port settings to the new ones specified */
2260 change_port_settings(tty, edge_port, old_termios); 2260 change_port_settings(tty, edge_port, old_termios);
2261 } 2261 }
2262 2262
2263 static int edge_tiocmset(struct tty_struct *tty, 2263 static int edge_tiocmset(struct tty_struct *tty,
2264 unsigned int set, unsigned int clear) 2264 unsigned int set, unsigned int clear)
2265 { 2265 {
2266 struct usb_serial_port *port = tty->driver_data; 2266 struct usb_serial_port *port = tty->driver_data;
2267 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2267 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2268 unsigned int mcr; 2268 unsigned int mcr;
2269 unsigned long flags; 2269 unsigned long flags;
2270 2270
2271 spin_lock_irqsave(&edge_port->ep_lock, flags); 2271 spin_lock_irqsave(&edge_port->ep_lock, flags);
2272 mcr = edge_port->shadow_mcr; 2272 mcr = edge_port->shadow_mcr;
2273 if (set & TIOCM_RTS) 2273 if (set & TIOCM_RTS)
2274 mcr |= MCR_RTS; 2274 mcr |= MCR_RTS;
2275 if (set & TIOCM_DTR) 2275 if (set & TIOCM_DTR)
2276 mcr |= MCR_DTR; 2276 mcr |= MCR_DTR;
2277 if (set & TIOCM_LOOP) 2277 if (set & TIOCM_LOOP)
2278 mcr |= MCR_LOOPBACK; 2278 mcr |= MCR_LOOPBACK;
2279 2279
2280 if (clear & TIOCM_RTS) 2280 if (clear & TIOCM_RTS)
2281 mcr &= ~MCR_RTS; 2281 mcr &= ~MCR_RTS;
2282 if (clear & TIOCM_DTR) 2282 if (clear & TIOCM_DTR)
2283 mcr &= ~MCR_DTR; 2283 mcr &= ~MCR_DTR;
2284 if (clear & TIOCM_LOOP) 2284 if (clear & TIOCM_LOOP)
2285 mcr &= ~MCR_LOOPBACK; 2285 mcr &= ~MCR_LOOPBACK;
2286 2286
2287 edge_port->shadow_mcr = mcr; 2287 edge_port->shadow_mcr = mcr;
2288 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2288 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2289 2289
2290 restore_mcr(edge_port, mcr); 2290 restore_mcr(edge_port, mcr);
2291 return 0; 2291 return 0;
2292 } 2292 }
2293 2293
2294 static int edge_tiocmget(struct tty_struct *tty) 2294 static int edge_tiocmget(struct tty_struct *tty)
2295 { 2295 {
2296 struct usb_serial_port *port = tty->driver_data; 2296 struct usb_serial_port *port = tty->driver_data;
2297 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2297 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2298 unsigned int result = 0; 2298 unsigned int result = 0;
2299 unsigned int msr; 2299 unsigned int msr;
2300 unsigned int mcr; 2300 unsigned int mcr;
2301 unsigned long flags; 2301 unsigned long flags;
2302 2302
2303 spin_lock_irqsave(&edge_port->ep_lock, flags); 2303 spin_lock_irqsave(&edge_port->ep_lock, flags);
2304 2304
2305 msr = edge_port->shadow_msr; 2305 msr = edge_port->shadow_msr;
2306 mcr = edge_port->shadow_mcr; 2306 mcr = edge_port->shadow_mcr;
2307 result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */ 2307 result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */
2308 | ((mcr & MCR_RTS) ? TIOCM_RTS: 0) /* 0x004 */ 2308 | ((mcr & MCR_RTS) ? TIOCM_RTS: 0) /* 0x004 */
2309 | ((msr & EDGEPORT_MSR_CTS) ? TIOCM_CTS: 0) /* 0x020 */ 2309 | ((msr & EDGEPORT_MSR_CTS) ? TIOCM_CTS: 0) /* 0x020 */
2310 | ((msr & EDGEPORT_MSR_CD) ? TIOCM_CAR: 0) /* 0x040 */ 2310 | ((msr & EDGEPORT_MSR_CD) ? TIOCM_CAR: 0) /* 0x040 */
2311 | ((msr & EDGEPORT_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */ 2311 | ((msr & EDGEPORT_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */
2312 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ 2312 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
2313 2313
2314 2314
2315 dev_dbg(&port->dev, "%s -- %x\n", __func__, result); 2315 dev_dbg(&port->dev, "%s -- %x\n", __func__, result);
2316 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2316 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2317 2317
2318 return result; 2318 return result;
2319 } 2319 }
2320 2320
2321 static int get_serial_info(struct edgeport_port *edge_port, 2321 static int get_serial_info(struct edgeport_port *edge_port,
2322 struct serial_struct __user *retinfo) 2322 struct serial_struct __user *retinfo)
2323 { 2323 {
2324 struct serial_struct tmp; 2324 struct serial_struct tmp;
2325 unsigned cwait; 2325 unsigned cwait;
2326 2326
2327 if (!retinfo) 2327 if (!retinfo)
2328 return -EFAULT; 2328 return -EFAULT;
2329 2329
2330 cwait = edge_port->port->port.closing_wait; 2330 cwait = edge_port->port->port.closing_wait;
2331 if (cwait != ASYNC_CLOSING_WAIT_NONE) 2331 if (cwait != ASYNC_CLOSING_WAIT_NONE)
2332 cwait = jiffies_to_msecs(cwait) / 10; 2332 cwait = jiffies_to_msecs(cwait) / 10;
2333 2333
2334 memset(&tmp, 0, sizeof(tmp)); 2334 memset(&tmp, 0, sizeof(tmp));
2335 2335
2336 tmp.type = PORT_16550A; 2336 tmp.type = PORT_16550A;
2337 tmp.line = edge_port->port->minor; 2337 tmp.line = edge_port->port->minor;
2338 tmp.port = edge_port->port->port_number; 2338 tmp.port = edge_port->port->port_number;
2339 tmp.irq = 0; 2339 tmp.irq = 0;
2340 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; 2340 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
2341 tmp.xmit_fifo_size = edge_port->port->bulk_out_size; 2341 tmp.xmit_fifo_size = edge_port->port->bulk_out_size;
2342 tmp.baud_base = 9600; 2342 tmp.baud_base = 9600;
2343 tmp.close_delay = 5*HZ; 2343 tmp.close_delay = 5*HZ;
2344 tmp.closing_wait = cwait; 2344 tmp.closing_wait = cwait;
2345 2345
2346 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 2346 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
2347 return -EFAULT; 2347 return -EFAULT;
2348 return 0; 2348 return 0;
2349 } 2349 }
2350 2350
2351 static int edge_ioctl(struct tty_struct *tty, 2351 static int edge_ioctl(struct tty_struct *tty,
2352 unsigned int cmd, unsigned long arg) 2352 unsigned int cmd, unsigned long arg)
2353 { 2353 {
2354 struct usb_serial_port *port = tty->driver_data; 2354 struct usb_serial_port *port = tty->driver_data;
2355 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2355 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2356 2356
2357 switch (cmd) { 2357 switch (cmd) {
2358 case TIOCGSERIAL: 2358 case TIOCGSERIAL:
2359 dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__); 2359 dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__);
2360 return get_serial_info(edge_port, 2360 return get_serial_info(edge_port,
2361 (struct serial_struct __user *) arg); 2361 (struct serial_struct __user *) arg);
2362 } 2362 }
2363 return -ENOIOCTLCMD; 2363 return -ENOIOCTLCMD;
2364 } 2364 }
2365 2365
2366 static void edge_break(struct tty_struct *tty, int break_state) 2366 static void edge_break(struct tty_struct *tty, int break_state)
2367 { 2367 {
2368 struct usb_serial_port *port = tty->driver_data; 2368 struct usb_serial_port *port = tty->driver_data;
2369 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2369 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2370 int status; 2370 int status;
2371 int bv = 0; /* Off */ 2371 int bv = 0; /* Off */
2372 2372
2373 if (break_state == -1) 2373 if (break_state == -1)
2374 bv = 1; /* On */ 2374 bv = 1; /* On */
2375 status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); 2375 status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv);
2376 if (status) 2376 if (status)
2377 dev_dbg(&port->dev, "%s - error %d sending break set/clear command.\n", 2377 dev_dbg(&port->dev, "%s - error %d sending break set/clear command.\n",
2378 __func__, status); 2378 __func__, status);
2379 } 2379 }
2380 2380
2381 static int edge_startup(struct usb_serial *serial) 2381 static int edge_startup(struct usb_serial *serial)
2382 { 2382 {
2383 struct edgeport_serial *edge_serial; 2383 struct edgeport_serial *edge_serial;
2384 int status; 2384 int status;
2385 2385
2386 /* create our private serial structure */ 2386 /* create our private serial structure */
2387 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); 2387 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
2388 if (!edge_serial) 2388 if (!edge_serial)
2389 return -ENOMEM; 2389 return -ENOMEM;
2390 2390
2391 mutex_init(&edge_serial->es_lock); 2391 mutex_init(&edge_serial->es_lock);
2392 edge_serial->serial = serial; 2392 edge_serial->serial = serial;
2393 usb_set_serial_data(serial, edge_serial); 2393 usb_set_serial_data(serial, edge_serial);
2394 2394
2395 status = download_fw(edge_serial); 2395 status = download_fw(edge_serial);
2396 if (status) { 2396 if (status) {
2397 kfree(edge_serial); 2397 kfree(edge_serial);
2398 return status; 2398 return status;
2399 } 2399 }
2400 2400
2401 return 0; 2401 return 0;
2402 } 2402 }
2403 2403
2404 static void edge_disconnect(struct usb_serial *serial) 2404 static void edge_disconnect(struct usb_serial *serial)
2405 { 2405 {
2406 } 2406 }
2407 2407
2408 static void edge_release(struct usb_serial *serial) 2408 static void edge_release(struct usb_serial *serial)
2409 { 2409 {
2410 kfree(usb_get_serial_data(serial)); 2410 kfree(usb_get_serial_data(serial));
2411 } 2411 }
2412 2412
2413 static int edge_port_probe(struct usb_serial_port *port) 2413 static int edge_port_probe(struct usb_serial_port *port)
2414 { 2414 {
2415 struct edgeport_port *edge_port; 2415 struct edgeport_port *edge_port;
2416 int ret; 2416 int ret;
2417 2417
2418 edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL); 2418 edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL);
2419 if (!edge_port) 2419 if (!edge_port)
2420 return -ENOMEM; 2420 return -ENOMEM;
2421 2421
2422 spin_lock_init(&edge_port->ep_lock); 2422 spin_lock_init(&edge_port->ep_lock);
2423 edge_port->port = port; 2423 edge_port->port = port;
2424 edge_port->edge_serial = usb_get_serial_data(port->serial); 2424 edge_port->edge_serial = usb_get_serial_data(port->serial);
2425 edge_port->bUartMode = default_uart_mode; 2425 edge_port->bUartMode = default_uart_mode;
2426 2426
2427 switch (port->port_number) { 2427 switch (port->port_number) {
2428 case 0: 2428 case 0:
2429 edge_port->uart_base = UMPMEM_BASE_UART1; 2429 edge_port->uart_base = UMPMEM_BASE_UART1;
2430 edge_port->dma_address = UMPD_OEDB1_ADDRESS; 2430 edge_port->dma_address = UMPD_OEDB1_ADDRESS;
2431 break; 2431 break;
2432 case 1: 2432 case 1:
2433 edge_port->uart_base = UMPMEM_BASE_UART2; 2433 edge_port->uart_base = UMPMEM_BASE_UART2;
2434 edge_port->dma_address = UMPD_OEDB2_ADDRESS; 2434 edge_port->dma_address = UMPD_OEDB2_ADDRESS;
2435 break; 2435 break;
2436 default: 2436 default:
2437 dev_err(&port->dev, "unknown port number\n"); 2437 dev_err(&port->dev, "unknown port number\n");
2438 ret = -ENODEV; 2438 ret = -ENODEV;
2439 goto err; 2439 goto err;
2440 } 2440 }
2441 2441
2442 dev_dbg(&port->dev, 2442 dev_dbg(&port->dev,
2443 "%s - port_number = %d, uart_base = %04x, dma_address = %04x\n", 2443 "%s - port_number = %d, uart_base = %04x, dma_address = %04x\n",
2444 __func__, port->port_number, edge_port->uart_base, 2444 __func__, port->port_number, edge_port->uart_base,
2445 edge_port->dma_address); 2445 edge_port->dma_address);
2446 2446
2447 usb_set_serial_port_data(port, edge_port); 2447 usb_set_serial_port_data(port, edge_port);
2448 2448
2449 ret = edge_create_sysfs_attrs(port); 2449 ret = edge_create_sysfs_attrs(port);
2450 if (ret) 2450 if (ret)
2451 goto err; 2451 goto err;
2452 2452
2453 port->port.closing_wait = msecs_to_jiffies(closing_wait * 10); 2453 port->port.closing_wait = msecs_to_jiffies(closing_wait * 10);
2454 port->port.drain_delay = 1; 2454 port->port.drain_delay = 1;
2455 2455
2456 return 0; 2456 return 0;
2457 err: 2457 err:
2458 kfree(edge_port); 2458 kfree(edge_port);
2459 2459
2460 return ret; 2460 return ret;
2461 } 2461 }
2462 2462
2463 static int edge_port_remove(struct usb_serial_port *port) 2463 static int edge_port_remove(struct usb_serial_port *port)
2464 { 2464 {
2465 struct edgeport_port *edge_port; 2465 struct edgeport_port *edge_port;
2466 2466
2467 edge_port = usb_get_serial_port_data(port); 2467 edge_port = usb_get_serial_port_data(port);
2468 edge_remove_sysfs_attrs(port); 2468 edge_remove_sysfs_attrs(port);
2469 kfree(edge_port); 2469 kfree(edge_port);
2470 2470
2471 return 0; 2471 return 0;
2472 } 2472 }
2473 2473
2474 /* Sysfs Attributes */ 2474 /* Sysfs Attributes */
2475 2475
2476 static ssize_t uart_mode_show(struct device *dev, 2476 static ssize_t uart_mode_show(struct device *dev,
2477 struct device_attribute *attr, char *buf) 2477 struct device_attribute *attr, char *buf)
2478 { 2478 {
2479 struct usb_serial_port *port = to_usb_serial_port(dev); 2479 struct usb_serial_port *port = to_usb_serial_port(dev);
2480 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2480 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2481 2481
2482 return sprintf(buf, "%d\n", edge_port->bUartMode); 2482 return sprintf(buf, "%d\n", edge_port->bUartMode);
2483 } 2483 }
2484 2484
2485 static ssize_t uart_mode_store(struct device *dev, 2485 static ssize_t uart_mode_store(struct device *dev,
2486 struct device_attribute *attr, const char *valbuf, size_t count) 2486 struct device_attribute *attr, const char *valbuf, size_t count)
2487 { 2487 {
2488 struct usb_serial_port *port = to_usb_serial_port(dev); 2488 struct usb_serial_port *port = to_usb_serial_port(dev);
2489 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2489 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2490 unsigned int v = simple_strtoul(valbuf, NULL, 0); 2490 unsigned int v = simple_strtoul(valbuf, NULL, 0);
2491 2491
2492 dev_dbg(dev, "%s: setting uart_mode = %d\n", __func__, v); 2492 dev_dbg(dev, "%s: setting uart_mode = %d\n", __func__, v);
2493 2493
2494 if (v < 256) 2494 if (v < 256)
2495 edge_port->bUartMode = v; 2495 edge_port->bUartMode = v;
2496 else 2496 else
2497 dev_err(dev, "%s - uart_mode %d is invalid\n", __func__, v); 2497 dev_err(dev, "%s - uart_mode %d is invalid\n", __func__, v);
2498 2498
2499 return count; 2499 return count;
2500 } 2500 }
2501 static DEVICE_ATTR_RW(uart_mode); 2501 static DEVICE_ATTR_RW(uart_mode);
2502 2502
2503 static int edge_create_sysfs_attrs(struct usb_serial_port *port) 2503 static int edge_create_sysfs_attrs(struct usb_serial_port *port)
2504 { 2504 {
2505 return device_create_file(&port->dev, &dev_attr_uart_mode); 2505 return device_create_file(&port->dev, &dev_attr_uart_mode);
2506 } 2506 }
2507 2507
2508 static int edge_remove_sysfs_attrs(struct usb_serial_port *port) 2508 static int edge_remove_sysfs_attrs(struct usb_serial_port *port)
2509 { 2509 {
2510 device_remove_file(&port->dev, &dev_attr_uart_mode); 2510 device_remove_file(&port->dev, &dev_attr_uart_mode);
2511 return 0; 2511 return 0;
2512 } 2512 }
2513 2513
2514 2514
2515 static struct usb_serial_driver edgeport_1port_device = { 2515 static struct usb_serial_driver edgeport_1port_device = {
2516 .driver = { 2516 .driver = {
2517 .owner = THIS_MODULE, 2517 .owner = THIS_MODULE,
2518 .name = "edgeport_ti_1", 2518 .name = "edgeport_ti_1",
2519 }, 2519 },
2520 .description = "Edgeport TI 1 port adapter", 2520 .description = "Edgeport TI 1 port adapter",
2521 .id_table = edgeport_1port_id_table, 2521 .id_table = edgeport_1port_id_table,
2522 .num_ports = 1, 2522 .num_ports = 1,
2523 .open = edge_open, 2523 .open = edge_open,
2524 .close = edge_close, 2524 .close = edge_close,
2525 .throttle = edge_throttle, 2525 .throttle = edge_throttle,
2526 .unthrottle = edge_unthrottle, 2526 .unthrottle = edge_unthrottle,
2527 .attach = edge_startup, 2527 .attach = edge_startup,
2528 .disconnect = edge_disconnect, 2528 .disconnect = edge_disconnect,
2529 .release = edge_release, 2529 .release = edge_release,
2530 .port_probe = edge_port_probe, 2530 .port_probe = edge_port_probe,
2531 .port_remove = edge_port_remove, 2531 .port_remove = edge_port_remove,
2532 .ioctl = edge_ioctl, 2532 .ioctl = edge_ioctl,
2533 .set_termios = edge_set_termios, 2533 .set_termios = edge_set_termios,
2534 .tiocmget = edge_tiocmget, 2534 .tiocmget = edge_tiocmget,
2535 .tiocmset = edge_tiocmset, 2535 .tiocmset = edge_tiocmset,
2536 .tiocmiwait = usb_serial_generic_tiocmiwait, 2536 .tiocmiwait = usb_serial_generic_tiocmiwait,
2537 .get_icount = usb_serial_generic_get_icount, 2537 .get_icount = usb_serial_generic_get_icount,
2538 .write = edge_write, 2538 .write = edge_write,
2539 .write_room = edge_write_room, 2539 .write_room = edge_write_room,
2540 .chars_in_buffer = edge_chars_in_buffer, 2540 .chars_in_buffer = edge_chars_in_buffer,
2541 .tx_empty = edge_tx_empty, 2541 .tx_empty = edge_tx_empty,
2542 .break_ctl = edge_break, 2542 .break_ctl = edge_break,
2543 .read_int_callback = edge_interrupt_callback, 2543 .read_int_callback = edge_interrupt_callback,
2544 .read_bulk_callback = edge_bulk_in_callback, 2544 .read_bulk_callback = edge_bulk_in_callback,
2545 .write_bulk_callback = edge_bulk_out_callback, 2545 .write_bulk_callback = edge_bulk_out_callback,
2546 }; 2546 };
2547 2547
2548 static struct usb_serial_driver edgeport_2port_device = { 2548 static struct usb_serial_driver edgeport_2port_device = {
2549 .driver = { 2549 .driver = {
2550 .owner = THIS_MODULE, 2550 .owner = THIS_MODULE,
2551 .name = "edgeport_ti_2", 2551 .name = "edgeport_ti_2",
2552 }, 2552 },
2553 .description = "Edgeport TI 2 port adapter", 2553 .description = "Edgeport TI 2 port adapter",
2554 .id_table = edgeport_2port_id_table, 2554 .id_table = edgeport_2port_id_table,
2555 .num_ports = 2, 2555 .num_ports = 2,
2556 .open = edge_open, 2556 .open = edge_open,
2557 .close = edge_close, 2557 .close = edge_close,
2558 .throttle = edge_throttle, 2558 .throttle = edge_throttle,
2559 .unthrottle = edge_unthrottle, 2559 .unthrottle = edge_unthrottle,
2560 .attach = edge_startup, 2560 .attach = edge_startup,
2561 .disconnect = edge_disconnect, 2561 .disconnect = edge_disconnect,
2562 .release = edge_release, 2562 .release = edge_release,
2563 .port_probe = edge_port_probe, 2563 .port_probe = edge_port_probe,
2564 .port_remove = edge_port_remove, 2564 .port_remove = edge_port_remove,
2565 .ioctl = edge_ioctl, 2565 .ioctl = edge_ioctl,
2566 .set_termios = edge_set_termios, 2566 .set_termios = edge_set_termios,
2567 .tiocmget = edge_tiocmget, 2567 .tiocmget = edge_tiocmget,
2568 .tiocmset = edge_tiocmset, 2568 .tiocmset = edge_tiocmset,
2569 .tiocmiwait = usb_serial_generic_tiocmiwait, 2569 .tiocmiwait = usb_serial_generic_tiocmiwait,
2570 .get_icount = usb_serial_generic_get_icount, 2570 .get_icount = usb_serial_generic_get_icount,
2571 .write = edge_write, 2571 .write = edge_write,
2572 .write_room = edge_write_room, 2572 .write_room = edge_write_room,
2573 .chars_in_buffer = edge_chars_in_buffer, 2573 .chars_in_buffer = edge_chars_in_buffer,
2574 .tx_empty = edge_tx_empty, 2574 .tx_empty = edge_tx_empty,
2575 .break_ctl = edge_break, 2575 .break_ctl = edge_break,
2576 .read_int_callback = edge_interrupt_callback, 2576 .read_int_callback = edge_interrupt_callback,
2577 .read_bulk_callback = edge_bulk_in_callback, 2577 .read_bulk_callback = edge_bulk_in_callback,
2578 .write_bulk_callback = edge_bulk_out_callback, 2578 .write_bulk_callback = edge_bulk_out_callback,
2579 }; 2579 };
2580 2580
2581 static struct usb_serial_driver * const serial_drivers[] = { 2581 static struct usb_serial_driver * const serial_drivers[] = {
2582 &edgeport_1port_device, &edgeport_2port_device, NULL 2582 &edgeport_1port_device, &edgeport_2port_device, NULL
2583 }; 2583 };
2584 2584
2585 module_usb_serial_driver(serial_drivers, id_table_combined); 2585 module_usb_serial_driver(serial_drivers, id_table_combined);
2586 2586
2587 MODULE_AUTHOR(DRIVER_AUTHOR); 2587 MODULE_AUTHOR(DRIVER_AUTHOR);
2588 MODULE_DESCRIPTION(DRIVER_DESC); 2588 MODULE_DESCRIPTION(DRIVER_DESC);
2589 MODULE_LICENSE("GPL"); 2589 MODULE_LICENSE("GPL");
2590 MODULE_FIRMWARE("edgeport/down3.bin"); 2590 MODULE_FIRMWARE("edgeport/down3.bin");
2591 2591
2592 module_param(closing_wait, int, S_IRUGO | S_IWUSR); 2592 module_param(closing_wait, int, S_IRUGO | S_IWUSR);
2593 MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs"); 2593 MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs");
2594 2594
2595 module_param(ignore_cpu_rev, bool, S_IRUGO | S_IWUSR); 2595 module_param(ignore_cpu_rev, bool, S_IRUGO | S_IWUSR);
2596 MODULE_PARM_DESC(ignore_cpu_rev, 2596 MODULE_PARM_DESC(ignore_cpu_rev,
2597 "Ignore the cpu revision when connecting to a device"); 2597 "Ignore the cpu revision when connecting to a device");
2598 2598
2599 module_param(default_uart_mode, int, S_IRUGO | S_IWUSR); 2599 module_param(default_uart_mode, int, S_IRUGO | S_IWUSR);
2600 MODULE_PARM_DESC(default_uart_mode, "Default uart_mode, 0=RS232, ..."); 2600 MODULE_PARM_DESC(default_uart_mode, "Default uart_mode, 0=RS232, ...");
2601 2601
drivers/usb/serial/io_usbvend.h
1 /************************************************************************ 1 /************************************************************************
2 * 2 *
3 * USBVEND.H Vendor-specific USB definitions 3 * USBVEND.H Vendor-specific USB definitions
4 * 4 *
5 * NOTE: This must be kept in sync with the Edgeport firmware and 5 * NOTE: This must be kept in sync with the Edgeport firmware and
6 * must be kept backward-compatible with older firmware. 6 * must be kept backward-compatible with older firmware.
7 * 7 *
8 ************************************************************************ 8 ************************************************************************
9 * 9 *
10 * Copyright (C) 1998 Inside Out Networks, Inc. 10 * Copyright (C) 1998 Inside Out Networks, Inc.
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version. 14 * (at your option) any later version.
15 * 15 *
16 ************************************************************************/ 16 ************************************************************************/
17 17
18 #if !defined(_USBVEND_H) 18 #if !defined(_USBVEND_H)
19 #define _USBVEND_H 19 #define _USBVEND_H
20 20
21 /************************************************************************ 21 /************************************************************************
22 * 22 *
23 * D e f i n e s / T y p e d e f s 23 * D e f i n e s / T y p e d e f s
24 * 24 *
25 ************************************************************************/ 25 ************************************************************************/
26 26
27 // 27 //
28 // Definitions of USB product IDs 28 // Definitions of USB product IDs
29 // 29 //
30 30
31 #define USB_VENDOR_ID_ION 0x1608 // Our VID 31 #define USB_VENDOR_ID_ION 0x1608 // Our VID
32 #define USB_VENDOR_ID_TI 0x0451 // TI VID 32 #define USB_VENDOR_ID_TI 0x0451 // TI VID
33 #define USB_VENDOR_ID_AXIOHM 0x05D9 /* Axiohm VID */ 33 #define USB_VENDOR_ID_AXIOHM 0x05D9 /* Axiohm VID */
34 34
35 // 35 //
36 // Definitions of USB product IDs (PID) 36 // Definitions of USB product IDs (PID)
37 // We break the USB-defined PID into an OEM Id field (upper 6 bits) 37 // We break the USB-defined PID into an OEM Id field (upper 6 bits)
38 // and a Device Id (bottom 10 bits). The Device Id defines what 38 // and a Device Id (bottom 10 bits). The Device Id defines what
39 // device this actually is regardless of what the OEM wants to 39 // device this actually is regardless of what the OEM wants to
40 // call it. 40 // call it.
41 // 41 //
42 42
43 // ION-device OEM IDs 43 // ION-device OEM IDs
44 #define ION_OEM_ID_ION 0 // 00h Inside Out Networks 44 #define ION_OEM_ID_ION 0 // 00h Inside Out Networks
45 #define ION_OEM_ID_NLYNX 1 // 01h NLynx Systems 45 #define ION_OEM_ID_NLYNX 1 // 01h NLynx Systems
46 #define ION_OEM_ID_GENERIC 2 // 02h Generic OEM 46 #define ION_OEM_ID_GENERIC 2 // 02h Generic OEM
47 #define ION_OEM_ID_MAC 3 // 03h Mac Version 47 #define ION_OEM_ID_MAC 3 // 03h Mac Version
48 #define ION_OEM_ID_MEGAWOLF 4 // 04h Lupusb OEM Mac version (MegaWolf) 48 #define ION_OEM_ID_MEGAWOLF 4 // 04h Lupusb OEM Mac version (MegaWolf)
49 #define ION_OEM_ID_MULTITECH 5 // 05h Multitech Rapidports 49 #define ION_OEM_ID_MULTITECH 5 // 05h Multitech Rapidports
50 #define ION_OEM_ID_AGILENT 6 // 06h AGILENT board 50 #define ION_OEM_ID_AGILENT 6 // 06h AGILENT board
51 51
52 52
53 // ION-device Device IDs 53 // ION-device Device IDs
54 // Product IDs - assigned to match middle digit of serial number (No longer true) 54 // Product IDs - assigned to match middle digit of serial number (No longer true)
55 55
56 #define ION_DEVICE_ID_80251_NETCHIP 0x020 // This bit is set in the PID if this edgeport hardware$ 56 #define ION_DEVICE_ID_80251_NETCHIP 0x020 // This bit is set in the PID if this edgeport hardware$
57 // is based on the 80251+Netchip. 57 // is based on the 80251+Netchip.
58 58
59 #define ION_DEVICE_ID_GENERATION_1 0x00 // Value for 930 based edgeports 59 #define ION_DEVICE_ID_GENERATION_1 0x00 // Value for 930 based edgeports
60 #define ION_DEVICE_ID_GENERATION_2 0x01 // Value for 80251+Netchip. 60 #define ION_DEVICE_ID_GENERATION_2 0x01 // Value for 80251+Netchip.
61 #define ION_DEVICE_ID_GENERATION_3 0x02 // Value for Texas Instruments TUSB5052 chip 61 #define ION_DEVICE_ID_GENERATION_3 0x02 // Value for Texas Instruments TUSB5052 chip
62 #define ION_DEVICE_ID_GENERATION_4 0x03 // Watchport Family of products 62 #define ION_DEVICE_ID_GENERATION_4 0x03 // Watchport Family of products
63 #define ION_GENERATION_MASK 0x03 63 #define ION_GENERATION_MASK 0x03
64 64
65 #define ION_DEVICE_ID_HUB_MASK 0x0080 // This bit in the PID designates a HUB device 65 #define ION_DEVICE_ID_HUB_MASK 0x0080 // This bit in the PID designates a HUB device
66 // for example 8C would be a 421 4 port hub 66 // for example 8C would be a 421 4 port hub
67 // and 8D would be a 2 port embedded hub 67 // and 8D would be a 2 port embedded hub
68 68
69 #define EDGEPORT_DEVICE_ID_MASK 0x0ff // Not including OEM or GENERATION fields 69 #define EDGEPORT_DEVICE_ID_MASK 0x0ff // Not including OEM or GENERATION fields
70 70
71 #define ION_DEVICE_ID_UNCONFIGURED_EDGE_DEVICE 0x000 // In manufacturing only 71 #define ION_DEVICE_ID_UNCONFIGURED_EDGE_DEVICE 0x000 // In manufacturing only
72 #define ION_DEVICE_ID_EDGEPORT_4 0x001 // Edgeport/4 RS232 72 #define ION_DEVICE_ID_EDGEPORT_4 0x001 // Edgeport/4 RS232
73 #define ION_DEVICE_ID_EDGEPORT_8R 0x002 // Edgeport with RJ45 no Ring 73 #define ION_DEVICE_ID_EDGEPORT_8R 0x002 // Edgeport with RJ45 no Ring
74 #define ION_DEVICE_ID_RAPIDPORT_4 0x003 // Rapidport/4 74 #define ION_DEVICE_ID_RAPIDPORT_4 0x003 // Rapidport/4
75 #define ION_DEVICE_ID_EDGEPORT_4T 0x004 // Edgeport/4 RS232 for Telxon (aka "Fleetport") 75 #define ION_DEVICE_ID_EDGEPORT_4T 0x004 // Edgeport/4 RS232 for Telxon (aka "Fleetport")
76 #define ION_DEVICE_ID_EDGEPORT_2 0x005 // Edgeport/2 RS232 76 #define ION_DEVICE_ID_EDGEPORT_2 0x005 // Edgeport/2 RS232
77 #define ION_DEVICE_ID_EDGEPORT_4I 0x006 // Edgeport/4 RS422 77 #define ION_DEVICE_ID_EDGEPORT_4I 0x006 // Edgeport/4 RS422
78 #define ION_DEVICE_ID_EDGEPORT_2I 0x007 // Edgeport/2 RS422/RS485 78 #define ION_DEVICE_ID_EDGEPORT_2I 0x007 // Edgeport/2 RS422/RS485
79 #define ION_DEVICE_ID_EDGEPORT_8RR 0x008 // Edgeport with RJ45 with Data and RTS/CTS only 79 #define ION_DEVICE_ID_EDGEPORT_8RR 0x008 // Edgeport with RJ45 with Data and RTS/CTS only
80 // ION_DEVICE_ID_EDGEPORT_8_HANDBUILT 0x009 // Hand-built Edgeport/8 (Placeholder, used in middle digit of serial number only!) 80 // ION_DEVICE_ID_EDGEPORT_8_HANDBUILT 0x009 // Hand-built Edgeport/8 (Placeholder, used in middle digit of serial number only!)
81 // ION_DEVICE_ID_MULTIMODEM_4X56 0x00A // MultiTech version of RP/4 (Placeholder, used in middle digit of serial number only!) 81 // ION_DEVICE_ID_MULTIMODEM_4X56 0x00A // MultiTech version of RP/4 (Placeholder, used in middle digit of serial number only!)
82 #define ION_DEVICE_ID_EDGEPORT_PARALLEL_PORT 0x00B // Edgeport/(4)21 Parallel port (USS720) 82 #define ION_DEVICE_ID_EDGEPORT_PARALLEL_PORT 0x00B // Edgeport/(4)21 Parallel port (USS720)
83 #define ION_DEVICE_ID_EDGEPORT_421 0x00C // Edgeport/421 Hub+RS232+Parallel 83 #define ION_DEVICE_ID_EDGEPORT_421 0x00C // Edgeport/421 Hub+RS232+Parallel
84 #define ION_DEVICE_ID_EDGEPORT_21 0x00D // Edgeport/21 RS232+Parallel 84 #define ION_DEVICE_ID_EDGEPORT_21 0x00D // Edgeport/21 RS232+Parallel
85 #define ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU 0x00E // Half of an Edgeport/8 (the kind with 2 EP/4s on 1 PCB) 85 #define ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU 0x00E // Half of an Edgeport/8 (the kind with 2 EP/4s on 1 PCB)
86 #define ION_DEVICE_ID_EDGEPORT_8 0x00F // Edgeport/8 (single-CPU) 86 #define ION_DEVICE_ID_EDGEPORT_8 0x00F // Edgeport/8 (single-CPU)
87 #define ION_DEVICE_ID_EDGEPORT_2_DIN 0x010 // Edgeport/2 RS232 with Apple DIN connector 87 #define ION_DEVICE_ID_EDGEPORT_2_DIN 0x010 // Edgeport/2 RS232 with Apple DIN connector
88 #define ION_DEVICE_ID_EDGEPORT_4_DIN 0x011 // Edgeport/4 RS232 with Apple DIN connector 88 #define ION_DEVICE_ID_EDGEPORT_4_DIN 0x011 // Edgeport/4 RS232 with Apple DIN connector
89 #define ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU 0x012 // Half of an Edgeport/16 (the kind with 2 EP/8s) 89 #define ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU 0x012 // Half of an Edgeport/16 (the kind with 2 EP/8s)
90 #define ION_DEVICE_ID_EDGEPORT_COMPATIBLE 0x013 // Edgeport Compatible, for NCR, Axiohm etc. testing 90 #define ION_DEVICE_ID_EDGEPORT_COMPATIBLE 0x013 // Edgeport Compatible, for NCR, Axiohm etc. testing
91 #define ION_DEVICE_ID_EDGEPORT_8I 0x014 // Edgeport/8 RS422 (single-CPU) 91 #define ION_DEVICE_ID_EDGEPORT_8I 0x014 // Edgeport/8 RS422 (single-CPU)
92 #define ION_DEVICE_ID_EDGEPORT_1 0x015 // Edgeport/1 RS232 92 #define ION_DEVICE_ID_EDGEPORT_1 0x015 // Edgeport/1 RS232
93 #define ION_DEVICE_ID_EPOS44 0x016 // Half of an EPOS/44 (TIUMP BASED) 93 #define ION_DEVICE_ID_EPOS44 0x016 // Half of an EPOS/44 (TIUMP BASED)
94 #define ION_DEVICE_ID_EDGEPORT_42 0x017 // Edgeport/42 94 #define ION_DEVICE_ID_EDGEPORT_42 0x017 // Edgeport/42
95 #define ION_DEVICE_ID_EDGEPORT_412_8 0x018 // Edgeport/412 8 port part 95 #define ION_DEVICE_ID_EDGEPORT_412_8 0x018 // Edgeport/412 8 port part
96 #define ION_DEVICE_ID_EDGEPORT_412_4 0x019 // Edgeport/412 4 port part 96 #define ION_DEVICE_ID_EDGEPORT_412_4 0x019 // Edgeport/412 4 port part
97 #define ION_DEVICE_ID_EDGEPORT_22I 0x01A // Edgeport/22I is an Edgeport/4 with ports 1&2 RS422 and ports 3&4 RS232 97 #define ION_DEVICE_ID_EDGEPORT_22I 0x01A // Edgeport/22I is an Edgeport/4 with ports 1&2 RS422 and ports 3&4 RS232
98 98
99 // Compact Form factor TI based devices 2c, 21c, 22c, 221c 99 // Compact Form factor TI based devices 2c, 21c, 22c, 221c
100 #define ION_DEVICE_ID_EDGEPORT_2C 0x01B // Edgeport/2c is a TI based Edgeport/2 - Small I2c 100 #define ION_DEVICE_ID_EDGEPORT_2C 0x01B // Edgeport/2c is a TI based Edgeport/2 - Small I2c
101 #define ION_DEVICE_ID_EDGEPORT_221C 0x01C // Edgeport/221c is a TI based Edgeport/2 with lucent chip and 101 #define ION_DEVICE_ID_EDGEPORT_221C 0x01C // Edgeport/221c is a TI based Edgeport/2 with lucent chip and
102 // 2 external hub ports - Large I2C 102 // 2 external hub ports - Large I2C
103 #define ION_DEVICE_ID_EDGEPORT_22C 0x01D // Edgeport/22c is a TI based Edgeport/2 with 103 #define ION_DEVICE_ID_EDGEPORT_22C 0x01D // Edgeport/22c is a TI based Edgeport/2 with
104 // 2 external hub ports - Large I2C 104 // 2 external hub ports - Large I2C
105 #define ION_DEVICE_ID_EDGEPORT_21C 0x01E // Edgeport/21c is a TI based Edgeport/2 with lucent chip 105 #define ION_DEVICE_ID_EDGEPORT_21C 0x01E // Edgeport/21c is a TI based Edgeport/2 with lucent chip
106 // Small I2C 106 // Small I2C
107 107
108 108
109 /* 109 /*
110 * DANGER DANGER The 0x20 bit was used to indicate a 8251/netchip GEN 2 device. 110 * DANGER DANGER The 0x20 bit was used to indicate a 8251/netchip GEN 2 device.
111 * Since the MAC, Linux, and Optimal drivers still used the old code 111 * Since the MAC, Linux, and Optimal drivers still used the old code
112 * I suggest that you skip the 0x20 bit when creating new PIDs 112 * I suggest that you skip the 0x20 bit when creating new PIDs
113 */ 113 */
114 114
115 115
116 // Generation 3 devices -- 3410 based edgport/1 (256 byte I2C) 116 // Generation 3 devices -- 3410 based edgport/1 (256 byte I2C)
117 #define ION_DEVICE_ID_TI3410_EDGEPORT_1 0x040 // Edgeport/1 RS232 117 #define ION_DEVICE_ID_TI3410_EDGEPORT_1 0x040 // Edgeport/1 RS232
118 #define ION_DEVICE_ID_TI3410_EDGEPORT_1I 0x041 // Edgeport/1i- RS422 model 118 #define ION_DEVICE_ID_TI3410_EDGEPORT_1I 0x041 // Edgeport/1i- RS422 model
119 119
120 // Ti based software switchable RS232/RS422/RS485 devices 120 // Ti based software switchable RS232/RS422/RS485 devices
121 #define ION_DEVICE_ID_EDGEPORT_4S 0x042 // Edgeport/4s - software switchable model 121 #define ION_DEVICE_ID_EDGEPORT_4S 0x042 // Edgeport/4s - software switchable model
122 #define ION_DEVICE_ID_EDGEPORT_8S 0x043 // Edgeport/8s - software switchable model 122 #define ION_DEVICE_ID_EDGEPORT_8S 0x043 // Edgeport/8s - software switchable model
123 123
124 // Usb to Ethernet dongle 124 // Usb to Ethernet dongle
125 #define ION_DEVICE_ID_EDGEPORT_E 0x0E0 // Edgeport/E Usb to Ethernet 125 #define ION_DEVICE_ID_EDGEPORT_E 0x0E0 // Edgeport/E Usb to Ethernet
126 126
127 // Edgeport TI based devices 127 // Edgeport TI based devices
128 #define ION_DEVICE_ID_TI_EDGEPORT_4 0x0201 // Edgeport/4 RS232 128 #define ION_DEVICE_ID_TI_EDGEPORT_4 0x0201 // Edgeport/4 RS232
129 #define ION_DEVICE_ID_TI_EDGEPORT_2 0x0205 // Edgeport/2 RS232 129 #define ION_DEVICE_ID_TI_EDGEPORT_2 0x0205 // Edgeport/2 RS232
130 #define ION_DEVICE_ID_TI_EDGEPORT_4I 0x0206 // Edgeport/4i RS422 130 #define ION_DEVICE_ID_TI_EDGEPORT_4I 0x0206 // Edgeport/4i RS422
131 #define ION_DEVICE_ID_TI_EDGEPORT_2I 0x0207 // Edgeport/2i RS422/RS485 131 #define ION_DEVICE_ID_TI_EDGEPORT_2I 0x0207 // Edgeport/2i RS422/RS485
132 #define ION_DEVICE_ID_TI_EDGEPORT_421 0x020C // Edgeport/421 4 hub 2 RS232 + Parallel (lucent on a different hub port) 132 #define ION_DEVICE_ID_TI_EDGEPORT_421 0x020C // Edgeport/421 4 hub 2 RS232 + Parallel (lucent on a different hub port)
133 #define ION_DEVICE_ID_TI_EDGEPORT_21 0x020D // Edgeport/21 2 RS232 + Parallel (lucent on a different hub port) 133 #define ION_DEVICE_ID_TI_EDGEPORT_21 0x020D // Edgeport/21 2 RS232 + Parallel (lucent on a different hub port)
134 #define ION_DEVICE_ID_TI_EDGEPORT_416 0x0212 // Edgeport/416 134 #define ION_DEVICE_ID_TI_EDGEPORT_416 0x0212 // Edgeport/416
135 #define ION_DEVICE_ID_TI_EDGEPORT_1 0x0215 // Edgeport/1 RS232 135 #define ION_DEVICE_ID_TI_EDGEPORT_1 0x0215 // Edgeport/1 RS232
136 #define ION_DEVICE_ID_TI_EDGEPORT_42 0x0217 // Edgeport/42 4 hub 2 RS232 136 #define ION_DEVICE_ID_TI_EDGEPORT_42 0x0217 // Edgeport/42 4 hub 2 RS232
137 #define ION_DEVICE_ID_TI_EDGEPORT_22I 0x021A // Edgeport/22I is an Edgeport/4 with ports 1&2 RS422 and ports 3&4 RS232 137 #define ION_DEVICE_ID_TI_EDGEPORT_22I 0x021A // Edgeport/22I is an Edgeport/4 with ports 1&2 RS422 and ports 3&4 RS232
138 #define ION_DEVICE_ID_TI_EDGEPORT_2C 0x021B // Edgeport/2c RS232 138 #define ION_DEVICE_ID_TI_EDGEPORT_2C 0x021B // Edgeport/2c RS232
139 #define ION_DEVICE_ID_TI_EDGEPORT_221C 0x021C // Edgeport/221c is a TI based Edgeport/2 with lucent chip and 139 #define ION_DEVICE_ID_TI_EDGEPORT_221C 0x021C // Edgeport/221c is a TI based Edgeport/2 with lucent chip and
140 // 2 external hub ports - Large I2C 140 // 2 external hub ports - Large I2C
141 #define ION_DEVICE_ID_TI_EDGEPORT_22C 0x021D // Edgeport/22c is a TI based Edgeport/2 with 141 #define ION_DEVICE_ID_TI_EDGEPORT_22C 0x021D // Edgeport/22c is a TI based Edgeport/2 with
142 // 2 external hub ports - Large I2C 142 // 2 external hub ports - Large I2C
143 #define ION_DEVICE_ID_TI_EDGEPORT_21C 0x021E // Edgeport/21c is a TI based Edgeport/2 with lucent chip 143 #define ION_DEVICE_ID_TI_EDGEPORT_21C 0x021E // Edgeport/21c is a TI based Edgeport/2 with lucent chip
144 144
145 // Generation 3 devices -- 3410 based edgport/1 (256 byte I2C) 145 // Generation 3 devices -- 3410 based edgport/1 (256 byte I2C)
146 #define ION_DEVICE_ID_TI_TI3410_EDGEPORT_1 0x0240 // Edgeport/1 RS232 146 #define ION_DEVICE_ID_TI_TI3410_EDGEPORT_1 0x0240 // Edgeport/1 RS232
147 #define ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I 0x0241 // Edgeport/1i- RS422 model 147 #define ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I 0x0241 // Edgeport/1i- RS422 model
148 148
149 // Ti based software switchable RS232/RS422/RS485 devices 149 // Ti based software switchable RS232/RS422/RS485 devices
150 #define ION_DEVICE_ID_TI_EDGEPORT_4S 0x0242 // Edgeport/4s - software switchable model 150 #define ION_DEVICE_ID_TI_EDGEPORT_4S 0x0242 // Edgeport/4s - software switchable model
151 #define ION_DEVICE_ID_TI_EDGEPORT_8S 0x0243 // Edgeport/8s - software switchable model 151 #define ION_DEVICE_ID_TI_EDGEPORT_8S 0x0243 // Edgeport/8s - software switchable model
152 #define ION_DEVICE_ID_TI_EDGEPORT_8 0x0244 // Edgeport/8 (single-CPU) 152 #define ION_DEVICE_ID_TI_EDGEPORT_8 0x0244 // Edgeport/8 (single-CPU)
153 #define ION_DEVICE_ID_TI_EDGEPORT_416B 0x0247 // Edgeport/416 153 #define ION_DEVICE_ID_TI_EDGEPORT_416B 0x0247 // Edgeport/416
154 154
155 155
156 /************************************************************************ 156 /************************************************************************
157 * 157 *
158 * Generation 4 devices 158 * Generation 4 devices
159 * 159 *
160 ************************************************************************/ 160 ************************************************************************/
161 161
162 // Watchport based on 3410 both 1-wire and binary products (16K I2C) 162 // Watchport based on 3410 both 1-wire and binary products (16K I2C)
163 #define ION_DEVICE_ID_WP_UNSERIALIZED 0x300 // Watchport based on 3410 both 1-wire and binary products 163 #define ION_DEVICE_ID_WP_UNSERIALIZED 0x300 // Watchport based on 3410 both 1-wire and binary products
164 #define ION_DEVICE_ID_WP_PROXIMITY 0x301 // Watchport/P Discontinued 164 #define ION_DEVICE_ID_WP_PROXIMITY 0x301 // Watchport/P Discontinued
165 #define ION_DEVICE_ID_WP_MOTION 0x302 // Watchport/M 165 #define ION_DEVICE_ID_WP_MOTION 0x302 // Watchport/M
166 #define ION_DEVICE_ID_WP_MOISTURE 0x303 // Watchport/W 166 #define ION_DEVICE_ID_WP_MOISTURE 0x303 // Watchport/W
167 #define ION_DEVICE_ID_WP_TEMPERATURE 0x304 // Watchport/T 167 #define ION_DEVICE_ID_WP_TEMPERATURE 0x304 // Watchport/T
168 #define ION_DEVICE_ID_WP_HUMIDITY 0x305 // Watchport/H 168 #define ION_DEVICE_ID_WP_HUMIDITY 0x305 // Watchport/H
169 169
170 #define ION_DEVICE_ID_WP_POWER 0x306 // Watchport 170 #define ION_DEVICE_ID_WP_POWER 0x306 // Watchport
171 #define ION_DEVICE_ID_WP_LIGHT 0x307 // Watchport 171 #define ION_DEVICE_ID_WP_LIGHT 0x307 // Watchport
172 #define ION_DEVICE_ID_WP_RADIATION 0x308 // Watchport 172 #define ION_DEVICE_ID_WP_RADIATION 0x308 // Watchport
173 #define ION_DEVICE_ID_WP_ACCELERATION 0x309 // Watchport/A 173 #define ION_DEVICE_ID_WP_ACCELERATION 0x309 // Watchport/A
174 #define ION_DEVICE_ID_WP_DISTANCE 0x30A // Watchport/D Discontinued 174 #define ION_DEVICE_ID_WP_DISTANCE 0x30A // Watchport/D Discontinued
175 #define ION_DEVICE_ID_WP_PROX_DIST 0x30B // Watchport/D uses distance sensor 175 #define ION_DEVICE_ID_WP_PROX_DIST 0x30B // Watchport/D uses distance sensor
176 // Default to /P function 176 // Default to /P function
177 177
178 #define ION_DEVICE_ID_PLUS_PWR_HP4CD 0x30C // 5052 Plus Power HubPort/4CD+ (for Dell) 178 #define ION_DEVICE_ID_PLUS_PWR_HP4CD 0x30C // 5052 Plus Power HubPort/4CD+ (for Dell)
179 #define ION_DEVICE_ID_PLUS_PWR_HP4C 0x30D // 5052 Plus Power HubPort/4C+ 179 #define ION_DEVICE_ID_PLUS_PWR_HP4C 0x30D // 5052 Plus Power HubPort/4C+
180 #define ION_DEVICE_ID_PLUS_PWR_PCI 0x30E // 3410 Plus Power PCI Host Controller 4 port 180 #define ION_DEVICE_ID_PLUS_PWR_PCI 0x30E // 3410 Plus Power PCI Host Controller 4 port
181 181
182 182
183 // 183 //
184 // Definitions for AXIOHM USB product IDs 184 // Definitions for AXIOHM USB product IDs
185 // 185 //
186 #define USB_VENDOR_ID_AXIOHM 0x05D9 // Axiohm VID 186 #define USB_VENDOR_ID_AXIOHM 0x05D9 // Axiohm VID
187 187
188 #define AXIOHM_DEVICE_ID_MASK 0xffff 188 #define AXIOHM_DEVICE_ID_MASK 0xffff
189 #define AXIOHM_DEVICE_ID_EPIC_A758 0xA758 189 #define AXIOHM_DEVICE_ID_EPIC_A758 0xA758
190 #define AXIOHM_DEVICE_ID_EPIC_A794 0xA794 190 #define AXIOHM_DEVICE_ID_EPIC_A794 0xA794
191 #define AXIOHM_DEVICE_ID_EPIC_A225 0xA225 191 #define AXIOHM_DEVICE_ID_EPIC_A225 0xA225
192 192
193 193
194 // 194 //
195 // Definitions for NCR USB product IDs 195 // Definitions for NCR USB product IDs
196 // 196 //
197 #define USB_VENDOR_ID_NCR 0x0404 // NCR VID 197 #define USB_VENDOR_ID_NCR 0x0404 // NCR VID
198 198
199 #define NCR_DEVICE_ID_MASK 0xffff 199 #define NCR_DEVICE_ID_MASK 0xffff
200 #define NCR_DEVICE_ID_EPIC_0202 0x0202 200 #define NCR_DEVICE_ID_EPIC_0202 0x0202
201 #define NCR_DEVICE_ID_EPIC_0203 0x0203 201 #define NCR_DEVICE_ID_EPIC_0203 0x0203
202 #define NCR_DEVICE_ID_EPIC_0310 0x0310 202 #define NCR_DEVICE_ID_EPIC_0310 0x0310
203 #define NCR_DEVICE_ID_EPIC_0311 0x0311 203 #define NCR_DEVICE_ID_EPIC_0311 0x0311
204 #define NCR_DEVICE_ID_EPIC_0312 0x0312 204 #define NCR_DEVICE_ID_EPIC_0312 0x0312
205 205
206 206
207 // 207 //
208 // Definitions for SYMBOL USB product IDs 208 // Definitions for SYMBOL USB product IDs
209 // 209 //
210 #define USB_VENDOR_ID_SYMBOL 0x05E0 // Symbol VID 210 #define USB_VENDOR_ID_SYMBOL 0x05E0 // Symbol VID
211 #define SYMBOL_DEVICE_ID_MASK 0xffff 211 #define SYMBOL_DEVICE_ID_MASK 0xffff
212 #define SYMBOL_DEVICE_ID_KEYFOB 0x0700 212 #define SYMBOL_DEVICE_ID_KEYFOB 0x0700
213 213
214 214
215 // 215 //
216 // Definitions for other product IDs 216 // Definitions for other product IDs
217 #define ION_DEVICE_ID_MT4X56USB 0x1403 // OEM device 217 #define ION_DEVICE_ID_MT4X56USB 0x1403 // OEM device
218 218
219 219
220 #define GENERATION_ID_FROM_USB_PRODUCT_ID(ProductId) \ 220 #define GENERATION_ID_FROM_USB_PRODUCT_ID(ProductId) \
221 ((__u16) ((ProductId >> 8) & (ION_GENERATION_MASK))) 221 ((__u16) ((ProductId >> 8) & (ION_GENERATION_MASK)))
222 222
223 #define MAKE_USB_PRODUCT_ID(OemId, DeviceId) \ 223 #define MAKE_USB_PRODUCT_ID(OemId, DeviceId) \
224 ((__u16) (((OemId) << 10) || (DeviceId))) 224 ((__u16) (((OemId) << 10) || (DeviceId)))
225 225
226 #define DEVICE_ID_FROM_USB_PRODUCT_ID(ProductId) \ 226 #define DEVICE_ID_FROM_USB_PRODUCT_ID(ProductId) \
227 ((__u16) ((ProductId) & (EDGEPORT_DEVICE_ID_MASK))) 227 ((__u16) ((ProductId) & (EDGEPORT_DEVICE_ID_MASK)))
228 228
229 #define OEM_ID_FROM_USB_PRODUCT_ID(ProductId) \ 229 #define OEM_ID_FROM_USB_PRODUCT_ID(ProductId) \
230 ((__u16) (((ProductId) >> 10) & 0x3F)) 230 ((__u16) (((ProductId) >> 10) & 0x3F))
231 231
232 // 232 //
233 // Definitions of parameters for download code. Note that these are 233 // Definitions of parameters for download code. Note that these are
234 // specific to a given version of download code and must change if the 234 // specific to a given version of download code and must change if the
235 // corresponding download code changes. 235 // corresponding download code changes.
236 // 236 //
237 237
238 // TxCredits value below which driver won't bother sending (to prevent too many small writes). 238 // TxCredits value below which driver won't bother sending (to prevent too many small writes).
239 // Send only if above 25% 239 // Send only if above 25%
240 #define EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(InitialCredit, MaxPacketSize) (max(((InitialCredit) / 4), (MaxPacketSize))) 240 #define EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(InitialCredit, MaxPacketSize) (max(((InitialCredit) / 4), (MaxPacketSize)))
241 241
242 #define EDGE_FW_BULK_MAX_PACKET_SIZE 64 // Max Packet Size for Bulk In Endpoint (EP1) 242 #define EDGE_FW_BULK_MAX_PACKET_SIZE 64 // Max Packet Size for Bulk In Endpoint (EP1)
243 #define EDGE_FW_BULK_READ_BUFFER_SIZE 1024 // Size to use for Bulk reads 243 #define EDGE_FW_BULK_READ_BUFFER_SIZE 1024 // Size to use for Bulk reads
244 244
245 #define EDGE_FW_INT_MAX_PACKET_SIZE 32 // Max Packet Size for Interrupt In Endpoint 245 #define EDGE_FW_INT_MAX_PACKET_SIZE 32 // Max Packet Size for Interrupt In Endpoint
246 // Note that many units were shipped with MPS=16, we 246 // Note that many units were shipped with MPS=16, we
247 // force an upgrade to this value). 247 // force an upgrade to this value).
248 #define EDGE_FW_INT_INTERVAL 2 // 2ms polling on IntPipe 248 #define EDGE_FW_INT_INTERVAL 2 // 2ms polling on IntPipe
249 249
250 250
251 // 251 //
252 // Definitions of I/O Networks vendor-specific requests 252 // Definitions of I/O Networks vendor-specific requests
253 // for default endpoint 253 // for default endpoint
254 // 254 //
255 // bmRequestType = 01000000 Set vendor-specific, to device 255 // bmRequestType = 01000000 Set vendor-specific, to device
256 // bmRequestType = 11000000 Get vendor-specific, to device 256 // bmRequestType = 11000000 Get vendor-specific, to device
257 // 257 //
258 // These are the definitions for the bRequest field for the 258 // These are the definitions for the bRequest field for the
259 // above bmRequestTypes. 259 // above bmRequestTypes.
260 // 260 //
261 // For the read/write Edgeport memory commands, the parameters 261 // For the read/write Edgeport memory commands, the parameters
262 // are as follows: 262 // are as follows:
263 // wValue = 16-bit address 263 // wValue = 16-bit address
264 // wIndex = unused (though we could put segment 00: or FF: here) 264 // wIndex = unused (though we could put segment 00: or FF: here)
265 // wLength = # bytes to read/write (max 64) 265 // wLength = # bytes to read/write (max 64)
266 // 266 //
267 267
268 #define USB_REQUEST_ION_RESET_DEVICE 0 // Warm reboot Edgeport, retaining USB address 268 #define USB_REQUEST_ION_RESET_DEVICE 0 // Warm reboot Edgeport, retaining USB address
269 #define USB_REQUEST_ION_GET_EPIC_DESC 1 // Get Edgeport Compatibility Descriptor 269 #define USB_REQUEST_ION_GET_EPIC_DESC 1 // Get Edgeport Compatibility Descriptor
270 // unused 2 // Unused, available 270 // unused 2 // Unused, available
271 #define USB_REQUEST_ION_READ_RAM 3 // Read EdgePort RAM at specified addr 271 #define USB_REQUEST_ION_READ_RAM 3 // Read EdgePort RAM at specified addr
272 #define USB_REQUEST_ION_WRITE_RAM 4 // Write EdgePort RAM at specified addr 272 #define USB_REQUEST_ION_WRITE_RAM 4 // Write EdgePort RAM at specified addr
273 #define USB_REQUEST_ION_READ_ROM 5 // Read EdgePort ROM at specified addr 273 #define USB_REQUEST_ION_READ_ROM 5 // Read EdgePort ROM at specified addr
274 #define USB_REQUEST_ION_WRITE_ROM 6 // Write EdgePort ROM at specified addr 274 #define USB_REQUEST_ION_WRITE_ROM 6 // Write EdgePort ROM at specified addr
275 #define USB_REQUEST_ION_EXEC_DL_CODE 7 // Begin execution of RAM-based download 275 #define USB_REQUEST_ION_EXEC_DL_CODE 7 // Begin execution of RAM-based download
276 // code by jumping to address in wIndex:wValue 276 // code by jumping to address in wIndex:wValue
277 // 8 // Unused, available 277 // 8 // Unused, available
278 #define USB_REQUEST_ION_ENABLE_SUSPEND 9 // Enable/Disable suspend feature 278 #define USB_REQUEST_ION_ENABLE_SUSPEND 9 // Enable/Disable suspend feature
279 // (wValue != 0: Enable; wValue = 0: Disable) 279 // (wValue != 0: Enable; wValue = 0: Disable)
280 280
281 #define USB_REQUEST_ION_SEND_IOSP 10 // Send an IOSP command to the edgeport over the control pipe 281 #define USB_REQUEST_ION_SEND_IOSP 10 // Send an IOSP command to the edgeport over the control pipe
282 #define USB_REQUEST_ION_RECV_IOSP 11 // Receive an IOSP command from the edgeport over the control pipe 282 #define USB_REQUEST_ION_RECV_IOSP 11 // Receive an IOSP command from the edgeport over the control pipe
283 283
284 284
285 #define USB_REQUEST_ION_DIS_INT_TIMER 0x80 // Sent to Axiohm to enable/ disable 285 #define USB_REQUEST_ION_DIS_INT_TIMER 0x80 // Sent to Axiohm to enable/ disable
286 // interrupt token timer 286 // interrupt token timer
287 // wValue = 1, enable (default) 287 // wValue = 1, enable (default)
288 // wValue = 0, disable 288 // wValue = 0, disable
289 289
290 // 290 //
291 // Define parameter values for our vendor-specific commands 291 // Define parameter values for our vendor-specific commands
292 // 292 //
293 293
294 // 294 //
295 // Edgeport Compatibility Descriptor 295 // Edgeport Compatibility Descriptor
296 // 296 //
297 // This descriptor is only returned by Edgeport-compatible devices 297 // This descriptor is only returned by Edgeport-compatible devices
298 // supporting the EPiC spec. True ION devices do not return this 298 // supporting the EPiC spec. True ION devices do not return this
299 // descriptor, but instead return STALL on receipt of the 299 // descriptor, but instead return STALL on receipt of the
300 // GET_EPIC_DESC command. The driver interprets a STALL to mean that 300 // GET_EPIC_DESC command. The driver interprets a STALL to mean that
301 // this is a "real" Edgeport. 301 // this is a "real" Edgeport.
302 // 302 //
303 303
304 struct edge_compatibility_bits { 304 struct edge_compatibility_bits {
305 // This __u32 defines which Vendor-specific commands/functionality 305 // This __u32 defines which Vendor-specific commands/functionality
306 // the device supports on the default EP0 pipe. 306 // the device supports on the default EP0 pipe.
307 307
308 __u32 VendEnableSuspend : 1; // 0001 Set if device supports ION_ENABLE_SUSPEND 308 __u32 VendEnableSuspend : 1; // 0001 Set if device supports ION_ENABLE_SUSPEND
309 __u32 VendUnused : 31; // Available for future expansion, must be 0 309 __u32 VendUnused : 31; // Available for future expansion, must be 0
310 310
311 // This __u32 defines which IOSP commands are supported over the 311 // This __u32 defines which IOSP commands are supported over the
312 // bulk pipe EP1. 312 // bulk pipe EP1.
313 313
314 // xxxx Set if device supports: 314 // xxxx Set if device supports:
315 __u32 IOSPOpen : 1; // 0001 OPEN / OPEN_RSP (Currently must be 1) 315 __u32 IOSPOpen : 1; // 0001 OPEN / OPEN_RSP (Currently must be 1)
316 __u32 IOSPClose : 1; // 0002 CLOSE 316 __u32 IOSPClose : 1; // 0002 CLOSE
317 __u32 IOSPChase : 1; // 0004 CHASE / CHASE_RSP 317 __u32 IOSPChase : 1; // 0004 CHASE / CHASE_RSP
318 __u32 IOSPSetRxFlow : 1; // 0008 SET_RX_FLOW 318 __u32 IOSPSetRxFlow : 1; // 0008 SET_RX_FLOW
319 __u32 IOSPSetTxFlow : 1; // 0010 SET_TX_FLOW 319 __u32 IOSPSetTxFlow : 1; // 0010 SET_TX_FLOW
320 __u32 IOSPSetXChar : 1; // 0020 SET_XON_CHAR/SET_XOFF_CHAR 320 __u32 IOSPSetXChar : 1; // 0020 SET_XON_CHAR/SET_XOFF_CHAR
321 __u32 IOSPRxCheck : 1; // 0040 RX_CHECK_REQ/RX_CHECK_RSP 321 __u32 IOSPRxCheck : 1; // 0040 RX_CHECK_REQ/RX_CHECK_RSP
322 __u32 IOSPSetClrBreak : 1; // 0080 SET_BREAK/CLEAR_BREAK 322 __u32 IOSPSetClrBreak : 1; // 0080 SET_BREAK/CLEAR_BREAK
323 __u32 IOSPWriteMCR : 1; // 0100 MCR register writes (set/clr DTR/RTS) 323 __u32 IOSPWriteMCR : 1; // 0100 MCR register writes (set/clr DTR/RTS)
324 __u32 IOSPWriteLCR : 1; // 0200 LCR register writes (wordlen/stop/parity) 324 __u32 IOSPWriteLCR : 1; // 0200 LCR register writes (wordlen/stop/parity)
325 __u32 IOSPSetBaudRate : 1; // 0400 setting Baud rate (writes to LCR.80h and DLL/DLM register) 325 __u32 IOSPSetBaudRate : 1; // 0400 setting Baud rate (writes to LCR.80h and DLL/DLM register)
326 __u32 IOSPDisableIntPipe : 1; // 0800 Do not use the interrupt pipe for TxCredits or RxButesAvailable 326 __u32 IOSPDisableIntPipe : 1; // 0800 Do not use the interrupt pipe for TxCredits or RxButesAvailable
327 __u32 IOSPRxDataAvail : 1; // 1000 Return status of RX Fifo (Data available in Fifo) 327 __u32 IOSPRxDataAvail : 1; // 1000 Return status of RX Fifo (Data available in Fifo)
328 __u32 IOSPTxPurge : 1; // 2000 Purge TXBuffer and/or Fifo in Edgeport hardware 328 __u32 IOSPTxPurge : 1; // 2000 Purge TXBuffer and/or Fifo in Edgeport hardware
329 __u32 IOSPUnused : 18; // Available for future expansion, must be 0 329 __u32 IOSPUnused : 18; // Available for future expansion, must be 0
330 330
331 // This __u32 defines which 'general' features are supported 331 // This __u32 defines which 'general' features are supported
332 332
333 __u32 TrueEdgeport : 1; // 0001 Set if device is a 'real' Edgeport 333 __u32 TrueEdgeport : 1; // 0001 Set if device is a 'real' Edgeport
334 // (Used only by driver, NEVER set by an EPiC device) 334 // (Used only by driver, NEVER set by an EPiC device)
335 __u32 GenUnused : 31; // Available for future expansion, must be 0 335 __u32 GenUnused : 31; // Available for future expansion, must be 0
336 }; 336 };
337 337
338 #define EDGE_COMPATIBILITY_MASK0 0x0001 338 #define EDGE_COMPATIBILITY_MASK0 0x0001
339 #define EDGE_COMPATIBILITY_MASK1 0x3FFF 339 #define EDGE_COMPATIBILITY_MASK1 0x3FFF
340 #define EDGE_COMPATIBILITY_MASK2 0x0001 340 #define EDGE_COMPATIBILITY_MASK2 0x0001
341 341
342 struct edge_compatibility_descriptor { 342 struct edge_compatibility_descriptor {
343 __u8 Length; // Descriptor Length (per USB spec) 343 __u8 Length; // Descriptor Length (per USB spec)
344 __u8 DescType; // Descriptor Type (per USB spec, =DEVICE type) 344 __u8 DescType; // Descriptor Type (per USB spec, =DEVICE type)
345 __u8 EpicVer; // Version of EPiC spec supported 345 __u8 EpicVer; // Version of EPiC spec supported
346 // (Currently must be 1) 346 // (Currently must be 1)
347 __u8 NumPorts; // Number of serial ports supported 347 __u8 NumPorts; // Number of serial ports supported
348 __u8 iDownloadFile; // Index of string containing download code filename 348 __u8 iDownloadFile; // Index of string containing download code filename
349 // 0=no download, FF=download compiled into driver. 349 // 0=no download, FF=download compiled into driver.
350 __u8 Unused[3]; // Available for future expansion, must be 0 350 __u8 Unused[3]; // Available for future expansion, must be 0
351 // (Currently must be 0). 351 // (Currently must be 0).
352 __u8 MajorVersion; // Firmware version: xx. 352 __u8 MajorVersion; // Firmware version: xx.
353 __u8 MinorVersion; // yy. 353 __u8 MinorVersion; // yy.
354 __le16 BuildNumber; // zzzz (LE format) 354 __le16 BuildNumber; // zzzz (LE format)
355 355
356 // The following structure contains __u32s, with each bit 356 // The following structure contains __u32s, with each bit
357 // specifying whether the EPiC device supports the given 357 // specifying whether the EPiC device supports the given
358 // command or functionality. 358 // command or functionality.
359 struct edge_compatibility_bits Supports; 359 struct edge_compatibility_bits Supports;
360 }; 360 };
361 361
362 // Values for iDownloadFile 362 // Values for iDownloadFile
363 #define EDGE_DOWNLOAD_FILE_NONE 0 // No download requested 363 #define EDGE_DOWNLOAD_FILE_NONE 0 // No download requested
364 #define EDGE_DOWNLOAD_FILE_INTERNAL 0xFF // Download the file compiled into driver (930 version) 364 #define EDGE_DOWNLOAD_FILE_INTERNAL 0xFF // Download the file compiled into driver (930 version)
365 #define EDGE_DOWNLOAD_FILE_I930 0xFF // Download the file compiled into driver (930 version) 365 #define EDGE_DOWNLOAD_FILE_I930 0xFF // Download the file compiled into driver (930 version)
366 #define EDGE_DOWNLOAD_FILE_80251 0xFE // Download the file compiled into driver (80251 version) 366 #define EDGE_DOWNLOAD_FILE_80251 0xFE // Download the file compiled into driver (80251 version)
367 367
368 368
369 369
370 /* 370 /*
371 * Special addresses for READ/WRITE_RAM/ROM 371 * Special addresses for READ/WRITE_RAM/ROM
372 */ 372 */
373 373
374 // Version 1 (original) format of DeviceParams 374 // Version 1 (original) format of DeviceParams
375 #define EDGE_MANUF_DESC_ADDR_V1 0x00FF7F00 375 #define EDGE_MANUF_DESC_ADDR_V1 0x00FF7F00
376 #define EDGE_MANUF_DESC_LEN_V1 sizeof(EDGE_MANUF_DESCRIPTOR_V1) 376 #define EDGE_MANUF_DESC_LEN_V1 sizeof(EDGE_MANUF_DESCRIPTOR_V1)
377 377
378 // Version 2 format of DeviceParams. This format is longer (3C0h) 378 // Version 2 format of DeviceParams. This format is longer (3C0h)
379 // and starts lower in memory, at the uppermost 1K in ROM. 379 // and starts lower in memory, at the uppermost 1K in ROM.
380 #define EDGE_MANUF_DESC_ADDR 0x00FF7C00 380 #define EDGE_MANUF_DESC_ADDR 0x00FF7C00
381 #define EDGE_MANUF_DESC_LEN sizeof(struct edge_manuf_descriptor) 381 #define EDGE_MANUF_DESC_LEN sizeof(struct edge_manuf_descriptor)
382 382
383 // Boot params descriptor 383 // Boot params descriptor
384 #define EDGE_BOOT_DESC_ADDR 0x00FF7FC0 384 #define EDGE_BOOT_DESC_ADDR 0x00FF7FC0
385 #define EDGE_BOOT_DESC_LEN sizeof(struct edge_boot_descriptor) 385 #define EDGE_BOOT_DESC_LEN sizeof(struct edge_boot_descriptor)
386 386
387 // Define the max block size that may be read or written 387 // Define the max block size that may be read or written
388 // in a read/write RAM/ROM command. 388 // in a read/write RAM/ROM command.
389 #define MAX_SIZE_REQ_ION_READ_MEM ((__u16)64) 389 #define MAX_SIZE_REQ_ION_READ_MEM ((__u16)64)
390 #define MAX_SIZE_REQ_ION_WRITE_MEM ((__u16)64) 390 #define MAX_SIZE_REQ_ION_WRITE_MEM ((__u16)64)
391 391
392 392
393 // 393 //
394 // Notes for the following two ION vendor-specific param descriptors: 394 // Notes for the following two ION vendor-specific param descriptors:
395 // 395 //
396 // 1. These have a standard USB descriptor header so they look like a 396 // 1. These have a standard USB descriptor header so they look like a
397 // normal descriptor. 397 // normal descriptor.
398 // 2. Any strings in the structures are in USB-defined string 398 // 2. Any strings in the structures are in USB-defined string
399 // descriptor format, so that they may be separately retrieved, 399 // descriptor format, so that they may be separately retrieved,
400 // if necessary, with a minimum of work on the 930. This also 400 // if necessary, with a minimum of work on the 930. This also
401 // requires them to be in UNICODE format, which, for English at 401 // requires them to be in UNICODE format, which, for English at
402 // least, simply means extending each __u8 into a __u16. 402 // least, simply means extending each __u8 into a __u16.
403 // 3. For all fields, 00 means 'uninitialized'. 403 // 3. For all fields, 00 means 'uninitialized'.
404 // 4. All unused areas should be set to 00 for future expansion. 404 // 4. All unused areas should be set to 00 for future expansion.
405 // 405 //
406 406
407 // This structure is ver 2 format. It contains ALL USB descriptors as 407 // This structure is ver 2 format. It contains ALL USB descriptors as
408 // well as the configuration parameters that were in the original V1 408 // well as the configuration parameters that were in the original V1
409 // structure. It is NOT modified when new boot code is downloaded; rather, 409 // structure. It is NOT modified when new boot code is downloaded; rather,
410 // these values are set or modified by manufacturing. It is located at 410 // these values are set or modified by manufacturing. It is located at
411 // xC00-xFBF (length 3C0h) in the ROM. 411 // xC00-xFBF (length 3C0h) in the ROM.
412 // This structure is a superset of the v1 structure and is arranged so 412 // This structure is a superset of the v1 structure and is arranged so
413 // that all of the v1 fields remain at the same address. We are just 413 // that all of the v1 fields remain at the same address. We are just
414 // adding more room to the front of the structure to hold the descriptors. 414 // adding more room to the front of the structure to hold the descriptors.
415 // 415 //
416 // The actual contents of this structure are defined in a 930 assembly 416 // The actual contents of this structure are defined in a 930 assembly
417 // file, converted to a binary image, and then written by the serialization 417 // file, converted to a binary image, and then written by the serialization
418 // program. The C definition of this structure just defines a dummy 418 // program. The C definition of this structure just defines a dummy
419 // area for general USB descriptors and the descriptor tables (the root 419 // area for general USB descriptors and the descriptor tables (the root
420 // descriptor starts at xC00). At the bottom of the structure are the 420 // descriptor starts at xC00). At the bottom of the structure are the
421 // fields inherited from the v1 structure. 421 // fields inherited from the v1 structure.
422 422
423 #define MAX_SERIALNUMBER_LEN 12 423 #define MAX_SERIALNUMBER_LEN 12
424 #define MAX_ASSEMBLYNUMBER_LEN 14 424 #define MAX_ASSEMBLYNUMBER_LEN 14
425 425
426 struct edge_manuf_descriptor { 426 struct edge_manuf_descriptor {
427 427
428 __u16 RootDescTable[0x10]; // C00 Root of descriptor tables (just a placeholder) 428 __u16 RootDescTable[0x10]; // C00 Root of descriptor tables (just a placeholder)
429 __u8 DescriptorArea[0x2E0]; // C20 Descriptors go here, up to 2E0h (just a placeholder) 429 __u8 DescriptorArea[0x2E0]; // C20 Descriptors go here, up to 2E0h (just a placeholder)
430 430
431 // Start of v1-compatible section 431 // Start of v1-compatible section
432 __u8 Length; // F00 Desc length for what follows, per USB (= C0h ) 432 __u8 Length; // F00 Desc length for what follows, per USB (= C0h )
433 __u8 DescType; // F01 Desc type, per USB (=DEVICE type) 433 __u8 DescType; // F01 Desc type, per USB (=DEVICE type)
434 __u8 DescVer; // F02 Desc version/format (currently 2) 434 __u8 DescVer; // F02 Desc version/format (currently 2)
435 __u8 NumRootDescEntries; // F03 # entries in RootDescTable 435 __u8 NumRootDescEntries; // F03 # entries in RootDescTable
436 436
437 __u8 RomSize; // F04 Size of ROM/E2PROM in K 437 __u8 RomSize; // F04 Size of ROM/E2PROM in K
438 __u8 RamSize; // F05 Size of external RAM in K 438 __u8 RamSize; // F05 Size of external RAM in K
439 __u8 CpuRev; // F06 CPU revision level (chg only if s/w visible) 439 __u8 CpuRev; // F06 CPU revision level (chg only if s/w visible)
440 __u8 BoardRev; // F07 PCB revision level (chg only if s/w visible) 440 __u8 BoardRev; // F07 PCB revision level (chg only if s/w visible)
441 441
442 __u8 NumPorts; // F08 Number of ports 442 __u8 NumPorts; // F08 Number of ports
443 __u8 DescDate[3]; // F09 MM/DD/YY when descriptor template was compiler, 443 __u8 DescDate[3]; // F09 MM/DD/YY when descriptor template was compiler,
444 // so host can track changes to USB-only descriptors. 444 // so host can track changes to USB-only descriptors.
445 445
446 __u8 SerNumLength; // F0C USB string descriptor len 446 __u8 SerNumLength; // F0C USB string descriptor len
447 __u8 SerNumDescType; // F0D USB descriptor type (=STRING type) 447 __u8 SerNumDescType; // F0D USB descriptor type (=STRING type)
448 __le16 SerialNumber[MAX_SERIALNUMBER_LEN]; // F0E "01-01-000100" Unicode Serial Number 448 __le16 SerialNumber[MAX_SERIALNUMBER_LEN]; // F0E "01-01-000100" Unicode Serial Number
449 449
450 __u8 AssemblyNumLength; // F26 USB string descriptor len 450 __u8 AssemblyNumLength; // F26 USB string descriptor len
451 __u8 AssemblyNumDescType; // F27 USB descriptor type (=STRING type) 451 __u8 AssemblyNumDescType; // F27 USB descriptor type (=STRING type)
452 __le16 AssemblyNumber[MAX_ASSEMBLYNUMBER_LEN]; // F28 "350-1000-01-A " assembly number 452 __le16 AssemblyNumber[MAX_ASSEMBLYNUMBER_LEN]; // F28 "350-1000-01-A " assembly number
453 453
454 __u8 OemAssyNumLength; // F44 USB string descriptor len 454 __u8 OemAssyNumLength; // F44 USB string descriptor len
455 __u8 OemAssyNumDescType; // F45 USB descriptor type (=STRING type) 455 __u8 OemAssyNumDescType; // F45 USB descriptor type (=STRING type)
456 __le16 OemAssyNumber[MAX_ASSEMBLYNUMBER_LEN]; // F46 "xxxxxxxxxxxxxx" OEM assembly number 456 __le16 OemAssyNumber[MAX_ASSEMBLYNUMBER_LEN]; // F46 "xxxxxxxxxxxxxx" OEM assembly number
457 457
458 __u8 ManufDateLength; // F62 USB string descriptor len 458 __u8 ManufDateLength; // F62 USB string descriptor len
459 __u8 ManufDateDescType; // F63 USB descriptor type (=STRING type) 459 __u8 ManufDateDescType; // F63 USB descriptor type (=STRING type)
460 __le16 ManufDate[6]; // F64 "MMDDYY" manufacturing date 460 __le16 ManufDate[6]; // F64 "MMDDYY" manufacturing date
461 461
462 __u8 Reserved3[0x4D]; // F70 -- unused, set to 0 -- 462 __u8 Reserved3[0x4D]; // F70 -- unused, set to 0 --
463 463
464 __u8 UartType; // FBD Uart Type 464 __u8 UartType; // FBD Uart Type
465 __u8 IonPid; // FBE Product ID, == LSB of USB DevDesc.PID 465 __u8 IonPid; // FBE Product ID, == LSB of USB DevDesc.PID
466 // (Note: Edgeport/4s before 11/98 will have 466 // (Note: Edgeport/4s before 11/98 will have
467 // 00 here instead of 01) 467 // 00 here instead of 01)
468 __u8 IonConfig; // FBF Config byte for ION manufacturing use 468 __u8 IonConfig; // FBF Config byte for ION manufacturing use
469 // FBF end of structure, total len = 3C0h 469 // FBF end of structure, total len = 3C0h
470 470
471 }; 471 };
472 472
473 473
474 #define MANUF_DESC_VER_1 1 // Original definition of MANUF_DESC 474 #define MANUF_DESC_VER_1 1 // Original definition of MANUF_DESC
475 #define MANUF_DESC_VER_2 2 // Ver 2, starts at xC00h len 3C0h 475 #define MANUF_DESC_VER_2 2 // Ver 2, starts at xC00h len 3C0h
476 476
477 477
478 // Uart Types 478 // Uart Types
479 // Note: Since this field was added only recently, all Edgeport/4 units 479 // Note: Since this field was added only recently, all Edgeport/4 units
480 // shipped before 11/98 will have 00 in this field. Therefore, 480 // shipped before 11/98 will have 00 in this field. Therefore,
481 // both 00 and 01 values mean '654. 481 // both 00 and 01 values mean '654.
482 #define MANUF_UART_EXAR_654_EARLY 0 // Exar 16C654 in Edgeport/4s before 11/98 482 #define MANUF_UART_EXAR_654_EARLY 0 // Exar 16C654 in Edgeport/4s before 11/98
483 #define MANUF_UART_EXAR_654 1 // Exar 16C654 483 #define MANUF_UART_EXAR_654 1 // Exar 16C654
484 #define MANUF_UART_EXAR_2852 2 // Exar 16C2852 484 #define MANUF_UART_EXAR_2852 2 // Exar 16C2852
485 485
486 // 486 //
487 // Note: The CpuRev and BoardRev values do not conform to manufacturing 487 // Note: The CpuRev and BoardRev values do not conform to manufacturing
488 // revisions; they are to be incremented only when the CPU or hardware 488 // revisions; they are to be incremented only when the CPU or hardware
489 // changes in a software-visible way, such that the 930 software or 489 // changes in a software-visible way, such that the 930 software or
490 // the host driver needs to handle the hardware differently. 490 // the host driver needs to handle the hardware differently.
491 // 491 //
492 492
493 // Values of bottom 5 bits of CpuRev & BoardRev for 493 // Values of bottom 5 bits of CpuRev & BoardRev for
494 // Implementation 0 (ie, 930-based) 494 // Implementation 0 (ie, 930-based)
495 #define MANUF_CPU_REV_AD4 1 // 930 AD4, with EP1 Rx bug (needs RXSPM) 495 #define MANUF_CPU_REV_AD4 1 // 930 AD4, with EP1 Rx bug (needs RXSPM)
496 #define MANUF_CPU_REV_AD5 2 // 930 AD5, with above bug (supposedly) fixed 496 #define MANUF_CPU_REV_AD5 2 // 930 AD5, with above bug (supposedly) fixed
497 #define MANUF_CPU_80251 0x20 // Intel 80251 497 #define MANUF_CPU_80251 0x20 // Intel 80251
498 498
499 499
500 #define MANUF_BOARD_REV_A 1 // Original version, == Manuf Rev A 500 #define MANUF_BOARD_REV_A 1 // Original version, == Manuf Rev A
501 #define MANUF_BOARD_REV_B 2 // Manuf Rev B, wakeup interrupt works 501 #define MANUF_BOARD_REV_B 2 // Manuf Rev B, wakeup interrupt works
502 #define MANUF_BOARD_REV_C 3 // Manuf Rev C, 2/4 ports, rs232/rs422 502 #define MANUF_BOARD_REV_C 3 // Manuf Rev C, 2/4 ports, rs232/rs422
503 #define MANUF_BOARD_REV_GENERATION_2 0x20 // Second generaiton edgeport 503 #define MANUF_BOARD_REV_GENERATION_2 0x20 // Second generaiton edgeport
504 504
505 505
506 // Values of bottom 5 bits of CpuRev & BoardRev for 506 // Values of bottom 5 bits of CpuRev & BoardRev for
507 // Implementation 1 (ie, 251+Netchip-based) 507 // Implementation 1 (ie, 251+Netchip-based)
508 #define MANUF_CPU_REV_1 1 // C251TB Rev 1 (Need actual Intel rev here) 508 #define MANUF_CPU_REV_1 1 // C251TB Rev 1 (Need actual Intel rev here)
509 509
510 #define MANUF_BOARD_REV_A 1 // First rev of 251+Netchip design 510 #define MANUF_BOARD_REV_A 1 // First rev of 251+Netchip design
511 511
512 #define MANUF_SERNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->SerialNumber) 512 #define MANUF_SERNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->SerialNumber)
513 #define MANUF_ASSYNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->AssemblyNumber) 513 #define MANUF_ASSYNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->AssemblyNumber)
514 #define MANUF_OEMASSYNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->OemAssyNumber) 514 #define MANUF_OEMASSYNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->OemAssyNumber)
515 #define MANUF_MANUFDATE_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->ManufDate) 515 #define MANUF_MANUFDATE_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->ManufDate)
516 516
517 #define MANUF_ION_CONFIG_DIAG_NO_LOOP 0x20 // As below but no ext loopback test 517 #define MANUF_ION_CONFIG_DIAG_NO_LOOP 0x20 // As below but no ext loopback test
518 #define MANUF_ION_CONFIG_DIAG 0x40 // 930 based device: 1=Run h/w diags, 0=norm 518 #define MANUF_ION_CONFIG_DIAG 0x40 // 930 based device: 1=Run h/w diags, 0=norm
519 // TIUMP Device : 1=IONSERIAL needs to run Final Test 519 // TIUMP Device : 1=IONSERIAL needs to run Final Test
520 #define MANUF_ION_CONFIG_MASTER 0x80 // 930 based device: 1=Master mode, 0=Normal 520 #define MANUF_ION_CONFIG_MASTER 0x80 // 930 based device: 1=Master mode, 0=Normal
521 // TIUMP Device : 1=First device on a multi TIUMP Device 521 // TIUMP Device : 1=First device on a multi TIUMP Device
522 522
523 // 523 //
524 // This structure describes parameters for the boot code, and 524 // This structure describes parameters for the boot code, and
525 // is programmed along with new boot code. These are values 525 // is programmed along with new boot code. These are values
526 // which are specific to a given build of the boot code. It 526 // which are specific to a given build of the boot code. It
527 // is exactly 64 bytes long and is fixed at address FF:xFC0 527 // is exactly 64 bytes long and is fixed at address FF:xFC0
528 // - FF:xFFF. Note that the 930-mandated UCONFIG bytes are 528 // - FF:xFFF. Note that the 930-mandated UCONFIG bytes are
529 // included in this structure. 529 // included in this structure.
530 // 530 //
531 struct edge_boot_descriptor { 531 struct edge_boot_descriptor {
532 __u8 Length; // C0 Desc length, per USB (= 40h) 532 __u8 Length; // C0 Desc length, per USB (= 40h)
533 __u8 DescType; // C1 Desc type, per USB (= DEVICE type) 533 __u8 DescType; // C1 Desc type, per USB (= DEVICE type)
534 __u8 DescVer; // C2 Desc version/format 534 __u8 DescVer; // C2 Desc version/format
535 __u8 Reserved1; // C3 -- unused, set to 0 -- 535 __u8 Reserved1; // C3 -- unused, set to 0 --
536 536
537 __le16 BootCodeLength; // C4 Boot code goes from FF:0000 to FF:(len-1) 537 __le16 BootCodeLength; // C4 Boot code goes from FF:0000 to FF:(len-1)
538 // (LE format) 538 // (LE format)
539 539
540 __u8 MajorVersion; // C6 Firmware version: xx. 540 __u8 MajorVersion; // C6 Firmware version: xx.
541 __u8 MinorVersion; // C7 yy. 541 __u8 MinorVersion; // C7 yy.
542 __le16 BuildNumber; // C8 zzzz (LE format) 542 __le16 BuildNumber; // C8 zzzz (LE format)
543 543
544 __u16 EnumRootDescTable; // CA Root of ROM-based descriptor table 544 __u16 EnumRootDescTable; // CA Root of ROM-based descriptor table
545 __u8 NumDescTypes; // CC Number of supported descriptor types 545 __u8 NumDescTypes; // CC Number of supported descriptor types
546 546
547 __u8 Reserved4; // CD Fix Compiler Packing 547 __u8 Reserved4; // CD Fix Compiler Packing
548 548
549 __le16 Capabilities; // CE-CF Capabilities flags (LE format) 549 __le16 Capabilities; // CE-CF Capabilities flags (LE format)
550 __u8 Reserved2[0x28]; // D0 -- unused, set to 0 -- 550 __u8 Reserved2[0x28]; // D0 -- unused, set to 0 --
551 __u8 UConfig0; // F8 930-defined CPU configuration byte 0 551 __u8 UConfig0; // F8 930-defined CPU configuration byte 0
552 __u8 UConfig1; // F9 930-defined CPU configuration byte 1 552 __u8 UConfig1; // F9 930-defined CPU configuration byte 1
553 __u8 Reserved3[6]; // FA -- unused, set to 0 -- 553 __u8 Reserved3[6]; // FA -- unused, set to 0 --
554 // FF end of structure, total len = 80 554 // FF end of structure, total len = 80
555 }; 555 };
556 556
557 557
558 #define BOOT_DESC_VER_1 1 // Original definition of BOOT_PARAMS 558 #define BOOT_DESC_VER_1 1 // Original definition of BOOT_PARAMS
559 #define BOOT_DESC_VER_2 2 // 2nd definition, descriptors not included in boot 559 #define BOOT_DESC_VER_2 2 // 2nd definition, descriptors not included in boot
560 560
561 561
562 // Capabilities flags 562 // Capabilities flags
563 563
564 #define BOOT_CAP_RESET_CMD 0x0001 // If set, boot correctly supports ION_RESET_DEVICE 564 #define BOOT_CAP_RESET_CMD 0x0001 // If set, boot correctly supports ION_RESET_DEVICE
565 565
566 566
567 /************************************************************************ 567 /************************************************************************
568 T I U M P D E F I N I T I O N S 568 T I U M P D E F I N I T I O N S
569 ***********************************************************************/ 569 ***********************************************************************/
570 570
571 // Chip definitions in I2C 571 // Chip definitions in I2C
572 #define UMP5152 0x52 572 #define UMP5152 0x52
573 #define UMP3410 0x10 573 #define UMP3410 0x10
574 574
575 575
576 //************************************************************************ 576 //************************************************************************
577 // TI I2C Format Definitions 577 // TI I2C Format Definitions
578 //************************************************************************ 578 //************************************************************************
579 #define I2C_DESC_TYPE_INFO_BASIC 0x01 579 #define I2C_DESC_TYPE_INFO_BASIC 0x01
580 #define I2C_DESC_TYPE_FIRMWARE_BASIC 0x02 580 #define I2C_DESC_TYPE_FIRMWARE_BASIC 0x02
581 #define I2C_DESC_TYPE_DEVICE 0x03 581 #define I2C_DESC_TYPE_DEVICE 0x03
582 #define I2C_DESC_TYPE_CONFIG 0x04 582 #define I2C_DESC_TYPE_CONFIG 0x04
583 #define I2C_DESC_TYPE_STRING 0x05 583 #define I2C_DESC_TYPE_STRING 0x05
584 #define I2C_DESC_TYPE_FIRMWARE_AUTO 0x07 // for 3410 download 584 #define I2C_DESC_TYPE_FIRMWARE_AUTO 0x07 // for 3410 download
585 #define I2C_DESC_TYPE_CONFIG_KLUDGE 0x14 // for 3410 585 #define I2C_DESC_TYPE_CONFIG_KLUDGE 0x14 // for 3410
586 #define I2C_DESC_TYPE_WATCHPORT_VERSION 0x15 // firmware version number for watchport 586 #define I2C_DESC_TYPE_WATCHPORT_VERSION 0x15 // firmware version number for watchport
587 #define I2C_DESC_TYPE_WATCHPORT_CALIBRATION_DATA 0x16 // Watchport Calibration Data 587 #define I2C_DESC_TYPE_WATCHPORT_CALIBRATION_DATA 0x16 // Watchport Calibration Data
588 588
589 #define I2C_DESC_TYPE_FIRMWARE_BLANK 0xf2 589 #define I2C_DESC_TYPE_FIRMWARE_BLANK 0xf2
590 590
591 // Special section defined by ION 591 // Special section defined by ION
592 #define I2C_DESC_TYPE_ION 0 // Not defined by TI 592 #define I2C_DESC_TYPE_ION 0 // Not defined by TI
593 593
594 594
595 struct ti_i2c_desc { 595 struct ti_i2c_desc {
596 __u8 Type; // Type of descriptor 596 __u8 Type; // Type of descriptor
597 __u16 Size; // Size of data only not including header 597 __le16 Size; // Size of data only not including header
598 __u8 CheckSum; // Checksum (8 bit sum of data only) 598 __u8 CheckSum; // Checksum (8 bit sum of data only)
599 __u8 Data[0]; // Data starts here 599 __u8 Data[0]; // Data starts here
600 } __attribute__((packed)); 600 } __attribute__((packed));
601 601
602 // for 5152 devices only (type 2 record) 602 // for 5152 devices only (type 2 record)
603 // for 3410 the version is stored in the WATCHPORT_FIRMWARE_VERSION descriptor 603 // for 3410 the version is stored in the WATCHPORT_FIRMWARE_VERSION descriptor
604 struct ti_i2c_firmware_rec { 604 struct ti_i2c_firmware_rec {
605 __u8 Ver_Major; // Firmware Major version number 605 __u8 Ver_Major; // Firmware Major version number
606 __u8 Ver_Minor; // Firmware Minor version number 606 __u8 Ver_Minor; // Firmware Minor version number
607 __u8 Data[0]; // Download starts here 607 __u8 Data[0]; // Download starts here
608 } __attribute__((packed)); 608 } __attribute__((packed));
609 609
610 610
611 struct watchport_firmware_version { 611 struct watchport_firmware_version {
612 // Added 2 bytes for version number 612 // Added 2 bytes for version number
613 __u8 Version_Major; // Download Version (for Watchport) 613 __u8 Version_Major; // Download Version (for Watchport)
614 __u8 Version_Minor; 614 __u8 Version_Minor;
615 } __attribute__((packed)); 615 } __attribute__((packed));
616 616
617 617
618 // Structure of header of download image in fw_down.h 618 // Structure of header of download image in fw_down.h
619 struct ti_i2c_image_header { 619 struct ti_i2c_image_header {
620 __le16 Length; 620 __le16 Length;
621 __u8 CheckSum; 621 __u8 CheckSum;
622 } __attribute__((packed)); 622 } __attribute__((packed));
623 623
624 struct ti_basic_descriptor { 624 struct ti_basic_descriptor {
625 __u8 Power; // Self powered 625 __u8 Power; // Self powered
626 // bit 7: 1 - power switching supported 626 // bit 7: 1 - power switching supported
627 // 0 - power switching not supported 627 // 0 - power switching not supported
628 // 628 //
629 // bit 0: 1 - self powered 629 // bit 0: 1 - self powered
630 // 0 - bus powered 630 // 0 - bus powered
631 // 631 //
632 // 632 //
633 __u16 HubVid; // VID HUB 633 __u16 HubVid; // VID HUB
634 __u16 HubPid; // PID HUB 634 __u16 HubPid; // PID HUB
635 __u16 DevPid; // PID Edgeport 635 __u16 DevPid; // PID Edgeport
636 __u8 HubTime; // Time for power on to power good 636 __u8 HubTime; // Time for power on to power good
637 __u8 HubCurrent; // HUB Current = 100ma 637 __u8 HubCurrent; // HUB Current = 100ma
638 } __attribute__((packed)); 638 } __attribute__((packed));
639 639
640 640
641 // CPU / Board Rev Definitions 641 // CPU / Board Rev Definitions
642 #define TI_CPU_REV_5052 2 // 5052 based edgeports 642 #define TI_CPU_REV_5052 2 // 5052 based edgeports
643 #define TI_CPU_REV_3410 3 // 3410 based edgeports 643 #define TI_CPU_REV_3410 3 // 3410 based edgeports
644 644
645 #define TI_BOARD_REV_TI_EP 0 // Basic ti based edgeport 645 #define TI_BOARD_REV_TI_EP 0 // Basic ti based edgeport
646 #define TI_BOARD_REV_COMPACT 1 // Compact board 646 #define TI_BOARD_REV_COMPACT 1 // Compact board
647 #define TI_BOARD_REV_WATCHPORT 2 // Watchport 647 #define TI_BOARD_REV_WATCHPORT 2 // Watchport
648 648
649 649
650 #define TI_GET_CPU_REVISION(x) (__u8)((((x)>>4)&0x0f)) 650 #define TI_GET_CPU_REVISION(x) (__u8)((((x)>>4)&0x0f))
651 #define TI_GET_BOARD_REVISION(x) (__u8)(((x)&0x0f)) 651 #define TI_GET_BOARD_REVISION(x) (__u8)(((x)&0x0f))
652 652
653 #define TI_I2C_SIZE_MASK 0x1f // 5 bits 653 #define TI_I2C_SIZE_MASK 0x1f // 5 bits
654 #define TI_GET_I2C_SIZE(x) ((((x) & TI_I2C_SIZE_MASK)+1)*256) 654 #define TI_GET_I2C_SIZE(x) ((((x) & TI_I2C_SIZE_MASK)+1)*256)
655 655
656 #define TI_MAX_I2C_SIZE (16 * 1024) 656 #define TI_MAX_I2C_SIZE (16 * 1024)
657 657
658 #define TI_MANUF_VERSION_0 0 658 #define TI_MANUF_VERSION_0 0
659 659
660 // IonConig2 flags 660 // IonConig2 flags
661 #define TI_CONFIG2_RS232 0x01 661 #define TI_CONFIG2_RS232 0x01
662 #define TI_CONFIG2_RS422 0x02 662 #define TI_CONFIG2_RS422 0x02
663 #define TI_CONFIG2_RS485 0x04 663 #define TI_CONFIG2_RS485 0x04
664 #define TI_CONFIG2_SWITCHABLE 0x08 664 #define TI_CONFIG2_SWITCHABLE 0x08
665 665
666 #define TI_CONFIG2_WATCHPORT 0x10 666 #define TI_CONFIG2_WATCHPORT 0x10
667 667
668 668
669 struct edge_ti_manuf_descriptor { 669 struct edge_ti_manuf_descriptor {
670 __u8 IonConfig; // Config byte for ION manufacturing use 670 __u8 IonConfig; // Config byte for ION manufacturing use
671 __u8 IonConfig2; // Expansion 671 __u8 IonConfig2; // Expansion
672 __u8 Version; // Version 672 __u8 Version; // Version
673 __u8 CpuRev_BoardRev; // CPU revision level (0xF0) and Board Rev Level (0x0F) 673 __u8 CpuRev_BoardRev; // CPU revision level (0xF0) and Board Rev Level (0x0F)
674 __u8 NumPorts; // Number of ports for this UMP 674 __u8 NumPorts; // Number of ports for this UMP
675 __u8 NumVirtualPorts; // Number of Virtual ports 675 __u8 NumVirtualPorts; // Number of Virtual ports
676 __u8 HubConfig1; // Used to configure the Hub 676 __u8 HubConfig1; // Used to configure the Hub
677 __u8 HubConfig2; // Used to configure the Hub 677 __u8 HubConfig2; // Used to configure the Hub
678 __u8 TotalPorts; // Total Number of Com Ports for the entire device (All UMPs) 678 __u8 TotalPorts; // Total Number of Com Ports for the entire device (All UMPs)
679 __u8 Reserved; // Reserved 679 __u8 Reserved; // Reserved
680 } __attribute__((packed)); 680 } __attribute__((packed));
681 681
682 682
683 #endif // if !defined(_USBVEND_H) 683 #endif // if !defined(_USBVEND_H)
684 684
drivers/usb/serial/option.c
1 /* 1 /*
2 USB Driver for GSM modems 2 USB Driver for GSM modems
3 3
4 Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de> 4 Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de>
5 5
6 This driver is free software; you can redistribute it and/or modify 6 This driver is free software; you can redistribute it and/or modify
7 it under the terms of Version 2 of the GNU General Public License as 7 it under the terms of Version 2 of the GNU General Public License as
8 published by the Free Software Foundation. 8 published by the Free Software Foundation.
9 9
10 Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org> 10 Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org>
11 11
12 History: see the git log. 12 History: see the git log.
13 13
14 Work sponsored by: Sigos GmbH, Germany <info@sigos.de> 14 Work sponsored by: Sigos GmbH, Germany <info@sigos.de>
15 15
16 This driver exists because the "normal" serial driver doesn't work too well 16 This driver exists because the "normal" serial driver doesn't work too well
17 with GSM modems. Issues: 17 with GSM modems. Issues:
18 - data loss -- one single Receive URB is not nearly enough 18 - data loss -- one single Receive URB is not nearly enough
19 - nonstandard flow (Option devices) control 19 - nonstandard flow (Option devices) control
20 - controlling the baud rate doesn't make sense 20 - controlling the baud rate doesn't make sense
21 21
22 This driver is named "option" because the most common device it's 22 This driver is named "option" because the most common device it's
23 used for is a PC-Card (with an internal OHCI-USB interface, behind 23 used for is a PC-Card (with an internal OHCI-USB interface, behind
24 which the GSM interface sits), made by Option Inc. 24 which the GSM interface sits), made by Option Inc.
25 25
26 Some of the "one port" devices actually exhibit multiple USB instances 26 Some of the "one port" devices actually exhibit multiple USB instances
27 on the USB bus. This is not a bug, these ports are used for different 27 on the USB bus. This is not a bug, these ports are used for different
28 device features. 28 device features.
29 */ 29 */
30 30
31 #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 31 #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
32 #define DRIVER_DESC "USB Driver for GSM modems" 32 #define DRIVER_DESC "USB Driver for GSM modems"
33 33
34 #include <linux/kernel.h> 34 #include <linux/kernel.h>
35 #include <linux/jiffies.h> 35 #include <linux/jiffies.h>
36 #include <linux/errno.h> 36 #include <linux/errno.h>
37 #include <linux/tty.h> 37 #include <linux/tty.h>
38 #include <linux/tty_flip.h> 38 #include <linux/tty_flip.h>
39 #include <linux/slab.h> 39 #include <linux/slab.h>
40 #include <linux/module.h> 40 #include <linux/module.h>
41 #include <linux/bitops.h> 41 #include <linux/bitops.h>
42 #include <linux/usb.h> 42 #include <linux/usb.h>
43 #include <linux/usb/serial.h> 43 #include <linux/usb/serial.h>
44 #include "usb-wwan.h" 44 #include "usb-wwan.h"
45 45
46 /* Function prototypes */ 46 /* Function prototypes */
47 static int option_probe(struct usb_serial *serial, 47 static int option_probe(struct usb_serial *serial,
48 const struct usb_device_id *id); 48 const struct usb_device_id *id);
49 static int option_attach(struct usb_serial *serial); 49 static int option_attach(struct usb_serial *serial);
50 static void option_release(struct usb_serial *serial); 50 static void option_release(struct usb_serial *serial);
51 static int option_send_setup(struct usb_serial_port *port); 51 static int option_send_setup(struct usb_serial_port *port);
52 static void option_instat_callback(struct urb *urb); 52 static void option_instat_callback(struct urb *urb);
53 53
54 /* Vendor and product IDs */ 54 /* Vendor and product IDs */
55 #define OPTION_VENDOR_ID 0x0AF0 55 #define OPTION_VENDOR_ID 0x0AF0
56 #define OPTION_PRODUCT_COLT 0x5000 56 #define OPTION_PRODUCT_COLT 0x5000
57 #define OPTION_PRODUCT_RICOLA 0x6000 57 #define OPTION_PRODUCT_RICOLA 0x6000
58 #define OPTION_PRODUCT_RICOLA_LIGHT 0x6100 58 #define OPTION_PRODUCT_RICOLA_LIGHT 0x6100
59 #define OPTION_PRODUCT_RICOLA_QUAD 0x6200 59 #define OPTION_PRODUCT_RICOLA_QUAD 0x6200
60 #define OPTION_PRODUCT_RICOLA_QUAD_LIGHT 0x6300 60 #define OPTION_PRODUCT_RICOLA_QUAD_LIGHT 0x6300
61 #define OPTION_PRODUCT_RICOLA_NDIS 0x6050 61 #define OPTION_PRODUCT_RICOLA_NDIS 0x6050
62 #define OPTION_PRODUCT_RICOLA_NDIS_LIGHT 0x6150 62 #define OPTION_PRODUCT_RICOLA_NDIS_LIGHT 0x6150
63 #define OPTION_PRODUCT_RICOLA_NDIS_QUAD 0x6250 63 #define OPTION_PRODUCT_RICOLA_NDIS_QUAD 0x6250
64 #define OPTION_PRODUCT_RICOLA_NDIS_QUAD_LIGHT 0x6350 64 #define OPTION_PRODUCT_RICOLA_NDIS_QUAD_LIGHT 0x6350
65 #define OPTION_PRODUCT_COBRA 0x6500 65 #define OPTION_PRODUCT_COBRA 0x6500
66 #define OPTION_PRODUCT_COBRA_BUS 0x6501 66 #define OPTION_PRODUCT_COBRA_BUS 0x6501
67 #define OPTION_PRODUCT_VIPER 0x6600 67 #define OPTION_PRODUCT_VIPER 0x6600
68 #define OPTION_PRODUCT_VIPER_BUS 0x6601 68 #define OPTION_PRODUCT_VIPER_BUS 0x6601
69 #define OPTION_PRODUCT_GT_MAX_READY 0x6701 69 #define OPTION_PRODUCT_GT_MAX_READY 0x6701
70 #define OPTION_PRODUCT_FUJI_MODEM_LIGHT 0x6721 70 #define OPTION_PRODUCT_FUJI_MODEM_LIGHT 0x6721
71 #define OPTION_PRODUCT_FUJI_MODEM_GT 0x6741 71 #define OPTION_PRODUCT_FUJI_MODEM_GT 0x6741
72 #define OPTION_PRODUCT_FUJI_MODEM_EX 0x6761 72 #define OPTION_PRODUCT_FUJI_MODEM_EX 0x6761
73 #define OPTION_PRODUCT_KOI_MODEM 0x6800 73 #define OPTION_PRODUCT_KOI_MODEM 0x6800
74 #define OPTION_PRODUCT_SCORPION_MODEM 0x6901 74 #define OPTION_PRODUCT_SCORPION_MODEM 0x6901
75 #define OPTION_PRODUCT_ETNA_MODEM 0x7001 75 #define OPTION_PRODUCT_ETNA_MODEM 0x7001
76 #define OPTION_PRODUCT_ETNA_MODEM_LITE 0x7021 76 #define OPTION_PRODUCT_ETNA_MODEM_LITE 0x7021
77 #define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041 77 #define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041
78 #define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061 78 #define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061
79 #define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100 79 #define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100
80 #define OPTION_PRODUCT_GTM380_MODEM 0x7201 80 #define OPTION_PRODUCT_GTM380_MODEM 0x7201
81 81
82 #define HUAWEI_VENDOR_ID 0x12D1 82 #define HUAWEI_VENDOR_ID 0x12D1
83 #define HUAWEI_PRODUCT_E173 0x140C 83 #define HUAWEI_PRODUCT_E173 0x140C
84 #define HUAWEI_PRODUCT_E1750 0x1406 84 #define HUAWEI_PRODUCT_E1750 0x1406
85 #define HUAWEI_PRODUCT_K4505 0x1464 85 #define HUAWEI_PRODUCT_K4505 0x1464
86 #define HUAWEI_PRODUCT_K3765 0x1465 86 #define HUAWEI_PRODUCT_K3765 0x1465
87 #define HUAWEI_PRODUCT_K4605 0x14C6 87 #define HUAWEI_PRODUCT_K4605 0x14C6
88 #define HUAWEI_PRODUCT_E173S6 0x1C07 88 #define HUAWEI_PRODUCT_E173S6 0x1C07
89 89
90 #define QUANTA_VENDOR_ID 0x0408 90 #define QUANTA_VENDOR_ID 0x0408
91 #define QUANTA_PRODUCT_Q101 0xEA02 91 #define QUANTA_PRODUCT_Q101 0xEA02
92 #define QUANTA_PRODUCT_Q111 0xEA03 92 #define QUANTA_PRODUCT_Q111 0xEA03
93 #define QUANTA_PRODUCT_GLX 0xEA04 93 #define QUANTA_PRODUCT_GLX 0xEA04
94 #define QUANTA_PRODUCT_GKE 0xEA05 94 #define QUANTA_PRODUCT_GKE 0xEA05
95 #define QUANTA_PRODUCT_GLE 0xEA06 95 #define QUANTA_PRODUCT_GLE 0xEA06
96 96
97 #define NOVATELWIRELESS_VENDOR_ID 0x1410 97 #define NOVATELWIRELESS_VENDOR_ID 0x1410
98 98
99 /* YISO PRODUCTS */ 99 /* YISO PRODUCTS */
100 100
101 #define YISO_VENDOR_ID 0x0EAB 101 #define YISO_VENDOR_ID 0x0EAB
102 #define YISO_PRODUCT_U893 0xC893 102 #define YISO_PRODUCT_U893 0xC893
103 103
104 /* 104 /*
105 * NOVATEL WIRELESS PRODUCTS 105 * NOVATEL WIRELESS PRODUCTS
106 * 106 *
107 * Note from Novatel Wireless: 107 * Note from Novatel Wireless:
108 * If your Novatel modem does not work on linux, don't 108 * If your Novatel modem does not work on linux, don't
109 * change the option module, but check our website. If 109 * change the option module, but check our website. If
110 * that does not help, contact ddeschepper@nvtl.com 110 * that does not help, contact ddeschepper@nvtl.com
111 */ 111 */
112 /* MERLIN EVDO PRODUCTS */ 112 /* MERLIN EVDO PRODUCTS */
113 #define NOVATELWIRELESS_PRODUCT_V640 0x1100 113 #define NOVATELWIRELESS_PRODUCT_V640 0x1100
114 #define NOVATELWIRELESS_PRODUCT_V620 0x1110 114 #define NOVATELWIRELESS_PRODUCT_V620 0x1110
115 #define NOVATELWIRELESS_PRODUCT_V740 0x1120 115 #define NOVATELWIRELESS_PRODUCT_V740 0x1120
116 #define NOVATELWIRELESS_PRODUCT_V720 0x1130 116 #define NOVATELWIRELESS_PRODUCT_V720 0x1130
117 117
118 /* MERLIN HSDPA/HSPA PRODUCTS */ 118 /* MERLIN HSDPA/HSPA PRODUCTS */
119 #define NOVATELWIRELESS_PRODUCT_U730 0x1400 119 #define NOVATELWIRELESS_PRODUCT_U730 0x1400
120 #define NOVATELWIRELESS_PRODUCT_U740 0x1410 120 #define NOVATELWIRELESS_PRODUCT_U740 0x1410
121 #define NOVATELWIRELESS_PRODUCT_U870 0x1420 121 #define NOVATELWIRELESS_PRODUCT_U870 0x1420
122 #define NOVATELWIRELESS_PRODUCT_XU870 0x1430 122 #define NOVATELWIRELESS_PRODUCT_XU870 0x1430
123 #define NOVATELWIRELESS_PRODUCT_X950D 0x1450 123 #define NOVATELWIRELESS_PRODUCT_X950D 0x1450
124 124
125 /* EXPEDITE PRODUCTS */ 125 /* EXPEDITE PRODUCTS */
126 #define NOVATELWIRELESS_PRODUCT_EV620 0x2100 126 #define NOVATELWIRELESS_PRODUCT_EV620 0x2100
127 #define NOVATELWIRELESS_PRODUCT_ES720 0x2110 127 #define NOVATELWIRELESS_PRODUCT_ES720 0x2110
128 #define NOVATELWIRELESS_PRODUCT_E725 0x2120 128 #define NOVATELWIRELESS_PRODUCT_E725 0x2120
129 #define NOVATELWIRELESS_PRODUCT_ES620 0x2130 129 #define NOVATELWIRELESS_PRODUCT_ES620 0x2130
130 #define NOVATELWIRELESS_PRODUCT_EU730 0x2400 130 #define NOVATELWIRELESS_PRODUCT_EU730 0x2400
131 #define NOVATELWIRELESS_PRODUCT_EU740 0x2410 131 #define NOVATELWIRELESS_PRODUCT_EU740 0x2410
132 #define NOVATELWIRELESS_PRODUCT_EU870D 0x2420 132 #define NOVATELWIRELESS_PRODUCT_EU870D 0x2420
133 /* OVATION PRODUCTS */ 133 /* OVATION PRODUCTS */
134 #define NOVATELWIRELESS_PRODUCT_MC727 0x4100 134 #define NOVATELWIRELESS_PRODUCT_MC727 0x4100
135 #define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 135 #define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
136 /* 136 /*
137 * Note from Novatel Wireless: 137 * Note from Novatel Wireless:
138 * All PID in the 5xxx range are currently reserved for 138 * All PID in the 5xxx range are currently reserved for
139 * auto-install CDROMs, and should not be added to this 139 * auto-install CDROMs, and should not be added to this
140 * module. 140 * module.
141 * 141 *
142 * #define NOVATELWIRELESS_PRODUCT_U727 0x5010 142 * #define NOVATELWIRELESS_PRODUCT_U727 0x5010
143 * #define NOVATELWIRELESS_PRODUCT_MC727_NEW 0x5100 143 * #define NOVATELWIRELESS_PRODUCT_MC727_NEW 0x5100
144 */ 144 */
145 #define NOVATELWIRELESS_PRODUCT_OVMC760 0x6002 145 #define NOVATELWIRELESS_PRODUCT_OVMC760 0x6002
146 #define NOVATELWIRELESS_PRODUCT_MC780 0x6010 146 #define NOVATELWIRELESS_PRODUCT_MC780 0x6010
147 #define NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED 0x6000 147 #define NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED 0x6000
148 #define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0x6001 148 #define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0x6001
149 #define NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED 0x7000 149 #define NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED 0x7000
150 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED 0x7001 150 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED 0x7001
151 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED3 0x7003 151 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED3 0x7003
152 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED4 0x7004 152 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED4 0x7004
153 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED5 0x7005 153 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED5 0x7005
154 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED6 0x7006 154 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED6 0x7006
155 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED7 0x7007 155 #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED7 0x7007
156 #define NOVATELWIRELESS_PRODUCT_MC996D 0x7030 156 #define NOVATELWIRELESS_PRODUCT_MC996D 0x7030
157 #define NOVATELWIRELESS_PRODUCT_MF3470 0x7041 157 #define NOVATELWIRELESS_PRODUCT_MF3470 0x7041
158 #define NOVATELWIRELESS_PRODUCT_MC547 0x7042 158 #define NOVATELWIRELESS_PRODUCT_MC547 0x7042
159 #define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED 0x8000 159 #define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED 0x8000
160 #define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0x8001 160 #define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0x8001
161 #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0x9000 161 #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0x9000
162 #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0x9001 162 #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0x9001
163 #define NOVATELWIRELESS_PRODUCT_E362 0x9010 163 #define NOVATELWIRELESS_PRODUCT_E362 0x9010
164 #define NOVATELWIRELESS_PRODUCT_E371 0x9011
164 #define NOVATELWIRELESS_PRODUCT_G2 0xA010 165 #define NOVATELWIRELESS_PRODUCT_G2 0xA010
165 #define NOVATELWIRELESS_PRODUCT_MC551 0xB001 166 #define NOVATELWIRELESS_PRODUCT_MC551 0xB001
166 167
167 /* AMOI PRODUCTS */ 168 /* AMOI PRODUCTS */
168 #define AMOI_VENDOR_ID 0x1614 169 #define AMOI_VENDOR_ID 0x1614
169 #define AMOI_PRODUCT_H01 0x0800 170 #define AMOI_PRODUCT_H01 0x0800
170 #define AMOI_PRODUCT_H01A 0x7002 171 #define AMOI_PRODUCT_H01A 0x7002
171 #define AMOI_PRODUCT_H02 0x0802 172 #define AMOI_PRODUCT_H02 0x0802
172 #define AMOI_PRODUCT_SKYPEPHONE_S2 0x0407 173 #define AMOI_PRODUCT_SKYPEPHONE_S2 0x0407
173 174
174 #define DELL_VENDOR_ID 0x413C 175 #define DELL_VENDOR_ID 0x413C
175 176
176 /* Dell modems */ 177 /* Dell modems */
177 #define DELL_PRODUCT_5700_MINICARD 0x8114 178 #define DELL_PRODUCT_5700_MINICARD 0x8114
178 #define DELL_PRODUCT_5500_MINICARD 0x8115 179 #define DELL_PRODUCT_5500_MINICARD 0x8115
179 #define DELL_PRODUCT_5505_MINICARD 0x8116 180 #define DELL_PRODUCT_5505_MINICARD 0x8116
180 #define DELL_PRODUCT_5700_EXPRESSCARD 0x8117 181 #define DELL_PRODUCT_5700_EXPRESSCARD 0x8117
181 #define DELL_PRODUCT_5510_EXPRESSCARD 0x8118 182 #define DELL_PRODUCT_5510_EXPRESSCARD 0x8118
182 183
183 #define DELL_PRODUCT_5700_MINICARD_SPRINT 0x8128 184 #define DELL_PRODUCT_5700_MINICARD_SPRINT 0x8128
184 #define DELL_PRODUCT_5700_MINICARD_TELUS 0x8129 185 #define DELL_PRODUCT_5700_MINICARD_TELUS 0x8129
185 186
186 #define DELL_PRODUCT_5720_MINICARD_VZW 0x8133 187 #define DELL_PRODUCT_5720_MINICARD_VZW 0x8133
187 #define DELL_PRODUCT_5720_MINICARD_SPRINT 0x8134 188 #define DELL_PRODUCT_5720_MINICARD_SPRINT 0x8134
188 #define DELL_PRODUCT_5720_MINICARD_TELUS 0x8135 189 #define DELL_PRODUCT_5720_MINICARD_TELUS 0x8135
189 #define DELL_PRODUCT_5520_MINICARD_CINGULAR 0x8136 190 #define DELL_PRODUCT_5520_MINICARD_CINGULAR 0x8136
190 #define DELL_PRODUCT_5520_MINICARD_GENERIC_L 0x8137 191 #define DELL_PRODUCT_5520_MINICARD_GENERIC_L 0x8137
191 #define DELL_PRODUCT_5520_MINICARD_GENERIC_I 0x8138 192 #define DELL_PRODUCT_5520_MINICARD_GENERIC_I 0x8138
192 193
193 #define DELL_PRODUCT_5730_MINICARD_SPRINT 0x8180 194 #define DELL_PRODUCT_5730_MINICARD_SPRINT 0x8180
194 #define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181 195 #define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181
195 #define DELL_PRODUCT_5730_MINICARD_VZW 0x8182 196 #define DELL_PRODUCT_5730_MINICARD_VZW 0x8182
196 197
197 #define DELL_PRODUCT_5800_MINICARD_VZW 0x8195 /* Novatel E362 */ 198 #define DELL_PRODUCT_5800_MINICARD_VZW 0x8195 /* Novatel E362 */
198 #define DELL_PRODUCT_5800_V2_MINICARD_VZW 0x8196 /* Novatel E362 */ 199 #define DELL_PRODUCT_5800_V2_MINICARD_VZW 0x8196 /* Novatel E362 */
199 #define DELL_PRODUCT_5804_MINICARD_ATT 0x819b /* Novatel E371 */ 200 #define DELL_PRODUCT_5804_MINICARD_ATT 0x819b /* Novatel E371 */
200 201
201 #define KYOCERA_VENDOR_ID 0x0c88 202 #define KYOCERA_VENDOR_ID 0x0c88
202 #define KYOCERA_PRODUCT_KPC650 0x17da 203 #define KYOCERA_PRODUCT_KPC650 0x17da
203 #define KYOCERA_PRODUCT_KPC680 0x180a 204 #define KYOCERA_PRODUCT_KPC680 0x180a
204 205
205 #define ANYDATA_VENDOR_ID 0x16d5 206 #define ANYDATA_VENDOR_ID 0x16d5
206 #define ANYDATA_PRODUCT_ADU_620UW 0x6202 207 #define ANYDATA_PRODUCT_ADU_620UW 0x6202
207 #define ANYDATA_PRODUCT_ADU_E100A 0x6501 208 #define ANYDATA_PRODUCT_ADU_E100A 0x6501
208 #define ANYDATA_PRODUCT_ADU_500A 0x6502 209 #define ANYDATA_PRODUCT_ADU_500A 0x6502
209 210
210 #define AXESSTEL_VENDOR_ID 0x1726 211 #define AXESSTEL_VENDOR_ID 0x1726
211 #define AXESSTEL_PRODUCT_MV110H 0x1000 212 #define AXESSTEL_PRODUCT_MV110H 0x1000
212 213
213 #define BANDRICH_VENDOR_ID 0x1A8D 214 #define BANDRICH_VENDOR_ID 0x1A8D
214 #define BANDRICH_PRODUCT_C100_1 0x1002 215 #define BANDRICH_PRODUCT_C100_1 0x1002
215 #define BANDRICH_PRODUCT_C100_2 0x1003 216 #define BANDRICH_PRODUCT_C100_2 0x1003
216 #define BANDRICH_PRODUCT_1004 0x1004 217 #define BANDRICH_PRODUCT_1004 0x1004
217 #define BANDRICH_PRODUCT_1005 0x1005 218 #define BANDRICH_PRODUCT_1005 0x1005
218 #define BANDRICH_PRODUCT_1006 0x1006 219 #define BANDRICH_PRODUCT_1006 0x1006
219 #define BANDRICH_PRODUCT_1007 0x1007 220 #define BANDRICH_PRODUCT_1007 0x1007
220 #define BANDRICH_PRODUCT_1008 0x1008 221 #define BANDRICH_PRODUCT_1008 0x1008
221 #define BANDRICH_PRODUCT_1009 0x1009 222 #define BANDRICH_PRODUCT_1009 0x1009
222 #define BANDRICH_PRODUCT_100A 0x100a 223 #define BANDRICH_PRODUCT_100A 0x100a
223 224
224 #define BANDRICH_PRODUCT_100B 0x100b 225 #define BANDRICH_PRODUCT_100B 0x100b
225 #define BANDRICH_PRODUCT_100C 0x100c 226 #define BANDRICH_PRODUCT_100C 0x100c
226 #define BANDRICH_PRODUCT_100D 0x100d 227 #define BANDRICH_PRODUCT_100D 0x100d
227 #define BANDRICH_PRODUCT_100E 0x100e 228 #define BANDRICH_PRODUCT_100E 0x100e
228 229
229 #define BANDRICH_PRODUCT_100F 0x100f 230 #define BANDRICH_PRODUCT_100F 0x100f
230 #define BANDRICH_PRODUCT_1010 0x1010 231 #define BANDRICH_PRODUCT_1010 0x1010
231 #define BANDRICH_PRODUCT_1011 0x1011 232 #define BANDRICH_PRODUCT_1011 0x1011
232 #define BANDRICH_PRODUCT_1012 0x1012 233 #define BANDRICH_PRODUCT_1012 0x1012
233 234
234 #define QUALCOMM_VENDOR_ID 0x05C6 235 #define QUALCOMM_VENDOR_ID 0x05C6
235 236
236 #define CMOTECH_VENDOR_ID 0x16d8 237 #define CMOTECH_VENDOR_ID 0x16d8
237 #define CMOTECH_PRODUCT_6001 0x6001 238 #define CMOTECH_PRODUCT_6001 0x6001
238 #define CMOTECH_PRODUCT_CMU_300 0x6002 239 #define CMOTECH_PRODUCT_CMU_300 0x6002
239 #define CMOTECH_PRODUCT_6003 0x6003 240 #define CMOTECH_PRODUCT_6003 0x6003
240 #define CMOTECH_PRODUCT_6004 0x6004 241 #define CMOTECH_PRODUCT_6004 0x6004
241 #define CMOTECH_PRODUCT_6005 0x6005 242 #define CMOTECH_PRODUCT_6005 0x6005
242 #define CMOTECH_PRODUCT_CGU_628A 0x6006 243 #define CMOTECH_PRODUCT_CGU_628A 0x6006
243 #define CMOTECH_PRODUCT_CHE_628S 0x6007 244 #define CMOTECH_PRODUCT_CHE_628S 0x6007
244 #define CMOTECH_PRODUCT_CMU_301 0x6008 245 #define CMOTECH_PRODUCT_CMU_301 0x6008
245 #define CMOTECH_PRODUCT_CHU_628 0x6280 246 #define CMOTECH_PRODUCT_CHU_628 0x6280
246 #define CMOTECH_PRODUCT_CHU_628S 0x6281 247 #define CMOTECH_PRODUCT_CHU_628S 0x6281
247 #define CMOTECH_PRODUCT_CDU_680 0x6803 248 #define CMOTECH_PRODUCT_CDU_680 0x6803
248 #define CMOTECH_PRODUCT_CDU_685A 0x6804 249 #define CMOTECH_PRODUCT_CDU_685A 0x6804
249 #define CMOTECH_PRODUCT_CHU_720S 0x7001 250 #define CMOTECH_PRODUCT_CHU_720S 0x7001
250 #define CMOTECH_PRODUCT_7002 0x7002 251 #define CMOTECH_PRODUCT_7002 0x7002
251 #define CMOTECH_PRODUCT_CHU_629K 0x7003 252 #define CMOTECH_PRODUCT_CHU_629K 0x7003
252 #define CMOTECH_PRODUCT_7004 0x7004 253 #define CMOTECH_PRODUCT_7004 0x7004
253 #define CMOTECH_PRODUCT_7005 0x7005 254 #define CMOTECH_PRODUCT_7005 0x7005
254 #define CMOTECH_PRODUCT_CGU_629 0x7006 255 #define CMOTECH_PRODUCT_CGU_629 0x7006
255 #define CMOTECH_PRODUCT_CHU_629S 0x700a 256 #define CMOTECH_PRODUCT_CHU_629S 0x700a
256 #define CMOTECH_PRODUCT_CHU_720I 0x7211 257 #define CMOTECH_PRODUCT_CHU_720I 0x7211
257 #define CMOTECH_PRODUCT_7212 0x7212 258 #define CMOTECH_PRODUCT_7212 0x7212
258 #define CMOTECH_PRODUCT_7213 0x7213 259 #define CMOTECH_PRODUCT_7213 0x7213
259 #define CMOTECH_PRODUCT_7251 0x7251 260 #define CMOTECH_PRODUCT_7251 0x7251
260 #define CMOTECH_PRODUCT_7252 0x7252 261 #define CMOTECH_PRODUCT_7252 0x7252
261 #define CMOTECH_PRODUCT_7253 0x7253 262 #define CMOTECH_PRODUCT_7253 0x7253
262 263
263 #define TELIT_VENDOR_ID 0x1bc7 264 #define TELIT_VENDOR_ID 0x1bc7
264 #define TELIT_PRODUCT_UC864E 0x1003 265 #define TELIT_PRODUCT_UC864E 0x1003
265 #define TELIT_PRODUCT_UC864G 0x1004 266 #define TELIT_PRODUCT_UC864G 0x1004
266 #define TELIT_PRODUCT_CC864_DUAL 0x1005 267 #define TELIT_PRODUCT_CC864_DUAL 0x1005
267 #define TELIT_PRODUCT_CC864_SINGLE 0x1006 268 #define TELIT_PRODUCT_CC864_SINGLE 0x1006
268 #define TELIT_PRODUCT_DE910_DUAL 0x1010 269 #define TELIT_PRODUCT_DE910_DUAL 0x1010
269 #define TELIT_PRODUCT_UE910_V2 0x1012 270 #define TELIT_PRODUCT_UE910_V2 0x1012
270 #define TELIT_PRODUCT_LE920 0x1200 271 #define TELIT_PRODUCT_LE920 0x1200
271 272
272 /* ZTE PRODUCTS */ 273 /* ZTE PRODUCTS */
273 #define ZTE_VENDOR_ID 0x19d2 274 #define ZTE_VENDOR_ID 0x19d2
274 #define ZTE_PRODUCT_MF622 0x0001 275 #define ZTE_PRODUCT_MF622 0x0001
275 #define ZTE_PRODUCT_MF628 0x0015 276 #define ZTE_PRODUCT_MF628 0x0015
276 #define ZTE_PRODUCT_MF626 0x0031 277 #define ZTE_PRODUCT_MF626 0x0031
277 #define ZTE_PRODUCT_MC2718 0xffe8 278 #define ZTE_PRODUCT_MC2718 0xffe8
278 #define ZTE_PRODUCT_AC2726 0xfff1 279 #define ZTE_PRODUCT_AC2726 0xfff1
279 280
280 #define BENQ_VENDOR_ID 0x04a5 281 #define BENQ_VENDOR_ID 0x04a5
281 #define BENQ_PRODUCT_H10 0x4068 282 #define BENQ_PRODUCT_H10 0x4068
282 283
283 #define DLINK_VENDOR_ID 0x1186 284 #define DLINK_VENDOR_ID 0x1186
284 #define DLINK_PRODUCT_DWM_652 0x3e04 285 #define DLINK_PRODUCT_DWM_652 0x3e04
285 #define DLINK_PRODUCT_DWM_652_U5 0xce16 286 #define DLINK_PRODUCT_DWM_652_U5 0xce16
286 #define DLINK_PRODUCT_DWM_652_U5A 0xce1e 287 #define DLINK_PRODUCT_DWM_652_U5A 0xce1e
287 288
288 #define QISDA_VENDOR_ID 0x1da5 289 #define QISDA_VENDOR_ID 0x1da5
289 #define QISDA_PRODUCT_H21_4512 0x4512 290 #define QISDA_PRODUCT_H21_4512 0x4512
290 #define QISDA_PRODUCT_H21_4523 0x4523 291 #define QISDA_PRODUCT_H21_4523 0x4523
291 #define QISDA_PRODUCT_H20_4515 0x4515 292 #define QISDA_PRODUCT_H20_4515 0x4515
292 #define QISDA_PRODUCT_H20_4518 0x4518 293 #define QISDA_PRODUCT_H20_4518 0x4518
293 #define QISDA_PRODUCT_H20_4519 0x4519 294 #define QISDA_PRODUCT_H20_4519 0x4519
294 295
295 /* TLAYTECH PRODUCTS */ 296 /* TLAYTECH PRODUCTS */
296 #define TLAYTECH_VENDOR_ID 0x20B9 297 #define TLAYTECH_VENDOR_ID 0x20B9
297 #define TLAYTECH_PRODUCT_TEU800 0x1682 298 #define TLAYTECH_PRODUCT_TEU800 0x1682
298 299
299 /* TOSHIBA PRODUCTS */ 300 /* TOSHIBA PRODUCTS */
300 #define TOSHIBA_VENDOR_ID 0x0930 301 #define TOSHIBA_VENDOR_ID 0x0930
301 #define TOSHIBA_PRODUCT_HSDPA_MINICARD 0x1302 302 #define TOSHIBA_PRODUCT_HSDPA_MINICARD 0x1302
302 #define TOSHIBA_PRODUCT_G450 0x0d45 303 #define TOSHIBA_PRODUCT_G450 0x0d45
303 304
304 #define ALINK_VENDOR_ID 0x1e0e 305 #define ALINK_VENDOR_ID 0x1e0e
305 #define ALINK_PRODUCT_PH300 0x9100 306 #define ALINK_PRODUCT_PH300 0x9100
306 #define ALINK_PRODUCT_3GU 0x9200 307 #define ALINK_PRODUCT_3GU 0x9200
307 308
308 /* ALCATEL PRODUCTS */ 309 /* ALCATEL PRODUCTS */
309 #define ALCATEL_VENDOR_ID 0x1bbb 310 #define ALCATEL_VENDOR_ID 0x1bbb
310 #define ALCATEL_PRODUCT_X060S_X200 0x0000 311 #define ALCATEL_PRODUCT_X060S_X200 0x0000
311 #define ALCATEL_PRODUCT_X220_X500D 0x0017 312 #define ALCATEL_PRODUCT_X220_X500D 0x0017
312 #define ALCATEL_PRODUCT_L100V 0x011e 313 #define ALCATEL_PRODUCT_L100V 0x011e
313 #define ALCATEL_PRODUCT_L800MA 0x0203 314 #define ALCATEL_PRODUCT_L800MA 0x0203
314 315
315 #define PIRELLI_VENDOR_ID 0x1266 316 #define PIRELLI_VENDOR_ID 0x1266
316 #define PIRELLI_PRODUCT_C100_1 0x1002 317 #define PIRELLI_PRODUCT_C100_1 0x1002
317 #define PIRELLI_PRODUCT_C100_2 0x1003 318 #define PIRELLI_PRODUCT_C100_2 0x1003
318 #define PIRELLI_PRODUCT_1004 0x1004 319 #define PIRELLI_PRODUCT_1004 0x1004
319 #define PIRELLI_PRODUCT_1005 0x1005 320 #define PIRELLI_PRODUCT_1005 0x1005
320 #define PIRELLI_PRODUCT_1006 0x1006 321 #define PIRELLI_PRODUCT_1006 0x1006
321 #define PIRELLI_PRODUCT_1007 0x1007 322 #define PIRELLI_PRODUCT_1007 0x1007
322 #define PIRELLI_PRODUCT_1008 0x1008 323 #define PIRELLI_PRODUCT_1008 0x1008
323 #define PIRELLI_PRODUCT_1009 0x1009 324 #define PIRELLI_PRODUCT_1009 0x1009
324 #define PIRELLI_PRODUCT_100A 0x100a 325 #define PIRELLI_PRODUCT_100A 0x100a
325 #define PIRELLI_PRODUCT_100B 0x100b 326 #define PIRELLI_PRODUCT_100B 0x100b
326 #define PIRELLI_PRODUCT_100C 0x100c 327 #define PIRELLI_PRODUCT_100C 0x100c
327 #define PIRELLI_PRODUCT_100D 0x100d 328 #define PIRELLI_PRODUCT_100D 0x100d
328 #define PIRELLI_PRODUCT_100E 0x100e 329 #define PIRELLI_PRODUCT_100E 0x100e
329 #define PIRELLI_PRODUCT_100F 0x100f 330 #define PIRELLI_PRODUCT_100F 0x100f
330 #define PIRELLI_PRODUCT_1011 0x1011 331 #define PIRELLI_PRODUCT_1011 0x1011
331 #define PIRELLI_PRODUCT_1012 0x1012 332 #define PIRELLI_PRODUCT_1012 0x1012
332 333
333 /* Airplus products */ 334 /* Airplus products */
334 #define AIRPLUS_VENDOR_ID 0x1011 335 #define AIRPLUS_VENDOR_ID 0x1011
335 #define AIRPLUS_PRODUCT_MCD650 0x3198 336 #define AIRPLUS_PRODUCT_MCD650 0x3198
336 337
337 /* Longcheer/Longsung vendor ID; makes whitelabel devices that 338 /* Longcheer/Longsung vendor ID; makes whitelabel devices that
338 * many other vendors like 4G Systems, Alcatel, ChinaBird, 339 * many other vendors like 4G Systems, Alcatel, ChinaBird,
339 * Mobidata, etc sell under their own brand names. 340 * Mobidata, etc sell under their own brand names.
340 */ 341 */
341 #define LONGCHEER_VENDOR_ID 0x1c9e 342 #define LONGCHEER_VENDOR_ID 0x1c9e
342 343
343 /* 4G Systems products */ 344 /* 4G Systems products */
344 /* This is the 4G XS Stick W14 a.k.a. Mobilcom Debitel Surf-Stick * 345 /* This is the 4G XS Stick W14 a.k.a. Mobilcom Debitel Surf-Stick *
345 * It seems to contain a Qualcomm QSC6240/6290 chipset */ 346 * It seems to contain a Qualcomm QSC6240/6290 chipset */
346 #define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603 347 #define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603
347 348
348 /* iBall 3.5G connect wireless modem */ 349 /* iBall 3.5G connect wireless modem */
349 #define IBALL_3_5G_CONNECT 0x9605 350 #define IBALL_3_5G_CONNECT 0x9605
350 351
351 /* Zoom */ 352 /* Zoom */
352 #define ZOOM_PRODUCT_4597 0x9607 353 #define ZOOM_PRODUCT_4597 0x9607
353 354
354 /* Haier products */ 355 /* Haier products */
355 #define HAIER_VENDOR_ID 0x201e 356 #define HAIER_VENDOR_ID 0x201e
356 #define HAIER_PRODUCT_CE100 0x2009 357 #define HAIER_PRODUCT_CE100 0x2009
357 358
358 /* Cinterion (formerly Siemens) products */ 359 /* Cinterion (formerly Siemens) products */
359 #define SIEMENS_VENDOR_ID 0x0681 360 #define SIEMENS_VENDOR_ID 0x0681
360 #define CINTERION_VENDOR_ID 0x1e2d 361 #define CINTERION_VENDOR_ID 0x1e2d
361 #define CINTERION_PRODUCT_HC25_MDM 0x0047 362 #define CINTERION_PRODUCT_HC25_MDM 0x0047
362 #define CINTERION_PRODUCT_HC25_MDMNET 0x0040 363 #define CINTERION_PRODUCT_HC25_MDMNET 0x0040
363 #define CINTERION_PRODUCT_HC28_MDM 0x004C 364 #define CINTERION_PRODUCT_HC28_MDM 0x004C
364 #define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */ 365 #define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */
365 #define CINTERION_PRODUCT_EU3_E 0x0051 366 #define CINTERION_PRODUCT_EU3_E 0x0051
366 #define CINTERION_PRODUCT_EU3_P 0x0052 367 #define CINTERION_PRODUCT_EU3_P 0x0052
367 #define CINTERION_PRODUCT_PH8 0x0053 368 #define CINTERION_PRODUCT_PH8 0x0053
368 #define CINTERION_PRODUCT_AHXX 0x0055 369 #define CINTERION_PRODUCT_AHXX 0x0055
369 #define CINTERION_PRODUCT_PLXX 0x0060 370 #define CINTERION_PRODUCT_PLXX 0x0060
370 371
371 /* Olivetti products */ 372 /* Olivetti products */
372 #define OLIVETTI_VENDOR_ID 0x0b3c 373 #define OLIVETTI_VENDOR_ID 0x0b3c
373 #define OLIVETTI_PRODUCT_OLICARD100 0xc000 374 #define OLIVETTI_PRODUCT_OLICARD100 0xc000
374 #define OLIVETTI_PRODUCT_OLICARD145 0xc003 375 #define OLIVETTI_PRODUCT_OLICARD145 0xc003
375 #define OLIVETTI_PRODUCT_OLICARD200 0xc005 376 #define OLIVETTI_PRODUCT_OLICARD200 0xc005
376 #define OLIVETTI_PRODUCT_OLICARD500 0xc00b 377 #define OLIVETTI_PRODUCT_OLICARD500 0xc00b
377 378
378 /* Celot products */ 379 /* Celot products */
379 #define CELOT_VENDOR_ID 0x211f 380 #define CELOT_VENDOR_ID 0x211f
380 #define CELOT_PRODUCT_CT680M 0x6801 381 #define CELOT_PRODUCT_CT680M 0x6801
381 382
382 /* Samsung products */ 383 /* Samsung products */
383 #define SAMSUNG_VENDOR_ID 0x04e8 384 #define SAMSUNG_VENDOR_ID 0x04e8
384 #define SAMSUNG_PRODUCT_GT_B3730 0x6889 385 #define SAMSUNG_PRODUCT_GT_B3730 0x6889
385 386
386 /* YUGA products www.yuga-info.com gavin.kx@qq.com */ 387 /* YUGA products www.yuga-info.com gavin.kx@qq.com */
387 #define YUGA_VENDOR_ID 0x257A 388 #define YUGA_VENDOR_ID 0x257A
388 #define YUGA_PRODUCT_CEM600 0x1601 389 #define YUGA_PRODUCT_CEM600 0x1601
389 #define YUGA_PRODUCT_CEM610 0x1602 390 #define YUGA_PRODUCT_CEM610 0x1602
390 #define YUGA_PRODUCT_CEM500 0x1603 391 #define YUGA_PRODUCT_CEM500 0x1603
391 #define YUGA_PRODUCT_CEM510 0x1604 392 #define YUGA_PRODUCT_CEM510 0x1604
392 #define YUGA_PRODUCT_CEM800 0x1605 393 #define YUGA_PRODUCT_CEM800 0x1605
393 #define YUGA_PRODUCT_CEM900 0x1606 394 #define YUGA_PRODUCT_CEM900 0x1606
394 395
395 #define YUGA_PRODUCT_CEU818 0x1607 396 #define YUGA_PRODUCT_CEU818 0x1607
396 #define YUGA_PRODUCT_CEU816 0x1608 397 #define YUGA_PRODUCT_CEU816 0x1608
397 #define YUGA_PRODUCT_CEU828 0x1609 398 #define YUGA_PRODUCT_CEU828 0x1609
398 #define YUGA_PRODUCT_CEU826 0x160A 399 #define YUGA_PRODUCT_CEU826 0x160A
399 #define YUGA_PRODUCT_CEU518 0x160B 400 #define YUGA_PRODUCT_CEU518 0x160B
400 #define YUGA_PRODUCT_CEU516 0x160C 401 #define YUGA_PRODUCT_CEU516 0x160C
401 #define YUGA_PRODUCT_CEU528 0x160D 402 #define YUGA_PRODUCT_CEU528 0x160D
402 #define YUGA_PRODUCT_CEU526 0x160F 403 #define YUGA_PRODUCT_CEU526 0x160F
403 #define YUGA_PRODUCT_CEU881 0x161F 404 #define YUGA_PRODUCT_CEU881 0x161F
404 #define YUGA_PRODUCT_CEU882 0x162F 405 #define YUGA_PRODUCT_CEU882 0x162F
405 406
406 #define YUGA_PRODUCT_CWM600 0x2601 407 #define YUGA_PRODUCT_CWM600 0x2601
407 #define YUGA_PRODUCT_CWM610 0x2602 408 #define YUGA_PRODUCT_CWM610 0x2602
408 #define YUGA_PRODUCT_CWM500 0x2603 409 #define YUGA_PRODUCT_CWM500 0x2603
409 #define YUGA_PRODUCT_CWM510 0x2604 410 #define YUGA_PRODUCT_CWM510 0x2604
410 #define YUGA_PRODUCT_CWM800 0x2605 411 #define YUGA_PRODUCT_CWM800 0x2605
411 #define YUGA_PRODUCT_CWM900 0x2606 412 #define YUGA_PRODUCT_CWM900 0x2606
412 413
413 #define YUGA_PRODUCT_CWU718 0x2607 414 #define YUGA_PRODUCT_CWU718 0x2607
414 #define YUGA_PRODUCT_CWU716 0x2608 415 #define YUGA_PRODUCT_CWU716 0x2608
415 #define YUGA_PRODUCT_CWU728 0x2609 416 #define YUGA_PRODUCT_CWU728 0x2609
416 #define YUGA_PRODUCT_CWU726 0x260A 417 #define YUGA_PRODUCT_CWU726 0x260A
417 #define YUGA_PRODUCT_CWU518 0x260B 418 #define YUGA_PRODUCT_CWU518 0x260B
418 #define YUGA_PRODUCT_CWU516 0x260C 419 #define YUGA_PRODUCT_CWU516 0x260C
419 #define YUGA_PRODUCT_CWU528 0x260D 420 #define YUGA_PRODUCT_CWU528 0x260D
420 #define YUGA_PRODUCT_CWU581 0x260E 421 #define YUGA_PRODUCT_CWU581 0x260E
421 #define YUGA_PRODUCT_CWU526 0x260F 422 #define YUGA_PRODUCT_CWU526 0x260F
422 #define YUGA_PRODUCT_CWU582 0x261F 423 #define YUGA_PRODUCT_CWU582 0x261F
423 #define YUGA_PRODUCT_CWU583 0x262F 424 #define YUGA_PRODUCT_CWU583 0x262F
424 425
425 #define YUGA_PRODUCT_CLM600 0x3601 426 #define YUGA_PRODUCT_CLM600 0x3601
426 #define YUGA_PRODUCT_CLM610 0x3602 427 #define YUGA_PRODUCT_CLM610 0x3602
427 #define YUGA_PRODUCT_CLM500 0x3603 428 #define YUGA_PRODUCT_CLM500 0x3603
428 #define YUGA_PRODUCT_CLM510 0x3604 429 #define YUGA_PRODUCT_CLM510 0x3604
429 #define YUGA_PRODUCT_CLM800 0x3605 430 #define YUGA_PRODUCT_CLM800 0x3605
430 #define YUGA_PRODUCT_CLM900 0x3606 431 #define YUGA_PRODUCT_CLM900 0x3606
431 432
432 #define YUGA_PRODUCT_CLU718 0x3607 433 #define YUGA_PRODUCT_CLU718 0x3607
433 #define YUGA_PRODUCT_CLU716 0x3608 434 #define YUGA_PRODUCT_CLU716 0x3608
434 #define YUGA_PRODUCT_CLU728 0x3609 435 #define YUGA_PRODUCT_CLU728 0x3609
435 #define YUGA_PRODUCT_CLU726 0x360A 436 #define YUGA_PRODUCT_CLU726 0x360A
436 #define YUGA_PRODUCT_CLU518 0x360B 437 #define YUGA_PRODUCT_CLU518 0x360B
437 #define YUGA_PRODUCT_CLU516 0x360C 438 #define YUGA_PRODUCT_CLU516 0x360C
438 #define YUGA_PRODUCT_CLU528 0x360D 439 #define YUGA_PRODUCT_CLU528 0x360D
439 #define YUGA_PRODUCT_CLU526 0x360F 440 #define YUGA_PRODUCT_CLU526 0x360F
440 441
441 /* Viettel products */ 442 /* Viettel products */
442 #define VIETTEL_VENDOR_ID 0x2262 443 #define VIETTEL_VENDOR_ID 0x2262
443 #define VIETTEL_PRODUCT_VT1000 0x0002 444 #define VIETTEL_PRODUCT_VT1000 0x0002
444 445
445 /* ZD Incorporated */ 446 /* ZD Incorporated */
446 #define ZD_VENDOR_ID 0x0685 447 #define ZD_VENDOR_ID 0x0685
447 #define ZD_PRODUCT_7000 0x7000 448 #define ZD_PRODUCT_7000 0x7000
448 449
449 /* LG products */ 450 /* LG products */
450 #define LG_VENDOR_ID 0x1004 451 #define LG_VENDOR_ID 0x1004
451 #define LG_PRODUCT_L02C 0x618f 452 #define LG_PRODUCT_L02C 0x618f
452 453
453 /* MediaTek products */ 454 /* MediaTek products */
454 #define MEDIATEK_VENDOR_ID 0x0e8d 455 #define MEDIATEK_VENDOR_ID 0x0e8d
455 #define MEDIATEK_PRODUCT_DC_1COM 0x00a0 456 #define MEDIATEK_PRODUCT_DC_1COM 0x00a0
456 #define MEDIATEK_PRODUCT_DC_4COM 0x00a5 457 #define MEDIATEK_PRODUCT_DC_4COM 0x00a5
457 #define MEDIATEK_PRODUCT_DC_4COM2 0x00a7 458 #define MEDIATEK_PRODUCT_DC_4COM2 0x00a7
458 #define MEDIATEK_PRODUCT_DC_5COM 0x00a4 459 #define MEDIATEK_PRODUCT_DC_5COM 0x00a4
459 #define MEDIATEK_PRODUCT_7208_1COM 0x7101 460 #define MEDIATEK_PRODUCT_7208_1COM 0x7101
460 #define MEDIATEK_PRODUCT_7208_2COM 0x7102 461 #define MEDIATEK_PRODUCT_7208_2COM 0x7102
461 #define MEDIATEK_PRODUCT_7103_2COM 0x7103 462 #define MEDIATEK_PRODUCT_7103_2COM 0x7103
462 #define MEDIATEK_PRODUCT_7106_2COM 0x7106 463 #define MEDIATEK_PRODUCT_7106_2COM 0x7106
463 #define MEDIATEK_PRODUCT_FP_1COM 0x0003 464 #define MEDIATEK_PRODUCT_FP_1COM 0x0003
464 #define MEDIATEK_PRODUCT_FP_2COM 0x0023 465 #define MEDIATEK_PRODUCT_FP_2COM 0x0023
465 #define MEDIATEK_PRODUCT_FPDC_1COM 0x0043 466 #define MEDIATEK_PRODUCT_FPDC_1COM 0x0043
466 #define MEDIATEK_PRODUCT_FPDC_2COM 0x0033 467 #define MEDIATEK_PRODUCT_FPDC_2COM 0x0033
467 468
468 /* Cellient products */ 469 /* Cellient products */
469 #define CELLIENT_VENDOR_ID 0x2692 470 #define CELLIENT_VENDOR_ID 0x2692
470 #define CELLIENT_PRODUCT_MEN200 0x9005 471 #define CELLIENT_PRODUCT_MEN200 0x9005
471 472
472 /* Hyundai Petatel Inc. products */ 473 /* Hyundai Petatel Inc. products */
473 #define PETATEL_VENDOR_ID 0x1ff4 474 #define PETATEL_VENDOR_ID 0x1ff4
474 #define PETATEL_PRODUCT_NP10T_600A 0x600a 475 #define PETATEL_PRODUCT_NP10T_600A 0x600a
475 #define PETATEL_PRODUCT_NP10T_600E 0x600e 476 #define PETATEL_PRODUCT_NP10T_600E 0x600e
476 477
477 /* TP-LINK Incorporated products */ 478 /* TP-LINK Incorporated products */
478 #define TPLINK_VENDOR_ID 0x2357 479 #define TPLINK_VENDOR_ID 0x2357
479 #define TPLINK_PRODUCT_MA180 0x0201 480 #define TPLINK_PRODUCT_MA180 0x0201
480 481
481 /* Changhong products */ 482 /* Changhong products */
482 #define CHANGHONG_VENDOR_ID 0x2077 483 #define CHANGHONG_VENDOR_ID 0x2077
483 #define CHANGHONG_PRODUCT_CH690 0x7001 484 #define CHANGHONG_PRODUCT_CH690 0x7001
484 485
485 /* Inovia */ 486 /* Inovia */
486 #define INOVIA_VENDOR_ID 0x20a6 487 #define INOVIA_VENDOR_ID 0x20a6
487 #define INOVIA_SEW858 0x1105 488 #define INOVIA_SEW858 0x1105
488 489
489 /* some devices interfaces need special handling due to a number of reasons */ 490 /* some devices interfaces need special handling due to a number of reasons */
490 enum option_blacklist_reason { 491 enum option_blacklist_reason {
491 OPTION_BLACKLIST_NONE = 0, 492 OPTION_BLACKLIST_NONE = 0,
492 OPTION_BLACKLIST_SENDSETUP = 1, 493 OPTION_BLACKLIST_SENDSETUP = 1,
493 OPTION_BLACKLIST_RESERVED_IF = 2 494 OPTION_BLACKLIST_RESERVED_IF = 2
494 }; 495 };
495 496
496 #define MAX_BL_NUM 8 497 #define MAX_BL_NUM 8
497 struct option_blacklist_info { 498 struct option_blacklist_info {
498 /* bitfield of interface numbers for OPTION_BLACKLIST_SENDSETUP */ 499 /* bitfield of interface numbers for OPTION_BLACKLIST_SENDSETUP */
499 const unsigned long sendsetup; 500 const unsigned long sendsetup;
500 /* bitfield of interface numbers for OPTION_BLACKLIST_RESERVED_IF */ 501 /* bitfield of interface numbers for OPTION_BLACKLIST_RESERVED_IF */
501 const unsigned long reserved; 502 const unsigned long reserved;
502 }; 503 };
503 504
504 static const struct option_blacklist_info four_g_w14_blacklist = { 505 static const struct option_blacklist_info four_g_w14_blacklist = {
505 .sendsetup = BIT(0) | BIT(1), 506 .sendsetup = BIT(0) | BIT(1),
506 }; 507 };
507 508
508 static const struct option_blacklist_info alcatel_x200_blacklist = { 509 static const struct option_blacklist_info alcatel_x200_blacklist = {
509 .sendsetup = BIT(0) | BIT(1), 510 .sendsetup = BIT(0) | BIT(1),
510 .reserved = BIT(4), 511 .reserved = BIT(4),
511 }; 512 };
512 513
513 static const struct option_blacklist_info zte_0037_blacklist = { 514 static const struct option_blacklist_info zte_0037_blacklist = {
514 .sendsetup = BIT(0) | BIT(1), 515 .sendsetup = BIT(0) | BIT(1),
515 }; 516 };
516 517
517 static const struct option_blacklist_info zte_k3765_z_blacklist = { 518 static const struct option_blacklist_info zte_k3765_z_blacklist = {
518 .sendsetup = BIT(0) | BIT(1) | BIT(2), 519 .sendsetup = BIT(0) | BIT(1) | BIT(2),
519 .reserved = BIT(4), 520 .reserved = BIT(4),
520 }; 521 };
521 522
522 static const struct option_blacklist_info zte_mc2718_z_blacklist = { 523 static const struct option_blacklist_info zte_mc2718_z_blacklist = {
523 .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4), 524 .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4),
524 }; 525 };
525 526
526 static const struct option_blacklist_info huawei_cdc12_blacklist = { 527 static const struct option_blacklist_info huawei_cdc12_blacklist = {
527 .reserved = BIT(1) | BIT(2), 528 .reserved = BIT(1) | BIT(2),
528 }; 529 };
529 530
530 static const struct option_blacklist_info net_intf0_blacklist = { 531 static const struct option_blacklist_info net_intf0_blacklist = {
531 .reserved = BIT(0), 532 .reserved = BIT(0),
532 }; 533 };
533 534
534 static const struct option_blacklist_info net_intf1_blacklist = { 535 static const struct option_blacklist_info net_intf1_blacklist = {
535 .reserved = BIT(1), 536 .reserved = BIT(1),
536 }; 537 };
537 538
538 static const struct option_blacklist_info net_intf2_blacklist = { 539 static const struct option_blacklist_info net_intf2_blacklist = {
539 .reserved = BIT(2), 540 .reserved = BIT(2),
540 }; 541 };
541 542
542 static const struct option_blacklist_info net_intf3_blacklist = { 543 static const struct option_blacklist_info net_intf3_blacklist = {
543 .reserved = BIT(3), 544 .reserved = BIT(3),
544 }; 545 };
545 546
546 static const struct option_blacklist_info net_intf4_blacklist = { 547 static const struct option_blacklist_info net_intf4_blacklist = {
547 .reserved = BIT(4), 548 .reserved = BIT(4),
548 }; 549 };
549 550
550 static const struct option_blacklist_info net_intf5_blacklist = { 551 static const struct option_blacklist_info net_intf5_blacklist = {
551 .reserved = BIT(5), 552 .reserved = BIT(5),
552 }; 553 };
553 554
554 static const struct option_blacklist_info net_intf6_blacklist = { 555 static const struct option_blacklist_info net_intf6_blacklist = {
555 .reserved = BIT(6), 556 .reserved = BIT(6),
556 }; 557 };
557 558
558 static const struct option_blacklist_info zte_mf626_blacklist = { 559 static const struct option_blacklist_info zte_mf626_blacklist = {
559 .sendsetup = BIT(0) | BIT(1), 560 .sendsetup = BIT(0) | BIT(1),
560 .reserved = BIT(4), 561 .reserved = BIT(4),
561 }; 562 };
562 563
563 static const struct option_blacklist_info zte_1255_blacklist = { 564 static const struct option_blacklist_info zte_1255_blacklist = {
564 .reserved = BIT(3) | BIT(4), 565 .reserved = BIT(3) | BIT(4),
565 }; 566 };
566 567
567 static const struct option_blacklist_info telit_le920_blacklist = { 568 static const struct option_blacklist_info telit_le920_blacklist = {
568 .sendsetup = BIT(0), 569 .sendsetup = BIT(0),
569 .reserved = BIT(1) | BIT(5), 570 .reserved = BIT(1) | BIT(5),
570 }; 571 };
571 572
572 static const struct usb_device_id option_ids[] = { 573 static const struct usb_device_id option_ids[] = {
573 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 574 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
574 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 575 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
575 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) }, 576 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
576 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) }, 577 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) },
577 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) }, 578 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) },
578 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS) }, 579 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS) },
579 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_LIGHT) }, 580 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_LIGHT) },
580 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_QUAD) }, 581 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_QUAD) },
581 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_QUAD_LIGHT) }, 582 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_QUAD_LIGHT) },
582 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) }, 583 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) },
583 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA_BUS) }, 584 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA_BUS) },
584 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER) }, 585 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER) },
585 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER_BUS) }, 586 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER_BUS) },
586 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX_READY) }, 587 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX_READY) },
587 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_LIGHT) }, 588 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_LIGHT) },
588 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_GT) }, 589 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_GT) },
589 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_EX) }, 590 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_EX) },
590 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_MODEM) }, 591 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_MODEM) },
591 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_MODEM) }, 592 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_MODEM) },
592 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM) }, 593 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM) },
593 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_LITE) }, 594 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_LITE) },
594 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, 595 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) },
595 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, 596 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) },
596 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, 597 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) },
597 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GTM380_MODEM) }, 598 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GTM380_MODEM) },
598 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q101) }, 599 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q101) },
599 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q111) }, 600 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q111) },
600 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) }, 601 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) },
601 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GKE) }, 602 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GKE) },
602 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLE) }, 603 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLE) },
603 { USB_DEVICE(QUANTA_VENDOR_ID, 0xea42), 604 { USB_DEVICE(QUANTA_VENDOR_ID, 0xea42),
604 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 605 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
605 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c05, USB_CLASS_COMM, 0x02, 0xff) }, 606 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c05, USB_CLASS_COMM, 0x02, 0xff) },
606 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c1f, USB_CLASS_COMM, 0x02, 0xff) }, 607 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c1f, USB_CLASS_COMM, 0x02, 0xff) },
607 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) }, 608 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) },
608 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff), 609 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff),
609 .driver_info = (kernel_ulong_t) &net_intf1_blacklist }, 610 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
610 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173S6, 0xff, 0xff, 0xff), 611 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173S6, 0xff, 0xff, 0xff),
611 .driver_info = (kernel_ulong_t) &net_intf1_blacklist }, 612 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
612 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff), 613 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff),
613 .driver_info = (kernel_ulong_t) &net_intf2_blacklist }, 614 .driver_info = (kernel_ulong_t) &net_intf2_blacklist },
614 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) }, 615 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) },
615 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1442, USB_CLASS_COMM, 0x02, 0xff) }, 616 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1442, USB_CLASS_COMM, 0x02, 0xff) },
616 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff), 617 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff),
617 .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist }, 618 .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist },
618 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff), 619 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff),
619 .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist }, 620 .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist },
620 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x14ac, 0xff, 0xff, 0xff), /* Huawei E1820 */ 621 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x14ac, 0xff, 0xff, 0xff), /* Huawei E1820 */
621 .driver_info = (kernel_ulong_t) &net_intf1_blacklist }, 622 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
622 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4605, 0xff, 0xff, 0xff), 623 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4605, 0xff, 0xff, 0xff),
623 .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist }, 624 .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist },
624 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0xff, 0xff) }, 625 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0xff, 0xff) },
625 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x01) }, 626 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x01) },
626 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x02) }, 627 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x02) },
627 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x03) }, 628 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x03) },
628 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x04) }, 629 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x04) },
629 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x05) }, 630 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x05) },
630 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x06) }, 631 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x06) },
631 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0A) }, 632 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0A) },
632 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0B) }, 633 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0B) },
633 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0D) }, 634 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0D) },
634 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0E) }, 635 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0E) },
635 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0F) }, 636 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x0F) },
636 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x10) }, 637 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x10) },
637 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x12) }, 638 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x12) },
638 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x13) }, 639 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x13) },
639 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x14) }, 640 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x14) },
640 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x15) }, 641 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x15) },
641 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x17) }, 642 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x17) },
642 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x18) }, 643 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x18) },
643 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x19) }, 644 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x19) },
644 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x1A) }, 645 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x1A) },
645 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x1B) }, 646 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x1B) },
646 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x1C) }, 647 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x1C) },
647 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x31) }, 648 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x31) },
648 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x32) }, 649 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x32) },
649 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x33) }, 650 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x33) },
650 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x34) }, 651 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x34) },
651 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x35) }, 652 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x35) },
652 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x36) }, 653 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x36) },
653 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3A) }, 654 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3A) },
654 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3B) }, 655 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3B) },
655 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3D) }, 656 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3D) },
656 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3E) }, 657 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3E) },
657 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3F) }, 658 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x3F) },
658 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x48) }, 659 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x48) },
659 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x49) }, 660 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x49) },
660 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x4A) }, 661 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x4A) },
661 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x4B) }, 662 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x4B) },
662 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x4C) }, 663 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x4C) },
663 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x61) }, 664 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x61) },
664 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x62) }, 665 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x62) },
665 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x63) }, 666 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x63) },
666 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x64) }, 667 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x64) },
667 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x65) }, 668 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x65) },
668 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x66) }, 669 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x66) },
669 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6A) }, 670 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6A) },
670 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6B) }, 671 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6B) },
671 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6D) }, 672 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6D) },
672 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6E) }, 673 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6E) },
673 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6F) }, 674 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6F) },
674 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x72) }, 675 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x72) },
675 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x73) }, 676 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x73) },
676 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x74) }, 677 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x74) },
677 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x75) }, 678 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x75) },
678 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x78) }, 679 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x78) },
679 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x79) }, 680 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x79) },
680 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7A) }, 681 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7A) },
681 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7B) }, 682 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7B) },
682 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7C) }, 683 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7C) },
683 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x01) }, 684 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x01) },
684 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x02) }, 685 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x02) },
685 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x03) }, 686 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x03) },
686 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x04) }, 687 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x04) },
687 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x05) }, 688 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x05) },
688 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x06) }, 689 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x06) },
689 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0A) }, 690 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0A) },
690 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0B) }, 691 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0B) },
691 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0D) }, 692 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0D) },
692 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0E) }, 693 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0E) },
693 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0F) }, 694 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x0F) },
694 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x10) }, 695 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x10) },
695 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x12) }, 696 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x12) },
696 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x13) }, 697 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x13) },
697 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x14) }, 698 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x14) },
698 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x15) }, 699 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x15) },
699 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x17) }, 700 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x17) },
700 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x18) }, 701 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x18) },
701 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x19) }, 702 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x19) },
702 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x1A) }, 703 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x1A) },
703 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x1B) }, 704 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x1B) },
704 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x1C) }, 705 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x1C) },
705 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x31) }, 706 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x31) },
706 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x32) }, 707 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x32) },
707 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x33) }, 708 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x33) },
708 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x34) }, 709 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x34) },
709 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x35) }, 710 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x35) },
710 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x36) }, 711 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x36) },
711 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3A) }, 712 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3A) },
712 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3B) }, 713 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3B) },
713 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3D) }, 714 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3D) },
714 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3E) }, 715 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3E) },
715 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3F) }, 716 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x3F) },
716 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x48) }, 717 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x48) },
717 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x49) }, 718 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x49) },
718 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x4A) }, 719 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x4A) },
719 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x4B) }, 720 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x4B) },
720 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x4C) }, 721 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x4C) },
721 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x61) }, 722 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x61) },
722 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x62) }, 723 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x62) },
723 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x63) }, 724 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x63) },
724 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x64) }, 725 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x64) },
725 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x65) }, 726 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x65) },
726 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x66) }, 727 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x66) },
727 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6A) }, 728 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6A) },
728 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6B) }, 729 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6B) },
729 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6D) }, 730 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6D) },
730 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6E) }, 731 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6E) },
731 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6F) }, 732 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6F) },
732 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x72) }, 733 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x72) },
733 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x73) }, 734 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x73) },
734 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x74) }, 735 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x74) },
735 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x75) }, 736 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x75) },
736 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x78) }, 737 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x78) },
737 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x79) }, 738 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x79) },
738 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) }, 739 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) },
739 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7B) }, 740 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7B) },
740 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7C) }, 741 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7C) },
741 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x01) }, 742 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x01) },
742 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x02) }, 743 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x02) },
743 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x03) }, 744 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x03) },
744 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x04) }, 745 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x04) },
745 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x05) }, 746 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x05) },
746 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x06) }, 747 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x06) },
747 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0A) }, 748 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0A) },
748 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0B) }, 749 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0B) },
749 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0D) }, 750 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0D) },
750 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0E) }, 751 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0E) },
751 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0F) }, 752 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0F) },
752 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x10) }, 753 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x10) },
753 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x12) }, 754 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x12) },
754 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x13) }, 755 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x13) },
755 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x14) }, 756 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x14) },
756 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x15) }, 757 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x15) },
757 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x17) }, 758 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x17) },
758 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x18) }, 759 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x18) },
759 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x19) }, 760 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x19) },
760 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1A) }, 761 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1A) },
761 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1B) }, 762 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1B) },
762 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1C) }, 763 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1C) },
763 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x31) }, 764 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x31) },
764 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x32) }, 765 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x32) },
765 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x33) }, 766 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x33) },
766 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x34) }, 767 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x34) },
767 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x35) }, 768 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x35) },
768 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x36) }, 769 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x36) },
769 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3A) }, 770 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3A) },
770 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3B) }, 771 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3B) },
771 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3D) }, 772 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3D) },
772 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3E) }, 773 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3E) },
773 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3F) }, 774 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3F) },
774 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x48) }, 775 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x48) },
775 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x49) }, 776 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x49) },
776 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4A) }, 777 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4A) },
777 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4B) }, 778 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4B) },
778 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4C) }, 779 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4C) },
779 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x61) }, 780 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x61) },
780 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x62) }, 781 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x62) },
781 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x63) }, 782 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x63) },
782 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x64) }, 783 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x64) },
783 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x65) }, 784 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x65) },
784 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x66) }, 785 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x66) },
785 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6A) }, 786 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6A) },
786 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6B) }, 787 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6B) },
787 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) }, 788 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) },
788 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) }, 789 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) },
789 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) }, 790 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) },
790 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x72) }, 791 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x72) },
791 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x73) }, 792 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x73) },
792 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x74) }, 793 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x74) },
793 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x75) }, 794 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x75) },
794 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) }, 795 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) },
795 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) }, 796 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) },
796 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) }, 797 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) },
797 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7B) }, 798 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7B) },
798 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7C) }, 799 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7C) },
799 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x01) }, 800 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x01) },
800 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x02) }, 801 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x02) },
801 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x03) }, 802 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x03) },
802 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x04) }, 803 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x04) },
803 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x05) }, 804 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x05) },
804 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x06) }, 805 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x06) },
805 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0A) }, 806 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0A) },
806 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0B) }, 807 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0B) },
807 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0D) }, 808 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0D) },
808 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0E) }, 809 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0E) },
809 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0F) }, 810 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0F) },
810 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x10) }, 811 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x10) },
811 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x12) }, 812 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x12) },
812 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x13) }, 813 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x13) },
813 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x14) }, 814 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x14) },
814 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x15) }, 815 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x15) },
815 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x17) }, 816 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x17) },
816 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x18) }, 817 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x18) },
817 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x19) }, 818 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x19) },
818 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1A) }, 819 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1A) },
819 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1B) }, 820 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1B) },
820 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1C) }, 821 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1C) },
821 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x31) }, 822 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x31) },
822 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x32) }, 823 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x32) },
823 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x33) }, 824 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x33) },
824 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x34) }, 825 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x34) },
825 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x35) }, 826 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x35) },
826 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x36) }, 827 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x36) },
827 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3A) }, 828 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3A) },
828 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3B) }, 829 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3B) },
829 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3D) }, 830 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3D) },
830 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3E) }, 831 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3E) },
831 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3F) }, 832 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3F) },
832 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x48) }, 833 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x48) },
833 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x49) }, 834 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x49) },
834 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4A) }, 835 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4A) },
835 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4B) }, 836 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4B) },
836 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4C) }, 837 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4C) },
837 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x61) }, 838 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x61) },
838 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x62) }, 839 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x62) },
839 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x63) }, 840 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x63) },
840 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x64) }, 841 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x64) },
841 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x65) }, 842 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x65) },
842 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x66) }, 843 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x66) },
843 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6A) }, 844 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6A) },
844 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6B) }, 845 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6B) },
845 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) }, 846 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) },
846 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) }, 847 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) },
847 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) }, 848 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) },
848 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x72) }, 849 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x72) },
849 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x73) }, 850 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x73) },
850 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x74) }, 851 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x74) },
851 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x75) }, 852 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x75) },
852 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) }, 853 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) },
853 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) }, 854 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) },
854 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) }, 855 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) },
855 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7B) }, 856 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7B) },
856 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7C) }, 857 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7C) },
857 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x01) }, 858 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x01) },
858 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x02) }, 859 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x02) },
859 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x03) }, 860 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x03) },
860 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x04) }, 861 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x04) },
861 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x05) }, 862 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x05) },
862 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x06) }, 863 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x06) },
863 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0A) }, 864 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0A) },
864 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0B) }, 865 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0B) },
865 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0D) }, 866 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0D) },
866 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0E) }, 867 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0E) },
867 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0F) }, 868 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0F) },
868 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x10) }, 869 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x10) },
869 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x12) }, 870 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x12) },
870 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x13) }, 871 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x13) },
871 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x14) }, 872 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x14) },
872 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x15) }, 873 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x15) },
873 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x17) }, 874 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x17) },
874 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x18) }, 875 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x18) },
875 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x19) }, 876 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x19) },
876 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1A) }, 877 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1A) },
877 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1B) }, 878 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1B) },
878 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1C) }, 879 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1C) },
879 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x31) }, 880 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x31) },
880 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x32) }, 881 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x32) },
881 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x33) }, 882 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x33) },
882 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x34) }, 883 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x34) },
883 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x35) }, 884 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x35) },
884 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x36) }, 885 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x36) },
885 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3A) }, 886 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3A) },
886 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3B) }, 887 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3B) },
887 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3D) }, 888 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3D) },
888 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3E) }, 889 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3E) },
889 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3F) }, 890 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3F) },
890 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x48) }, 891 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x48) },
891 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x49) }, 892 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x49) },
892 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4A) }, 893 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4A) },
893 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4B) }, 894 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4B) },
894 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4C) }, 895 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4C) },
895 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x61) }, 896 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x61) },
896 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x62) }, 897 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x62) },
897 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x63) }, 898 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x63) },
898 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x64) }, 899 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x64) },
899 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x65) }, 900 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x65) },
900 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x66) }, 901 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x66) },
901 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6A) }, 902 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6A) },
902 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6B) }, 903 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6B) },
903 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) }, 904 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) },
904 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) }, 905 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) },
905 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) }, 906 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) },
906 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x72) }, 907 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x72) },
907 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x73) }, 908 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x73) },
908 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x74) }, 909 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x74) },
909 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x75) }, 910 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x75) },
910 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) }, 911 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) },
911 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) }, 912 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) },
912 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) }, 913 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) },
913 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7B) }, 914 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7B) },
914 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7C) }, 915 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7C) },
915 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x01) }, 916 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x01) },
916 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x02) }, 917 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x02) },
917 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x03) }, 918 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x03) },
918 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x04) }, 919 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x04) },
919 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x05) }, 920 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x05) },
920 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x06) }, 921 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x06) },
921 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0A) }, 922 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0A) },
922 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0B) }, 923 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0B) },
923 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0D) }, 924 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0D) },
924 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0E) }, 925 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0E) },
925 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0F) }, 926 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0F) },
926 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x10) }, 927 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x10) },
927 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x12) }, 928 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x12) },
928 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x13) }, 929 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x13) },
929 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x14) }, 930 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x14) },
930 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x15) }, 931 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x15) },
931 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x17) }, 932 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x17) },
932 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x18) }, 933 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x18) },
933 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x19) }, 934 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x19) },
934 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1A) }, 935 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1A) },
935 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1B) }, 936 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1B) },
936 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1C) }, 937 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1C) },
937 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x31) }, 938 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x31) },
938 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x32) }, 939 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x32) },
939 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x33) }, 940 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x33) },
940 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x34) }, 941 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x34) },
941 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x35) }, 942 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x35) },
942 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x36) }, 943 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x36) },
943 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3A) }, 944 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3A) },
944 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3B) }, 945 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3B) },
945 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3D) }, 946 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3D) },
946 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3E) }, 947 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3E) },
947 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3F) }, 948 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3F) },
948 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x48) }, 949 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x48) },
949 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x49) }, 950 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x49) },
950 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4A) }, 951 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4A) },
951 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4B) }, 952 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4B) },
952 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4C) }, 953 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4C) },
953 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x61) }, 954 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x61) },
954 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x62) }, 955 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x62) },
955 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x63) }, 956 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x63) },
956 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x64) }, 957 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x64) },
957 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x65) }, 958 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x65) },
958 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x66) }, 959 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x66) },
959 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6A) }, 960 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6A) },
960 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6B) }, 961 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6B) },
961 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) }, 962 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) },
962 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) }, 963 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) },
963 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) }, 964 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) },
964 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x72) }, 965 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x72) },
965 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x73) }, 966 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x73) },
966 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x74) }, 967 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x74) },
967 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x75) }, 968 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x75) },
968 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) }, 969 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) },
969 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) }, 970 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) },
970 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) }, 971 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) },
971 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7B) }, 972 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7B) },
972 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) }, 973 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) },
973 974
974 975
975 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, 976 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) },
976 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, 977 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) },
977 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V740) }, 978 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V740) },
978 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V720) }, 979 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V720) },
979 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U730) }, 980 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U730) },
980 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U740) }, 981 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U740) },
981 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U870) }, 982 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U870) },
982 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_XU870) }, 983 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_XU870) },
983 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_X950D) }, 984 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_X950D) },
984 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EV620) }, 985 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EV620) },
985 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_ES720) }, 986 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_ES720) },
986 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E725) }, 987 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E725) },
987 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_ES620) }, 988 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_ES620) },
988 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU730) }, 989 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU730) },
989 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU740) }, 990 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU740) },
990 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, 991 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) },
991 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, 992 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) },
992 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, 993 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) },
993 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_OVMC760) }, 994 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_OVMC760) },
994 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC780) }, 995 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC780) },
995 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED) }, 996 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED) },
996 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, 997 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) },
997 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, 998 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) },
998 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, 999 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) },
999 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED) }, 1000 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED) },
1000 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED) }, 1001 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED) },
1001 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED3) }, 1002 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED3) },
1002 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED4) }, 1003 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED4) },
1003 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED5) }, 1004 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED5) },
1004 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED6) }, 1005 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED6) },
1005 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED7) }, 1006 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED7) },
1006 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC996D) }, 1007 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC996D) },
1007 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MF3470) }, 1008 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MF3470) },
1008 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC547) }, 1009 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC547) },
1009 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED) }, 1010 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED) },
1010 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED) }, 1011 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED) },
1011 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_G2) }, 1012 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_G2) },
1012 /* Novatel Ovation MC551 a.k.a. Verizon USB551L */ 1013 /* Novatel Ovation MC551 a.k.a. Verizon USB551L */
1013 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) }, 1014 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) },
1014 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E362, 0xff, 0xff, 0xff) }, 1015 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E362, 0xff, 0xff, 0xff) },
1016 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E371, 0xff, 0xff, 0xff) },
1015 1017
1016 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, 1018 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) },
1017 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, 1019 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) },
1018 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) }, 1020 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) },
1019 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_SKYPEPHONE_S2) }, 1021 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_SKYPEPHONE_S2) },
1020 1022
1021 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ 1023 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */
1022 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5500_MINICARD) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ 1024 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5500_MINICARD) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
1023 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5505_MINICARD) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ 1025 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5505_MINICARD) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
1024 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_EXPRESSCARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ 1026 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_EXPRESSCARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */
1025 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5510_EXPRESSCARD) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ 1027 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5510_EXPRESSCARD) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */
1026 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD_SPRINT) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ 1028 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD_SPRINT) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */
1027 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD_TELUS) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite ET620 CDMA/EV-DO */ 1029 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD_TELUS) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite ET620 CDMA/EV-DO */
1028 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_VZW) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 1030 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_VZW) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
1029 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_SPRINT) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 1031 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_SPRINT) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
1030 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_TELUS) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 1032 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_TELUS) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
1031 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_CINGULAR) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 1033 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_CINGULAR) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */
1032 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_L) }, /* Dell Wireless HSDPA 5520 */ 1034 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_L) }, /* Dell Wireless HSDPA 5520 */
1033 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_I) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ 1035 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_I) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */
1034 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 1036 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
1035 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 1037 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
1036 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 1038 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
1037 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_MINICARD_VZW, 0xff, 0xff, 0xff) }, 1039 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_MINICARD_VZW, 0xff, 0xff, 0xff) },
1038 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_V2_MINICARD_VZW, 0xff, 0xff, 0xff) }, 1040 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_V2_MINICARD_VZW, 0xff, 0xff, 0xff) },
1039 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5804_MINICARD_ATT, 0xff, 0xff, 0xff) }, 1041 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5804_MINICARD_ATT, 0xff, 0xff, 0xff) },
1040 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ 1042 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */
1041 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 1043 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
1042 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, 1044 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) },
1043 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, 1045 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) },
1044 { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, 1046 { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) },
1045 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1, 0xff) }, 1047 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1, 0xff) },
1046 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2, 0xff) }, 1048 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2, 0xff) },
1047 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004, 0xff) }, 1049 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004, 0xff) },
1048 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005, 0xff) }, 1050 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005, 0xff) },
1049 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006, 0xff) }, 1051 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006, 0xff) },
1050 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007, 0xff) }, 1052 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007, 0xff) },
1051 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008, 0xff) }, 1053 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008, 0xff) },
1052 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009, 0xff) }, 1054 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009, 0xff) },
1053 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A, 0xff) }, 1055 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A, 0xff) },
1054 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B, 0xff) }, 1056 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B, 0xff) },
1055 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C, 0xff) }, 1057 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C, 0xff) },
1056 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D, 0xff) }, 1058 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D, 0xff) },
1057 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E, 0xff) }, 1059 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E, 0xff) },
1058 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F, 0xff) }, 1060 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F, 0xff) },
1059 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010, 0xff) }, 1061 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010, 0xff) },
1060 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011, 0xff) }, 1062 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011, 0xff) },
1061 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) }, 1063 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) },
1062 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, 1064 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
1063 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 1065 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
1064 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 1066 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
1065 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ 1067 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
1066 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ 1068 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
1067 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, 1069 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
1068 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, 1070 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
1069 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), 1071 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
1070 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1072 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1071 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6004) }, 1073 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6004) },
1072 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6005) }, 1074 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6005) },
1073 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CGU_628A) }, 1075 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CGU_628A) },
1074 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHE_628S), 1076 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHE_628S),
1075 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1077 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1076 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_301), 1078 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_301),
1077 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1079 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1078 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_628), 1080 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_628),
1079 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1081 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1080 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_628S) }, 1082 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_628S) },
1081 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU_680) }, 1083 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU_680) },
1082 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU_685A) }, 1084 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU_685A) },
1083 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_720S), 1085 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_720S),
1084 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1086 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1085 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7002), 1087 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7002),
1086 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1088 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1087 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_629K), 1089 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_629K),
1088 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1090 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1089 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7004), 1091 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7004),
1090 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1092 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1091 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7005) }, 1093 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7005) },
1092 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CGU_629), 1094 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CGU_629),
1093 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1095 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1094 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_629S), 1096 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_629S),
1095 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1097 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1096 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_720I), 1098 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_720I),
1097 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1099 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1098 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7212), 1100 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7212),
1099 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1101 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1100 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7213), 1102 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7213),
1101 .driver_info = (kernel_ulong_t)&net_intf0_blacklist }, 1103 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1102 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7251), 1104 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7251),
1103 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1105 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1104 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7252), 1106 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7252),
1105 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1107 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1106 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7253), 1108 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7253),
1107 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1109 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1108 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 1110 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
1109 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) }, 1111 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) },
1110 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_DUAL) }, 1112 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_DUAL) },
1111 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, 1113 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) },
1112 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, 1114 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) },
1113 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, 1115 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) },
1114 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), 1116 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
1115 .driver_info = (kernel_ulong_t)&telit_le920_blacklist }, 1117 .driver_info = (kernel_ulong_t)&telit_le920_blacklist },
1116 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ 1118 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
1117 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff), 1119 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff),
1118 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1120 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1119 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0003, 0xff, 0xff, 0xff) }, 1121 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0003, 0xff, 0xff, 0xff) },
1120 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0004, 0xff, 0xff, 0xff) }, 1122 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0004, 0xff, 0xff, 0xff) },
1121 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0005, 0xff, 0xff, 0xff) }, 1123 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0005, 0xff, 0xff, 0xff) },
1122 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0006, 0xff, 0xff, 0xff) }, 1124 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0006, 0xff, 0xff, 0xff) },
1123 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0008, 0xff, 0xff, 0xff) }, 1125 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0008, 0xff, 0xff, 0xff) },
1124 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0009, 0xff, 0xff, 0xff) }, 1126 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0009, 0xff, 0xff, 0xff) },
1125 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000a, 0xff, 0xff, 0xff) }, 1127 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000a, 0xff, 0xff, 0xff) },
1126 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000b, 0xff, 0xff, 0xff) }, 1128 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000b, 0xff, 0xff, 0xff) },
1127 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000c, 0xff, 0xff, 0xff) }, 1129 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000c, 0xff, 0xff, 0xff) },
1128 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000d, 0xff, 0xff, 0xff) }, 1130 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000d, 0xff, 0xff, 0xff) },
1129 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000e, 0xff, 0xff, 0xff) }, 1131 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000e, 0xff, 0xff, 0xff) },
1130 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000f, 0xff, 0xff, 0xff) }, 1132 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x000f, 0xff, 0xff, 0xff) },
1131 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0010, 0xff, 0xff, 0xff) }, 1133 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0010, 0xff, 0xff, 0xff) },
1132 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0011, 0xff, 0xff, 0xff) }, 1134 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0011, 0xff, 0xff, 0xff) },
1133 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0012, 0xff, 0xff, 0xff), 1135 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0012, 0xff, 0xff, 0xff),
1134 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1136 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1135 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0013, 0xff, 0xff, 0xff) }, 1137 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0013, 0xff, 0xff, 0xff) },
1136 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628, 0xff, 0xff, 0xff) }, 1138 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628, 0xff, 0xff, 0xff) },
1137 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0016, 0xff, 0xff, 0xff) }, 1139 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0016, 0xff, 0xff, 0xff) },
1138 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff), 1140 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff),
1139 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1141 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1140 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0018, 0xff, 0xff, 0xff) }, 1142 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0018, 0xff, 0xff, 0xff) },
1141 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0019, 0xff, 0xff, 0xff), 1143 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0019, 0xff, 0xff, 0xff),
1142 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1144 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1143 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0020, 0xff, 0xff, 0xff) }, 1145 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0020, 0xff, 0xff, 0xff) },
1144 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0021, 0xff, 0xff, 0xff), 1146 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0021, 0xff, 0xff, 0xff),
1145 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1147 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1146 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0022, 0xff, 0xff, 0xff) }, 1148 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0022, 0xff, 0xff, 0xff) },
1147 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0023, 0xff, 0xff, 0xff) }, 1149 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0023, 0xff, 0xff, 0xff) },
1148 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0024, 0xff, 0xff, 0xff) }, 1150 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0024, 0xff, 0xff, 0xff) },
1149 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0025, 0xff, 0xff, 0xff), 1151 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0025, 0xff, 0xff, 0xff),
1150 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1152 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1151 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0028, 0xff, 0xff, 0xff) }, 1153 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0028, 0xff, 0xff, 0xff) },
1152 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0029, 0xff, 0xff, 0xff) }, 1154 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0029, 0xff, 0xff, 0xff) },
1153 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0030, 0xff, 0xff, 0xff) }, 1155 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0030, 0xff, 0xff, 0xff) },
1154 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF626, 0xff, 1156 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF626, 0xff,
1155 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_mf626_blacklist }, 1157 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_mf626_blacklist },
1156 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0032, 0xff, 0xff, 0xff) }, 1158 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0032, 0xff, 0xff, 0xff) },
1157 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0033, 0xff, 0xff, 0xff) }, 1159 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0033, 0xff, 0xff, 0xff) },
1158 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0034, 0xff, 0xff, 0xff) }, 1160 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0034, 0xff, 0xff, 0xff) },
1159 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0037, 0xff, 0xff, 0xff), 1161 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0037, 0xff, 0xff, 0xff),
1160 .driver_info = (kernel_ulong_t)&zte_0037_blacklist }, 1162 .driver_info = (kernel_ulong_t)&zte_0037_blacklist },
1161 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0038, 0xff, 0xff, 0xff) }, 1163 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0038, 0xff, 0xff, 0xff) },
1162 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0039, 0xff, 0xff, 0xff) }, 1164 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0039, 0xff, 0xff, 0xff) },
1163 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0040, 0xff, 0xff, 0xff) }, 1165 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0040, 0xff, 0xff, 0xff) },
1164 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0042, 0xff, 0xff, 0xff), 1166 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0042, 0xff, 0xff, 0xff),
1165 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1167 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1166 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0043, 0xff, 0xff, 0xff) }, 1168 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0043, 0xff, 0xff, 0xff) },
1167 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0044, 0xff, 0xff, 0xff) }, 1169 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0044, 0xff, 0xff, 0xff) },
1168 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0048, 0xff, 0xff, 0xff) }, 1170 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0048, 0xff, 0xff, 0xff) },
1169 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0049, 0xff, 0xff, 0xff), 1171 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0049, 0xff, 0xff, 0xff),
1170 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1172 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1171 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0050, 0xff, 0xff, 0xff) }, 1173 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0050, 0xff, 0xff, 0xff) },
1172 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0051, 0xff, 0xff, 0xff) }, 1174 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0051, 0xff, 0xff, 0xff) },
1173 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0052, 0xff, 0xff, 0xff), 1175 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0052, 0xff, 0xff, 0xff),
1174 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1176 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1175 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0054, 0xff, 0xff, 0xff) }, 1177 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0054, 0xff, 0xff, 0xff) },
1176 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0055, 0xff, 0xff, 0xff), 1178 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0055, 0xff, 0xff, 0xff),
1177 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1179 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1178 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0056, 0xff, 0xff, 0xff) }, 1180 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0056, 0xff, 0xff, 0xff) },
1179 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0057, 0xff, 0xff, 0xff) }, 1181 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0057, 0xff, 0xff, 0xff) },
1180 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0058, 0xff, 0xff, 0xff), 1182 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0058, 0xff, 0xff, 0xff),
1181 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1183 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1182 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0061, 0xff, 0xff, 0xff) }, 1184 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0061, 0xff, 0xff, 0xff) },
1183 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0062, 0xff, 0xff, 0xff) }, 1185 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0062, 0xff, 0xff, 0xff) },
1184 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0063, 0xff, 0xff, 0xff), 1186 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0063, 0xff, 0xff, 0xff),
1185 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1187 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1186 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0064, 0xff, 0xff, 0xff) }, 1188 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0064, 0xff, 0xff, 0xff) },
1187 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0065, 0xff, 0xff, 0xff) }, 1189 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0065, 0xff, 0xff, 0xff) },
1188 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0066, 0xff, 0xff, 0xff) }, 1190 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0066, 0xff, 0xff, 0xff) },
1189 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0067, 0xff, 0xff, 0xff) }, 1191 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0067, 0xff, 0xff, 0xff) },
1190 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0069, 0xff, 0xff, 0xff) }, 1192 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0069, 0xff, 0xff, 0xff) },
1191 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0076, 0xff, 0xff, 0xff) }, 1193 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0076, 0xff, 0xff, 0xff) },
1192 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0077, 0xff, 0xff, 0xff) }, 1194 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0077, 0xff, 0xff, 0xff) },
1193 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0078, 0xff, 0xff, 0xff) }, 1195 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0078, 0xff, 0xff, 0xff) },
1194 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0079, 0xff, 0xff, 0xff) }, 1196 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0079, 0xff, 0xff, 0xff) },
1195 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0082, 0xff, 0xff, 0xff) }, 1197 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0082, 0xff, 0xff, 0xff) },
1196 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0083, 0xff, 0xff, 0xff) }, 1198 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0083, 0xff, 0xff, 0xff) },
1197 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0086, 0xff, 0xff, 0xff) }, 1199 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0086, 0xff, 0xff, 0xff) },
1198 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0087, 0xff, 0xff, 0xff) }, 1200 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0087, 0xff, 0xff, 0xff) },
1199 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0088, 0xff, 0xff, 0xff) }, 1201 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0088, 0xff, 0xff, 0xff) },
1200 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0089, 0xff, 0xff, 0xff) }, 1202 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0089, 0xff, 0xff, 0xff) },
1201 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0090, 0xff, 0xff, 0xff) }, 1203 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0090, 0xff, 0xff, 0xff) },
1202 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0091, 0xff, 0xff, 0xff) }, 1204 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0091, 0xff, 0xff, 0xff) },
1203 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0092, 0xff, 0xff, 0xff) }, 1205 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0092, 0xff, 0xff, 0xff) },
1204 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0093, 0xff, 0xff, 0xff) }, 1206 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0093, 0xff, 0xff, 0xff) },
1205 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) }, 1207 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) },
1206 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0095, 0xff, 0xff, 0xff) }, 1208 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0095, 0xff, 0xff, 0xff) },
1207 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0096, 0xff, 0xff, 0xff) }, 1209 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0096, 0xff, 0xff, 0xff) },
1208 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0097, 0xff, 0xff, 0xff) }, 1210 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0097, 0xff, 0xff, 0xff) },
1209 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0104, 0xff, 0xff, 0xff), 1211 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0104, 0xff, 0xff, 0xff),
1210 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1212 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1211 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0105, 0xff, 0xff, 0xff) }, 1213 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0105, 0xff, 0xff, 0xff) },
1212 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0106, 0xff, 0xff, 0xff) }, 1214 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0106, 0xff, 0xff, 0xff) },
1213 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0108, 0xff, 0xff, 0xff) }, 1215 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0108, 0xff, 0xff, 0xff) },
1214 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff), 1216 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff),
1215 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1217 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1216 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) }, 1218 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) },
1217 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff), 1219 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff),
1218 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1220 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1219 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff), 1221 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff),
1220 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1222 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1221 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) }, 1223 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) },
1222 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff), 1224 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff),
1223 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1225 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1224 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff), 1226 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff),
1225 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1227 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1226 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff), 1228 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff),
1227 .driver_info = (kernel_ulong_t)&net_intf6_blacklist }, 1229 .driver_info = (kernel_ulong_t)&net_intf6_blacklist },
1228 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff), 1230 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff),
1229 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1231 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1230 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) }, 1232 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) },
1231 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0135, 0xff, 0xff, 0xff) }, 1233 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0135, 0xff, 0xff, 0xff) },
1232 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0136, 0xff, 0xff, 0xff) }, 1234 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0136, 0xff, 0xff, 0xff) },
1233 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0137, 0xff, 0xff, 0xff) }, 1235 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0137, 0xff, 0xff, 0xff) },
1234 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0139, 0xff, 0xff, 0xff) }, 1236 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0139, 0xff, 0xff, 0xff) },
1235 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) }, 1237 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) },
1236 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, 1238 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) },
1237 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) }, 1239 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) },
1238 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0145, 0xff, 0xff, 0xff) }, 1240 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0145, 0xff, 0xff, 0xff) },
1239 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0148, 0xff, 0xff, 0xff) }, 1241 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0148, 0xff, 0xff, 0xff) },
1240 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0151, 0xff, 0xff, 0xff) }, 1242 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0151, 0xff, 0xff, 0xff) },
1241 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) }, 1243 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) },
1242 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) }, 1244 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) },
1243 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, 1245 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) },
1244 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff), 1246 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff),
1245 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1247 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1246 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff), 1248 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff),
1247 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1249 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1248 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, 1250 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) },
1249 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, 1251 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) },
1250 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) }, 1252 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) },
1251 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0164, 0xff, 0xff, 0xff) }, 1253 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0164, 0xff, 0xff, 0xff) },
1252 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, 1254 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
1253 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), 1255 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
1254 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1256 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1255 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0189, 0xff, 0xff, 0xff) }, 1257 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0189, 0xff, 0xff, 0xff) },
1256 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */ 1258 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */
1257 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1259 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1258 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0196, 0xff, 0xff, 0xff) }, 1260 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0196, 0xff, 0xff, 0xff) },
1259 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0197, 0xff, 0xff, 0xff) }, 1261 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0197, 0xff, 0xff, 0xff) },
1260 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */ 1262 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */
1261 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1263 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1262 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0200, 0xff, 0xff, 0xff) }, 1264 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0200, 0xff, 0xff, 0xff) },
1263 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0201, 0xff, 0xff, 0xff) }, 1265 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0201, 0xff, 0xff, 0xff) },
1264 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0254, 0xff, 0xff, 0xff) }, 1266 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0254, 0xff, 0xff, 0xff) },
1265 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */ 1267 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */
1266 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1268 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1267 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0265, 0xff, 0xff, 0xff), /* ONDA MT8205 */ 1269 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0265, 0xff, 0xff, 0xff), /* ONDA MT8205 */
1268 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1270 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1269 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0284, 0xff, 0xff, 0xff), /* ZTE MF880 */ 1271 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0284, 0xff, 0xff, 0xff), /* ZTE MF880 */
1270 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1272 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1271 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0317, 0xff, 0xff, 0xff) }, 1273 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0317, 0xff, 0xff, 0xff) },
1272 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff), 1274 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff),
1273 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1275 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1274 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0330, 0xff, 0xff, 0xff) }, 1276 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0330, 0xff, 0xff, 0xff) },
1275 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0395, 0xff, 0xff, 0xff) }, 1277 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0395, 0xff, 0xff, 0xff) },
1276 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0412, 0xff, 0xff, 0xff), /* Telewell TW-LTE 4G */ 1278 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0412, 0xff, 0xff, 0xff), /* Telewell TW-LTE 4G */
1277 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1279 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1278 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0414, 0xff, 0xff, 0xff) }, 1280 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0414, 0xff, 0xff, 0xff) },
1279 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0417, 0xff, 0xff, 0xff) }, 1281 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0417, 0xff, 0xff, 0xff) },
1280 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), 1282 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff),
1281 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1283 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1282 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), 1284 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
1283 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1285 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1284 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff), 1286 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff),
1285 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1287 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1286 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1018, 0xff, 0xff, 0xff) }, 1288 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1018, 0xff, 0xff, 0xff) },
1287 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff), 1289 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff),
1288 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1290 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1289 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, 1291 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) },
1290 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) }, 1292 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) },
1291 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) }, 1293 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) },
1292 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1060, 0xff, 0xff, 0xff) }, 1294 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1060, 0xff, 0xff, 0xff) },
1293 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1061, 0xff, 0xff, 0xff) }, 1295 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1061, 0xff, 0xff, 0xff) },
1294 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1062, 0xff, 0xff, 0xff) }, 1296 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1062, 0xff, 0xff, 0xff) },
1295 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1063, 0xff, 0xff, 0xff) }, 1297 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1063, 0xff, 0xff, 0xff) },
1296 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1064, 0xff, 0xff, 0xff) }, 1298 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1064, 0xff, 0xff, 0xff) },
1297 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1065, 0xff, 0xff, 0xff) }, 1299 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1065, 0xff, 0xff, 0xff) },
1298 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1066, 0xff, 0xff, 0xff) }, 1300 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1066, 0xff, 0xff, 0xff) },
1299 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1067, 0xff, 0xff, 0xff) }, 1301 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1067, 0xff, 0xff, 0xff) },
1300 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1068, 0xff, 0xff, 0xff) }, 1302 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1068, 0xff, 0xff, 0xff) },
1301 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1069, 0xff, 0xff, 0xff) }, 1303 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1069, 0xff, 0xff, 0xff) },
1302 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1070, 0xff, 0xff, 0xff) }, 1304 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1070, 0xff, 0xff, 0xff) },
1303 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1071, 0xff, 0xff, 0xff) }, 1305 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1071, 0xff, 0xff, 0xff) },
1304 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1072, 0xff, 0xff, 0xff) }, 1306 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1072, 0xff, 0xff, 0xff) },
1305 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1073, 0xff, 0xff, 0xff) }, 1307 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1073, 0xff, 0xff, 0xff) },
1306 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1074, 0xff, 0xff, 0xff) }, 1308 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1074, 0xff, 0xff, 0xff) },
1307 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1075, 0xff, 0xff, 0xff) }, 1309 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1075, 0xff, 0xff, 0xff) },
1308 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1076, 0xff, 0xff, 0xff) }, 1310 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1076, 0xff, 0xff, 0xff) },
1309 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1077, 0xff, 0xff, 0xff) }, 1311 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1077, 0xff, 0xff, 0xff) },
1310 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1078, 0xff, 0xff, 0xff) }, 1312 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1078, 0xff, 0xff, 0xff) },
1311 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1079, 0xff, 0xff, 0xff) }, 1313 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1079, 0xff, 0xff, 0xff) },
1312 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1080, 0xff, 0xff, 0xff) }, 1314 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1080, 0xff, 0xff, 0xff) },
1313 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1081, 0xff, 0xff, 0xff) }, 1315 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1081, 0xff, 0xff, 0xff) },
1314 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1082, 0xff, 0xff, 0xff) }, 1316 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1082, 0xff, 0xff, 0xff) },
1315 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1083, 0xff, 0xff, 0xff) }, 1317 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1083, 0xff, 0xff, 0xff) },
1316 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1084, 0xff, 0xff, 0xff) }, 1318 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1084, 0xff, 0xff, 0xff) },
1317 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1085, 0xff, 0xff, 0xff) }, 1319 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1085, 0xff, 0xff, 0xff) },
1318 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1086, 0xff, 0xff, 0xff) }, 1320 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1086, 0xff, 0xff, 0xff) },
1319 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1087, 0xff, 0xff, 0xff) }, 1321 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1087, 0xff, 0xff, 0xff) },
1320 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1088, 0xff, 0xff, 0xff) }, 1322 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1088, 0xff, 0xff, 0xff) },
1321 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1089, 0xff, 0xff, 0xff) }, 1323 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1089, 0xff, 0xff, 0xff) },
1322 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1090, 0xff, 0xff, 0xff) }, 1324 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1090, 0xff, 0xff, 0xff) },
1323 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1091, 0xff, 0xff, 0xff) }, 1325 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1091, 0xff, 0xff, 0xff) },
1324 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1092, 0xff, 0xff, 0xff) }, 1326 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1092, 0xff, 0xff, 0xff) },
1325 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1093, 0xff, 0xff, 0xff) }, 1327 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1093, 0xff, 0xff, 0xff) },
1326 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1094, 0xff, 0xff, 0xff) }, 1328 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1094, 0xff, 0xff, 0xff) },
1327 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1095, 0xff, 0xff, 0xff) }, 1329 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1095, 0xff, 0xff, 0xff) },
1328 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1096, 0xff, 0xff, 0xff) }, 1330 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1096, 0xff, 0xff, 0xff) },
1329 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1097, 0xff, 0xff, 0xff) }, 1331 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1097, 0xff, 0xff, 0xff) },
1330 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1098, 0xff, 0xff, 0xff) }, 1332 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1098, 0xff, 0xff, 0xff) },
1331 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1099, 0xff, 0xff, 0xff) }, 1333 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1099, 0xff, 0xff, 0xff) },
1332 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1100, 0xff, 0xff, 0xff) }, 1334 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1100, 0xff, 0xff, 0xff) },
1333 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1101, 0xff, 0xff, 0xff) }, 1335 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1101, 0xff, 0xff, 0xff) },
1334 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1102, 0xff, 0xff, 0xff) }, 1336 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1102, 0xff, 0xff, 0xff) },
1335 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1103, 0xff, 0xff, 0xff) }, 1337 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1103, 0xff, 0xff, 0xff) },
1336 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1104, 0xff, 0xff, 0xff) }, 1338 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1104, 0xff, 0xff, 0xff) },
1337 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1105, 0xff, 0xff, 0xff) }, 1339 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1105, 0xff, 0xff, 0xff) },
1338 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1106, 0xff, 0xff, 0xff) }, 1340 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1106, 0xff, 0xff, 0xff) },
1339 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1107, 0xff, 0xff, 0xff) }, 1341 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1107, 0xff, 0xff, 0xff) },
1340 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1108, 0xff, 0xff, 0xff) }, 1342 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1108, 0xff, 0xff, 0xff) },
1341 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1109, 0xff, 0xff, 0xff) }, 1343 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1109, 0xff, 0xff, 0xff) },
1342 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1110, 0xff, 0xff, 0xff) }, 1344 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1110, 0xff, 0xff, 0xff) },
1343 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1111, 0xff, 0xff, 0xff) }, 1345 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1111, 0xff, 0xff, 0xff) },
1344 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1112, 0xff, 0xff, 0xff) }, 1346 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1112, 0xff, 0xff, 0xff) },
1345 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1113, 0xff, 0xff, 0xff) }, 1347 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1113, 0xff, 0xff, 0xff) },
1346 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1114, 0xff, 0xff, 0xff) }, 1348 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1114, 0xff, 0xff, 0xff) },
1347 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1115, 0xff, 0xff, 0xff) }, 1349 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1115, 0xff, 0xff, 0xff) },
1348 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1116, 0xff, 0xff, 0xff) }, 1350 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1116, 0xff, 0xff, 0xff) },
1349 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1117, 0xff, 0xff, 0xff) }, 1351 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1117, 0xff, 0xff, 0xff) },
1350 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1118, 0xff, 0xff, 0xff) }, 1352 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1118, 0xff, 0xff, 0xff) },
1351 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1119, 0xff, 0xff, 0xff) }, 1353 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1119, 0xff, 0xff, 0xff) },
1352 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1120, 0xff, 0xff, 0xff) }, 1354 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1120, 0xff, 0xff, 0xff) },
1353 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1121, 0xff, 0xff, 0xff) }, 1355 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1121, 0xff, 0xff, 0xff) },
1354 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1122, 0xff, 0xff, 0xff) }, 1356 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1122, 0xff, 0xff, 0xff) },
1355 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1123, 0xff, 0xff, 0xff) }, 1357 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1123, 0xff, 0xff, 0xff) },
1356 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1124, 0xff, 0xff, 0xff) }, 1358 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1124, 0xff, 0xff, 0xff) },
1357 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1125, 0xff, 0xff, 0xff) }, 1359 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1125, 0xff, 0xff, 0xff) },
1358 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1126, 0xff, 0xff, 0xff) }, 1360 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1126, 0xff, 0xff, 0xff) },
1359 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1127, 0xff, 0xff, 0xff) }, 1361 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1127, 0xff, 0xff, 0xff) },
1360 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1128, 0xff, 0xff, 0xff) }, 1362 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1128, 0xff, 0xff, 0xff) },
1361 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1129, 0xff, 0xff, 0xff) }, 1363 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1129, 0xff, 0xff, 0xff) },
1362 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1130, 0xff, 0xff, 0xff) }, 1364 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1130, 0xff, 0xff, 0xff) },
1363 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1131, 0xff, 0xff, 0xff) }, 1365 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1131, 0xff, 0xff, 0xff) },
1364 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1132, 0xff, 0xff, 0xff) }, 1366 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1132, 0xff, 0xff, 0xff) },
1365 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1133, 0xff, 0xff, 0xff) }, 1367 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1133, 0xff, 0xff, 0xff) },
1366 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1134, 0xff, 0xff, 0xff) }, 1368 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1134, 0xff, 0xff, 0xff) },
1367 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1135, 0xff, 0xff, 0xff) }, 1369 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1135, 0xff, 0xff, 0xff) },
1368 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1136, 0xff, 0xff, 0xff) }, 1370 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1136, 0xff, 0xff, 0xff) },
1369 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1137, 0xff, 0xff, 0xff) }, 1371 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1137, 0xff, 0xff, 0xff) },
1370 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1138, 0xff, 0xff, 0xff) }, 1372 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1138, 0xff, 0xff, 0xff) },
1371 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1139, 0xff, 0xff, 0xff) }, 1373 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1139, 0xff, 0xff, 0xff) },
1372 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1140, 0xff, 0xff, 0xff) }, 1374 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1140, 0xff, 0xff, 0xff) },
1373 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1141, 0xff, 0xff, 0xff) }, 1375 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1141, 0xff, 0xff, 0xff) },
1374 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1142, 0xff, 0xff, 0xff) }, 1376 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1142, 0xff, 0xff, 0xff) },
1375 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1143, 0xff, 0xff, 0xff) }, 1377 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1143, 0xff, 0xff, 0xff) },
1376 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1144, 0xff, 0xff, 0xff) }, 1378 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1144, 0xff, 0xff, 0xff) },
1377 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1145, 0xff, 0xff, 0xff) }, 1379 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1145, 0xff, 0xff, 0xff) },
1378 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1146, 0xff, 0xff, 0xff) }, 1380 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1146, 0xff, 0xff, 0xff) },
1379 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1147, 0xff, 0xff, 0xff) }, 1381 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1147, 0xff, 0xff, 0xff) },
1380 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1148, 0xff, 0xff, 0xff) }, 1382 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1148, 0xff, 0xff, 0xff) },
1381 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1149, 0xff, 0xff, 0xff) }, 1383 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1149, 0xff, 0xff, 0xff) },
1382 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1150, 0xff, 0xff, 0xff) }, 1384 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1150, 0xff, 0xff, 0xff) },
1383 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1151, 0xff, 0xff, 0xff) }, 1385 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1151, 0xff, 0xff, 0xff) },
1384 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1152, 0xff, 0xff, 0xff) }, 1386 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1152, 0xff, 0xff, 0xff) },
1385 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1153, 0xff, 0xff, 0xff) }, 1387 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1153, 0xff, 0xff, 0xff) },
1386 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1154, 0xff, 0xff, 0xff) }, 1388 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1154, 0xff, 0xff, 0xff) },
1387 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1155, 0xff, 0xff, 0xff) }, 1389 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1155, 0xff, 0xff, 0xff) },
1388 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1156, 0xff, 0xff, 0xff) }, 1390 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1156, 0xff, 0xff, 0xff) },
1389 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1157, 0xff, 0xff, 0xff) }, 1391 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1157, 0xff, 0xff, 0xff) },
1390 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1158, 0xff, 0xff, 0xff) }, 1392 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1158, 0xff, 0xff, 0xff) },
1391 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1159, 0xff, 0xff, 0xff) }, 1393 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1159, 0xff, 0xff, 0xff) },
1392 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1160, 0xff, 0xff, 0xff) }, 1394 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1160, 0xff, 0xff, 0xff) },
1393 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1161, 0xff, 0xff, 0xff) }, 1395 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1161, 0xff, 0xff, 0xff) },
1394 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1162, 0xff, 0xff, 0xff) }, 1396 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1162, 0xff, 0xff, 0xff) },
1395 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1163, 0xff, 0xff, 0xff) }, 1397 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1163, 0xff, 0xff, 0xff) },
1396 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1164, 0xff, 0xff, 0xff) }, 1398 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1164, 0xff, 0xff, 0xff) },
1397 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1165, 0xff, 0xff, 0xff) }, 1399 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1165, 0xff, 0xff, 0xff) },
1398 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1166, 0xff, 0xff, 0xff) }, 1400 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1166, 0xff, 0xff, 0xff) },
1399 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1167, 0xff, 0xff, 0xff) }, 1401 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1167, 0xff, 0xff, 0xff) },
1400 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1168, 0xff, 0xff, 0xff) }, 1402 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1168, 0xff, 0xff, 0xff) },
1401 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) }, 1403 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) },
1402 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) }, 1404 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) },
1403 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) }, 1405 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) },
1404 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff), 1406 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff),
1405 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1407 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1406 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) }, 1408 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) },
1407 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff), 1409 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff),
1408 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1410 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1409 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) }, 1411 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) },
1410 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) }, 1412 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) },
1411 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) }, 1413 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) },
1412 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) }, 1414 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) },
1413 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff), 1415 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff),
1414 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1416 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1415 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) }, 1417 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) },
1416 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff), 1418 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff),
1417 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1419 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1418 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff), 1420 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff),
1419 .driver_info = (kernel_ulong_t)&zte_1255_blacklist }, 1421 .driver_info = (kernel_ulong_t)&zte_1255_blacklist },
1420 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff), 1422 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff),
1421 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1423 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1422 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) }, 1424 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) },
1423 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) }, 1425 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) },
1424 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) }, 1426 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) },
1425 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1260, 0xff, 0xff, 0xff) }, 1427 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1260, 0xff, 0xff, 0xff) },
1426 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1261, 0xff, 0xff, 0xff) }, 1428 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1261, 0xff, 0xff, 0xff) },
1427 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1262, 0xff, 0xff, 0xff) }, 1429 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1262, 0xff, 0xff, 0xff) },
1428 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1263, 0xff, 0xff, 0xff) }, 1430 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1263, 0xff, 0xff, 0xff) },
1429 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1264, 0xff, 0xff, 0xff) }, 1431 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1264, 0xff, 0xff, 0xff) },
1430 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1265, 0xff, 0xff, 0xff) }, 1432 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1265, 0xff, 0xff, 0xff) },
1431 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1266, 0xff, 0xff, 0xff) }, 1433 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1266, 0xff, 0xff, 0xff) },
1432 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1267, 0xff, 0xff, 0xff) }, 1434 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1267, 0xff, 0xff, 0xff) },
1433 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1268, 0xff, 0xff, 0xff) }, 1435 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1268, 0xff, 0xff, 0xff) },
1434 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1269, 0xff, 0xff, 0xff) }, 1436 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1269, 0xff, 0xff, 0xff) },
1435 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1270, 0xff, 0xff, 0xff), 1437 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1270, 0xff, 0xff, 0xff),
1436 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1438 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1437 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1271, 0xff, 0xff, 0xff) }, 1439 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1271, 0xff, 0xff, 0xff) },
1438 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1272, 0xff, 0xff, 0xff) }, 1440 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1272, 0xff, 0xff, 0xff) },
1439 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1273, 0xff, 0xff, 0xff) }, 1441 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1273, 0xff, 0xff, 0xff) },
1440 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1274, 0xff, 0xff, 0xff) }, 1442 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1274, 0xff, 0xff, 0xff) },
1441 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1275, 0xff, 0xff, 0xff) }, 1443 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1275, 0xff, 0xff, 0xff) },
1442 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1276, 0xff, 0xff, 0xff) }, 1444 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1276, 0xff, 0xff, 0xff) },
1443 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1277, 0xff, 0xff, 0xff) }, 1445 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1277, 0xff, 0xff, 0xff) },
1444 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1278, 0xff, 0xff, 0xff) }, 1446 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1278, 0xff, 0xff, 0xff) },
1445 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1279, 0xff, 0xff, 0xff) }, 1447 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1279, 0xff, 0xff, 0xff) },
1446 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1280, 0xff, 0xff, 0xff) }, 1448 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1280, 0xff, 0xff, 0xff) },
1447 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1281, 0xff, 0xff, 0xff) }, 1449 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1281, 0xff, 0xff, 0xff) },
1448 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1282, 0xff, 0xff, 0xff) }, 1450 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1282, 0xff, 0xff, 0xff) },
1449 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1283, 0xff, 0xff, 0xff) }, 1451 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1283, 0xff, 0xff, 0xff) },
1450 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1284, 0xff, 0xff, 0xff) }, 1452 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1284, 0xff, 0xff, 0xff) },
1451 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1285, 0xff, 0xff, 0xff) }, 1453 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1285, 0xff, 0xff, 0xff) },
1452 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1286, 0xff, 0xff, 0xff) }, 1454 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1286, 0xff, 0xff, 0xff) },
1453 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1287, 0xff, 0xff, 0xff) }, 1455 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1287, 0xff, 0xff, 0xff) },
1454 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1288, 0xff, 0xff, 0xff) }, 1456 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1288, 0xff, 0xff, 0xff) },
1455 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1289, 0xff, 0xff, 0xff) }, 1457 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1289, 0xff, 0xff, 0xff) },
1456 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1290, 0xff, 0xff, 0xff) }, 1458 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1290, 0xff, 0xff, 0xff) },
1457 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1291, 0xff, 0xff, 0xff) }, 1459 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1291, 0xff, 0xff, 0xff) },
1458 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1292, 0xff, 0xff, 0xff) }, 1460 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1292, 0xff, 0xff, 0xff) },
1459 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1293, 0xff, 0xff, 0xff) }, 1461 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1293, 0xff, 0xff, 0xff) },
1460 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1294, 0xff, 0xff, 0xff) }, 1462 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1294, 0xff, 0xff, 0xff) },
1461 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1295, 0xff, 0xff, 0xff) }, 1463 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1295, 0xff, 0xff, 0xff) },
1462 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1296, 0xff, 0xff, 0xff) }, 1464 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1296, 0xff, 0xff, 0xff) },
1463 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1297, 0xff, 0xff, 0xff) }, 1465 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1297, 0xff, 0xff, 0xff) },
1464 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, 1466 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) },
1465 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, 1467 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) },
1466 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, 1468 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) },
1467 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1301, 0xff, 0xff, 0xff) }, 1469 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1301, 0xff, 0xff, 0xff) },
1468 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1302, 0xff, 0xff, 0xff) }, 1470 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1302, 0xff, 0xff, 0xff) },
1469 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1303, 0xff, 0xff, 0xff) }, 1471 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1303, 0xff, 0xff, 0xff) },
1470 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1333, 0xff, 0xff, 0xff) }, 1472 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1333, 0xff, 0xff, 0xff) },
1471 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff), 1473 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff),
1472 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1474 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1473 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff), 1475 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff),
1474 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1476 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1475 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1424, 0xff, 0xff, 0xff), 1477 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1424, 0xff, 0xff, 0xff),
1476 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1478 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1477 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff, 0xff), 1479 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff, 0xff),
1478 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1480 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1479 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */ 1481 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */
1480 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1482 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1481 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1533, 0xff, 0xff, 0xff) }, 1483 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1533, 0xff, 0xff, 0xff) },
1482 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1534, 0xff, 0xff, 0xff) }, 1484 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1534, 0xff, 0xff, 0xff) },
1483 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1535, 0xff, 0xff, 0xff) }, 1485 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1535, 0xff, 0xff, 0xff) },
1484 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1545, 0xff, 0xff, 0xff) }, 1486 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1545, 0xff, 0xff, 0xff) },
1485 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1546, 0xff, 0xff, 0xff) }, 1487 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1546, 0xff, 0xff, 0xff) },
1486 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1547, 0xff, 0xff, 0xff) }, 1488 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1547, 0xff, 0xff, 0xff) },
1487 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1565, 0xff, 0xff, 0xff) }, 1489 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1565, 0xff, 0xff, 0xff) },
1488 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1566, 0xff, 0xff, 0xff) }, 1490 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1566, 0xff, 0xff, 0xff) },
1489 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1567, 0xff, 0xff, 0xff) }, 1491 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1567, 0xff, 0xff, 0xff) },
1490 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1589, 0xff, 0xff, 0xff) }, 1492 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1589, 0xff, 0xff, 0xff) },
1491 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1590, 0xff, 0xff, 0xff) }, 1493 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1590, 0xff, 0xff, 0xff) },
1492 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1591, 0xff, 0xff, 0xff) }, 1494 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1591, 0xff, 0xff, 0xff) },
1493 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1592, 0xff, 0xff, 0xff) }, 1495 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1592, 0xff, 0xff, 0xff) },
1494 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1594, 0xff, 0xff, 0xff) }, 1496 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1594, 0xff, 0xff, 0xff) },
1495 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1596, 0xff, 0xff, 0xff) }, 1497 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1596, 0xff, 0xff, 0xff) },
1496 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1598, 0xff, 0xff, 0xff) }, 1498 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1598, 0xff, 0xff, 0xff) },
1497 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1600, 0xff, 0xff, 0xff) }, 1499 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1600, 0xff, 0xff, 0xff) },
1498 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 1500 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff,
1499 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist }, 1501 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist },
1500 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) }, 1502 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
1501 1503
1502 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) }, /* ZTE CDMA products */ 1504 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) }, /* ZTE CDMA products */
1503 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0027, 0xff, 0xff, 0xff) }, 1505 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0027, 0xff, 0xff, 0xff) },
1504 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) }, 1506 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) },
1505 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0060, 0xff, 0xff, 0xff) }, 1507 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0060, 0xff, 0xff, 0xff) },
1506 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) }, 1508 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
1507 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, 1509 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
1508 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) }, 1510 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) },
1509 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff), 1511 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff),
1510 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1512 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1511 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff), 1513 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff),
1512 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1514 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1513 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff), 1515 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff),
1514 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1516 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1515 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) }, 1517 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) },
1516 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) }, 1518 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) },
1517 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff), 1519 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff),
1518 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1520 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1519 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) }, 1521 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) },
1520 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff), 1522 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff),
1521 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1523 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1522 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff), 1524 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff),
1523 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1525 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1524 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) }, 1526 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) },
1525 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) }, 1527 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) },
1526 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) }, 1528 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) },
1527 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) }, 1529 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) },
1528 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8e, 0xff, 0xff, 0xff) }, 1530 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8e, 0xff, 0xff, 0xff) },
1529 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8f, 0xff, 0xff, 0xff) }, 1531 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8f, 0xff, 0xff, 0xff) },
1530 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff90, 0xff, 0xff, 0xff) }, 1532 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff90, 0xff, 0xff, 0xff) },
1531 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff91, 0xff, 0xff, 0xff) }, 1533 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff91, 0xff, 0xff, 0xff) },
1532 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) }, 1534 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) },
1533 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) }, 1535 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) },
1534 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) }, 1536 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) },
1535 1537
1536 /* NOTE: most ZTE CDMA devices should be driven by zte_ev, not option */ 1538 /* NOTE: most ZTE CDMA devices should be driven by zte_ev, not option */
1537 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff), 1539 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff),
1538 .driver_info = (kernel_ulong_t)&zte_mc2718_z_blacklist }, 1540 .driver_info = (kernel_ulong_t)&zte_mc2718_z_blacklist },
1539 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) }, 1541 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) },
1540 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) }, 1542 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
1541 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) }, 1543 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
1542 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, 1544 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
1543 1545
1544 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 1546 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
1545 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 1547 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
1546 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */ 1548 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */
1547 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) }, 1549 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
1548 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, 1550 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
1549 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) }, 1551 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
1550 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) }, 1552 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
1551 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4518) }, 1553 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4518) },
1552 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4519) }, 1554 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4519) },
1553 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) }, 1555 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) },
1554 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */ 1556 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */
1555 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) }, 1557 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) },
1556 { USB_DEVICE(ALINK_VENDOR_ID, ALINK_PRODUCT_PH300) }, 1558 { USB_DEVICE(ALINK_VENDOR_ID, ALINK_PRODUCT_PH300) },
1557 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) }, 1559 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) },
1558 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200), 1560 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200),
1559 .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist 1561 .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist
1560 }, 1562 },
1561 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D), 1563 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D),
1562 .driver_info = (kernel_ulong_t)&net_intf6_blacklist }, 1564 .driver_info = (kernel_ulong_t)&net_intf6_blacklist },
1563 { USB_DEVICE(ALCATEL_VENDOR_ID, 0x0052), 1565 { USB_DEVICE(ALCATEL_VENDOR_ID, 0x0052),
1564 .driver_info = (kernel_ulong_t)&net_intf6_blacklist }, 1566 .driver_info = (kernel_ulong_t)&net_intf6_blacklist },
1565 { USB_DEVICE(ALCATEL_VENDOR_ID, 0x00b6), 1567 { USB_DEVICE(ALCATEL_VENDOR_ID, 0x00b6),
1566 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1568 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1567 { USB_DEVICE(ALCATEL_VENDOR_ID, 0x00b7), 1569 { USB_DEVICE(ALCATEL_VENDOR_ID, 0x00b7),
1568 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1570 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1569 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L100V), 1571 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L100V),
1570 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1572 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1571 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L800MA), 1573 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L800MA),
1572 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1574 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1573 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 1575 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
1574 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, 1576 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
1575 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), 1577 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14),
1576 .driver_info = (kernel_ulong_t)&four_g_w14_blacklist 1578 .driver_info = (kernel_ulong_t)&four_g_w14_blacklist
1577 }, 1579 },
1578 { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, 1580 { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) },
1579 { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) }, 1581 { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) },
1580 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, 1582 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
1581 /* Pirelli */ 1583 /* Pirelli */
1582 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) }, 1584 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) },
1583 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) }, 1585 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) },
1584 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004, 0xff) }, 1586 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004, 0xff) },
1585 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005, 0xff) }, 1587 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005, 0xff) },
1586 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006, 0xff) }, 1588 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006, 0xff) },
1587 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007, 0xff) }, 1589 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007, 0xff) },
1588 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008, 0xff) }, 1590 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008, 0xff) },
1589 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009, 0xff) }, 1591 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009, 0xff) },
1590 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A, 0xff) }, 1592 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A, 0xff) },
1591 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B, 0xff) }, 1593 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B, 0xff) },
1592 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C, 0xff) }, 1594 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C, 0xff) },
1593 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D, 0xff) }, 1595 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D, 0xff) },
1594 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E, 0xff) }, 1596 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E, 0xff) },
1595 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F, 0xff) }, 1597 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F, 0xff) },
1596 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011, 0xff) }, 1598 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011, 0xff) },
1597 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012, 0xff) }, 1599 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012, 0xff) },
1598 /* Cinterion */ 1600 /* Cinterion */
1599 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) }, 1601 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) },
1600 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, 1602 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) },
1601 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8), 1603 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8),
1602 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1604 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1603 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) }, 1605 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) },
1604 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX), 1606 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX),
1605 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1607 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1606 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, 1608 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
1607 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) }, 1609 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
1608 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) }, 1610 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) },
1609 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) }, 1611 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) },
1610 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, /* HC28 enumerates with Siemens or Cinterion VID depending on FW revision */ 1612 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, /* HC28 enumerates with Siemens or Cinterion VID depending on FW revision */
1611 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) }, 1613 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
1612 1614
1613 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, 1615 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
1614 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) }, 1616 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) },
1615 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200), 1617 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200),
1616 .driver_info = (kernel_ulong_t)&net_intf6_blacklist 1618 .driver_info = (kernel_ulong_t)&net_intf6_blacklist
1617 }, 1619 },
1618 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD500), 1620 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD500),
1619 .driver_info = (kernel_ulong_t)&net_intf4_blacklist 1621 .driver_info = (kernel_ulong_t)&net_intf4_blacklist
1620 }, 1622 },
1621 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ 1623 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
1622 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/ 1624 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
1623 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) }, 1625 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) },
1624 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM610) }, 1626 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM610) },
1625 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM500) }, 1627 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM500) },
1626 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM510) }, 1628 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM510) },
1627 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM800) }, 1629 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM800) },
1628 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM900) }, 1630 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM900) },
1629 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU818) }, 1631 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU818) },
1630 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU816) }, 1632 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU816) },
1631 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU828) }, 1633 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU828) },
1632 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU826) }, 1634 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU826) },
1633 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU518) }, 1635 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU518) },
1634 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU516) }, 1636 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU516) },
1635 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU528) }, 1637 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU528) },
1636 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU526) }, 1638 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU526) },
1637 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM600) }, 1639 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM600) },
1638 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM610) }, 1640 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM610) },
1639 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM500) }, 1641 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM500) },
1640 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM510) }, 1642 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM510) },
1641 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM800) }, 1643 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM800) },
1642 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM900) }, 1644 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWM900) },
1643 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU718) }, 1645 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU718) },
1644 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU716) }, 1646 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU716) },
1645 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU728) }, 1647 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU728) },
1646 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU726) }, 1648 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU726) },
1647 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU518) }, 1649 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU518) },
1648 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU516) }, 1650 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU516) },
1649 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU528) }, 1651 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU528) },
1650 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU526) }, 1652 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU526) },
1651 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM600) }, 1653 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM600) },
1652 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM610) }, 1654 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM610) },
1653 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM500) }, 1655 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM500) },
1654 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM510) }, 1656 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM510) },
1655 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM800) }, 1657 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM800) },
1656 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM900) }, 1658 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLM900) },
1657 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU718) }, 1659 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU718) },
1658 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU716) }, 1660 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU716) },
1659 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU728) }, 1661 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU728) },
1660 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU726) }, 1662 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU726) },
1661 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU518) }, 1663 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU518) },
1662 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU516) }, 1664 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU516) },
1663 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU528) }, 1665 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU528) },
1664 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) }, 1666 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) },
1665 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU881) }, 1667 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU881) },
1666 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU882) }, 1668 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEU882) },
1667 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU581) }, 1669 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU581) },
1668 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU582) }, 1670 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU582) },
1669 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU583) }, 1671 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CWU583) },
1670 { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) }, 1672 { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) },
1671 { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) }, 1673 { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) },
1672 { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */ 1674 { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */
1673 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x00, 0x00) }, 1675 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x00, 0x00) },
1674 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x02, 0x01) }, 1676 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x02, 0x01) },
1675 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x00, 0x00) }, 1677 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x00, 0x00) },
1676 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x02, 0x01) }, /* MediaTek MT6276M modem & app port */ 1678 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x02, 0x01) }, /* MediaTek MT6276M modem & app port */
1677 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_1COM, 0x0a, 0x00, 0x00) }, 1679 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_1COM, 0x0a, 0x00, 0x00) },
1678 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_5COM, 0xff, 0x02, 0x01) }, 1680 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_5COM, 0xff, 0x02, 0x01) },
1679 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_5COM, 0xff, 0x00, 0x00) }, 1681 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_5COM, 0xff, 0x00, 0x00) },
1680 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM, 0xff, 0x02, 0x01) }, 1682 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM, 0xff, 0x02, 0x01) },
1681 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM, 0xff, 0x00, 0x00) }, 1683 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM, 0xff, 0x00, 0x00) },
1682 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7208_1COM, 0x02, 0x00, 0x00) }, 1684 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7208_1COM, 0x02, 0x00, 0x00) },
1683 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7208_2COM, 0x02, 0x02, 0x01) }, 1685 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7208_2COM, 0x02, 0x02, 0x01) },
1684 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_1COM, 0x0a, 0x00, 0x00) }, 1686 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_1COM, 0x0a, 0x00, 0x00) },
1685 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_2COM, 0x0a, 0x00, 0x00) }, 1687 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_2COM, 0x0a, 0x00, 0x00) },
1686 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_1COM, 0x0a, 0x00, 0x00) }, 1688 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_1COM, 0x0a, 0x00, 0x00) },
1687 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_2COM, 0x0a, 0x00, 0x00) }, 1689 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_2COM, 0x0a, 0x00, 0x00) },
1688 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7103_2COM, 0xff, 0x00, 0x00) }, 1690 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7103_2COM, 0xff, 0x00, 0x00) },
1689 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7106_2COM, 0x02, 0x02, 0x01) }, 1691 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7106_2COM, 0x02, 0x02, 0x01) },
1690 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x02, 0x01) }, 1692 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x02, 0x01) },
1691 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x00, 0x00) }, 1693 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x00, 0x00) },
1692 { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) }, 1694 { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) },
1693 { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600A) }, 1695 { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600A) },
1694 { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600E) }, 1696 { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600E) },
1695 { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180), 1697 { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180),
1696 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1698 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1697 { USB_DEVICE(TPLINK_VENDOR_ID, 0x9000), /* TP-Link MA260 */ 1699 { USB_DEVICE(TPLINK_VENDOR_ID, 0x9000), /* TP-Link MA260 */
1698 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1700 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1699 { USB_DEVICE(CHANGHONG_VENDOR_ID, CHANGHONG_PRODUCT_CH690) }, 1701 { USB_DEVICE(CHANGHONG_VENDOR_ID, CHANGHONG_PRODUCT_CH690) },
1700 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x02, 0x01) }, /* D-Link DWM-156 (variant) */ 1702 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x02, 0x01) }, /* D-Link DWM-156 (variant) */
1701 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x00, 0x00) }, /* D-Link DWM-156 (variant) */ 1703 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x00, 0x00) }, /* D-Link DWM-156 (variant) */
1702 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x02, 0x01) }, 1704 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x02, 0x01) },
1703 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) }, 1705 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) },
1704 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) }, 1706 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) },
1705 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) }, 1707 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
1706 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ 1708 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
1707 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ 1709 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
1708 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, 1710 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
1709 { } /* Terminating entry */ 1711 { } /* Terminating entry */
1710 }; 1712 };
1711 MODULE_DEVICE_TABLE(usb, option_ids); 1713 MODULE_DEVICE_TABLE(usb, option_ids);
1712 1714
1713 /* The card has three separate interfaces, which the serial driver 1715 /* The card has three separate interfaces, which the serial driver
1714 * recognizes separately, thus num_port=1. 1716 * recognizes separately, thus num_port=1.
1715 */ 1717 */
1716 1718
1717 static struct usb_serial_driver option_1port_device = { 1719 static struct usb_serial_driver option_1port_device = {
1718 .driver = { 1720 .driver = {
1719 .owner = THIS_MODULE, 1721 .owner = THIS_MODULE,
1720 .name = "option1", 1722 .name = "option1",
1721 }, 1723 },
1722 .description = "GSM modem (1-port)", 1724 .description = "GSM modem (1-port)",
1723 .id_table = option_ids, 1725 .id_table = option_ids,
1724 .num_ports = 1, 1726 .num_ports = 1,
1725 .probe = option_probe, 1727 .probe = option_probe,
1726 .open = usb_wwan_open, 1728 .open = usb_wwan_open,
1727 .close = usb_wwan_close, 1729 .close = usb_wwan_close,
1728 .dtr_rts = usb_wwan_dtr_rts, 1730 .dtr_rts = usb_wwan_dtr_rts,
1729 .write = usb_wwan_write, 1731 .write = usb_wwan_write,
1730 .write_room = usb_wwan_write_room, 1732 .write_room = usb_wwan_write_room,
1731 .chars_in_buffer = usb_wwan_chars_in_buffer, 1733 .chars_in_buffer = usb_wwan_chars_in_buffer,
1732 .set_termios = usb_wwan_set_termios, 1734 .set_termios = usb_wwan_set_termios,
1733 .tiocmget = usb_wwan_tiocmget, 1735 .tiocmget = usb_wwan_tiocmget,
1734 .tiocmset = usb_wwan_tiocmset, 1736 .tiocmset = usb_wwan_tiocmset,
1735 .ioctl = usb_wwan_ioctl, 1737 .ioctl = usb_wwan_ioctl,
1736 .attach = option_attach, 1738 .attach = option_attach,
1737 .release = option_release, 1739 .release = option_release,
1738 .port_probe = usb_wwan_port_probe, 1740 .port_probe = usb_wwan_port_probe,
1739 .port_remove = usb_wwan_port_remove, 1741 .port_remove = usb_wwan_port_remove,
1740 .read_int_callback = option_instat_callback, 1742 .read_int_callback = option_instat_callback,
1741 #ifdef CONFIG_PM 1743 #ifdef CONFIG_PM
1742 .suspend = usb_wwan_suspend, 1744 .suspend = usb_wwan_suspend,
1743 .resume = usb_wwan_resume, 1745 .resume = usb_wwan_resume,
1744 #endif 1746 #endif
1745 }; 1747 };
1746 1748
1747 static struct usb_serial_driver * const serial_drivers[] = { 1749 static struct usb_serial_driver * const serial_drivers[] = {
1748 &option_1port_device, NULL 1750 &option_1port_device, NULL
1749 }; 1751 };
1750 1752
1751 struct option_private { 1753 struct option_private {
1752 u8 bInterfaceNumber; 1754 u8 bInterfaceNumber;
1753 }; 1755 };
1754 1756
1755 module_usb_serial_driver(serial_drivers, option_ids); 1757 module_usb_serial_driver(serial_drivers, option_ids);
1756 1758
1757 static bool is_blacklisted(const u8 ifnum, enum option_blacklist_reason reason, 1759 static bool is_blacklisted(const u8 ifnum, enum option_blacklist_reason reason,
1758 const struct option_blacklist_info *blacklist) 1760 const struct option_blacklist_info *blacklist)
1759 { 1761 {
1760 unsigned long num; 1762 unsigned long num;
1761 const unsigned long *intf_list; 1763 const unsigned long *intf_list;
1762 1764
1763 if (blacklist) { 1765 if (blacklist) {
1764 if (reason == OPTION_BLACKLIST_SENDSETUP) 1766 if (reason == OPTION_BLACKLIST_SENDSETUP)
1765 intf_list = &blacklist->sendsetup; 1767 intf_list = &blacklist->sendsetup;
1766 else if (reason == OPTION_BLACKLIST_RESERVED_IF) 1768 else if (reason == OPTION_BLACKLIST_RESERVED_IF)
1767 intf_list = &blacklist->reserved; 1769 intf_list = &blacklist->reserved;
1768 else { 1770 else {
1769 BUG_ON(reason); 1771 BUG_ON(reason);
1770 return false; 1772 return false;
1771 } 1773 }
1772 1774
1773 for_each_set_bit(num, intf_list, MAX_BL_NUM + 1) { 1775 for_each_set_bit(num, intf_list, MAX_BL_NUM + 1) {
1774 if (num == ifnum) 1776 if (num == ifnum)
1775 return true; 1777 return true;
1776 } 1778 }
1777 } 1779 }
1778 return false; 1780 return false;
1779 } 1781 }
1780 1782
1781 static int option_probe(struct usb_serial *serial, 1783 static int option_probe(struct usb_serial *serial,
1782 const struct usb_device_id *id) 1784 const struct usb_device_id *id)
1783 { 1785 {
1784 struct usb_interface_descriptor *iface_desc = 1786 struct usb_interface_descriptor *iface_desc =
1785 &serial->interface->cur_altsetting->desc; 1787 &serial->interface->cur_altsetting->desc;
1786 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; 1788 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
1787 1789
1788 /* Never bind to the CD-Rom emulation interface */ 1790 /* Never bind to the CD-Rom emulation interface */
1789 if (iface_desc->bInterfaceClass == 0x08) 1791 if (iface_desc->bInterfaceClass == 0x08)
1790 return -ENODEV; 1792 return -ENODEV;
1791 1793
1792 /* 1794 /*
1793 * Don't bind reserved interfaces (like network ones) which often have 1795 * Don't bind reserved interfaces (like network ones) which often have
1794 * the same class/subclass/protocol as the serial interfaces. Look at 1796 * the same class/subclass/protocol as the serial interfaces. Look at
1795 * the Windows driver .INF files for reserved interface numbers. 1797 * the Windows driver .INF files for reserved interface numbers.
1796 */ 1798 */
1797 if (is_blacklisted( 1799 if (is_blacklisted(
1798 iface_desc->bInterfaceNumber, 1800 iface_desc->bInterfaceNumber,
1799 OPTION_BLACKLIST_RESERVED_IF, 1801 OPTION_BLACKLIST_RESERVED_IF,
1800 (const struct option_blacklist_info *) id->driver_info)) 1802 (const struct option_blacklist_info *) id->driver_info))
1801 return -ENODEV; 1803 return -ENODEV;
1802 /* 1804 /*
1803 * Don't bind network interface on Samsung GT-B3730, it is handled by 1805 * Don't bind network interface on Samsung GT-B3730, it is handled by
1804 * a separate module. 1806 * a separate module.
1805 */ 1807 */
1806 if (dev_desc->idVendor == cpu_to_le16(SAMSUNG_VENDOR_ID) && 1808 if (dev_desc->idVendor == cpu_to_le16(SAMSUNG_VENDOR_ID) &&
1807 dev_desc->idProduct == cpu_to_le16(SAMSUNG_PRODUCT_GT_B3730) && 1809 dev_desc->idProduct == cpu_to_le16(SAMSUNG_PRODUCT_GT_B3730) &&
1808 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) 1810 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
1809 return -ENODEV; 1811 return -ENODEV;
1810 1812
1811 /* Store device id so we can use it during attach. */ 1813 /* Store device id so we can use it during attach. */
1812 usb_set_serial_data(serial, (void *)id); 1814 usb_set_serial_data(serial, (void *)id);
1813 1815
1814 return 0; 1816 return 0;
1815 } 1817 }
1816 1818
1817 static int option_attach(struct usb_serial *serial) 1819 static int option_attach(struct usb_serial *serial)
1818 { 1820 {
1819 struct usb_interface_descriptor *iface_desc; 1821 struct usb_interface_descriptor *iface_desc;
1820 const struct usb_device_id *id; 1822 const struct usb_device_id *id;
1821 struct usb_wwan_intf_private *data; 1823 struct usb_wwan_intf_private *data;
1822 struct option_private *priv; 1824 struct option_private *priv;
1823 1825
1824 data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL); 1826 data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL);
1825 if (!data) 1827 if (!data)
1826 return -ENOMEM; 1828 return -ENOMEM;
1827 1829
1828 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 1830 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1829 if (!priv) { 1831 if (!priv) {
1830 kfree(data); 1832 kfree(data);
1831 return -ENOMEM; 1833 return -ENOMEM;
1832 } 1834 }
1833 1835
1834 /* Retrieve device id stored at probe. */ 1836 /* Retrieve device id stored at probe. */
1835 id = usb_get_serial_data(serial); 1837 id = usb_get_serial_data(serial);
1836 iface_desc = &serial->interface->cur_altsetting->desc; 1838 iface_desc = &serial->interface->cur_altsetting->desc;
1837 1839
1838 priv->bInterfaceNumber = iface_desc->bInterfaceNumber; 1840 priv->bInterfaceNumber = iface_desc->bInterfaceNumber;
1839 data->private = priv; 1841 data->private = priv;
1840 1842
1841 if (!is_blacklisted(iface_desc->bInterfaceNumber, 1843 if (!is_blacklisted(iface_desc->bInterfaceNumber,
1842 OPTION_BLACKLIST_SENDSETUP, 1844 OPTION_BLACKLIST_SENDSETUP,
1843 (struct option_blacklist_info *)id->driver_info)) { 1845 (struct option_blacklist_info *)id->driver_info)) {
1844 data->send_setup = option_send_setup; 1846 data->send_setup = option_send_setup;
1845 } 1847 }
1846 spin_lock_init(&data->susp_lock); 1848 spin_lock_init(&data->susp_lock);
1847 1849
1848 usb_set_serial_data(serial, data); 1850 usb_set_serial_data(serial, data);
1849 1851
1850 return 0; 1852 return 0;
1851 } 1853 }
1852 1854
1853 static void option_release(struct usb_serial *serial) 1855 static void option_release(struct usb_serial *serial)
1854 { 1856 {
1855 struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial); 1857 struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
1856 struct option_private *priv = intfdata->private; 1858 struct option_private *priv = intfdata->private;
1857 1859
1858 kfree(priv); 1860 kfree(priv);
1859 kfree(intfdata); 1861 kfree(intfdata);
1860 } 1862 }
1861 1863
1862 static void option_instat_callback(struct urb *urb) 1864 static void option_instat_callback(struct urb *urb)
1863 { 1865 {
1864 int err; 1866 int err;
1865 int status = urb->status; 1867 int status = urb->status;
1866 struct usb_serial_port *port = urb->context; 1868 struct usb_serial_port *port = urb->context;
1867 struct device *dev = &port->dev; 1869 struct device *dev = &port->dev;
1868 struct usb_wwan_port_private *portdata = 1870 struct usb_wwan_port_private *portdata =
1869 usb_get_serial_port_data(port); 1871 usb_get_serial_port_data(port);
1870 1872
1871 dev_dbg(dev, "%s: urb %p port %p has data %p\n", __func__, urb, port, portdata); 1873 dev_dbg(dev, "%s: urb %p port %p has data %p\n", __func__, urb, port, portdata);
1872 1874
1873 if (status == 0) { 1875 if (status == 0) {
1874 struct usb_ctrlrequest *req_pkt = 1876 struct usb_ctrlrequest *req_pkt =
1875 (struct usb_ctrlrequest *)urb->transfer_buffer; 1877 (struct usb_ctrlrequest *)urb->transfer_buffer;
1876 1878
1877 if (!req_pkt) { 1879 if (!req_pkt) {
1878 dev_dbg(dev, "%s: NULL req_pkt\n", __func__); 1880 dev_dbg(dev, "%s: NULL req_pkt\n", __func__);
1879 return; 1881 return;
1880 } 1882 }
1881 if ((req_pkt->bRequestType == 0xA1) && 1883 if ((req_pkt->bRequestType == 0xA1) &&
1882 (req_pkt->bRequest == 0x20)) { 1884 (req_pkt->bRequest == 0x20)) {
1883 int old_dcd_state; 1885 int old_dcd_state;
1884 unsigned char signals = *((unsigned char *) 1886 unsigned char signals = *((unsigned char *)
1885 urb->transfer_buffer + 1887 urb->transfer_buffer +
1886 sizeof(struct usb_ctrlrequest)); 1888 sizeof(struct usb_ctrlrequest));
1887 1889
1888 dev_dbg(dev, "%s: signal x%x\n", __func__, signals); 1890 dev_dbg(dev, "%s: signal x%x\n", __func__, signals);
1889 1891
1890 old_dcd_state = portdata->dcd_state; 1892 old_dcd_state = portdata->dcd_state;
1891 portdata->cts_state = 1; 1893 portdata->cts_state = 1;
1892 portdata->dcd_state = ((signals & 0x01) ? 1 : 0); 1894 portdata->dcd_state = ((signals & 0x01) ? 1 : 0);
1893 portdata->dsr_state = ((signals & 0x02) ? 1 : 0); 1895 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
1894 portdata->ri_state = ((signals & 0x08) ? 1 : 0); 1896 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
1895 1897
1896 if (old_dcd_state && !portdata->dcd_state) 1898 if (old_dcd_state && !portdata->dcd_state)
1897 tty_port_tty_hangup(&port->port, true); 1899 tty_port_tty_hangup(&port->port, true);
1898 } else { 1900 } else {
1899 dev_dbg(dev, "%s: type %x req %x\n", __func__, 1901 dev_dbg(dev, "%s: type %x req %x\n", __func__,
1900 req_pkt->bRequestType, req_pkt->bRequest); 1902 req_pkt->bRequestType, req_pkt->bRequest);
1901 } 1903 }
1902 } else 1904 } else
1903 dev_err(dev, "%s: error %d\n", __func__, status); 1905 dev_err(dev, "%s: error %d\n", __func__, status);
1904 1906
1905 /* Resubmit urb so we continue receiving IRQ data */ 1907 /* Resubmit urb so we continue receiving IRQ data */
1906 if (status != -ESHUTDOWN && status != -ENOENT) { 1908 if (status != -ESHUTDOWN && status != -ENOENT) {
1907 err = usb_submit_urb(urb, GFP_ATOMIC); 1909 err = usb_submit_urb(urb, GFP_ATOMIC);
1908 if (err) 1910 if (err)
1909 dev_dbg(dev, "%s: resubmit intr urb failed. (%d)\n", 1911 dev_dbg(dev, "%s: resubmit intr urb failed. (%d)\n",
1910 __func__, err); 1912 __func__, err);
1911 } 1913 }
1912 } 1914 }
1913 1915
1914 /** send RTS/DTR state to the port. 1916 /** send RTS/DTR state to the port.
1915 * 1917 *
1916 * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN 1918 * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN
1917 * CDC. 1919 * CDC.
1918 */ 1920 */
1919 static int option_send_setup(struct usb_serial_port *port) 1921 static int option_send_setup(struct usb_serial_port *port)
1920 { 1922 {
1921 struct usb_serial *serial = port->serial; 1923 struct usb_serial *serial = port->serial;
1922 struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial); 1924 struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
1923 struct option_private *priv = intfdata->private; 1925 struct option_private *priv = intfdata->private;
1924 struct usb_wwan_port_private *portdata; 1926 struct usb_wwan_port_private *portdata;
1925 int val = 0; 1927 int val = 0;
1926 1928
1927 portdata = usb_get_serial_port_data(port); 1929 portdata = usb_get_serial_port_data(port);
1928 1930
1929 if (portdata->dtr_state) 1931 if (portdata->dtr_state)
1930 val |= 0x01; 1932 val |= 0x01;
1931 if (portdata->rts_state) 1933 if (portdata->rts_state)
1932 val |= 0x02; 1934 val |= 0x02;
1933 1935
1934 return usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 1936 return usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
1935 0x22, 0x21, val, priv->bInterfaceNumber, NULL, 1937 0x22, 0x21, val, priv->bInterfaceNumber, NULL,
1936 0, USB_CTRL_SET_TIMEOUT); 1938 0, USB_CTRL_SET_TIMEOUT);
1937 } 1939 }
1938 1940
1939 MODULE_AUTHOR(DRIVER_AUTHOR); 1941 MODULE_AUTHOR(DRIVER_AUTHOR);
1940 MODULE_DESCRIPTION(DRIVER_DESC); 1942 MODULE_DESCRIPTION(DRIVER_DESC);
1941 MODULE_LICENSE("GPL"); 1943 MODULE_LICENSE("GPL");
1942 1944
include/uapi/linux/usb/Kbuild
1 # UAPI Header export list 1 # UAPI Header export list
2 header-y += audio.h 2 header-y += audio.h
3 header-y += cdc.h 3 header-y += cdc.h
4 header-y += cdc-wdm.h
4 header-y += ch11.h 5 header-y += ch11.h
5 header-y += ch9.h 6 header-y += ch9.h
6 header-y += functionfs.h 7 header-y += functionfs.h
7 header-y += g_printer.h 8 header-y += g_printer.h
8 header-y += gadgetfs.h 9 header-y += gadgetfs.h
9 header-y += midi.h 10 header-y += midi.h
10 header-y += tmc.h 11 header-y += tmc.h
11 header-y += video.h 12 header-y += video.h
12 13
include/uapi/linux/usb/cdc-wdm.h
1 /* 1 /*
2 * USB CDC Device Management userspace API definitions 2 * USB CDC Device Management userspace API definitions
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation. 6 * version 2 as published by the Free Software Foundation.
7 */ 7 */
8 8
9 #ifndef _UAPI__LINUX_USB_CDC_WDM_H 9 #ifndef _UAPI__LINUX_USB_CDC_WDM_H
10 #define _UAPI__LINUX_USB_CDC_WDM_H 10 #define _UAPI__LINUX_USB_CDC_WDM_H
11 11
12 #include <linux/types.h>
13
12 /* 14 /*
13 * This IOCTL is used to retrieve the wMaxCommand for the device, 15 * This IOCTL is used to retrieve the wMaxCommand for the device,
14 * defining the message limit for both reading and writing. 16 * defining the message limit for both reading and writing.
15 * 17 *
16 * For CDC WDM functions this will be the wMaxCommand field of the 18 * For CDC WDM functions this will be the wMaxCommand field of the
17 * Device Management Functional Descriptor. 19 * Device Management Functional Descriptor.
18 */ 20 */
19 #define IOCTL_WDM_MAX_COMMAND _IOR('H', 0xA0, __u16) 21 #define IOCTL_WDM_MAX_COMMAND _IOR('H', 0xA0, __u16)
20 22
21 #endif /* _UAPI__LINUX_USB_CDC_WDM_H */ 23 #endif /* _UAPI__LINUX_USB_CDC_WDM_H */
22 24