[U-Boot,v2,17/22] x86: acpi: Refactor acpi_resume()

Submitted by Bin Meng on April 21, 2017, 2:24 p.m.

Details

Message ID 1492784689-15701-18-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Bin Meng
Headers show

Commit Message

Bin Meng April 21, 2017, 2:24 p.m.
To do something more in acpi_resume() like turning on ACPI mode,
we need locate ACPI FADT table pointer first. But currently this
is done in acpi_find_wakeup_vector().

This changes acpi_resume() signature to accept ACPI FADT pointer
as the parameter. A new API acpi_find_fadt() is introduced, and
acpi_find_wakeup_vector() is updated to use FADT pointer as the
parameter as well.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

---

Changes in v2:
- add a function comment block for acpi_find_fadt()

 arch/x86/cpu/cpu.c                |  6 +++---
 arch/x86/include/asm/acpi_s3.h    |  5 +++--
 arch/x86/include/asm/acpi_table.h | 11 ++++++++++-
 arch/x86/lib/acpi_s3.c            |  7 ++++++-
 arch/x86/lib/acpi_table.c         | 16 +++++++++++-----
 5 files changed, 33 insertions(+), 12 deletions(-)

Comments

Bin Meng April 26, 2017, 7:35 a.m.
On Fri, Apr 21, 2017 at 10:24 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> To do something more in acpi_resume() like turning on ACPI mode,
> we need locate ACPI FADT table pointer first. But currently this
> is done in acpi_find_wakeup_vector().
>
> This changes acpi_resume() signature to accept ACPI FADT pointer
> as the parameter. A new API acpi_find_fadt() is introduced, and
> acpi_find_wakeup_vector() is updated to use FADT pointer as the
> parameter as well.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> ---
>
> Changes in v2:
> - add a function comment block for acpi_find_fadt()
>
>  arch/x86/cpu/cpu.c                |  6 +++---
>  arch/x86/include/asm/acpi_s3.h    |  5 +++--
>  arch/x86/include/asm/acpi_table.h | 11 ++++++++++-
>  arch/x86/lib/acpi_s3.c            |  7 ++++++-
>  arch/x86/lib/acpi_table.c         | 16 +++++++++++-----
>  5 files changed, 33 insertions(+), 12 deletions(-)
>

applied to u-boot-x86/next, thanks!

Patch hide | download patch | download mbox

diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index c9fc7e4..dfe624f 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -208,10 +208,10 @@  int last_stage_init(void)
 	board_final_cleanup();
 
 #if CONFIG_HAVE_ACPI_RESUME
-	void *wake_vector = acpi_find_wakeup_vector();
+	struct acpi_fadt *fadt = acpi_find_fadt();
 
-	if (wake_vector != NULL && gd->arch.prev_sleep_state == ACPI_S3)
-		acpi_resume(wake_vector);
+	if (fadt != NULL && gd->arch.prev_sleep_state == ACPI_S3)
+		acpi_resume(fadt);
 #endif
 
 	write_tables();
diff --git a/arch/x86/include/asm/acpi_s3.h b/arch/x86/include/asm/acpi_s3.h
index b8d14f4..1ad20f4 100644
--- a/arch/x86/include/asm/acpi_s3.h
+++ b/arch/x86/include/asm/acpi_s3.h
@@ -99,15 +99,16 @@  enum acpi_sleep_state chipset_prev_sleep_state(void);
  */
 void chipset_clear_sleep_state(void);
 
+struct acpi_fadt;
 /**
  * acpi_resume() - Do ACPI S3 resume
  *
  * This calls U-Boot wake up assembly stub and jumps to OS's wake up vector.
  *
- * @wake_vec:	OS wake up vector
+ * @fadt:	FADT table pointer in the ACPI table
  * @return:	Never returns
  */
-void acpi_resume(void *wake_vec);
+void acpi_resume(struct acpi_fadt *fadt);
 
 #endif /* __ASSEMBLY__ */
 
diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h
index e96409b..dd7a946 100644
--- a/arch/x86/include/asm/acpi_table.h
+++ b/arch/x86/include/asm/acpi_table.h
@@ -328,6 +328,15 @@  void enter_acpi_mode(int pm1_cnt);
 ulong write_acpi_tables(ulong start);
 
 /**
+ * acpi_find_fadt() - find ACPI FADT table in the sytem memory
+ *
+ * This routine parses the ACPI table to locate the ACPI FADT table.
+ *
+ * @return:	a pointer to the ACPI FADT table in the system memory
+ */
+struct acpi_fadt *acpi_find_fadt(void);
+
+/**
  * acpi_find_wakeup_vector() - find OS installed wake up vector address
  *
  * This routine parses the ACPI table to locate the wake up vector installed
@@ -335,4 +344,4 @@  ulong write_acpi_tables(ulong start);
  *
  * @return:	wake up vector address installed by the OS
  */
-void *acpi_find_wakeup_vector(void);
+void *acpi_find_wakeup_vector(struct acpi_fadt *);
diff --git a/arch/x86/lib/acpi_s3.c b/arch/x86/lib/acpi_s3.c
index f679c06..e5cc3b0 100644
--- a/arch/x86/lib/acpi_s3.c
+++ b/arch/x86/lib/acpi_s3.c
@@ -6,6 +6,7 @@ 
 
 #include <common.h>
 #include <asm/acpi_s3.h>
+#include <asm/acpi_table.h>
 #include <asm/post.h>
 
 static void asmlinkage (*acpi_do_wakeup)(void *vector) = (void *)WAKEUP_BASE;
@@ -19,8 +20,12 @@  static void acpi_jump_to_wakeup(void *vector)
 	acpi_do_wakeup(vector);
 }
 
-void acpi_resume(void *wake_vec)
+void acpi_resume(struct acpi_fadt *fadt)
 {
+	void *wake_vec;
+
+	wake_vec = acpi_find_wakeup_vector(fadt);
+
 	post_code(POST_OS_RESUME);
 	acpi_jump_to_wakeup(wake_vec);
 }
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index 87a71ca..01d5b6f 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -460,18 +460,14 @@  static struct acpi_rsdp *acpi_valid_rsdp(struct acpi_rsdp *rsdp)
 	return rsdp;
 }
 
-void *acpi_find_wakeup_vector(void)
+struct acpi_fadt *acpi_find_fadt(void)
 {
 	char *p, *end;
 	struct acpi_rsdp *rsdp = NULL;
 	struct acpi_rsdt *rsdt;
 	struct acpi_fadt *fadt = NULL;
-	struct acpi_facs *facs;
-	void *wake_vec;
 	int i;
 
-	debug("Trying to find the wakeup vector...\n");
-
 	/* Find RSDP */
 	for (p = (char *)ROM_TABLE_ADDR; p < (char *)ROM_TABLE_END; p += 16) {
 		rsdp = acpi_valid_rsdp((struct acpi_rsdp *)p);
@@ -499,6 +495,16 @@  void *acpi_find_wakeup_vector(void)
 		return NULL;
 
 	debug("FADT found at %p\n", fadt);
+	return fadt;
+}
+
+void *acpi_find_wakeup_vector(struct acpi_fadt *fadt)
+{
+	struct acpi_facs *facs;
+	void *wake_vec;
+
+	debug("Trying to find the wakeup vector...\n");
+
 	facs = (struct acpi_facs *)fadt->firmware_ctrl;
 
 	if (facs == NULL) {