pnpbusvar.h revision 1.1 1 /* $NetBSD: pnpbusvar.h,v 1.1 2006/03/09 20:17:27 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, numio, numirq, numdma;
78 SIMPLEQ_HEAD(, pnpbus_mem) mem;
79 SIMPLEQ_HEAD(, pnpbus_io) io;
80 SIMPLEQ_HEAD(, pnpbus_irq) irq;
81 SIMPLEQ_HEAD(, pnpbus_dma) dma;
82 struct pnpbus_compatid *compatids;
83 };
84
85 /*
86 * Bus attach arguments
87 */
88 struct pnpbus_attach_args {
89 bus_space_tag_t paa_iot; /* i/o space tag */
90 bus_space_tag_t paa_memt; /* mem space tag */
91 isa_chipset_tag_t paa_ic; /* ISA chipset tag */
92 };
93
94 /*
95 * driver attach arguments
96 */
97 struct pnpbus_dev_attach_args {
98 bus_space_tag_t pna_iot; /* i/o space tag */
99 bus_space_tag_t pna_memt; /* mem space tag */
100 isa_chipset_tag_t pna_ic; /* ISA chipset tag */
101
102 struct pnpresources pna_res; /* resources gathered from PNP */
103 char pna_devid[8]; /* PNP device id string */
104 PPC_DEVICE *pna_ppc_dev; /* PNP device entry */
105 void *pna_aux; /* driver specific */
106 };
107
108 /*
109 * master bus
110 */
111 struct pnpbus_softc {
112 struct device sc_dev; /* base device */
113 isa_chipset_tag_t sc_ic;
114
115 bus_space_tag_t sc_iot; /* io space tag */
116 bus_space_tag_t sc_memt; /* mem space tag */
117 };
118
119 int pnpbus_scan(struct pnpbus_dev_attach_args *pna, PPC_DEVICE *dev);
120 void pnpbus_print_devres(struct pnpbus_dev_attach_args *pna);
121 void *pnpbus_intr_establish(int idx, int level, int (*ih_fun)(void *),
122 void *ih_arg, struct pnpresources *r);
123 void pnpbus_intr_disestablish(void *arg);
124 int pnpbus_getirqnum(struct pnpresources *r, int idx, int *irqp, int *istp);
125 int pnpbus_getdmachan(struct pnpresources *r, int idx, int *chanp);
126 int pnpbus_getioport(struct pnpresources *r, int idx, int *basep,
127 int *sizep);
128 int pnpbus_io_map(struct pnpresources *r, int idx, bus_space_tag_t *tagp,
129 bus_space_handle_t *hdlp);
130 void pnpbus_io_unmap(struct pnpresources *r, int idx, bus_space_tag_t tag,
131 bus_space_handle_t hdl);
132
133 #endif /* _PREP_PNPBUSVAR_H_ */
134