kernel tree reorganization stage 1: Major cvs repository work (not logged as
[dragonfly.git] / sys / dev / usbmisc / uftdi / uftdi.c
1 /*      $NetBSD: uftdi.c,v 1.12 2002/07/18 14:44:10 scw Exp $   */
2 /*      $FreeBSD: src/sys/dev/usb/uftdi.c,v 1.3.2.1 2002/11/21 01:28:17 ticso Exp $     */
3 /*      $DragonFly: src/sys/dev/usbmisc/uftdi/uftdi.c,v 1.3 2003/08/07 21:17:14 dillon Exp $    */
4
5 /*
6  * Copyright (c) 2000 The NetBSD Foundation, Inc.
7  * All rights reserved.
8  *
9  * This code is derived from software contributed to The NetBSD Foundation
10  * by Lennart Augustsson (lennart@augustsson.net).
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. All advertising materials mentioning features or use of this software
21  *    must display the following acknowledgement:
22  *        This product includes software developed by the NetBSD
23  *        Foundation, Inc. and its contributors.
24  * 4. Neither the name of The NetBSD Foundation nor the names of its
25  *    contributors may be used to endorse or promote products derived
26  *    from this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGE.
39  */
40
41 /*
42  * FTDI FT8U100AX serial adapter driver
43  */
44
45 /*
46  * XXX This driver will not support multiple serial ports.
47  * XXX The ucom layer needs to be extended first.
48  */
49
50 #include <sys/cdefs.h>
51
52 #include <sys/param.h>
53 #include <sys/systm.h>
54 #include <sys/kernel.h>
55 #include <sys/malloc.h>
56 #include <sys/bus.h>
57 #include <sys/ioccom.h>
58 #include <sys/fcntl.h>
59 #include <sys/conf.h>
60 #include <sys/tty.h>
61 #include <sys/file.h>
62
63 #if __FreeBSD_version >= 500014
64 #include <sys/selinfo.h>
65 #else
66 #include <sys/select.h>
67 #endif
68
69 #include <sys/sysctl.h>
70
71 #include <bus/usb/usb.h>
72 #include <bus/usb/usbhid.h>
73
74 #include <bus/usb/usbdi.h>
75 #include <bus/usb/usbdi_util.h>
76 #include <bus/usb/usbdevs.h>
77
78 #include "../ucom/ucomvar.h"
79
80 #include "uftdireg.h"
81
82 #ifdef USB_DEBUG
83 static int uftdidebug = 0;
84 SYSCTL_NODE(_hw_usb, OID_AUTO, uftdi, CTLFLAG_RW, 0, "USB uftdi");
85 SYSCTL_INT(_hw_usb_uftdi, OID_AUTO, debug, CTLFLAG_RW,
86            &uftdidebug, 0, "uftdi debug level");
87 #define DPRINTF(x)      do { \
88                                 if (uftdidebug) \
89                                         logprintf x; \
90                         } while (0)
91
92 #define DPRINTFN(n, x)  do { \
93                                 if (uftdidebug > (n)) \
94                                         logprintf x; \
95                         } while (0)
96
97 #else
98 #define DPRINTF(x)
99 #define DPRINTFN(n,x)
100 #endif
101
102 #define UFTDI_CONFIG_INDEX      0
103 #define UFTDI_IFACE_INDEX       0
104
105
106 /*
107  * These are the maximum number of bytes transferred per frame.
108  * The output buffer size cannot be increased due to the size encoding.
109  */
110 #define UFTDIIBUFSIZE 64
111 #define UFTDIOBUFSIZE 64
112
113 struct uftdi_softc {
114         struct ucom_softc       sc_ucom;
115     
116         usbd_interface_handle   sc_iface;       /* interface */
117
118         enum uftdi_type         sc_type;
119         u_int                   sc_hdrlen;
120
121         u_char                  sc_msr;
122         u_char                  sc_lsr;
123
124         u_char                  sc_dying;
125
126         u_int                   last_lcr;
127 };
128
129 Static void     uftdi_get_status(void *, int portno, u_char *lsr, u_char *msr);
130 Static void     uftdi_set(void *, int, int, int);
131 Static int      uftdi_param(void *, int, struct termios *);
132 Static int      uftdi_open(void *sc, int portno);
133 Static void     uftdi_read(void *sc, int portno, u_char **ptr,u_int32_t *count);
134 Static void     uftdi_write(void *sc, int portno, u_char *to, u_char *from,
135                             u_int32_t *count);
136 Static void     uftdi_break(void *sc, int portno, int onoff);
137
138 struct ucom_callback uftdi_callback = {
139         uftdi_get_status,
140         uftdi_set,
141         uftdi_param,
142         NULL,
143         uftdi_open,
144         NULL,
145         uftdi_read,
146         uftdi_write,
147 };
148
149 USB_MATCH(uftdi)
150 {
151         USB_MATCH_START(uftdi, uaa);
152
153         if (uaa->iface != NULL)
154                 return (UMATCH_NONE);
155
156         DPRINTFN(20,("uftdi: vendor=0x%x, product=0x%x\n",
157                      uaa->vendor, uaa->product));
158
159         if (uaa->vendor == USB_VENDOR_FTDI &&
160             (uaa->product == USB_PRODUCT_FTDI_SERIAL_8U100AX ||
161              uaa->product == USB_PRODUCT_FTDI_SERIAL_8U232AM))
162                 return (UMATCH_VENDOR_PRODUCT);
163
164         return (UMATCH_NONE);
165 }
166
167 USB_ATTACH(uftdi)
168 {
169         USB_ATTACH_START(uftdi, sc, uaa);
170         usbd_device_handle dev = uaa->device;
171         usbd_interface_handle iface;
172         usb_interface_descriptor_t *id;
173         usb_endpoint_descriptor_t *ed;
174         char *devinfo;
175         const char *devname;
176         int i;
177         usbd_status err;
178         struct ucom_softc *ucom = &sc->sc_ucom;
179         DPRINTFN(10,("\nuftdi_attach: sc=%p\n", sc));
180         devinfo = malloc(1024, M_USBDEV, M_WAITOK);
181
182         ucom->sc_dev = self;
183         ucom->sc_udev = dev;
184
185         devname = USBDEVNAME(ucom->sc_dev);
186
187         /* Move the device into the configured state. */
188         err = usbd_set_config_index(dev, UFTDI_CONFIG_INDEX, 1);
189         if (err) {
190                 printf("\n%s: failed to set configuration, err=%s\n",
191                        devname, usbd_errstr(err));
192                 goto bad;
193         }
194
195         err = usbd_device2interface_handle(dev, UFTDI_IFACE_INDEX, &iface);
196         if (err) {
197                 printf("\n%s: failed to get interface, err=%s\n",
198                        devname, usbd_errstr(err));
199                 goto bad;
200         }
201
202         usbd_devinfo(dev, 0, devinfo);
203         /*      USB_ATTACH_SETUP;*/
204         printf("%s: %s\n", devname, devinfo);
205
206         id = usbd_get_interface_descriptor(iface);
207         ucom->sc_iface = iface;
208         switch( uaa->product ){
209         case USB_PRODUCT_FTDI_SERIAL_8U100AX:
210                 sc->sc_type = UFTDI_TYPE_SIO;
211                 sc->sc_hdrlen = 1;
212                 break;
213         case USB_PRODUCT_FTDI_SERIAL_8U232AM:
214                 sc->sc_type = UFTDI_TYPE_8U232AM;
215                 sc->sc_hdrlen = 0;
216                 break;
217
218         default:                /* Can't happen */
219                 goto bad;
220         }
221         
222         ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1;
223         
224         for (i = 0; i < id->bNumEndpoints; i++) {
225                 int addr, dir, attr;
226                 ed = usbd_interface2endpoint_descriptor(iface, i);
227                 if (ed == NULL) {
228                         printf("%s: could not read endpoint descriptor"
229                                ": %s\n", devname, usbd_errstr(err));
230                         goto bad;
231                 }
232                 
233                 addr = ed->bEndpointAddress;
234                 dir = UE_GET_DIR(ed->bEndpointAddress);
235                 attr = ed->bmAttributes & UE_XFERTYPE;
236                 if (dir == UE_DIR_IN && attr == UE_BULK)
237                   ucom->sc_bulkin_no = addr;
238                 else if (dir == UE_DIR_OUT && attr == UE_BULK)
239                   ucom->sc_bulkout_no = addr;
240                 else {
241                   printf("%s: unexpected endpoint\n", devname);
242                   goto bad;
243                 }
244         }
245         if (ucom->sc_bulkin_no == -1) {
246                 printf("%s: Could not find data bulk in\n",
247                        devname);
248                 goto bad;
249         }
250         if (ucom->sc_bulkout_no == -1) {
251                 printf("%s: Could not find data bulk out\n",
252                        devname);
253                 goto bad;
254         }
255         ucom->sc_parent  = sc;
256         ucom->sc_portno = FTDI_PIT_SIOA;
257         /* bulkin, bulkout set above */
258
259         ucom->sc_ibufsize = UFTDIIBUFSIZE;
260         ucom->sc_obufsize = UFTDIOBUFSIZE - sc->sc_hdrlen;
261         ucom->sc_ibufsizepad = UFTDIIBUFSIZE;
262         ucom->sc_opkthdrlen = sc->sc_hdrlen;
263
264
265         ucom->sc_callback = &uftdi_callback;
266 #if 0
267         usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, ucom->sc_udev,
268                            USBDEV(ucom->sc_dev));
269 #endif
270         DPRINTF(("uftdi: in=0x%x out=0x%x\n", ucom->sc_bulkin_no, ucom->sc_bulkout_no));
271         ucom_attach(&sc->sc_ucom);
272         free(devinfo, M_USBDEV);
273                 
274         USB_ATTACH_SUCCESS_RETURN;
275
276 bad:
277         DPRINTF(("uftdi_attach: ATTACH ERROR\n"));
278         ucom->sc_dying = 1;
279         free(devinfo, M_USBDEV);
280
281         USB_ATTACH_ERROR_RETURN;
282 }
283 #if 0
284 int
285 uftdi_activate(device_ptr_t self, enum devact act)
286 {
287         struct uftdi_softc *sc = (struct uftdi_softc *)self;
288         int rv = 0;
289
290         switch (act) {
291         case DVACT_ACTIVATE:
292                 return (EOPNOTSUPP);
293                 break;
294
295         case DVACT_DEACTIVATE:
296                 if (sc->sc_subdev != NULL)
297                         rv = config_deactivate(sc->sc_subdev);
298                 sc->sc_dying = 1;
299                 break;
300         }
301         return (rv);
302 }
303 #endif
304 #if 1
305 USB_DETACH(uftdi)
306 {
307         USB_DETACH_START(uftdi, sc);
308  
309         int rv = 0;
310
311         DPRINTF(("uftdi_detach: sc=%p\n", sc));
312         sc->sc_dying = 1;
313         rv = ucom_detach(&sc->sc_ucom);
314
315         return rv;
316 }
317 #endif
318 Static int
319 uftdi_open(void *vsc, int portno)
320 {
321         struct uftdi_softc *sc = vsc;
322         struct ucom_softc *ucom = (struct ucom_softc *) vsc;
323         usb_device_request_t req;
324         usbd_status err;
325         struct termios t;
326
327         DPRINTF(("uftdi_open: sc=%p\n", sc));
328
329         if (sc->sc_dying)
330                 return (EIO);
331
332         /* Perform a full reset on the device */
333         req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
334         req.bRequest = FTDI_SIO_RESET;
335         USETW(req.wValue, FTDI_SIO_RESET_SIO);
336         USETW(req.wIndex, portno);
337         USETW(req.wLength, 0);
338         err = usbd_do_request(ucom->sc_udev, &req, NULL);
339         if (err)
340                 return (EIO);
341
342         /* Set 9600 baud, 2 stop bits, no parity, 8 bits */
343         t.c_ospeed = 9600;
344         t.c_cflag = CSTOPB | CS8;
345         (void)uftdi_param(sc, portno, &t);
346
347         /* Turn on RTS/CTS flow control */
348         req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
349         req.bRequest = FTDI_SIO_SET_FLOW_CTRL;
350         USETW(req.wValue, 0);
351         USETW2(req.wIndex, FTDI_SIO_RTS_CTS_HS, portno);
352         USETW(req.wLength, 0);
353         err = usbd_do_request(ucom->sc_udev, &req, NULL);
354         if (err)
355                 return (EIO);
356
357         return (0);
358 }
359
360 Static void
361 uftdi_read(void *vsc, int portno, u_char **ptr, u_int32_t *count)
362 {
363         struct uftdi_softc *sc = vsc;
364         u_char msr, lsr;
365
366         DPRINTFN(15,("uftdi_read: sc=%p, port=%d count=%d\n", sc, portno,
367                      *count));
368
369         msr = FTDI_GET_MSR(*ptr);
370         lsr = FTDI_GET_LSR(*ptr);
371
372 #ifdef USB_DEBUG
373         if (*count != 2)
374                 DPRINTFN(10,("uftdi_read: sc=%p, port=%d count=%d data[0]="
375                             "0x%02x\n", sc, portno, *count, (*ptr)[2]));
376 #endif
377
378         if (sc->sc_msr != msr ||
379             (sc->sc_lsr & FTDI_LSR_MASK) != (lsr & FTDI_LSR_MASK)) {
380                 DPRINTF(("uftdi_read: status change msr=0x%02x(0x%02x) "
381                          "lsr=0x%02x(0x%02x)\n", msr, sc->sc_msr,
382                          lsr, sc->sc_lsr));
383                 sc->sc_msr = msr;
384                 sc->sc_lsr = lsr;
385                 ucom_status_change(&sc->sc_ucom);
386         }
387
388         /* Pick up status and adjust data part. */
389         *ptr += 2;
390         *count -= 2;
391 }
392
393 Static void
394 uftdi_write(void *vsc, int portno, u_char *to, u_char *from, u_int32_t *count)
395 {
396         struct uftdi_softc *sc = vsc;
397
398         DPRINTFN(10,("uftdi_write: sc=%p, port=%d count=%u data[0]=0x%02x\n",
399                      vsc, portno, *count, from[0]));
400
401         /* Make length tag and copy data */
402         if (sc->sc_hdrlen > 0)
403                 *to = FTDI_OUT_TAG(*count, portno);
404
405         memcpy(to + sc->sc_hdrlen, from, *count);
406         *count += sc->sc_hdrlen;
407 }
408
409 Static void
410 uftdi_set(void *vsc, int portno, int reg, int onoff)
411 {
412         struct uftdi_softc *sc = vsc;
413         struct ucom_softc *ucom = vsc;
414         usb_device_request_t req;
415         int ctl;
416
417         DPRINTF(("uftdi_set: sc=%p, port=%d reg=%d onoff=%d\n", vsc, portno,
418                  reg, onoff));
419
420         switch (reg) {
421         case UCOM_SET_DTR:
422                 ctl = onoff ? FTDI_SIO_SET_DTR_HIGH : FTDI_SIO_SET_DTR_LOW;
423                 break;
424         case UCOM_SET_RTS:
425                 ctl = onoff ? FTDI_SIO_SET_RTS_HIGH : FTDI_SIO_SET_RTS_LOW;
426                 break;
427         case UCOM_SET_BREAK:
428                 uftdi_break(sc, portno, onoff);
429                 return;
430         default:
431                 return;
432         }
433         req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
434         req.bRequest = FTDI_SIO_MODEM_CTRL;
435         USETW(req.wValue, ctl);
436         USETW(req.wIndex, portno);
437         USETW(req.wLength, 0);
438         DPRINTFN(2,("uftdi_set: reqtype=0x%02x req=0x%02x value=0x%04x "
439                     "index=0x%04x len=%d\n", req.bmRequestType, req.bRequest,
440                     UGETW(req.wValue), UGETW(req.wIndex), UGETW(req.wLength)));
441         (void)usbd_do_request(ucom->sc_udev, &req, NULL);
442 }
443
444 Static int
445 uftdi_param(void *vsc, int portno, struct termios *t)
446 {
447         struct uftdi_softc *sc = vsc;
448         struct ucom_softc *ucom = vsc;
449         usb_device_request_t req;
450         usbd_status err;
451         int rate=0, data, flow;
452
453         DPRINTF(("uftdi_param: sc=%p\n", sc));
454
455         if (sc->sc_dying)
456                 return (EIO);
457
458         switch (sc->sc_type) {
459         case UFTDI_TYPE_SIO:
460                 switch (t->c_ospeed) {
461                 case 300: rate = ftdi_sio_b300; break;
462                 case 600: rate = ftdi_sio_b600; break;
463                 case 1200: rate = ftdi_sio_b1200; break;
464                 case 2400: rate = ftdi_sio_b2400; break;
465                 case 4800: rate = ftdi_sio_b4800; break;
466                 case 9600: rate = ftdi_sio_b9600; break;
467                 case 19200: rate = ftdi_sio_b19200; break;
468                 case 38400: rate = ftdi_sio_b38400; break;
469                 case 57600: rate = ftdi_sio_b57600; break;
470                 case 115200: rate = ftdi_sio_b115200; break;
471                 default:
472                         return (EINVAL);
473                 }
474                 break;
475
476         case UFTDI_TYPE_8U232AM:
477                 switch(t->c_ospeed) {
478                 case 300: rate = ftdi_8u232am_b300; break;
479                 case 600: rate = ftdi_8u232am_b600; break;
480                 case 1200: rate = ftdi_8u232am_b1200; break;
481                 case 2400: rate = ftdi_8u232am_b2400; break;
482                 case 4800: rate = ftdi_8u232am_b4800; break;
483                 case 9600: rate = ftdi_8u232am_b9600; break;
484                 case 19200: rate = ftdi_8u232am_b19200; break;
485                 case 38400: rate = ftdi_8u232am_b38400; break;
486                 case 57600: rate = ftdi_8u232am_b57600; break;
487                 case 115200: rate = ftdi_8u232am_b115200; break;
488                 case 230400: rate = ftdi_8u232am_b230400; break;
489                 case 460800: rate = ftdi_8u232am_b460800; break;
490                 case 921600: rate = ftdi_8u232am_b921600; break;
491                 default:
492                         return (EINVAL);
493                 }
494                 break;
495         }
496         req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
497         req.bRequest = FTDI_SIO_SET_BAUD_RATE;
498         USETW(req.wValue, rate);
499         USETW(req.wIndex, portno);
500         USETW(req.wLength, 0);
501         DPRINTFN(2,("uftdi_param: reqtype=0x%02x req=0x%02x value=0x%04x "
502                     "index=0x%04x len=%d\n", req.bmRequestType, req.bRequest,
503                     UGETW(req.wValue), UGETW(req.wIndex), UGETW(req.wLength)));
504         err = usbd_do_request(ucom->sc_udev, &req, NULL);
505         if (err)
506                 return (EIO);
507
508         if (ISSET(t->c_cflag, CSTOPB))
509                 data = FTDI_SIO_SET_DATA_STOP_BITS_2;
510         else
511                 data = FTDI_SIO_SET_DATA_STOP_BITS_1;
512         if (ISSET(t->c_cflag, PARENB)) {
513                 if (ISSET(t->c_cflag, PARODD))
514                         data |= FTDI_SIO_SET_DATA_PARITY_ODD;
515                 else
516                         data |= FTDI_SIO_SET_DATA_PARITY_EVEN;
517         } else
518                 data |= FTDI_SIO_SET_DATA_PARITY_NONE;
519         switch (ISSET(t->c_cflag, CSIZE)) {
520         case CS5:
521                 data |= FTDI_SIO_SET_DATA_BITS(5);
522                 break;
523         case CS6:
524                 data |= FTDI_SIO_SET_DATA_BITS(6);
525                 break;
526         case CS7:
527                 data |= FTDI_SIO_SET_DATA_BITS(7);
528                 break;
529         case CS8:
530                 data |= FTDI_SIO_SET_DATA_BITS(8);
531                 break;
532         }
533         sc->last_lcr = data;
534
535         req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
536         req.bRequest = FTDI_SIO_SET_DATA;
537         USETW(req.wValue, data);
538         USETW(req.wIndex, portno);
539         USETW(req.wLength, 0);
540         DPRINTFN(2,("uftdi_param: reqtype=0x%02x req=0x%02x value=0x%04x "
541                     "index=0x%04x len=%d\n", req.bmRequestType, req.bRequest,
542                     UGETW(req.wValue), UGETW(req.wIndex), UGETW(req.wLength)));
543         err = usbd_do_request(ucom->sc_udev, &req, NULL);
544         if (err)
545                 return (EIO);
546
547         if (ISSET(t->c_cflag, CRTSCTS)) {
548                 flow = FTDI_SIO_RTS_CTS_HS;
549                 USETW(req.wValue, 0);
550         } else if (ISSET(t->c_iflag, IXON|IXOFF)) {
551                 flow = FTDI_SIO_XON_XOFF_HS;
552                 USETW2(req.wValue, t->c_cc[VSTOP], t->c_cc[VSTART]);
553         } else {
554                 flow = FTDI_SIO_DISABLE_FLOW_CTRL;
555                 USETW(req.wValue, 0);
556         }
557         req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
558         req.bRequest = FTDI_SIO_SET_FLOW_CTRL;
559         USETW2(req.wIndex, flow, portno);
560         USETW(req.wLength, 0);
561         err = usbd_do_request(ucom->sc_udev, &req, NULL);
562         if (err)
563                 return (EIO);
564
565         return (0);
566 }
567
568 void
569 uftdi_get_status(void *vsc, int portno, u_char *lsr, u_char *msr)
570 {
571         struct uftdi_softc *sc = vsc;
572
573         DPRINTF(("uftdi_status: msr=0x%02x lsr=0x%02x\n",
574                  sc->sc_msr, sc->sc_lsr));
575
576         if (msr != NULL)
577                 *msr = sc->sc_msr;
578         if (lsr != NULL)
579                 *lsr = sc->sc_lsr;
580 }
581
582 void
583 uftdi_break(void *vsc, int portno, int onoff)
584 {
585         struct uftdi_softc *sc = vsc;
586         struct ucom_softc *ucom = vsc;
587
588         usb_device_request_t req;
589         int data;
590
591         DPRINTF(("uftdi_break: sc=%p, port=%d onoff=%d\n", vsc, portno,
592                   onoff));
593
594         if (onoff) {
595                 data = sc->last_lcr | FTDI_SIO_SET_BREAK;
596         } else {
597                 data = sc->last_lcr;
598         }
599
600         req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
601         req.bRequest = FTDI_SIO_SET_DATA;
602         USETW(req.wValue, data);
603         USETW(req.wIndex, portno);
604         USETW(req.wLength, 0);
605         (void)usbd_do_request(ucom->sc_udev, &req, NULL);
606 }
607
608 Static device_method_t uftdi_methods[] = {
609         /* Device interface */
610         DEVMETHOD(device_probe, uftdi_match),
611         DEVMETHOD(device_attach, uftdi_attach),
612         DEVMETHOD(device_detach, uftdi_detach),
613
614         { 0, 0 }
615 };
616
617 Static driver_t uftdi_driver = {
618         "ucom",
619         uftdi_methods,
620         sizeof (struct uftdi_softc)
621 };
622
623 DRIVER_MODULE(uftdi, uhub, uftdi_driver, ucom_devclass, usbd_driver_load, 0);
624 MODULE_DEPEND(uftdi, usb, 1, 1, 1);
625 MODULE_DEPEND(uftdi, ucom,UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);