Home | History | Annotate | Line # | Download | only in hpc
pi1ppcvar.h revision 1.4.2.1
      1  1.4.2.1    cherry /* $NetBSD: pi1ppcvar.h,v 1.4.2.1 2011/06/23 14:19:39 cherry Exp $ */
      2      1.1  kurahone 
      3      1.1  kurahone /*-
      4      1.1  kurahone  * Copyright (c) 2001 Alcove - Nicolas Souchu
      5      1.1  kurahone  * Copyright (c) 2005 Joe Britt <britt (at) danger.com> - SGI PI1 version
      6      1.1  kurahone  * All rights reserved.
      7      1.1  kurahone  *
      8      1.1  kurahone  * Redistribution and use in source and binary forms, with or without
      9      1.1  kurahone  * modification, are permitted provided that the following conditions
     10      1.1  kurahone  * are met:
     11      1.1  kurahone  * 1. Redistributions of source code must retain the above copyright
     12      1.1  kurahone  *    notice, this list of conditions and the following disclaimer.
     13      1.1  kurahone  * 2. Redistributions in binary form must reproduce the above copyright
     14      1.1  kurahone  *    notice, this list of conditions and the following disclaimer in the
     15      1.1  kurahone  *    documentation and/or other materials provided with the distribution.
     16      1.1  kurahone  *
     17      1.1  kurahone  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     18      1.1  kurahone  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19      1.1  kurahone  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20      1.1  kurahone  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     21      1.1  kurahone  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22      1.1  kurahone  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23      1.1  kurahone  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24      1.1  kurahone  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25      1.1  kurahone  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26      1.1  kurahone  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27      1.1  kurahone  * SUCH DAMAGE.
     28      1.1  kurahone  *
     29      1.1  kurahone  * FreeBSD: src/sys/isa/ppcreg.h,v 1.10.2.4 2001/10/02 05:21:45 nsouch Exp
     30      1.1  kurahone  *
     31      1.1  kurahone  */
     32      1.1  kurahone 
     33      1.1  kurahone #ifndef __PI1PPCVAR_H
     34      1.1  kurahone #define __PI1PPCVAR_H
     35      1.1  kurahone 
     36      1.1  kurahone #include <machine/bus.h>
     37      1.1  kurahone #include <machine/types.h>
     38      1.1  kurahone #include <sys/device.h>
     39      1.1  kurahone #include <sys/callout.h>
     40      1.1  kurahone 
     41      1.1  kurahone #include <dev/ppbus/ppbus_conf.h>
     42      1.1  kurahone 
     43      1.1  kurahone /* Maximum time to wait for device response */
     44      1.1  kurahone #define MAXBUSYWAIT	(5 * (hz))
     45      1.1  kurahone 
     46      1.1  kurahone /* Poll interval when wating for device to become ready */
     47      1.1  kurahone #define PI1PPC_POLL	((hz)/10)
     48      1.1  kurahone 
     49      1.1  kurahone /* Diagnostic and verbose printing macros */
     50      1.1  kurahone 
     51      1.1  kurahone #ifdef PI1PPC_DEBUG
     52      1.1  kurahone extern int pi1ppc_debug;
     53      1.1  kurahone #define PI1PPC_DPRINTF(arg) if(pi1ppc_debug) printf arg
     54      1.1  kurahone #else
     55      1.1  kurahone #define PI1PPC_DPRINTF(arg)
     56      1.1  kurahone #endif
     57      1.1  kurahone 
     58      1.1  kurahone #ifdef PI1PPC_VERBOSE
     59      1.1  kurahone extern int pi1ppc_verbose;
     60      1.1  kurahone #define PI1PPC_VPRINTF(arg) if(pi1ppc_verbose) printf arg
     61      1.1  kurahone #else
     62      1.1  kurahone #define PI1PPC_VPRINTF(arg)
     63      1.1  kurahone #endif
     64      1.1  kurahone 
     65      1.1  kurahone /* Flag used in DMA transfer */
     66      1.1  kurahone #define PI1PPC_DMA_MODE_READ 0x0
     67      1.1  kurahone #define PI1PPC_DMA_MODE_WRITE 0x1
     68      1.1  kurahone 
     69      1.1  kurahone /* Flags passed via config */
     70      1.1  kurahone #define PI1PPC_FLAG_DISABLE_INTR	0x01
     71      1.1  kurahone #define PI1PPC_FLAG_DISABLE_DMA	0x02
     72      1.1  kurahone 
     73      1.1  kurahone /* Locking for pi1ppc device */
     74  1.4.2.1    cherry #define PI1PPC_SC_LOCK(sc)	(&((sc)->sc_lock))
     75  1.4.2.1    cherry #define PI1PPC_LOCK(sc)		mutex_enter(&sc->sc_lock)
     76  1.4.2.1    cherry #define PI1PPC_UNLOCK(sc)	mutex_exit(&sc->sc_lock)
     77      1.1  kurahone 
     78      1.1  kurahone /* Single softintr callback entry */
     79      1.1  kurahone struct pi1ppc_handler_node {
     80      1.1  kurahone 	void (*func)(void *);
     81      1.2  christos 	void *arg;
     82      1.1  kurahone 	SLIST_ENTRY(pi1ppc_handler_node) entries;
     83      1.1  kurahone };
     84      1.1  kurahone 
     85      1.1  kurahone /* Generic structure to hold parallel port chipset info. */
     86      1.1  kurahone struct pi1ppc_softc {
     87      1.1  kurahone 	/* Generic device attributes */
     88  1.4.2.1    cherry 	device_t sc_dev;
     89      1.1  kurahone 
     90  1.4.2.1    cherry 	kmutex_t sc_lock;
     91  1.4.2.1    cherry 	kcondvar_t sc_in_cv;
     92  1.4.2.1    cherry 	kcondvar_t sc_out_cv;
     93      1.1  kurahone 
     94      1.1  kurahone 	/* Machine independent bus infrastructure */
     95      1.1  kurahone 	bus_space_tag_t sc_iot;
     96      1.1  kurahone 	bus_space_handle_t sc_ioh;
     97      1.1  kurahone 	bus_dma_tag_t sc_dmat;
     98      1.1  kurahone 	bus_dmamap_t sc_dmapt;
     99      1.1  kurahone 	bus_size_t sc_dma_maxsize;
    100      1.1  kurahone 
    101      1.1  kurahone 	/* Child device */
    102      1.3    cegger 	device_t child;
    103      1.1  kurahone 
    104      1.1  kurahone         /* Opaque handle used for interrupt handler establishment */
    105      1.2  christos 	void *sc_ieh;
    106      1.1  kurahone 
    107      1.1  kurahone 	/* List of soft interrupts to call */
    108      1.1  kurahone 	SLIST_HEAD(handler_list, pi1ppc_handler_node) sc_handler_listhead;
    109      1.1  kurahone 
    110      1.1  kurahone 	 /* Input buffer: working pointers, and size in bytes. */
    111      1.1  kurahone 	char * sc_inb;
    112      1.1  kurahone 	char * sc_inbstart;
    113      1.4   tsutsui 	uint32_t sc_inb_nbytes;
    114      1.1  kurahone 	int sc_inerr;
    115      1.1  kurahone 
    116      1.1  kurahone 	/* Output buffer pointer, working pointer, and size in bytes. */
    117      1.1  kurahone 	char * sc_outb;
    118      1.1  kurahone 	char * sc_outbstart;
    119      1.4   tsutsui 	uint32_t sc_outb_nbytes;
    120      1.1  kurahone 	int sc_outerr;
    121      1.1  kurahone 
    122      1.1  kurahone 	/* DMA functions: setup by bus specific attach code */
    123      1.4   tsutsui 	int (*sc_dma_start)(struct pi1ppc_softc *, void *, u_int, uint8_t);
    124      1.1  kurahone 	int (*sc_dma_finish)(struct pi1ppc_softc *);
    125      1.1  kurahone 	int (*sc_dma_abort)(struct pi1ppc_softc *);
    126      1.3    cegger 	int (*sc_dma_malloc)(device_t, void **, bus_addr_t *,
    127      1.1  kurahone 		bus_size_t);
    128      1.3    cegger 	void (*sc_dma_free)(device_t, void **, bus_addr_t *,
    129      1.1  kurahone 		bus_size_t);
    130      1.1  kurahone 
    131      1.1  kurahone 	/* Microsequence related members */
    132      1.1  kurahone 	char * sc_ptr;		/* microseq current pointer */
    133      1.1  kurahone 	int sc_accum;		/* microseq accumulator */
    134      1.1  kurahone 
    135      1.1  kurahone 	/* Device attachment state */
    136      1.1  kurahone #define PI1PPC_ATTACHED 1
    137      1.1  kurahone #define PI1PPC_NOATTACH 0
    138      1.4   tsutsui 	uint8_t sc_dev_ok;
    139      1.1  kurahone 
    140      1.1  kurahone 	/*
    141      1.1  kurahone 	 * Hardware capabilities flags: standard mode and nibble mode are
    142      1.1  kurahone 	 * assumed to always be available since if they aren't you don't
    143      1.1  kurahone 	 * HAVE a parallel port.
    144      1.1  kurahone 	 */
    145      1.1  kurahone #define PI1PPC_HAS_INTR	0x01	/* Interrupt available */
    146      1.1  kurahone #define PI1PPC_HAS_DMA	0x02	/* DMA available */
    147      1.1  kurahone #define PI1PPC_HAS_FIFO	0x04	/* FIFO available */
    148      1.1  kurahone #define PI1PPC_HAS_PS2	0x08	/* PS2 mode capable */
    149      1.4   tsutsui 	uint8_t sc_has;		/* Chipset detected capabilities */
    150      1.1  kurahone 
    151      1.1  kurahone 	/* Flags specifying mode of chipset operation . */
    152      1.1  kurahone #define PI1PPC_MODE_STD	0x01	/* Use centronics-compatible mode */
    153      1.1  kurahone #define PI1PPC_MODE_PS2	0x02	/* Use PS2 mode */
    154      1.1  kurahone #define PI1PPC_MODE_NIBBLE 0x10	/* Use nibble mode */
    155      1.4   tsutsui 	uint8_t sc_mode;	/* Current operational mode */
    156      1.1  kurahone 
    157      1.1  kurahone 	/* Flags which further define chipset operation */
    158      1.1  kurahone #define PI1PPC_USE_INTR	0x01	/* Use interrupts */
    159      1.1  kurahone #define PI1PPC_USE_DMA	0x02	/* Use DMA */
    160      1.4   tsutsui 	uint8_t sc_use;		/* Capabilities to use */
    161      1.1  kurahone 
    162      1.1  kurahone 	/* Parallel Port Chipset model. */
    163      1.1  kurahone #define GENERIC         6
    164      1.4   tsutsui 	uint8_t sc_model;	/* chipset model */
    165      1.1  kurahone 
    166      1.1  kurahone 	/* EPP mode - UNUSED */
    167      1.4   tsutsui 	uint8_t sc_epp;
    168      1.1  kurahone 
    169      1.1  kurahone 	/* Parallel Port Chipset Type.  Only Indy-style needed? */
    170      1.1  kurahone #define PI1PPC_TYPE_INDY 0
    171      1.4   tsutsui 	uint8_t sc_type;
    172      1.1  kurahone 
    173      1.1  kurahone 	/* Stored register values after an interrupt occurs */
    174      1.4   tsutsui 	uint8_t sc_ecr_intr;
    175      1.4   tsutsui 	uint8_t sc_ctr_intr;
    176      1.4   tsutsui 	uint8_t sc_str_intr;
    177      1.1  kurahone 
    178      1.1  kurahone #define PI1PPC_IRQ_NONE	0x0
    179      1.1  kurahone #define PI1PPC_IRQ_nACK	0x1
    180      1.1  kurahone #define PI1PPC_IRQ_DMA	0x2
    181      1.1  kurahone #define PI1PPC_IRQ_FIFO	0x4
    182      1.1  kurahone #define PI1PPC_IRQ_nFAULT	0x8
    183      1.4   tsutsui 	uint8_t sc_irqstat;	/* Record irq settings */
    184      1.1  kurahone 
    185      1.1  kurahone #define PI1PPC_DMA_INIT		0x01
    186      1.1  kurahone #define PI1PPC_DMA_STARTED	0x02
    187      1.1  kurahone #define PI1PPC_DMA_COMPLETE	0x03
    188      1.1  kurahone #define PI1PPC_DMA_INTERRUPTED	0x04
    189      1.1  kurahone #define PI1PPC_DMA_ERROR		0x05
    190      1.4   tsutsui 	uint8_t sc_dmastat;	/* Record dma state */
    191      1.1  kurahone 
    192      1.1  kurahone #define PI1PPC_PWORD_MASK	0x30
    193      1.1  kurahone #define PI1PPC_PWORD_16	0x00
    194      1.1  kurahone #define PI1PPC_PWORD_8	0x10
    195      1.1  kurahone #define PI1PPC_PWORD_32	0x20
    196      1.4   tsutsui 	uint8_t sc_pword;	/* PWord size: used for FIFO DMA transfers */
    197      1.4   tsutsui 	uint8_t sc_fifo;	/* FIFO size */
    198      1.1  kurahone 
    199      1.1  kurahone 	/* Indicates number of PWords in FIFO queues that generate interrupt */
    200      1.4   tsutsui 	uint8_t sc_wthr;	/* writeIntrThresold */
    201      1.4   tsutsui 	uint8_t sc_rthr;	/* readIntrThresold */
    202      1.1  kurahone };
    203      1.1  kurahone 
    204      1.1  kurahone #ifdef _KERNEL
    205      1.1  kurahone 
    206      1.1  kurahone /* Function prototypes */
    207      1.1  kurahone 
    208      1.1  kurahone /* Soft config attach/detach routines */
    209      1.1  kurahone void pi1ppc_sc_attach(struct pi1ppc_softc *);
    210      1.1  kurahone int pi1ppc_sc_detach(struct pi1ppc_softc *, int);
    211      1.1  kurahone 
    212      1.1  kurahone /* Detection routines */
    213      1.1  kurahone int pi1ppc_detect_port(bus_space_tag_t, bus_space_handle_t);
    214      1.1  kurahone 
    215      1.1  kurahone /* Interrupt handler for pi1ppc device */
    216      1.1  kurahone int pi1ppcintr(void *);
    217      1.1  kurahone 
    218      1.1  kurahone #endif /* _KERNEL */
    219      1.1  kurahone 
    220      1.1  kurahone #endif /* __PI1PPCVAR_H */
    221