1 /* $NetBSD: ppbus_base.h,v 1.7 2007/10/19 12:01:07 ad Exp $ */
4 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * $FreeBSD: src/sys/dev/ppbus/ppbconf.h,v 1.17.2.1 2000/05/24 00:20:57 n_hibma Exp $
31 #ifndef __PPBUS_BASE_H
32 #define __PPBUS_BASE_H
36 #include <dev/ppbus/ppbus_msq.h>
39 /* Parallel Port Chipset control bits. */
44 #define IRQENABLE 0x10
47 #define nSTROBE inv(STROBE)
48 #define nAUTOFEED inv(AUTOFEED)
49 #define INIT inv(nINIT)
50 #define nSELECTIN inv(SELECTIN)
53 /* Parallel Port Chipset status bits. */
61 /* Byte mode signals */
62 #define HOSTCLK nSTROBE /* Also ECP mode signal */
63 #define HOSTBUSY nAUTOFEED
64 #define ACTIVE1284 nSELECTIN /* Also ECP mode signal */
67 #define ACKDATAREQ PERROR
68 #define XFLAG SELECT /* Also ECP mode signal */
69 #define nDATAVAIL nERROR
71 /* ECP mode signals */
72 #define HOSTACK nAUTOFEED
76 #define nACKREV PERROR
77 #define nPERIREQ nERROR
79 /* EPP mode signals */
80 #define nWRITE nSTROBE
81 #define nDATASTB nAUTOFEED
82 #define nADDRSTB nSELECTIN
89 /* ECR register bit definitions */
90 #define ECR_FIFO_EMPTY 0x1 /* ecr register - bit 0 */
91 #define ECR_FIFO_FULL 0x2 /* ecr register - bit 1 */
92 #define ECR_SERVICE_INTR 0x4 /* ecr register - bit 2 */
93 #define ECR_ENABLE_DMA 0x8 /* ecr register - bit 3 */
94 #define ECR_nFAULT_INTR 0x10 /* ecr register - bit 4 */
95 /* bits 5 through 7 */
96 #define ECR_STD 0x00 /* Standard mode */
97 #define ECR_PS2 0x20 /* Bidirectional mode */
98 #define ECR_FIFO 0x40 /* Fast Centronics mode */
99 #define ECR_ECP 0x60 /* ECP mode */
100 #define ECR_EPP 0x80 /* EPP mode */
101 #define ECR_TST 0xc0 /* Test mode*/
103 /* Used for IEEE 1284 'PNP' detection */
104 #define PPBUS_PNP_PRINTER 0
105 #define PPBUS_PNP_MODEM 1
106 #define PPBUS_PNP_NET 2
107 #define PPBUS_PNP_HDC 3
108 #define PPBUS_PNP_PCMCIA 4
109 #define PPBUS_PNP_MEDIA 5
110 #define PPBUS_PNP_FDC 6
111 #define PPBUS_PNP_PORTS 7
112 #define PPBUS_PNP_SCANNER 8
113 #define PPBUS_PNP_DIGICAM 9
114 #define PPBUS_PNP_UNKNOWN 10
117 /* Structure to store status information. */
118 struct ppbus_status
{
119 unsigned char status
;
121 unsigned int timeout
:1;
122 unsigned int error
:1;
123 unsigned int select
:1;
124 unsigned int paper_end
:1;
129 /* How tsleep() is called in ppbus_request_bus(). */
130 #define PPBUS_DONTWAIT 0
131 #define PPBUS_NOINTR 0
132 #define PPBUS_WAIT 0x1
133 #define PPBUS_INTR 0x2
134 #define PPBUS_POLL 0x4
135 #define PPBUS_FOREVER -1
138 /* PPBUS interface functions (includes parport interface) */
139 int ppbus_scan_bus(device_t
);
140 void ppbus_pnp_detect(device_t
);
141 int ppbus_request_bus(device_t
, device_t
, int, unsigned int);
142 int ppbus_release_bus(device_t
, device_t
, int, unsigned int);
143 int ppbus_get_status(device_t
, struct ppbus_status
*);
144 int ppbus_poll_bus(device_t
, int, char, char, int);
146 /* Parport interface function prototypes */
147 int ppbus_read_ivar(device_t
, int, unsigned int *);
148 int ppbus_write_ivar(device_t
, int, unsigned int *);
149 int ppbus_reset_epp_timeout(device_t
);
150 int ppbus_ecp_sync(device_t
);
151 int ppbus_set_mode(device_t
, int, int);
152 int ppbus_get_mode(device_t
);
153 int ppbus_write(device_t
, char *, int, int, size_t *);
154 int ppbus_read(device_t
, char *, int, int, size_t *);
155 int ppbus_exec_microseq(device_t
, struct ppbus_microseq
* *);
156 int ppbus_io(device_t
, int, u_char
*, int, u_char
);
157 int ppbus_dma_malloc(device_t
, void **, bus_addr_t
*, bus_size_t
);
158 int ppbus_dma_free(device_t
, void **, bus_addr_t
*, bus_size_t
);
159 int ppbus_add_handler(device_t
, void (*)(void *), void *);
160 int ppbus_remove_handler(device_t
, void (*)(void *));
162 #endif /* __PPBUS_BASE_H */