1 /* $NetBSD: pnpbusvar.h,v 1.5 2008/04/28 19:01:45 garbled Exp $ */
4 * Copyright (c) 2006 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
32 #ifndef _PREP_PNPBUSVAR_H_
33 #define _PREP_PNPBUSVAR_H_
35 #include <sys/queue.h>
36 #include <machine/bus.h>
37 #include <machine/residual.h>
40 SIMPLEQ_ENTRY(pnpbus_mem
) next
;
41 uint32_t minbase
, maxbase
, align
, len
;
45 SIMPLEQ_ENTRY(pnpbus_io
) next
;
46 uint16_t minbase
, maxbase
, align
, len
;
50 SIMPLEQ_ENTRY(pnpbus_irq
) next
;
55 SIMPLEQ_ENTRY(pnpbus_dma
) next
;
59 struct pnpbus_compatid
{
61 struct pnpbus_compatid
*next
;
64 #define PNPBUS_MAXMEM 4
65 #define PNPBUS_MAXIOPORT 8
66 #define PNPBUS_MAXIRQ 2
67 #define PNPBUS_MAXDMA 2
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
;
82 * Bus attach arguments
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 */
93 * driver attach arguments
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 */
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 */
116 struct pnpbus_softc
{
117 struct device sc_dev
; /* base device */
118 isa_chipset_tag_t sc_ic
;
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 */
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
,
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
,
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
);
145 #endif /* _PREP_PNPBUSVAR_H_ */