2010-04-15 11:02:24 +04:00
|
|
|
/* $NetBSD: acpivar.h,v 1.48 2010/04/15 07:02:24 jruoho Exp $ */
|
2001-09-28 06:09:22 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2010-03-05 11:30:48 +03:00
|
|
|
#ifndef _SYS_DEV_ACPI_ACPIVAR_H
|
|
|
|
#define _SYS_DEV_ACPI_ACPIVAR_H
|
|
|
|
|
2001-09-28 06:09:22 +04:00
|
|
|
/*
|
|
|
|
* This file defines the ACPI interface provided to the rest of the
|
|
|
|
* kernel, as well as the autoconfiguration structures for ACPI
|
|
|
|
* support.
|
|
|
|
*/
|
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/bus.h>
|
2001-09-28 06:09:22 +04:00
|
|
|
#include <dev/pci/pcivar.h>
|
2002-12-28 09:14:07 +03:00
|
|
|
#include <dev/isa/isavar.h>
|
2001-09-28 06:09:22 +04:00
|
|
|
|
|
|
|
#include <dev/acpi/acpica.h>
|
2010-04-14 21:12:14 +04:00
|
|
|
#include <dev/acpi/acpi_util.h>
|
2001-09-28 06:09:22 +04:00
|
|
|
|
2003-04-17 05:22:21 +04:00
|
|
|
#include <dev/sysmon/sysmonvar.h>
|
|
|
|
|
2001-09-28 06:09:22 +04:00
|
|
|
/*
|
2010-04-15 11:02:24 +04:00
|
|
|
* This structure is used to attach the ACPI "bus".
|
2001-09-28 06:09:22 +04:00
|
|
|
*/
|
|
|
|
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 */
|
2002-12-28 09:14:07 +03:00
|
|
|
isa_chipset_tag_t aa_ic; /* ISA chipset */
|
2001-09-28 06:09:22 +04:00
|
|
|
};
|
|
|
|
|
2010-03-16 08:48:42 +03:00
|
|
|
/*
|
|
|
|
* ACPI driver capabilities.
|
|
|
|
*/
|
|
|
|
#define ACPI_DEVICE_POWER __BIT(0)
|
|
|
|
#define ACPI_DEVICE_WAKEUP __BIT(1)
|
|
|
|
|
2001-09-28 06:09:22 +04:00
|
|
|
/*
|
2010-04-15 11:02:24 +04:00
|
|
|
* An ACPI device node.
|
2001-09-28 06:09:22 +04:00
|
|
|
*
|
2010-04-15 11:02:24 +04:00
|
|
|
* Note that this is available for all nodes, meaning that e.g.
|
|
|
|
* the device_t (ad_device) may be NULL for unattached devices.
|
2001-09-28 06:09:22 +04:00
|
|
|
*/
|
|
|
|
struct acpi_devnode {
|
2010-03-09 21:15:21 +03:00
|
|
|
device_t ad_device; /* Device */
|
|
|
|
device_t ad_parent; /* Backpointer to the parent */
|
2010-04-15 11:02:24 +04:00
|
|
|
ACPI_NOTIFY_HANDLER ad_notify; /* Device notify */
|
2010-03-09 21:15:21 +03:00
|
|
|
ACPI_DEVICE_INFO *ad_devinfo; /* Device info */
|
|
|
|
ACPI_HANDLE ad_handle; /* Device handle */
|
|
|
|
char ad_name[5]; /* Device name */
|
2010-03-16 08:48:42 +03:00
|
|
|
uint32_t ad_flags; /* Device flags */
|
2010-03-09 21:15:21 +03:00
|
|
|
uint32_t ad_type; /* Device type */
|
2010-04-12 16:14:26 +04:00
|
|
|
int ad_wake; /* Device wakeup */
|
2010-03-09 21:15:21 +03:00
|
|
|
|
|
|
|
SIMPLEQ_ENTRY(acpi_devnode) ad_list;
|
2001-09-28 06:09:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2010-04-15 11:02:24 +04:00
|
|
|
* Software state of the ACPI subsystem.
|
2001-09-28 06:09:22 +04:00
|
|
|
*/
|
|
|
|
struct acpi_softc {
|
2008-03-27 05:51:26 +03:00
|
|
|
device_t sc_dev; /* base device info */
|
2001-09-28 06:09:22 +04:00
|
|
|
bus_space_tag_t sc_iot; /* PCI I/O space tag */
|
|
|
|
bus_space_tag_t sc_memt; /* PCI MEM space tag */
|
|
|
|
pci_chipset_tag_t sc_pc; /* PCI chipset tag */
|
|
|
|
int sc_pciflags; /* PCI bus flags */
|
2002-07-29 07:25:18 +04:00
|
|
|
int sc_pci_bus; /* internal PCI fixup */
|
2002-12-28 09:14:07 +03:00
|
|
|
isa_chipset_tag_t sc_ic; /* ISA chipset tag */
|
2001-09-28 06:09:22 +04:00
|
|
|
|
|
|
|
void *sc_sdhook; /* shutdown hook */
|
|
|
|
|
2003-04-17 05:22:21 +04:00
|
|
|
/*
|
|
|
|
* Power switch handlers for fixed-feature buttons.
|
|
|
|
*/
|
|
|
|
struct sysmon_pswitch sc_smpsw_power;
|
|
|
|
struct sysmon_pswitch sc_smpsw_sleep;
|
|
|
|
|
2001-09-28 06:09:22 +04:00
|
|
|
int sc_sleepstate; /* current sleep state */
|
2010-04-12 22:55:27 +04:00
|
|
|
int sc_sleepstates; /* supported sleep states */
|
2001-09-28 06:09:22 +04:00
|
|
|
|
2003-05-16 01:29:49 +04:00
|
|
|
int sc_quirks;
|
|
|
|
|
2009-04-08 04:23:30 +04:00
|
|
|
device_t sc_apmbus;
|
2010-03-09 21:15:21 +03:00
|
|
|
|
|
|
|
SIMPLEQ_HEAD(, acpi_devnode) sc_devnodes; /* devices */
|
2001-09-28 06:09:22 +04:00
|
|
|
};
|
|
|
|
|
2001-09-29 09:34:00 +04:00
|
|
|
/*
|
|
|
|
* acpi_attach_args:
|
|
|
|
*
|
|
|
|
* Used to attach a device instance to the acpi "bus".
|
|
|
|
*/
|
2001-09-28 06:09:22 +04:00
|
|
|
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 */
|
2002-12-28 09:14:07 +03:00
|
|
|
isa_chipset_tag_t aa_ic; /* ISA chipset */
|
2001-09-28 06:09:22 +04:00
|
|
|
};
|
|
|
|
|
2001-09-29 09:34:00 +04:00
|
|
|
/*
|
|
|
|
* ACPI resources:
|
|
|
|
*
|
|
|
|
* acpi_io I/O ports
|
|
|
|
* acpi_iorange I/O port range
|
|
|
|
* acpi_mem memory region
|
|
|
|
* acpi_memrange memory range
|
|
|
|
* acpi_irq Interrupt Request
|
|
|
|
* acpi_drq DMA request
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct acpi_io {
|
|
|
|
SIMPLEQ_ENTRY(acpi_io) ar_list;
|
|
|
|
int ar_index;
|
|
|
|
uint32_t ar_base;
|
|
|
|
uint32_t ar_length;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_iorange {
|
|
|
|
SIMPLEQ_ENTRY(acpi_iorange) ar_list;
|
|
|
|
int ar_index;
|
|
|
|
uint32_t ar_low;
|
|
|
|
uint32_t ar_high;
|
|
|
|
uint32_t ar_length;
|
|
|
|
uint32_t ar_align;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_mem {
|
|
|
|
SIMPLEQ_ENTRY(acpi_mem) ar_list;
|
|
|
|
int ar_index;
|
|
|
|
uint32_t ar_base;
|
|
|
|
uint32_t ar_length;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_memrange {
|
|
|
|
SIMPLEQ_ENTRY(acpi_memrange) ar_list;
|
|
|
|
int ar_index;
|
|
|
|
uint32_t ar_low;
|
|
|
|
uint32_t ar_high;
|
|
|
|
uint32_t ar_length;
|
|
|
|
uint32_t ar_align;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_irq {
|
|
|
|
SIMPLEQ_ENTRY(acpi_irq) ar_list;
|
|
|
|
int ar_index;
|
|
|
|
uint32_t ar_irq;
|
2002-12-28 11:44:43 +03:00
|
|
|
uint32_t ar_type;
|
2001-09-29 09:34:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_drq {
|
|
|
|
SIMPLEQ_ENTRY(acpi_drq) ar_list;
|
|
|
|
int ar_index;
|
|
|
|
uint32_t ar_drq;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_resources {
|
|
|
|
SIMPLEQ_HEAD(, acpi_io) ar_io;
|
|
|
|
int ar_nio;
|
|
|
|
|
|
|
|
SIMPLEQ_HEAD(, acpi_iorange) ar_iorange;
|
|
|
|
int ar_niorange;
|
|
|
|
|
|
|
|
SIMPLEQ_HEAD(, acpi_mem) ar_mem;
|
|
|
|
int ar_nmem;
|
|
|
|
|
|
|
|
SIMPLEQ_HEAD(, acpi_memrange) ar_memrange;
|
|
|
|
int ar_nmemrange;
|
|
|
|
|
|
|
|
SIMPLEQ_HEAD(, acpi_irq) ar_irq;
|
|
|
|
int ar_nirq;
|
|
|
|
|
|
|
|
SIMPLEQ_HEAD(, acpi_drq) ar_drq;
|
|
|
|
int ar_ndrq;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* acpi_resource_parse_ops:
|
|
|
|
*
|
|
|
|
* The client of ACPI resources specifies these operations
|
|
|
|
* when the resources are parsed.
|
|
|
|
*/
|
|
|
|
struct acpi_resource_parse_ops {
|
2009-05-12 13:50:28 +04:00
|
|
|
void (*init)(device_t, void *, void **);
|
|
|
|
void (*fini)(device_t, void *);
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2009-05-12 13:50:28 +04:00
|
|
|
void (*ioport)(device_t, void *, uint32_t, uint32_t);
|
|
|
|
void (*iorange)(device_t, void *, uint32_t, uint32_t,
|
2001-09-29 09:34:00 +04:00
|
|
|
uint32_t, uint32_t);
|
|
|
|
|
2009-05-12 13:50:28 +04:00
|
|
|
void (*memory)(device_t, void *, uint32_t, uint32_t);
|
|
|
|
void (*memrange)(device_t, void *, uint32_t, uint32_t,
|
2001-09-29 09:34:00 +04:00
|
|
|
uint32_t, uint32_t);
|
|
|
|
|
2009-05-12 13:50:28 +04:00
|
|
|
void (*irq)(device_t, void *, uint32_t, uint32_t);
|
|
|
|
void (*drq)(device_t, void *, uint32_t);
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2009-05-12 13:50:28 +04:00
|
|
|
void (*start_dep)(device_t, void *, int);
|
|
|
|
void (*end_dep)(device_t, void *);
|
2001-09-29 09:34:00 +04:00
|
|
|
};
|
|
|
|
|
2001-09-28 06:09:22 +04:00
|
|
|
extern struct acpi_softc *acpi_softc;
|
|
|
|
extern int acpi_active;
|
|
|
|
|
2001-09-29 09:34:00 +04:00
|
|
|
extern const struct acpi_resource_parse_ops acpi_resource_parse_ops_default;
|
|
|
|
|
2001-09-28 06:09:22 +04:00
|
|
|
int acpi_probe(void);
|
2010-04-14 21:12:14 +04:00
|
|
|
int acpi_check(device_t, const char *);
|
|
|
|
|
2007-12-09 23:27:42 +03:00
|
|
|
ACPI_PHYSICAL_ADDRESS acpi_OsGetRootPointer(void);
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2010-04-15 11:02:24 +04:00
|
|
|
bool acpi_register_notify(struct acpi_devnode *,
|
|
|
|
ACPI_NOTIFY_HANDLER);
|
|
|
|
void acpi_deregister_notify(struct acpi_devnode *);
|
|
|
|
|
2009-05-12 13:50:28 +04:00
|
|
|
ACPI_STATUS acpi_resource_parse(device_t, ACPI_HANDLE, const char *,
|
2001-09-29 09:34:00 +04:00
|
|
|
void *, const struct acpi_resource_parse_ops *);
|
2009-05-12 13:50:28 +04:00
|
|
|
void acpi_resource_print(device_t, struct acpi_resources *);
|
2004-04-11 14:36:35 +04:00
|
|
|
void acpi_resource_cleanup(struct acpi_resources *);
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-05-26 21:15:17 +04:00
|
|
|
ACPI_STATUS acpi_pwr_switch_consumer(ACPI_HANDLE, int);
|
|
|
|
|
2006-07-04 04:30:21 +04:00
|
|
|
void * acpi_pci_link_devbyhandle(ACPI_HANDLE);
|
|
|
|
void acpi_pci_link_add_reference(void *, int, int, int, int);
|
|
|
|
int acpi_pci_link_route_interrupt(void *, int, int *, int *, int *);
|
|
|
|
char * acpi_pci_link_name(void *);
|
|
|
|
ACPI_HANDLE acpi_pci_link_handle(void *);
|
|
|
|
void acpi_pci_link_state(void);
|
2008-11-18 02:29:49 +03:00
|
|
|
void acpi_pci_link_resume(void);
|
2006-07-04 04:30:21 +04:00
|
|
|
|
2001-09-29 09:34:00 +04:00
|
|
|
struct acpi_io *acpi_res_io(struct acpi_resources *, int);
|
|
|
|
struct acpi_iorange *acpi_res_iorange(struct acpi_resources *, int);
|
|
|
|
struct acpi_mem *acpi_res_mem(struct acpi_resources *, int);
|
|
|
|
struct acpi_memrange *acpi_res_memrange(struct acpi_resources *, int);
|
|
|
|
struct acpi_irq *acpi_res_irq(struct acpi_resources *, int);
|
|
|
|
struct acpi_drq *acpi_res_drq(struct acpi_resources *, int);
|
2002-06-18 12:09:21 +04:00
|
|
|
|
|
|
|
/*
|
2010-04-14 21:12:14 +04:00
|
|
|
* Sleep state transition.
|
2002-06-18 12:09:21 +04:00
|
|
|
*/
|
2010-04-14 21:12:14 +04:00
|
|
|
ACPI_STATUS acpi_enter_sleep_state(struct acpi_softc *, int);
|
2003-02-14 14:05:39 +03:00
|
|
|
|
2003-05-16 01:29:49 +04:00
|
|
|
/*
|
2010-04-14 21:12:14 +04:00
|
|
|
* Quirk handling.
|
2003-05-16 01:29:49 +04:00
|
|
|
*/
|
|
|
|
struct acpi_quirk {
|
2007-12-09 23:27:42 +03:00
|
|
|
const char *aq_tabletype; /* what type of table (FADT, DSDT, etc) */
|
2006-07-04 04:30:21 +04:00
|
|
|
const char *aq_oemid; /* compared against the table OemId */
|
|
|
|
int aq_oemrev; /* compared against the table OemRev */
|
|
|
|
int aq_cmpop; /* how to compare the oemrev number */
|
|
|
|
const char *aq_tabid; /* compared against the table TableId */
|
2003-05-16 01:29:49 +04:00
|
|
|
int aq_quirks; /* the actual quirks */
|
|
|
|
};
|
|
|
|
|
2006-07-04 04:30:21 +04:00
|
|
|
#define ACPI_QUIRK_BROKEN 0x00000001 /* totally broken */
|
|
|
|
#define ACPI_QUIRK_BADPCI 0x00000002 /* bad PCI hierarchy */
|
|
|
|
#define ACPI_QUIRK_BADBBN 0x00000004 /* _BBN broken */
|
2006-09-23 21:04:26 +04:00
|
|
|
#define ACPI_QUIRK_IRQ0 0x00000008 /* bad 0->2 irq override */
|
2003-05-16 01:29:49 +04:00
|
|
|
|
|
|
|
int acpi_find_quirks(void);
|
2010-01-31 14:26:20 +03:00
|
|
|
|
|
|
|
#ifdef ACPI_DEBUG
|
|
|
|
void acpi_debug_init(void);
|
|
|
|
#endif
|
2010-03-05 11:30:48 +03:00
|
|
|
|
|
|
|
#endif /* !_SYS_DEV_ACPI_ACPIVAR_H */
|