coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pmlib.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/acpimmio.h>
4 #include <amdblocks/pmlib.h>
5 #include <console/console.h>
6 #include <types.h>
7 
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 */
15 
17 {
18  uint8_t pwr_fail = PWR_PWRSTATE;
19 
20  switch (CONFIG_MAINBOARD_POWER_FAILURE_STATE) {
22  printk(BIOS_INFO, "Set power off after power failure.\n");
23  pwr_fail |= PWR_FAIL_OFF;
24  break;
26  printk(BIOS_INFO, "Set power on after power failure.\n");
27  pwr_fail |= PWR_FAIL_ON;
28  break;
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 
41 }
#define printk(level,...)
Definition: stdlib.h:16
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
Definition: loglevel.h:86
void pm_io_write8(uint8_t reg, uint8_t value)
Definition: mmio_util.c:119
#define PWR_FAIL_OFF
Definition: pmlib.c:12
#define PM_RTC_SHADOW_REG
Definition: pmlib.c:10
void pm_set_power_failure_state(void)
Definition: pmlib.c:16
#define PWR_FAIL_ON
Definition: pmlib.c:13
#define PWR_FAIL_PREV
Definition: pmlib.c:14
#define PWR_PWRSTATE
Definition: pmlib.c:11
@ MAINBOARD_POWER_STATE_ON
Definition: pmlib.h:8
@ MAINBOARD_POWER_STATE_PREVIOUS
Definition: pmlib.h:9
@ MAINBOARD_POWER_STATE_OFF
Definition: pmlib.h:7
unsigned char uint8_t
Definition: stdint.h:8