1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_USB_USBSER_KEYSPAN_USA90MSG_H
28 #define	_SYS_USB_USBSER_KEYSPAN_USA90MSG_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 typedef struct keyspan_usa19hs_port_ctrl_msg keyspan_usa19hs_port_ctrl_msg_t;
37 typedef struct keyspan_usa19hs_port_status_msg
38     keyspan_usa19hs_port_status_msg_t;
39 
40 /*
41  * usa90msg.h
42  *
43  * Copyright (c) 1998-2003 InnoSys Incorporated.  All Rights Reserved
44  *
45  * Keyspan USB Async Firmware to run on xxxxx
46  *
47  *
48  * Revisions:
49  *
50  * 2003feb14		add setTxMode/txMode  and cancelRxXoff to portControl
51  *
52  */
53 
54 struct keyspan_usa19hs_port_ctrl_msg {
55 	/*
56 	 * there are three types of "commands" sent in the control message:
57 	 *
58 	 * configuration changes which must be requested by setting
59 	 * the corresponding "set" flag (and should only be requested
60 	 * when necessary, to reduce overhead on the device):
61 	 */
62 
63 	uint8_t setClocking;	/* host requests baud rate be set */
64 	uint8_t baudLo;		/* host does baud divisor calculation */
65 	uint8_t baudHi;		/* host does baud divisor calculation */
66 
67 	uint8_t setLcr;		/* host requests lcr be set */
68 	uint8_t lcr;		/* use PARITY, STOPBITS, DATABITS below */
69 
70 	uint8_t setRxMode;	/* set receive mode */
71 	uint8_t rxMode;		/* RXMODE_DMA or RXMODE_BYHAND */
72 
73 	uint8_t setTxMode;	/* set transmit mode */
74 	uint8_t txMode;		/* TXMODE_DMA or TXMODE_BYHAND */
75 
76 	/* host requests tx flow control be set */
77 	uint8_t setTxFlowControl;
78 	uint8_t txFlowControl;	/* use TX_FLOW... bits below */
79 
80 	/* host requests rx flow control be set */
81 	uint8_t setRxFlowControl;
82 	uint8_t rxFlowControl;	/* use RX_FLOW... bits below */
83 	uint8_t sendXoff;	/* host requests XOFF transmitted immediately */
84 	uint8_t sendXon;	/* host requests XON char transmitted */
85 	uint8_t xonChar;	/* specified in current character format */
86 	uint8_t xoffChar;	/* specified in current character format */
87 
88 	uint8_t sendChar;	/* host requests char transmitted immediately */
89 	uint8_t txChar;		/* character to send */
90 
91 	uint8_t setRts;		/* host requests RTS output be set */
92 	uint8_t rts;		/* 1=on, 0=off */
93 	uint8_t setDtr;		/* host requests DTR output be set */
94 	uint8_t dtr;		/* 1=on, 0=off */
95 
96 	/*
97 	 * configuration data which is simply used as is
98 	 * and must be specified correctly in every host message.
99 	 */
100 
101 	/* forward when this number of chars available */
102 	uint8_t rxForwardingLength;
103 	uint8_t rxForwardingTimeout;	/* (1-31 in ms) */
104 	uint8_t txAckSetting;	/* 0=don't ack, 1=normal, 2-255 TBD... */
105 	/*
106 	 * Firmware states which cause actions if they change
107 	 * and must be specified correctly in every host message.
108 	 */
109 
110 	uint8_t portEnabled;	/* 0=disabled, 1=enabled */
111 	uint8_t txFlush;	/* 0=normal, 1=toss outbound data */
112 	uint8_t txBreak;	/* 0=break off, 1=break on */
113 	uint8_t loopbackMode;	/* 0=no loopback, 1=loopback enabled */
114 
115 	/*
116 	 * commands which are flags only; these are processed in order
117 	 * (so that, e.g., if rxFlush and rxForward flags are set, the
118 	 * port will have no data to forward); any non-zero value
119 	 * is respected
120 	 */
121 
122 	uint8_t rxFlush;	/* toss inbound data */
123 
124 	/* forward all inbound data, NOW (as if fwdLen==1) */
125 	uint8_t rxForward;
126 	uint8_t cancelRxXoff;	/* cancel any receive XOFF state (_txXoff) */
127 	uint8_t returnStatus;	/* return current status NOW */
128 };
129 
130 /* defines for bits in lcr */
131 #define		USA_DATABITS_5		0x00
132 #define		USA_DATABITS_6		0x01
133 #define		USA_DATABITS_7		0x02
134 #define		USA_DATABITS_8		0x03
135 #define		STOPBITS_5678_1		0x00 /* 1 stop bit for all byte sizes */
136 #define		STOPBITS_5_1p5		0x04 /* 1.5 stop bits for 5-bit byte */
137 #define		STOPBITS_678_2		0x04 /* 2 stop bits for 6-8 bit byte */
138 #define		USA_PARITY_NONE		0x00
139 #define		USA_PARITY_ODD		0x08
140 #define		USA_PARITY_EVEN		0x18
141 #define		PARITY_MARK_1		0x28 /* force parity MARK */
142 #define		PARITY_SPACE_0		0x38 /* force parity SPACE */
143 
144 #define		TXFLOW_CTS			0x04
145 #define		TXFLOW_DSR			0x08
146 #define		TXFLOW_XOFF			0x01
147 #define		TXFLOW_XOFF_ANY		0x02
148 #define		TXFLOW_XOFF_BITS	(TXFLOW_XOFF | TXFLOW_XOFF_ANY)
149 
150 #define		RXFLOW_XOFF			0x10
151 #define		RXFLOW_RTS			0x20
152 #define		RXFLOW_DTR			0x40
153 #define		RXFLOW_DSR_SENSITIVITY	0x80
154 
155 #define		RXMODE_BYHAND		0x00
156 #define		RXMODE_DMA			0x02
157 
158 #define		TXMODE_BYHAND		0x00
159 #define		TXMODE_DMA			0x02
160 
161 /* all things called "StatusMessage" are sent on the status endpoint */
162 
163 struct keyspan_usa19hs_port_status_msg {
164 	uint8_t msr;		/* reports the actual MSR register */
165 	uint8_t cts;		/* reports CTS pin */
166 	uint8_t dcd;		/* reports DCD pin */
167 	uint8_t dsr;		/* reports DSR pin */
168 	uint8_t ri;		/* reports RI pin */
169 	uint8_t _txXoff;	/* port is in XOFF state (we received XOFF) */
170 	uint8_t rxBreak;	/* reports break state */
171 
172 	/* count of overrun errors (since last reported) */
173 	uint8_t rxOverrun;
174 
175 	/* count of parity errors (since last reported) */
176 	uint8_t rxParity;
177 
178 	/* count of frame errors (since last reported) */
179 	uint8_t rxFrame;
180 	uint8_t portState;	/* PORTSTATE_xxx bits (useful for debugging) */
181 	uint8_t messageAck;	/* message acknowledgement */
182 	uint8_t charAck;	/* character acknowledgement */
183 
184 	/* (value = returnStatus) a control message has been processed */
185 	uint8_t controlResponse;
186 };
187 
188 /* bits in RX data message when STAT byte is included */
189 
190 #define	RXERROR_OVERRUN		0x02
191 #define	RXERROR_PARITY		0x04
192 #define	RXERROR_FRAMING		0x08
193 #define	RXERROR_BREAK		0x10
194 
195 #define	PORTSTATE_ENABLED	0x80
196 #define	PORTSTATE_TXFLUSH	0x01
197 #define	PORTSTATE_TXBREAK	0x02
198 #define	PORTSTATE_LOOPBACK	0x04
199 
200 /* MSR bits */
201 
202 /* CTS has changed since last report */
203 #define	USA_MSR_dCTS			0x01
204 #define	USA_MSR_dDSR			0x02
205 #define	USA_MSR_dRI			0x04
206 #define	USA_MSR_dDCD			0x08
207 
208 #define	USA_MSR_CTS			0x10	/* current state of CTS */
209 #define	USA_MSR_DSR			0x20
210 #define	USA_USA_MSR_RI			0x40
211 #define	MSR_DCD				0x80
212 
213 /* ie: the maximum length of an endpoint buffer */
214 #define		MAX_DATA_LEN			64
215 
216 #ifdef	__cplusplus
217 }
218 #endif
219 
220 #endif	/* _SYS_USB_USBSER_KEYSPAN_USA90MSG_H */
221