summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2024-07-30 19:47:07 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2024-07-30 19:47:07 +0000
commitc69199934d0c07407debf00aa139c4899bae5574 (patch)
tree7ba2c0ad545ea56f8361e543e17d862c2a7a1659 /sys
parentd8377f80b7928ed366f88afebec62c73014df84b (diff)
Make the Samsung Galaxy Book4 Edge (x1e80100) boot in ACPI mode;
Until now the kernel did panic during early boot because we couldn't respond to the battery requests sent to the 0xa1 "bus". This (dummy) driver registers a 0xa1 region space very early, and responds with a static zero value to satisfy the battery requests on 0xa1, which let us boot successfully to multi-user. In the future this machine should be operated in FDT mode, and an improved AML parsing interface might make this workaround obsolete also for RAMDISK. Help and OK kettenis@, deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/arm64/conf/GENERIC3
-rw-r--r--sys/arch/arm64/conf/RAMDISK3
-rw-r--r--sys/dev/acpi/acpi.c29
-rw-r--r--sys/dev/acpi/acpisectwo.c90
-rw-r--r--sys/dev/acpi/files.acpi7
5 files changed, 128 insertions, 4 deletions
diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC
index b6421e6e22c..e2c746bdcb3 100644
--- a/sys/arch/arm64/conf/GENERIC
+++ b/sys/arch/arm64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.286 2024/03/25 17:24:03 patrick Exp $
+# $OpenBSD: GENERIC,v 1.287 2024/07/30 19:47:05 mglocker Exp $
#
# GENERIC machine description file
#
@@ -46,6 +46,7 @@ acpiec* at acpi?
acpige* at acpi?
acpimcfg* at acpi?
acpiiort* at acpi?
+acpisectwo* at acpi?
smmu* at acpiiort?
acpipci* at acpi?
pci* at acpipci?
diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK
index c25a704337d..6cb8d2d7389 100644
--- a/sys/arch/arm64/conf/RAMDISK
+++ b/sys/arch/arm64/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.216 2024/03/25 17:24:03 patrick Exp $
+# $OpenBSD: RAMDISK,v 1.217 2024/07/30 19:47:05 mglocker Exp $
machine arm64
maxusers 4
@@ -41,6 +41,7 @@ acpi0 at mainbus?
acpiec* at acpi?
acpimcfg* at acpi?
acpiiort* at acpi?
+acpisectwo* at acpi?
smmu* at acpiiort?
acpipci* at acpi?
pci* at acpipci?
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 20aa4b9c2a0..29f84dd0343 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.435 2024/07/14 13:58:57 jmatthew Exp $ */
+/* $OpenBSD: acpi.c,v 1.436 2024/07/30 19:47:06 mglocker Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -95,6 +95,9 @@ int acpi_gpe(struct acpi_softc *, int, void *);
void acpi_enable_rungpes(struct acpi_softc *);
+#ifdef __arm64__
+int acpi_foundsectwo(struct aml_node *, void *);
+#endif
int acpi_foundec(struct aml_node *, void *);
int acpi_foundsony(struct aml_node *node, void *arg);
int acpi_foundhid(struct aml_node *, void *);
@@ -1231,6 +1234,10 @@ acpi_attach_common(struct acpi_softc *sc, paddr_t base)
/* initialize runtime environment */
aml_find_node(sc->sc_root, "_INI", acpi_inidev, sc);
+#ifdef __arm64__
+ aml_find_node(sc->sc_root, "ECTC", acpi_foundsectwo, sc);
+#endif
+
/* Get PCI mapping */
aml_walknodes(sc->sc_root, AML_WALK_PRE, acpi_getpci, sc);
@@ -2770,6 +2777,26 @@ acpi_create_thread(void *arg)
DEVNAME(sc));
}
+#if __arm64__
+int
+acpi_foundsectwo(struct aml_node *node, void *arg)
+{
+ struct acpi_softc *sc = (struct acpi_softc *)arg;
+ struct device *self = (struct device *)arg;
+ struct acpi_attach_args aaa;
+
+ memset(&aaa, 0, sizeof(aaa));
+ aaa.aaa_iot = sc->sc_iot;
+ aaa.aaa_memt = sc->sc_memt;
+ aaa.aaa_node = node->parent;
+ aaa.aaa_name = "acpisectwo";
+
+ config_found(self, &aaa, acpi_print);
+
+ return 0;
+}
+#endif
+
int
acpi_foundec(struct aml_node *node, void *arg)
{
diff --git a/sys/dev/acpi/acpisectwo.c b/sys/dev/acpi/acpisectwo.c
new file mode 100644
index 00000000000..b7f8f908b67
--- /dev/null
+++ b/sys/dev/acpi/acpisectwo.c
@@ -0,0 +1,90 @@
+/* $OpenBSD: acpisectwo.c,v 1.1 2024/07/30 19:47:06 mglocker Exp $ */
+/*
+ * Copyright (c) 2024 Marcus Glocker <mglocker@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/dsdt.h>
+
+//#define ACPISECTWO_DEBUG
+#ifdef ACPISECTWO_DEBUG
+#define DPRINTF(x) printf x
+#else
+#define DPRINTF(x)
+#endif
+
+#define ACPISECTWO_REGIONSPACE_BAT 0xa1
+
+struct acpisectwo_softc {
+ struct device sc_dev;
+ struct acpi_softc *sc_acpi;
+ struct aml_node *sc_node;
+};
+
+int acpisectwo_match(struct device *, void *, void *);
+void acpisectwo_attach(struct device *, struct device *, void *);
+
+const struct cfattach acpisectwo_ca = {
+ sizeof(struct acpisectwo_softc), acpisectwo_match, acpisectwo_attach
+};
+
+struct cfdriver acpisectwo_cd = {
+ NULL, "acpisectwo", DV_DULL
+};
+
+int acpisectwo_bat_opreg_handler(void *, int, uint64_t, int, uint64_t *);
+
+int
+acpisectwo_match(struct device *parent, void *match, void *aux)
+{
+ struct acpi_attach_args *aa = aux;
+ struct cfdata *cf = match;
+
+ if (aa->aaa_name == NULL ||
+ strcmp(aa->aaa_name, cf->cf_driver->cd_name) != 0 ||
+ aa->aaa_table != NULL)
+ return 0;
+
+ return 1;
+}
+
+void
+acpisectwo_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct acpisectwo_softc *sc = (struct acpisectwo_softc *)self;
+ struct acpi_attach_args *aa = aux;
+
+ printf("\n");
+
+ sc->sc_node = aa->aaa_node;
+
+ aml_register_regionspace(sc->sc_node, ACPISECTWO_REGIONSPACE_BAT, sc,
+ acpisectwo_bat_opreg_handler);
+}
+
+int
+acpisectwo_bat_opreg_handler(void *cookie, int iodir, uint64_t address,
+ int size, uint64_t *value)
+{
+ DPRINTF(("%s: iodir=%d, address=0x%llx, size=%d\n",
+ __func__, iodir, address, size));
+
+ *value = 0;
+
+ return 0;
+}
diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi
index 4036d6a19f6..f664ac350da 100644
--- a/sys/dev/acpi/files.acpi
+++ b/sys/dev/acpi/files.acpi
@@ -1,4 +1,4 @@
-# $OpenBSD: files.acpi,v 1.69 2023/04/23 00:20:26 dlg Exp $
+# $OpenBSD: files.acpi,v 1.70 2024/07/30 19:47:06 mglocker Exp $
#
# Config file and device description for machine-independent ACPI code.
# Included by ports that need it.
@@ -110,6 +110,11 @@ device acpitoshiba
attach acpitoshiba at acpi
file dev/acpi/acpitoshiba.c acpitoshiba
+# Samsung EC2
+device acpisectwo
+attach acpisectwo at acpi
+file dev/acpi/acpisectwo.c acpisectwo
+
# Sony support
device acpisony
attach acpisony at acpi