2020-04-05 15:46:52 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
/* This file is part of the coreboot project. */
|
2017-10-11 03:26:18 +02:00
|
|
|
|
2019-03-03 07:01:05 +01:00
|
|
|
#include <device/mmio.h>
|
2019-09-27 23:00:30 +02:00
|
|
|
#include <intelblocks/cfg.h>
|
2019-09-17 18:48:00 +02:00
|
|
|
#include <intelblocks/pmclib.h>
|
2018-05-28 12:42:03 +02:00
|
|
|
#include <intelpch/lockdown.h>
|
2017-10-11 03:26:18 +02:00
|
|
|
#include <soc/pm.h>
|
|
|
|
|
2018-05-28 12:42:03 +02:00
|
|
|
static void pmc_lock_pmsync(void)
|
2017-10-11 03:26:18 +02:00
|
|
|
{
|
2018-05-28 12:42:03 +02:00
|
|
|
uint8_t *pmcbase;
|
|
|
|
uint32_t pmsyncreg;
|
2017-10-11 03:26:18 +02:00
|
|
|
|
|
|
|
pmcbase = pmc_mmio_regs();
|
2018-05-28 12:42:03 +02:00
|
|
|
|
2017-10-11 03:26:18 +02:00
|
|
|
pmsyncreg = read32(pmcbase + PMSYNC_TPR_CFG);
|
2018-05-09 11:25:09 +02:00
|
|
|
pmsyncreg |= PCH2CPU_TPR_CFG_LOCK;
|
2017-10-11 03:26:18 +02:00
|
|
|
write32(pmcbase + PMSYNC_TPR_CFG, pmsyncreg);
|
2018-05-28 12:42:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pmc_lock_abase(void)
|
|
|
|
{
|
|
|
|
uint8_t *pmcbase;
|
|
|
|
uint32_t reg32;
|
|
|
|
|
|
|
|
pmcbase = pmc_mmio_regs();
|
2017-10-11 03:26:18 +02:00
|
|
|
|
|
|
|
reg32 = read32(pmcbase + GEN_PMCON_B);
|
|
|
|
reg32 |= (SLP_STR_POL_LOCK | ACPI_BASE_LOCK);
|
|
|
|
write32(pmcbase + GEN_PMCON_B, reg32);
|
|
|
|
}
|
|
|
|
|
2018-05-28 12:42:03 +02:00
|
|
|
static void pmc_lock_smi(void)
|
2017-10-11 03:26:18 +02:00
|
|
|
{
|
2018-05-28 12:42:03 +02:00
|
|
|
uint8_t *pmcbase;
|
|
|
|
uint8_t reg8;
|
2017-10-11 03:26:18 +02:00
|
|
|
|
2018-05-28 12:42:03 +02:00
|
|
|
pmcbase = pmc_mmio_regs();
|
2017-10-11 03:26:18 +02:00
|
|
|
|
2018-05-28 12:42:03 +02:00
|
|
|
reg8 = read8(pmcbase + GEN_PMCON_B);
|
|
|
|
reg8 |= SMI_LOCK;
|
|
|
|
write8(pmcbase + GEN_PMCON_B, reg8);
|
2017-10-11 03:26:18 +02:00
|
|
|
}
|
|
|
|
|
2018-05-28 12:42:03 +02:00
|
|
|
static void pmc_lockdown_cfg(int chipset_lockdown)
|
2017-10-11 03:26:18 +02:00
|
|
|
{
|
2018-05-28 12:42:03 +02:00
|
|
|
/* PMSYNC */
|
|
|
|
pmc_lock_pmsync();
|
|
|
|
/* Lock down ABASE and sleep stretching policy */
|
|
|
|
pmc_lock_abase();
|
2019-09-17 18:48:00 +02:00
|
|
|
/* Make sure payload/OS can't trigger global reset */
|
|
|
|
pmc_global_reset_disable_and_lock();
|
2017-10-11 03:26:18 +02:00
|
|
|
|
2018-05-28 12:42:03 +02:00
|
|
|
if (chipset_lockdown == CHIPSET_LOCKDOWN_COREBOOT)
|
|
|
|
pmc_lock_smi();
|
|
|
|
}
|
2017-10-11 03:26:18 +02:00
|
|
|
|
2018-05-28 12:42:03 +02:00
|
|
|
void soc_lockdown_config(int chipset_lockdown)
|
|
|
|
{
|
2017-10-11 03:26:18 +02:00
|
|
|
/* PMC lock down configuration */
|
2018-05-28 12:42:03 +02:00
|
|
|
pmc_lockdown_cfg(chipset_lockdown);
|
2017-10-11 03:26:18 +02:00
|
|
|
}
|