Home | History | Annotate | Line # | Download | only in pnpbus
pnpbusvar.h revision 1.1.8.2
      1  1.1.8.2  simonb /*	$NetBSD: pnpbusvar.h,v 1.1.8.2 2006/04/22 11:37:54 simonb Exp $	*/
      2  1.1.8.2  simonb 
      3  1.1.8.2  simonb /*-
      4  1.1.8.2  simonb  * Copyright (c) 2006 The NetBSD Foundation, Inc.
      5  1.1.8.2  simonb  * All rights reserved.
      6  1.1.8.2  simonb  *
      7  1.1.8.2  simonb  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1.8.2  simonb  * by Tim Rightnour.
      9  1.1.8.2  simonb  *
     10  1.1.8.2  simonb  * Redistribution and use in source and binary forms, with or without
     11  1.1.8.2  simonb  * modification, are permitted provided that the following conditions
     12  1.1.8.2  simonb  * are met:
     13  1.1.8.2  simonb  * 1. Redistributions of source code must retain the above copyright
     14  1.1.8.2  simonb  *    notice, this list of conditions and the following disclaimer.
     15  1.1.8.2  simonb  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1.8.2  simonb  *    notice, this list of conditions and the following disclaimer in the
     17  1.1.8.2  simonb  *    documentation and/or other materials provided with the distribution.
     18  1.1.8.2  simonb  * 3. All advertising materials mentioning features or use of this software
     19  1.1.8.2  simonb  *    must display the following acknowledgement:
     20  1.1.8.2  simonb  *      This product includes software developed by the NetBSD
     21  1.1.8.2  simonb  *      Foundation, Inc. and its contributors.
     22  1.1.8.2  simonb  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1.8.2  simonb  *    contributors may be used to endorse or promote products derived
     24  1.1.8.2  simonb  *    from this software without specific prior written permission.
     25  1.1.8.2  simonb  *
     26  1.1.8.2  simonb  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1.8.2  simonb  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1.8.2  simonb  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1.8.2  simonb  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1.8.2  simonb  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1.8.2  simonb  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1.8.2  simonb  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1.8.2  simonb  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1.8.2  simonb  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1.8.2  simonb  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1.8.2  simonb  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1.8.2  simonb  */
     38  1.1.8.2  simonb 
     39  1.1.8.2  simonb #ifndef _PREP_PNPBUSVAR_H_
     40  1.1.8.2  simonb #define _PREP_PNPBUSVAR_H_
     41  1.1.8.2  simonb 
     42  1.1.8.2  simonb #include <sys/queue.h>
     43  1.1.8.2  simonb #include <machine/bus.h>
     44  1.1.8.2  simonb #include <machine/residual.h>
     45  1.1.8.2  simonb 
     46  1.1.8.2  simonb struct pnpbus_mem {
     47  1.1.8.2  simonb 	SIMPLEQ_ENTRY(pnpbus_mem) next;
     48  1.1.8.2  simonb 	uint32_t minbase, maxbase, align, len;
     49  1.1.8.2  simonb 	int flags;
     50  1.1.8.2  simonb };
     51  1.1.8.2  simonb struct pnpbus_io {
     52  1.1.8.2  simonb 	SIMPLEQ_ENTRY(pnpbus_io) next;
     53  1.1.8.2  simonb 	uint16_t minbase, maxbase, align, len;
     54  1.1.8.2  simonb 	int flags;
     55  1.1.8.2  simonb };
     56  1.1.8.2  simonb struct pnpbus_irq {
     57  1.1.8.2  simonb 	SIMPLEQ_ENTRY(pnpbus_irq) next;
     58  1.1.8.2  simonb 	uint16_t mask;
     59  1.1.8.2  simonb 	int flags;
     60  1.1.8.2  simonb };
     61  1.1.8.2  simonb struct pnpbus_dma {
     62  1.1.8.2  simonb 	SIMPLEQ_ENTRY(pnpbus_dma) next;
     63  1.1.8.2  simonb 	uint8_t mask;
     64  1.1.8.2  simonb 	int flags;
     65  1.1.8.2  simonb };
     66  1.1.8.2  simonb struct pnpbus_compatid {
     67  1.1.8.2  simonb 	char idstr[8];
     68  1.1.8.2  simonb 	struct pnpbus_compatid *next;
     69  1.1.8.2  simonb };
     70  1.1.8.2  simonb 
     71  1.1.8.2  simonb #define PNPBUS_MAXMEM 4
     72  1.1.8.2  simonb #define PNPBUS_MAXIOPORT 8
     73  1.1.8.2  simonb #define PNPBUS_MAXIRQ 2
     74  1.1.8.2  simonb #define PNPBUS_MAXDMA 2
     75  1.1.8.2  simonb 
     76  1.1.8.2  simonb struct pnpresources {
     77  1.1.8.2  simonb 	int nummem, numio, numirq, numdma;
     78  1.1.8.2  simonb 	SIMPLEQ_HEAD(, pnpbus_mem) mem;
     79  1.1.8.2  simonb 	SIMPLEQ_HEAD(, pnpbus_io) io;
     80  1.1.8.2  simonb 	SIMPLEQ_HEAD(, pnpbus_irq) irq;
     81  1.1.8.2  simonb 	SIMPLEQ_HEAD(, pnpbus_dma) dma;
     82  1.1.8.2  simonb 	struct pnpbus_compatid *compatids;
     83  1.1.8.2  simonb };
     84  1.1.8.2  simonb 
     85  1.1.8.2  simonb /*
     86  1.1.8.2  simonb  * Bus attach arguments
     87  1.1.8.2  simonb  */
     88  1.1.8.2  simonb struct pnpbus_attach_args {
     89  1.1.8.2  simonb 	bus_space_tag_t paa_iot;		/* i/o space tag */
     90  1.1.8.2  simonb 	bus_space_tag_t paa_memt;		/* mem space tag */
     91  1.1.8.2  simonb 	isa_chipset_tag_t paa_ic;		/* ISA chipset tag */
     92  1.1.8.2  simonb };
     93  1.1.8.2  simonb 
     94  1.1.8.2  simonb /*
     95  1.1.8.2  simonb  * driver attach arguments
     96  1.1.8.2  simonb  */
     97  1.1.8.2  simonb struct pnpbus_dev_attach_args {
     98  1.1.8.2  simonb 	bus_space_tag_t pna_iot;	/* i/o space tag */
     99  1.1.8.2  simonb 	bus_space_tag_t pna_memt;	/* mem space tag */
    100  1.1.8.2  simonb 	isa_chipset_tag_t pna_ic;	/* ISA chipset tag */
    101  1.1.8.2  simonb 
    102  1.1.8.2  simonb 	struct pnpresources pna_res;	/* resources gathered from PNP */
    103  1.1.8.2  simonb 	char	pna_devid[8];		/* PNP device id string */
    104  1.1.8.2  simonb 	PPC_DEVICE *pna_ppc_dev;	/* PNP device entry */
    105  1.1.8.2  simonb 	void	*pna_aux;		/* driver specific */
    106  1.1.8.2  simonb };
    107  1.1.8.2  simonb 
    108  1.1.8.2  simonb /*
    109  1.1.8.2  simonb  * master bus
    110  1.1.8.2  simonb  */
    111  1.1.8.2  simonb struct pnpbus_softc {
    112  1.1.8.2  simonb 	struct	device sc_dev;		/* base device */
    113  1.1.8.2  simonb 	isa_chipset_tag_t sc_ic;
    114  1.1.8.2  simonb 
    115  1.1.8.2  simonb 	bus_space_tag_t sc_iot;		/* io space tag */
    116  1.1.8.2  simonb 	bus_space_tag_t sc_memt;	/* mem space tag */
    117  1.1.8.2  simonb };
    118  1.1.8.2  simonb 
    119  1.1.8.2  simonb int	pnpbus_scan(struct pnpbus_dev_attach_args *pna, PPC_DEVICE *dev);
    120  1.1.8.2  simonb void	pnpbus_print_devres(struct pnpbus_dev_attach_args *pna);
    121  1.1.8.2  simonb void	*pnpbus_intr_establish(int idx, int level, int (*ih_fun)(void *),
    122  1.1.8.2  simonb 	    void *ih_arg, struct pnpresources *r);
    123  1.1.8.2  simonb void	pnpbus_intr_disestablish(void *arg);
    124  1.1.8.2  simonb int	pnpbus_getirqnum(struct pnpresources *r, int idx, int *irqp, int *istp);
    125  1.1.8.2  simonb int	pnpbus_getdmachan(struct pnpresources *r, int idx, int *chanp);
    126  1.1.8.2  simonb int	pnpbus_getioport(struct pnpresources *r, int idx, int *basep,
    127  1.1.8.2  simonb 	    int *sizep);
    128  1.1.8.2  simonb int	pnpbus_io_map(struct pnpresources *r, int idx, bus_space_tag_t *tagp,
    129  1.1.8.2  simonb 	    bus_space_handle_t *hdlp);
    130  1.1.8.2  simonb void	pnpbus_io_unmap(struct pnpresources *r, int idx, bus_space_tag_t tag,
    131  1.1.8.2  simonb 	    bus_space_handle_t hdl);
    132  1.1.8.2  simonb 
    133  1.1.8.2  simonb #endif /* _PREP_PNPBUSVAR_H_ */
    134