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