Home | History | Annotate | Line # | Download | only in hpc
pi1ppcvar.h revision 1.2.40.1
      1  1.2.40.1       mjf /* $NetBSD: pi1ppcvar.h,v 1.2.40.1 2008/06/02 13:22:37 mjf 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 
     44       1.1  kurahone /* Maximum time to wait for device response */
     45       1.1  kurahone #define MAXBUSYWAIT	(5 * (hz))
     46       1.1  kurahone 
     47       1.1  kurahone /* Poll interval when wating for device to become ready */
     48       1.1  kurahone #define PI1PPC_POLL	((hz)/10)
     49       1.1  kurahone 
     50       1.1  kurahone /* Interrupt priority level for pi1ppc device */
     51       1.1  kurahone #define IPL_PI1PPC	IPL_TTY
     52       1.1  kurahone #define splpi1ppc	spltty
     53       1.1  kurahone 
     54       1.1  kurahone 
     55       1.1  kurahone /* Diagnostic and verbose printing macros */
     56       1.1  kurahone 
     57       1.1  kurahone #ifdef PI1PPC_DEBUG
     58       1.1  kurahone extern int pi1ppc_debug;
     59       1.1  kurahone #define PI1PPC_DPRINTF(arg) if(pi1ppc_debug) printf arg
     60       1.1  kurahone #else
     61       1.1  kurahone #define PI1PPC_DPRINTF(arg)
     62       1.1  kurahone #endif
     63       1.1  kurahone 
     64       1.1  kurahone #ifdef PI1PPC_VERBOSE
     65       1.1  kurahone extern int pi1ppc_verbose;
     66       1.1  kurahone #define PI1PPC_VPRINTF(arg) if(pi1ppc_verbose) printf arg
     67       1.1  kurahone #else
     68       1.1  kurahone #define PI1PPC_VPRINTF(arg)
     69       1.1  kurahone #endif
     70       1.1  kurahone 
     71       1.1  kurahone 
     72       1.1  kurahone /* Flag used in DMA transfer */
     73       1.1  kurahone #define PI1PPC_DMA_MODE_READ 0x0
     74       1.1  kurahone #define PI1PPC_DMA_MODE_WRITE 0x1
     75       1.1  kurahone 
     76       1.1  kurahone 
     77       1.1  kurahone /* Flags passed via config */
     78       1.1  kurahone #define PI1PPC_FLAG_DISABLE_INTR	0x01
     79       1.1  kurahone #define PI1PPC_FLAG_DISABLE_DMA	0x02
     80       1.1  kurahone 
     81       1.1  kurahone 
     82       1.1  kurahone /* Locking for pi1ppc device */
     83       1.1  kurahone #if defined(MULTIPROCESSOR) || defined (LOCKDEBUG)
     84       1.1  kurahone #include <sys/lock.h>
     85       1.1  kurahone #define PI1PPC_SC_LOCK(sc) (&((sc)->sc_lock))
     86       1.1  kurahone #define PI1PPC_LOCK_INIT(sc) simple_lock_init(PI1PPC_SC_LOCK((sc)))
     87       1.1  kurahone #define PI1PPC_LOCK(sc) simple_lock(PI1PPC_SC_LOCK((sc)))
     88       1.1  kurahone #define PI1PPC_UNLOCK(sc) simple_unlock(PI1PPC_SC_LOCK((sc)))
     89       1.1  kurahone #else /* !(MULTIPROCESSOR) && !(LOCKDEBUG) */
     90       1.1  kurahone #define PI1PPC_LOCK_INIT(sc)
     91       1.1  kurahone #define PI1PPC_LOCK(sc)
     92       1.1  kurahone #define PI1PPC_UNLOCK(sc)
     93       1.1  kurahone #define PI1PPC_SC_LOCK(sc) NULL
     94       1.1  kurahone #endif /* MULTIPROCESSOR || LOCKDEBUG */
     95       1.1  kurahone 
     96       1.1  kurahone /* Single softintr callback entry */
     97       1.1  kurahone struct pi1ppc_handler_node {
     98       1.1  kurahone 	void (*func)(void *);
     99       1.2  christos 	void *arg;
    100       1.1  kurahone 	SLIST_ENTRY(pi1ppc_handler_node) entries;
    101       1.1  kurahone };
    102       1.1  kurahone 
    103       1.1  kurahone /* Generic structure to hold parallel port chipset info. */
    104       1.1  kurahone struct pi1ppc_softc {
    105       1.1  kurahone 	/* Generic device attributes */
    106  1.2.40.1       mjf         device_t sc_dev;
    107       1.1  kurahone 
    108       1.1  kurahone #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
    109       1.1  kurahone 	/* Simple lock */
    110       1.1  kurahone 	struct simplelock sc_lock;
    111       1.1  kurahone #endif
    112       1.1  kurahone 
    113       1.1  kurahone 	/* Machine independent bus infrastructure */
    114       1.1  kurahone 	bus_space_tag_t sc_iot;
    115       1.1  kurahone 	bus_space_handle_t sc_ioh;
    116       1.1  kurahone 	bus_dma_tag_t sc_dmat;
    117       1.1  kurahone 	bus_dmamap_t sc_dmapt;
    118       1.1  kurahone 	bus_size_t sc_dma_maxsize;
    119       1.1  kurahone 
    120       1.1  kurahone 	/* Child device */
    121  1.2.40.1       mjf 	device_t child;
    122       1.1  kurahone 
    123       1.1  kurahone         /* Opaque handle used for interrupt handler establishment */
    124       1.2  christos 	void *sc_ieh;
    125       1.1  kurahone 
    126       1.1  kurahone 	/* List of soft interrupts to call */
    127       1.1  kurahone 	SLIST_HEAD(handler_list, pi1ppc_handler_node) sc_handler_listhead;
    128       1.1  kurahone 
    129       1.1  kurahone 	 /* Input buffer: working pointers, and size in bytes. */
    130       1.1  kurahone 	char * sc_inb;
    131       1.1  kurahone 	char * sc_inbstart;
    132       1.1  kurahone 	u_int32_t sc_inb_nbytes;
    133       1.1  kurahone 	int sc_inerr;
    134       1.1  kurahone 
    135       1.1  kurahone 	/* Output buffer pointer, working pointer, and size in bytes. */
    136       1.1  kurahone 	char * sc_outb;
    137       1.1  kurahone 	char * sc_outbstart;
    138       1.1  kurahone 	u_int32_t sc_outb_nbytes;
    139       1.1  kurahone 	int sc_outerr;
    140       1.1  kurahone 
    141       1.1  kurahone 	/* DMA functions: setup by bus specific attach code */
    142       1.1  kurahone 	int (*sc_dma_start)(struct pi1ppc_softc *, void *, u_int, u_int8_t);
    143       1.1  kurahone 	int (*sc_dma_finish)(struct pi1ppc_softc *);
    144       1.1  kurahone 	int (*sc_dma_abort)(struct pi1ppc_softc *);
    145  1.2.40.1       mjf 	int (*sc_dma_malloc)(device_t, void **, bus_addr_t *,
    146       1.1  kurahone 		bus_size_t);
    147  1.2.40.1       mjf 	void (*sc_dma_free)(device_t, void **, bus_addr_t *,
    148       1.1  kurahone 		bus_size_t);
    149       1.1  kurahone 
    150       1.1  kurahone 	/* Microsequence related members */
    151       1.1  kurahone 	char * sc_ptr;		/* microseq current pointer */
    152       1.1  kurahone 	int sc_accum;		/* microseq accumulator */
    153       1.1  kurahone 
    154       1.1  kurahone 	/* Device attachment state */
    155       1.1  kurahone #define PI1PPC_ATTACHED 1
    156       1.1  kurahone #define PI1PPC_NOATTACH 0
    157       1.1  kurahone 	u_int8_t sc_dev_ok;
    158       1.1  kurahone 
    159       1.1  kurahone 	/*
    160       1.1  kurahone 	 * Hardware capabilities flags: standard mode and nibble mode are
    161       1.1  kurahone 	 * assumed to always be available since if they aren't you don't
    162       1.1  kurahone 	 * HAVE a parallel port.
    163       1.1  kurahone 	 */
    164       1.1  kurahone #define PI1PPC_HAS_INTR	0x01	/* Interrupt available */
    165       1.1  kurahone #define PI1PPC_HAS_DMA	0x02	/* DMA available */
    166       1.1  kurahone #define PI1PPC_HAS_FIFO	0x04	/* FIFO available */
    167       1.1  kurahone #define PI1PPC_HAS_PS2	0x08	/* PS2 mode capable */
    168       1.1  kurahone 	u_int8_t sc_has;	/* Chipset detected capabilities */
    169       1.1  kurahone 
    170       1.1  kurahone 	/* Flags specifying mode of chipset operation . */
    171       1.1  kurahone #define PI1PPC_MODE_STD	0x01	/* Use centronics-compatible mode */
    172       1.1  kurahone #define PI1PPC_MODE_PS2	0x02	/* Use PS2 mode */
    173       1.1  kurahone #define PI1PPC_MODE_NIBBLE 0x10	/* Use nibble mode */
    174       1.1  kurahone 	u_int8_t sc_mode;	/* Current operational mode */
    175       1.1  kurahone 
    176       1.1  kurahone 	/* Flags which further define chipset operation */
    177       1.1  kurahone #define PI1PPC_USE_INTR	0x01	/* Use interrupts */
    178       1.1  kurahone #define PI1PPC_USE_DMA	0x02	/* Use DMA */
    179       1.1  kurahone 	u_int8_t sc_use;	/* Capabilities to use */
    180       1.1  kurahone 
    181       1.1  kurahone 	/* Parallel Port Chipset model. */
    182       1.1  kurahone #define GENERIC         6
    183       1.1  kurahone 	u_int8_t sc_model;	/* chipset model */
    184       1.1  kurahone 
    185       1.1  kurahone 	/* EPP mode - UNUSED */
    186       1.1  kurahone 	u_int8_t sc_epp;
    187       1.1  kurahone 
    188       1.1  kurahone 	/* Parallel Port Chipset Type.  Only Indy-style needed? */
    189       1.1  kurahone #define PI1PPC_TYPE_INDY 0
    190       1.1  kurahone 	u_int8_t sc_type;
    191       1.1  kurahone 
    192       1.1  kurahone 	/* Stored register values after an interrupt occurs */
    193       1.1  kurahone 	u_int8_t sc_ecr_intr;
    194       1.1  kurahone 	u_int8_t sc_ctr_intr;
    195       1.1  kurahone 	u_int8_t sc_str_intr;
    196       1.1  kurahone 
    197       1.1  kurahone #define PI1PPC_IRQ_NONE	0x0
    198       1.1  kurahone #define PI1PPC_IRQ_nACK	0x1
    199       1.1  kurahone #define PI1PPC_IRQ_DMA	0x2
    200       1.1  kurahone #define PI1PPC_IRQ_FIFO	0x4
    201       1.1  kurahone #define PI1PPC_IRQ_nFAULT	0x8
    202       1.1  kurahone 	u_int8_t sc_irqstat;	/* Record irq settings */
    203       1.1  kurahone 
    204       1.1  kurahone #define PI1PPC_DMA_INIT		0x01
    205       1.1  kurahone #define PI1PPC_DMA_STARTED	0x02
    206       1.1  kurahone #define PI1PPC_DMA_COMPLETE	0x03
    207       1.1  kurahone #define PI1PPC_DMA_INTERRUPTED	0x04
    208       1.1  kurahone #define PI1PPC_DMA_ERROR		0x05
    209       1.1  kurahone 	u_int8_t sc_dmastat;	/* Record dma state */
    210       1.1  kurahone 
    211       1.1  kurahone #define PI1PPC_PWORD_MASK	0x30
    212       1.1  kurahone #define PI1PPC_PWORD_16	0x00
    213       1.1  kurahone #define PI1PPC_PWORD_8	0x10
    214       1.1  kurahone #define PI1PPC_PWORD_32	0x20
    215       1.1  kurahone 	u_int8_t sc_pword;	/* PWord size: used for FIFO DMA transfers */
    216       1.1  kurahone 	u_int8_t sc_fifo;	/* FIFO size */
    217       1.1  kurahone 
    218       1.1  kurahone 	/* Indicates number of PWords in FIFO queues that generate interrupt */
    219       1.1  kurahone 	u_int8_t sc_wthr;	/* writeIntrThresold */
    220       1.1  kurahone 	u_int8_t sc_rthr;	/* readIntrThresold */
    221       1.1  kurahone };
    222       1.1  kurahone 
    223       1.1  kurahone 
    224       1.1  kurahone 
    225       1.1  kurahone #ifdef _KERNEL
    226       1.1  kurahone 
    227       1.1  kurahone /* Function prototypes */
    228       1.1  kurahone 
    229       1.1  kurahone /* Soft config attach/detach routines */
    230       1.1  kurahone void pi1ppc_sc_attach(struct pi1ppc_softc *);
    231       1.1  kurahone int pi1ppc_sc_detach(struct pi1ppc_softc *, int);
    232       1.1  kurahone 
    233       1.1  kurahone /* Detection routines */
    234       1.1  kurahone int pi1ppc_detect_port(bus_space_tag_t, bus_space_handle_t);
    235       1.1  kurahone 
    236       1.1  kurahone /* Interrupt handler for pi1ppc device */
    237       1.1  kurahone int pi1ppcintr(void *);
    238       1.1  kurahone 
    239       1.1  kurahone #endif /* _KERNEL */
    240       1.1  kurahone 
    241       1.1  kurahone #endif /* __PI1PPCVAR_H */
    242