summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/Kconfig6
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/acpi-test.c61
3 files changed, 68 insertions, 0 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 0f736f8bde..b76198b10a 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -35,4 +35,10 @@ config UBOOTVAR
While it can be used standalone, it is best when coupled
with corresponding filesystem driver.
+config ACPI_TEST
+ bool "ACPI Test driver"
+ depends on ACPI
+ help
+ This is a simple Test driver to test the ACPI bus.
+
endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index bc1c01ea4d..4d92465a1e 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_SRAM) += sram.o
obj-$(CONFIG_STATE_DRV) += state.o
obj-$(CONFIG_DEV_MEM) += mem.o
obj-$(CONFIG_UBOOTVAR) += ubootvar.o
+obj-$(CONFIG_ACPI_TEST) += acpi-test.o
diff --git a/drivers/misc/acpi-test.c b/drivers/misc/acpi-test.c
new file mode 100644
index 0000000000..970b435a0e
--- /dev/null
+++ b/drivers/misc/acpi-test.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019 Ahmad Fatoum
+ */
+
+#include <common.h>
+#include <init.h>
+#include <acpi.h>
+
+static const char *profiles[] = {
+ "Unspecified",
+ "Desktop",
+ "Mobile",
+ "Workstation",
+ "Enterprise Server",
+ "SOHO Server",
+ "Applicance PC",
+ "Performance Server",
+ "Tablet",
+};
+
+static int acpi_test_probe(struct device_d *dev)
+{
+ const char *profile = "reserved";
+ u8 *sdt;
+ u8 profileno;
+
+ dev_dbg(dev, "driver initializing...\n");
+
+ sdt = (u8 __force *)dev_request_mem_region_by_name(dev, "SDT");
+ if (IS_ERR(sdt)) {
+ dev_err(dev, "no SDT resource available: %s\n", strerrorp(sdt));
+ return PTR_ERR(sdt);
+ }
+
+ dev_dbg(dev, "SDT is at 0x%p\n", sdt);
+
+ profileno = sdt[45];
+
+ if (profileno < ARRAY_SIZE(profiles))
+ profile = profiles[profileno];
+
+ dev_info(dev, "PM profile is for '%s'\n", profile);
+
+ return 0;
+}
+
+static void acpi_test_remove(struct device_d *dev)
+{
+ dev_info(dev, "FADT driver removed\n");
+}
+
+static struct acpi_driver acpi_test_driver = {
+ .signature = "FACP",
+ .driver = {
+ .name = "acpi-test",
+ .probe = acpi_test_probe,
+ .remove = acpi_test_remove,
+ }
+};
+device_acpi_driver(acpi_test_driver);