acpi_if.m revision 144629
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: head/sys/dev/acpica/acpi_if.m 144629 2005-04-04 15:46:57Z njl $
27131276Snjl#
28131276Snjl
29131276Snjl#include <sys/bus.h>
30131276Snjl#include <sys/types.h>
31131276Snjl#include "acpi.h"
32131276Snjl
33131276SnjlINTERFACE acpi;
34131276Snjl
35131276Snjl#
36132212Snjl# Callback function for each child handle traversed in acpi_scan_children().
37131276Snjl#
38132212Snjl# ACPI_HANDLE h:  current child device being considered
39132212Snjl#
40132212Snjl# device_t *dev:  pointer to the child's original device_t or NULL if there
41132212Snjl#   was none.  The callback should store a new device in *dev if it has
42132212Snjl#   created one.  The method implementation will automatically clean up the
43132212Snjl#   previous device and properly associate the current ACPI_HANDLE with it.
44132212Snjl#
45132212Snjl# level:  current level being scanned
46132212Snjl#
47132212Snjl# void *arg:  argument passed in original call to acpi_scan_children()
48132212Snjl#
49132212Snjl# Returns:  AE_OK if the scan should continue, otherwise an error
50132212Snjl#
51132212SnjlHEADER {
52132212Snjl	typedef ACPI_STATUS (*acpi_scan_cb_t)(ACPI_HANDLE h, device_t *dev,
53132212Snjl	    int level, void *arg);
54132212Snjl};
55132212Snjl
56132212Snjl#
57132212Snjl# Default implementation for acpi_id_probe().
58132212Snjl#
59131276SnjlCODE {
60131276Snjl	static char *
61131276Snjl	acpi_generic_id_probe(device_t bus, device_t dev, char **ids)
62131276Snjl	{
63131276Snjl		return (NULL);
64131276Snjl	}
65131276Snjl};
66131276Snjl
67131276Snjl#
68132212Snjl# Check a device for a match in a list of ID strings.  The strings can be
69132212Snjl# EISA PNP IDs or ACPI _HID/_CID values.
70131276Snjl#
71132212Snjl# device_t bus:  parent bus for the device
72132212Snjl#
73132212Snjl# device_t dev:  device being considered
74132212Snjl#
75132212Snjl# char **ids:  array of ID strings to consider
76132212Snjl#
77132212Snjl# Returns:  ID string matched or NULL if no match
78132212Snjl#
79131276SnjlMETHOD char * id_probe {
80131276Snjl	device_t	bus;
81131276Snjl	device_t	dev;
82131276Snjl	char		**ids;
83131276Snjl} DEFAULT acpi_generic_id_probe;
84131276Snjl
85131276Snjl#
86132212Snjl# Evaluate an ACPI method or object, given its path.
87131276Snjl#
88132212Snjl# device_t bus:  parent bus for the device
89132212Snjl#
90132212Snjl# device_t dev:  evaluate the object relative to this device's handle.
91132212Snjl#   Specify NULL to begin the search at the ACPI root.
92132212Snjl#
93132212Snjl# ACPI_STRING pathname:  absolute or relative path to this object
94132212Snjl#
95132212Snjl# ACPI_OBJECT_LIST *parameters:  array of arguments to pass to the object.
96132212Snjl#   Specify NULL if there are none.
97132212Snjl#
98132212Snjl# ACPI_BUFFER *ret:  the result (if any) of the evaluation
99132212Snjl#   Specify NULL if there is none.
100132212Snjl#
101132212Snjl# Returns:  AE_OK or an error value
102132212Snjl#
103131276SnjlMETHOD ACPI_STATUS evaluate_object {
104131276Snjl	device_t	bus;
105131276Snjl	device_t	dev;
106131276Snjl	ACPI_STRING 	pathname;
107131276Snjl	ACPI_OBJECT_LIST *parameters;
108131276Snjl	ACPI_BUFFER	*ret;
109131276Snjl};
110131276Snjl
111131276Snjl#
112138305Snjl# Get the highest power state (D0-D3) that is usable for a device when
113138305Snjl# suspending/resuming.  If a bus calls this when suspending a device, it
114138305Snjl# must also call it when resuming.
115138305Snjl#
116138305Snjl# device_t bus:  parent bus for the device
117138305Snjl#
118138305Snjl# device_t dev:  check this device's appropriate power state
119138305Snjl#
120138305Snjl# int *dstate:  if successful, contains the highest valid sleep state
121138305Snjl#
122138305Snjl# Returns:  0 on success, ESRCH if device has no special state, or
123138305Snjl#   some other error value.
124138305Snjl#
125138305SnjlMETHOD int pwr_for_sleep {
126138305Snjl	device_t	bus;
127138305Snjl	device_t	dev;
128138305Snjl	int		*dstate;
129138305Snjl};
130138305Snjl
131138305Snjl#
132132212Snjl# Rescan a subtree and optionally reattach devices to handles.  Users
133132212Snjl# specify a callback that is called for each ACPI_HANDLE of type Device
134132212Snjl# that is a child of "dev".
135131276Snjl#
136132212Snjl# device_t bus:  parent bus for the device
137132212Snjl#
138132212Snjl# device_t dev:  begin the scan starting with this device's handle.
139132212Snjl#   Specify NULL to begin the scan at the ACPI root.
140132212Snjl# 
141132212Snjl# int max_depth:  number of levels to traverse (i.e., 1 means just the
142132212Snjl#   immediate children.
143132212Snjl#
144132212Snjl# acpi_scan_cb_t user_fn:  called for each child handle
145132212Snjl#
146132212Snjl# void *arg:  argument to pass to the callback function
147132212Snjl#
148132212Snjl# Returns:  AE_OK or an error value, based on the callback return value
149132212Snjl#
150132212SnjlMETHOD ACPI_STATUS scan_children {
151131276Snjl	device_t	bus;
152131276Snjl	device_t	dev;
153132212Snjl	int		max_depth;
154132212Snjl	acpi_scan_cb_t	user_fn;
155132212Snjl	void		*arg;
156131276Snjl};
157143861Snjl
158143861Snjl#
159144629Snjl# Query a given driver for its supported feature(s).  This should be
160144629Snjl# called by the parent bus before the driver is probed.
161144629Snjl#
162144629Snjl# driver_t *driver:  child driver
163144629Snjl#
164144629Snjl# u_int *features:  returned bitmask of all supported features
165144629Snjl#
166144629SnjlSTATICMETHOD int get_features {
167144629Snjl	driver_t	*driver;
168144629Snjl	u_int		*features;
169144629Snjl};
170144629Snjl
171144629Snjl#
172143861Snjl# Read embedded controller (EC) address space
173143861Snjl#
174143861Snjl# device_t dev:  EC device
175143861Snjl# u_int addr:  Address to read from in EC space
176143861Snjl# ACPI_INTEGER *val:  Location to store read value
177143861Snjl# int width:  Size of area to read in bytes
178143861Snjl#
179143861SnjlMETHOD int ec_read {
180143861Snjl	device_t	dev;
181143861Snjl	u_int		addr;
182143861Snjl	ACPI_INTEGER	*val;
183143861Snjl	int		width;
184143861Snjl};
185143861Snjl
186143861Snjl#
187143861Snjl# Write embedded controller (EC) address space
188143861Snjl#
189143861Snjl# device_t dev:  EC device
190143861Snjl# u_int addr:  Address to write to in EC space
191143861Snjl# ACPI_INTEGER val:  Value to write
192143861Snjl# int width:  Size of value to write in bytes
193143861Snjl#
194143861SnjlMETHOD int ec_write {
195143861Snjl	device_t	dev;
196143861Snjl	u_int		addr;
197143861Snjl	ACPI_INTEGER	val;
198143861Snjl	int		width;
199143861Snjl};
200