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