FreeBSD/Linux Kernel Cross Reference
sys/dev/acpi/acpivar.h
1 /* $NetBSD: acpivar.h,v 1.15.2.2 2004/04/28 05:25:25 jmc Exp $ */
2
3 /*
4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved.
6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
23 * written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 /*
39 * This file defines the ACPI interface provided to the rest of the
40 * kernel, as well as the autoconfiguration structures for ACPI
41 * support.
42 */
43
44 #include <machine/bus.h>
45 #include <dev/pci/pcivar.h>
46 #include <dev/isa/isavar.h>
47
48 #include <dev/acpi/acpica.h>
49
50 #include <dev/sysmon/sysmonvar.h>
51
52 /*
53 * acpibus_attach_args:
54 *
55 * This structure is used to attach the ACPI "bus".
56 */
57 struct acpibus_attach_args {
58 const char *aa_busname; /* XXX should be common */
59 bus_space_tag_t aa_iot; /* PCI I/O space tag */
60 bus_space_tag_t aa_memt; /* PCI MEM space tag */
61 pci_chipset_tag_t aa_pc; /* PCI chipset */
62 int aa_pciflags; /* PCI bus flags */
63 isa_chipset_tag_t aa_ic; /* ISA chipset */
64 };
65
66 /*
67 * Types of switches that ACPI understands.
68 */
69 #define ACPI_SWITCH_POWERBUTTON 0
70 #define ACPI_SWITCH_SLEEPBUTTON 1
71 #define ACPI_SWITCH_LID 2
72 #define ACPI_NSWITCHES 3
73
74 /*
75 * acpi_devnode:
76 *
77 * An ACPI device node.
78 */
79 struct acpi_devnode {
80 TAILQ_ENTRY(acpi_devnode) ad_list;
81 ACPI_HANDLE ad_handle; /* our ACPI handle */
82 u_int32_t ad_level; /* ACPI level */
83 u_int32_t ad_type; /* ACPI object type */
84 ACPI_DEVICE_INFO *ad_devinfo; /* our ACPI device info */
85 struct acpi_scope *ad_scope; /* backpointer to scope */
86 struct device *ad_device; /* pointer to configured device */
87 };
88
89 /*
90 * acpi_scope:
91 *
92 * Description of an ACPI scope.
93 */
94 struct acpi_scope {
95 TAILQ_ENTRY(acpi_scope) as_list;
96 const char *as_name; /* scope name */
97 /*
98 * Device nodes we manage.
99 */
100 TAILQ_HEAD(, acpi_devnode) as_devnodes;
101 };
102
103 /*
104 * acpi_softc:
105 *
106 * Software state of the ACPI subsystem.
107 */
108 struct acpi_softc {
109 struct device sc_dev; /* base device info */
110 bus_space_tag_t sc_iot; /* PCI I/O space tag */
111 bus_space_tag_t sc_memt; /* PCI MEM space tag */
112 pci_chipset_tag_t sc_pc; /* PCI chipset tag */
113 int sc_pciflags; /* PCI bus flags */
114 int sc_pci_bus; /* internal PCI fixup */
115 isa_chipset_tag_t sc_ic; /* ISA chipset tag */
116
117 void *sc_sdhook; /* shutdown hook */
118
119 /*
120 * Power switch handlers for fixed-feature buttons.
121 */
122 struct sysmon_pswitch sc_smpsw_power;
123 struct sysmon_pswitch sc_smpsw_sleep;
124
125 /*
126 * Sleep state to transition to when a given
127 * switch is activated.
128 */
129 int sc_switch_sleep[ACPI_NSWITCHES];
130
131 int sc_sleepstate; /* current sleep state */
132
133 int sc_quirks;
134
135 /*
136 * Scopes we manage.
137 */
138 TAILQ_HEAD(, acpi_scope) sc_scopes;
139 };
140
141 /*
142 * acpi_attach_args:
143 *
144 * Used to attach a device instance to the acpi "bus".
145 */
146 struct acpi_attach_args {
147 struct acpi_devnode *aa_node; /* ACPI device node */
148 bus_space_tag_t aa_iot; /* PCI I/O space tag */
149 bus_space_tag_t aa_memt; /* PCI MEM space tag */
150 pci_chipset_tag_t aa_pc; /* PCI chipset tag */
151 int aa_pciflags; /* PCI bus flags */
152 isa_chipset_tag_t aa_ic; /* ISA chipset */
153 };
154
155 /*
156 * ACPI resources:
157 *
158 * acpi_io I/O ports
159 * acpi_iorange I/O port range
160 * acpi_mem memory region
161 * acpi_memrange memory range
162 * acpi_irq Interrupt Request
163 * acpi_drq DMA request
164 */
165
166 struct acpi_io {
167 SIMPLEQ_ENTRY(acpi_io) ar_list;
168 int ar_index;
169 uint32_t ar_base;
170 uint32_t ar_length;
171 };
172
173 struct acpi_iorange {
174 SIMPLEQ_ENTRY(acpi_iorange) ar_list;
175 int ar_index;
176 uint32_t ar_low;
177 uint32_t ar_high;
178 uint32_t ar_length;
179 uint32_t ar_align;
180 };
181
182 struct acpi_mem {
183 SIMPLEQ_ENTRY(acpi_mem) ar_list;
184 int ar_index;
185 uint32_t ar_base;
186 uint32_t ar_length;
187 };
188
189 struct acpi_memrange {
190 SIMPLEQ_ENTRY(acpi_memrange) ar_list;
191 int ar_index;
192 uint32_t ar_low;
193 uint32_t ar_high;
194 uint32_t ar_length;
195 uint32_t ar_align;
196 };
197
198 struct acpi_irq {
199 SIMPLEQ_ENTRY(acpi_irq) ar_list;
200 int ar_index;
201 uint32_t ar_irq;
202 uint32_t ar_type;
203 };
204
205 struct acpi_drq {
206 SIMPLEQ_ENTRY(acpi_drq) ar_list;
207 int ar_index;
208 uint32_t ar_drq;
209 };
210
211 struct acpi_resources {
212 SIMPLEQ_HEAD(, acpi_io) ar_io;
213 int ar_nio;
214
215 SIMPLEQ_HEAD(, acpi_iorange) ar_iorange;
216 int ar_niorange;
217
218 SIMPLEQ_HEAD(, acpi_mem) ar_mem;
219 int ar_nmem;
220
221 SIMPLEQ_HEAD(, acpi_memrange) ar_memrange;
222 int ar_nmemrange;
223
224 SIMPLEQ_HEAD(, acpi_irq) ar_irq;
225 int ar_nirq;
226
227 SIMPLEQ_HEAD(, acpi_drq) ar_drq;
228 int ar_ndrq;
229 };
230
231 /*
232 * acpi_resource_parse_ops:
233 *
234 * The client of ACPI resources specifies these operations
235 * when the resources are parsed.
236 */
237 struct acpi_resource_parse_ops {
238 void (*init)(struct device *, void *, void **);
239 void (*fini)(struct device *, void *);
240
241 void (*ioport)(struct device *, void *, uint32_t, uint32_t);
242 void (*iorange)(struct device *, void *, uint32_t, uint32_t,
243 uint32_t, uint32_t);
244
245 void (*memory)(struct device *, void *, uint32_t, uint32_t);
246 void (*memrange)(struct device *, void *, uint32_t, uint32_t,
247 uint32_t, uint32_t);
248
249 void (*irq)(struct device *, void *, uint32_t, uint32_t);
250 void (*drq)(struct device *, void *, uint32_t);
251
252 void (*start_dep)(struct device *, void *, int);
253 void (*end_dep)(struct device *, void *);
254 };
255
256 extern struct acpi_softc *acpi_softc;
257 extern int acpi_active;
258
259 extern const struct acpi_resource_parse_ops acpi_resource_parse_ops_default;
260
261 int acpi_probe(void);
262 int acpi_match_hid(ACPI_DEVICE_INFO *, const char * const *);
263
264 ACPI_STATUS acpi_eval_integer(ACPI_HANDLE, char *, ACPI_INTEGER *);
265 ACPI_STATUS acpi_eval_string(ACPI_HANDLE, char *, char **);
266 ACPI_STATUS acpi_eval_struct(ACPI_HANDLE, char *, ACPI_BUFFER *);
267
268 ACPI_STATUS acpi_get(ACPI_HANDLE, ACPI_BUFFER *,
269 ACPI_STATUS (*)(ACPI_HANDLE, ACPI_BUFFER *));
270
271 ACPI_STATUS acpi_resource_parse(struct device *, struct acpi_devnode *,
272 void *, const struct acpi_resource_parse_ops *);
273 void acpi_resource_print(struct device *, struct acpi_resources *);
274
275 #if defined(_KERNEL_OPT)
276 #include "acpiec.h"
277
278 #if NACPIEC > 0
279 void acpiec_early_attach(struct device *);
280 #endif
281 #else
282 #define NACPIEC 0
283 #endif
284
285 struct acpi_io *acpi_res_io(struct acpi_resources *, int);
286 struct acpi_iorange *acpi_res_iorange(struct acpi_resources *, int);
287 struct acpi_mem *acpi_res_mem(struct acpi_resources *, int);
288 struct acpi_memrange *acpi_res_memrange(struct acpi_resources *, int);
289 struct acpi_irq *acpi_res_irq(struct acpi_resources *, int);
290 struct acpi_drq *acpi_res_drq(struct acpi_resources *, int);
291
292 /*
293 * power state transition
294 */
295 ACPI_STATUS acpi_enter_sleep_state(struct acpi_softc *, int);
296
297 /*
298 * quirk handling
299 */
300 struct acpi_quirk {
301 const char *aq_oemid; /* compared against the X/RSDT OemId */
302 int aq_oemrev; /* compared against the X/RSDT OemRev */
303 int aq_quirks; /* the actual quirks */
304 };
305
306 #define ACPI_QUIRK_BADPCI 0x00000001 /* bad PCI hierarchy */
307 #define ACPI_QUIRK_BADIRQ 0x00000002 /* bad IRQ information */
308
309 int acpi_find_quirks(void);
Cache object: 0880d3f882f2c9a9c031053b715e8465
|