1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <acpi/acpi_gnvs.h>
5 #include <acpi/acpi_pm.h>
8 #include <console/console.h>
11 static const char *pm_fetch_failure_msg
[PS_CLAIMER_MAX
] = {
12 [PS_CLAIMER_ELOG
] = "no event recorded in ELOG.",
13 [PS_CLAIMER_RTC
] = "RTC init aborted.",
14 [PS_CLAIMER_WAKE
] = "wake source unknown.",
17 void __weak
mainboard_suspend_resume(void)
21 /* Default mapping to ACPI FADT preferred_pm_profile field. */
22 uint8_t acpi_get_preferred_pm_profile(void)
24 switch (smbios_mainboard_enclosure_type()) {
25 case SMBIOS_ENCLOSURE_LAPTOP
:
26 case SMBIOS_ENCLOSURE_CONVERTIBLE
:
28 case SMBIOS_ENCLOSURE_DETACHABLE
:
29 case SMBIOS_ENCLOSURE_TABLET
:
31 case SMBIOS_ENCLOSURE_DESKTOP
:
33 case SMBIOS_ENCLOSURE_UNKNOWN
:
35 return PM_UNSPECIFIED
;
39 struct chipset_power_state
*acpi_get_pm_state(void)
41 static struct chipset_power_state
*acpi_pm_state
;
45 acpi_pm_state
= cbmem_find(CBMEM_ID_POWER_STATE
);
49 int acpi_fetch_pm_state(const struct chipset_power_state
**ps
,
50 enum power_state_claimer ps_claimer
)
52 assert(ps_claimer
< PS_CLAIMER_MAX
);
53 *ps
= acpi_get_pm_state();
56 printk(BIOS_ERR
, "No CBMEM_ID_POWER_STATE entry, %s\n",
57 ps_claimer
< PS_CLAIMER_MAX
?
58 pm_fetch_failure_msg
[ps_claimer
] : "unknown claimer.");
64 /* Not every <soc/nvs.h> exists and has required fields. */
65 #if CONFIG(ACPI_GNVS_USB_CHARGECTL) && ENV_SMM
67 #include <cpu/x86/smm.h>
70 void usb_charge_mode_from_gnvs(uint8_t slp_typ
, bool *usb0_disable
, bool *usb1_disable
)
77 *usb0_disable
= (gnvs
->s3u0
== 0);
78 *usb1_disable
= (gnvs
->s3u1
== 0);
82 *usb0_disable
= (gnvs
->s5u0
== 0);
83 *usb1_disable
= (gnvs
->s5u1
== 0);
88 #endif /* CONFIG(ACPI_GNVS_USB_CHARGECTL) */