Home | History | Annotate | Line # | Download | only in ic
atppcvar.h revision 1.6
      1  1.6     perry /* $NetBSD: atppcvar.h,v 1.6 2005/02/27 00:27:00 perry Exp $ */
      2  1.2     bjh21 
      3  1.1  jdolecek /*-
      4  1.1  jdolecek  * Copyright (c) 2001 Alcove - Nicolas Souchu
      5  1.1  jdolecek  * All rights reserved.
      6  1.1  jdolecek  *
      7  1.1  jdolecek  * Redistribution and use in source and binary forms, with or without
      8  1.1  jdolecek  * modification, are permitted provided that the following conditions
      9  1.1  jdolecek  * are met:
     10  1.1  jdolecek  * 1. Redistributions of source code must retain the above copyright
     11  1.1  jdolecek  *    notice, this list of conditions and the following disclaimer.
     12  1.1  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  jdolecek  *    documentation and/or other materials provided with the distribution.
     15  1.1  jdolecek  *
     16  1.1  jdolecek  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  1.1  jdolecek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.1  jdolecek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.1  jdolecek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.1  jdolecek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  1.1  jdolecek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.1  jdolecek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1  jdolecek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  1.1  jdolecek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1  jdolecek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1  jdolecek  * SUCH DAMAGE.
     27  1.1  jdolecek  *
     28  1.3     bjh21  * FreeBSD: src/sys/isa/ppcreg.h,v 1.10.2.4 2001/10/02 05:21:45 nsouch Exp
     29  1.1  jdolecek  *
     30  1.1  jdolecek  */
     31  1.1  jdolecek 
     32  1.1  jdolecek #ifndef __ATPPCVAR_H
     33  1.1  jdolecek #define __ATPPCVAR_H
     34  1.1  jdolecek 
     35  1.1  jdolecek #include <machine/bus.h>
     36  1.1  jdolecek #include <machine/types.h>
     37  1.1  jdolecek #include <sys/device.h>
     38  1.1  jdolecek #include <sys/callout.h>
     39  1.1  jdolecek 
     40  1.1  jdolecek #include <dev/ppbus/ppbus_conf.h>
     41  1.1  jdolecek 
     42  1.1  jdolecek 
     43  1.1  jdolecek /* Maximum time to wait for device response */
     44  1.1  jdolecek #define MAXBUSYWAIT	(5 * (hz))
     45  1.1  jdolecek 
     46  1.1  jdolecek /* Poll interval when wating for device to become ready */
     47  1.1  jdolecek #define ATPPC_POLL	((hz)/10)
     48  1.1  jdolecek 
     49  1.1  jdolecek /* Interrupt priority level for atppc device */
     50  1.1  jdolecek #define IPL_ATPPC	IPL_TTY
     51  1.1  jdolecek #define splatppc        spltty
     52  1.1  jdolecek 
     53  1.1  jdolecek 
     54  1.1  jdolecek /* Diagnostic and verbose printing macros */
     55  1.1  jdolecek 
     56  1.1  jdolecek #ifdef ATPPC_DEBUG
     57  1.1  jdolecek extern int atppc_debug;
     58  1.1  jdolecek #define ATPPC_DPRINTF(arg) if(atppc_debug) printf arg
     59  1.1  jdolecek #else
     60  1.1  jdolecek #define ATPPC_DPRINTF(arg)
     61  1.1  jdolecek #endif
     62  1.1  jdolecek 
     63  1.1  jdolecek #ifdef ATPPC_VERBOSE
     64  1.1  jdolecek extern int atppc_verbose;
     65  1.1  jdolecek #define ATPPC_VPRINTF(arg) if(atppc_verbose) printf arg
     66  1.1  jdolecek #else
     67  1.1  jdolecek #define ATPPC_VPRINTF(arg)
     68  1.1  jdolecek #endif
     69  1.1  jdolecek 
     70  1.1  jdolecek 
     71  1.1  jdolecek /* Flag used in DMA transfer */
     72  1.1  jdolecek #define ATPPC_DMA_MODE_READ 0x0
     73  1.1  jdolecek #define ATPPC_DMA_MODE_WRITE 0x1
     74  1.1  jdolecek 
     75  1.1  jdolecek 
     76  1.1  jdolecek /* Flags passed via config */
     77  1.1  jdolecek #define ATPPC_FLAG_DISABLE_INTR	0x01
     78  1.1  jdolecek #define ATPPC_FLAG_DISABLE_DMA	0x02
     79  1.1  jdolecek 
     80  1.1  jdolecek 
     81  1.1  jdolecek /* Locking for atppc device */
     82  1.1  jdolecek #if defined(MULTIPROCESSOR) || defined (LOCKDEBUG)
     83  1.1  jdolecek #include <sys/lock.h>
     84  1.1  jdolecek #define ATPPC_SC_LOCK(sc) (&((sc)->sc_lock))
     85  1.4  drochner #define ATPPC_LOCK_INIT(sc) simple_lock_init(ATPPC_SC_LOCK((sc)))
     86  1.1  jdolecek #define ATPPC_LOCK(sc) simple_lock(ATPPC_SC_LOCK((sc)))
     87  1.1  jdolecek #define ATPPC_UNLOCK(sc) simple_unlock(ATPPC_SC_LOCK((sc)))
     88  1.1  jdolecek #else /* !(MULTIPROCESSOR) && !(LOCKDEBUG) */
     89  1.4  drochner #define ATPPC_LOCK_INIT(sc)
     90  1.1  jdolecek #define ATPPC_LOCK(sc)
     91  1.1  jdolecek #define ATPPC_UNLOCK(sc)
     92  1.6     perry #define ATPPC_SC_LOCK(sc) NULL
     93  1.1  jdolecek #endif /* MULTIPROCESSOR || LOCKDEBUG */
     94  1.1  jdolecek 
     95  1.1  jdolecek /* Single softintr callback entry */
     96  1.1  jdolecek struct atppc_handler_node {
     97  1.1  jdolecek 	void (*func)(void *);
     98  1.1  jdolecek 	void * arg;
     99  1.1  jdolecek 	SLIST_ENTRY(atppc_handler_node) entries;
    100  1.1  jdolecek };
    101  1.1  jdolecek 
    102  1.1  jdolecek /* Generic structure to hold parallel port chipset info. */
    103  1.1  jdolecek struct atppc_softc {
    104  1.1  jdolecek 	/* Generic device attributes */
    105  1.1  jdolecek 	struct device sc_dev;
    106  1.1  jdolecek 
    107  1.1  jdolecek #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
    108  1.6     perry 	/* Simple lock */
    109  1.1  jdolecek 	struct simplelock sc_lock;
    110  1.1  jdolecek #endif
    111  1.1  jdolecek 
    112  1.1  jdolecek 	/* Machine independent bus infrastructure */
    113  1.1  jdolecek 	bus_space_tag_t sc_iot;
    114  1.1  jdolecek 	bus_space_handle_t sc_ioh;
    115  1.1  jdolecek 	bus_dma_tag_t sc_dmat;
    116  1.1  jdolecek 	bus_dmamap_t sc_dmapt;
    117  1.1  jdolecek 	bus_size_t sc_dma_maxsize;
    118  1.1  jdolecek 
    119  1.1  jdolecek 	/* Child device */
    120  1.1  jdolecek 	struct device * child;
    121  1.1  jdolecek 
    122  1.1  jdolecek         /* Opaque handle used for interrupt handler establishment */
    123  1.1  jdolecek 	void * sc_ieh;
    124  1.1  jdolecek 
    125  1.1  jdolecek 	/* List of soft interrupts to call */
    126  1.1  jdolecek 	SLIST_HEAD(handler_list, atppc_handler_node) sc_handler_listhead;
    127  1.1  jdolecek 
    128  1.1  jdolecek 	 /* Input buffer: working pointers, and size in bytes. */
    129  1.1  jdolecek 	char * sc_inb;
    130  1.1  jdolecek 	char * sc_inbstart;
    131  1.1  jdolecek 	u_int32_t sc_inb_nbytes;
    132  1.1  jdolecek 	int sc_inerr;
    133  1.1  jdolecek 
    134  1.1  jdolecek 	/* Output buffer pointer, working pointer, and size in bytes. */
    135  1.1  jdolecek 	char * sc_outb;
    136  1.1  jdolecek 	char * sc_outbstart;
    137  1.1  jdolecek 	u_int32_t sc_outb_nbytes;
    138  1.1  jdolecek 	int sc_outerr;
    139  1.1  jdolecek 
    140  1.1  jdolecek 	/* DMA functions: setup by bus specific attach code */
    141  1.1  jdolecek 	int (*sc_dma_start)(struct atppc_softc *, void *, u_int, u_int8_t);
    142  1.1  jdolecek 	int (*sc_dma_finish)(struct atppc_softc *);
    143  1.1  jdolecek 	int (*sc_dma_abort)(struct atppc_softc *);
    144  1.6     perry 	int (*sc_dma_malloc)(struct device *, caddr_t *, bus_addr_t *,
    145  1.1  jdolecek 		bus_size_t);
    146  1.6     perry 	void (*sc_dma_free)(struct device *, caddr_t *, bus_addr_t *,
    147  1.1  jdolecek 		bus_size_t);
    148  1.6     perry 
    149  1.1  jdolecek 	/* Microsequence related members */
    150  1.1  jdolecek 	char * sc_ptr;		/* microseq current pointer */
    151  1.1  jdolecek 	int sc_accum;		/* microseq accumulator */
    152  1.1  jdolecek 
    153  1.1  jdolecek 	/* Device attachment state */
    154  1.1  jdolecek #define ATPPC_ATTACHED 1
    155  1.1  jdolecek #define ATPPC_NOATTACH 0
    156  1.1  jdolecek 	u_int8_t sc_dev_ok;
    157  1.1  jdolecek 
    158  1.6     perry 	/*
    159  1.6     perry 	 * Hardware capabilities flags: standard mode and nibble mode are
    160  1.6     perry 	 * assumed to always be available since if they aren't you don't
    161  1.1  jdolecek 	 * HAVE a parallel port.
    162  1.1  jdolecek 	 */
    163  1.1  jdolecek #define ATPPC_HAS_INTR	0x01	/* Interrupt available */
    164  1.1  jdolecek #define ATPPC_HAS_DMA	0x02	/* DMA available */
    165  1.1  jdolecek #define ATPPC_HAS_FIFO	0x04	/* FIFO available */
    166  1.1  jdolecek #define ATPPC_HAS_PS2	0x08	/* PS2 mode capable */
    167  1.1  jdolecek #define ATPPC_HAS_ECP	0x10	/* ECP mode available */
    168  1.1  jdolecek #define ATPPC_HAS_EPP	0x20	/* EPP mode available */
    169  1.1  jdolecek 	u_int8_t sc_has;	/* Chipset detected capabilities */
    170  1.1  jdolecek 
    171  1.1  jdolecek 	/* Flags specifying mode of chipset operation . */
    172  1.1  jdolecek #define ATPPC_MODE_STD	0x01	/* Use centronics-compatible mode */
    173  1.6     perry #define ATPPC_MODE_PS2	0x02	/* Use PS2 mode */
    174  1.1  jdolecek #define ATPPC_MODE_EPP	0x04	/* Use EPP mode */
    175  1.1  jdolecek #define ATPPC_MODE_ECP	0x08	/* Use ECP mode */
    176  1.1  jdolecek #define ATPPC_MODE_NIBBLE 0x10	/* Use nibble mode */
    177  1.1  jdolecek #define ATPPC_MODE_FAST	0x20	/* Use Fast Centronics mode */
    178  1.1  jdolecek 	u_int8_t sc_mode;	/* Current operational mode */
    179  1.1  jdolecek 
    180  1.1  jdolecek 	/* Flags which further define chipset operation */
    181  1.1  jdolecek #define ATPPC_USE_INTR	0x01	/* Use interrupts */
    182  1.1  jdolecek #define ATPPC_USE_DMA	0x02	/* Use DMA */
    183  1.1  jdolecek 	u_int8_t sc_use;	/* Capabilities to use */
    184  1.1  jdolecek 
    185  1.1  jdolecek 	/* Parallel Port Chipset model. */
    186  1.1  jdolecek #define SMC_LIKE        0
    187  1.1  jdolecek #define SMC_37C665GT    1
    188  1.1  jdolecek #define SMC_37C666GT    2
    189  1.1  jdolecek #define NS_PC87332      3
    190  1.1  jdolecek #define NS_PC87306      4
    191  1.1  jdolecek #define INTEL_820191AA  5       /* XXX not implemented */
    192  1.1  jdolecek #define GENERIC         6
    193  1.1  jdolecek #define WINB_W83877F    7
    194  1.1  jdolecek #define WINB_W83877AF   8
    195  1.1  jdolecek #define WINB_UNKNOWN    9
    196  1.1  jdolecek #define NS_PC87334      10
    197  1.1  jdolecek #define SMC_37C935      11
    198  1.1  jdolecek #define NS_PC87303      12
    199  1.1  jdolecek 	u_int8_t sc_model;	/* chipset model */
    200  1.1  jdolecek 
    201  1.1  jdolecek 	/* EPP mode */
    202  1.1  jdolecek #define ATPPC_EPP_1_9	0x0
    203  1.1  jdolecek #define ATPPC_EPP_1_7	0x1
    204  1.1  jdolecek 	u_int8_t sc_epp;
    205  1.1  jdolecek 
    206  1.1  jdolecek 	/* Parallel Port Chipset Type. SMC versus GENERIC (others) */
    207  1.1  jdolecek #define ATPPC_TYPE_SMCLIKE 0
    208  1.1  jdolecek #define ATPPC_TYPE_GENERIC 1
    209  1.1  jdolecek 	u_int8_t sc_type;	/* generic or smclike chipset type */
    210  1.1  jdolecek 
    211  1.1  jdolecek 	/* Stored register values after an interrupt occurs */
    212  1.1  jdolecek 	u_int8_t sc_ecr_intr;
    213  1.1  jdolecek 	u_int8_t sc_ctr_intr;
    214  1.1  jdolecek 	u_int8_t sc_str_intr;
    215  1.1  jdolecek 
    216  1.1  jdolecek #define ATPPC_IRQ_NONE	0x0
    217  1.1  jdolecek #define ATPPC_IRQ_nACK	0x1
    218  1.1  jdolecek #define ATPPC_IRQ_DMA	0x2
    219  1.1  jdolecek #define ATPPC_IRQ_FIFO	0x4
    220  1.1  jdolecek #define ATPPC_IRQ_nFAULT	0x8
    221  1.1  jdolecek 	u_int8_t sc_irqstat;	/* Record irq settings */
    222  1.1  jdolecek 
    223  1.1  jdolecek #define ATPPC_DMA_INIT		0x01
    224  1.1  jdolecek #define ATPPC_DMA_STARTED	0x02
    225  1.1  jdolecek #define ATPPC_DMA_COMPLETE	0x03
    226  1.1  jdolecek #define ATPPC_DMA_INTERRUPTED	0x04
    227  1.1  jdolecek #define ATPPC_DMA_ERROR		0x05
    228  1.1  jdolecek 	u_int8_t sc_dmastat;	/* Record dma state */
    229  1.1  jdolecek 
    230  1.1  jdolecek #define ATPPC_PWORD_MASK	0x30
    231  1.1  jdolecek #define ATPPC_PWORD_16	0x00
    232  1.1  jdolecek #define ATPPC_PWORD_8	0x10
    233  1.1  jdolecek #define ATPPC_PWORD_32	0x20
    234  1.1  jdolecek 	u_int8_t sc_pword;	/* PWord size: used for FIFO DMA transfers */
    235  1.1  jdolecek 	u_int8_t sc_fifo;	/* FIFO size */
    236  1.1  jdolecek 
    237  1.1  jdolecek 	/* Indicates number of PWords in FIFO queues that generate interrupt */
    238  1.1  jdolecek 	u_int8_t sc_wthr;	/* writeIntrThresold */
    239  1.1  jdolecek 	u_int8_t sc_rthr;	/* readIntrThresold */
    240  1.1  jdolecek };
    241  1.1  jdolecek 
    242  1.1  jdolecek 
    243  1.1  jdolecek 
    244  1.1  jdolecek #ifdef _KERNEL
    245  1.1  jdolecek 
    246  1.1  jdolecek /* Function prototypes */
    247  1.1  jdolecek 
    248  1.1  jdolecek /* Soft config attach/detach routines */
    249  1.5     perry void atppc_sc_attach(struct atppc_softc *);
    250  1.5     perry int atppc_sc_detach(struct atppc_softc *, int);
    251  1.1  jdolecek 
    252  1.1  jdolecek /* Detection routines */
    253  1.5     perry int atppc_detect_port(bus_space_tag_t, bus_space_handle_t);
    254  1.1  jdolecek 
    255  1.1  jdolecek /* Interrupt handler for atppc device */
    256  1.5     perry int atppcintr(void *);
    257  1.1  jdolecek 
    258  1.1  jdolecek #endif /* _KERNEL */
    259  1.1  jdolecek 
    260  1.6     perry #endif /* __ATPPCVAR_H */
    261