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