Home | History | Annotate | Line # | Download | only in pnpbus
pnpbusvar.h revision 1.3
      1 /*	$NetBSD: pnpbusvar.h,v 1.3 2006/06/23 03:08:41 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 };
     94 
     95 /*
     96  * driver attach arguments
     97  */
     98 struct pnpbus_dev_attach_args {
     99 	bus_space_tag_t pna_iot;	/* i/o space tag */
    100 	bus_space_tag_t pna_memt;	/* mem space tag */
    101 	isa_chipset_tag_t pna_ic;	/* ISA chipset tag */
    102 
    103 	struct pnpresources pna_res;	/* resources gathered from PNP */
    104 	char	pna_devid[8];		/* PNP device id string */
    105 	PPC_DEVICE *pna_ppc_dev;	/* PNP device entry */
    106 	void	*pna_aux;		/* driver specific */
    107 	uint8_t	basetype;		/* PNP base type */
    108 	uint8_t subtype;		/* PNP subtype */
    109 	uint8_t interface;		/* PNP interface */
    110 	uint16_t chipid;		/* Chip identifier if any */
    111 	uint8_t	chipmfg0;		/* Chip vendor0 */
    112 	uint8_t chipmfg1;		/* chip vendor1 */
    113 };
    114 
    115 /*
    116  * master bus
    117  */
    118 struct pnpbus_softc {
    119 	struct	device sc_dev;		/* base device */
    120 	isa_chipset_tag_t sc_ic;
    121 
    122 	bus_space_tag_t sc_iot;		/* io space tag */
    123 	bus_space_tag_t sc_memt;	/* mem space tag */
    124 };
    125 
    126 int	pnpbus_scan(struct pnpbus_dev_attach_args *pna, PPC_DEVICE *dev);
    127 void	pnpbus_print_devres(struct pnpbus_dev_attach_args *pna);
    128 void	*pnpbus_intr_establish(int idx, int level, int (*ih_fun)(void *),
    129 	    void *ih_arg, struct pnpresources *r);
    130 void	pnpbus_intr_disestablish(void *arg);
    131 int	pnpbus_getirqnum(struct pnpresources *r, int idx, int *irqp, int *istp);
    132 int	pnpbus_getdmachan(struct pnpresources *r, int idx, int *chanp);
    133 int	pnpbus_getioport(struct pnpresources *r, int idx, int *basep,
    134 	    int *sizep);
    135 int	pnpbus_io_map(struct pnpresources *r, int idx, bus_space_tag_t *tagp,
    136 	    bus_space_handle_t *hdlp);
    137 void	pnpbus_io_unmap(struct pnpresources *r, int idx, bus_space_tag_t tag,
    138 	    bus_space_handle_t hdl);
    139 int	pnpbus_getiomem(struct pnpresources *r, int idx, int *basep,
    140 	    int *sizep);
    141 int	pnpbus_iomem_map(struct pnpresources *r, int idx, bus_space_tag_t *tagp,
    142 	    bus_space_handle_t *hdlp);
    143 void	pnpbus_iomem_unmap(struct pnpresources *r, int idx, bus_space_tag_t tag,
    144 	    bus_space_handle_t hdl);
    145 
    146 #endif /* _PREP_PNPBUSVAR_H_ */
    147