coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pmclib.c File Reference
#include <acpi/acpi_pm.h>
#include <arch/io.h>
#include <assert.h>
#include <bootmode.h>
#include <device/mmio.h>
#include <device/pci.h>
#include <cbmem.h>
#include <cpu/x86/smm.h>
#include <console/console.h>
#include <halt.h>
#include <intelblocks/pmclib.h>
#include <intelblocks/gpio.h>
#include <intelblocks/tco.h>
#include <option.h>
#include <security/vboot/vboot_common.h>
#include <soc/pci_devs.h>
#include <soc/pm.h>
#include <stdint.h>
#include <string.h>
#include <timer.h>
Include dependency graph for pmclib.c:

Go to the source code of this file.

Data Structures

struct  cfg_assert_dur
 

Macros

#define PCH_PM_PWR_CYC_DUR   0
 

Enumerations

enum  min_assert_dur {
  MinAssertDur0s = 0 , MinAssertDur60us = 60 , MinAssertDur1ms = 1000 , MinAssertDur50ms = 50000 ,
  MinAssertDur98ms = 98000 , MinAssertDur500ms = 500000 , MinAssertDur1s = 1000000 , MinAssertDur2s = 2000000 ,
  MinAssertDur3s = 3000000 , MinAssertDur4s = 4000000
}
 

Functions

struct chipset_power_statepmc_get_power_state (void)
 
static void migrate_power_state (int is_recovery)
 
static void print_num_status_bits (int num_bits, uint32_t status, const char *const bit_names[])
 
__weak uint32_t soc_get_smi_status (uint32_t generic_sts)
 
int acpi_get_sleep_type (void)
 
static uint32_t pmc_reset_smi_status (void)
 
static uint32_t print_smi_status (uint32_t smi_sts)
 
void pmc_update_pm1_enable (u16 events)
 
uint16_t pmc_read_pm1_enable (void)
 
uint32_t pmc_clear_smi_status (void)
 
uint32_t pmc_get_smi_en (void)
 
void pmc_enable_smi (uint32_t mask)
 
void pmc_disable_smi (uint32_t mask)
 
void pmc_enable_pm1 (uint16_t events)
 
uint32_t pmc_read_pm1_control (void)
 
void pmc_write_pm1_control (uint32_t pm1_cnt)
 
void pmc_enable_pm1_control (uint32_t mask)
 
void pmc_disable_pm1_control (uint32_t mask)
 
static uint16_t reset_pm1_status (void)
 
static uint16_t print_pm1_status (uint16_t pm1_sts)
 
uint16_t pmc_clear_pm1_status (void)
 
static uint32_t print_tco_status (uint32_t tco_sts)
 
uint32_t pmc_clear_tco_status (void)
 
static void pmc_enable_gpe (int gpe, uint32_t mask)
 
static void pmc_disable_gpe (int gpe, uint32_t mask)
 
void pmc_enable_std_gpe (uint32_t mask)
 
void pmc_disable_std_gpe (uint32_t mask)
 
void pmc_disable_all_gpe (void)
 
static void pmc_clear_gpi_gpe_status (void)
 
static uint32_t reset_std_gpe_status (void)
 
static uint32_t print_std_gpe_sts (uint32_t gpe_sts)
 
static void pmc_clear_std_gpe_status (void)
 
void pmc_clear_all_gpe_status (void)
 
__weak void soc_clear_pm_registers (uintptr_t pmc_bar)
 
void pmc_clear_prsts (void)
 
__weak int soc_prev_sleep_state (const struct chipset_power_state *ps, int prev_sleep_state)
 
static int pmc_prev_sleep_state (const struct chipset_power_state *ps)
 
void pmc_fill_pm_reg_info (struct chipset_power_state *ps)
 
int pmc_fill_power_state (struct chipset_power_state *ps)
 
int platform_is_resuming (void)
 
int acpi_get_gpe (int gpe)
 
void vboot_platform_prepare_reboot (void)
 
void poweroff (void)
 
void pmc_gpe_init (void)
 
void pmc_set_power_failure_state (const bool target_on)
 
static enum min_assert_dur get_high_assert_width (const struct cfg_assert_dur *cfg_assert_dur)
 
static void get_min_assert_dur (uint8_t slp_s4_min_assert, uint8_t slp_s3_min_assert, uint8_t slp_a_min_assert, uint8_t pm_pwr_cyc_dur, struct cfg_assert_dur *cfg_assert_dur)
 
