| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#define __SIMPLE_DEVICE__ |
| 9 |
|
| 10 |
#include <console/console.h> |
| 11 |
#include <device/pci.h> |
| 12 |
#include <intelblocks/pmclib.h> |
| 13 |
#include <intelblocks/rtc.h> |
| 14 |
#include <soc/pm.h> |
| 15 |
#include <soc/pmc.h> |
| 16 |
|
| 17 |
uint8_t *pmc_mmio_regs(void) |
| 18 |
{ |
| 19 |
|
| 20 |
|
| 21 |
return (void *)(uintptr_t)PCH_PWRM_BASE_ADDRESS; |
| 22 |
} |
| 23 |
|
| 24 |
uintptr_t soc_read_pmc_base(void) |
| 25 |
{ |
| 26 |
return (uintptr_t)(pmc_mmio_regs()); |
| 27 |
} |
| 28 |
|
| 29 |
uint32_t *soc_pmc_etr_addr(void) |
| 30 |
{ |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
return (uint32_t *)(soc_read_pmc_base() + ETR); |
| 37 |
} |
| 38 |
|
| 39 |
int soc_get_rtc_failed(void) |
| 40 |
{ |
| 41 |
uint32_t pmcon_b = read32(pmc_mmio_regs() + GEN_PMCON_B); |
| 42 |
int rtc_fail = !!(pmcon_b & RTC_BATTERY_DEAD); |
| 43 |
|
| 44 |
if (rtc_fail) |
| 45 |
printk(BIOS_ERR, "%s: RTC battery dead or removed\n", __func__); |
| 46 |
|
| 47 |
return rtc_fail; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
void pmc_soc_set_afterg3_en(const bool on) |
| 55 |
{ |
| 56 |
uint8_t reg8; |
| 57 |
uint8_t *const pmcbase = pmc_mmio_regs(); |
| 58 |
|
| 59 |
reg8 = read8(pmcbase + GEN_PMCON_A); |
| 60 |
if (on) |
| 61 |
reg8 &= ~SLEEP_AFTER_POWER_FAIL; |
| 62 |
else |
| 63 |
reg8 |= SLEEP_AFTER_POWER_FAIL; |
| 64 |
write8(pmcbase + GEN_PMCON_A, reg8); |
| 65 |
} |
| 66 |
|
| 67 |
void pmc_lockdown_config(void) |
| 68 |
{ |
| 69 |
|
| 70 |
pmc_global_reset_disable_and_lock(); |
| 71 |
|
| 72 |
|
| 73 |
pmc_or_mmio32(GEN_PMCON_B, SLP_STR_POL_LOCK); |
| 74 |
pmc_or_mmio32(PM_CFG, PMC_LOCK); |
| 75 |
} |