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