uint8_t get_pm_pwr_cyc_dur (uint8_t slp_s4_min_assert, uint8_t slp_s3_min_assert, uint8_t slp_a_min_assert, uint8_t pm_pwr_cyc_dur)
 
void pmc_set_acpi_mode (void)
 
enum pch_pmc_xtal pmc_get_xtal_freq (void)
 

Variables

static struct chipset_power_state power_state
 

Macro Definition Documentation

◆ PCH_PM_PWR_CYC_DUR

#define PCH_PM_PWR_CYC_DUR   0

Definition at line 56 of file pmclib.c.

Enumeration Type Documentation

◆ min_assert_dur

Enumerator
MinAssertDur0s 
MinAssertDur60us 
MinAssertDur1ms 
MinAssertDur50ms 
MinAssertDur98ms 
MinAssertDur500ms 
MinAssertDur1s 
MinAssertDur2s 
MinAssertDur3s 
MinAssertDur4s 

Definition at line 27 of file pmclib.c.

Function Documentation

◆ acpi_get_gpe()

int acpi_get_gpe ( int  gpe)

Definition at line 478 of file pmclib.c.

References ACPI_BASE_ADDRESS, GPE0_STS, GPE_MAX, inl(), mask, outl(), stopwatch_expired(), and stopwatch_init_msecs_expire().

Here is the call graph for this function:

◆ acpi_get_sleep_type()

int acpi_get_sleep_type ( void  )

Definition at line 109 of file pmclib.c.

References ACPI_S0, pmc_get_power_state(), chipset_power_state::prev_sleep_state, and prev_sleep_state().

Here is the call graph for this function:

◆ get_high_assert_width()

static enum min_assert_dur get_high_assert_width ( const struct cfg_assert_dur cfg_assert_dur)
static

Definition at line 623 of file pmclib.c.

References BIOS_INFO, BIOS_WARNING, get_uint_option(), MAINBOARD_POWER_STATE_OFF, MAINBOARD_POWER_STATE_ON, MAINBOARD_POWER_STATE_PREVIOUS, pmc_soc_set_afterg3_en(), and printk.

Referenced by get_pm_pwr_cyc_dur().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_min_assert_dur()

static void get_min_assert_dur ( uint8_t  slp_s4_min_assert,
uint8_t  slp_s3_min_assert,
uint8_t  slp_a_min_assert,
uint8_t  pm_pwr_cyc_dur,
struct cfg_assert_dur cfg_assert_dur 
)
static

◆ get_pm_pwr_cyc_dur()

uint8_t get_pm_pwr_cyc_dur ( uint8_t  slp_s4_min_assert,
uint8_t  slp_s3_min_assert,
uint8_t  slp_a_min_assert,
uint8_t  pm_pwr_cyc_dur 
)

Definition at line 724 of file pmclib.c.

References BIOS_DEBUG, get_high_assert_width(), get_min_assert_dur(), MinAssertDur1s, MinAssertDur2s, MinAssertDur4s, MinAssertDur50ms, PCH_PM_PWR_CYC_DUR, cfg_assert_dur::pm_pwr_cyc_dur, printk, and cfg_assert_dur::slp_a.

Referenced by fill_fsps_misc_power_params(), and platform_fsp_silicon_init_params_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ migrate_power_state()

static void migrate_power_state ( int  is_recovery)
static

Definition at line 72 of file pmclib.c.

References BIOS_DEBUG, cbmem_add(), CBMEM_ID_POWER_STATE, memcpy(), NULL, power_state, and printk.

Here is the call graph for this function:

◆ platform_is_resuming()

int platform_is_resuming ( void  )

Definition at line 469 of file pmclib.c.

References ACPI_BASE_ADDRESS, ACPI_S3, inw(), PM1_STS, pmc_read_pm1_control(), and WAK_STS.

Referenced by southbridge_detect_s3_resume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_clear_all_gpe_status()

void pmc_clear_all_gpe_status ( void  )

Definition at line 355 of file pmclib.c.

References pmc_clear_gpi_gpe_status(), and pmc_clear_std_gpe_status().

Referenced by smihandler_southbridge_gpe0(), smihandler_southbridge_sleep(), and smm_southbridge_clear_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_clear_gpi_gpe_status()

