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