1139749Simp#- 2131276Snjl# Copyright (c) 2004 Nate Lawson 3131276Snjl# All rights reserved. 4131276Snjl# 5131276Snjl# Redistribution and use in source and binary forms, with or without 6131276Snjl# modification, are permitted provided that the following conditions 7131276Snjl# are met: 8131276Snjl# 1. Redistributions of source code must retain the above copyright 9131276Snjl# notice, this list of conditions and the following disclaimer. 10131276Snjl# 2. Redistributions in binary form must reproduce the above copyright 11131276Snjl# notice, this list of conditions and the following disclaimer in the 12131276Snjl# documentation and/or other materials provided with the distribution. 13131276Snjl# 14131276Snjl# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15131276Snjl# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16131276Snjl# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17131276Snjl# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18131276Snjl# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19131276Snjl# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20131276Snjl# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21131276Snjl# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22131276Snjl# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23131276Snjl# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24131276Snjl# SUCH DAMAGE. 25131276Snjl# 26131276Snjl# $FreeBSD: releng/10.2/sys/dev/acpica/acpi_if.m 214072 2010-10-19 19:53:06Z jkim $ 27131276Snjl# 28131276Snjl 29131276Snjl#include <sys/bus.h> 30131276Snjl#include <sys/types.h> 31131276Snjl 32193530Sjkim#include <contrib/dev/acpica/include/acpi.h> 33193530Sjkim 34131276SnjlINTERFACE acpi; 35131276Snjl 36131276Snjl# 37132212Snjl# Callback function for each child handle traversed in acpi_scan_children(). 38131276Snjl# 39132212Snjl# ACPI_HANDLE h: current child device being considered 40132212Snjl# 41132212Snjl# device_t *dev: pointer to the child's original device_t or NULL if there 42132212Snjl# was none. The callback should store a new device in *dev if it has 43132212Snjl# created one. The method implementation will automatically clean up the 44132212Snjl# previous device and properly associate the current ACPI_HANDLE with it. 45132212Snjl# 46132212Snjl# level: current level being scanned 47132212Snjl# 48132212Snjl# void *arg: argument passed in original call to acpi_scan_children() 49132212Snjl# 50132212Snjl# Returns: AE_OK if the scan should continue, otherwise an error 51132212Snjl# 52132212SnjlHEADER { 53132212Snjl typedef ACPI_STATUS (*acpi_scan_cb_t)(ACPI_HANDLE h, device_t *dev, 54132212Snjl int level, void *arg); 55148352Snjl 56148352Snjl struct acpi_bif; 57148352Snjl struct acpi_bst; 58132212Snjl}; 59132212Snjl 60132212Snjl# 61132212Snjl# Default implementation for acpi_id_probe(). 62132212Snjl# 63131276SnjlCODE { 64131276Snjl static char * 65131276Snjl acpi_generic_id_probe(device_t bus, device_t dev, char **ids) 66131276Snjl { 67131276Snjl return (NULL); 68131276Snjl } 69131276Snjl}; 70131276Snjl 71131276Snjl# 72132212Snjl# Check a device for a match in a list of ID strings. The strings can be 73132212Snjl# EISA PNP IDs or ACPI _HID/_CID values. 74131276Snjl# 75132212Snjl# device_t bus: parent bus for the device 76132212Snjl# 77132212Snjl# device_t dev: device being considered 78132212Snjl# 79132212Snjl# char **ids: array of ID strings to consider 80132212Snjl# 81132212Snjl# Returns: ID string matched or NULL if no match 82132212Snjl# 83131276SnjlMETHOD char * id_probe { 84131276Snjl device_t bus; 85131276Snjl device_t dev; 86131276Snjl char **ids; 87131276Snjl} DEFAULT acpi_generic_id_probe; 88131276Snjl 89131276Snjl# 90132212Snjl# Evaluate an ACPI method or object, given its path. 91131276Snjl# 92132212Snjl# device_t bus: parent bus for the device 93132212Snjl# 94132212Snjl# device_t dev: evaluate the object relative to this device's handle. 95132212Snjl# Specify NULL to begin the search at the ACPI root. 96132212Snjl# 97132212Snjl# ACPI_STRING pathname: absolute or relative path to this object 98132212Snjl# 99132212Snjl# ACPI_OBJECT_LIST *parameters: array of arguments to pass to the object. 100132212Snjl# Specify NULL if there are none. 101132212Snjl# 102132212Snjl# ACPI_BUFFER *ret: the result (if any) of the evaluation 103132212Snjl# Specify NULL if there is none. 104132212Snjl# 105132212Snjl# Returns: AE_OK or an error value 106132212Snjl# 107131276SnjlMETHOD ACPI_STATUS evaluate_object { 108131276Snjl device_t bus; 109131276Snjl device_t dev; 110131276Snjl ACPI_STRING pathname; 111131276Snjl ACPI_OBJECT_LIST *parameters; 112131276Snjl ACPI_BUFFER *ret; 113131276Snjl}; 114131276Snjl 115131276Snjl# 116138305Snjl# Get the highest power state (D0-D3) that is usable for a device when 117138305Snjl# suspending/resuming. If a bus calls this when suspending a device, it 118138305Snjl# must also call it when resuming. 119138305Snjl# 120138305Snjl# device_t bus: parent bus for the device 121138305Snjl# 122138305Snjl# device_t dev: check this device's appropriate power state 123138305Snjl# 124138305Snjl# int *dstate: if successful, contains the highest valid sleep state 125138305Snjl# 126214072Sjkim# Returns: 0 on success or some other error value. 127138305Snjl# 128138305SnjlMETHOD int pwr_for_sleep { 129138305Snjl device_t bus; 130138305Snjl device_t dev; 131138305Snjl int *dstate; 132138305Snjl}; 133138305Snjl 134138305Snjl# 135132212Snjl# Rescan a subtree and optionally reattach devices to handles. Users 136132212Snjl# specify a callback that is called for each ACPI_HANDLE of type Device 137132212Snjl# that is a child of "dev". 138131276Snjl# 139132212Snjl# device_t bus: parent bus for the device 140132212Snjl# 141132212Snjl# device_t dev: begin the scan starting with this device's handle. 142132212Snjl# Specify NULL to begin the scan at the ACPI root. 143132212Snjl# 144132212Snjl# int max_depth: number of levels to traverse (i.e., 1 means just the 145132212Snjl# immediate children. 146132212Snjl# 147132212Snjl# acpi_scan_cb_t user_fn: called for each child handle 148132212Snjl# 149132212Snjl# void *arg: argument to pass to the callback function 150132212Snjl# 151132212Snjl# Returns: AE_OK or an error value, based on the callback return value 152132212Snjl# 153132212SnjlMETHOD ACPI_STATUS scan_children { 154131276Snjl device_t bus; 155131276Snjl device_t dev; 156132212Snjl int max_depth; 157132212Snjl acpi_scan_cb_t user_fn; 158132212Snjl void *arg; 159131276Snjl}; 160143861Snjl 161143861Snjl# 162144629Snjl# Query a given driver for its supported feature(s). This should be 163144629Snjl# called by the parent bus before the driver is probed. 164144629Snjl# 165144629Snjl# driver_t *driver: child driver 166144629Snjl# 167144629Snjl# u_int *features: returned bitmask of all supported features 168144629Snjl# 169144629SnjlSTATICMETHOD int get_features { 170144629Snjl driver_t *driver; 171144629Snjl u_int *features; 172144629Snjl}; 173144629Snjl 174144629Snjl# 175143861Snjl# Read embedded controller (EC) address space 176143861Snjl# 177143861Snjl# device_t dev: EC device 178143861Snjl# u_int addr: Address to read from in EC space 179202771Sjkim# UINT64 *val: Location to store read value 180143861Snjl# int width: Size of area to read in bytes 181143861Snjl# 182143861SnjlMETHOD int ec_read { 183143861Snjl device_t dev; 184143861Snjl u_int addr; 185202771Sjkim UINT64 *val; 186143861Snjl int width; 187143861Snjl}; 188143861Snjl 189143861Snjl# 190143861Snjl# Write embedded controller (EC) address space 191143861Snjl# 192143861Snjl# device_t dev: EC device 193143861Snjl# u_int addr: Address to write to in EC space 194202771Sjkim# UINT64 val: Value to write 195143861Snjl# int width: Size of value to write in bytes 196143861Snjl# 197143861SnjlMETHOD int ec_write { 198143861Snjl device_t dev; 199143861Snjl u_int addr; 200202771Sjkim UINT64 val; 201143861Snjl int width; 202143861Snjl}; 203148352Snjl 204148352Snjl# 205148352Snjl# Get battery information (_BIF format) 206148352Snjl# 207148352Snjl# device_t dev: Battery device 208148352Snjl# struct acpi_bif *bif: Pointer to storage for _BIF results 209148352Snjl# 210148352SnjlMETHOD int batt_get_info { 211148352Snjl device_t dev; 212148352Snjl struct acpi_bif *bif; 213148352Snjl}; 214148352Snjl 215148352Snjl# 216148352Snjl# Get battery status (_BST format) 217148352Snjl# 218148352Snjl# device_t dev: Battery device 219148352Snjl# struct acpi_bst *bst: Pointer to storage for _BST results 220148352Snjl# 221148352SnjlMETHOD int batt_get_status { 222148352Snjl device_t dev; 223148352Snjl struct acpi_bst *bst; 224148352Snjl}; 225