static void pmc_clear_gpi_gpe_status ( void  )
static

Definition at line 313 of file pmclib.c.

References ACPI_BASE_ADDRESS, GPE0_REG_MAX, GPE0_STS, GPE_STD, inl(), and outl().

Referenced by pmc_clear_all_gpe_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_clear_pm1_status()

uint16_t pmc_clear_pm1_status ( void  )

Definition at line 250 of file pmclib.c.

References print_pm1_status(), and reset_pm1_status().

Referenced by ec_init(), smihandler_southbridge_pm1(), smihandler_southbridge_sleep(), and smm_southbridge_clear_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_clear_prsts()

void pmc_clear_prsts ( void  )

Definition at line 366 of file pmclib.c.

References PRSTS, chipset_power_state::prsts, read32p(), soc_clear_pm_registers(), soc_read_pmc_base(), and write32p().

Referenced by pmc_soc_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_clear_smi_status()

uint32_t pmc_clear_smi_status ( void  )

Definition at line 164 of file pmclib.c.

References pmc_reset_smi_status(), and print_smi_status().

Referenced by smm_southbridge_clear_state(), and southbridge_smi_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_clear_std_gpe_status()

static void pmc_clear_std_gpe_status ( void  )
static

Definition at line 350 of file pmclib.c.

References print_std_gpe_sts(), and reset_std_gpe_status().

Referenced by pmc_clear_all_gpe_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_clear_tco_status()

uint32_t pmc_clear_tco_status ( void  )

Definition at line 275 of file pmclib.c.

References print_tco_status(), and tco_reset_status().

Referenced by smihandler_southbridge_tco(), and smm_southbridge_clear_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_disable_all_gpe()

void pmc_disable_all_gpe ( void  )

Definition at line 305 of file pmclib.c.

References GPE0_REG_MAX, and pmc_disable_gpe().

Referenced by smihandler_southbridge_sleep(), and smm_southbridge_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_disable_gpe()

static void pmc_disable_gpe ( int  gpe,
uint32_t  mask 
)
static

Definition at line 288 of file pmclib.c.

References ACPI_BASE_ADDRESS, GPE0_EN, chipset_power_state::gpe0_en, inl(), mask, and outl().

Referenced by pmc_disable_all_gpe(), and pmc_disable_std_gpe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_disable_pm1_control()

void pmc_disable_pm1_control ( uint32_t  mask)

Definition at line 213 of file pmclib.c.

References mask, chipset_power_state::pm1_cnt, pmc_read_pm1_control(), and pmc_write_pm1_control().

Referenced by smihandler_southbridge_apmc(), smihandler_southbridge_pm1(), and smihandler_southbridge_sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_disable_smi()

void pmc_disable_smi ( uint32_t  mask)

Definition at line 183 of file pmclib.c.

References ACPI_BASE_ADDRESS, inl(), mask, outl(), and SMI_EN.

Referenced by smihandler_southbridge_sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_disable_std_gpe()

void pmc_disable_std_gpe ( uint32_t  mask)

Definition at line 300 of file pmclib.c.

References GPE_STD, mask, and pmc_disable_gpe().

Referenced by smm_southbridge_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_enable_gpe()

static void pmc_enable_gpe ( int  gpe,
uint32_t  mask 
)
static

Definition at line 281 of file pmclib.c.

References ACPI_BASE_ADDRESS, GPE0_EN, chipset_power_state::gpe0_en, inl(), mask, and outl().

Referenced by pmc_enable_std_gpe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_enable_pm1()

void pmc_enable_pm1 ( uint16_t  events)

Definition at line 191 of file pmclib.c.

References ACPI_BASE_ADDRESS, outw(), and PM1_EN.

Referenced by pmc_update_pm1_enable(), and smm_southbridge_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_enable_pm1_control()

void pmc_enable_pm1_control ( uint32_t  mask)

Definition at line 206 of file pmclib.c.

References mask, chipset_power_state::pm1_cnt, pmc_read_pm1_control(), and pmc_write_pm1_control().

Referenced by ec_init(), poweroff(), smihandler_southbridge_apmc(), smihandler_southbridge_pm1(), and smihandler_southbridge_sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_enable_smi()

void pmc_enable_smi ( uint32_t  mask)

Definition at line 176 of file pmclib.c.

References ACPI_BASE_ADDRESS, inl(), mask, outl(), and SMI_EN.

