aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2008-03-13 20:39:04 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2008-03-13 20:39:04 +0000
commit5217af301c6022ce74e7828730f22e623cea26da (patch)
tree6f62dea9f9beb25f9322cfc93d6d3df609bad843 /sys/dev
parent6c62df7e49144f090a823bc18cacc448744efa72 (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpica/acpi.c83
-rw-r--r--sys/dev/acpica/acpivar.h1
2 files changed, 39 insertions, 45 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 44a901224087..da26b8aa67df 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -91,7 +91,6 @@ struct mtx acpi_mutex;
int acpi_quirks;
static int acpi_modevent(struct module *mod, int event, void *junk);
-static void acpi_identify(driver_t *driver, device_t parent);
static int acpi_probe(device_t dev);
static int acpi_attach(device_t dev);
static int acpi_suspend(device_t dev);
@@ -156,7 +155,6 @@ static int acpi_child_pnpinfo_str_method(device_t acdev, device_t child,
static device_method_t acpi_methods[] = {
/* Device interface */
- DEVMETHOD(device_identify, acpi_identify),
DEVMETHOD(device_probe, acpi_probe),
DEVMETHOD(device_attach, acpi_attach),
DEVMETHOD(device_shutdown, acpi_shutdown),
@@ -219,6 +217,9 @@ static struct rman acpi_rman_io, acpi_rman_mem;
static const char* sleep_state_names[] = {
"S0", "S1", "S2", "S3", "S4", "S5", "NONE"};
+/* Holds the description of the acpi0 device. */
+static char acpi_desc[ACPI_OEM_ID_SIZE + ACPI_OEM_TABLE_ID_SIZE + 2];
+
SYSCTL_NODE(_debug, OID_AUTO, acpi, CTLFLAG_RD, NULL, "ACPI debugging");
static char acpi_ca_version[12];
SYSCTL_STRING(_debug_acpi, OID_AUTO, acpi_ca_version, CTLFLAG_RD,
@@ -316,64 +317,41 @@ acpi_Startup(void)
}
/*
- * Detect ACPI, perform early initialisation
+ * Detect ACPI and perform early initialisation.
*/
-static void
-acpi_identify(driver_t *driver, device_t parent)
+int
+acpi_identify(void)
{
- device_t child;
+ ACPI_TABLE_RSDP *rsdp;
+ ACPI_TABLE_HEADER *rsdt;
+ ACPI_PHYSICAL_ADDRESS paddr;
+ struct sbuf sb;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
if (!cold)
- return_VOID;
+ return (ENXIO);
/* Check that we haven't been disabled with a hint. */
if (resource_disabled("acpi", 0))
- return_VOID;
-
- /* Make sure we're not being doubly invoked. */
- if (device_find_child(parent, "acpi", 0) != NULL)
- return_VOID;
+ return (ENXIO);
- snprintf(acpi_ca_version, sizeof(acpi_ca_version), "%x", ACPI_CA_VERSION);
+ /* Check for other PM systems. */
+ if (power_pm_get_type() != POWER_PM_TYPE_NONE &&
+ power_pm_get_type() != POWER_PM_TYPE_ACPI) {
+ printf("ACPI identify failed, other PM system enabled.\n");
+ return (ENXIO);
+ }
/* Initialize root tables. */
if (ACPI_FAILURE(acpi_Startup())) {
printf("ACPI: Try disabling either ACPI or apic support.\n");
- return_VOID;
- }
-
- /* Attach the actual ACPI device. */
- if ((child = BUS_ADD_CHILD(parent, 10, "acpi", 0)) == NULL) {
- device_printf(parent, "device_identify failed\n");
- return_VOID;
- }
-}
-
-/*
- * Fetch some descriptive data from ACPI to put in our attach message.
- */
-static int
-acpi_probe(device_t dev)
-{
- ACPI_TABLE_RSDP *rsdp;
- ACPI_TABLE_HEADER *rsdt;
- ACPI_PHYSICAL_ADDRESS paddr;
- char buf[ACPI_OEM_ID_SIZE + ACPI_OEM_TABLE_ID_SIZE + 2];
- struct sbuf sb;
-
- ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
-
- if (power_pm_get_type() != POWER_PM_TYPE_NONE &&
- power_pm_get_type() != POWER_PM_TYPE_ACPI) {
- device_printf(dev, "probe failed, other PM system enabled.\n");
- return_VALUE (ENXIO);
+ return (ENXIO);
}
if ((paddr = AcpiOsGetRootPointer()) == 0 ||
(rsdp = AcpiOsMapMemory(paddr, sizeof(ACPI_TABLE_RSDP))) == NULL)
- return_VALUE (ENXIO);
+ return (ENXIO);
if (rsdp->Revision > 1 && rsdp->XsdtPhysicalAddress != 0)
paddr = (ACPI_PHYSICAL_ADDRESS)rsdp->XsdtPhysicalAddress;
else
@@ -381,18 +359,33 @@ acpi_probe(device_t dev)
AcpiOsUnmapMemory(rsdp, sizeof(ACPI_TABLE_RSDP));
if ((rsdt = AcpiOsMapMemory(paddr, sizeof(ACPI_TABLE_HEADER))) == NULL)
- return_VALUE (ENXIO);
- sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
+ return (ENXIO);
+ sbuf_new(&sb, acpi_desc, sizeof(acpi_desc), SBUF_FIXEDLEN);
sbuf_bcat(&sb, rsdt->OemId, ACPI_OEM_ID_SIZE);
sbuf_trim(&sb);
sbuf_putc(&sb, ' ');
sbuf_bcat(&sb, rsdt->OemTableId, ACPI_OEM_TABLE_ID_SIZE);
sbuf_trim(&sb);
sbuf_finish(&sb);
- device_set_desc_copy(dev, sbuf_data(&sb));
sbuf_delete(&sb);
AcpiOsUnmapMemory(rsdt, sizeof(ACPI_TABLE_HEADER));
+ snprintf(acpi_ca_version, sizeof(acpi_ca_version), "%x", ACPI_CA_VERSION);
+
+ return (0);
+}
+
+/*
+ * Fetch some descriptive data from ACPI to put in our attach message.
+ */
+static int
+acpi_probe(device_t dev)
+{
+
+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+
+ device_set_desc(dev, acpi_desc);
+
return_VALUE (0);
}
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 35bd66dc0926..a5ac2de051a1 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -364,6 +364,7 @@ struct acpi_parse_resource_set {
extern struct acpi_parse_resource_set acpi_res_parse_set;
+int acpi_identify(void);
void acpi_config_intr(device_t dev, ACPI_RESOURCE *res);
ACPI_STATUS acpi_lookup_irq_resource(device_t dev, int rid,
struct resource *res, ACPI_RESOURCE *acpi_res);