public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v3 11/57] acpi: Add support for writing a _PRW
Date: Sun,  6 Sep 2020 15:43:19 -0600	[thread overview]
Message-ID: <20200906214405.71632-2-sjg@chromium.org> (raw)
In-Reply-To: <20200906214405.71632-1-sjg@chromium.org>

A 'Power Resource for Wake' list the resources a device depends on for
wake. Add a function to generate this.

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

(no changes since v1)

 include/acpi/acpigen.h | 10 ++++++++++
 lib/acpi/acpigen.c     | 10 ++++++++++
 test/dm/acpigen.c      | 30 ++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)

diff --git a/include/acpi/acpigen.h b/include/acpi/acpigen.h
index 228ac9c404b..a9b70123c0a 100644
--- a/include/acpi/acpigen.h
+++ b/include/acpi/acpigen.h
@@ -563,4 +563,14 @@ int acpigen_set_enable_tx_gpio(struct acpi_ctx *ctx, u32 tx_state_val,
 			       const char *dw0_read, const char *dw0_write,
 			       struct acpi_gpio *gpio, bool enable);
 
+/**
+ * acpigen_write_prw() - Write a power resource for wake (_PRW)
+ *
+ * @ctx: ACPI context pointer
+ * @wake: GPE that wakes up the device
+ * @level: Deepest power system sleeping state that can be entered while still
+ *	providing wake functionality
+ */
+void acpigen_write_prw(struct acpi_ctx *ctx, uint wake, uint level);
+
 #endif
diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c
index c609ef4daa4..527de89b1e1 100644
--- a/lib/acpi/acpigen.c
+++ b/lib/acpi/acpigen.c
@@ -426,6 +426,16 @@ void acpigen_write_register_resource(struct acpi_ctx *ctx,
 	acpigen_write_resourcetemplate_footer(ctx);
 }
 
