1 /* $NetBSD: uftdi.c,v 1.13 2002/09/23 05:51:23 simonb Exp $ */
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net).
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
39 #include <sys/cdefs.h>
40 __FBSDID("$FreeBSD$");
43 * FTDI FT8U100AX serial adapter driver
46 #include <sys/cdefs.h>
48 #include <sys/param.h>
49 #include <sys/systm.h>
50 #include <sys/kernel.h>
51 #include <sys/malloc.h>
52 #include <sys/module.h>
54 #include <sys/ioccom.h>
55 #include <sys/fcntl.h>
60 #include <sys/selinfo.h>
62 #include <sys/sysctl.h>
64 #include <dev/usb/usb.h>
65 #include <dev/usb/usbhid.h>
67 #include <dev/usb/usbdi.h>
68 #include <dev/usb/usbdi_util.h>
71 #include <dev/usb/ucomvar.h>
73 #include <dev/usb/uftdireg.h>
76 static int uftdidebug = 0;
77 SYSCTL_NODE(_hw_usb, OID_AUTO, uftdi, CTLFLAG_RW, 0, "USB uftdi");
78 SYSCTL_INT(_hw_usb_uftdi, OID_AUTO, debug, CTLFLAG_RW,
79 &uftdidebug, 0, "uftdi debug level");
80 #define DPRINTF(x) do { \
85 #define DPRINTFN(n, x) do { \
86 if (uftdidebug > (n)) \
95 #define UFTDI_CONFIG_INDEX 0
96 #define UFTDI_IFACE_INDEX 0
100 * These are the maximum number of bytes transferred per frame.
101 * The output buffer size cannot be increased due to the size encoding.
103 #define UFTDIIBUFSIZE 64
104 #define UFTDIOBUFSIZE 64
107 struct ucom_softc sc_ucom;
108 usbd_interface_handle sc_iface; /* interface */
109 enum uftdi_type sc_type;
116 static void uftdi_get_status(void *, int portno, u_char *lsr, u_char *msr);
117 static void uftdi_set(void *, int, int, int);
118 static int uftdi_param(void *, int, struct termios *);
119 static int uftdi_open(void *sc, int portno);
120 static void uftdi_read(void *sc, int portno, u_char **ptr,u_int32_t *count);
121 static void uftdi_write(void *sc, int portno, u_char *to, u_char *from,
123 static void uftdi_break(void *sc, int portno, int onoff);
124 static int uftdi_8u232am_getrate(speed_t speed, int *rate);
126 struct ucom_callback uftdi_callback = {
138 uftdi_match(device_t self)
140 struct usb_attach_arg *uaa = device_get_ivars(self);
142 if (uaa->iface != NULL) {
143 if (uaa->vendor == USB_VENDOR_FTDI &&
144 (uaa->product == USB_PRODUCT_FTDI_SERIAL_2232C))
145 return (UMATCH_VENDOR_IFACESUBCLASS);
146 return (UMATCH_NONE);
149 DPRINTFN(20,("uftdi: vendor=0x%x, product=0x%x\n",
150 uaa->vendor, uaa->product));
152 if (uaa->vendor == USB_VENDOR_FTDI &&
153 (uaa->product == USB_PRODUCT_FTDI_SERIAL_8U100AX ||
154 uaa->product == USB_PRODUCT_FTDI_SERIAL_8U232AM ||
155 uaa->product == USB_PRODUCT_FTDI_SEMC_DSS20 ||
156 uaa->product == USB_PRODUCT_FTDI_CFA_631 ||
157 uaa->product == USB_PRODUCT_FTDI_CFA_632 ||
158 uaa->product == USB_PRODUCT_FTDI_CFA_633 ||
159 uaa->product == USB_PRODUCT_FTDI_CFA_634 ||
160 uaa->product == USB_PRODUCT_FTDI_CFA_635 ||
161 uaa->product == USB_PRODUCT_FTDI_USBSERIAL ||
162 uaa->product == USB_PRODUCT_FTDI_MX2_3 ||
163 uaa->product == USB_PRODUCT_FTDI_MX4_5 ||
164 uaa->product == USB_PRODUCT_FTDI_LK202 ||
165 uaa->product == USB_PRODUCT_FTDI_LK204 ||
166 uaa->product == USB_PRODUCT_FTDI_TACTRIX_OPENPORT_13M ||
167 uaa->product == USB_PRODUCT_FTDI_TACTRIX_OPENPORT_13S ||
168 uaa->product == USB_PRODUCT_FTDI_TACTRIX_OPENPORT_13U ||
169 uaa->product == USB_PRODUCT_FTDI_EISCOU ||
170 uaa->product == USB_PRODUCT_FTDI_UOPTBR ||
171 uaa->product == USB_PRODUCT_FTDI_EMCU2D ||
172 uaa->product == USB_PRODUCT_FTDI_PCMSFU ||
173 uaa->product == USB_PRODUCT_FTDI_EMCU2H ))
174 return (UMATCH_VENDOR_PRODUCT);
175 if (uaa->vendor == USB_VENDOR_SIIG2 &&
176 (uaa->product == USB_PRODUCT_SIIG2_US2308))
177 return (UMATCH_VENDOR_PRODUCT);
178 if (uaa->vendor == USB_VENDOR_INTREPIDCS &&
179 (uaa->product == USB_PRODUCT_INTREPIDCS_VALUECAN ||
180 uaa->product == USB_PRODUCT_INTREPIDCS_NEOVI))
181 return (UMATCH_VENDOR_PRODUCT);
182 if (uaa->vendor == USB_VENDOR_BBELECTRONICS &&
183 (uaa->product == USB_PRODUCT_BBELECTRONICS_USOTL4))
184 return (UMATCH_VENDOR_PRODUCT);
185 if (uaa->vendor == USB_VENDOR_MELCO &&
186 (uaa->product == USB_PRODUCT_MELCO_PCOPRS1))
187 return (UMATCH_VENDOR_PRODUCT);
189 return (UMATCH_NONE);
193 uftdi_attach(device_t self)
195 struct uftdi_softc *sc = device_get_softc(self);
196 struct usb_attach_arg *uaa = device_get_ivars(self);
197 usbd_device_handle dev = uaa->device;
198 usbd_interface_handle iface;
199 usb_interface_descriptor_t *id;
200 usb_endpoint_descriptor_t *ed;
203 struct ucom_softc *ucom = &sc->sc_ucom;
204 DPRINTFN(10,("\nuftdi_attach: sc=%p\n", sc));
209 if (uaa->iface == NULL) {
210 /* Move the device into the configured state. */
211 err = usbd_set_config_index(dev, UFTDI_CONFIG_INDEX, 1);
213 device_printf(ucom->sc_dev,
214 "failed to set configuration, err=%s\n",
219 err = usbd_device2interface_handle(dev, UFTDI_IFACE_INDEX, &iface);
221 device_printf(ucom->sc_dev,
222 "failed to get interface, err=%s\n", usbd_errstr(err));
229 id = usbd_get_interface_descriptor(iface);
230 ucom->sc_iface = iface;
231 switch( uaa->vendor ){
232 case USB_VENDOR_FTDI:
233 switch( uaa->product ){
234 case USB_PRODUCT_FTDI_SERIAL_8U100AX:
235 sc->sc_type = UFTDI_TYPE_SIO;
238 case USB_PRODUCT_FTDI_SEMC_DSS20:
239 case USB_PRODUCT_FTDI_SERIAL_8U232AM:
240 case USB_PRODUCT_FTDI_SERIAL_2232C:
241 case USB_PRODUCT_FTDI_CFA_631:
242 case USB_PRODUCT_FTDI_CFA_632:
243 case USB_PRODUCT_FTDI_CFA_633:
244 case USB_PRODUCT_FTDI_CFA_634:
245 case USB_PRODUCT_FTDI_CFA_635:
246 case USB_PRODUCT_FTDI_USBSERIAL:
247 case USB_PRODUCT_FTDI_MX2_3:
248 case USB_PRODUCT_FTDI_MX4_5:
249 case USB_PRODUCT_FTDI_LK202:
250 case USB_PRODUCT_FTDI_LK204:
251 case USB_PRODUCT_FTDI_TACTRIX_OPENPORT_13M:
252 case USB_PRODUCT_FTDI_TACTRIX_OPENPORT_13S:
253 case USB_PRODUCT_FTDI_TACTRIX_OPENPORT_13U:
254 case USB_PRODUCT_FTDI_EISCOU:
255 case USB_PRODUCT_FTDI_UOPTBR:
256 case USB_PRODUCT_FTDI_EMCU2D:
257 case USB_PRODUCT_FTDI_PCMSFU:
258 case USB_PRODUCT_FTDI_EMCU2H:
259 sc->sc_type = UFTDI_TYPE_8U232AM;
263 default: /* Can't happen */
268 case USB_VENDOR_INTREPIDCS:
269 switch( uaa->product ){
270 case USB_PRODUCT_INTREPIDCS_VALUECAN:
271 case USB_PRODUCT_INTREPIDCS_NEOVI:
272 sc->sc_type = UFTDI_TYPE_8U232AM;
276 default: /* Can't happen */
281 case USB_VENDOR_SIIG2:
282 switch( uaa->product ){
283 case USB_PRODUCT_SIIG2_US2308:
284 sc->sc_type = UFTDI_TYPE_8U232AM;
288 default: /* Can't happen */
293 case USB_VENDOR_BBELECTRONICS:
294 switch( uaa->product ){
295 case USB_PRODUCT_BBELECTRONICS_USOTL4:
296 sc->sc_type = UFTDI_TYPE_8U232AM;
300 default: /* Can't happen */
305 case USB_VENDOR_MELCO:
306 switch( uaa->product ){
307 case USB_PRODUCT_MELCO_PCOPRS1:
308 sc->sc_type = UFTDI_TYPE_8U232AM;
312 default: /* Can't happen */
317 default: /* Can't happen */
321 ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1;
323 for (i = 0; i < id->bNumEndpoints; i++) {
325 ed = usbd_interface2endpoint_descriptor(iface, i);
327 device_printf(ucom->sc_dev,
328 "could not read endpoint descriptor\n");
332 addr = ed->bEndpointAddress;
333 dir = UE_GET_DIR(ed->bEndpointAddress);
334 attr = ed->bmAttributes & UE_XFERTYPE;
335 if (dir == UE_DIR_IN && attr == UE_BULK)
336 ucom->sc_bulkin_no = addr;
337 else if (dir == UE_DIR_OUT && attr == UE_BULK)
338 ucom->sc_bulkout_no = addr;
340 device_printf(ucom->sc_dev, "unexpected endpoint\n");
344 if (ucom->sc_bulkin_no == -1) {
345 device_printf(ucom->sc_dev, "Could not find data bulk in\n");
348 if (ucom->sc_bulkout_no == -1) {
349 device_printf(ucom->sc_dev, "Could not find data bulk out\n");
352 ucom->sc_parent = sc;
353 if (uaa->iface == NULL)
354 ucom->sc_portno = FTDI_PIT_SIOA;
356 ucom->sc_portno = FTDI_PIT_SIOA + id->bInterfaceNumber;
357 /* bulkin, bulkout set above */
359 ucom->sc_ibufsize = UFTDIIBUFSIZE;
360 ucom->sc_obufsize = UFTDIOBUFSIZE - sc->sc_hdrlen;
361 ucom->sc_ibufsizepad = UFTDIIBUFSIZE;
362 ucom->sc_opkthdrlen = sc->sc_hdrlen;
365 ucom->sc_callback = &uftdi_callback;
367 usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, ucom->sc_udev,
370 DPRINTF(("uftdi: in=0x%x out=0x%x\n", ucom->sc_bulkin_no, ucom->sc_bulkout_no));
371 ucom_attach(&sc->sc_ucom);
375 DPRINTF(("uftdi_attach: ATTACH ERROR\n"));
381 uftdi_activate(device_t self, enum devact act)
383 struct uftdi_softc *sc = (struct uftdi_softc *)self;
390 case DVACT_DEACTIVATE:
391 if (sc->sc_subdev != NULL)
392 rv = config_deactivate(sc->sc_subdev);
393 sc->sc_ucom.sc_dying = 1;
401 uftdi_detach(device_t self)
403 struct uftdi_softc *sc = device_get_softc(self);
407 DPRINTF(("uftdi_detach: sc=%p\n", sc));
408 sc->sc_ucom.sc_dying = 1;
409 rv = ucom_detach(&sc->sc_ucom);
415 uftdi_open(void *vsc, int portno)
417 struct uftdi_softc *sc = vsc;
418 struct ucom_softc *ucom = &sc->sc_ucom;
419 usb_device_request_t req;
423 DPRINTF(("uftdi_open: sc=%p\n", sc));
428 /* Perform a full reset on the device */
429 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
430 req.bRequest = FTDI_SIO_RESET;
431 USETW(req.wValue, FTDI_SIO_RESET_SIO);
432 USETW(req.wIndex, portno);
433 USETW(req.wLength, 0);
434 err = usbd_do_request(ucom->sc_udev, &req, NULL);
438 /* Set 9600 baud, 2 stop bits, no parity, 8 bits */
440 t.c_cflag = CSTOPB | CS8;
441 (void)uftdi_param(sc, portno, &t);
443 /* Turn on RTS/CTS flow control */
444 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
445 req.bRequest = FTDI_SIO_SET_FLOW_CTRL;
446 USETW(req.wValue, 0);
447 USETW2(req.wIndex, FTDI_SIO_RTS_CTS_HS, portno);
448 USETW(req.wLength, 0);
449 err = usbd_do_request(ucom->sc_udev, &req, NULL);
457 uftdi_read(void *vsc, int portno, u_char **ptr, u_int32_t *count)
459 struct uftdi_softc *sc = vsc;
462 DPRINTFN(15,("uftdi_read: sc=%p, port=%d count=%d\n", sc, portno,
465 msr = FTDI_GET_MSR(*ptr);
466 lsr = FTDI_GET_LSR(*ptr);
470 DPRINTFN(10,("uftdi_read: sc=%p, port=%d count=%d data[0]="
471 "0x%02x\n", sc, portno, *count, (*ptr)[2]));
474 if (sc->sc_msr != msr ||
475 (sc->sc_lsr & FTDI_LSR_MASK) != (lsr & FTDI_LSR_MASK)) {
476 DPRINTF(("uftdi_read: status change msr=0x%02x(0x%02x) "
477 "lsr=0x%02x(0x%02x)\n", msr, sc->sc_msr,
481 ucom_status_change(&sc->sc_ucom);
484 /* Pick up status and adjust data part. */
490 uftdi_write(void *vsc, int portno, u_char *to, u_char *from, u_int32_t *count)
492 struct uftdi_softc *sc = vsc;
494 DPRINTFN(10,("uftdi_write: sc=%p, port=%d count=%u data[0]=0x%02x\n",
495 vsc, portno, *count, from[0]));
497 /* Make length tag and copy data */
498 if (sc->sc_hdrlen > 0)
499 *to = FTDI_OUT_TAG(*count, portno);
501 memcpy(to + sc->sc_hdrlen, from, *count);
502 *count += sc->sc_hdrlen;
506 uftdi_set(void *vsc, int portno, int reg, int onoff)
508 struct uftdi_softc *sc = vsc;
509 struct ucom_softc *ucom = vsc;
510 usb_device_request_t req;
513 DPRINTF(("uftdi_set: sc=%p, port=%d reg=%d onoff=%d\n", vsc, portno,
518 ctl = onoff ? FTDI_SIO_SET_DTR_HIGH : FTDI_SIO_SET_DTR_LOW;
521 ctl = onoff ? FTDI_SIO_SET_RTS_HIGH : FTDI_SIO_SET_RTS_LOW;
524 uftdi_break(sc, portno, onoff);
529 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
530 req.bRequest = FTDI_SIO_MODEM_CTRL;
531 USETW(req.wValue, ctl);
532 USETW(req.wIndex, portno);
533 USETW(req.wLength, 0);
534 DPRINTFN(2,("uftdi_set: reqtype=0x%02x req=0x%02x value=0x%04x "
535 "index=0x%04x len=%d\n", req.bmRequestType, req.bRequest,
536 UGETW(req.wValue), UGETW(req.wIndex), UGETW(req.wLength)));
537 (void)usbd_do_request(ucom->sc_udev, &req, NULL);
541 uftdi_param(void *vsc, int portno, struct termios *t)
543 struct uftdi_softc *sc = vsc;
544 struct ucom_softc *ucom = &sc->sc_ucom;
545 usb_device_request_t req;
547 int rate=0, data, flow;
549 DPRINTF(("uftdi_param: sc=%p\n", sc));
554 switch (sc->sc_type) {
556 switch (t->c_ospeed) {
557 case 300: rate = ftdi_sio_b300; break;
558 case 600: rate = ftdi_sio_b600; break;
559 case 1200: rate = ftdi_sio_b1200; break;
560 case 2400: rate = ftdi_sio_b2400; break;
561 case 4800: rate = ftdi_sio_b4800; break;
562 case 9600: rate = ftdi_sio_b9600; break;
563 case 19200: rate = ftdi_sio_b19200; break;
564 case 38400: rate = ftdi_sio_b38400; break;
565 case 57600: rate = ftdi_sio_b57600; break;
566 case 115200: rate = ftdi_sio_b115200; break;
572 case UFTDI_TYPE_8U232AM:
573 if (uftdi_8u232am_getrate(t->c_ospeed, &rate) == -1)
577 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
578 req.bRequest = FTDI_SIO_SET_BAUD_RATE;
579 USETW(req.wValue, rate);
580 USETW(req.wIndex, portno);
581 USETW(req.wLength, 0);
582 DPRINTFN(2,("uftdi_param: reqtype=0x%02x req=0x%02x value=0x%04x "
583 "index=0x%04x len=%d\n", req.bmRequestType, req.bRequest,
584 UGETW(req.wValue), UGETW(req.wIndex), UGETW(req.wLength)));
585 err = usbd_do_request(ucom->sc_udev, &req, NULL);
589 if (ISSET(t->c_cflag, CSTOPB))
590 data = FTDI_SIO_SET_DATA_STOP_BITS_2;
592 data = FTDI_SIO_SET_DATA_STOP_BITS_1;
593 if (ISSET(t->c_cflag, PARENB)) {
594 if (ISSET(t->c_cflag, PARODD))
595 data |= FTDI_SIO_SET_DATA_PARITY_ODD;
597 data |= FTDI_SIO_SET_DATA_PARITY_EVEN;
599 data |= FTDI_SIO_SET_DATA_PARITY_NONE;
600 switch (ISSET(t->c_cflag, CSIZE)) {
602 data |= FTDI_SIO_SET_DATA_BITS(5);
605 data |= FTDI_SIO_SET_DATA_BITS(6);
608 data |= FTDI_SIO_SET_DATA_BITS(7);
611 data |= FTDI_SIO_SET_DATA_BITS(8);
616 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
617 req.bRequest = FTDI_SIO_SET_DATA;
618 USETW(req.wValue, data);
619 USETW(req.wIndex, portno);
620 USETW(req.wLength, 0);
621 DPRINTFN(2,("uftdi_param: reqtype=0x%02x req=0x%02x value=0x%04x "
622 "index=0x%04x len=%d\n", req.bmRequestType, req.bRequest,
623 UGETW(req.wValue), UGETW(req.wIndex), UGETW(req.wLength)));
624 err = usbd_do_request(ucom->sc_udev, &req, NULL);
628 if (ISSET(t->c_cflag, CRTSCTS)) {
629 flow = FTDI_SIO_RTS_CTS_HS;
630 USETW(req.wValue, 0);
631 } else if (ISSET(t->c_iflag, IXON|IXOFF)) {
632 flow = FTDI_SIO_XON_XOFF_HS;
633 USETW2(req.wValue, t->c_cc[VSTOP], t->c_cc[VSTART]);
635 flow = FTDI_SIO_DISABLE_FLOW_CTRL;
636 USETW(req.wValue, 0);
638 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
639 req.bRequest = FTDI_SIO_SET_FLOW_CTRL;
640 USETW2(req.wIndex, flow, portno);
641 USETW(req.wLength, 0);
642 err = usbd_do_request(ucom->sc_udev, &req, NULL);
650 uftdi_get_status(void *vsc, int portno, u_char *lsr, u_char *msr)
652 struct uftdi_softc *sc = vsc;
654 DPRINTF(("uftdi_status: msr=0x%02x lsr=0x%02x\n",
655 sc->sc_msr, sc->sc_lsr));
664 uftdi_break(void *vsc, int portno, int onoff)
666 struct uftdi_softc *sc = vsc;
667 struct ucom_softc *ucom = vsc;
669 usb_device_request_t req;
672 DPRINTF(("uftdi_break: sc=%p, port=%d onoff=%d\n", vsc, portno,
676 data = sc->last_lcr | FTDI_SIO_SET_BREAK;
681 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
682 req.bRequest = FTDI_SIO_SET_DATA;
683 USETW(req.wValue, data);
684 USETW(req.wIndex, portno);
685 USETW(req.wLength, 0);
686 (void)usbd_do_request(ucom->sc_udev, &req, NULL);
690 uftdi_8u232am_getrate(speed_t speed, int *rate)
692 /* Table of the nearest even powers-of-2 for values 0..15. */
693 static const unsigned char roundoff[16] = {
694 0, 2, 2, 4, 4, 4, 8, 8,
695 8, 8, 8, 8, 16, 16, 16, 16,
698 unsigned int d, freq;
704 /* Special cases for 2M and 3M. */
705 if (speed >= 3000000 * 100 / 103 &&
706 speed <= 3000000 * 100 / 97) {
710 if (speed >= 2000000 * 100 / 103 &&
711 speed <= 2000000 * 100 / 97) {
716 d = (FTDI_8U232AM_FREQ << 4) / speed;
717 d = (d & ~15) + roundoff[d & 15];
719 if (d < FTDI_8U232AM_MIN_DIV)
720 d = FTDI_8U232AM_MIN_DIV;
721 else if (d > FTDI_8U232AM_MAX_DIV)
722 d = FTDI_8U232AM_MAX_DIV;
725 * Calculate the frequency needed for d to exactly divide down
726 * to our target speed, and check that the actual frequency is
730 if (freq < (quad_t)(FTDI_8U232AM_FREQ << 4) * 100 / 103 ||
731 freq > (quad_t)(FTDI_8U232AM_FREQ << 4) * 100 / 97)
735 * Pack the divisor into the resultant value. The lower
736 * 14-bits hold the integral part, while the upper 2 bits
737 * encode the fractional component: either 0, 0.5, 0.25, or
753 static device_method_t uftdi_methods[] = {
754 /* Device interface */
755 DEVMETHOD(device_probe, uftdi_match),
756 DEVMETHOD(device_attach, uftdi_attach),
757 DEVMETHOD(device_detach, uftdi_detach),
762 static driver_t uftdi_driver = {
765 sizeof (struct uftdi_softc)
768 DRIVER_MODULE(uftdi, uhub, uftdi_driver, ucom_devclass, usbd_driver_load, 0);
769 MODULE_DEPEND(uftdi, usb, 1, 1, 1);
770 MODULE_DEPEND(uftdi, ucom,UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);