xref: /illumos-gate/usr/src/uts/common/sys/bpp_io.h (revision 2d6eb4a5)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1990,1991,1997-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_BPP_IO_H
28 #define	_SYS_BPP_IO_H
29 
30 /*
31  *	I/O header file for the bidirectional parallel port
32  *	driver (bpp) for the Zebra SBus card.
33  */
34 
35 #include <sys/ioccom.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*	#defines (not struct elements) below */
42 
43 /*
44  * Minor device number encoding (should not be here):
45  */
46 #define	BPP_UNIT(dev)	getminor(*dev)
47 
48 /*
49  * ioctl defines for cmd argument
50  */
51 	/* set contents of transfer parms structure	*/
52 #define	BPPIOC_SETPARMS		_IOW('b', 1, struct bpp_transfer_parms)
53 	/* read contents of transfer parms structure	*/
54 #define	BPPIOC_GETPARMS		_IOR('b', 2, struct bpp_transfer_parms)
55 	/* set contents of output pins structure	*/
56 #define	BPPIOC_SETOUTPINS	_IOW('b', 3, struct bpp_pins)
57 	/* read contents of output pins structure	*/
58 #define	BPPIOC_GETOUTPINS	_IOR('b', 4, struct bpp_pins)
59 	/* read contents of snapshot error status structure	*/
60 #define	BPPIOC_GETERR		_IOR('b', 5, struct bpp_error_status)
61 	/* pretend to attempt a data transfer	*/
62 #define	BPPIOC_TESTIO		_IO('b', 6)
63 /* ioctl values 7-12 are test-only and are reserved */
64 
65 
66 /*	Structure definitions and locals #defines below */
67 
68 #define	MAX_TIMEOUT	1800000		/* maximum read/write timeout	*/
69 					/* 30 minutes			*/
70 /*
71  * #defines and enum variables, and general comments for the
72  * bpp_transfer_parms structure.
73  */
74 
75 /* Values for read_handshake and write_handshake fields */
76 enum	handshake_t {
77 	BPP_NO_HS = 1,		/* no handshake pins */
78 	BPP_ACK_HS = 2,		/* handshake controlled by ACK line */
79 	BPP_BUSY_HS = 3,	/* handshake controlled by BSY line */
80 	BPP_ACK_BUSY_HS = 4,	/* handshake controlled by ACK and BSY lines */
81 				/* read_handshake only! */
82 	BPP_XSCAN_HS = 5,	/* xerox scanner mode, read_handshake only! */
83 	BPP_HSCAN_HS = 6,	/* HP scanjet scanner mode */
84 				/* read_handshake only! */
85 	BPP_CLEAR_MEM = 7,	/* write 0's to memory, read_handshake only! */
86 	BPP_SET_MEM = 8,	/* write 1's to memory, read_handshake only! */
87 	/* The following handshakes are RESERVED. Do not use. */
88 	BPP_VPRINT_HS = 9,	/* valid only in read/write mode */
89 	BPP_VPLOT_HS = 10	/* valid only in read/write mode */
90 };
91 
92 /*
93  * The read_setup_time field indicates
94  * dstrb- to bsy+ in BPP_HS_NOHS or BPP_HS_ACKHS
95  * dstrb- to ack+ in BPP_HS_ACKHS or BPP_HS_ACKBUSYHS
96  * ack- to dstrb+ in BPP_HS_XSCANHS
97  *
98  * The read_strobe_width field indicates
99  * ack+ to ack- in BPP_HS_ACKHS or BPP_HS_ACKBUSYHS
100  * dstrb+ to dstrb- in BPP_HS_XSCANHS
101  */
102 
103 /* Values allowed for write_handshake field */
104 /*
105  * these are duplicates of the definitions above
106  *	BPP_HS_NOHS
107  *	BPP_HS_ACKHS
108  *	BPP_HS_BUSYHS
109  */
110 
111 /*
112  * The write_setup_time field indicates
113  * data valid to dstrb+ in all handshakes
114  *
115  * The write_strobe_width field indicates
116  * dstrb+ to dstrb- in non-reserved handshakes
117  * minimum dstrb+ to dstrb- in BPP_HS_VPRINTHS or BPP_HS_VPLOTHS
118  */
119 
120 
121 /*
122  * This structure is used to configure the hardware handshake and
123  * timing modes.
124  */
125 struct bpp_transfer_parms {
126 	enum	handshake_t
127 		read_handshake;		/* parallel port read handshake mode */
128 	int	read_setup_time;	/* DSS register - in nanoseconds */
129 	int	read_strobe_width;	/* DSW register - in nanoseconds */
130 	int	read_timeout;		/* wait this many microseconds */
131 					/* before aborting a transfer */
132 	enum	handshake_t
133 		write_handshake;	/* parallel port write handshake mode */
134 	int	write_setup_time;	/* DSS register - in nanoseconds */
135 	int	write_strobe_width;	/* DSW register - in nanoseconds */
136 	int	write_timeout;		/* wait this many microseconds */
137 					/* before aborting a transfer */
138 };
139 
140 struct bpp_pins {
141 	uchar_t	output_reg_pins;	/* pins in P_OR register */
142 	uchar_t	input_reg_pins;		/* pins in P_IR register */
143 };
144 
145 
146 /*
147  * #defines and general comments for
148  * the bpp_pins structure.
149  */
150 /* Values for output_reg_pins field */
151 #define	BPP_SLCTIN_PIN		0x01	/* Select in pin		*/
152 #define	BPP_AFX_PIN		0x02	/* Auto feed pin		*/
153 #define	BPP_INIT_PIN		0x04	/* Initialize pin		*/
154 #define	BPP_V1_PIN		0x08	/* reserved pin 1		*/
155 #define	BPP_V2_PIN		0x10	/* reserved pin 2		*/
156 #define	BPP_V3_PIN		0x20	/* reserved pin 3		*/
157 
158 #define	BPP_ALL_OUT_PINS	(BPP_SLCTIN_PIN | BPP_AFX_PIN | BPP_INIT_PIN |\
159 				BPP_V1_PIN | BPP_V2_PIN | BPP_V3_PIN)
160 
161 /* Values for input_reg_pins field */
162 #define	BPP_ERR_PIN		0x01	/* Error pin			*/
163 #define	BPP_SLCT_PIN		0x02	/* Select pin			*/
164 #define	BPP_PE_PIN		0x04	/* Paper empty pin		*/
165 
166 #define	BPP_ALL_IN_PINS		(BPP_ERR_PIN | BPP_SLCT_PIN | BPP_PE_PIN)
167 
168 struct	bpp_error_status {
169 	char	timeout_occurred;	/* 1 if a timeout occurred	*/
170 	char	bus_error;		/* 1 if an SBus bus error	*/
171 	uchar_t	pin_status;		/* status of pins which could */
172 					/* cause an error */
173 };
174 
175 /*
176  * #defines for the bpp_error_status structure
177  */
178 /* Values for pin_status field */
179 #define	BPP_ERR_ERR		0x01	/* Error pin active		*/
180 #define	BPP_SLCT_ERR		0x02	/* Select pin active		*/
181 #define	BPP_PE_ERR		0x04	/* Paper empty pin active	*/
182 #define	BPP_SLCTIN_ERR		0x10	/* Select in pin active		*/
183 #define	BPP_BUSY_ERR		0x40	/* Busy pin active		*/
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif /* !_SYS_BPP_IO_H */
190