diff options
| author | ichiro <ichiro@NetBSD.org> | 2001-12-17 14:31:02 +0000 |
|---|---|---|
| committer | ichiro <ichiro@NetBSD.org> | 2001-12-17 14:31:02 +0000 |
| commit | 1b0449d255803a529cd2be4e6fd1e770da6b23b3 (patch) | |
| tree | 527b66b5a5a26c265ee2a7c74d11055f5738a03e /sys/dev | |
| parent | d5f332950121863e61ea3beccab938c627edac4f (diff) | |
support BREAK function,
keep a value of the last LCR.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/uftdi.c | 34 | ||||
| -rw-r--r-- | sys/dev/usb/uftdireg.h | 3 |
2 files changed, 33 insertions, 4 deletions
diff --git a/sys/dev/usb/uftdi.c b/sys/dev/usb/uftdi.c index 84128723ad1..6ed62c50261 100644 --- a/sys/dev/usb/uftdi.c +++ b/sys/dev/usb/uftdi.c @@ -1,4 +1,4 @@ -/* $NetBSD: uftdi.c,v 1.7 2001/11/13 06:24:54 lukem Exp $ */ +/* $NetBSD: uftdi.c,v 1.8 2001/12/17 14:31:02 ichiro Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -46,7 +46,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.7 2001/11/13 06:24:54 lukem Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.8 2001/12/17 14:31:02 ichiro Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -97,6 +97,8 @@ struct uftdi_softc { device_ptr_t sc_subdev; u_char sc_dying; + + u_int last_lcr; }; Static void uftdi_get_status(void *, int portno, u_char *lsr, u_char *msr); @@ -106,6 +108,7 @@ Static int uftdi_open(void *sc, int portno); Static void uftdi_read(void *sc, int portno, u_char **ptr,u_int32_t *count); Static void uftdi_write(void *sc, int portno, u_char *to, u_char *from, u_int32_t *count); +Static void uftdi_break(void *sc, int portno, int onoff); struct ucom_methods uftdi_methods = { uftdi_get_status, @@ -378,7 +381,7 @@ uftdi_set(void *vsc, int portno, int reg, int onoff) ctl = onoff ? FTDI_SIO_SET_RTS_HIGH : FTDI_SIO_SET_RTS_LOW; break; case UCOM_SET_BREAK: - /* XXX how do we set break? */ + uftdi_break(sc, portno, onoff); return; default: return; @@ -458,6 +461,8 @@ uftdi_param(void *vsc, int portno, struct termios *t) data |= FTDI_SIO_SET_DATA_BITS(8); break; } + sc->last_lcr = data; + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.bRequest = FTDI_SIO_SET_DATA; USETW(req.wValue, data); @@ -486,3 +491,26 @@ uftdi_get_status(void *vsc, int portno, u_char *lsr, u_char *msr) if (lsr != NULL) *lsr = sc->sc_lsr; } + +void +uftdi_break(void *vsc, int portno, int onoff) +{ + struct uftdi_softc *sc = vsc; + int data; + + DPRINTF(("uftdi_break: sc=%p, port=%d onoff=%d\n", vsc, portno, + onoff)); + + if (onoff) { + data = sc->last_lcr | FTDI_SIO_SET_BREAK; + } else { + data = sc->last_lcr; + } + + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = FTDI_SIO_SET_DATA; + USETW(req.wValue, data); + USETW(req.wIndex, portno); + USETW(req.wLength, 0); + (void)usbd_do_request(sc->sc_udev, &req, NULL); +} diff --git a/sys/dev/usb/uftdireg.h b/sys/dev/usb/uftdireg.h index 7a594d2f59d..3dcaacb7345 100644 --- a/sys/dev/usb/uftdireg.h +++ b/sys/dev/usb/uftdireg.h @@ -1,4 +1,4 @@ -/* $NetBSD: uftdireg.h,v 1.3 2001/06/12 14:59:28 wiz Exp $ */ +/* $NetBSD: uftdireg.h,v 1.4 2001/12/17 14:31:02 ichiro Exp $ */ /* * Definitions for the FTDI USB Single Port Serial Converter - @@ -120,6 +120,7 @@ enum { #define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11) #define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11) #define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11) +#define FTDI_SIO_SET_BREAK (0x1 << 14) /* |
