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