Deleted Added
full compact
uftdi.c (187994) uftdi.c (188413)
1/* $NetBSD: uftdi.c,v 1.13 2002/09/23 05:51:23 simonb Exp $ */
2
3/*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net).

--- 23 unchanged lines hidden (view full) ---

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.
37 */
38
39#include <sys/cdefs.h>
1/* $NetBSD: uftdi.c,v 1.13 2002/09/23 05:51:23 simonb Exp $ */
2
3/*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net).

--- 23 unchanged lines hidden (view full) ---

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.
37 */
38
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/sys/dev/usb2/serial/uftdi2.c 187994 2009-02-02 00:49:39Z alfred $");
40__FBSDID("$FreeBSD: head/sys/dev/usb2/serial/uftdi2.c 188413 2009-02-09 22:05:25Z thompsa $");
41
42/*
43 * NOTE: all function names beginning like "uftdi_cfg_" can only
44 * be called from within the config thread function !
45 */
46
47/*
48 * FTDI FT8U100AX serial adapter driver

--- 32 unchanged lines hidden (view full) ---

81#define UFTDI_IBUFSIZE 64 /* bytes, maximum number of bytes per
82 * frame */
83#define UFTDI_OBUFSIZE 64 /* bytes, cannot be increased due to
84 * do size encoding */
85
86enum {
87 UFTDI_BULK_DT_WR,
88 UFTDI_BULK_DT_RD,
41
42/*
43 * NOTE: all function names beginning like "uftdi_cfg_" can only
44 * be called from within the config thread function !
45 */
46
47/*
48 * FTDI FT8U100AX serial adapter driver

--- 32 unchanged lines hidden (view full) ---

81#define UFTDI_IBUFSIZE 64 /* bytes, maximum number of bytes per
82 * frame */
83#define UFTDI_OBUFSIZE 64 /* bytes, cannot be increased due to
84 * do size encoding */
85
86enum {
87 UFTDI_BULK_DT_WR,
88 UFTDI_BULK_DT_RD,
89 UFTDI_BULK_CS_WR,
90 UFTDI_BULK_CS_RD,
91 UFTDI_N_TRANSFER = 4,
89 UFTDI_N_TRANSFER,
92};
93
94struct uftdi_softc {
95 struct usb2_com_super_softc sc_super_ucom;
96 struct usb2_com_softc sc_ucom;
97
98 struct usb2_device *sc_udev;
99 struct usb2_xfer *sc_xfer[UFTDI_N_TRANSFER];
100 device_t sc_dev;
101
102 uint32_t sc_unit;
103 enum uftdi_type sc_type;
104
105 uint16_t sc_last_lcr;
106
107 uint8_t sc_iface_index;
108 uint8_t sc_hdrlen;
90};
91
92struct uftdi_softc {
93 struct usb2_com_super_softc sc_super_ucom;
94 struct usb2_com_softc sc_ucom;
95
96 struct usb2_device *sc_udev;
97 struct usb2_xfer *sc_xfer[UFTDI_N_TRANSFER];
98 device_t sc_dev;
99
100 uint32_t sc_unit;
101 enum uftdi_type sc_type;
102
103 uint16_t sc_last_lcr;
104
105 uint8_t sc_iface_index;
106 uint8_t sc_hdrlen;
109
110 uint8_t sc_msr;
111 uint8_t sc_lsr;
112
107 uint8_t sc_msr;
108 uint8_t sc_lsr;
109
113 uint8_t sc_flag;
114#define UFTDI_FLAG_WRITE_STALL 0x01
115#define UFTDI_FLAG_READ_STALL 0x02
116
117 uint8_t sc_name[16];
118};
119
120struct uftdi_param_config {
121 uint16_t rate;
122 uint16_t lcr;
123 uint8_t v_start;
124 uint8_t v_stop;
125 uint8_t v_flow;
126};
127
128/* prototypes */
129
130static device_probe_t uftdi_probe;
131static device_attach_t uftdi_attach;
132static device_detach_t uftdi_detach;
133
134static usb2_callback_t uftdi_write_callback;
110 uint8_t sc_name[16];
111};
112
113struct uftdi_param_config {
114 uint16_t rate;
115 uint16_t lcr;
116 uint8_t v_start;
117 uint8_t v_stop;
118 uint8_t v_flow;
119};
120
121/* prototypes */
122
123static device_probe_t uftdi_probe;
124static device_attach_t uftdi_attach;
125static device_detach_t uftdi_detach;
126
127static usb2_callback_t uftdi_write_callback;
135static usb2_callback_t uftdi_write_clear_stall_callback;
136static usb2_callback_t uftdi_read_callback;
128static usb2_callback_t uftdi_read_callback;
137static usb2_callback_t uftdi_read_clear_stall_callback;
138
129
139static void uftdi_cfg_do_request(struct uftdi_softc *,
140 struct usb2_device_request *, void *);
141static void uftdi_cfg_open(struct usb2_com_softc *);
142static void uftdi_cfg_set_dtr(struct usb2_com_softc *, uint8_t);
143static void uftdi_cfg_set_rts(struct usb2_com_softc *, uint8_t);
144static void uftdi_cfg_set_break(struct usb2_com_softc *, uint8_t);
145static int uftdi_set_parm_soft(struct termios *,
146 struct uftdi_param_config *, uint8_t);
147static int uftdi_pre_param(struct usb2_com_softc *, struct termios *);
148static void uftdi_cfg_param(struct usb2_com_softc *, struct termios *);

