xref: /linux/drivers/usb/serial/keyspan_usa28msg.h (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1*527c1e56SGreg Kroah-Hartman /* SPDX-License-Identifier: BSD-3-Clause */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds 	usa28msg.h
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds 	Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
61da177e4SLinus Torvalds 	This file is available under a BSD-style copyright
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds 	Keyspan USB Async Message Formats for the USA26X
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds 	Redistribution and use in source and binary forms, with or without
111da177e4SLinus Torvalds 	modification, are permitted provided that the following conditions are
121da177e4SLinus Torvalds 	met:
131da177e4SLinus Torvalds 
141da177e4SLinus Torvalds 	1. Redistributions of source code must retain this licence text
151da177e4SLinus Torvalds    	without modification, this list of conditions, and the following
161da177e4SLinus Torvalds    	disclaimer.  The following copyright notice must appear immediately at
171da177e4SLinus Torvalds    	the beginning of all source files:
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds         	Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds         	This file is available under a BSD-style copyright
221da177e4SLinus Torvalds 
231da177e4SLinus Torvalds 	2. The name of InnoSys Incorporated may not be used to endorse or promote
241da177e4SLinus Torvalds    	products derived from this software without specific prior written
251da177e4SLinus Torvalds    	permission.
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds 	THIS SOFTWARE IS PROVIDED BY INNOSYS CORP. ``AS IS'' AND ANY EXPRESS OR
281da177e4SLinus Torvalds 	IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
291da177e4SLinus Torvalds 	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
301da177e4SLinus Torvalds 	NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
311da177e4SLinus Torvalds 	INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
321da177e4SLinus Torvalds 	(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
331da177e4SLinus Torvalds 	SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
341da177e4SLinus Torvalds 	CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
351da177e4SLinus Torvalds 	LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
361da177e4SLinus Torvalds 	OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
371da177e4SLinus Torvalds 	SUCH DAMAGE.
381da177e4SLinus Torvalds 
391da177e4SLinus Torvalds 	Note: these message formats are common to USA18, USA19, and USA28;
401da177e4SLinus Torvalds 	(for USA28X, see usa26msg.h)
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds 	Buffer formats for RX/TX data messages are not defined by
431da177e4SLinus Torvalds 	a structure, but are described here:
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds 	USB OUT (host -> USA28, transmit) messages contain a
461da177e4SLinus Torvalds 	REQUEST_ACK indicator (set to 0xff to request an ACK at the
471da177e4SLinus Torvalds 	completion of transmit; 0x00 otherwise), followed by data.
481da177e4SLinus Torvalds 	If the port is configured for parity, the data will be an
491da177e4SLinus Torvalds 	alternating string of parity and data bytes, so the message
501da177e4SLinus Torvalds 	format will be:
511da177e4SLinus Torvalds 
521da177e4SLinus Torvalds 		RQSTACK PAR DAT PAR DAT ...
531da177e4SLinus Torvalds 
541da177e4SLinus Torvalds 	so the maximum length is 63 bytes (1 + 62, or 31 data bytes);
551da177e4SLinus Torvalds 	always an odd number for the total message length.
561da177e4SLinus Torvalds 
571da177e4SLinus Torvalds 	If there is no parity, the format is simply:
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds 		RQSTACK DAT DAT DAT ...
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds 	with a total data length of 63.
621da177e4SLinus Torvalds 
631da177e4SLinus Torvalds 	USB IN (USA28 -> host, receive) messages contain data and parity
641da177e4SLinus Torvalds 	if parity is configred, thusly:
651da177e4SLinus Torvalds 
661da177e4SLinus Torvalds 		DAT PAR DAT PAR DAT PAR ...
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds 	for a total of 32 data bytes;
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds 	If parity is not configured, the format is:
711da177e4SLinus Torvalds 
721da177e4SLinus Torvalds 		DAT DAT DAT ...
731da177e4SLinus Torvalds 
741da177e4SLinus Torvalds 	for a total of 64 data bytes.
751da177e4SLinus Torvalds 
761da177e4SLinus Torvalds 	In the TX messages (USB OUT), the 0x01 bit of the PARity byte is
771da177e4SLinus Torvalds 	the parity bit.  In the RX messages (USB IN), the PARity byte is
781da177e4SLinus Torvalds 	the content of the 8051's status register; the parity bit
791da177e4SLinus Torvalds 	(RX_PARITY_BIT) is the 0x04 bit.
801da177e4SLinus Torvalds 
811da177e4SLinus Torvalds 	revision history:
821da177e4SLinus Torvalds 
831da177e4SLinus Torvalds 	1999may06	add resetDataToggle to control message
841da177e4SLinus Torvalds 	2000mar21	add rs232invalid to status response message
851da177e4SLinus Torvalds 	2000apr04	add 230.4Kb definition to setBaudRate
861da177e4SLinus Torvalds 	2000apr13	add/remove loopbackMode switch
871da177e4SLinus Torvalds 	2000apr13	change definition of setBaudRate to cover 115.2Kb, too
881da177e4SLinus Torvalds 	2000jun01	add extended BSD-style copyright text
891da177e4SLinus Torvalds */
901da177e4SLinus Torvalds 
911da177e4SLinus Torvalds #ifndef	__USA28MSG__
921da177e4SLinus Torvalds #define	__USA28MSG__
931da177e4SLinus Torvalds 
941da177e4SLinus Torvalds 
951da177e4SLinus Torvalds struct keyspan_usa28_portControlMessage
961da177e4SLinus Torvalds {
971da177e4SLinus Torvalds 	/*
981da177e4SLinus Torvalds 		there are four types of "commands" sent in the control message:
991da177e4SLinus Torvalds 
1001da177e4SLinus Torvalds 		1.	configuration changes which must be requested by setting
1011da177e4SLinus Torvalds 			the corresponding "set" flag (and should only be requested
1021da177e4SLinus Torvalds 			when necessary, to reduce overhead on the USA28):
1031da177e4SLinus Torvalds 	*/
1041da177e4SLinus Torvalds 	u8	setBaudRate,	// 0=don't set, 1=baudLo/Hi, 2=115.2K, 3=230.4K
1051da177e4SLinus Torvalds 		baudLo,			// host does baud divisor calculation
1061da177e4SLinus Torvalds 		baudHi;			// baudHi is only used for first port (gives lower rates)
1071da177e4SLinus Torvalds 
1081da177e4SLinus Torvalds 	/*
1091da177e4SLinus Torvalds 		2.	configuration changes which are done every time (because it's
1101da177e4SLinus Torvalds 			hardly more trouble to do them than to check whether to do them):
1111da177e4SLinus Torvalds 	*/
1121da177e4SLinus Torvalds 	u8	parity,			// 1=use parity, 0=don't
1131da177e4SLinus Torvalds 		ctsFlowControl,	        // all except 19Q: 1=use CTS flow control, 0=don't
1141da177e4SLinus Torvalds 					// 19Q: 0x08:CTSflowControl 0x10:DSRflowControl
1151da177e4SLinus Torvalds 		xonFlowControl,	// 1=use XON/XOFF flow control, 0=don't
1161da177e4SLinus Torvalds 		rts,			// 1=on, 0=off
1171da177e4SLinus Torvalds 		dtr;			// 1=on, 0=off
1181da177e4SLinus Torvalds 
1191da177e4SLinus Torvalds 	/*
1201da177e4SLinus Torvalds 		3.	configuration data which is simply used as is (no overhead,
1211da177e4SLinus Torvalds 			but must be correct in every host message).
1221da177e4SLinus Torvalds 	*/
1231da177e4SLinus Torvalds 	u8	forwardingLength,  // forward when this number of chars available
1241da177e4SLinus Torvalds 		forwardMs,		// forward this many ms after last rx data
1251da177e4SLinus Torvalds 		breakThreshold,	// specified in ms, 1-255 (see note below)
1261da177e4SLinus Torvalds 		xonChar,		// specified in current character format
1271da177e4SLinus Torvalds 		xoffChar;		// specified in current character format
1281da177e4SLinus Torvalds 
1291da177e4SLinus Torvalds 	/*
1301da177e4SLinus Torvalds 		4.	commands which are flags only; these are processed in order
1311da177e4SLinus Torvalds 			(so that, e.g., if both _txOn and _txOff flags are set, the
1321da177e4SLinus Torvalds 			port ends in a TX_OFF state); any non-zero value is respected
1331da177e4SLinus Torvalds 	*/
1341da177e4SLinus Torvalds 	u8	_txOn,			// enable transmitting (and continue if there's data)
1351da177e4SLinus Torvalds 		_txOff,			// stop transmitting
1361da177e4SLinus Torvalds 		txFlush,		// toss outbound data
1371da177e4SLinus Torvalds 		txForceXoff,	// pretend we've received XOFF
1381da177e4SLinus Torvalds 		txBreak,		// turn on break (leave on until txOn clears it)
1391da177e4SLinus Torvalds 		rxOn,			// turn on receiver
1401da177e4SLinus Torvalds 		rxOff,			// turn off receiver
1411da177e4SLinus Torvalds 		rxFlush,		// toss inbound data
1421da177e4SLinus Torvalds 		rxForward,		// forward all inbound data, NOW
1431da177e4SLinus Torvalds 		returnStatus,	// return current status n times (1 or 2)
1441da177e4SLinus Torvalds 		resetDataToggle;// reset data toggle state to DATA0
1451da177e4SLinus Torvalds 
1461da177e4SLinus Torvalds };
1471da177e4SLinus Torvalds 
1481da177e4SLinus Torvalds struct keyspan_usa28_portStatusMessage
1491da177e4SLinus Torvalds {
1501da177e4SLinus Torvalds 	u8	port,			// 0=first, 1=second, 2=global (see below)
1511da177e4SLinus Torvalds 		cts,
1521da177e4SLinus Torvalds 		dsr,			// (not used in all products)
1531da177e4SLinus Torvalds 		dcd,
1541da177e4SLinus Torvalds 
1551da177e4SLinus Torvalds 		ri,				// (not used in all products)
1561da177e4SLinus Torvalds 		_txOff,			// port has been disabled (by host)
1571da177e4SLinus Torvalds 		_txXoff,		// port is in XOFF state (either host or RX XOFF)
1581da177e4SLinus Torvalds 		dataLost,		// count of lost chars; wraps; not guaranteed exact
1591da177e4SLinus Torvalds 
1601da177e4SLinus Torvalds 		rxEnabled,		// as configured by rxOn/rxOff 1=on, 0=off
1611da177e4SLinus Torvalds 		rxBreak,		// 1=we're in break state
1621da177e4SLinus Torvalds 		rs232invalid,	// 1=no valid signals on rs-232 inputs
1631da177e4SLinus Torvalds 		controlResponse;// 1=a control messages has been processed
1641da177e4SLinus Torvalds };
1651da177e4SLinus Torvalds 
1661da177e4SLinus Torvalds // bit defines in txState
1671da177e4SLinus Torvalds #define	TX_OFF			0x01	// requested by host txOff command
1681da177e4SLinus Torvalds #define	TX_XOFF			0x02	// either real, or simulated by host
1691da177e4SLinus Torvalds 
1701da177e4SLinus Torvalds struct keyspan_usa28_globalControlMessage
1711da177e4SLinus Torvalds {
1721da177e4SLinus Torvalds 	u8	sendGlobalStatus,	// 2=request for two status responses
1731da177e4SLinus Torvalds 		resetStatusToggle,	// 1=reset global status toggle
1741da177e4SLinus Torvalds 		resetStatusCount;	// a cycling value
1751da177e4SLinus Torvalds };
1761da177e4SLinus Torvalds 
1771da177e4SLinus Torvalds struct keyspan_usa28_globalStatusMessage
1781da177e4SLinus Torvalds {
1791da177e4SLinus Torvalds 	u8	port,				// 3
1801da177e4SLinus Torvalds 		sendGlobalStatus,	// from request, decremented
1811da177e4SLinus Torvalds 		resetStatusCount;	// as in request
1821da177e4SLinus Torvalds };
1831da177e4SLinus Torvalds 
1841da177e4SLinus Torvalds struct keyspan_usa28_globalDebugMessage
1851da177e4SLinus Torvalds {
1861da177e4SLinus Torvalds 	u8	port,				// 2
1871da177e4SLinus Torvalds 		n,					// typically a count/status byte
1881da177e4SLinus Torvalds 		b;					// typically a data byte
1891da177e4SLinus Torvalds };
1901da177e4SLinus Torvalds 
1911da177e4SLinus Torvalds // ie: the maximum length of an EZUSB endpoint buffer
1921da177e4SLinus Torvalds #define	MAX_DATA_LEN			64
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds // the parity bytes have only one significant bit
1951da177e4SLinus Torvalds #define	RX_PARITY_BIT			0x04
1961da177e4SLinus Torvalds #define	TX_PARITY_BIT			0x01
1971da177e4SLinus Torvalds 
1981da177e4SLinus Torvalds // update status approx. 60 times a second (16.6666 ms)
1991da177e4SLinus Torvalds #define	STATUS_UPDATE_INTERVAL	16
2001da177e4SLinus Torvalds 
2011da177e4SLinus Torvalds #endif
2021da177e4SLinus Torvalds 
203