[PATCH v3 04/16] acpi: Create a new Kconfig for ACPI

Simon Glass sjg at chromium.org
Mon Mar 27 06:15:38 CEST 2023


We have several Kconfig options for ACPI, but all relate to specific
functions, such as generating tables and AML code.

Add a new option which controls including basic ACPI library code,
including the lib/acpi directory. This will allow us to add functions
which are available even if table generation is not supported.

Adjust the command to avoid a build error when ACPIGEN is not enabled.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v3:
- Don't enable ACPI by default except on x86 and sandbox

Changes in v2:
- Add new patch to create a new Kconfig for ACPI

 arch/Kconfig         |  2 ++
 cmd/Kconfig          |  2 +-
 cmd/acpi.c           |  4 ++++
 drivers/core/Kconfig |  1 +
 lib/Kconfig          | 10 +++++++++-
 lib/Makefile         |  2 +-
 lib/acpi/Makefile    |  4 ++++
 7 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index d30676ae817b..e4831aeaa075 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -194,6 +194,7 @@ config SANDBOX
 	imply PHYLIB
 	imply DM_MDIO
 	imply DM_MDIO_MUX
+	imply ACPI
 	imply ACPI_PMC
 	imply ACPI_PMC_SANDBOX
 	imply CMD_PMC
@@ -260,6 +261,7 @@ config X86
 	imply PCH
 	imply PHYSMEM
 	imply RTC_MC146818
+	imply ACPI
 	imply ACPIGEN if !QEMU && !EFI_APP
 	imply SYSINFO if GENERATE_SMBIOS_TABLE
 	imply SYSINFO_SMBIOS if GENERATE_SMBIOS_TABLE
diff --git a/cmd/Kconfig b/cmd/Kconfig
index ba5ec69293fd..1bffbe2e2ba0 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -109,7 +109,7 @@ menu "Info commands"
 
 config CMD_ACPI
 	bool "acpi"
-	depends on ACPIGEN
+	depends on ACPI
 	default y
 	help
 	  List and dump ACPI tables. ACPI (Advanced Configuration and Power
diff --git a/cmd/acpi.c b/cmd/acpi.c
index d0fc062ef8cb..991b5235e289 100644
--- a/cmd/acpi.c
+++ b/cmd/acpi.c
@@ -162,6 +162,10 @@ static int do_acpi_items(struct cmd_tbl *cmdtp, int flag, int argc,
 	bool dump_contents;
 
 	dump_contents = argc >= 2 && !strcmp("-d", argv[1]);
+	if (!IS_ENABLED(CONFIG_ACPIGEN)) {
+		printf("Not supported (enable ACPIGEN)\n");
+		return CMD_RET_FAILURE;
+	}
 	acpi_dump_items(dump_contents ? ACPI_DUMP_CONTENTS : ACPI_DUMP_LIST);
 
 	return 0;
diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 0f755aa702ee..f0d848f45d8e 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -448,6 +448,7 @@ config OFNODE_MULTI_TREE_MAX
 
 config ACPIGEN
 	bool "Support ACPI table generation in driver model"
+	depends on ACPI
 	default y if SANDBOX || (GENERATE_ACPI_TABLE && !QEMU)
 	select LIB_UUID
 	help
diff --git a/lib/Kconfig b/lib/Kconfig
index 4278b2405546..475797d9b391 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -281,9 +281,17 @@ config SUPPORT_ACPI
 	  U-Boot can generate these tables and pass them to the Operating
 	  System.
 
+config ACPI
+	bool "Enable support for ACPI libraries"
+	depends on SUPPORT_ACPI
+	help
+	  Provides library functions for dealing with ACPI tables. This does
+	  not necessarily include generation of tables
+	  (see GENERATE_ACPI_TABLE), but allows for tables to be located.
+
 config GENERATE_ACPI_TABLE
 	bool "Generate an ACPI (Advanced Configuration and Power Interface) table"
-	depends on SUPPORT_ACPI
+	depends on ACPI
 	select QFW if QEMU
 	help
 	  The Advanced Configuration and Power Interface (ACPI) specification
diff --git a/lib/Makefile b/lib/Makefile
index 10aa7ac02985..8d8ccc8bbc39 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -66,7 +66,7 @@ obj-$(CONFIG_$(SPL_TPL_)CRC8) += crc8.o
 
 obj-y += crypto/
 
-obj-$(CONFIG_$(SPL_TPL_)GENERATE_ACPI_TABLE) += acpi/
+obj-$(CONFIG_$(SPL_TPL_)ACPI) += acpi/
 obj-$(CONFIG_$(SPL_)MD5) += md5.o
 obj-$(CONFIG_ECDSA) += ecdsa/
 obj-$(CONFIG_$(SPL_)RSA) += rsa/
diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile
index 956b5a0d7265..12337abaecfa 100644
--- a/lib/acpi/Makefile
+++ b/lib/acpi/Makefile
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+ifdef CONFIG_$(SPL_TPL_)GENERATE_ACPI_TABLE
+
 obj-$(CONFIG_$(SPL_)ACPIGEN) += acpigen.o
 obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi_device.o
 obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi_dp.o
@@ -21,3 +23,5 @@ endif
 obj-y += facs.o
 obj-y += ssdt.o
 endif
+
+endif # GENERATE_ACPI_TABLE
-- 
2.40.0.348.gf938b09366-goog



More information about the U-Boot mailing list