--- 19 unchanged lines hidden (view full) ---

168 [UFTDI_BULK_DT_RD] = {
169 .type = UE_BULK,
170 .endpoint = UE_ADDR_ANY,
171 .direction = UE_DIR_IN,
172 .mh.bufsize = UFTDI_IBUFSIZE,
173 .mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
174 .mh.callback = &uftdi_read_callback,
175 },
130static void uftdi_cfg_open(struct usb2_com_softc *);
131static void uftdi_cfg_set_dtr(struct usb2_com_softc *, uint8_t);
132static void uftdi_cfg_set_rts(struct usb2_com_softc *, uint8_t);
133static void uftdi_cfg_set_break(struct usb2_com_softc *, uint8_t);
134static int uftdi_set_parm_soft(struct termios *,
135 struct uftdi_param_config *, uint8_t);
136static int uftdi_pre_param(struct usb2_com_softc *, struct termios *);
137static void uftdi_cfg_param(struct usb2_com_softc *, struct termios *);

--- 19 unchanged lines hidden (view full) ---

157 [UFTDI_BULK_DT_RD] = {
158 .type = UE_BULK,
159 .endpoint = UE_ADDR_ANY,
160 .direction = UE_DIR_IN,
161 .mh.bufsize = UFTDI_IBUFSIZE,
162 .mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
163 .mh.callback = &uftdi_read_callback,
164 },
176
177 [UFTDI_BULK_CS_WR] = {
178 .type = UE_CONTROL,
179 .endpoint = 0x00, /* Control pipe */
180 .direction = UE_DIR_ANY,
181 .mh.bufsize = sizeof(struct usb2_device_request),
182 .mh.flags = {},
183 .mh.callback = &uftdi_write_clear_stall_callback,
184 .mh.timeout = 1000, /* 1 second */
185 .mh.interval = 50, /* 50ms */
186 },
187
188 [UFTDI_BULK_CS_RD] = {
189 .type = UE_CONTROL,
190 .endpoint = 0x00, /* Control pipe */
191 .direction = UE_DIR_ANY,
192 .mh.bufsize = sizeof(struct usb2_device_request),
193 .mh.flags = {},
194 .mh.callback = &uftdi_read_clear_stall_callback,
195 .mh.timeout = 1000, /* 1 second */
196 .mh.interval = 50, /* 50ms */
197 },
198};
199
200static const struct usb2_com_callback uftdi_callback = {
201 .usb2_com_cfg_get_status = &uftdi_cfg_get_status,
202 .usb2_com_cfg_set_dtr = &uftdi_cfg_set_dtr,
203 .usb2_com_cfg_set_rts = &uftdi_cfg_set_rts,
204 .usb2_com_cfg_set_break = &uftdi_cfg_set_break,
205 .usb2_com_cfg_param = &uftdi_cfg_param,

--- 112 unchanged lines hidden (view full) ---

318 if (error) {
319 device_printf(dev, "allocating USB "
320 "transfers failed!\n");
321 goto detach;
322 }
323 sc->sc_ucom.sc_portno = FTDI_PIT_SIOA + uaa->info.bIfaceNum;
324
325 /* clear stall at first run */
165};
166
167static const struct usb2_com_callback uftdi_callback = {
168 .usb2_com_cfg_get_status = &uftdi_cfg_get_status,
169 .usb2_com_cfg_set_dtr = &uftdi_cfg_set_dtr,
170 .usb2_com_cfg_set_rts = &uftdi_cfg_set_rts,
171 .usb2_com_cfg_set_break = &uftdi_cfg_set_break,
172 .usb2_com_cfg_param = &uftdi_cfg_param,

--- 112 unchanged lines hidden (view full) ---

285 if (error) {
286 device_printf(dev, "allocating USB "
287 "transfers failed!\n");
288 goto detach;
289 }
290 sc->sc_ucom.sc_portno = FTDI_PIT_SIOA + uaa->info.bIfaceNum;
291
292 /* clear stall at first run */
293 usb2_transfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_WR]);
294 usb2_transfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_RD]);
326
295
327 sc->sc_flag |= (UFTDI_FLAG_WRITE_STALL |
328 UFTDI_FLAG_READ_STALL);
329
330 /* set a valid "lcr" value */
331
332 sc->sc_last_lcr =
333 (FTDI_SIO_SET_DATA_STOP_BITS_2 |
334 FTDI_SIO_SET_DATA_PARITY_NONE |
335 FTDI_SIO_SET_DATA_BITS(8));
336
337 error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,

