xref: /titanic_53/usr/src/uts/i86pc/sys/acpidev.h (revision a31148363f598def767ac48c5d82e1572e44b935)
1b72d5b75SMichael Corcoran /*
2b72d5b75SMichael Corcoran  * CDDL HEADER START
3b72d5b75SMichael Corcoran  *
4b72d5b75SMichael Corcoran  * The contents of this file are subject to the terms of the
5b72d5b75SMichael Corcoran  * Common Development and Distribution License (the "License").
6b72d5b75SMichael Corcoran  * You may not use this file except in compliance with the License.
7b72d5b75SMichael Corcoran  *
8b72d5b75SMichael Corcoran  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9b72d5b75SMichael Corcoran  * or http://www.opensolaris.org/os/licensing.
10b72d5b75SMichael Corcoran  * See the License for the specific language governing permissions
11b72d5b75SMichael Corcoran  * and limitations under the License.
12b72d5b75SMichael Corcoran  *
13b72d5b75SMichael Corcoran  * When distributing Covered Code, include this CDDL HEADER in each
14b72d5b75SMichael Corcoran  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15b72d5b75SMichael Corcoran  * If applicable, add the following below this CDDL HEADER, with the
16b72d5b75SMichael Corcoran  * fields enclosed by brackets "[]" replaced with your own identifying
17b72d5b75SMichael Corcoran  * information: Portions Copyright [yyyy] [name of copyright owner]
18b72d5b75SMichael Corcoran  *
19b72d5b75SMichael Corcoran  * CDDL HEADER END
20b72d5b75SMichael Corcoran  */
21b72d5b75SMichael Corcoran /*
22*a3114836SGerry Liu  * Copyright (c) 2009-2010, Intel Corporation.
23b72d5b75SMichael Corcoran  * All rights reserved.
24b72d5b75SMichael Corcoran  */
25b72d5b75SMichael Corcoran 
26b72d5b75SMichael Corcoran #ifndef	_SYS_ACPIDEV_H
27b72d5b75SMichael Corcoran #define	_SYS_ACPIDEV_H
28b72d5b75SMichael Corcoran #include <sys/types.h>
29b72d5b75SMichael Corcoran #include <sys/obpdefs.h>
30b72d5b75SMichael Corcoran #include <sys/sunddi.h>
31*a3114836SGerry Liu #ifdef	_KERNEL
32b72d5b75SMichael Corcoran #include <sys/acpi/acpi.h>
33b72d5b75SMichael Corcoran #include <sys/acpica.h>
34*a3114836SGerry Liu #endif
35b72d5b75SMichael Corcoran 
36b72d5b75SMichael Corcoran #ifdef __cplusplus
37b72d5b75SMichael Corcoran extern "C" {
38b72d5b75SMichael Corcoran #endif
39b72d5b75SMichael Corcoran 
40b72d5b75SMichael Corcoran /* Maximum recursion levels when enumerating objects in ACPI namespace. */
41b72d5b75SMichael Corcoran #define	ACPIDEV_MAX_ENUM_LEVELS		32
42b72d5b75SMichael Corcoran 
43b72d5b75SMichael Corcoran /* Maximum length of device name for ACPI object. */
44b72d5b75SMichael Corcoran #define	ACPIDEV_MAX_NAMELEN		OBP_MAXDRVNAME
45b72d5b75SMichael Corcoran 
46b72d5b75SMichael Corcoran /* Pseudo ACPI device HID for ACPI root object. */
47b72d5b75SMichael Corcoran #define	ACPIDEV_HID_ROOTNEX		"SOLA0001"
48b72d5b75SMichael Corcoran /* Pseudo ACPI device HID for ACPI virtual bus. */
49b72d5b75SMichael Corcoran #define	ACPIDEV_HID_VIRTNEX		"SOLA0002"
50b72d5b75SMichael Corcoran #define	ACPIDEV_HID_SCOPE		"SOLA0003"
51b72d5b75SMichael Corcoran #define	ACPIDEV_HID_PROCESSOR		"SOLA0004"
52b72d5b75SMichael Corcoran 
53b72d5b75SMichael Corcoran /* ACPI device HIDs/CIDs defined by ACPI specification. */
54b72d5b75SMichael Corcoran #define	ACPIDEV_HID_CONTAINER1		"PNP0A05"
55b72d5b75SMichael Corcoran #define	ACPIDEV_HID_CONTAINER2		"PNP0A06"
56b72d5b75SMichael Corcoran #define	ACPIDEV_HID_MODULE		"ACPI0004"
57b72d5b75SMichael Corcoran #define	ACPIDEV_HID_CPU			"ACPI0007"
58b72d5b75SMichael Corcoran #define	ACPIDEV_HID_PCI_HOSTBRIDGE	"PNP0A03"
59b72d5b75SMichael Corcoran #define	ACPIDEV_HID_PCIE_HOSTBRIDGE	"PNP0A08"
60*a3114836SGerry Liu #define	ACPIDEV_HID_PCIEX_HOSTBRIDGE	"PNP0A08"
61b72d5b75SMichael Corcoran #define	ACPIDEV_HID_MEMORY		"PNP0C80"
62b72d5b75SMichael Corcoran 
63b72d5b75SMichael Corcoran /* Device names for ACPI objects. */
64b72d5b75SMichael Corcoran #define	ACPIDEV_NODE_NAME_ROOT		"fw"
65*a3114836SGerry Liu #define	ACPIDEV_NODE_NAME_ACPIDR	"acpidr"
66b72d5b75SMichael Corcoran #define	ACPIDEV_NODE_NAME_CONTAINER	"container"
67b72d5b75SMichael Corcoran #define	ACPIDEV_NODE_NAME_MODULE_SBD	"sb"
68b72d5b75SMichael Corcoran #define	ACPIDEV_NODE_NAME_MODULE_CPU	"socket"
69b72d5b75SMichael Corcoran #define	ACPIDEV_NODE_NAME_CPU		"cpu"
70b72d5b75SMichael Corcoran #define	ACPIDEV_NODE_NAME_PROCESSOR	"cpus"
71b72d5b75SMichael Corcoran #define	ACPIDEV_NODE_NAME_MEMORY	"mem"
72*a3114836SGerry Liu #define	ACPIDEV_NODE_NAME_PCI		"pci"
73b72d5b75SMichael Corcoran 
74b72d5b75SMichael Corcoran /* Device types for ACPI objects. */
75b72d5b75SMichael Corcoran #define	ACPIDEV_TYPE_ROOTNEX		"acpirootnex"
76b72d5b75SMichael Corcoran #define	ACPIDEV_TYPE_VIRTNEX		"acpivirtnex"
77b72d5b75SMichael Corcoran #define	ACPIDEV_TYPE_SCOPE		"acpiscope"
78b72d5b75SMichael Corcoran #define	ACPIDEV_TYPE_DEVICE		"acpidevice"
79b72d5b75SMichael Corcoran #define	ACPIDEV_TYPE_CONTAINER		"acpicontainer"
803b17bf65SMichael Corcoran #define	ACPIDEV_TYPE_CPU		"acpicpu"
81b72d5b75SMichael Corcoran #define	ACPIDEV_TYPE_MEMORY		"acpimemory"
82*a3114836SGerry Liu #define	ACPIDEV_TYPE_PCI		"pci"
83*a3114836SGerry Liu #define	ACPIDEV_TYPE_PCIEX		"pciex"
84b72d5b75SMichael Corcoran 
85b72d5b75SMichael Corcoran /* Device property names for ACPI objects. */
86b72d5b75SMichael Corcoran #define	ACPIDEV_PROP_NAME_UNIT_ADDR	"unit-address"
87b72d5b75SMichael Corcoran #define	ACPIDEV_PROP_NAME_ACPI_UID	"acpi-uid"
88b72d5b75SMichael Corcoran #define	ACPIDEV_PROP_NAME_PROCESSOR_ID	"acpi-processor-id"
89b72d5b75SMichael Corcoran #define	ACPIDEV_PROP_NAME_LOCALAPIC_ID	"apic-id"
90*a3114836SGerry Liu #define	ACPIDEV_PROP_NAME_PROXIMITY_ID	"proximity-id"
91b72d5b75SMichael Corcoran 
92b72d5b75SMichael Corcoran #define	ACPIDEV_PROP_NAME_UID_FORMAT	"acpidev-uid-format"
93b72d5b75SMichael Corcoran 
94*a3114836SGerry Liu /* Miscellaneous strings. */
95*a3114836SGerry Liu #define	ACPIDEV_CMD_OST_PREFIX		"acpi-update-status"
96*a3114836SGerry Liu #define	ACPIDEV_CMD_OST_INPROGRESS	"acpi-update-status=inprogress"
97*a3114836SGerry Liu #define	ACPIDEV_CMD_OST_SUCCESS		"acpi-update-status=success"
98*a3114836SGerry Liu #define	ACPIDEV_CMD_OST_FAILURE		"acpi-update-status=failure"
99*a3114836SGerry Liu #define	ACPIDEV_CMD_OST_NOOP		"acpi-update-status=noop"
100*a3114836SGerry Liu 
101*a3114836SGerry Liu #define	ACPIDEV_EVENT_TYPE_ATTR_NAME	"acpi-event-type"
102*a3114836SGerry Liu #define	ACPIDEV_EVENT_TYPE_BUS_CHECK	"bus_check"
103*a3114836SGerry Liu #define	ACPIDEV_EVENT_TYPE_DEVICE_CHECK	"device_check"
104*a3114836SGerry Liu #define	ACPIDEV_EVENT_TYPE_DEVICE_CHECK_LIGHT	"device_check_light"
105*a3114836SGerry Liu #define	ACPIDEV_EVENT_TYPE_EJECT_REQUEST	"eject_request"
106*a3114836SGerry Liu 
107b72d5b75SMichael Corcoran /* ACPI device class Id. */
108b72d5b75SMichael Corcoran typedef enum acpidev_class_id {
109b72d5b75SMichael Corcoran 	ACPIDEV_CLASS_ID_INVALID = 0,
110b72d5b75SMichael Corcoran 	ACPIDEV_CLASS_ID_ROOTNEX = 1,
111b72d5b75SMichael Corcoran 	ACPIDEV_CLASS_ID_SCOPE = 2,
112b72d5b75SMichael Corcoran 	ACPIDEV_CLASS_ID_DEVICE = 3,
113b72d5b75SMichael Corcoran 	ACPIDEV_CLASS_ID_CONTAINER = 4,
114b72d5b75SMichael Corcoran 	ACPIDEV_CLASS_ID_CPU = 5,
115b72d5b75SMichael Corcoran 	ACPIDEV_CLASS_ID_MEMORY = 6,
116*a3114836SGerry Liu 	ACPIDEV_CLASS_ID_PCI = 7,
117*a3114836SGerry Liu 	ACPIDEV_CLASS_ID_PCIEX = 8,
118b72d5b75SMichael Corcoran 	ACPIDEV_CLASS_ID_MAX
119b72d5b75SMichael Corcoran } acpidev_class_id_t;
120b72d5b75SMichael Corcoran 
121b72d5b75SMichael Corcoran /* Flags for acpidev_options boot options. */
122b72d5b75SMichael Corcoran #define	ACPIDEV_OUSER_NO_CPU		0x1
123b72d5b75SMichael Corcoran #define	ACPIDEV_OUSER_NO_MEM		0x2
124b72d5b75SMichael Corcoran #define	ACPIDEV_OUSER_NO_CONTAINER	0x4
125*a3114836SGerry Liu #define	ACPIDEV_OUSER_NO_PCI		0x8
126*a3114836SGerry Liu #define	ACPIDEV_OUSER_NO_CACHE		0x10000
127b72d5b75SMichael Corcoran 
128b72d5b75SMichael Corcoran #ifdef	_KERNEL
129b72d5b75SMichael Corcoran 
130*a3114836SGerry Liu /* Common ACPI object names. */
131*a3114836SGerry Liu #define	ACPIDEV_OBJECT_NAME_SB		ACPI_NS_SYSTEM_BUS
132*a3114836SGerry Liu #define	ACPIDEV_OBJECT_NAME_PR		"_PR_"
133*a3114836SGerry Liu 
134*a3114836SGerry Liu /* Common ACPI method names. */
135*a3114836SGerry Liu #define	ACPIDEV_METHOD_NAME_MAT		"_MAT"
136*a3114836SGerry Liu #define	ACPIDEV_METHOD_NAME_EJ0		"_EJ0"
137*a3114836SGerry Liu #define	ACPIDEV_METHOD_NAME_EDL		"_EDL"
138*a3114836SGerry Liu #define	ACPIDEV_METHOD_NAME_EJD		"_EJD"
139*a3114836SGerry Liu #define	ACPIDEV_METHOD_NAME_OST		"_OST"
140*a3114836SGerry Liu #define	ACPIDEV_METHOD_NAME_PXM		"_PXM"
141*a3114836SGerry Liu #define	ACPIDEV_METHOD_NAME_SLI		"_SLI"
142*a3114836SGerry Liu 
143*a3114836SGerry Liu /* Source event code for _OST. */
144*a3114836SGerry Liu #define	ACPI_OST_EVENT_EJECTING		0x103
145*a3114836SGerry Liu #define	ACPI_OST_EVENT_INSERTING	0x200
146*a3114836SGerry Liu 
147*a3114836SGerry Liu /* Status code for _OST. */
148*a3114836SGerry Liu #define	ACPI_OST_STA_SUCCESS		0x0
149*a3114836SGerry Liu 
150*a3114836SGerry Liu /* Non-specific failure. */
151*a3114836SGerry Liu #define	ACPI_OST_STA_FAILURE		0x1
152*a3114836SGerry Liu 
153*a3114836SGerry Liu /* Unrecognized Notify Code. */
154*a3114836SGerry Liu #define	ACPI_OST_STA_NOT_SUPPORT	0x2
155*a3114836SGerry Liu 
156*a3114836SGerry Liu /* Device ejection not supported by OSPM. */
157*a3114836SGerry Liu #define	ACPI_OST_STA_EJECT_NOT_SUPPORT	0x80
158*a3114836SGerry Liu 
159*a3114836SGerry Liu /* Device in use by application. */
160*a3114836SGerry Liu #define	ACPI_OST_STA_EJECT_IN_USE	0x81
161*a3114836SGerry Liu 
162*a3114836SGerry Liu /* Device Busy. */
163*a3114836SGerry Liu #define	ACPI_OST_STA_EJECT_BUSY		0x82
164*a3114836SGerry Liu 
165*a3114836SGerry Liu /* Ejection dependency is busy or not supported for ejection by OSPM. */
166*a3114836SGerry Liu #define	ACPI_OST_STA_EJECT_DEPENDENCY	0x83
167*a3114836SGerry Liu 
168*a3114836SGerry Liu /* Ejection is in progress (pending). */
169*a3114836SGerry Liu #define	ACPI_OST_STA_EJECT_IN_PROGRESS	0x84
170*a3114836SGerry Liu 
171*a3114836SGerry Liu /* Device insertion in progress (pending). */
172*a3114836SGerry Liu #define	ACPI_OST_STA_INSERT_IN_PROGRESS	0x80
173*a3114836SGerry Liu 
174*a3114836SGerry Liu /* Device driver load failure. */
175*a3114836SGerry Liu #define	ACPI_OST_STA_INSERT_DRIVER	0x81
176*a3114836SGerry Liu 
177*a3114836SGerry Liu /* Device insertion not supported by OSPM. */
178*a3114836SGerry Liu #define	ACPI_OST_STA_INSERT_NOT_SUPPORT	0x82
179*a3114836SGerry Liu 
180*a3114836SGerry Liu /*
181*a3114836SGerry Liu  * Insertion failure
182*a3114836SGerry Liu  * Resources Unavailable as described by the following bit encodings:
183*a3114836SGerry Liu  * Bit[3] Bus Numbers
184*a3114836SGerry Liu  * Bit[2] Interrupts
185*a3114836SGerry Liu  * Bit[1] I/O
186*a3114836SGerry Liu  * Bit[0] Memory
187*a3114836SGerry Liu  */
188*a3114836SGerry Liu #define	ACPI_OST_STA_INSERT_NO_RESOURCE	0x90
189*a3114836SGerry Liu #define	ACPI_OST_STA_INSERT_NO_BUS	0x8
190*a3114836SGerry Liu #define	ACPI_OST_STA_INSERT_NO_INTR	0x4
191*a3114836SGerry Liu #define	ACPI_OST_STA_INSERT_NO_IO	0x2
192*a3114836SGerry Liu #define	ACPI_OST_STA_INSERT_NO_MEM	0x1
193*a3114836SGerry Liu 
194*a3114836SGerry Liu /*
195*a3114836SGerry Liu  * According to the ACPI specification, self latency (entry[n][n]) in the
196*a3114836SGerry Liu  * SLIT table should be 10.
197*a3114836SGerry Liu  */
198*a3114836SGerry Liu #define	ACPI_SLIT_SELF_LATENCY		10
199*a3114836SGerry Liu 
200*a3114836SGerry Liu /*
201*a3114836SGerry Liu  * The DR driver assigns a unique device id for each hot-added memory device.
202*a3114836SGerry Liu  * ACPI_MEMNODE_DEVID_BOOT is assigned to memory devices present at boot,
203*a3114836SGerry Liu  * which is distinguished from device ids assigned by the DR driver.
204*a3114836SGerry Liu  */
205*a3114836SGerry Liu #define	ACPI_MEMNODE_DEVID_BOOT		UINT32_MAX
206*a3114836SGerry Liu 
207b72d5b75SMichael Corcoran /* Forward declaration */
208b72d5b75SMichael Corcoran typedef	struct acpidev_data_impl	*acpidev_data_handle_t;
209b72d5b75SMichael Corcoran typedef struct acpidev_walk_info	acpidev_walk_info_t;
210b72d5b75SMichael Corcoran typedef struct acpidev_filter_rule	acpidev_filter_rule_t;
211b72d5b75SMichael Corcoran typedef struct acpidev_class		acpidev_class_t;
212b72d5b75SMichael Corcoran typedef struct acpidev_class_list	acpidev_class_list_t;
213b72d5b75SMichael Corcoran 
214b72d5b75SMichael Corcoran /* Type of ACPI device enumerating operation. */
215b72d5b75SMichael Corcoran typedef enum acpidev_op_type {
216b72d5b75SMichael Corcoran 	ACPIDEV_OP_BOOT_PROBE = 0,	/* First pass probing at boot time. */
217b72d5b75SMichael Corcoran 	ACPIDEV_OP_BOOT_REPROBE,	/* Second pass probing at boot time. */
218b72d5b75SMichael Corcoran 	ACPIDEV_OP_HOTPLUG_PROBE	/* Probing for hotplug at runtime. */
219b72d5b75SMichael Corcoran } acpidev_op_type_t;
220b72d5b75SMichael Corcoran 
221b72d5b75SMichael Corcoran /*
222b72d5b75SMichael Corcoran  * Structure to pass arguments when enumerating ACPI namespace.
223b72d5b75SMichael Corcoran  */
224b72d5b75SMichael Corcoran struct acpidev_walk_info {
225b72d5b75SMichael Corcoran 	/* Always valid for all callbacks. */
226b72d5b75SMichael Corcoran 	acpidev_op_type_t		awi_op_type;
227b72d5b75SMichael Corcoran 	int				awi_level;
228b72d5b75SMichael Corcoran 	acpidev_walk_info_t		*awi_parent;
229b72d5b75SMichael Corcoran 	acpidev_class_t			*awi_class_curr;
230b72d5b75SMichael Corcoran 
231b72d5b75SMichael Corcoran 	/* Valid for all callbacks except pre_probe and post_probe. */
232b72d5b75SMichael Corcoran 	int				awi_flags;
233b72d5b75SMichael Corcoran 	ACPI_HANDLE			awi_hdl;
234b72d5b75SMichael Corcoran 	ACPI_DEVICE_INFO		*awi_info;
235b72d5b75SMichael Corcoran 	char				*awi_name;
236b72d5b75SMichael Corcoran 	acpidev_data_handle_t		awi_data;
237b72d5b75SMichael Corcoran 
238b72d5b75SMichael Corcoran 	/* Need to validate it before access. */
239b72d5b75SMichael Corcoran 	dev_info_t			*awi_dip;
240b72d5b75SMichael Corcoran 	acpidev_class_list_t		**awi_class_list;
241b72d5b75SMichael Corcoran 
242b72d5b75SMichael Corcoran 	/* Used by class to store data temporarily. */
243b72d5b75SMichael Corcoran 	intptr_t			awi_scratchpad[4];
244b72d5b75SMichael Corcoran };
245b72d5b75SMichael Corcoran 
246b72d5b75SMichael Corcoran /* Disable creating device nodes for ACPI objects. */
247b72d5b75SMichael Corcoran #define	ACPIDEV_WI_DISABLE_CREATE	0x1
248b72d5b75SMichael Corcoran /* Device node has already been created for an ACPI object. */
249b72d5b75SMichael Corcoran #define	ACPIDEV_WI_DEVICE_CREATED	0x2
250b72d5b75SMichael Corcoran /* Disable enumerating children of ACPI objects. */
251b72d5b75SMichael Corcoran #define	ACPIDEV_WI_DISABLE_SCAN		0x10
252b72d5b75SMichael Corcoran /* Children of ACPI objects have already been enumerated. */
253b72d5b75SMichael Corcoran #define	ACPIDEV_WI_CHILD_SCANNED	0x20
254b72d5b75SMichael Corcoran 
255b72d5b75SMichael Corcoran /*
256b72d5b75SMichael Corcoran  * Device filtering result code.
257b72d5b75SMichael Corcoran  * Device filtering logic will be applied to determine how to handle ACPI
258b72d5b75SMichael Corcoran  * objects according to the filtering result code when enumerating ACPI objects.
259b72d5b75SMichael Corcoran  */
260b72d5b75SMichael Corcoran typedef enum acpidev_filter_result {
261b72d5b75SMichael Corcoran 	ACPIDEV_FILTER_FAILED = -1,	/* operation failed */
262b72d5b75SMichael Corcoran 	ACPIDEV_FILTER_CONTINUE = 0,	/* continue to evaluate filter rules */
263b72d5b75SMichael Corcoran 	ACPIDEV_FILTER_DEFAULT,		/* create node and scan child */
264b72d5b75SMichael Corcoran 	ACPIDEV_FILTER_SCAN,		/* scan child of current node only */
265b72d5b75SMichael Corcoran 	ACPIDEV_FILTER_CREATE,		/* create device node only */
266b72d5b75SMichael Corcoran 	ACPIDEV_FILTER_SKIP,		/* skip current node */
267b72d5b75SMichael Corcoran } acpidev_filter_result_t;
268b72d5b75SMichael Corcoran 
269b72d5b75SMichael Corcoran typedef acpidev_filter_result_t (* acpidev_filter_func_t)(acpidev_walk_info_t *,
270b72d5b75SMichael Corcoran     ACPI_HANDLE, acpidev_filter_rule_t *, char *, int);
271b72d5b75SMichael Corcoran 
272b72d5b75SMichael Corcoran /*
273b72d5b75SMichael Corcoran  * Device filter rule data structure.
274b72d5b75SMichael Corcoran  * User provided callback will be called if adf_filter_func is not NULL,
275b72d5b75SMichael Corcoran  * otherwise default filtering algorithm will be applied.
276b72d5b75SMichael Corcoran  */
277b72d5b75SMichael Corcoran struct acpidev_filter_rule {
278b72d5b75SMichael Corcoran 	acpidev_filter_func_t		adf_filter_func;
279b72d5b75SMichael Corcoran 	intptr_t			adf_filter_arg;
280b72d5b75SMichael Corcoran 	acpidev_filter_result_t		adf_retcode;
281b72d5b75SMichael Corcoran 	acpidev_class_list_t		**adf_class_list;
282b72d5b75SMichael Corcoran 	intptr_t			adf_minlvl;
283b72d5b75SMichael Corcoran 	intptr_t			adf_maxlvl;
284b72d5b75SMichael Corcoran 	char				*adf_pattern;
285b72d5b75SMichael Corcoran 	char				*adf_replace;
286b72d5b75SMichael Corcoran };
287b72d5b75SMichael Corcoran 
288b72d5b75SMichael Corcoran /* Callback function prototypes for ACPI device class driver. */
289b72d5b75SMichael Corcoran typedef ACPI_STATUS (* acpidev_pre_probe_t)(acpidev_walk_info_t *);
290b72d5b75SMichael Corcoran typedef ACPI_STATUS (* acpidev_post_probe_t)(acpidev_walk_info_t *);
291b72d5b75SMichael Corcoran typedef ACPI_STATUS (* acpidev_probe_t)(acpidev_walk_info_t *);
292b72d5b75SMichael Corcoran typedef acpidev_filter_result_t (* acpidev_filter_t)(acpidev_walk_info_t *,
293b72d5b75SMichael Corcoran     char *, int);
294b72d5b75SMichael Corcoran typedef ACPI_STATUS (* acpidev_init_t)(acpidev_walk_info_t *);
295*a3114836SGerry Liu typedef void (* acpidev_fini_t)(ACPI_HANDLE, acpidev_data_handle_t,
296b72d5b75SMichael Corcoran     acpidev_class_t *);
297b72d5b75SMichael Corcoran 
298b72d5b75SMichael Corcoran /* Device class driver interface. */
299b72d5b75SMichael Corcoran struct acpidev_class {
300b72d5b75SMichael Corcoran 	volatile uint32_t		adc_refcnt;
301b72d5b75SMichael Corcoran 	int				adc_version;
302b72d5b75SMichael Corcoran 	acpidev_class_id_t		adc_class_id;
303b72d5b75SMichael Corcoran 	/* Name of device class, used in log messages. */
304b72d5b75SMichael Corcoran 	char				*adc_class_name;
305b72d5b75SMichael Corcoran 	/* Used as "device_type" property. */
306b72d5b75SMichael Corcoran 	char				*adc_dev_type;
307b72d5b75SMichael Corcoran 	/* Private storage for device driver. */
308b72d5b75SMichael Corcoran 	void				*adc_private;
309b72d5b75SMichael Corcoran 	/* Callback to setup environment before probing child objects. */
310b72d5b75SMichael Corcoran 	acpidev_pre_probe_t		adc_pre_probe;
311b72d5b75SMichael Corcoran 	/* Callback to clean environment after probing child objects. */
312b72d5b75SMichael Corcoran 	acpidev_post_probe_t		adc_post_probe;
313b72d5b75SMichael Corcoran 	/* Callback to probe child objects. */
314b72d5b75SMichael Corcoran 	acpidev_probe_t			adc_probe;
315b72d5b75SMichael Corcoran 	/* Callback to figure out policy to handle objects. */
316b72d5b75SMichael Corcoran 	acpidev_filter_t		adc_filter;
317b72d5b75SMichael Corcoran 	/* Callback to set device class specific device properties. */
318b72d5b75SMichael Corcoran 	acpidev_init_t			adc_init;
319b72d5b75SMichael Corcoran 	/* Callback to clean up resources when destroying device nodes. */
320b72d5b75SMichael Corcoran 	acpidev_fini_t			adc_fini;
321b72d5b75SMichael Corcoran };
322b72d5b75SMichael Corcoran 
323b72d5b75SMichael Corcoran /* Versions of the ACPI device class driver data structure. */
324b72d5b75SMichael Corcoran #define	ACPIDEV_CLASS_REV1		1
325b72d5b75SMichael Corcoran #define	ACPIDEV_CLASS_REV		ACPIDEV_CLASS_REV1
326b72d5b75SMichael Corcoran 
327b72d5b75SMichael Corcoran /*
328b72d5b75SMichael Corcoran  * Class drivers.
329b72d5b75SMichael Corcoran  */
330b72d5b75SMichael Corcoran extern acpidev_class_t			acpidev_class_scope;
331b72d5b75SMichael Corcoran extern acpidev_class_t			acpidev_class_device;
332b72d5b75SMichael Corcoran extern acpidev_class_t			acpidev_class_container;
333b72d5b75SMichael Corcoran extern acpidev_class_t			acpidev_class_cpu;
334b72d5b75SMichael Corcoran extern acpidev_class_t			acpidev_class_memory;
335*a3114836SGerry Liu extern acpidev_class_t			acpidev_class_pci;
336b72d5b75SMichael Corcoran 
337b72d5b75SMichael Corcoran /*
338b72d5b75SMichael Corcoran  * Class driver lists.
339b72d5b75SMichael Corcoran  */
340b72d5b75SMichael Corcoran extern acpidev_class_list_t		*acpidev_class_list_root;
341b72d5b75SMichael Corcoran extern acpidev_class_list_t		*acpidev_class_list_scope;
342b72d5b75SMichael Corcoran extern acpidev_class_list_t		*acpidev_class_list_device;
343b72d5b75SMichael Corcoran extern acpidev_class_list_t		*acpidev_class_list_cpu;
344b72d5b75SMichael Corcoran extern acpidev_class_list_t		*acpidev_class_list_memory;
345b72d5b75SMichael Corcoran 
346b72d5b75SMichael Corcoran /*
347b72d5b75SMichael Corcoran  * Register a device class driver onto a driver list. All class drivers on the
348b72d5b75SMichael Corcoran  * same list will be called in order when processing an ACPI object.
349b72d5b75SMichael Corcoran  * This interface can be used to support machine/platform specific object
350b72d5b75SMichael Corcoran  * handling by registering special plug-in class drivers to override system
351b72d5b75SMichael Corcoran  * default behaviors.
352b72d5b75SMichael Corcoran  * listpp:	pointer to driver list header
353b72d5b75SMichael Corcoran  * clsp:	device class driver to register
354b72d5b75SMichael Corcoran  * tail:	insert at tail of list if true
355b72d5b75SMichael Corcoran  * Return values:
356b72d5b75SMichael Corcoran  *	AE_OK: success
357b72d5b75SMichael Corcoran  *	AE_BAD_PARAMETER: invalid parameter
358b72d5b75SMichael Corcoran  *	AE_BAD_DATA: driver version mismatch
359b72d5b75SMichael Corcoran  *	AE_ALREADY_EXISTS: class driver already exists on the list
360b72d5b75SMichael Corcoran  */
361b72d5b75SMichael Corcoran extern ACPI_STATUS acpidev_register_class(acpidev_class_list_t **listpp,
362b72d5b75SMichael Corcoran     acpidev_class_t *clsp, boolean_t tail);
363b72d5b75SMichael Corcoran 
364b72d5b75SMichael Corcoran /*
365b72d5b75SMichael Corcoran  * Unregister a device class driver from a driver list.
366b72d5b75SMichael Corcoran  * listpp: pointer to driver list header
367b72d5b75SMichael Corcoran  * clsp: device class driver to unregister
368b72d5b75SMichael Corcoran  * Return values:
369b72d5b75SMichael Corcoran  *	AE_OK: success
370b72d5b75SMichael Corcoran  *	AE_BAD_PARAMETER: invalid parameter
371b72d5b75SMichael Corcoran  *	AE_NOT_FOUND: class driver doesn't exist in list
372b72d5b75SMichael Corcoran  *	AE_ERROR: class driver is still in use.
373b72d5b75SMichael Corcoran  */
374b72d5b75SMichael Corcoran extern ACPI_STATUS acpidev_unregister_class(acpidev_class_list_t **listpp,
375b72d5b75SMichael Corcoran     acpidev_class_t *clsp);
376b72d5b75SMichael Corcoran 
377b72d5b75SMichael Corcoran /*
378b72d5b75SMichael Corcoran  * Recursively enumerate child objects of an ACPI object.
379b72d5b75SMichael Corcoran  * It does following things in turn:
380b72d5b75SMichael Corcoran  * 1) Call pre_probe callback for each registered handler
381b72d5b75SMichael Corcoran  * 2) Enumerate child objects and call probe callbacks for each object
382b72d5b75SMichael Corcoran  * 3) Call post_probe callback for each registered handler
383b72d5b75SMichael Corcoran  * Return AE_OK on success and error code on failure.
384b72d5b75SMichael Corcoran  */
385b72d5b75SMichael Corcoran extern ACPI_STATUS acpidev_probe_child(acpidev_walk_info_t *infop);
386b72d5b75SMichael Corcoran 
387b72d5b75SMichael Corcoran /*
388b72d5b75SMichael Corcoran  * Default handler to process ACPI objects.
389b72d5b75SMichael Corcoran  * It creates a device node for an ACPI object and scans all child objects on
390b72d5b75SMichael Corcoran  * demand.
391b72d5b75SMichael Corcoran  * Return values:
392b72d5b75SMichael Corcoran  * AE_OK: on success
393b72d5b75SMichael Corcoran  * AE_NOT_EXIST: device doesn't exist according to _STA value.
394b72d5b75SMichael Corcoran  * AE_ALREADY_EXISTS: object already handled by other handler.
395b72d5b75SMichael Corcoran  * AE_ERROR: on other failure
396b72d5b75SMichael Corcoran  */
397b72d5b75SMichael Corcoran extern ACPI_STATUS acpidev_process_object(acpidev_walk_info_t *infop,
398b72d5b75SMichael Corcoran     int flags);
399b72d5b75SMichael Corcoran 
400b72d5b75SMichael Corcoran /* Flags for acpidev_process_device() */
401b72d5b75SMichael Corcoran #define	ACPIDEV_PROCESS_FLAG_CREATE	0x1	/* Create device */
402b72d5b75SMichael Corcoran #define	ACPIDEV_PROCESS_FLAG_SCAN	0x2	/* Scan child objects */
403b72d5b75SMichael Corcoran #define	ACPIDEV_PROCESS_FLAG_CHECK	0x100	/* Check status */
404b72d5b75SMichael Corcoran #define	ACPIDEV_PROCESS_FLAG_NOBIND	0x200	/* Skip binding driver */
405b72d5b75SMichael Corcoran #define	ACPIDEV_PROCESS_FLAG_OFFLINE	0x400	/* Put device into offline. */
406b72d5b75SMichael Corcoran #define	ACPIDEV_PROCESS_FLAG_NOTAG	0x800	/* Skip tag dip with object. */
407b72d5b75SMichael Corcoran #define	ACPIDEV_PROCESS_FLAG_SYNCSTATUS	0x1000	/* Sync object status. */
408*a3114836SGerry Liu #define	ACPIDEV_PROCESS_FLAG_HOLDBRANCH	0x10000	/* Hold device branch. */
409b72d5b75SMichael Corcoran 
410b72d5b75SMichael Corcoran /*
411b72d5b75SMichael Corcoran  * Filter ACPI objects according to filter rules, generate devname if needed.
412b72d5b75SMichael Corcoran  * infop:	pointer to walker information structure
413b72d5b75SMichael Corcoran  * hdl:		handle of ACPI object in question
414b72d5b75SMichael Corcoran  * afrp:	pointer to filter rule array
415b72d5b75SMichael Corcoran  * entries:	number of filter rules in array
416b72d5b75SMichael Corcoran  * devname:	buffer to store generated device name
417b72d5b75SMichael Corcoran  * len:		sizeof devname buffer
418b72d5b75SMichael Corcoran  */
419b72d5b75SMichael Corcoran extern acpidev_filter_result_t acpidev_filter_device(acpidev_walk_info_t *infop,
420b72d5b75SMichael Corcoran     ACPI_HANDLE hdl, acpidev_filter_rule_t *afrp, int entries,
421b72d5b75SMichael Corcoran     char *devname, int len);
422b72d5b75SMichael Corcoran 
423b72d5b75SMichael Corcoran /* Default object filtering algorithm. */
424b72d5b75SMichael Corcoran extern acpidev_filter_result_t acpidev_filter_default(
425b72d5b75SMichael Corcoran     acpidev_walk_info_t *infop, ACPI_HANDLE hdl, acpidev_filter_rule_t *afrp,
426b72d5b75SMichael Corcoran     char *devname, int len);
427b72d5b75SMichael Corcoran 
428b72d5b75SMichael Corcoran /* Utility routines */
429b72d5b75SMichael Corcoran extern dev_info_t *acpidev_root_node(void);
430b72d5b75SMichael Corcoran extern char *acpidev_get_object_name(ACPI_HANDLE hdl);
431b72d5b75SMichael Corcoran extern void acpidev_free_object_name(char *objname);
432b72d5b75SMichael Corcoran 
433b72d5b75SMichael Corcoran extern acpidev_walk_info_t *acpidev_alloc_walk_info(acpidev_op_type_t op_type,
434b72d5b75SMichael Corcoran     int lvl, ACPI_HANDLE hdl, acpidev_class_list_t **listpp,
435b72d5b75SMichael Corcoran     acpidev_walk_info_t *pinfop);
436b72d5b75SMichael Corcoran extern void acpidev_free_walk_info(acpidev_walk_info_t *infop);
437b72d5b75SMichael Corcoran extern dev_info_t *acpidev_walk_info_get_pdip(acpidev_walk_info_t *infop);
438b72d5b75SMichael Corcoran 
439b72d5b75SMichael Corcoran /* Interfaces to access data associated with ACPI object. */
440b72d5b75SMichael Corcoran extern acpidev_data_handle_t acpidev_data_get_handle(ACPI_HANDLE hdl);
441b72d5b75SMichael Corcoran extern acpidev_data_handle_t acpidev_data_create_handle(ACPI_HANDLE hdl);
442b72d5b75SMichael Corcoran extern void acpidev_data_destroy_handle(ACPI_HANDLE hdl);
443b72d5b75SMichael Corcoran extern ACPI_HANDLE acpidev_data_get_object(acpidev_data_handle_t hdl);
444b72d5b75SMichael Corcoran extern dev_info_t *acpidev_data_get_devinfo(acpidev_data_handle_t hdl);
445b72d5b75SMichael Corcoran extern int acpidev_data_get_status(acpidev_data_handle_t hdl);
446*a3114836SGerry Liu extern boolean_t acpidev_data_dr_capable(acpidev_data_handle_t hdl);
447*a3114836SGerry Liu extern boolean_t acpidev_data_dr_ready(acpidev_data_handle_t hdl);
448*a3114836SGerry Liu extern boolean_t acpidev_data_dr_failed(acpidev_data_handle_t hdl);
449b72d5b75SMichael Corcoran extern void acpidev_data_set_flag(acpidev_data_handle_t hdl, uint32_t flag);
450b72d5b75SMichael Corcoran extern void acpidev_data_clear_flag(acpidev_data_handle_t hdl, uint32_t flag);
451b72d5b75SMichael Corcoran extern uint32_t acpidev_data_get_flag(acpidev_data_handle_t hdl, uint32_t flag);
452b72d5b75SMichael Corcoran 
453*a3114836SGerry Liu /* ACPI system event handler has been registered. */
454*a3114836SGerry Liu #define	ACPIDEV_DATA_HANDLER_READY	0x1
455*a3114836SGerry Liu 
456b72d5b75SMichael Corcoran /*
457b72d5b75SMichael Corcoran  * Try to generate meaningful device unit address from uid.
458b72d5b75SMichael Corcoran  * Return buf on success and NULL on failure.
459b72d5b75SMichael Corcoran  */
460b72d5b75SMichael Corcoran extern char *acpidev_generate_unitaddr(char *uid, char **fmts, size_t nfmt,
461b72d5b75SMichael Corcoran     char *buf, size_t len);
462b72d5b75SMichael Corcoran 
463b72d5b75SMichael Corcoran /*
464b72d5b75SMichael Corcoran  * Set device unit address property if _UID is available or unitaddr is valid.
465b72d5b75SMichael Corcoran  * Return AE_OK on success and error code on failure.
466b72d5b75SMichael Corcoran  * N.B.: it returns AE_OK if _UID is unavailable and unitaddr is NULL.
467b72d5b75SMichael Corcoran  */
468b72d5b75SMichael Corcoran extern ACPI_STATUS acpidev_set_unitaddr(acpidev_walk_info_t *infop,
469b72d5b75SMichael Corcoran     char **fmts, size_t nfmt, char *unitaddr);
470b72d5b75SMichael Corcoran 
471b72d5b75SMichael Corcoran /*
472b72d5b75SMichael Corcoran  * Generate the device 'compatible' property list for a device based on:
473b72d5b75SMichael Corcoran  *	* Device HID if available
474b72d5b75SMichael Corcoran  *	* Device CIDs if available
475b72d5b75SMichael Corcoran  *	* property array passed in
476b72d5b75SMichael Corcoran  * infop:	pointer to walk information structure
477b72d5b75SMichael Corcoran  * compat:	pointer to property array
478b72d5b75SMichael Corcoran  * acount:	entries in property array
479b72d5b75SMichael Corcoran  * Return AE_OK on success and error code on failure.
480b72d5b75SMichael Corcoran  */
481b72d5b75SMichael Corcoran extern ACPI_STATUS acpidev_set_compatible(acpidev_walk_info_t *infop,
482b72d5b75SMichael Corcoran     char **compat, int acount);
483b72d5b75SMichael Corcoran 
484b72d5b75SMichael Corcoran /*
485b72d5b75SMichael Corcoran  * Query ACPI device status.
486b72d5b75SMichael Corcoran  * N.B.: it returns with all status bits set if _STA is not available.
487b72d5b75SMichael Corcoran  */
488b72d5b75SMichael Corcoran extern int acpidev_query_device_status(ACPI_HANDLE hdl);
489b72d5b75SMichael Corcoran 
490b72d5b75SMichael Corcoran /*
491b72d5b75SMichael Corcoran  * Check whether device exists.
492b72d5b75SMichael Corcoran  * Return false if device doesn't exist.
493b72d5b75SMichael Corcoran  */
494b72d5b75SMichael Corcoran extern boolean_t acpidev_check_device_present(int status);
495b72d5b75SMichael Corcoran 
496b72d5b75SMichael Corcoran /*
497b72d5b75SMichael Corcoran  * Check whether device is enabled.
498b72d5b75SMichael Corcoran  * Return false if device doesn't exist or hasn't been enabled.
499b72d5b75SMichael Corcoran  */
500b72d5b75SMichael Corcoran extern boolean_t acpidev_check_device_enabled(int status);
501b72d5b75SMichael Corcoran 
502b72d5b75SMichael Corcoran /*
503b72d5b75SMichael Corcoran  * Match device ids with ACPI object's _HID and _CIDs.
504b72d5b75SMichael Corcoran  * infop: ACPI object information structure
505b72d5b75SMichael Corcoran  * ids: array of ACPI HIDs and CIDs
506b72d5b75SMichael Corcoran  * count: entries in array
507b72d5b75SMichael Corcoran  * Return TRUE if one item matches or num is zero, else FALSE.
508b72d5b75SMichael Corcoran  */
509b72d5b75SMichael Corcoran extern boolean_t acpidev_match_device_id(ACPI_DEVICE_INFO *infop,
510b72d5b75SMichael Corcoran     char **ids, int count);
511b72d5b75SMichael Corcoran 
512b72d5b75SMichael Corcoran /*
513b72d5b75SMichael Corcoran  * Implement almost the same function as AcpiGetDevices() with the following
514b72d5b75SMichael Corcoran  * changes/enhancements:
515b72d5b75SMichael Corcoran  * 1) Support limiting recursive levels.
516b72d5b75SMichael Corcoran  * 2) Support matching multiple ids instead of one.
517b72d5b75SMichael Corcoran  * 3) Report device without ACPI_STA_DEVICE_PRESENT flag which will be ignored
518b72d5b75SMichael Corcoran  *    by AcpiGetDevices().
519b72d5b75SMichael Corcoran  */
520b72d5b75SMichael Corcoran extern ACPI_STATUS acpidev_get_device_by_id(ACPI_HANDLE hdl,
521b72d5b75SMichael Corcoran     char **ids, int count, int maxdepth, boolean_t skip_non_exist,
522b72d5b75SMichael Corcoran     ACPI_WALK_CALLBACK userfunc, void *userarg, void** retval);
523b72d5b75SMichael Corcoran 
524b72d5b75SMichael Corcoran /* Callback for APIC entry walker. */
525b72d5b75SMichael Corcoran typedef ACPI_STATUS (* acpidev_apic_walker_t)(ACPI_SUBTABLE_HEADER *, void *);
526b72d5b75SMichael Corcoran 
527b72d5b75SMichael Corcoran /*
528b72d5b75SMichael Corcoran  * Walk ACPI APIC entries from the first source available in following order:
529b72d5b75SMichael Corcoran  * 1) ACPI buffer passed in if bufp isn't NULL.
530b72d5b75SMichael Corcoran  * 2) Buffer returned by evaluating method if it isn't NULL.
531b72d5b75SMichael Corcoran  * 3) MADT table as last resort.
532b72d5b75SMichael Corcoran  */
533b72d5b75SMichael Corcoran extern ACPI_STATUS acpidev_walk_apic(ACPI_BUFFER *bufp, ACPI_HANDLE hdl,
534b72d5b75SMichael Corcoran     char *method, acpidev_apic_walker_t func, void *context);
535b72d5b75SMichael Corcoran 
536*a3114836SGerry Liu /*
537*a3114836SGerry Liu  * Evaluate _OST method under object, which is used to support hotplug event.
538*a3114836SGerry Liu  * hdl: object handle
539*a3114836SGerry Liu  * code: _OST source event code
540*a3114836SGerry Liu  * stauts: _OST result status code
541*a3114836SGerry Liu  * bufp and len: optional third parameter for _OST.
542*a3114836SGerry Liu  */
543*a3114836SGerry Liu extern ACPI_STATUS acpidev_eval_ost(ACPI_HANDLE hdl, uint32_t code,
544*a3114836SGerry Liu     uint32_t status, char *bufp, size_t len);
545*a3114836SGerry Liu 
546*a3114836SGerry Liu /*
547*a3114836SGerry Liu  * Evaluate _EJ0 method under object.
548*a3114836SGerry Liu  */
549*a3114836SGerry Liu extern ACPI_STATUS acpidev_eval_ej0(ACPI_HANDLE hdl);
550*a3114836SGerry Liu 
551*a3114836SGerry Liu /*
552*a3114836SGerry Liu  * Evaluate _PXM method under object.
553*a3114836SGerry Liu  */
554*a3114836SGerry Liu extern ACPI_STATUS acpidev_eval_pxm(ACPI_HANDLE hdl, uint32_t *idp);
555*a3114836SGerry Liu 
556b72d5b75SMichael Corcoran #endif	/* _KERNEL */
557b72d5b75SMichael Corcoran 
558b72d5b75SMichael Corcoran #ifdef __cplusplus
559b72d5b75SMichael Corcoran }
560b72d5b75SMichael Corcoran #endif
561b72d5b75SMichael Corcoran 
562b72d5b75SMichael Corcoran #endif	/* _SYS_ACPIDEV_H */
563