blob: 490bdae74e025c32b2223615a9f9112846ae3677 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer8e073822012-04-04 00:07:22 +02002
Sindhoor Tilak6217a152020-07-19 12:36:47 +00003#include <console/console.h>
Tristan Corrick63626b12018-11-30 22:53:50 +13004#include <device/pci_ops.h>
Patrick Rudolph2dc63892018-06-28 14:13:06 +02005#include <southbridge/intel/common/pmbase.h>
Tristan Corrick63626b12018-11-30 22:53:50 +13006#include <southbridge/intel/common/pmutil.h>
7#include <southbridge/intel/common/rcba.h>
Zheng Bao600784e2013-02-07 17:30:23 +08008#include <spi-generic.h>
Tristan Corrick63626b12018-11-30 22:53:50 +13009
10#include "finalize.h"
Stefan Reinauer8e073822012-04-04 00:07:22 +020011
12void intel_pch_finalize_smm(void)
13{
Tristan Corrick63626b12018-11-30 22:53:50 +130014 const pci_devfn_t lpc_dev = PCI_DEV(0, 0x1f, 0);
15
Stefan Reinauer8e073822012-04-04 00:07:22 +020016 /* Lock SPIBAR */
17 RCBA32_OR(0x3804, (1 << 15));
Stefan Reinauer8e073822012-04-04 00:07:22 +020018
Julius Wernercd49cce2019-03-05 16:53:33 -080019 if (CONFIG(SPI_FLASH_SMM))
Tristan Corrick63626b12018-11-30 22:53:50 +130020 /* Re-init SPI driver to handle locked BAR */
21 spi_init();
Duncan Laurie312ee0c2012-09-09 20:12:32 -070022
Stefan Reinauer8e073822012-04-04 00:07:22 +020023 /* TCLOCKDN: TC Lockdown */
Tristan Corrick63626b12018-11-30 22:53:50 +130024 RCBA32_OR(0x0050, (1UL << 31));
Stefan Reinauer8e073822012-04-04 00:07:22 +020025
26 /* BIOS Interface Lockdown */
27 RCBA32_OR(0x3410, (1 << 0));
28
29 /* Function Disable SUS Well Lockdown */
30 RCBA_AND_OR(8, 0x3420, ~0U, (1 << 7));
31
Tristan Corrick63626b12018-11-30 22:53:50 +130032 pci_or_config16(lpc_dev, D31F0_GEN_PMCON_1, SMI_LOCK);
Stefan Reinauer8e073822012-04-04 00:07:22 +020033
Tristan Corrick63626b12018-11-30 22:53:50 +130034 pci_or_config8(lpc_dev, D31F0_GEN_PMCON_LOCK,
35 ACPI_BASE_LOCK | SLP_STR_POL_LOCK);
Stefan Reinauer8e073822012-04-04 00:07:22 +020036
Tristan Corrick63626b12018-11-30 22:53:50 +130037 pci_update_config32(lpc_dev, D31F0_ETR3, ~ETR3_CF9GR, ETR3_CF9LOCK);
38
Julius Wernercd49cce2019-03-05 16:53:33 -080039 if (CONFIG(SOUTHBRIDGE_INTEL_LYNXPOINT))
Tristan Corrick63626b12018-11-30 22:53:50 +130040 /* PMSYNC */
41 RCBA32_OR(0x33c4, (1UL << 31));
Patrick Rudolph7565cf12017-05-03 18:38:21 +020042
Stefan Reinauer8e073822012-04-04 00:07:22 +020043 /* R/WO registers */
44 RCBA32(0x21a4) = RCBA32(0x21a4);
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030045 pci_write_config32(PCI_DEV(0, 27, 0), 0x74,
46 pci_read_config32(PCI_DEV(0, 27, 0), 0x74));
Duncan Laurie04c5bae2012-08-13 09:37:42 -070047
Angel Ponsd21b4632021-02-10 17:12:05 +010048 if (CONFIG(BOOTMEDIA_SMM_BWP))
49 write_pmbase16(SMI_EN, read_pmbase16(SMI_EN) | TCO_EN);
50
Patrick Rudolph2dc63892018-06-28 14:13:06 +020051 write_pmbase16(TCO1_CNT, read_pmbase16(TCO1_CNT) | TCO_LOCK);
Dennis Wassenberg0c047202015-09-10 12:03:45 +020052
lilacious40cb3fe2023-06-21 23:24:14 +020053 post_code(POSTCODE_OS_BOOT);
Stefan Reinauer8e073822012-04-04 00:07:22 +020054}