ubsavar.h revision 1.3.2.2 1 1.3.2.2 mjf /* $NetBSD: ubsavar.h,v 1.3.2.2 2008/02/18 21:06:26 mjf Exp $ */
2 1.3.2.2 mjf /*-
3 1.3.2.2 mjf * Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>.
4 1.3.2.2 mjf * All rights reserved.
5 1.3.2.2 mjf *
6 1.3.2.2 mjf * Redistribution and use in source and binary forms, with or without
7 1.3.2.2 mjf * modification, are permitted provided that the following conditions
8 1.3.2.2 mjf * are met:
9 1.3.2.2 mjf * 1. Redistributions of source code must retain the above copyright
10 1.3.2.2 mjf * notice, this list of conditions and the following disclaimer.
11 1.3.2.2 mjf * 2. Redistributions in binary form must reproduce the above copyright
12 1.3.2.2 mjf * notice, this list of conditions and the following disclaimer in the
13 1.3.2.2 mjf * documentation and/or other materials provided with the distribution.
14 1.3.2.2 mjf *
15 1.3.2.2 mjf * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 1.3.2.2 mjf * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 1.3.2.2 mjf * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 1.3.2.2 mjf * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 1.3.2.2 mjf * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 1.3.2.2 mjf * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 1.3.2.2 mjf * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.3.2.2 mjf * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 1.3.2.2 mjf * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 1.3.2.2 mjf * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 1.3.2.2 mjf * SUCH DAMAGE.
26 1.3.2.2 mjf */
27 1.3.2.2 mjf /*
28 1.3.2.2 mjf * Copyright (c) 2001 The NetBSD Foundation, Inc.
29 1.3.2.2 mjf * All rights reserved.
30 1.3.2.2 mjf *
31 1.3.2.2 mjf * This code is derived from software contributed to The NetBSD Foundation
32 1.3.2.2 mjf * by Ichiro FUKUHARA (ichiro (at) ichiro.org).
33 1.3.2.2 mjf *
34 1.3.2.2 mjf * Redistribution and use in source and binary forms, with or without
35 1.3.2.2 mjf * modification, are permitted provided that the following conditions
36 1.3.2.2 mjf * are met:
37 1.3.2.2 mjf * 1. Redistributions of source code must retain the above copyright
38 1.3.2.2 mjf * notice, this list of conditions and the following disclaimer.
39 1.3.2.2 mjf * 2. Redistributions in binary form must reproduce the above copyright
40 1.3.2.2 mjf * notice, this list of conditions and the following disclaimer in the
41 1.3.2.2 mjf * documentation and/or other materials provided with the distribution.
42 1.3.2.2 mjf * 3. All advertising materials mentioning features or use of this software
43 1.3.2.2 mjf * must display the following acknowledgement:
44 1.3.2.2 mjf * This product includes software developed by the NetBSD
45 1.3.2.2 mjf * Foundation, Inc. and its contributors.
46 1.3.2.2 mjf * 4. Neither the name of The NetBSD Foundation nor the names of its
47 1.3.2.2 mjf * contributors may be used to endorse or promote products derived
48 1.3.2.2 mjf * from this software without specific prior written permission.
49 1.3.2.2 mjf *
50 1.3.2.2 mjf * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
51 1.3.2.2 mjf * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
52 1.3.2.2 mjf * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53 1.3.2.2 mjf * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
54 1.3.2.2 mjf * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
55 1.3.2.2 mjf * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
56 1.3.2.2 mjf * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57 1.3.2.2 mjf * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58 1.3.2.2 mjf * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59 1.3.2.2 mjf * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
60 1.3.2.2 mjf * POSSIBILITY OF SUCH DAMAGE.
61 1.3.2.2 mjf */
62 1.3.2.2 mjf
63 1.3.2.2 mjf #define UBSA_MODVER 1 /* module version */
64 1.3.2.2 mjf
65 1.3.2.2 mjf #define UBSA_DEFAULT_CONFIG_INDEX 1
66 1.3.2.2 mjf #define UBSA_IFACE_INDEX_OFFSET 0
67 1.3.2.2 mjf
68 1.3.2.2 mjf #define UBSA_INTR_INTERVAL 100 /* ms */
69 1.3.2.2 mjf
70 1.3.2.2 mjf #define UBSA_SET_BAUDRATE 0x00
71 1.3.2.2 mjf #define UBSA_SET_STOP_BITS 0x01
72 1.3.2.2 mjf #define UBSA_SET_DATA_BITS 0x02
73 1.3.2.2 mjf #define UBSA_SET_PARITY 0x03
74 1.3.2.2 mjf #define UBSA_SET_DTR 0x0A
75 1.3.2.2 mjf #define UBSA_SET_RTS 0x0B
76 1.3.2.2 mjf #define UBSA_SET_BREAK 0x0C
77 1.3.2.2 mjf #define UBSA_SET_FLOW_CTRL 0x10
78 1.3.2.2 mjf
79 1.3.2.2 mjf #define UBSA_QUADUMTS_SET_PIN 0x22
80 1.3.2.2 mjf
81 1.3.2.2 mjf #define UBSA_PARITY_NONE 0x00
82 1.3.2.2 mjf #define UBSA_PARITY_EVEN 0x01
83 1.3.2.2 mjf #define UBSA_PARITY_ODD 0x02
84 1.3.2.2 mjf #define UBSA_PARITY_MARK 0x03
85 1.3.2.2 mjf #define UBSA_PARITY_SPACE 0x04
86 1.3.2.2 mjf
87 1.3.2.2 mjf #define UBSA_FLOW_NONE 0x0000
88 1.3.2.2 mjf #define UBSA_FLOW_OCTS 0x0001
89 1.3.2.2 mjf #define UBSA_FLOW_ODSR 0x0002
90 1.3.2.2 mjf #define UBSA_FLOW_IDSR 0x0004
91 1.3.2.2 mjf #define UBSA_FLOW_IDTR 0x0008
92 1.3.2.2 mjf #define UBSA_FLOW_IRTS 0x0010
93 1.3.2.2 mjf #define UBSA_FLOW_ORTS 0x0020
94 1.3.2.2 mjf #define UBSA_FLOW_UNKNOWN 0x0040
95 1.3.2.2 mjf #define UBSA_FLOW_OXON 0x0080
96 1.3.2.2 mjf #define UBSA_FLOW_IXON 0x0100
97 1.3.2.2 mjf
98 1.3.2.2 mjf /* line status register */
99 1.3.2.2 mjf #define UBSA_LSR_TSRE 0x40 /* Transmitter empty: byte sent */
100 1.3.2.2 mjf #define UBSA_LSR_TXRDY 0x20 /* Transmitter buffer empty */
101 1.3.2.2 mjf #define UBSA_LSR_BI 0x10 /* Break detected */
102 1.3.2.2 mjf #define UBSA_LSR_FE 0x08 /* Framing error: bad stop bit */
103 1.3.2.2 mjf #define UBSA_LSR_PE 0x04 /* Parity error */
104 1.3.2.2 mjf #define UBSA_LSR_OE 0x02 /* Overrun, lost incoming byte */
105 1.3.2.2 mjf #define UBSA_LSR_RXRDY 0x01 /* Byte ready in Receive Buffer */
106 1.3.2.2 mjf #define UBSA_LSR_RCV_MASK 0x1f /* Mask for incoming data or error */
107 1.3.2.2 mjf
108 1.3.2.2 mjf /* modem status register */
109 1.3.2.2 mjf /* All deltas are from the last read of the MSR. */
110 1.3.2.2 mjf #define UBSA_MSR_DCD 0x80 /* Current Data Carrier Detect */
111 1.3.2.2 mjf #define UBSA_MSR_RI 0x40 /* Current Ring Indicator */
112 1.3.2.2 mjf #define UBSA_MSR_DSR 0x20 /* Current Data Set Ready */
113 1.3.2.2 mjf #define UBSA_MSR_CTS 0x10 /* Current Clear to Send */
114 1.3.2.2 mjf #define UBSA_MSR_DDCD 0x08 /* DCD has changed state */
115 1.3.2.2 mjf #define UBSA_MSR_TERI 0x04 /* RI has toggled low to high */
116 1.3.2.2 mjf #define UBSA_MSR_DDSR 0x02 /* DSR has changed state */
117 1.3.2.2 mjf #define UBSA_MSR_DCTS 0x01 /* CTS has changed state */
118 1.3.2.2 mjf
119 1.3.2.2 mjf #define UBSA_MAXCONN 3
120 1.3.2.2 mjf
121 1.3.2.2 mjf struct ubsa_softc {
122 1.3.2.2 mjf USBBASEDEVICE sc_dev; /* base device */
123 1.3.2.2 mjf usbd_device_handle sc_udev; /* USB device */
124 1.3.2.2 mjf usbd_interface_handle sc_iface[UBSA_MAXCONN]; /* interface */
125 1.3.2.2 mjf
126 1.3.2.2 mjf int sc_iface_number[UBSA_MAXCONN]; /* interface number */
127 1.3.2.2 mjf int sc_config_index; /* USB CONFIG_INDEX */
128 1.3.2.2 mjf
129 1.3.2.2 mjf int sc_intr_number; /* interrupt number */
130 1.3.2.2 mjf usbd_pipe_handle sc_intr_pipe; /* interrupt pipe */
131 1.3.2.2 mjf u_char *sc_intr_buf; /* interrupt buffer */
132 1.3.2.2 mjf int sc_isize;
133 1.3.2.2 mjf
134 1.3.2.2 mjf u_char sc_dtr; /* current DTR state */
135 1.3.2.2 mjf u_char sc_rts; /* current RTS state */
136 1.3.2.2 mjf
137 1.3.2.2 mjf u_char sc_lsr; /* Local status register */
138 1.3.2.2 mjf u_char sc_msr; /* ubsa status register */
139 1.3.2.2 mjf
140 1.3.2.2 mjf device_ptr_t sc_subdevs[UBSA_MAXCONN]; /* ucom device */
141 1.3.2.2 mjf int sc_numif; /* number of interfaces */
142 1.3.2.2 mjf
143 1.3.2.2 mjf u_char sc_dying; /* disconnecting */
144 1.3.2.2 mjf u_char sc_quadumts;
145 1.3.2.2 mjf u_int16_t sc_devflags;
146 1.3.2.2 mjf };
147 1.3.2.2 mjf
148 1.3.2.2 mjf
149 1.3.2.2 mjf void ubsa_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
150 1.3.2.2 mjf
151 1.3.2.2 mjf void ubsa_get_status(void *, int, u_char *, u_char *);
152 1.3.2.2 mjf void ubsa_set(void *, int, int, int);
153 1.3.2.2 mjf int ubsa_param(void *, int, struct termios *);
154 1.3.2.2 mjf int ubsa_open(void *, int);
155 1.3.2.2 mjf void ubsa_close(void *, int);
156 1.3.2.2 mjf
157 1.3.2.2 mjf void ubsa_break(struct ubsa_softc *sc, int, int onoff);
158 1.3.2.2 mjf int ubsa_request(struct ubsa_softc *, int, u_int8_t, u_int16_t);
159 1.3.2.2 mjf void ubsa_dtr(struct ubsa_softc *, int, int);
160 1.3.2.2 mjf void ubsa_quadumts_dtr(struct ubsa_softc *, int, int);
161 1.3.2.2 mjf void ubsa_rts(struct ubsa_softc *, int, int);
162 1.3.2.2 mjf void ubsa_quadumts_rts(struct ubsa_softc *, int, int);
163 1.3.2.2 mjf void ubsa_baudrate(struct ubsa_softc *, int, speed_t);
164 1.3.2.2 mjf void ubsa_parity(struct ubsa_softc *, int, tcflag_t);
165 1.3.2.2 mjf void ubsa_databits(struct ubsa_softc *, int, tcflag_t);
166 1.3.2.2 mjf void ubsa_stopbits(struct ubsa_softc *, int, tcflag_t);
167 1.3.2.2 mjf void ubsa_flow(struct ubsa_softc *, int, tcflag_t, tcflag_t);
168