#-1# Copyright (c) 2004 Nate Lawson2# All rights reserved.3#4# Redistribution and use in source and binary forms, with or without5# modification, are permitted provided that the following conditions6# are met:7# 1. Redistributions of source code must retain the above copyright8# notice, this list of conditions and the following disclaimer.9# 2. Redistributions in binary form must reproduce the above copyright10# notice, this list of conditions and the following disclaimer in the11# documentation and/or other materials provided with the distribution.12#13# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23# SUCH DAMAGE.24#25#2627#include <sys/bus.h>28#include <sys/types.h>2930#include <contrib/dev/acpica/include/acpi.h>3132INTERFACE acpi;3334#35# Callback function for each child handle traversed in acpi_scan_children().36#37# ACPI_HANDLE h: current child device being considered38#39# device_t *dev: pointer to the child's original device_t or NULL if there40# was none. The callback should store a new device in *dev if it has41# created one. The method implementation will automatically clean up the42# previous device and properly associate the current ACPI_HANDLE with it.43#44# level: current level being scanned45#46# void *arg: argument passed in original call to acpi_scan_children()47#48# Returns: AE_OK if the scan should continue, otherwise an error49#50HEADER {51typedef ACPI_STATUS (*acpi_scan_cb_t)(ACPI_HANDLE h, device_t *dev,52int level, void *arg);5354struct acpi_bix;55struct acpi_bif;56struct acpi_bst;57};5859#60# Default implementation for acpi_id_probe().61#62CODE {63static int64acpi_generic_id_probe(device_t bus, device_t dev, char **ids,65char **match)66{67return (ENXIO);68}69};7071#72# Check a device for a match in a list of ID strings. The strings can be73# EISA PNP IDs or ACPI _HID/_CID values.74#75# device_t bus: parent bus for the device76#77# device_t dev: device being considered78#79# char **ids: array of ID strings to consider80#81# char **match: Pointer to store ID string matched or NULL if no match82# pass NULL if not needed.83#84# Returns: BUS_PROBE_DEFAULT if _HID match85# BUS_PROBE_LOW_PRIORITY if _CID match and not _HID match86# ENXIO if no match.87#8889METHOD int id_probe {90device_t bus;91device_t dev;92char **ids;93char **match;94} DEFAULT acpi_generic_id_probe;9596#97# Evaluate an ACPI method or object, given its path.98#99# device_t bus: parent bus for the device100#101# device_t dev: evaluate the object relative to this device's handle.102# Specify NULL to begin the search at the ACPI root.103#104# ACPI_STRING pathname: absolute or relative path to this object105#106# ACPI_OBJECT_LIST *parameters: array of arguments to pass to the object.107# Specify NULL if there are none.108#109# ACPI_BUFFER *ret: the result (if any) of the evaluation110# Specify NULL if there is none.111#112# Returns: AE_OK or an error value113#114METHOD ACPI_STATUS evaluate_object {115device_t bus;116device_t dev;117ACPI_STRING pathname;118ACPI_OBJECT_LIST *parameters;119ACPI_BUFFER *ret;120};121122#123# Get property value from Device Specific Data124#125# device_t bus: parent bus for the device126#127# device_t dev: find property for this device's handle.128#129# const ACPI_STRING propname: name of the property130#131# const ACPI_OBJECT **value: property value output132# Specify NULL if ignored133#134# Returns: AE_OK or an error value135#136METHOD ACPI_STATUS get_property {137device_t bus;138device_t dev;139ACPI_STRING propname;140const ACPI_OBJECT **value;141};142143#144# Get the highest power state (D0-D3) that is usable for a device when145# suspending/resuming. If a bus calls this when suspending a device, it146# must also call it when resuming.147#148# device_t bus: parent bus for the device149#150# device_t dev: check this device's appropriate power state151#152# int *dstate: if successful, contains the highest valid sleep state153#154# Returns: 0 on success or some other error value.155#156METHOD int pwr_for_sleep {157device_t bus;158device_t dev;159int *dstate;160};161162#163# Rescan a subtree and optionally reattach devices to handles. Users164# specify a callback that is called for each ACPI_HANDLE of type Device165# that is a child of "dev".166#167# device_t bus: parent bus for the device168#169# device_t dev: begin the scan starting with this device's handle.170# Specify NULL to begin the scan at the ACPI root.171#172# int max_depth: number of levels to traverse (i.e., 1 means just the173# immediate children.174#175# acpi_scan_cb_t user_fn: called for each child handle176#177# void *arg: argument to pass to the callback function178#179# Returns: AE_OK or an error value, based on the callback return value180#181METHOD ACPI_STATUS scan_children {182device_t bus;183device_t dev;184int max_depth;185acpi_scan_cb_t user_fn;186void *arg;187};188189#190# Query a given driver for its supported feature(s). This should be191# called by the parent bus before the driver is probed.192#193# driver_t *driver: child driver194#195# u_int *features: returned bitmask of all supported features196#197STATICMETHOD int get_features {198driver_t *driver;199u_int *features;200};201202#203# Read embedded controller (EC) address space204#205# device_t dev: EC device206# u_int addr: Address to read from in EC space207# UINT64 *val: Location to store read value208# int width: Size of area to read in bytes209#210METHOD int ec_read {211device_t dev;212u_int addr;213UINT64 *val;214int width;215};216217#218# Write embedded controller (EC) address space219#220# device_t dev: EC device221# u_int addr: Address to write to in EC space222# UINT64 val: Value to write223# int width: Size of value to write in bytes224#225METHOD int ec_write {226device_t dev;227u_int addr;228UINT64 val;229int width;230};231232#233# Get battery information (_BIF or _BIX format)234#235# device_t dev: Battery device236# void *bix: Pointer to storage for _BIF or _BIX results237# size_t len: length of acpi_bif or acpi_bix.238#239METHOD int batt_get_info {240device_t dev;241void *bix;242size_t len;243};244245#246# Get battery status (_BST format)247#248# device_t dev: Battery device249# struct acpi_bst *bst: Pointer to storage for _BST results250#251METHOD int batt_get_status {252device_t dev;253struct acpi_bst *bst;254};255256257