Kyösti Mälkki | 4a3f67a | 2020-06-18 13:44:29 +0300 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpi.h> |
| 4 | #include <console/console.h> |
| 5 | #include <romstage_handoff.h> |
Kyösti Mälkki | e0d3868 | 2020-06-07 12:01:58 +0300 | [diff] [blame] | 6 | #include <smbios.h> |
Kyösti Mälkki | 4a3f67a | 2020-06-18 13:44:29 +0300 | [diff] [blame] | 7 | |
| 8 | /* This is filled with acpi_handoff_wakeup_s3() call early in ramstage. */ |
| 9 | static int acpi_slp_type = -1; |
| 10 | |
| 11 | static void acpi_handoff_wakeup(void) |
| 12 | { |
| 13 | if (acpi_slp_type < 0) { |
| 14 | if (romstage_handoff_is_resume()) { |
| 15 | printk(BIOS_DEBUG, "S3 Resume\n"); |
| 16 | acpi_slp_type = ACPI_S3; |
| 17 | } else { |
| 18 | printk(BIOS_DEBUG, "Normal boot\n"); |
| 19 | acpi_slp_type = ACPI_S0; |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | int acpi_handoff_wakeup_s3(void) |
| 25 | { |
| 26 | acpi_handoff_wakeup(); |
| 27 | return (acpi_slp_type == ACPI_S3); |
| 28 | } |
| 29 | |
| 30 | void __weak mainboard_suspend_resume(void) |
| 31 | { |
| 32 | } |
Kyösti Mälkki | e0d3868 | 2020-06-07 12:01:58 +0300 | [diff] [blame] | 33 | |
| 34 | /* Default mapping to ACPI FADT preferred_pm_profile field. */ |
| 35 | uint8_t acpi_get_preferred_pm_profile(void) |
| 36 | { |
| 37 | switch (smbios_mainboard_enclosure_type()) { |
| 38 | case SMBIOS_ENCLOSURE_LAPTOP: |
| 39 | case SMBIOS_ENCLOSURE_CONVERTIBLE: |
| 40 | return PM_MOBILE; |
| 41 | case SMBIOS_ENCLOSURE_DETACHABLE: |
| 42 | case SMBIOS_ENCLOSURE_TABLET: |
| 43 | return PM_TABLET; |
| 44 | case SMBIOS_ENCLOSURE_DESKTOP: |
| 45 | return PM_DESKTOP; |
| 46 | case SMBIOS_ENCLOSURE_UNKNOWN: |
| 47 | default: |
| 48 | return PM_UNSPECIFIED; |
| 49 | } |
| 50 | } |