From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] misc: add ACPI test driver
Date: Wed, 4 Dec 2019 15:07:21 +0100 [thread overview]
Message-ID: <20191204140721.20299-3-ahmad@a3f.at> (raw)
In-Reply-To: <20191204140721.20299-1-ahmad@a3f.at>
We have a bus driver for ACPI, but no drivers yet. Add a simple (rather
useless) driver that exercises the API, which future drivers can be
based on. As soon as we have proper ACPI drivers, this driver could be
removed again.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
drivers/misc/Kconfig | 6 ++++
drivers/misc/Makefile | 1 +
drivers/misc/acpi-test.c | 61 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
create mode 100644 drivers/misc/acpi-test.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 0f736f8bded3..b76198b10af5 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 bc1c01ea4d67..4d92465a1e5e 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 000000000000..970b435a0eec
--- /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);
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-12-04 14:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 14:07 [PATCH 0/2] bus: efi: add basic ACPI bus infrastructure Ahmad Fatoum
2019-12-04 14:07 ` [PATCH 1/2] " Ahmad Fatoum
2019-12-04 14:07 ` Ahmad Fatoum [this message]
2019-12-04 14:27 ` [PATCH 0/2] " Ahmad Fatoum
2019-12-09 10:39 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191204140721.20299-3-ahmad@a3f.at \
--to=ahmad@a3f.at \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox