xref: /linux/drivers/usb/serial/io_ionsp.h (revision a320471147fe61ed9260295958f07cc23ec360c8)
11da177e4SLinus Torvalds /************************************************************************
21da177e4SLinus Torvalds  *
31da177e4SLinus Torvalds  *	IONSP.H		Definitions for I/O Networks Serial Protocol
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  *	Copyright (C) 1997-1998 Inside Out Networks, Inc.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  *	This program is free software; you can redistribute it and/or modify
81da177e4SLinus Torvalds  *	it under the terms of the GNU General Public License as published by
91da177e4SLinus Torvalds  *	the Free Software Foundation; either version 2 of the License, or
101da177e4SLinus Torvalds  *	(at your option) any later version.
111da177e4SLinus Torvalds  *
121da177e4SLinus Torvalds  *	These definitions are used by both kernel-mode driver and the
131da177e4SLinus Torvalds  *	peripheral firmware and MUST be kept in sync.
141da177e4SLinus Torvalds  *
151da177e4SLinus Torvalds  ************************************************************************/
161da177e4SLinus Torvalds 
171da177e4SLinus Torvalds /************************************************************************
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds The data to and from all ports on the peripheral is multiplexed
201da177e4SLinus Torvalds through a single endpoint pair (EP1 since it supports 64-byte
211da177e4SLinus Torvalds MaxPacketSize). Therefore, the data, commands, and status for
221da177e4SLinus Torvalds each port must be preceded by a short header identifying the
231da177e4SLinus Torvalds destination port. The header also identifies the bytes that follow
241da177e4SLinus Torvalds as data or as command/status info.
251da177e4SLinus Torvalds 
261da177e4SLinus Torvalds Header format, first byte:
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds     CLLLLPPP
291da177e4SLinus Torvalds     --------
301da177e4SLinus Torvalds     | |	 |------ Port Number:	0-7
311da177e4SLinus Torvalds     | |--------- Length:	MSB bits of length
321da177e4SLinus Torvalds     |----------- Data/Command:	0 = Data header
331da177e4SLinus Torvalds 				1 = Cmd / Status (Cmd if OUT, Status if IN)
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds This gives 2 possible formats:
361da177e4SLinus Torvalds 
371da177e4SLinus Torvalds 
381da177e4SLinus Torvalds     Data header:		0LLLLPPP	LLLLLLLL
391da177e4SLinus Torvalds     ============
401da177e4SLinus Torvalds 
411da177e4SLinus Torvalds     Where (LLLL,LLLLLLL) is 12-bit length of data that follows for
421da177e4SLinus Torvalds     port number (PPP). The length is 0-based (0-FFF means 0-4095
431da177e4SLinus Torvalds     bytes). The ~4K limit allows the host driver (which deals in
441da177e4SLinus Torvalds     transfer requests instead of individual packets) to write a
451da177e4SLinus Torvalds     large chunk of data in a single request. Note, however, that
461da177e4SLinus Torvalds     the length must always be <= the current TxCredits for a given
471da177e4SLinus Torvalds     port due to buffering limitations on the peripheral.
481da177e4SLinus Torvalds 
491da177e4SLinus Torvalds 
501da177e4SLinus Torvalds     Cmd/Status header:		1ccccPPP	[ CCCCCCCC,	 Params ]...
511da177e4SLinus Torvalds     ==================
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds     Where (cccc) or (cccc,CCCCCCCC) is the cmd or status identifier.
541da177e4SLinus Torvalds     Frequently-used values are encoded as (cccc), longer ones using
551da177e4SLinus Torvalds     (cccc,CCCCCCCC). Subsequent bytes are optional parameters and are
561da177e4SLinus Torvalds     specific to the cmd or status code. This may include a length
571da177e4SLinus Torvalds     for command and status codes that need variable-length parameters.
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds 
601da177e4SLinus Torvalds In addition, we use another interrupt pipe (endpoint) which the host polls
611da177e4SLinus Torvalds periodically for flow control information. The peripheral, when there has
621da177e4SLinus Torvalds been a change, sends the following 10-byte packet:
631da177e4SLinus Torvalds 
641da177e4SLinus Torvalds 	RRRRRRRRRRRRRRRR
651da177e4SLinus Torvalds 	T0T0T0T0T0T0T0T0
661da177e4SLinus Torvalds 	T1T1T1T1T1T1T1T1
671da177e4SLinus Torvalds 	T2T2T2T2T2T2T2T2
681da177e4SLinus Torvalds 	T3T3T3T3T3T3T3T3
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds The first field is the 16-bit RxBytesAvail field, which indicates the
711da177e4SLinus Torvalds number of bytes which may be read by the host from EP1. This is necessary:
721da177e4SLinus Torvalds (a) because OSR2.1 has a bug which causes data loss if the peripheral returns
731da177e4SLinus Torvalds fewer bytes than the host expects to read, and (b) because, on Microsoft
741da177e4SLinus Torvalds platforms at least, an outstanding read posted on EP1 consumes about 35% of
751da177e4SLinus Torvalds the CPU just polling the device for data.
761da177e4SLinus Torvalds 
771da177e4SLinus Torvalds The next 4 fields are the 16-bit TxCredits for each port, which indicate how
781da177e4SLinus Torvalds many bytes the host is allowed to send on EP1 for transmit to a given port.
791da177e4SLinus Torvalds After an OPEN_PORT command, the Edgeport sends the initial TxCredits for that
801da177e4SLinus Torvalds port.
811da177e4SLinus Torvalds 
821da177e4SLinus Torvalds All 16-bit fields are sent in little-endian (Intel) format.
831da177e4SLinus Torvalds 
841da177e4SLinus Torvalds ************************************************************************/
851da177e4SLinus Torvalds 
861da177e4SLinus Torvalds //
871da177e4SLinus Torvalds // Define format of InterruptStatus packet returned from the
881da177e4SLinus Torvalds // Interrupt pipe
891da177e4SLinus Torvalds //
901da177e4SLinus Torvalds 
911da177e4SLinus Torvalds struct int_status_pkt {
921da177e4SLinus Torvalds 	__u16 RxBytesAvail;			// Additional bytes available to
931da177e4SLinus Torvalds 						// be read from Bulk IN pipe
941da177e4SLinus Torvalds 	__u16 TxCredits[MAX_RS232_PORTS];	// Additional space available in
951da177e4SLinus Torvalds 						// given port's TxBuffer
961da177e4SLinus Torvalds };
971da177e4SLinus Torvalds 
981da177e4SLinus Torvalds 
991da177e4SLinus Torvalds #define GET_INT_STATUS_SIZE(NumPorts) (sizeof(__u16) + (sizeof(__u16) * (NumPorts)))
1001da177e4SLinus Torvalds 
1011da177e4SLinus Torvalds 
1021da177e4SLinus Torvalds 
1031da177e4SLinus Torvalds //
1041da177e4SLinus Torvalds // Define cmd/status header values and macros to extract them.
1051da177e4SLinus Torvalds //
1061da177e4SLinus Torvalds //	Data:		0LLLLPPP LLLLLLLL
1071da177e4SLinus Torvalds //	Cmd/Stat:	1ccccPPP CCCCCCCC
1081da177e4SLinus Torvalds 
1091da177e4SLinus Torvalds #define	IOSP_DATA_HDR_SIZE		2
1101da177e4SLinus Torvalds #define	IOSP_CMD_HDR_SIZE		2
1111da177e4SLinus Torvalds 
1121da177e4SLinus Torvalds #define	IOSP_MAX_DATA_LENGTH		0x0FFF		// 12 bits -> 4K
1131da177e4SLinus Torvalds 
1141da177e4SLinus Torvalds #define	IOSP_PORT_MASK			0x07		// Mask to isolate port number
1151da177e4SLinus Torvalds #define	IOSP_CMD_STAT_BIT		0x80		// If set, this is command/status header
1161da177e4SLinus Torvalds 
1171da177e4SLinus Torvalds #define IS_CMD_STAT_HDR(Byte1)		((Byte1) & IOSP_CMD_STAT_BIT)
1181da177e4SLinus Torvalds #define IS_DATA_HDR(Byte1)		(!IS_CMD_STAT_HDR(Byte1))
1191da177e4SLinus Torvalds 
1201da177e4SLinus Torvalds #define	IOSP_GET_HDR_PORT(Byte1)		((__u8) ((Byte1) & IOSP_PORT_MASK))
1211da177e4SLinus Torvalds #define	IOSP_GET_HDR_DATA_LEN(Byte1, Byte2)	((__u16) (((__u16)((Byte1) & 0x78)) << 5) | (Byte2))
1221da177e4SLinus Torvalds #define	IOSP_GET_STATUS_CODE(Byte1)		((__u8) (((Byte1) &  0x78) >> 3))
1231da177e4SLinus Torvalds 
1241da177e4SLinus Torvalds 
1251da177e4SLinus Torvalds //
1261da177e4SLinus Torvalds // These macros build the 1st and 2nd bytes for a data header
1271da177e4SLinus Torvalds //
1281da177e4SLinus Torvalds #define	IOSP_BUILD_DATA_HDR1(Port, Len)		((__u8) (((Port) | ((__u8) (((__u16) (Len)) >> 5) & 0x78))))
1291da177e4SLinus Torvalds #define	IOSP_BUILD_DATA_HDR2(Port, Len)		((__u8) (Len))
1301da177e4SLinus Torvalds 
1311da177e4SLinus Torvalds 
1321da177e4SLinus Torvalds //
1331da177e4SLinus Torvalds // These macros build the 1st and 2nd bytes for a command header
1341da177e4SLinus Torvalds //
1351da177e4SLinus Torvalds #define	IOSP_BUILD_CMD_HDR1(Port, Cmd)		((__u8) (IOSP_CMD_STAT_BIT | (Port) | ((__u8) ((Cmd) << 3))))
1361da177e4SLinus Torvalds 
1371da177e4SLinus Torvalds 
1381da177e4SLinus Torvalds //--------------------------------------------------------------
1391da177e4SLinus Torvalds //
1401da177e4SLinus Torvalds //	Define values for commands and command parameters
1411da177e4SLinus Torvalds //	(sent from Host to Edgeport)
1421da177e4SLinus Torvalds //
1431da177e4SLinus Torvalds //	1ccccPPP P1P1P1P1 [ P2P2P2P2P2 ]...
1441da177e4SLinus Torvalds //
1451da177e4SLinus Torvalds //	cccc:	00-07	2-byte commands. Write UART register 0-7 with
1461da177e4SLinus Torvalds //					value in P1. See 16650.H for definitions of
1471da177e4SLinus Torvalds //					UART register numbers and contents.
1481da177e4SLinus Torvalds //
1491da177e4SLinus Torvalds //		08-0B	3-byte commands:					==== P1 ====	==== P2 ====
1501da177e4SLinus Torvalds //					08	available for expansion
1511da177e4SLinus Torvalds //					09	1-param commands		Command Code	Param
1521da177e4SLinus Torvalds //					0A	available for expansion
1531da177e4SLinus Torvalds //					0B	available for expansion
1541da177e4SLinus Torvalds //
1551da177e4SLinus Torvalds //		0C-0D	4-byte commands.	P1 = extended cmd and P2,P3 = params
1561da177e4SLinus Torvalds //						Currently unimplemented.
1571da177e4SLinus Torvalds //
1581da177e4SLinus Torvalds //		0E-0F	N-byte commands:	P1 = num bytes after P1 (ie, TotalLen - 2)
1591da177e4SLinus Torvalds //						P2 = extended cmd, P3..Pn = parameters.
1601da177e4SLinus Torvalds //						Currently unimplemented.
1611da177e4SLinus Torvalds //
1621da177e4SLinus Torvalds 
1631da177e4SLinus Torvalds #define	IOSP_WRITE_UART_REG(n)	((n) & 0x07)	// UartReg[ n ] := P1
1641da177e4SLinus Torvalds 
1651da177e4SLinus Torvalds // Register numbers and contents
1661da177e4SLinus Torvalds // defined in 16554.H.
1671da177e4SLinus Torvalds 
1681da177e4SLinus Torvalds //					0x08		// Available for expansion.
1691da177e4SLinus Torvalds #define	IOSP_EXT_CMD			0x09		// P1 = Command code (defined below)
1701da177e4SLinus Torvalds 
1711da177e4SLinus Torvalds // P2 = Parameter
1721da177e4SLinus Torvalds 
1731da177e4SLinus Torvalds //
1741da177e4SLinus Torvalds // Extended Command values, used with IOSP_EXT_CMD, may
1751da177e4SLinus Torvalds // or may not use parameter P2.
1761da177e4SLinus Torvalds //
1771da177e4SLinus Torvalds 
1781da177e4SLinus Torvalds #define	IOSP_CMD_OPEN_PORT		0x00		// Enable ints, init UART. (NO PARAM)
1791da177e4SLinus Torvalds #define	IOSP_CMD_CLOSE_PORT		0x01		// Disable ints, flush buffers. (NO PARAM)
1801da177e4SLinus Torvalds #define	IOSP_CMD_CHASE_PORT		0x02		// Wait for Edgeport TX buffers to empty. (NO PARAM)
1811da177e4SLinus Torvalds #define IOSP_CMD_SET_RX_FLOW		0x03		// Set Rx Flow Control in Edgeport
1821da177e4SLinus Torvalds #define IOSP_CMD_SET_TX_FLOW		0x04		// Set Tx Flow Control in Edgeport
1831da177e4SLinus Torvalds #define IOSP_CMD_SET_XON_CHAR		0x05		// Set XON Character in Edgeport
1841da177e4SLinus Torvalds #define IOSP_CMD_SET_XOFF_CHAR		0x06		// Set XOFF Character in Edgeport
1851da177e4SLinus Torvalds #define IOSP_CMD_RX_CHECK_REQ		0x07		// Request Edgeport to insert a Checkpoint into
1861da177e4SLinus Torvalds 
1871da177e4SLinus Torvalds // the receive data stream (Parameter = 1 byte sequence number)
1881da177e4SLinus Torvalds 
1891da177e4SLinus Torvalds #define IOSP_CMD_SET_BREAK		0x08		// Turn on the BREAK (LCR bit 6)
1901da177e4SLinus Torvalds #define IOSP_CMD_CLEAR_BREAK		0x09		// Turn off the BREAK (LCR bit 6)
1911da177e4SLinus Torvalds 
1921da177e4SLinus Torvalds 
1931da177e4SLinus Torvalds //
1941da177e4SLinus Torvalds // Define macros to simplify building of IOSP cmds
1951da177e4SLinus Torvalds //
1961da177e4SLinus Torvalds 
1971da177e4SLinus Torvalds #define MAKE_CMD_WRITE_REG(ppBuf, pLen, Port, Reg, Val)			\
1981da177e4SLinus Torvalds do {									\
199*a3204711SGreg Kroah-Hartman 	(*(ppBuf))[0] = IOSP_BUILD_CMD_HDR1((Port),			\
200*a3204711SGreg Kroah-Hartman 					    IOSP_WRITE_UART_REG(Reg));	\
2011da177e4SLinus Torvalds 	(*(ppBuf))[1] = (Val);						\
2021da177e4SLinus Torvalds 									\
2031da177e4SLinus Torvalds 	*ppBuf += 2;							\
2041da177e4SLinus Torvalds 	*pLen  += 2;							\
2051da177e4SLinus Torvalds } while (0)
2061da177e4SLinus Torvalds 
2071da177e4SLinus Torvalds #define MAKE_CMD_EXT_CMD(ppBuf, pLen, Port, ExtCmd, Param)		\
2081da177e4SLinus Torvalds do {									\
2091da177e4SLinus Torvalds 	(*(ppBuf))[0] = IOSP_BUILD_CMD_HDR1((Port), IOSP_EXT_CMD);	\
2101da177e4SLinus Torvalds 	(*(ppBuf))[1] = (ExtCmd);					\
2111da177e4SLinus Torvalds 	(*(ppBuf))[2] = (Param);					\
2121da177e4SLinus Torvalds 									\
2131da177e4SLinus Torvalds 	*ppBuf += 3;							\
2141da177e4SLinus Torvalds 	*pLen  += 3;							\
2151da177e4SLinus Torvalds } while (0)
2161da177e4SLinus Torvalds 
2171da177e4SLinus Torvalds 
2181da177e4SLinus Torvalds 
2191da177e4SLinus Torvalds //--------------------------------------------------------------
2201da177e4SLinus Torvalds //
2211da177e4SLinus Torvalds //	Define format of flow control commands
2221da177e4SLinus Torvalds //	(sent from Host to Edgeport)
2231da177e4SLinus Torvalds //
2241da177e4SLinus Torvalds //	11001PPP FlowCmd FlowTypes
2251da177e4SLinus Torvalds //
2261da177e4SLinus Torvalds //	Note that the 'FlowTypes' parameter is a bit mask; that is,
2271da177e4SLinus Torvalds //	more than one flow control type can be active at the same time.
2281da177e4SLinus Torvalds //	FlowTypes = 0 means 'no flow control'.
2291da177e4SLinus Torvalds //
2301da177e4SLinus Torvalds 
2311da177e4SLinus Torvalds //
2321da177e4SLinus Torvalds //	IOSP_CMD_SET_RX_FLOW
2331da177e4SLinus Torvalds //
2341da177e4SLinus Torvalds //	Tells Edgeport how it can stop incoming UART data
2351da177e4SLinus Torvalds //
2361da177e4SLinus Torvalds //  Example for Port 0
2371da177e4SLinus Torvalds //	P0 = 11001000
2381da177e4SLinus Torvalds //  P1 = IOSP_CMD_SET_RX_FLOW
2391da177e4SLinus Torvalds //  P2 = Bit mask as follows:
2401da177e4SLinus Torvalds 
2411da177e4SLinus Torvalds #define IOSP_RX_FLOW_RTS		0x01	// Edgeport drops RTS to stop incoming data
2421da177e4SLinus Torvalds #define IOSP_RX_FLOW_DTR		0x02	// Edgeport drops DTR to stop incoming data
2431da177e4SLinus Torvalds #define IOSP_RX_FLOW_DSR_SENSITIVITY	0x04	// Ignores Rx data unless DSR high
2441da177e4SLinus Torvalds 
2451da177e4SLinus Torvalds // Not currently implemented by firmware.
2461da177e4SLinus Torvalds #define IOSP_RX_FLOW_XON_XOFF		0x08	// Edgeport sends XOFF char to stop incoming data.
2471da177e4SLinus Torvalds 
2481da177e4SLinus Torvalds // Host must have previously programmed the
2491da177e4SLinus Torvalds // XON/XOFF values with SET_XON/SET_XOFF
2501da177e4SLinus Torvalds // before enabling this bit.
2511da177e4SLinus Torvalds 
2521da177e4SLinus Torvalds //
2531da177e4SLinus Torvalds //	IOSP_CMD_SET_TX_FLOW
2541da177e4SLinus Torvalds //
2551da177e4SLinus Torvalds //	Tells Edgeport what signal(s) will stop it from transmitting UART data
2561da177e4SLinus Torvalds //
2571da177e4SLinus Torvalds //  Example for Port 0
2581da177e4SLinus Torvalds //	P0 = 11001000
2591da177e4SLinus Torvalds //  P1 = IOSP_CMD_SET_TX_FLOW
2601da177e4SLinus Torvalds //  P2 = Bit mask as follows:
2611da177e4SLinus Torvalds 
2621da177e4SLinus Torvalds #define IOSP_TX_FLOW_CTS		0x01	// Edgeport stops Tx if CTS low
2631da177e4SLinus Torvalds #define IOSP_TX_FLOW_DSR		0x02	// Edgeport stops Tx if DSR low
2641da177e4SLinus Torvalds #define IOSP_TX_FLOW_DCD		0x04	// Edgeport stops Tx if DCD low
2651da177e4SLinus Torvalds #define IOSP_TX_FLOW_XON_XOFF		0x08	// Edgeport stops Tx upon receiving XOFF char.
2661da177e4SLinus Torvalds 
2671da177e4SLinus Torvalds // Host must have previously programmed the
2681da177e4SLinus Torvalds // XON/XOFF values with SET_XON/SET_XOFF
2691da177e4SLinus Torvalds // before enabling this bit.
2701da177e4SLinus Torvalds #define IOSP_TX_FLOW_XOFF_CONTINUE	0x10	// If not set, Edgeport stops Tx when
2711da177e4SLinus Torvalds 
2721da177e4SLinus Torvalds // sending XOFF in order to fix broken
2731da177e4SLinus Torvalds // systems that interpret the next
2741da177e4SLinus Torvalds // received char as XON.
2751da177e4SLinus Torvalds // If set, Edgeport continues Tx
2761da177e4SLinus Torvalds // normally after transmitting XOFF.
2771da177e4SLinus Torvalds // Not currently implemented by firmware.
2781da177e4SLinus Torvalds #define IOSP_TX_TOGGLE_RTS		0x20	// Edgeport drives RTS as a true half-duplex
2791da177e4SLinus Torvalds 
2801da177e4SLinus Torvalds // Request-to-Send signal: it is raised before
2811da177e4SLinus Torvalds // beginning transmission and lowered after
2821da177e4SLinus Torvalds // the last Tx char leaves the UART.
2831da177e4SLinus Torvalds // Not currently implemented by firmware.
2841da177e4SLinus Torvalds 
2851da177e4SLinus Torvalds //
2861da177e4SLinus Torvalds //	IOSP_CMD_SET_XON_CHAR
2871da177e4SLinus Torvalds //
2881da177e4SLinus Torvalds //	Sets the character which Edgeport transmits/interprets as XON.
2891da177e4SLinus Torvalds //	Note: This command MUST be sent before sending a SET_RX_FLOW or
2901da177e4SLinus Torvalds //	SET_TX_FLOW with the XON_XOFF bit set.
2911da177e4SLinus Torvalds //
2921da177e4SLinus Torvalds //  Example for Port 0
2931da177e4SLinus Torvalds //	P0 = 11001000
2941da177e4SLinus Torvalds //  P1 = IOSP_CMD_SET_XON_CHAR
2951da177e4SLinus Torvalds //  P2 = 0x11
2961da177e4SLinus Torvalds 
2971da177e4SLinus Torvalds 
2981da177e4SLinus Torvalds //
2991da177e4SLinus Torvalds //	IOSP_CMD_SET_XOFF_CHAR
3001da177e4SLinus Torvalds //
3011da177e4SLinus Torvalds //	Sets the character which Edgeport transmits/interprets as XOFF.
3021da177e4SLinus Torvalds //	Note: This command must be sent before sending a SET_RX_FLOW or
3031da177e4SLinus Torvalds //	SET_TX_FLOW with the XON_XOFF bit set.
3041da177e4SLinus Torvalds //
3051da177e4SLinus Torvalds //  Example for Port 0
3061da177e4SLinus Torvalds //	P0 = 11001000
3071da177e4SLinus Torvalds //  P1 = IOSP_CMD_SET_XOFF_CHAR
3081da177e4SLinus Torvalds //  P2 = 0x13
3091da177e4SLinus Torvalds 
3101da177e4SLinus Torvalds 
3111da177e4SLinus Torvalds //
3121da177e4SLinus Torvalds //	IOSP_CMD_RX_CHECK_REQ
3131da177e4SLinus Torvalds //
3141da177e4SLinus Torvalds //  This command is used to assist in the implementation of the
3151da177e4SLinus Torvalds //  IOCTL_SERIAL_PURGE Windows IOCTL.
3161da177e4SLinus Torvalds //  This IOSP command tries to place a marker at the end of the RX
3171da177e4SLinus Torvalds //  queue in the Edgeport. If the Edgeport RX queue is full then
3181da177e4SLinus Torvalds //  the Check will be discarded.
3191da177e4SLinus Torvalds //  It is up to the device driver to timeout waiting for the
3201da177e4SLinus Torvalds //  RX_CHECK_RSP.  If a RX_CHECK_RSP is received, the driver is
3211da177e4SLinus Torvalds //	sure that all data has been received from the edgeport and
3221da177e4SLinus Torvalds //	may now purge any internal RX buffers.
3231da177e4SLinus Torvalds //  Note tat the sequence numbers may be used to detect lost
3241da177e4SLinus Torvalds //  CHECK_REQs.
3251da177e4SLinus Torvalds 
3261da177e4SLinus Torvalds //  Example for Port 0
3271da177e4SLinus Torvalds //	P0 = 11001000
3281da177e4SLinus Torvalds //  P1 = IOSP_CMD_RX_CHECK_REQ
3291da177e4SLinus Torvalds //  P2 = Sequence number
3301da177e4SLinus Torvalds 
3311da177e4SLinus Torvalds 
3321da177e4SLinus Torvalds //  Response will be:
3331da177e4SLinus Torvalds //  P1 = IOSP_EXT_RX_CHECK_RSP
3341da177e4SLinus Torvalds //  P2 = Request Sequence number
3351da177e4SLinus Torvalds 
3361da177e4SLinus Torvalds 
3371da177e4SLinus Torvalds 
3381da177e4SLinus Torvalds //--------------------------------------------------------------
3391da177e4SLinus Torvalds //
3401da177e4SLinus Torvalds //	Define values for status and status parameters
3411da177e4SLinus Torvalds //	(received by Host from Edgeport)
3421da177e4SLinus Torvalds //
3431da177e4SLinus Torvalds //	1ssssPPP P1P1P1P1 [ P2P2P2P2P2 ]...
3441da177e4SLinus Torvalds //
3451da177e4SLinus Torvalds //	ssss:	00-07	2-byte status.	ssss identifies which UART register
3461da177e4SLinus Torvalds //					has changed value, and the new value is in P1.
3471da177e4SLinus Torvalds //					Note that the ssss values do not correspond to the
3481da177e4SLinus Torvalds //					16554 register numbers given in 16554.H. Instead,
3491da177e4SLinus Torvalds //					see below for definitions of the ssss numbers
3501da177e4SLinus Torvalds //					used in this status message.
3511da177e4SLinus Torvalds //
3521da177e4SLinus Torvalds //		08-0B	3-byte status:					==== P1 ====	==== P2 ====
3531da177e4SLinus Torvalds //					08	LSR_DATA:		New LSR		Errored byte
3541da177e4SLinus Torvalds //					09	1-param responses	Response Code	Param
3551da177e4SLinus Torvalds //					0A	OPEN_RSP:		InitialMsr	TxBufferSize
3561da177e4SLinus Torvalds //					0B	available for expansion
3571da177e4SLinus Torvalds //
3581da177e4SLinus Torvalds //		0C-0D	4-byte status.	P1 = extended status code and P2,P3 = params
3591da177e4SLinus Torvalds //					Not currently implemented.
3601da177e4SLinus Torvalds //
3611da177e4SLinus Torvalds //		0E-0F	N-byte status:	P1 = num bytes after P1 (ie, TotalLen - 2)
3621da177e4SLinus Torvalds //					P2 = extended status, P3..Pn = parameters.
3631da177e4SLinus Torvalds //					Not currently implemented.
3641da177e4SLinus Torvalds //
3651da177e4SLinus Torvalds 
3661da177e4SLinus Torvalds /****************************************************
3671da177e4SLinus Torvalds  *	SSSS values for 2-byte status messages (0-8)
3681da177e4SLinus Torvalds  ****************************************************/
3691da177e4SLinus Torvalds 
3701da177e4SLinus Torvalds #define	IOSP_STATUS_LSR			0x00	// P1 is new value of LSR register.
3711da177e4SLinus Torvalds 
3721da177e4SLinus Torvalds // Bits defined in 16554.H. Edgeport
3731da177e4SLinus Torvalds // returns this in order to report
3741da177e4SLinus Torvalds // line status errors (overrun,
3751da177e4SLinus Torvalds // parity, framing, break). This form
3761da177e4SLinus Torvalds // is used when a errored receive data
3771da177e4SLinus Torvalds // character was NOT present in the
3781da177e4SLinus Torvalds // UART when the LSR error occurred
3791da177e4SLinus Torvalds // (ie, when LSR bit 0 = 0).
3801da177e4SLinus Torvalds 
3811da177e4SLinus Torvalds #define	IOSP_STATUS_MSR			0x01	// P1 is new value of MSR register.
3821da177e4SLinus Torvalds 
3831da177e4SLinus Torvalds // Bits defined in 16554.H. Edgeport
3841da177e4SLinus Torvalds // returns this in order to report
3851da177e4SLinus Torvalds // changes in modem status lines
3861da177e4SLinus Torvalds // (CTS, DSR, RI, CD)
3871da177e4SLinus Torvalds //
3881da177e4SLinus Torvalds 
3891da177e4SLinus Torvalds //					0x02	// Available for future expansion
3901da177e4SLinus Torvalds //					0x03	//
3911da177e4SLinus Torvalds //					0x04	//
3921da177e4SLinus Torvalds //					0x05	//
3931da177e4SLinus Torvalds //					0x06	//
3941da177e4SLinus Torvalds //					0x07	//
3951da177e4SLinus Torvalds 
3961da177e4SLinus Torvalds 
3971da177e4SLinus Torvalds /****************************************************
3981da177e4SLinus Torvalds  *	SSSS values for 3-byte status messages (8-A)
3991da177e4SLinus Torvalds  ****************************************************/
4001da177e4SLinus Torvalds 
4011da177e4SLinus Torvalds #define	IOSP_STATUS_LSR_DATA		0x08	// P1 is new value of LSR register (same as STATUS_LSR)
4021da177e4SLinus Torvalds 
4031da177e4SLinus Torvalds // P2 is errored character read from
4041da177e4SLinus Torvalds //    RxFIFO after LSR reported an error.
4051da177e4SLinus Torvalds 
4061da177e4SLinus Torvalds #define	IOSP_EXT_STATUS			0x09	// P1 is status/response code, param in P2.
4071da177e4SLinus Torvalds 
4081da177e4SLinus Torvalds 
4091da177e4SLinus Torvalds // Response Codes (P1 values) for 3-byte status messages
4101da177e4SLinus Torvalds 
4111da177e4SLinus Torvalds #define	IOSP_EXT_STATUS_CHASE_RSP	0	// Reply to CHASE_PORT cmd. P2 is outcome:
4121da177e4SLinus Torvalds #define	IOSP_EXT_STATUS_CHASE_PASS	0	//	P2 = 0: All Tx data drained successfully
4131da177e4SLinus Torvalds #define	IOSP_EXT_STATUS_CHASE_FAIL	1	//	P2 = 1: Timed out (stuck due to flow
4141da177e4SLinus Torvalds 
4151da177e4SLinus Torvalds //			control from remote device).
4161da177e4SLinus Torvalds 
4171da177e4SLinus Torvalds #define	IOSP_EXT_STATUS_RX_CHECK_RSP	1	// Reply to RX_CHECK cmd. P2 is sequence number
4181da177e4SLinus Torvalds 
4191da177e4SLinus Torvalds 
4201da177e4SLinus Torvalds #define IOSP_STATUS_OPEN_RSP		0x0A	// Reply to OPEN_PORT cmd.
4211da177e4SLinus Torvalds 
4221da177e4SLinus Torvalds // P1 is Initial MSR value
4231da177e4SLinus Torvalds // P2 is encoded TxBuffer Size:
4241da177e4SLinus Torvalds //	TxBufferSize = (P2 + 1) * 64
4251da177e4SLinus Torvalds 
4261da177e4SLinus Torvalds //					0x0B	// Available for future expansion
4271da177e4SLinus Torvalds 
4281da177e4SLinus Torvalds #define GET_TX_BUFFER_SIZE(P2) (((P2) + 1) * 64)
4291da177e4SLinus Torvalds 
4301da177e4SLinus Torvalds 
4311da177e4SLinus Torvalds 
4321da177e4SLinus Torvalds 
4331da177e4SLinus Torvalds /****************************************************
4341da177e4SLinus Torvalds  *	SSSS values for 4-byte status messages
4351da177e4SLinus Torvalds  ****************************************************/
4361da177e4SLinus Torvalds 
4371da177e4SLinus Torvalds #define IOSP_EXT4_STATUS		0x0C	// Extended status code in P1,
4381da177e4SLinus Torvalds 
4391da177e4SLinus Torvalds // Params in P2, P3
4401da177e4SLinus Torvalds // Currently unimplemented.
4411da177e4SLinus Torvalds 
4421da177e4SLinus Torvalds //					0x0D	// Currently unused, available.
4431da177e4SLinus Torvalds 
4441da177e4SLinus Torvalds 
4451da177e4SLinus Torvalds 
4461da177e4SLinus Torvalds //
4471da177e4SLinus Torvalds // Macros to parse status messages
4481da177e4SLinus Torvalds //
4491da177e4SLinus Torvalds 
4501da177e4SLinus Torvalds #define	IOSP_GET_STATUS_LEN(code)	((code) < 8 ? 2 : ((code) < 0x0A ? 3 : 4))
4511da177e4SLinus Torvalds 
4521da177e4SLinus Torvalds #define	IOSP_STATUS_IS_2BYTE(code)	((code) < 0x08)
4531da177e4SLinus Torvalds #define	IOSP_STATUS_IS_3BYTE(code)	(((code) >= 0x08) && ((code) <= 0x0B))
4541da177e4SLinus Torvalds #define	IOSP_STATUS_IS_4BYTE(code)	(((code) >= 0x0C) && ((code) <= 0x0D))
4551da177e4SLinus Torvalds 
456