mb/google/brya/var/orisa: Update Type C DisplayPort HPD Configuration
[coreboot2.git] / src / acpi / acpi_pm.c
blob722d8f6b623bf96cc77dd7e8e748cc82ed0ecc89
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi.h>
4 #include <acpi/acpi_gnvs.h>
5 #include <acpi/acpi_pm.h>
6 #include <assert.h>
7 #include <cbmem.h>
8 #include <console/console.h>
9 #include <smbios.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:
27 return PM_MOBILE;
28 case SMBIOS_ENCLOSURE_DETACHABLE:
29 case SMBIOS_ENCLOSURE_TABLET:
30 return PM_TABLET;
31 case SMBIOS_ENCLOSURE_DESKTOP:
32 return PM_DESKTOP;
33 case SMBIOS_ENCLOSURE_UNKNOWN:
34 default:
35 return PM_UNSPECIFIED;
39 struct chipset_power_state *acpi_get_pm_state(void)
41 static struct chipset_power_state *acpi_pm_state;
42 if (acpi_pm_state)
43 return acpi_pm_state;
45 acpi_pm_state = cbmem_find(CBMEM_ID_POWER_STATE);
46 return acpi_pm_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();
55 if (!*ps) {
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.");
59 return -1;
61 return 0;
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>
68 #include <soc/nvs.h>
70 void usb_charge_mode_from_gnvs(uint8_t slp_typ, bool *usb0_disable, bool *usb1_disable)
72 if (!gnvs)
73 return;
75 switch (slp_typ) {
76 case ACPI_S3:
77 *usb0_disable = (gnvs->s3u0 == 0);
78 *usb1_disable = (gnvs->s3u1 == 0);
79 break;
80 case ACPI_S4:
81 case ACPI_S5:
82 *usb0_disable = (gnvs->s5u0 == 0);
83 *usb1_disable = (gnvs->s5u1 == 0);
84 break;
88 #endif /* CONFIG(ACPI_GNVS_USB_CHARGECTL) */