| 1 |
|
| 2 |
|
| 3 |
#include <amdblocks/acpimmio.h> |
| 4 |
#include <amdblocks/pmlib.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <types.h> |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#define PM_RTC_SHADOW_REG 0x5b |
| 11 |
#define PWR_PWRSTATE BIT(2) |
| 12 |
#define PWR_FAIL_OFF 0x0 |
| 13 |
#define PWR_FAIL_ON 0x1 |
| 14 |
#define PWR_FAIL_PREV 0x3 |
| 15 |
|
| 16 |
void pm_set_power_failure_state(void) |
| 17 |
{ |
| 18 |
uint8_t pwr_fail = PWR_PWRSTATE; |
| 19 |
|
| 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; |
| 38 |
} |
| 39 |
|
| 40 |
pm_write8(PM_RTC_SHADOW_REG, pwr_fail); |
| 41 |
} |