Home | History | Annotate | Line # | Download | only in pnpbus
pnpbusvar.h revision 1.4
      1 /*	$NetBSD: pnpbusvar.h,v 1.4 2006/10/27 19:52:51 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 struct pnpresources {
     77 	int nummem, numiomem, numio, numirq, numdma;
     78 	SIMPLEQ_HEAD(, pnpbus_mem) mem;
     79 	SIMPLEQ_HEAD(, pnpbus_mem) iomem;
     80 	SIMPLEQ_HEAD(, pnpbus_io) io;
     81 	SIMPLEQ_HEAD(, pnpbus_irq) irq;
     82 	SIMPLEQ_HEAD(, pnpbus_dma) dma;
     83 	struct pnpbus_compatid *compatids;
     84 };
     85 
     86 /*
     87  * Bus attach arguments
     88  */
     89 struct pnpbus_attach_args {
     90 	bus_space_tag_t paa_iot;		/* i/o space tag */
     91 	bus_space_tag_t paa_memt;		/* mem space tag */
     92 	isa_chipset_tag_t paa_ic;		/* ISA chipset tag */
     93 	bus_dma_tag_t paa_dmat;			/* ISA DMA tag */
     94 };
     95 
     96 /*
     97  * driver attach arguments
     98  */
     99 struct pnpbus_dev_attach_args {
    100 	bus_space_tag_t pna_iot;	/* i/o space tag */
    101 	bus_space_tag_t pna_memt;	/* mem space tag */
    102 	isa_chipset_tag_t pna_ic;	/* ISA chipset tag */
    103 	bus_dma_tag_t pna_dmat;		/* ISA DMA tag */
    104 
    105 	struct pnpresources pna_res;	/* resources gathered from PNP */
    106 	char	pna_devid[8];		/* PNP device id string */
    107 	PPC_DEVICE *pna_ppc_dev;	/* PNP device entry */
    108 	void	*pna_aux;		/* driver specific */
    109 	uint8_t	basetype;		/* PNP base type */
    110 	uint8_t subtype;		/* PNP subtype */
    111 	uint8_t interface;		/* PNP interface */
    112 	uint16_t chipid;		/* Chip identifier if any */
    113 	uint8_t	chipmfg0;		/* Chip vendor0 */
    114 	uint8_t chipmfg1;		/* chip vendor1 */
    115 };
    116 
    117 /*
    118  * master bus
    119  */
    120 struct pnpbus_softc {
    121 	struct	device sc_dev;		/* base device */
    122 	isa_chipset_tag_t sc_ic;
    123 
    124 	bus_space_tag_t sc_iot;		/* io space tag */
    125 	bus_space_tag_t sc_memt;	/* mem space tag */
    126 	bus_dma_tag_t sc_dmat;		/* ISA DMA tag */
    127 };
    128 
    129 int	pnpbus_scan(struct pnpbus_dev_attach_args *pna, PPC_DEVICE *dev);
    130 void	pnpbus_print_devres(struct pnpbus_dev_attach_args *pna);
    131 void	*pnpbus_intr_establish(int idx, int level, int (*ih_fun)(void *),
    132 	    void *ih_arg, struct pnpresources *r);
    133 void	pnpbus_intr_disestablish(void *arg);
    134 int	pnpbus_getirqnum(struct pnpresources *r, int idx, int *irqp, int *istp);
    135 int	pnpbus_getdmachan(struct pnpresources *r, int idx, int *chanp);
    136 int	pnpbus_getioport(struct pnpresources *r, int idx, int *basep,
    137 	    int *sizep);
    138 int	pnpbus_io_map(struct pnpresources *r, int idx, bus_space_tag_t *tagp,
    139 	    bus_space_handle_t *hdlp);
    140 void	pnpbus_io_unmap(struct pnpresources *r, int idx, bus_space_tag_t tag,
    141 	    bus_space_handle_t hdl);
    142 int	pnpbus_getiomem(struct pnpresources *r, int idx, int *basep,
    143 	    int *sizep);
    144 int	pnpbus_iomem_map(struct pnpresources *r, int idx, bus_space_tag_t *tagp,
    145 	    bus_space_handle_t *hdlp);
    146 void	pnpbus_iomem_unmap(struct pnpresources *r, int idx, bus_space_tag_t tag,
    147 	    bus_space_handle_t hdl);
    148 
    149 #endif /* _PREP_PNPBUSVAR_H_ */
    150