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