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