Home | History | Annotate | Line # | Download | only in ppbus
      1 /* $NetBSD: ppbus_base.h,v 1.8 2008/04/15 15:02:29 cegger Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1997, 1998, 1999 Nicolas Souchu
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     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.
     15  *
     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
     26  * SUCH DAMAGE.
     27  *
     28  * $FreeBSD: src/sys/dev/ppbus/ppbconf.h,v 1.17.2.1 2000/05/24 00:20:57 n_hibma Exp $
     29  *
     30  */
     31 #ifndef __PPBUS_BASE_H
     32 #define __PPBUS_BASE_H
     33 
     34 #include <sys/bus.h>
     35 
     36 #include <dev/ppbus/ppbus_msq.h>
     37 
     38 
     39 /* Parallel Port Chipset control bits. */
     40 #define STROBE		0x01
     41 #define AUTOFEED	0x02
     42 #define nINIT		0x04
     43 #define SELECTIN	0x08
     44 #define IRQENABLE	0x10
     45 #define PCD		0x20
     46 
     47 #define nSTROBE		inv(STROBE)
     48 #define nAUTOFEED	inv(AUTOFEED)
     49 #define INIT		inv(nINIT)
     50 #define nSELECTIN	inv(SELECTIN)
     51 #define nPCD		inv(PCD)
     52 
     53 /* Parallel Port Chipset status bits. */
     54 #define TIMEOUT		0x01
     55 #define nFAULT		0x08
     56 #define SELECT		0x10
     57 #define PERROR		0x20
     58 #define nACK		0x40
     59 #define nBUSY		0x80
     60 
     61 /* Byte mode signals */
     62 #define HOSTCLK         nSTROBE /* Also ECP mode signal */
     63 #define HOSTBUSY        nAUTOFEED
     64 #define ACTIVE1284      nSELECTIN /* Also ECP mode signal */
     65 #define PTRCLK          nACK
     66 #define PTRBUSY         BUSY
     67 #define ACKDATAREQ      PERROR
     68 #define XFLAG           SELECT /* Also ECP mode signal */
     69 #define nDATAVAIL       nERROR
     70 
     71 /* ECP mode signals */
     72 #define HOSTACK         nAUTOFEED
     73 #define nREVREQ         nINIT
     74 #define PERICLK         nACK
     75 #define PERIACK         BUSY
     76 #define nACKREV         PERROR
     77 #define nPERIREQ        nERROR
     78 
     79 /* EPP mode signals */
     80 #define nWRITE          nSTROBE
     81 #define nDATASTB        nAUTOFEED
     82 #define nADDRSTB        nSELECTIN
     83 #define nWAIT           BUSY
     84 /*
     85 #define nINIT           nRESET
     86 #define nACK            nINTR
     87 */
     88 
     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*/
    102 
    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
    115 
    116 
    117 /* Structure to store status information. */
    118 struct ppbus_status {
    119 	unsigned char status;
    120 
    121 	unsigned int timeout:1;
    122 	unsigned int error:1;
    123 	unsigned int select:1;
    124 	unsigned int paper_end:1;
    125 	unsigned int ack:1;
    126 	unsigned int busy:1;
    127 };
    128 
    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
    136 
    137 
    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);
    145 
    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 *));
    161 
    162 #endif /* __PPBUS_BASE_H */
    163