ucomvar.h revision 1.12 1 /* $NetBSD: ucomvar.h,v 1.12 2005/08/26 12:42:11 drochner Exp $ */
2
3 /*
4 * Copyright (c) 1999 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 (at) augustsson.net) at
9 * Carlstedt Research & Technology.
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 /* Macros to clear/set/test flags. */
42 #define SET(t, f) (t) |= (f)
43 #define CLR(t, f) (t) &= ~(f)
44 #define ISSET(t, f) ((t) & (f))
45
46 /* just for ucom_attach_args, not in the config namespace */
47 #define UCOM_UNK_PORTNO (-1)
48
49 struct ucom_softc;
50
51 struct ucom_methods {
52 void (*ucom_get_status)(void *sc, int portno, u_char *lsr, u_char *msr);
53 void (*ucom_set)(void *sc, int portno, int reg, int onoff);
54 #define UCOM_SET_DTR 1
55 #define UCOM_SET_RTS 2
56 #define UCOM_SET_BREAK 3
57 int (*ucom_param)(void *sc, int portno, struct termios *);
58 int (*ucom_ioctl)(void *sc, int portno, u_long cmd,
59 caddr_t data, int flag, usb_proc_ptr p);
60 int (*ucom_open)(void *sc, int portno);
61 void (*ucom_close)(void *sc, int portno);
62 void (*ucom_read)(void *sc, int portno, u_char **ptr, u_int32_t *count);
63 void (*ucom_write)(void *sc, int portno, u_char *to, u_char *from,
64 u_int32_t *count);
65 };
66
67 /* modem control register */
68 #define UMCR_RTS 0x02 /* Request To Send */
69 #define UMCR_DTR 0x01 /* Data Terminal Ready */
70
71 /* line status register */
72 #define ULSR_RCV_FIFO 0x80
73 #define ULSR_TSRE 0x40 /* Transmitter empty: byte sent */
74 #define ULSR_TXRDY 0x20 /* Transmitter buffer empty */
75 #define ULSR_BI 0x10 /* Break detected */
76 #define ULSR_FE 0x08 /* Framing error: bad stop bit */
77 #define ULSR_PE 0x04 /* Parity error */
78 #define ULSR_OE 0x02 /* Overrun, lost incoming byte */
79 #define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */
80 #define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */
81
82 /* modem status register */
83 /* All deltas are from the last read of the MSR. */
84 #define UMSR_DCD 0x80 /* Current Data Carrier Detect */
85 #define UMSR_RI 0x40 /* Current Ring Indicator */
86 #define UMSR_DSR 0x20 /* Current Data Set Ready */
87 #define UMSR_CTS 0x10 /* Current Clear to Send */
88 #define UMSR_DDCD 0x08 /* DCD has changed state */
89 #define UMSR_TERI 0x04 /* RI has toggled low to high */
90 #define UMSR_DDSR 0x02 /* DSR has changed state */
91 #define UMSR_DCTS 0x01 /* CTS has changed state */
92
93 struct ucom_attach_args {
94 int portno;
95 int bulkin;
96 int bulkout;
97 u_int ibufsize;
98 u_int ibufsizepad;
99 u_int obufsize;
100 u_int opkthdrlen;
101 const char *info; /* attach message */
102 usbd_device_handle device;
103 usbd_interface_handle iface;
104 struct ucom_methods *methods;
105 void *arg;
106 };
107
108 int ucomprint(void *, const char *);
109 int ucomsubmatch(struct device *t, struct cfdata *,
110 const int *, void *);
111 void ucom_status_change(struct ucom_softc *);
112