blob: 59d429747c5662dfb208ba762f6fde48b3029a59 [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
3#include <arch/io.h>
Sindhoor Tilak6217a152020-07-19 12:36:47 +00004#include <console/console.h>
Tristan Corrick63626b12018-11-30 22:53:50 +13005#include <device/pci_ops.h>
Patrick Rudolph2dc63892018-06-28 14:13:06 +02006#include <southbridge/intel/common/pmbase.h>
Tristan Corrick63626b12018-11-30 22:53:50 +13007#include <southbridge/intel/common/pmutil.h>
8#include <southbridge/intel/common/rcba.h>
Zheng Bao600784e2013-02-07 17:30:23 +08009#include <spi-generic.h>
Tristan Corrick63626b12018-11-30 22:53:50 +130010
11#include "finalize.h"
Stefan Reinauer8e073822012-04-04 00:07:22 +020012
13void intel_pch_finalize_smm(void)
14{
Tristan Corrick63626b12018-11-30 22:53:50 +130015 const pci_devfn_t lpc_dev = PCI_DEV(0, 0x1f, 0);
16
Stefan Reinauer8e073822012-04-04 00:07:22 +020017 /* Lock SPIBAR */
18 RCBA32_OR(0x3804, (1 << 15));
Stefan Reinauer8e073822012-04-04 00:07:22 +020019
Julius Wernercd49cce2019-03-05 16:53:33 -080020 if (CONFIG(SPI_FLASH_SMM))
Tristan Corrick63626b12018-11-30 22:53:50 +130021 /* Re-init SPI driver to handle locked BAR */
22 spi_init();
Duncan Laurie312ee0c2012-09-09 20:12:32 -070023
Stefan Reinauer8e073822012-04-04 00:07:22 +020024 /* TCLOCKDN: TC Lockdown */
Tristan Corrick63626b12018-11-30 22:53:50 +130025 RCBA32_OR(0x0050, (1UL << 31));
Stefan Reinauer8e073822012-04-04 00:07:22 +020026
27 /* BIOS Interface Lockdown */
28 RCBA32_OR(0x3410, (1 << 0));
29
30 /* Function Disable SUS Well Lockdown */
31 RCBA_AND_OR(8, 0x3420, ~0U, (1 << 7));
32
Tristan Corrick63626b12018-11-30 22:53:50 +130033 pci_or_config16(lpc_dev, D31F0_GEN_PMCON_1, SMI_LOCK);
Stefan Reinauer8e073822012-04-04 00:07:22 +020034
Tristan Corrick63626b12018-11-30 22:53:50 +130035 pci_or_config8(lpc_dev, D31F0_GEN_PMCON_LOCK,
36 ACPI_BASE_LOCK | SLP_STR_POL_LOCK);
Stefan Reinauer8e073822012-04-04 00:07:22 +020037
Tristan Corrick63626b12018-11-30 22:53:50 +130038 pci_update_config32(lpc_dev, D31F0_ETR3, ~ETR3_CF9GR, ETR3_CF9LOCK);
39
Julius Wernercd49cce2019-03-05 16:53:33 -080040 if (CONFIG(SOUTHBRIDGE_INTEL_LYNXPOINT))
Tristan Corrick63626b12018-11-30 22:53:50 +130041 /* PMSYNC */
42 RCBA32_OR(0x33c4, (1UL << 31));
Patrick Rudolph7565cf12017-05-03 18:38:21 +020043
Stefan Reinauer8e073822012-04-04 00:07:22 +020044 /* R/WO registers */
45 RCBA32(0x21a4) = RCBA32(0x21a4);
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030046 pci_write_config32(PCI_DEV(0, 27, 0), 0x74,
47 pci_read_config32(PCI_DEV(0, 27, 0), 0x74));
Duncan Laurie04c5bae2012-08-13 09:37:42 -070048
Patrick Rudolph2dc63892018-06-28 14:13:06 +020049 write_pmbase16(TCO1_CNT, read_pmbase16(TCO1_CNT) | TCO_LOCK);
Dennis Wassenberg0c047202015-09-10 12:03:45 +020050
Sindhoor Tilak6217a152020-07-19 12:36:47 +000051 post_code(POST_OS_BOOT);
Stefan Reinauer8e073822012-04-04 00:07:22 +020052}