Referenced by smm_southbridge_enable(), and southbridge_smi_set_eos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_enable_std_gpe()

void pmc_enable_std_gpe ( uint32_t  mask)

Definition at line 295 of file pmclib.c.

References GPE_STD, mask, and pmc_enable_gpe().

Here is the call graph for this function:

◆ pmc_fill_pm_reg_info()

◆ pmc_fill_power_state()

int pmc_fill_power_state ( struct chipset_power_state ps)

Definition at line 437 of file pmclib.c.

References BIOS_DEBUG, pmc_fill_pm_reg_info(), pmc_prev_sleep_state(), chipset_power_state::prev_sleep_state, and printk.

Referenced by mainboard_romstage_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_get_power_state()

struct chipset_power_state* pmc_get_power_state ( void  )

Definition at line 58 of file pmclib.c.

References acpi_get_pm_state(), cbmem_possibly_online(), ENV_POSTCAR, ENV_RAMSTAGE, NULL, and power_state.

Referenced by acpi_get_sleep_type(), check_full_retrain(), mainboard_romstage_entry(), and pch_log_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_get_smi_en()

uint32_t pmc_get_smi_en ( void  )

Definition at line 171 of file pmclib.c.

References ACPI_BASE_ADDRESS, inl(), and SMI_EN.

Referenced by smihandler_southbridge_periodic(), and smm_southbridge_clear_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_get_xtal_freq()

enum pch_pmc_xtal pmc_get_xtal_freq ( void  )

Definition at line 754 of file pmclib.c.

Referenced by fill_fsps_tsn_params(), and soc_fill_soundwire_controller().

Here is the caller graph for this function:

◆ pmc_gpe_init()

void pmc_gpe_init ( void  )

Definition at line 535 of file pmclib.c.

References BIOS_INFO, GPE0_DW_SHIFT, GPE0_DWX_MASK, GPIO_GPE_CFG, gpio_route_gpe(), printk, read32p(), soc_get_gpi_gpe_configs(), soc_read_pmc_base(), and write32p().

Referenced by bootblock_pch_init(), bootblock_soc_early_init(), pmc_init(), pmc_soc_init(), and soc_pmc_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_prev_sleep_state()

static int pmc_prev_sleep_state ( const struct chipset_power_state ps)
static

Definition at line 391 of file pmclib.c.

References ACPI_S0, ACPI_S3, ACPI_S5, CONFIG, chipset_power_state::pm1_cnt, chipset_power_state::pm1_sts, pmc_write_pm1_control(), prev_sleep_state(), SLP_TYP, soc_prev_sleep_state(), and WAK_STS.

Referenced by pmc_fill_power_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_read_pm1_control()

uint32_t pmc_read_pm1_control ( void  )

Definition at line 196 of file pmclib.c.

References ACPI_BASE_ADDRESS, inl(), and PM1_CNT.

Referenced by platform_is_resuming(), pmc_disable_pm1_control(), pmc_enable_pm1_control(), pmc_fill_pm_reg_info(), smihandler_southbridge_sleep(), soc_get_smi_status(), southbridge_smi_handler(), and vboot_platform_prepare_reboot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_read_pm1_enable()

uint16_t pmc_read_pm1_enable ( void  )

Definition at line 159 of file pmclib.c.

References ACPI_BASE_ADDRESS, inw(), and PM1_EN.

Referenced by pmc_update_pm1_enable(), and smihandler_southbridge_pm1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_reset_smi_status()

static uint32_t pmc_reset_smi_status ( void  )
static

Definition at line 121 of file pmclib.c.

References ACPI_BASE_ADDRESS, inl(), outl(), SMI_STS, and soc_get_smi_status().

Referenced by pmc_clear_smi_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_set_acpi_mode()

void pmc_set_acpi_mode ( void  )

Definition at line 754 of file pmclib.c.

Referenced by pmc_init(), pmc_soc_init(), and soc_pmc_init().

Here is the caller graph for this function:

◆ pmc_set_power_failure_state()

void pmc_set_power_failure_state ( const bool  target_on)

Definition at line 623 of file pmclib.c.

Referenced by pmc_init(), pmc_soc_init(), smihandler_southbridge_sleep(), and soc_pmc_enable().

Here is the caller graph for this function:

◆ pmc_update_pm1_enable()

void pmc_update_pm1_enable ( u16  events)