--- 16 unchanged lines hidden (view full) ---

354 usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
355
356 usb2_transfer_unsetup(sc->sc_xfer, UFTDI_N_TRANSFER);
357
358 return (0);
359}
360
361static void
296 /* set a valid "lcr" value */
297
298 sc->sc_last_lcr =
299 (FTDI_SIO_SET_DATA_STOP_BITS_2 |
300 FTDI_SIO_SET_DATA_PARITY_NONE |
301 FTDI_SIO_SET_DATA_BITS(8));
302
303 error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,

--- 16 unchanged lines hidden (view full) ---

320 usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
321
322 usb2_transfer_unsetup(sc->sc_xfer, UFTDI_N_TRANSFER);
323
324 return (0);
325}
326
327static void
362uftdi_cfg_do_request(struct uftdi_softc *sc, struct usb2_device_request *req,
363 void *data)
364{
365 uint16_t length;
366 usb2_error_t err;
367
368 if (usb2_com_cfg_is_gone(&sc->sc_ucom)) {
369 goto error;
370 }
371 err = usb2_do_request_flags
372 (sc->sc_udev, &Giant, req, data, 0, NULL, 1000);
373
374 if (err) {
375
376 DPRINTFN(0, "device request failed, err=%s "
377 "(ignored)\n", usb2_errstr(err));
378
379error:
380 length = UGETW(req->wLength);
381
382 if ((req->bmRequestType & UT_READ) && length) {
383 bzero(data, length);
384 }
385 }
386}
387
388static void
389uftdi_cfg_open(struct usb2_com_softc *ucom)
390{
391 struct uftdi_softc *sc = ucom->sc_parent;
392 uint16_t wIndex = ucom->sc_portno;
393 struct usb2_device_request req;
394
395 DPRINTF("");
396
397 /* perform a full reset on the device */
398
399 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
400 req.bRequest = FTDI_SIO_RESET;
401 USETW(req.wValue, FTDI_SIO_RESET_SIO);
402 USETW(req.wIndex, wIndex);
403 USETW(req.wLength, 0);
328uftdi_cfg_open(struct usb2_com_softc *ucom)
329{
330 struct uftdi_softc *sc = ucom->sc_parent;
331 uint16_t wIndex = ucom->sc_portno;
332 struct usb2_device_request req;
333
334 DPRINTF("");
335
336 /* perform a full reset on the device */
337
338 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
339 req.bRequest = FTDI_SIO_RESET;
340 USETW(req.wValue, FTDI_SIO_RESET_SIO);
341 USETW(req.wIndex, wIndex);
342 USETW(req.wLength, 0);
404 uftdi_cfg_do_request(sc, &req, NULL);
343 usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
344 &req, NULL, 0, 1000);
405
406 /* turn on RTS/CTS flow control */
407
408 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
409 req.bRequest = FTDI_SIO_SET_FLOW_CTRL;
410 USETW(req.wValue, 0);
411 USETW2(req.wIndex, FTDI_SIO_RTS_CTS_HS, wIndex);
412 USETW(req.wLength, 0);
345
346 /* turn on RTS/CTS flow control */
347
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, wIndex);
352 USETW(req.wLength, 0);
413 uftdi_cfg_do_request(sc, &req, NULL);
353 usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
354 &req, NULL, 0, 1000);
414
415 /*
416 * NOTE: with the new UCOM layer there will always be a
417 * "uftdi_cfg_param()" call after "open()", so there is no need for
418 * "open()" to configure anything
419 */
420}
421
422static void
423uftdi_write_callback(struct usb2_xfer *xfer)
424{
425 struct uftdi_softc *sc = xfer->priv_sc;
426 uint32_t actlen;
427 uint8_t buf[1];
428
429 switch (USB_GET_STATE(xfer)) {
430 case USB_ST_SETUP:
431 case USB_ST_TRANSFERRED:
355
356 /*
357 * NOTE: with the new UCOM layer there will always be a
358 * "uftdi_cfg_param()" call after "open()", so there is no need for
359 * "open()" to configure anything
360 */
361}
362
363static void
364uftdi_write_callback(struct usb2_xfer *xfer)
365{
366 struct uftdi_softc *sc = xfer->priv_sc;
367 uint32_t actlen;
368 uint8_t buf[1];
369
370 switch (USB_GET_STATE(xfer)) {
371 case USB_ST_SETUP:
372 case USB_ST_TRANSFERRED:
432 if (sc->sc_flag & UFTDI_FLAG_WRITE_STALL) {
433 usb2_transfer_start(sc->sc_xfer[UFTDI_BULK_CS_WR]);
434 return;
435 }
373tr_setup:
436 if (usb2_com_get_data(&sc->sc_ucom, xfer->frbuffers,
437 sc->sc_hdrlen, UFTDI_OBUFSIZE - sc->sc_hdrlen,
438 &actlen)) {
439
440 if (sc->sc_hdrlen > 0) {
441 buf[0] =
442 FTDI_OUT_TAG(actlen, sc->sc_ucom.sc_portno);
443 usb2_copy_in(xfer->frbuffers, 0, buf, 1);
444 }
445 xfer->frlengths[0] = actlen + sc->sc_hdrlen;
446 usb2_start_hardware(xfer);
447 }
448 return;
449
450 default: /* Error */
451 if (xfer->error != USB_ERR_CANCELLED) {
374 if (usb2_com_get_data(&sc->sc_ucom, xfer->frbuffers,
375 sc->sc_hdrlen, UFTDI_OBUFSIZE - sc->sc_hdrlen,
376 &actlen)) {
377
378 if (sc->sc_hdrlen > 0) {
379 buf[0] =
380 FTDI_OUT_TAG(actlen, sc->sc_ucom.sc_portno);
381 usb2_copy_in(xfer->frbuffers, 0, buf, 1);
382 }
383 xfer->frlengths[0] = actlen + sc->sc_hdrlen;
384 usb2_start_hardware(xfer);
385 }
386 return;
387
388 default: /* Error */
389 if (xfer->error != USB_ERR_CANCELLED) {
452 sc->sc_flag |= UFTDI_FLAG_WRITE_STALL;
453 usb2_transfer_start(sc->sc_xfer[UFTDI_BULK_CS_WR]);
390 /* try to clear stall first */
391 xfer->flags.stall_pipe = 1;
392 goto tr_setup;
454 }
455 return;
393 }
394 return;
456
457 }
458}
459
460static void
395 }
396}
397
398static void
461uftdi_write_clear_stall_callback(struct usb2_xfer *xfer)
462{
463 struct uftdi_softc *sc = xfer->priv_sc;
464 struct usb2_xfer *xfer_other = sc->sc_xfer[UFTDI_BULK_DT_WR];
465
466 if (usb2_clear_stall_callback(xfer, xfer_other)) {
467 DPRINTF("stall cleared\n");
468 sc->sc_flag &= ~UFTDI_FLAG_WRITE_STALL;
469 usb2_transfer_start(xfer_other);
470 }
471}
472
473static void
474uftdi_read_callback(struct usb2_xfer *xfer)
475{
476 struct uftdi_softc *sc = xfer->priv_sc;
477 uint8_t buf[2];
478 uint8_t ftdi_msr;
479 uint8_t msr;
480 uint8_t lsr;
481

--- 32 unchanged lines hidden (view full) ---

514 xfer->actlen -= 2;
515
516 if (xfer->actlen > 0) {
517 usb2_com_put_data(&sc->sc_ucom, xfer->frbuffers, 2,
518 xfer->actlen);
519 }
520 case USB_ST_SETUP:
521tr_setup:
399uftdi_read_callback(struct usb2_xfer *xfer)
400{
401 struct uftdi_softc *sc = xfer->priv_sc;
402 uint8_t buf[2];
403 uint8_t ftdi_msr;
404 uint8_t msr;
405 uint8_t lsr;
406

--- 32 unchanged lines hidden (view full) ---

439 xfer->actlen -= 2;
440
441 if (xfer->actlen > 0) {
442 usb2_com_put_data(&sc->sc_ucom, xfer->frbuffers, 2,
443 xfer->actlen);
444 }
445 case USB_ST_SETUP:
446tr_setup:
522 if (sc->sc_flag & UFTDI_FLAG_READ_STALL) {
523 usb2_transfer_start(sc->sc_xfer[UFTDI_BULK_CS_RD]);
524 } else {
525 xfer->frlengths[0] = xfer->max_data_length;
526 usb2_start_hardware(xfer);
527 }
447 xfer->frlengths[0] = xfer->max_data_length;
448 usb2_start_hardware(xfer);
528 return;
529
530 default: /* Error */
531 if (xfer->error != USB_ERR_CANCELLED) {
449 return;
450
451 default: /* Error */
452 if (xfer->error != USB_ERR_CANCELLED) {
532 sc->sc_flag |= UFTDI_FLAG_READ_STALL;
533 usb2_transfer_start(sc->sc_xfer[UFTDI_BULK_CS_RD]);
453 /* try to clear stall first */
454 xfer->flags.stall_pipe = 1;
455 goto tr_setup;
534 }
535 return;
456 }
457 return;
536
537 }
538}
539
540static void
458 }
459}
460
461static void
541uftdi_read_clear_stall_callback(struct usb2_xfer *xfer)
542{
543 struct uftdi_softc *sc = xfer->priv_sc;
544 struct usb2_xfer *xfer_other = sc->sc_xfer[UFTDI_BULK_DT_RD];
545
546 if (usb2_clear_stall_callback(xfer, xfer_other)) {
547 DPRINTF("stall cleared\n");
548 sc->sc_flag &= ~UFTDI_FLAG_READ_STALL;
549 usb2_transfer_start(xfer_other);
550 }
551}
552
553static void
554uftdi_cfg_set_dtr(struct usb2_com_softc *ucom, uint8_t onoff)
555{
556 struct uftdi_softc *sc = ucom->sc_parent;
557 uint16_t wIndex = ucom->sc_portno;
558 uint16_t wValue;
559 struct usb2_device_request req;
560
561 wValue = onoff ? FTDI_SIO_SET_DTR_HIGH : FTDI_SIO_SET_DTR_LOW;
562
563 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
564 req.bRequest = FTDI_SIO_MODEM_CTRL;
565 USETW(req.wValue, wValue);
566 USETW(req.wIndex, wIndex);
567 USETW(req.wLength, 0);
462uftdi_cfg_set_dtr(struct usb2_com_softc *ucom, uint8_t onoff)
463{
464 struct uftdi_softc *sc = ucom->sc_parent;
465 uint16_t wIndex = ucom->sc_portno;
466 uint16_t wValue;
467 struct usb2_device_request req;
468
469 wValue = onoff ? FTDI_SIO_SET_DTR_HIGH : FTDI_SIO_SET_DTR_LOW;
470
471 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
472 req.bRequest = FTDI_SIO_MODEM_CTRL;
473 USETW(req.wValue, wValue);
474 USETW(req.wIndex, wIndex);
475 USETW(req.wLength, 0);
568 uftdi_cfg_do_request(sc, &req, NULL);
476 usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
477 &req, NULL, 0, 1000);
569}
570
571static void
572uftdi_cfg_set_rts(struct usb2_com_softc *ucom, uint8_t onoff)
573{
574 struct uftdi_softc *sc = ucom->sc_parent;
575 uint16_t wIndex = ucom->sc_portno;
576 uint16_t wValue;
577 struct usb2_device_request req;
578
579 wValue = onoff ? FTDI_SIO_SET_RTS_HIGH : FTDI_SIO_SET_RTS_LOW;
580
581 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
582 req.bRequest = FTDI_SIO_MODEM_CTRL;
583 USETW(req.wValue, wValue);
584 USETW(req.wIndex, wIndex);
585 USETW(req.wLength, 0);
478}
479
480static void
481uftdi_cfg_set_rts(struct usb2_com_softc *ucom, uint8_t onoff)
482{
483 struct uftdi_softc *sc = ucom->sc_parent;
484 uint16_t wIndex = ucom->sc_portno;
485 uint16_t wValue;
486 struct usb2_device_request req;
487
488 wValue = onoff ? FTDI_SIO_SET_RTS_HIGH : FTDI_SIO_SET_RTS_LOW;
489
490 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
491 req.bRequest = FTDI_SIO_MODEM_CTRL;
492 USETW(req.wValue, wValue);
493 USETW(req.wIndex, wIndex);
494 USETW(req.wLength, 0);
586 uftdi_cfg_do_request(sc, &req, NULL);
495 usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
496 &req, NULL, 0, 1000);
587}
588
589static void
590uftdi_cfg_set_break(struct usb2_com_softc *ucom, uint8_t onoff)
591{
592 struct uftdi_softc *sc = ucom->sc_parent;
593 uint16_t wIndex = ucom->sc_portno;
594 uint16_t wValue;

--- 7 unchanged lines hidden (view full) ---

602
603 wValue = sc->sc_last_lcr;
604
605 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
606 req.bRequest = FTDI_SIO_SET_DATA;
607 USETW(req.wValue, wValue);
608 USETW(req.wIndex, wIndex);
609 USETW(req.wLength, 0);
497}
498
499static void
500uftdi_cfg_set_break(struct usb2_com_softc *ucom, uint8_t onoff)
501{
502 struct uftdi_softc *sc = ucom->sc_parent;
503 uint16_t wIndex = ucom->sc_portno;
504 uint16_t wValue;

--- 7 unchanged lines hidden (view full) ---

512
513 wValue = sc->sc_last_lcr;
514
515 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
516 req.bRequest = FTDI_SIO_SET_DATA;
517 USETW(req.wValue, wValue);
518 USETW(req.wIndex, wIndex);
519 USETW(req.wLength, 0);
610 uftdi_cfg_do_request(sc, &req, NULL);
520 usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
521 &req, NULL, 0, 1000);
611}
612
613static int
614uftdi_set_parm_soft(struct termios *t,
615 struct uftdi_param_config *cfg, uint8_t type)
616{
617 bzero(cfg, sizeof(*cfg));
618

--- 115 unchanged lines hidden (view full) ---

734
735 DPRINTF("\n");
736
737 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
738 req.bRequest = FTDI_SIO_SET_BAUD_RATE;
739 USETW(req.wValue, cfg.rate);
740 USETW(req.wIndex, wIndex);
741 USETW(req.wLength, 0);
522}
523
524static int
525uftdi_set_parm_soft(struct termios *t,
526 struct uftdi_param_config *cfg, uint8_t type)
527{
528 bzero(cfg, sizeof(*cfg));
529

--- 115 unchanged lines hidden (view full) ---

645
646 DPRINTF("\n");
647
648 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
649 req.bRequest = FTDI_SIO_SET_BAUD_RATE;
650 USETW(req.wValue, cfg.rate);
651 USETW(req.wIndex, wIndex);
652 USETW(req.wLength, 0);
742 uftdi_cfg_do_request(sc, &req, NULL);
653 usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
654 &req, NULL, 0, 1000);
743
744 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
745 req.bRequest = FTDI_SIO_SET_DATA;
746 USETW(req.wValue, cfg.lcr);
747 USETW(req.wIndex, wIndex);
748 USETW(req.wLength, 0);
655
656 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
657 req.bRequest = FTDI_SIO_SET_DATA;
658 USETW(req.wValue, cfg.lcr);
659 USETW(req.wIndex, wIndex);
660 USETW(req.wLength, 0);
749 uftdi_cfg_do_request(sc, &req, NULL);
661 usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
662 &req, NULL, 0, 1000);
750
751 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
752 req.bRequest = FTDI_SIO_SET_FLOW_CTRL;
753 USETW2(req.wValue, cfg.v_stop, cfg.v_start);
754 USETW2(req.wIndex, cfg.v_flow, wIndex);
755 USETW(req.wLength, 0);
663
664 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
665 req.bRequest = FTDI_SIO_SET_FLOW_CTRL;
666 USETW2(req.wValue, cfg.v_stop, cfg.v_start);
667 USETW2(req.wIndex, cfg.v_flow, wIndex);
668 USETW(req.wLength, 0);
756 uftdi_cfg_do_request(sc, &req, NULL);
669 usb2_com_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
670 &req, NULL, 0, 1000);
757}
758
759static void
760uftdi_cfg_get_status(struct usb2_com_softc *ucom, uint8_t *lsr, uint8_t *msr)
761{
762 struct uftdi_softc *sc = ucom->sc_parent;
763
764 DPRINTF("msr=0x%02x lsr=0x%02x\n",

--- 11 unchanged lines hidden (view full) ---

776 usb2_transfer_start(sc->sc_xfer[UFTDI_BULK_DT_RD]);
777}
778
779static void
780uftdi_stop_read(struct usb2_com_softc *ucom)
781{
782 struct uftdi_softc *sc = ucom->sc_parent;
783
671}
672
673static void
674uftdi_cfg_get_status(struct usb2_com_softc *ucom, uint8_t *lsr, uint8_t *msr)
675{
676 struct uftdi_softc *sc = ucom->sc_parent;
677
678 DPRINTF("msr=0x%02x lsr=0x%02x\n",

--- 11 unchanged lines hidden (view full) ---

690 usb2_transfer_start(sc->sc_xfer[UFTDI_BULK_DT_RD]);
691}
692
693static void
694uftdi_stop_read(struct usb2_com_softc *ucom)
695{
696 struct uftdi_softc *sc = ucom->sc_parent;
697
784 usb2_transfer_stop(sc->sc_xfer[UFTDI_BULK_CS_RD]);
785 usb2_transfer_stop(sc->sc_xfer[UFTDI_BULK_DT_RD]);
786}
787
788static void
789uftdi_start_write(struct usb2_com_softc *ucom)
790{
791 struct uftdi_softc *sc = ucom->sc_parent;
792
793 usb2_transfer_start(sc->sc_xfer[UFTDI_BULK_DT_WR]);
794}
795
796static void
797uftdi_stop_write(struct usb2_com_softc *ucom)
798{
799 struct uftdi_softc *sc = ucom->sc_parent;
800
698 usb2_transfer_stop(sc->sc_xfer[UFTDI_BULK_DT_RD]);
699}
700
701static void
702uftdi_start_write(struct usb2_com_softc *ucom)
703{
704 struct uftdi_softc *sc = ucom->sc_parent;
705
706 usb2_transfer_start(sc->sc_xfer[UFTDI_BULK_DT_WR]);
707}
708
709static void
710uftdi_stop_write(struct usb2_com_softc *ucom)
711{
712 struct uftdi_softc *sc = ucom->sc_parent;
713
801 usb2_transfer_stop(sc->sc_xfer[UFTDI_BULK_CS_WR]);
802 usb2_transfer_stop(sc->sc_xfer[UFTDI_BULK_DT_WR]);
803}
804
805/*------------------------------------------------------------------------*
806 * uftdi_8u232am_getrate
807 *
808 * Return values:
809 * 0: Success

--- 63 unchanged lines hidden ---
714 usb2_transfer_stop(sc->sc_xfer[UFTDI_BULK_DT_WR]);
715}
716
717/*------------------------------------------------------------------------*
718 * uftdi_8u232am_getrate
719 *
720 * Return values:
721 * 0: Success

--- 63 unchanged lines hidden ---