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