diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/acpi/acpi.c | 44 | ||||
-rw-r--r-- | sys/dev/acpi/acpibat.c | 5 | ||||
-rw-r--r-- | sys/dev/acpi/acpireg.h | 6 | ||||
-rw-r--r-- | sys/dev/acpi/acpisbs.c | 6 | ||||
-rw-r--r-- | sys/dev/acpi/acpivar.h | 3 |
5 files changed, 56 insertions, 8 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 67c76c6d21a..2ff280e4bb1 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.323 2017/03/02 10:38:10 natano Exp $ */ +/* $OpenBSD: acpi.c,v 1.324 2017/03/12 21:30:44 jcs Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -116,6 +116,7 @@ void acpi_enable_wakegpes(struct acpi_softc *, int); int acpi_foundec(struct aml_node *, void *); int acpi_foundsony(struct aml_node *node, void *arg); int acpi_foundhid(struct aml_node *, void *); +int acpi_foundsbs(struct aml_node *node, void *); int acpi_add_device(struct aml_node *node, void *arg); void acpi_thread(void *); @@ -1082,6 +1083,9 @@ acpi_attach(struct device *parent, struct device *self, void *aux) aml_walknodes(&aml_root, AML_WALK_PRE, acpi_add_device, sc); + /* try to find smart battery first */ + aml_find_node(&aml_root, "_HID", acpi_foundsbs, sc); + /* attach battery, power supply and button devices */ aml_find_node(&aml_root, "_HID", acpi_foundhid, sc); @@ -2913,6 +2917,44 @@ acpi_foundvideo(struct aml_node *node, void *arg) } int +acpi_foundsbs(struct aml_node *node, void *arg) +{ + struct acpi_softc *sc = (struct acpi_softc *)arg; + struct device *self = (struct device *)arg; + char cdev[32], dev[32]; + struct acpi_attach_args aaa; + int64_t sta; + + if (acpi_parsehid(node, arg, cdev, dev, sizeof(dev)) != 0) + return (0); + + if (aml_evalinteger(sc, node->parent, "_STA", 0, NULL, &sta)) + sta = STA_PRESENT | STA_ENABLED | STA_DEV_OK | 0x1000; + + if ((sta & STA_PRESENT) == 0) + return (0); + + acpi_attach_deps(sc, node->parent); + + if (strcmp(dev, ACPI_DEV_SBS) != 0) + return (0); + + if (node->parent->attached) + return (0); + + memset(&aaa, 0, sizeof(aaa)); + aaa.aaa_iot = sc->sc_iot; + aaa.aaa_memt = sc->sc_memt; + aaa.aaa_node = node->parent; + aaa.aaa_dev = dev; + + config_found(self, &aaa, acpi_print); + node->parent->attached = 1; + + return (0); +} + +int acpiopen(dev_t dev, int flag, int mode, struct proc *p) { int error = 0; diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index c0132398218..55c47961a61 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.62 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: acpibat.c,v 1.63 2017/03/12 21:30:44 jcs Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -54,6 +54,9 @@ acpibat_match(struct device *parent, void *match, void *aux) struct acpi_attach_args *aa = aux; struct cfdata *cf = match; + if (((struct acpi_softc *)parent)->sc_havesbs) + return (0); + /* sanity */ return (acpi_matchhids(aa, acpibat_hids, cf->cf_driver->cd_name)); } diff --git a/sys/dev/acpi/acpireg.h b/sys/dev/acpi/acpireg.h index 47b203d4bd3..130df5c97b2 100644 --- a/sys/dev/acpi/acpireg.h +++ b/sys/dev/acpi/acpireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpireg.h,v 1.38 2017/02/25 20:09:20 jcs Exp $ */ +/* $OpenBSD: acpireg.h,v 1.39 2017/03/12 21:30:44 jcs Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> @@ -748,10 +748,10 @@ struct acpi_ivrs { #define ACPI_DEV_MEMD "PNP0C80" /* Memory Device */ #define ACPI_DEV_MOUSE "PNP0F13" /* PS/2 Mouse */ #define ACPI_DEV_SHC "ACPI0001" /* SMBus 1.0 Host Controller */ -#define ACPI_DEV_SMS1 "ACPI0002" /* Smart Battery Subsystem */ +#define ACPI_DEV_SBS "ACPI0002" /* Smart Battery Subsystem */ #define ACPI_DEV_AC "ACPI0003" /* AC Device */ #define ACPI_DEV_MD "ACPI0004" /* Module Device */ -#define ACPI_DEV_SMS2 "ACPI0005" /* SMBus 2.0 Host Controller */ +#define ACPI_DEV_SMBUS "ACPI0005" /* SMBus 2.0 Host Controller */ #define ACPI_DEV_GBD "ACPI0006" /* GPE Block Device */ #define ACPI_DEV_PD "ACPI0007" /* Processor Device */ #define ACPI_DEV_ALSD "ACPI0008" /* Ambient Light Sensor Device */ diff --git a/sys/dev/acpi/acpisbs.c b/sys/dev/acpi/acpisbs.c index 72e691bcb83..4733fc6493f 100644 --- a/sys/dev/acpi/acpisbs.c +++ b/sys/dev/acpi/acpisbs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpisbs.c,v 1.3 2017/03/07 02:27:02 jcs Exp $ */ +/* $OpenBSD: acpisbs.c,v 1.4 2017/03/12 21:30:44 jcs Exp $ */ /* * Smart Battery Subsystem device driver * ACPI 5.0 spec section 10 @@ -144,7 +144,7 @@ struct cfdriver acpisbs_cd = { }; const char *acpisbs_hids[] = { - "ACPI0002", + ACPI_DEV_SBS, NULL }; @@ -211,6 +211,8 @@ acpisbs_attach(struct device *parent, struct device *self, void *aux) aml_register_notify(sc->sc_devnode, aa->aaa_dev, acpisbs_notify, sc, ACPIDEV_POLL); + + sc->sc_acpi->sc_havesbs = 1; } void diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index d521a90ac3d..77e20278671 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.85 2017/02/28 10:39:07 natano Exp $ */ +/* $OpenBSD: acpivar.h,v 1.86 2017/03/12 21:30:44 jcs Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -258,6 +258,7 @@ struct acpi_softc { struct acpi_ac_head sc_ac; struct acpi_bat_head sc_bat; struct acpi_sbs_head sc_sbs; + int sc_havesbs; struct timeout sc_dev_timeout; |