Commit 0f4e25887dfb3b54b21430340c511f7fd54bc955
1 parent
995727850f
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
x86: acpi: Refactor acpi_resume()
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> Tested-by: Stefan Roese <sr@denx.de>
Showing 5 changed files with 33 additions and 12 deletions Side-by-side Diff
arch/x86/cpu/cpu.c
... | ... | @@ -208,10 +208,10 @@ |
208 | 208 | board_final_cleanup(); |
209 | 209 | |
210 | 210 | #if CONFIG_HAVE_ACPI_RESUME |
211 | - void *wake_vector = acpi_find_wakeup_vector(); | |
211 | + struct acpi_fadt *fadt = acpi_find_fadt(); | |
212 | 212 | |
213 | - if (wake_vector != NULL && gd->arch.prev_sleep_state == ACPI_S3) | |
214 | - acpi_resume(wake_vector); | |
213 | + if (fadt != NULL && gd->arch.prev_sleep_state == ACPI_S3) | |
214 | + acpi_resume(fadt); | |
215 | 215 | #endif |
216 | 216 | |
217 | 217 | write_tables(); |
arch/x86/include/asm/acpi_s3.h
... | ... | @@ -99,15 +99,16 @@ |
99 | 99 | */ |
100 | 100 | void chipset_clear_sleep_state(void); |
101 | 101 | |
102 | +struct acpi_fadt; | |
102 | 103 | /** |
103 | 104 | * acpi_resume() - Do ACPI S3 resume |
104 | 105 | * |
105 | 106 | * This calls U-Boot wake up assembly stub and jumps to OS's wake up vector. |
106 | 107 | * |
107 | - * @wake_vec: OS wake up vector | |
108 | + * @fadt: FADT table pointer in the ACPI table | |
108 | 109 | * @return: Never returns |
109 | 110 | */ |
110 | -void acpi_resume(void *wake_vec); | |
111 | +void acpi_resume(struct acpi_fadt *fadt); | |
111 | 112 | |
112 | 113 | #endif /* __ASSEMBLY__ */ |
113 | 114 |
arch/x86/include/asm/acpi_table.h
... | ... | @@ -328,6 +328,15 @@ |
328 | 328 | ulong write_acpi_tables(ulong start); |
329 | 329 | |
330 | 330 | /** |
331 | + * acpi_find_fadt() - find ACPI FADT table in the sytem memory | |
332 | + * | |
333 | + * This routine parses the ACPI table to locate the ACPI FADT table. | |
334 | + * | |
335 | + * @return: a pointer to the ACPI FADT table in the system memory | |
336 | + */ | |
337 | +struct acpi_fadt *acpi_find_fadt(void); | |
338 | + | |
339 | +/** | |
331 | 340 | * acpi_find_wakeup_vector() - find OS installed wake up vector address |
332 | 341 | * |
333 | 342 | * This routine parses the ACPI table to locate the wake up vector installed |
... | ... | @@ -335,5 +344,5 @@ |
335 | 344 | * |
336 | 345 | * @return: wake up vector address installed by the OS |
337 | 346 | */ |
338 | -void *acpi_find_wakeup_vector(void); | |
347 | +void *acpi_find_wakeup_vector(struct acpi_fadt *); |
arch/x86/lib/acpi_s3.c
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | |
7 | 7 | #include <common.h> |
8 | 8 | #include <asm/acpi_s3.h> |
9 | +#include <asm/acpi_table.h> | |
9 | 10 | #include <asm/post.h> |
10 | 11 | |
11 | 12 | static void asmlinkage (*acpi_do_wakeup)(void *vector) = (void *)WAKEUP_BASE; |
12 | 13 | |
... | ... | @@ -19,8 +20,12 @@ |
19 | 20 | acpi_do_wakeup(vector); |
20 | 21 | } |
21 | 22 | |
22 | -void acpi_resume(void *wake_vec) | |
23 | +void acpi_resume(struct acpi_fadt *fadt) | |
23 | 24 | { |
25 | + void *wake_vec; | |
26 | + | |
27 | + wake_vec = acpi_find_wakeup_vector(fadt); | |
28 | + | |
24 | 29 | post_code(POST_OS_RESUME); |
25 | 30 | acpi_jump_to_wakeup(wake_vec); |
26 | 31 | } |
arch/x86/lib/acpi_table.c
... | ... | @@ -460,18 +460,14 @@ |
460 | 460 | return rsdp; |
461 | 461 | } |
462 | 462 | |
463 | -void *acpi_find_wakeup_vector(void) | |
463 | +struct acpi_fadt *acpi_find_fadt(void) | |
464 | 464 | { |
465 | 465 | char *p, *end; |
466 | 466 | struct acpi_rsdp *rsdp = NULL; |
467 | 467 | struct acpi_rsdt *rsdt; |
468 | 468 | struct acpi_fadt *fadt = NULL; |
469 | - struct acpi_facs *facs; | |
470 | - void *wake_vec; | |
471 | 469 | int i; |
472 | 470 | |
473 | - debug("Trying to find the wakeup vector...\n"); | |
474 | - | |
475 | 471 | /* Find RSDP */ |
476 | 472 | for (p = (char *)ROM_TABLE_ADDR; p < (char *)ROM_TABLE_END; p += 16) { |
477 | 473 | rsdp = acpi_valid_rsdp((struct acpi_rsdp *)p); |
... | ... | @@ -499,6 +495,16 @@ |
499 | 495 | return NULL; |
500 | 496 | |
501 | 497 | debug("FADT found at %p\n", fadt); |
498 | + return fadt; | |
499 | +} | |
500 | + | |
501 | +void *acpi_find_wakeup_vector(struct acpi_fadt *fadt) | |
502 | +{ | |
503 | + struct acpi_facs *facs; | |
504 | + void *wake_vec; | |
505 | + | |
506 | + debug("Trying to find the wakeup vector...\n"); | |
507 | + | |
502 | 508 | facs = (struct acpi_facs *)fadt->firmware_ctrl; |
503 | 509 | |
504 | 510 | if (facs == NULL) { |