+void acpigen_write_prw(struct acpi_ctx *ctx, uint wake, uint level)
+{
+	/* Name (_PRW, Package () { wake, level } */
+	acpigen_write_name(ctx, "_PRW");
+	acpigen_write_package(ctx, 2);
+	acpigen_write_integer(ctx, wake);
+	acpigen_write_integer(ctx, level);
+	acpigen_pop_len(ctx);
+}
+
 /*
  * ToUUID(uuid)
  *
diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c
index 1b2767e732d..16ae7025856 100644
--- a/test/dm/acpigen.c
+++ b/test/dm/acpigen.c
@@ -1097,3 +1097,33 @@ static int dm_test_acpi_write_name(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_acpi_write_name, 0);
+
+/* Test emitting a string */
+static int dm_test_acpi_write_prw(struct unit_test_state *uts)
+{
+	struct acpi_ctx *ctx;
+	u8 *ptr;
+
+	ut_assertok(alloc_context(&ctx));
+
+	ptr = acpigen_get_current(ctx);
+	acpigen_write_prw(ctx, 5, 3);
+	ut_asserteq(NAME_OP, *ptr++);
+
+	ut_asserteq_strn("_PRW", (char *)ptr);
+	ptr += 4;
+	ut_asserteq(PACKAGE_OP, *ptr++);
+	ut_asserteq(8, acpi_test_get_length(ptr));
+	ptr += 3;
+	ut_asserteq(2, *ptr++);
+	ut_asserteq(BYTE_PREFIX, *ptr++);
+	ut_asserteq(5, *ptr++);
+	ut_asserteq(BYTE_PREFIX, *ptr++);
+	ut_asserteq(3, *ptr++);
+	ut_asserteq_ptr(ptr, ctx->current);
+
+	free_context(&ctx);
+
+	return 0;
+}
+DM_TEST(dm_test_acpi_write_prw, 0);
-- 
2.28.0.526.ge36021eeef-goog

  parent reply	other threads:[~2020-09-06 21:43 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-06 21:43 [PATCH v3 00/57] dm: Add programatic generation of ACPI tables (part D) Simon Glass
2020-09-06 21:43 ` [PATCH v3 01/57] x86: acpi: Add cros_ec tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices Simon Glass
2020-09-21 13:50   ` Wolfgang Wallner
2020-09-22 13:51     ` Simon Glass
2020-09-22 14:19       ` Wolfgang Wallner
2020-09-22 14:30         ` Bin Meng
2020-09-22 14:47           ` Wolfgang Wallner
2020-09-22 14:52             ` Bin Meng
2020-09-06 21:43 ` [PATCH v3 03/57] x86: acpi: apl: Add asl files for Apollo Lake Simon Glass
2020-09-06 21:43 ` [PATCH v3 04/57] x86: acpi: Add DPTF asl files Simon Glass
2020-09-06 21:43 ` [PATCH v3 05/57] x86: apl: Correct PCIE_ECAM_BASE Simon Glass
2020-09-22  7:30   ` Bin Meng
2020-09-06 21:43 ` [PATCH v3 06/57] x86: Add a config for the systemagent PCIEX regions size Simon Glass
2020-09-06 21:43 ` [PATCH v3 07/57] x86: Add a common global NVS structure Simon Glass
2020-09-06 21:43 ` [PATCH v3 08/57] x86: acpi: Support external GNVS tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 09/57] x86: acpi: Expand the GNVS Simon Glass
2020-09-06 21:43 ` [PATCH v3 10/57] x86: coral: Add ACPI tables for coral Simon Glass
2020-09-06 21:43 ` Simon Glass [this message]
2020-09-06 21:43 ` [PATCH v3 12/57] acpi: Add support for conditions and return values Simon Glass
2020-09-06 21:43 ` [PATCH v3 13/57] acpi: Support generating a multi-function _DSM for devices Simon Glass
2020-09-06 21:43 ` [PATCH v3 14/57] dm: acpi: Use correct GPIO polarity type in acpi_dp_add_gpio() Simon Glass
2020-09-06 21:43 ` [PATCH v3 15/57] x86: link: Allow more space for U-Boot Simon Glass
2020-09-22  7:44   ` Bin Meng
2020-09-06 21:43 ` [PATCH v3 16/57] i2c: Add a generic driver to generate ACPI info Simon Glass
2020-09-06 21:43 ` [PATCH v3 17/57] x86: Add wake sources for the acpi_gpe driver Simon Glass
2020-09-06 21:43 ` [PATCH v3 18/57] x86: apl: Support writing the IntelGraphicsMem table Simon Glass
2020-09-06 21:43 ` [PATCH v3 19/57] x86: acpi: Add a common routine to write WiFi info Simon Glass
2020-09-06 21:43 ` [PATCH v3 20/57] x86: Add some definitions for SMM Simon Glass
2020-09-06 21:43 ` [PATCH v3 21/57] x86: apl: Add power-management definitions Simon Glass
2020-09-06 21:43 ` [PATCH v3 22/57] x86: apl: Update iomap for ACPI Simon Glass
2020-09-06 21:43 ` [PATCH v3 23/57] x86: Add a few common Intel CPU functions Simon Glass
2020-09-06 21:43 ` [PATCH v3 24/57] x86: acpi: Support generation of the HPET table Simon Glass
2020-09-06 21:43 ` [PATCH v3 25/57] x86: acpi: Support generation of the DBG2 table Simon Glass
2020-09-06 21:43 ` [PATCH v3 26/57] acpi: Add support for generating processor tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 27/57] x86: acpi: Add PCT and PTC tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 28/57] acpi: Add more support for generating processor tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 29/57] x86: acpi: Add common Intel ACPI tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 30/57] x86: Support Atom SoCs using SWSMISCI rather than the SWSCI Simon Glass
2020-09-06 21:43 ` [PATCH v3 31/57] x86: acpi: Add support for additional Intel tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 32/57] x86: apl: Allow reading hostbridge base addresses Simon Glass
2020-09-06 21:43 ` [PATCH v3 33/57] p2sb: Add some definitions used for ACPI Simon Glass
2020-09-06 21:43 ` [PATCH v3 34/57] x86: apl: Generate required ACPI tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 35/57] x86: apl: Add support for hostbridge ACPI generation Simon Glass
2020-09-06 21:43 ` [PATCH v3 36/57] x86: apl: Generate CPU tables Simon Glass
2020-09-06 21:43 ` [PATCH v3 37/57] x86: apl: Generate ACPI table for LPC Simon Glass
2020-09-06 21:43 ` [PATCH v3 38/57] x86: apl: Drop unnecessary code in PMC driver Simon Glass
2020-09-06 21:43 ` [PATCH v3 39/57] tpm: cr50: Add ACPI support Simon Glass
2020-09-21 11:50   ` Andy Shevchenko
2020-09-21 11:53     ` Andy Shevchenko
2020-09-22  8:15     ` Bin Meng
2020-09-22  8:27     ` Andy Shevchenko
2020-09-06 21:43 ` [PATCH v3 40/57] x86: fsp: Update the FSP API with the end-firmware method Simon Glass
2020-09-22  7:58   ` Bin Meng
2020-09-06 21:43 ` [PATCH v3 41/57] x86: cpu: Report address width from cpu_get_info() Simon Glass
2020-09-06 21:43 ` [PATCH v3 42/57] x86: Sort the MTRR table Simon Glass
2020-09-06 21:43 ` [PATCH v3 43/57] x86: Notify the FSP of the 'end firmware' event Simon Glass
2020-09-06 21:43 ` [PATCH v3 44/57] x86: Correct the assembly guard in e820.h Simon Glass
2020-09-22  8:02   ` Bin Meng
2020-09-06 21:43 ` [PATCH v3 45/57] x86: Add a header guard to asm/acpi_table.h Simon Glass
2020-09-22  8:03   ` Bin Meng
2020-09-06 21:43 ` [PATCH v3 46/57] x86: Correct handling of MADT table CPUs Simon Glass
2020-09-06 21:43 ` [PATCH v3 47/57] acpi: tpm: Add a TPM2 table Simon Glass
2020-09-06 21:43 ` [PATCH v3 48/57] acpi: tpm: Add a TPM1 table Simon Glass
2020-09-06 21:43 ` [PATCH v3 49/57] x86: acpi: Set the log category for x86 table generation Simon Glass
2020-09-22  8:04   ` Bin Meng
2020-09-06 21:43 ` [PATCH v3 50/57] x86: coral: Add audio descriptor files Simon Glass
2020-09-06 21:43 ` [PATCH v3 51/57] x86: apl: Check low-level init in FSP-S pre-init Simon Glass
2020-09-06 21:44 ` [PATCH v3 52/57] x86: fsp: Add more debugging for silicon init Simon Glass
2020-09-22  8:06   ` Bin Meng
2020-09-06 21:44 ` [PATCH v3 53/57] x86: fsp: Show FSP-S or FSP-M address in fsp_get_header() Simon Glass
2020-09-22  8:06   ` Bin Meng
2020-09-06 21:44 ` [PATCH v3 54/57] acpi: Use defines for field lengths Simon Glass
2020-09-22  8:07   ` Bin Meng
2020-09-06 21:44 ` [PATCH v3 55/57] x86: Add a way to add to the e820 memory table Simon Glass
2020-09-22  8:09   ` Bin Meng
2020-09-06 21:44 ` [PATCH v3 56/57] x86: Move include of bitops out of ACPI region Simon Glass
2020-09-22  8:09   ` Bin Meng
2020-09-06 21:44 ` [PATCH v3 57/57] x86: coral: Update config and device tree for ACPI Simon Glass
2020-09-22  8:16 ` [PATCH v3 00/57] dm: Add programatic generation of ACPI tables (part D) Bin Meng

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=20200906214405.71632-2-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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