Angel Pons | f5627e8 | 2020-04-05 15:46:52 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 2 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 3 | #include <device/mmio.h> |
Kyösti Mälkki | 32d47eb | 2019-09-28 00:00:30 +0300 | [diff] [blame] | 4 | #include <intelblocks/cfg.h> |
Michael Niewöhner | dce6359 | 2019-09-17 18:48:00 +0200 | [diff] [blame] | 5 | #include <intelblocks/pmclib.h> |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 6 | #include <intelpch/lockdown.h> |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 7 | #include <soc/pm.h> |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 8 | |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 9 | static void pmc_lock_pmsync(void) |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 10 | { |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 11 | uint8_t *pmcbase; |
12 | uint32_t pmsyncreg; | ||||
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 13 | |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 14 | pmcbase = pmc_mmio_regs(); |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 15 | |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 16 | pmsyncreg = read32(pmcbase + PMSYNC_TPR_CFG); |
Subrata Banik | c4986eb | 2018-05-09 14:55:09 +0530 | [diff] [blame] | 17 | pmsyncreg |= PCH2CPU_TPR_CFG_LOCK; |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 18 | write32(pmcbase + PMSYNC_TPR_CFG, pmsyncreg); |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 19 | } |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 20 | |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 21 | static void pmc_lock_abase(void) |
22 | { | ||||
23 | uint8_t *pmcbase; | ||||
24 | uint32_t reg32; | ||||
25 | |||||
26 | pmcbase = pmc_mmio_regs(); | ||||
27 | |||||
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 28 | reg32 = read32(pmcbase + GEN_PMCON_B); |
29 | reg32 |= (SLP_STR_POL_LOCK | ACPI_BASE_LOCK); | ||||
30 | write32(pmcbase + GEN_PMCON_B, reg32); | ||||
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 31 | } |
32 | |||||
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 33 | static void pmc_lock_smi(void) |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 34 | { |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 35 | uint8_t *pmcbase; |
36 | uint8_t reg8; | ||||
37 | |||||
38 | pmcbase = pmc_mmio_regs(); | ||||
39 | |||||
40 | reg8 = read8(pmcbase + GEN_PMCON_B); | ||||
41 | reg8 |= SMI_LOCK; | ||||
42 | write8(pmcbase + GEN_PMCON_B, reg8); | ||||
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 43 | } |
44 | |||||
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 45 | static void pmc_lockdown_cfg(int chipset_lockdown) |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 46 | { |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 47 | /* PMSYNC */ |
48 | pmc_lock_pmsync(); | ||||
49 | /* Lock down ABASE and sleep stretching policy */ | ||||
50 | pmc_lock_abase(); | ||||
Michael Niewöhner | dce6359 | 2019-09-17 18:48:00 +0200 | [diff] [blame] | 51 | /* Make sure payload/OS can't trigger global reset */ |
52 | pmc_global_reset_disable_and_lock(); | ||||
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 53 | |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 54 | if (chipset_lockdown == CHIPSET_LOCKDOWN_COREBOOT) |
55 | pmc_lock_smi(); | ||||
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 56 | } |
57 | |||||
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 58 | void soc_lockdown_config(int chipset_lockdown) |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 59 | { |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 60 | /* PMC lock down configuration */ |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 61 | pmc_lockdown_cfg(chipset_lockdown); |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 62 | } |