Home | History | Annotate | Line # | Download | only in pnpbus
      1  1.8   dyoung /*	$NetBSD: pnpbusvar.h,v 1.8 2011/07/01 16:55:42 dyoung 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  *
     19  1.1  garbled  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1  garbled  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1  garbled  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1  garbled  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1  garbled  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1  garbled  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1  garbled  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1  garbled  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1  garbled  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1  garbled  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1  garbled  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1  garbled  */
     31  1.1  garbled 
     32  1.1  garbled #ifndef _PREP_PNPBUSVAR_H_
     33  1.1  garbled #define _PREP_PNPBUSVAR_H_
     34  1.1  garbled 
     35  1.1  garbled #include <sys/queue.h>
     36  1.8   dyoung #include <sys/bus.h>
     37  1.1  garbled #include <machine/residual.h>
     38  1.1  garbled 
     39  1.1  garbled struct pnpbus_mem {
     40  1.1  garbled 	SIMPLEQ_ENTRY(pnpbus_mem) next;
     41  1.1  garbled 	uint32_t minbase, maxbase, align, len;
     42  1.1  garbled 	int flags;
     43  1.1  garbled };
     44  1.1  garbled struct pnpbus_io {
     45  1.1  garbled 	SIMPLEQ_ENTRY(pnpbus_io) next;
     46  1.1  garbled 	uint16_t minbase, maxbase, align, len;
     47  1.1  garbled 	int flags;
     48  1.1  garbled };
     49  1.1  garbled struct pnpbus_irq {
     50  1.1  garbled 	SIMPLEQ_ENTRY(pnpbus_irq) next;
     51  1.1  garbled 	uint16_t mask;
     52  1.1  garbled 	int flags;
     53  1.1  garbled };
     54  1.1  garbled struct pnpbus_dma {
     55  1.1  garbled 	SIMPLEQ_ENTRY(pnpbus_dma) next;
     56  1.1  garbled 	uint8_t mask;
     57  1.1  garbled 	int flags;
     58  1.1  garbled };
     59  1.1  garbled struct pnpbus_compatid {
     60  1.1  garbled 	char idstr[8];
     61  1.1  garbled 	struct pnpbus_compatid *next;
     62  1.1  garbled };
     63  1.1  garbled 
     64  1.1  garbled #define PNPBUS_MAXMEM 4
     65  1.1  garbled #define PNPBUS_MAXIOPORT 8
     66  1.1  garbled #define PNPBUS_MAXIRQ 2
     67  1.1  garbled #define PNPBUS_MAXDMA 2
     68  1.1  garbled 
     69  1.5  garbled #define IST_PNP	-1
     70  1.5  garbled 
     71  1.1  garbled struct pnpresources {
     72  1.3  garbled 	int nummem, numiomem, numio, numirq, numdma;
     73  1.1  garbled 	SIMPLEQ_HEAD(, pnpbus_mem) mem;
     74  1.3  garbled 	SIMPLEQ_HEAD(, pnpbus_mem) iomem;
     75  1.1  garbled 	SIMPLEQ_HEAD(, pnpbus_io) io;
     76  1.1  garbled 	SIMPLEQ_HEAD(, pnpbus_irq) irq;
     77  1.1  garbled 	SIMPLEQ_HEAD(, pnpbus_dma) dma;
     78  1.1  garbled 	struct pnpbus_compatid *compatids;
     79  1.1  garbled };
     80  1.1  garbled 
     81  1.1  garbled /*
     82  1.1  garbled  * Bus attach arguments
     83  1.1  garbled  */
     84  1.1  garbled struct pnpbus_attach_args {
     85  1.5  garbled 	const char *paa_name;		/* match to struct confargs*/
     86  1.5  garbled 	bus_space_tag_t paa_iot;	/* i/o space tag */
     87  1.5  garbled 	bus_space_tag_t paa_memt;	/* mem space tag */
     88  1.5  garbled 	isa_chipset_tag_t paa_ic;	/* ISA chipset tag */
     89  1.5  garbled 	bus_dma_tag_t paa_dmat;		/* ISA DMA tag */
     90  1.1  garbled };
     91  1.1  garbled 
     92  1.1  garbled /*
     93  1.1  garbled  * driver attach arguments
     94  1.1  garbled  */
     95  1.1  garbled struct pnpbus_dev_attach_args {
     96  1.1  garbled 	bus_space_tag_t pna_iot;	/* i/o space tag */
     97  1.1  garbled 	bus_space_tag_t pna_memt;	/* mem space tag */
     98  1.1  garbled 	isa_chipset_tag_t pna_ic;	/* ISA chipset tag */
     99  1.4  garbled 	bus_dma_tag_t pna_dmat;		/* ISA DMA tag */
    100  1.1  garbled 
    101  1.1  garbled 	struct pnpresources pna_res;	/* resources gathered from PNP */
    102  1.1  garbled 	char	pna_devid[8];		/* PNP device id string */
    103  1.1  garbled 	PPC_DEVICE *pna_ppc_dev;	/* PNP device entry */
    104  1.1  garbled 	void	*pna_aux;		/* driver specific */
    105  1.2  garbled 	uint8_t	basetype;		/* PNP base type */
    106  1.2  garbled 	uint8_t subtype;		/* PNP subtype */
    107  1.2  garbled 	uint8_t interface;		/* PNP interface */
    108  1.3  garbled 	uint16_t chipid;		/* Chip identifier if any */
    109  1.3  garbled 	uint8_t	chipmfg0;		/* Chip vendor0 */
    110  1.3  garbled 	uint8_t chipmfg1;		/* chip vendor1 */
    111  1.1  garbled };
    112  1.1  garbled 
    113  1.1  garbled /*
    114  1.1  garbled  * master bus
    115  1.1  garbled  */
    116  1.1  garbled struct pnpbus_softc {
    117  1.7     matt 	device_t sc_dev;		/* base device */
    118  1.1  garbled 	isa_chipset_tag_t sc_ic;
    119  1.1  garbled 
    120  1.1  garbled 	bus_space_tag_t sc_iot;		/* io space tag */
    121  1.1  garbled 	bus_space_tag_t sc_memt;	/* mem space tag */
    122  1.4  garbled 	bus_dma_tag_t sc_dmat;		/* ISA DMA tag */
    123  1.1  garbled };
    124  1.1  garbled 
    125  1.1  garbled int	pnpbus_scan(struct pnpbus_dev_attach_args *pna, PPC_DEVICE *dev);
    126  1.1  garbled void	pnpbus_print_devres(struct pnpbus_dev_attach_args *pna);
    127  1.5  garbled void	*pnpbus_intr_establish(int idx, int level, int tover,
    128  1.5  garbled 	    int (*ih_fun)(void *), void *ih_arg, struct pnpresources *r);
    129  1.1  garbled void	pnpbus_intr_disestablish(void *arg);
    130  1.1  garbled int	pnpbus_getirqnum(struct pnpresources *r, int idx, int *irqp, int *istp);
    131  1.1  garbled int	pnpbus_getdmachan(struct pnpresources *r, int idx, int *chanp);
    132  1.1  garbled int	pnpbus_getioport(struct pnpresources *r, int idx, int *basep,
    133  1.1  garbled 	    int *sizep);
    134  1.1  garbled int	pnpbus_io_map(struct pnpresources *r, int idx, bus_space_tag_t *tagp,
    135  1.1  garbled 	    bus_space_handle_t *hdlp);
    136  1.1  garbled void	pnpbus_io_unmap(struct pnpresources *r, int idx, bus_space_tag_t tag,
    137  1.1  garbled 	    bus_space_handle_t hdl);
    138  1.3  garbled int	pnpbus_getiomem(struct pnpresources *r, int idx, int *basep,
    139  1.3  garbled 	    int *sizep);
    140  1.3  garbled int	pnpbus_iomem_map(struct pnpresources *r, int idx, bus_space_tag_t *tagp,
    141  1.3  garbled 	    bus_space_handle_t *hdlp);
    142  1.3  garbled void	pnpbus_iomem_unmap(struct pnpresources *r, int idx, bus_space_tag_t tag,
    143  1.3  garbled 	    bus_space_handle_t hdl);
    144  1.1  garbled 
    145  1.1  garbled #endif /* _PREP_PNPBUSVAR_H_ */
    146