mb/google/nissa/var/rull: Configure Acoustic noise mitigation
[coreboot2.git] / src / soc / amd / common / block / pm / pmlib.c
blob86cb2cf896f5d1a8c8d0a4aa51c463871e84dc53
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <amdblocks/acpimmio.h>
4 #include <amdblocks/pmlib.h>
5 #include <console/console.h>
6 #include <types.h>
8 /* This register is a bit of an odd one. The configuration gets written into the lower nibble,
9 but ends up being copied to the upper nibble which gets initialized by this. */
10 #define PM_RTC_SHADOW_REG 0x5b
11 #define PWR_PWRSTATE BIT(2) /* power state bit; needs to be written as 1 */
12 #define PWR_FAIL_OFF 0x0 /* Always power off after power resumes */
13 #define PWR_FAIL_ON 0x1 /* Always power on after power resumes */
14 #define PWR_FAIL_PREV 0x3 /* Use previous setting after power resumes */
16 void pm_set_power_failure_state(void)
18 uint8_t pwr_fail = PWR_PWRSTATE;
20 switch (CONFIG_MAINBOARD_POWER_FAILURE_STATE) {
21 case MAINBOARD_POWER_STATE_OFF:
22 printk(BIOS_INFO, "Set power off after power failure.\n");
23 pwr_fail |= PWR_FAIL_OFF;
24 break;
25 case MAINBOARD_POWER_STATE_ON:
26 printk(BIOS_INFO, "Set power on after power failure.\n");
27 pwr_fail |= PWR_FAIL_ON;
28 break;
29 case MAINBOARD_POWER_STATE_PREVIOUS:
30 printk(BIOS_INFO, "Keep power state after power failure.\n");
31 pwr_fail |= PWR_FAIL_PREV;
32 break;
33 default:
34 printk(BIOS_WARNING, "Unknown power-failure state: %d\n",
35 CONFIG_MAINBOARD_POWER_FAILURE_STATE);
36 pwr_fail |= PWR_FAIL_OFF;
37 break;
40 pm_write8(PM_RTC_SHADOW_REG, pwr_fail);