Angel Pons | 3bd1e3d | 2020-04-05 15:47:17 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Subrata Banik | b51f54b | 2017-08-14 16:15:33 +0530 | [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> |
Ravi Sarawadi | 1483d1f | 2017-09-28 17:06:01 -0700 | [diff] [blame] | 5 | #include <intelblocks/lpc_lib.h> |
Michael Niewöhner | 43d2527 | 2019-09-17 18:48:00 +0200 | [diff] [blame] | 6 | #include <intelblocks/pmclib.h> |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 7 | #include <intelpch/lockdown.h> |
Subrata Banik | 639bf8a | 2017-08-25 12:08:59 +0530 | [diff] [blame] | 8 | #include <soc/pm.h> |
Subrata Banik | b51f54b | 2017-08-14 16:15:33 +0530 | [diff] [blame] | 9 | |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 10 | static void lpc_lockdown_config(int chipset_lockdown) |
Subrata Banik | b51f54b | 2017-08-14 16:15:33 +0530 | [diff] [blame] | 11 | { |
Elyes HAOUAS | 6dc9d03 | 2020-02-16 16:22:52 +0100 | [diff] [blame] | 12 | /* Set BIOS Interface Lock, BIOS Lock */ |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 13 | if (chipset_lockdown == CHIPSET_LOCKDOWN_COREBOOT) { |
Ravi Sarawadi | 1483d1f | 2017-09-28 17:06:01 -0700 | [diff] [blame] | 14 | lpc_set_bios_interface_lock_down(); |
| 15 | lpc_set_lock_enable(); |
| 16 | } |
Subrata Banik | b51f54b | 2017-08-14 16:15:33 +0530 | [diff] [blame] | 17 | } |
| 18 | |
Subrata Banik | 639bf8a | 2017-08-25 12:08:59 +0530 | [diff] [blame] | 19 | static void pmc_lockdown_config(void) |
| 20 | { |
| 21 | uint8_t *pmcbase; |
| 22 | u32 pmsyncreg; |
| 23 | |
| 24 | /* PMSYNC */ |
| 25 | pmcbase = pmc_mmio_regs(); |
| 26 | pmsyncreg = read32(pmcbase + PMSYNC_TPR_CFG); |
| 27 | pmsyncreg |= PMSYNC_LOCK; |
| 28 | write32(pmcbase + PMSYNC_TPR_CFG, pmsyncreg); |
Michael Niewöhner | 43d2527 | 2019-09-17 18:48:00 +0200 | [diff] [blame] | 29 | |
| 30 | /* Make sure payload/OS can't trigger global reset */ |
| 31 | pmc_global_reset_disable_and_lock(); |
Subrata Banik | 639bf8a | 2017-08-25 12:08:59 +0530 | [diff] [blame] | 32 | } |
| 33 | |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 34 | void soc_lockdown_config(int chipset_lockdown) |
Subrata Banik | 97a0945 | 2017-08-16 18:38:54 +0530 | [diff] [blame] | 35 | { |
Subrata Banik | b51f54b | 2017-08-14 16:15:33 +0530 | [diff] [blame] | 36 | /* LPC lock down configuration */ |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 37 | lpc_lockdown_config(chipset_lockdown); |
Subrata Banik | 97a0945 | 2017-08-16 18:38:54 +0530 | [diff] [blame] | 38 | |
Subrata Banik | 639bf8a | 2017-08-25 12:08:59 +0530 | [diff] [blame] | 39 | /* PMC lock down configuration */ |
| 40 | pmc_lockdown_config(); |
Subrata Banik | b51f54b | 2017-08-14 16:15:33 +0530 | [diff] [blame] | 41 | } |