2017-10-11 03:26:18 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Intel Corporation.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2019-03-03 07:01:05 +01:00
|
|
|
#include <device/mmio.h>
|
2019-09-27 23:00:30 +02:00
|
|
|
#include <intelblocks/cfg.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();
|
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
|
|
|
}
|