aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-12-01 09:02:47 -0700
committerSimon Glass <sjg@chromium.org>2022-01-25 11:44:36 -0700
commit6afa63a5a63662fa7e517b29da613f51e9e68429 (patch)
tree9b6852cab568303cc98ab6a6f0f6faa9f0d40a72 /include
parentfb746fdec6d58eacd7d9323eda7ccbde9419a41e (diff)
downloadu-boot-6afa63a5a63662fa7e517b29da613f51e9e68429.zip
u-boot-6afa63a5a63662fa7e517b29da613f51e9e68429.tar.gz
u-boot-6afa63a5a63662fa7e517b29da613f51e9e68429.tar.bz2
acpi: Add a linker list for ACPI tables
At present we call lots of functions to generate the required ACPI tables. It would be better to standardise these functions and allow them to be automatically collected and used when needed. Add a linker list to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/dm/acpi.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/include/dm/acpi.h b/include/dm/acpi.h
index a2da57f..2f52950 100644
--- a/include/dm/acpi.h
+++ b/include/dm/acpi.h
@@ -27,6 +27,8 @@
#if !defined(__ACPI__)
+#include <linker_lists.h>
+
struct nhlt;
struct udevice;
@@ -69,6 +71,48 @@ struct acpi_ctx {
};
/**
+ * enum acpi_writer_flags_t - flags to use for the ACPI writers
+ */
+enum acpi_writer_flags_t {
+ ACPIWF_ALIGN64_,
+};
+
+struct acpi_writer;
+
+/**
+ * acpi_writer_func() - Function that can write an ACPI table
+ *
+ * @ctx: ACPI context to use for writing
+ * @entry: Linker-list entry for this writer
+ * @return 0 if OK, -ve on error
+ */
+typedef int (*acpi_writer_func)(struct acpi_ctx *ctx,
+ const struct acpi_writer *entry);
+
+/**
+ * struct acpi_writer - an ACPI table that can be written
+ *
+ * @name: Name of the writer
+ * @table: Table name that is generated (e.g. "DSDT")
+ * @h_write: Writer function
+ */
+struct acpi_writer {
+ const char *name;
+ const char *table;
+ acpi_writer_func h_write;
+ int flags;
+};
+
+/* Declare a new ACPI table writer */
+#define ACPI_WRITER(_name, _table, _write, _flags) \
+ ll_entry_declare(struct acpi_writer, _name, acpi_writer) = { \
+ .name = #_name, \
+ .table = _table, \
+ .h_write = _write, \
+ .flags = _flags, \
+ }
+
+/**
* struct acpi_ops - ACPI operations supported by driver model
*/
struct acpi_ops {
@@ -240,6 +284,19 @@ int acpi_get_path(const struct udevice *dev, char *out_path, int maxlen);
*/
void acpi_reset_items(void);
+/**
+ * acpi_write_one() - Call a single ACPI writer entry
+ *
+ * This handles aligning the context afterwards, if the entry flags indicate
+ * that.
+ *
+ * @ctx: ACPI context to use
+ * @entry: Entry to call
+ * @return 0 if OK, -ENOENT if this writer produced an empty entry, other -ve
+ * value on error
+ */
+int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry);
+
#endif /* __ACPI__ */
#endif