summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMichael Knudsen <mk@cvs.openbsd.org>2007-04-22 20:52:28 +0000
committerMichael Knudsen <mk@cvs.openbsd.org>2007-04-22 20:52:28 +0000
commit6e8ae5cffc66ba546944fe0870020a092bdf7d81 (patch)
tree1eeb4489200254ee17ce8b3814cb19ee2043c63e /sys
parentef87ec7354a7ae7113394a2113b2577f6b76d24c (diff)
Add a TAILQ, aml_nodelist, of devices depending on the dock device to
struct acpidock_softc and stuff devices into it during attach. This list is not yet used, but I have code ready to handle the ACPI side of this. However, it still doesn't handle that there may in fact be multiple dock devices in a machine (e.g. on pre-60 series ThinkPads), but I need to figure out how to do so properly first. In the mean time I want this in the tree so I don't lose the code.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpi/acpidev.h5
-rw-r--r--sys/dev/acpi/acpidock.c40
2 files changed, 43 insertions, 2 deletions
diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h
index 0193bf8c03c..5f91459af96 100644
--- a/sys/dev/acpi/acpidev.h
+++ b/sys/dev/acpi/acpidev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpidev.h,v 1.21 2007/03/22 16:55:31 deraadt Exp $ */
+/* $OpenBSD: acpidev.h,v 1.22 2007/04/22 20:52:27 mk Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
@@ -294,6 +294,9 @@ struct acpidock_softc {
struct acpi_softc *sc_acpi;
struct aml_node *sc_devnode;
+ TAILQ_HEAD(, aml_nodelist) sc_deps_h;
+ struct aml_nodelist *sc_deps;
+
struct ksensor sc_sens[1];
struct ksensordev sc_sensdev;
diff --git a/sys/dev/acpi/acpidock.c b/sys/dev/acpi/acpidock.c
index 697ad81cfd3..d6783caa8a6 100644
--- a/sys/dev/acpi/acpidock.c
+++ b/sys/dev/acpi/acpidock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpidock.c,v 1.20 2007/04/17 16:04:00 mk Exp $ */
+/* $OpenBSD: acpidock.c,v 1.21 2007/04/22 20:52:27 mk Exp $ */
/*
* Copyright (c) 2006,2007 Michael Knudsen <mk@openbsd.org>
*
@@ -29,6 +29,11 @@
#include <dev/acpi/amltypes.h>
#include <dev/acpi/dsdt.h>
+struct aml_nodelist {
+ struct aml_node *node;
+ TAILQ_ENTRY(aml_nodelist) entries;
+};
+
int acpidock_match(struct device *, void *, void *);
void acpidock_attach(struct device *, struct device *, void *);
@@ -47,6 +52,8 @@ int acpidock_eject(struct acpidock_softc *, struct aml_node *);
int acpidock_notify(struct aml_node *, int, void *);
int acpidock_status(struct acpidock_softc *);
+void acpidock_foundejd(struct aml_node *, void *);
+
int
acpidock_match(struct device *parent, void *match, void *aux)
{
@@ -67,6 +74,7 @@ acpidock_attach(struct device *parent, struct device *self, void *aux)
{
struct acpidock_softc *sc = (struct acpidock_softc *)self;
struct acpi_attach_args *aa = aux;
+ extern struct aml_node aml_root;
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_devnode = aa->aaa_node->child;
@@ -101,6 +109,9 @@ acpidock_attach(struct device *parent, struct device *self, void *aux)
sensor_attach(&sc->sc_sensdev, &sc->sc_sens[0]);
sensordev_install(&sc->sc_sensdev);
+ TAILQ_INIT(&sc->sc_deps_h);
+ aml_find_node(aml_root.child, "_EJD", acpidock_foundejd, sc);
+
aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev,
acpidock_notify, sc, ACPIDEV_NOPOLL);
@@ -251,3 +262,30 @@ acpidock_notify(struct aml_node *node, int notify_type, void *arg)
return (0);
}
+void
+acpidock_foundejd(struct aml_node *node, void *arg)
+{
+ struct acpidock_softc *sc = (struct acpidock_softc *)arg;
+ struct aml_value res;
+
+ dnprintf(15, "%s: %s", DEVNAME(sc), node->parent->name);
+
+ if (aml_evalnode(sc->sc_acpi, node, 0, NULL, &res) == -1) {
+ printf(": error\n");
+ } else {
+ struct aml_nodelist *n;
+
+ /* XXX debug */
+ dnprintf(10, "%s: %s depends on %s\n", DEVNAME(sc),
+ node->parent->name, res.v_string);
+
+ /* XXX more than one dock? */
+
+ n = malloc(sizeof(struct aml_nodelist), M_DEVBUF, M_WAITOK);
+ n->node = node;
+
+ TAILQ_INSERT_TAIL(&sc->sc_deps_h, n, entries);
+ }
+
+ aml_freevalue(&res);
+}