
On Mon, Jan 27, 2020 at 1:08 PM Simon Glass sjg@chromium.org wrote:
ACPI (Advanced Configuration and Power Interface) is an Intel standard for specifying information about a platform. It is a little like device tree but considerably more complicated and with more backslashes. A primary difference is that it supports an interpreted bytecode language.
Driver model does not use ACPI for U-Boot's configuration, but it is convenient to have it support generation of ACPI tables for passing to Linux, etc.
As a starting point, add an optional set of ACPI operations to each device. Initially only a single operation is available, to obtain the ACPI name for the device. More operations are added later.
Enable ACPI for sandbox to ensure build coverage and so that we can add tests.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/core/Kconfig | 9 ++++++ drivers/core/Makefile | 1 + drivers/core/acpi.c | 32 +++++++++++++++++++ include/dm/acpi.h | 73 +++++++++++++++++++++++++++++++++++++++++++ include/dm/device.h | 5 +++ 5 files changed, 120 insertions(+) create mode 100644 drivers/core/acpi.c create mode 100644 include/dm/acpi.h
diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index 3b95b5387b..a3b0399342 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -261,4 +261,13 @@ config DM_DEV_READ_INLINE bool default y if !OF_LIVE
+config ACPIGEN
bool "Support ACPI table generation in driver model"
default y if SANDBOX || GENERATE_ACPI_TABLE
help
This option enables generation of ACPI tables using driver-model
devices. It adds a new operation struct to each driver, to support
things like generating device-specific tables and returning the ACPI
name of a device.
endmenu diff --git a/drivers/core/Makefile b/drivers/core/Makefile index bce7467da1..c707026a3a 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -3,6 +3,7 @@ # Copyright (c) 2013 Google, Inc
obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o +obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c new file mode 100644 index 0000000000..45542199f5 --- /dev/null +++ b/drivers/core/acpi.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Core driver model support for ACPI table generation
- Copyright 2019 Google LLC
- Written by Simon Glass sjg@chromium.org
- */
+#define LOG_CATEOGRY LOGC_ACPI
Need add this to log.h
+#include <common.h> +#include <dm.h> +#include <dm/acpi.h> +#include <dm/root.h>
Other than that, Reviewed-by: Bin Meng bmeng.cn@gmail.com