summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2022-01-27 14:14:47 -0500
committerTom Rini <[email protected]>2022-01-27 14:14:47 -0500
commit761a1786e125ce0e2f472f25f2b841d5f4e2f0cb (patch)
tree39f5349498ded95ab427bbde2dd8ff2f633303de /include/dm
parent9a1dd6dcfefc56c05ee7f7249faaa97c5f937fbc (diff)
parent2d2384bbaff0ab84c868b553c74048a5f6acc9e3 (diff)
Merge tag 'dm-pull-26jan22' of https://source.denx.de/u-boot/custodians/u-boot-dm
acpi refactoring to allow non-x86 use binman support for bintools (binary tools) minor tools improvements in preparation for FDT signing various minor fixes and improvements
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/acpi.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/include/dm/acpi.h b/include/dm/acpi.h
index 0fa239eb3a8..3adfe217678 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;
@@ -43,10 +45,15 @@ enum acpi_dump_option {
*
* @base: Base address of ACPI tables
* @current: Current address for writing
+ * @tab_start: Address of start of the table being written. This is set up
+ * before the writer or driver method is called. It must not be changed by the
+ * method
* @rsdp: Pointer to the Root System Description Pointer, typically used when
* adding a new table. The RSDP holds pointers to the RSDT and XSDT.
* @rsdt: Pointer to the Root System Description Table
* @xsdt: Pointer to the Extended System Description Table
+ * @facs: Pointer to the Firmware ACPI Control Structure
+ * @dsdt: Pointer to the Differentiated System Description Table
* @nhlt: Intel Non-High-Definition-Audio Link Table (NHLT) pointer, used to
* build up information that audio codecs need to provide in the NHLT ACPI
* table
@@ -56,15 +63,66 @@ enum acpi_dump_option {
struct acpi_ctx {
void *base;
void *current;
+ void *tab_start;
struct acpi_rsdp *rsdp;
struct acpi_rsdt *rsdt;
struct acpi_xsdt *xsdt;
+ struct acpi_facs *facs;
+ struct acpi_table_header *dsdt;
struct nhlt *nhlt;
char *len_stack[ACPIGEN_LENSTACK_SIZE];
int ltop;
};
/**
+ * enum acpi_writer_flags_t - flags to use for the ACPI writers
+ *
+ * ACPIWF_ALIGN64 - align to 64 bytes after writing this one (default is 16)
+ */
+enum acpi_writer_flags_t {
+ ACPIWF_ALIGN64 = 1 << 0,
+};
+
+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, \
+ }
+
+/* Get a pointer to a given ACPI-table writer */
+#define ACPI_WRITER_GET(_name) \
+ ll_entry_get(struct acpi_writer, _name, acpi_writer)
+
+/**
* struct acpi_ops - ACPI operations supported by driver model
*/
struct acpi_ops {
@@ -205,6 +263,20 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx);
int acpi_setup_nhlt(struct acpi_ctx *ctx, struct nhlt *nhlt);
/**
+ * acpi_add_other_item() - Add a new table to the list of ACPI tables
+ *
+ * This adds an entry of type ACPIT_TYPE_OTHER
+ *
+ * @ctx: ACPI context
+ * @writer: Writer entry that generated the data
+ * @type: Table type it refers to
+ * @start: The start of the data (the end is obtained from ctx->current)
+ * @return 0 if OK, -ENOSPC if too many items, -ENOMEM if out of memory
+ */
+int acpi_add_other_item(struct acpi_ctx *ctx, const struct acpi_writer *writer,
+ void *start);
+
+/**
* acpi_dump_items() - Dump out the collected ACPI items
*
* This lists the ACPI DSDT and SSDT items generated by the various U-Boot
@@ -236,6 +308,44 @@ 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);
+
+/**
+ * acpi_setup_ctx() - Set up a new ACPI context
+ *
+ * This zeros the context and sets up the base and current pointers, ensuring
+ * that they are aligned. Then it writes the acpi_start and acpi_ctx values in
+ * global_data
+ *
+ * @ctx: ACPI context to set up
+ * @start: Start address for ACPI table
+ */
+void acpi_setup_ctx(struct acpi_ctx *ctx, ulong start);
+
+/**
+ * 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