/*
* Copyright 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This structure is used to attach the ACPI "bus".
*/
struct acpibus_attach_args {
bus_space_tag_t aa_iot; /* PCI I/O space tag */
bus_space_tag_t aa_memt; /* PCI MEM space tag */
pci_chipset_tag_t aa_pc; /* PCI chipset */
int aa_pciflags; /* PCI bus flags */
isa_chipset_tag_t aa_ic; /* ISA chipset */
bus_dma_tag_t aa_dmat; /* PCI DMA tag */
bus_dma_tag_t aa_dmat64; /* PCI 64bit DMA tag */
};
/*
* PCI information for ACPI device nodes that correspond to PCI devices.
*
* Remarks:
*
* ap_bus <= 255
* ap_device <= 31
* ap_function <= 7 or ap_function == 0xFFFF
* ap_downbus <= 255
*
* Validity of some fields depends on the value of ap_flags:
*
* ap_segment always valid
* ap_bus, ap_device, ap_function valid for PCI devices
* ap_downbus valid for PCI bridges
*
* The device and function numbers are encoded in the value returned by
* _ADR. A function number of 0xFFFF is used to refer to all the
* functions on a PCI device (ACPI 4.0a, p. 200).
*/
struct acpi_pci_info {
pci_chipset_tag_t ap_pc; /* PCI chipset tag */
uint16_t ap_flags; /* Flags (cf. below) */
uint16_t ap_segment; /* PCI segment group */
uint16_t ap_bus; /* PCI bus */
uint16_t ap_device; /* PCI device */
uint16_t ap_function; /* PCI function */
uint16_t ap_downbus; /* PCI bridge downstream bus */
};
/*
* An ACPI device node.
*
* Remarks:
*
* ad_device NULL if no device has attached to the node
* ad_root never NULL
* ad_parent only NULL if root of the tree ("\")
* ad_pciinfo NULL if not a PCI device
* ad_wakedev NULL if no wakeup capabilities
* ad_notify NULL if there is no notify handler
* ad_devinfo never NULL
* ad_handle never NULL
*
* Each ACPI device node is associated with its handle. The function
* acpi_match_node() can be used to get the node structure from a handle.
*/
struct acpi_devnode {
device_t ad_device; /* Device */
device_t ad_root; /* Backpointer to acpi_softc */
struct acpi_devnode *ad_parent; /* Backpointer to parent */
struct acpi_pci_info *ad_pciinfo; /* PCI info */
struct acpi_wakedev *ad_wakedev; /* Device wake */
ACPI_NOTIFY_HANDLER ad_notify; /* Device notify */
ACPI_DEVICE_INFO *ad_devinfo; /* Device info */
ACPI_HANDLE ad_handle; /* Device handle */
char ad_name[5]; /* Device name */
uint32_t ad_flags; /* Device flags */
uint32_t ad_type; /* Device type */
int ad_state; /* Device power state */
bus_dma_tag_t ad_dmat; /* Bus DMA tag for device */
bus_dma_tag_t ad_dmat64; /* Bus DMA tag for device (64-bit) */
device_t ad_gpiodev; /* GPIO controller device */
int (*ad_gpio_translate)(void *, ACPI_RESOURCE_GPIO *, void **);
void *ad_gpio_priv; /* private data for translate */
bool ad_scanned; /* private: acpi_rescan state */
};
/*
* ACPI driver capabilities (ad_flags).
*/
#define ACPI_DEVICE_POWER __BIT(0) /* Support for D-states */
#define ACPI_DEVICE_WAKEUP __BIT(1) /* Support for wake-up */
#define ACPI_DEVICE_EJECT __BIT(2) /* Support for "ejection" */
#define ACPI_DEVICE_DOCK __BIT(3) /* Support for docking */
/*
* Software state of the ACPI subsystem.
*/
struct acpi_softc {
device_t sc_dev; /* base device info */
device_t sc_apmbus; /* APM pseudo-bus */
device_t sc_hpet; /* hpet(4) pseudo-bus */
device_t sc_wdrt; /* acpiwdrt(4) pseudo-bus */
struct acpi_devnode *sc_root; /* root of the device tree */
bus_space_tag_t sc_iot; /* PCI I/O space tag */
bus_space_tag_t sc_memt; /* PCI MEM space tag */
int sc_pciflags; /* PCI bus flags */
int sc_pci_bus; /* internal PCI fixup */
isa_chipset_tag_t sc_ic; /* ISA chipset tag */
bus_dma_tag_t sc_dmat; /* PCI DMA tag */
bus_dma_tag_t sc_dmat64; /* PCI 64bit DMA tag */
void *sc_sdhook; /* shutdown hook */
int sc_quirks;
int sc_sleepstate;
int sc_sleepstates;
/*
* Move this section to the other pseudo-bus child pointers
* after pullup -- putting it here avoids potential ABI
* compatibility issues with kernel modules.
*/
device_t sc_apei; /* apei(4) pseudo-bus */
};
/*
* acpi_attach_args:
*
* Used to attach a device instance to the acpi "bus".
*/
struct acpi_attach_args {
struct acpi_devnode *aa_node; /* ACPI device node */
bus_space_tag_t aa_iot; /* PCI I/O space tag */
bus_space_tag_t aa_memt; /* PCI MEM space tag */
pci_chipset_tag_t aa_pc; /* PCI chipset tag */
int aa_pciflags; /* PCI bus flags */
isa_chipset_tag_t aa_ic; /* ISA chipset */
bus_dma_tag_t aa_dmat; /* PCI DMA tag */
bus_dma_tag_t aa_dmat64; /* PCI 64bit DMA tag */
};
/*
* Quirk handling.
*/
struct acpi_quirk {
const char *aq_tabletype; /* Type of table */
const char *aq_oemid; /* "OemId" field */
int aq_oemrev; /* "OemRev" field */
int aq_cmpop; /* "OemRev" comparison */
const char *aq_tabid; /* "TableId */
int aq_quirks; /* The actual quirk */
};