Definition at line 151 of file pmclib.c.

References chipset_power_state::pm1_en, pmc_enable_pm1(), and pmc_read_pm1_enable().

Referenced by pm1_enable_pwrbtn_smi(), and pm1_handle_wake_pin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmc_write_pm1_control()

void pmc_write_pm1_control ( uint32_t  pm1_cnt)

Definition at line 201 of file pmclib.c.

References ACPI_BASE_ADDRESS, outl(), PM1_CNT, and chipset_power_state::pm1_cnt.

Referenced by pmc_disable_pm1_control(), pmc_enable_pm1_control(), pmc_prev_sleep_state(), and vboot_platform_prepare_reboot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poweroff()

void poweroff ( void  )

Definition at line 522 of file pmclib.c.

References ENV_SMM, halt(), pmc_enable_pm1_control(), SLP_EN, SLP_TYP_S5, and SLP_TYP_SHIFT.

Here is the call graph for this function:

◆ print_num_status_bits()

static void print_num_status_bits ( int  num_bits,
uint32_t  status,
const char *const  bit_names[] 
)
static

Definition at line 86 of file pmclib.c.

References BIOS_DEBUG, and printk.

Referenced by print_pm1_status(), print_smi_status(), print_std_gpe_sts(), and print_tco_status().

Here is the caller graph for this function:

◆ print_pm1_status()

static uint16_t print_pm1_status ( uint16_t  pm1_sts)
static

Definition at line 227 of file pmclib.c.

References ARRAY_SIZE, BIOS_SPEW, chipset_power_state::pm1_sts, print_num_status_bits(), and printk.

Referenced by pmc_clear_pm1_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_smi_status()

static uint32_t print_smi_status ( uint32_t  smi_sts)
static

Definition at line 129 of file pmclib.c.

References BIOS_DEBUG, print_num_status_bits(), printk, and soc_smi_sts_array().

Referenced by pmc_clear_smi_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_std_gpe_sts()

static uint32_t print_std_gpe_sts ( uint32_t  gpe_sts)
static

Definition at line 333 of file pmclib.c.

References BIOS_DEBUG, print_num_status_bits(), printk, and soc_std_gpe_sts_array().

Referenced by pmc_clear_std_gpe_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_tco_status()

static uint32_t print_tco_status ( uint32_t  tco_sts)
static

Definition at line 257 of file pmclib.c.

References BIOS_DEBUG, print_num_status_bits(), printk, soc_tco_sts_array(), and chipset_power_state::tco_sts.

Referenced by pmc_clear_tco_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_pm1_status()

static uint16_t reset_pm1_status ( void  )
static

Definition at line 220 of file pmclib.c.

References ACPI_BASE_ADDRESS, inw(), outw(), PM1_STS, and chipset_power_state::pm1_sts.

Referenced by pmc_clear_pm1_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_std_gpe_status()

static uint32_t reset_std_gpe_status ( void  )
static

Definition at line 326 of file pmclib.c.

References ACPI_BASE_ADDRESS, GPE0_STS, GPE_STD, inl(), and outl().

Referenced by pmc_clear_std_gpe_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ soc_clear_pm_registers()

__weak void soc_clear_pm_registers ( uintptr_t  pmc_bar)

Definition at line 362 of file pmclib.c.

Referenced by pmc_clear_prsts().

Here is the caller graph for this function:

◆ soc_get_smi_status()

__weak uint32_t soc_get_smi_status ( uint32_t  generic_sts)

Definition at line 104 of file pmclib.c.

Referenced by pmc_reset_smi_status().

Here is the caller graph for this function:

◆ soc_prev_sleep_state()

__weak int soc_prev_sleep_state ( const struct chipset_power_state ps,
int  prev_sleep_state 
)

Definition at line 381 of file pmclib.c.

References prev_sleep_state().

Referenced by pmc_prev_sleep_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vboot_platform_prepare_reboot()

void vboot_platform_prepare_reboot ( void  )

Definition at line 514 of file pmclib.c.

References pmc_read_pm1_control(), pmc_write_pm1_control(), SLP_TYP, SLP_TYP_S5, and SLP_TYP_SHIFT.

Here is the call graph for this function:

Variable Documentation

◆ power_state

struct chipset_power_state power_state
static

Definition at line 1 of file pmclib.c.

Referenced by migrate_power_state(), and pmc_get_power_state().