Home | History | Annotate | Line # | Download | only in ppbus
ppbus_base.h revision 1.1
      1 /*
      2  * Copyright (c) 1997, 1998, 1999 Nicolas Souchu
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  *
     14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24  * SUCH DAMAGE.
     25  *
     26  * $FreeBSD: src/sys/dev/ppbus/ppbconf.h,v 1.17.2.1 2000/05/24 00:20:57 n_hibma Exp $
     27  *
     28  */
     29 #ifndef __PPBUS_BASE_H
     30 #define __PPBUS_BASE_H
     31 
     32 #include <machine/bus.h>
     33 
     34 #include <dev/ppbus/ppbus_msq.h>
     35 
     36 
     37 /* Parallel Port Chipset control bits. */
     38 #define STROBE		0x01
     39 #define AUTOFEED	0x02
     40 #define nINIT		0x04
     41 #define SELECTIN	0x08
     42 #define IRQENABLE	0x10
     43 #define PCD		0x20
     44 
     45 #define nSTROBE		inv(STROBE)
     46 #define nAUTOFEED	inv(AUTOFEED)
     47 #define INIT		inv(nINIT)
     48 #define nSELECTIN	inv(SELECTIN)
     49 #define nPCD		inv(PCD)
     50 
     51 /* Parallel Port Chipset status bits. */
     52 #define TIMEOUT		0x01
     53 #define nFAULT		0x08
     54 #define SELECT		0x10
     55 #define PERROR		0x20
     56 #define nACK		0x40
     57 #define nBUSY		0x80
     58 
     59 /* Byte mode signals */
     60 #define HOSTCLK         nSTROBE /* Also ECP mode signal */
     61 #define HOSTBUSY        nAUTOFEED
     62 #define ACTIVE1284      nSELECTIN /* Also ECP mode signal */
     63 #define PTRCLK          nACK
     64 #define PTRBUSY         BUSY
     65 #define ACKDATAREQ      PERROR
     66 #define XFLAG           SELECT /* Also ECP mode signal */
     67 #define nDATAVAIL       nERROR
     68 
     69 /* ECP mode signals */
     70 #define HOSTACK         nAUTOFEED
     71 #define nREVREQ         nINIT
     72 #define PERICLK         nACK
     73 #define PERIACK         BUSY
     74 #define nACKREV         PERROR
     75 #define nPERIREQ        nERROR
     76 
     77 /* EPP mode signals */
     78 #define nWRITE          nSTROBE
     79 #define nDATASTB        nAUTOFEED
     80 #define nADDRSTB        nSELECTIN
     81 #define nWAIT           BUSY
     82 /*
     83 #define nINIT           nRESET
     84 #define nACK            nINTR
     85 */
     86 
     87 /* ECR register bit definitions */
     88 #define ECR_FIFO_EMPTY        0x1     /* ecr register - bit 0 */
     89 #define ECR_FIFO_FULL         0x2     /* ecr register - bit 1 */
     90 #define ECR_SERVICE_INTR      0x4     /* ecr register - bit 2 */
     91 #define ECR_ENABLE_DMA        0x8     /* ecr register - bit 3 */
     92 #define ECR_nFAULT_INTR       0x10    /* ecr register - bit 4 */
     93 /* bits 5 through 7 */
     94 #define ECR_STD           0x00    /* Standard mode */
     95 #define ECR_PS2           0x20    /* Bidirectional mode */
     96 #define ECR_FIFO          0x40    /* Fast Centronics mode */
     97 #define ECR_ECP           0x60    /* ECP mode */
     98 #define ECR_EPP           0x80    /* EPP mode */
     99 #define ECR_TST           0xc0    /* Test mode*/
    100 
    101 /* Used for IEEE 1284 'PNP' detection */
    102 #define PPBUS_PNP_PRINTER	0
    103 #define PPBUS_PNP_MODEM		1
    104 #define PPBUS_PNP_NET		2
    105 #define PPBUS_PNP_HDC		3
    106 #define PPBUS_PNP_PCMCIA	4
    107 #define PPBUS_PNP_MEDIA		5
    108 #define PPBUS_PNP_FDC		6
    109 #define PPBUS_PNP_PORTS		7
    110 #define PPBUS_PNP_SCANNER	8
    111 #define PPBUS_PNP_DIGICAM	9
    112 #define PPBUS_PNP_UNKNOWN	10
    113 
    114 
    115 /* Structure to store status information. */
    116 struct ppbus_status {
    117 	unsigned char status;
    118 
    119 	unsigned int timeout:1;
    120 	unsigned int error:1;
    121 	unsigned int select:1;
    122 	unsigned int paper_end:1;
    123 	unsigned int ack:1;
    124 	unsigned int busy:1;
    125 };
    126 
    127 /* How tsleep() is called in ppbus_request_bus(). */
    128 #define PPBUS_DONTWAIT  0
    129 #define PPBUS_NOINTR    0
    130 #define PPBUS_WAIT      0x1
    131 #define PPBUS_INTR      0x2
    132 #define PPBUS_POLL      0x4
    133 #define PPBUS_FOREVER   -1
    134 
    135 
    136 #ifdef _KERNEL
    137 
    138 /* PPBUS interface functions (includes parport interface) */
    139 int ppbus_scan_bus(struct device *);
    140 void ppbus_pnp_detect(struct device *);
    141 int ppbus_request_bus(struct device *, struct device *, int, unsigned int);
    142 int ppbus_release_bus(struct device *, struct device *, int, unsigned int);
    143 int ppbus_get_status(struct device *, struct ppbus_status *);
    144 int ppbus_poll_bus(struct device *, int, char, char, int);
    145 
    146 /* Parport interface function prototypes */
    147 int ppbus_read_ivar(struct device *, int, unsigned int *);
    148 int ppbus_write_ivar(struct device *, int, unsigned int *);
    149 int ppbus_reset_epp_timeout(struct device *);
    150 int ppbus_ecp_sync(struct device *);
    151 int ppbus_set_mode(struct device *, int, int);
    152 int ppbus_get_mode(struct device *);
    153 int ppbus_write(struct device *, char *, int, int, size_t *);
    154 int ppbus_read(struct device *, char *, int, int, size_t *);
    155 int ppbus_exec_microseq(struct device *, struct ppbus_microseq * *);
    156 int ppbus_io(struct device *, int, u_char *, int, u_char);
    157 int ppbus_dma_malloc(struct device *, caddr_t *, bus_addr_t *, bus_size_t);
    158 int ppbus_dma_free(struct device *, caddr_t *, bus_addr_t *, bus_size_t);
    159 int ppbus_add_handler(struct device *, void (*)(void *), void *);
    160 int ppbus_remove_handler(struct device *, void (*)(void *));
    161 
    162 #endif /* _KERNEL */
    163 
    164 #endif /* __PPBUS_BASE_H */
    165 
    166