blob: d143e58565721a24990b1c069ff853fbd7612949 [file] [log] [blame]
Stefan Reinauer8e073822012-04-04 00:07:22 +02001/*
2 * This file is part of the coreboot project.
3 *
Stefan Reinauer8e073822012-04-04 00:07:22 +02004 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; version 2 of
8 * the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Stefan Reinauer8e073822012-04-04 00:07:22 +020014 */
15
16#include <arch/io.h>
Duncan Laurie04c5bae2012-08-13 09:37:42 -070017#include <console/post_codes.h>
Tristan Corrick63626b12018-11-30 22:53:50 +130018#include <device/pci_ops.h>
Patrick Rudolph2dc63892018-06-28 14:13:06 +020019#include <southbridge/intel/common/pmbase.h>
Tristan Corrick63626b12018-11-30 22:53:50 +130020#include <southbridge/intel/common/pmutil.h>
21#include <southbridge/intel/common/rcba.h>
Zheng Bao600784e2013-02-07 17:30:23 +080022#include <spi-generic.h>
Tristan Corrick63626b12018-11-30 22:53:50 +130023
24#include "finalize.h"
Stefan Reinauer8e073822012-04-04 00:07:22 +020025
26void intel_pch_finalize_smm(void)
27{
Tristan Corrick63626b12018-11-30 22:53:50 +130028 const pci_devfn_t lpc_dev = PCI_DEV(0, 0x1f, 0);
29
Julius Wernercd49cce2019-03-05 16:53:33 -080030 if (CONFIG(LOCK_SPI_FLASH_RO) ||
31 CONFIG(LOCK_SPI_FLASH_NO_ACCESS)) {
Vladimir Serbinenkod3b194e2015-05-12 12:39:53 +020032 int i;
Tristan Corrick63626b12018-11-30 22:53:50 +130033 u32 lockmask = 1UL << 31;
Julius Wernercd49cce2019-03-05 16:53:33 -080034 if (CONFIG(LOCK_SPI_FLASH_NO_ACCESS))
Tristan Corrick63626b12018-11-30 22:53:50 +130035 lockmask |= 1 << 15;
Vladimir Serbinenkod3b194e2015-05-12 12:39:53 +020036 for (i = 0; i < 20; i += 4)
37 RCBA32(0x3874 + i) = RCBA32(0x3854 + i) | lockmask;
38 }
Nico Huberd1fb5642013-07-01 16:02:36 +020039
Stefan Reinauer8e073822012-04-04 00:07:22 +020040 /* Lock SPIBAR */
41 RCBA32_OR(0x3804, (1 << 15));
Stefan Reinauer8e073822012-04-04 00:07:22 +020042
Julius Wernercd49cce2019-03-05 16:53:33 -080043 if (CONFIG(SPI_FLASH_SMM))
Tristan Corrick63626b12018-11-30 22:53:50 +130044 /* Re-init SPI driver to handle locked BAR */
45 spi_init();
Duncan Laurie312ee0c2012-09-09 20:12:32 -070046
Stefan Reinauer8e073822012-04-04 00:07:22 +020047 /* TCLOCKDN: TC Lockdown */
Tristan Corrick63626b12018-11-30 22:53:50 +130048 RCBA32_OR(0x0050, (1UL << 31));
Stefan Reinauer8e073822012-04-04 00:07:22 +020049
50 /* BIOS Interface Lockdown */
51 RCBA32_OR(0x3410, (1 << 0));
52
53 /* Function Disable SUS Well Lockdown */
54 RCBA_AND_OR(8, 0x3420, ~0U, (1 << 7));
55
Tristan Corrick63626b12018-11-30 22:53:50 +130056 pci_or_config16(lpc_dev, D31F0_GEN_PMCON_1, SMI_LOCK);
Stefan Reinauer8e073822012-04-04 00:07:22 +020057
Tristan Corrick63626b12018-11-30 22:53:50 +130058 pci_or_config8(lpc_dev, D31F0_GEN_PMCON_LOCK,
59 ACPI_BASE_LOCK | SLP_STR_POL_LOCK);
Stefan Reinauer8e073822012-04-04 00:07:22 +020060
Tristan Corrick63626b12018-11-30 22:53:50 +130061 pci_update_config32(lpc_dev, D31F0_ETR3, ~ETR3_CF9GR, ETR3_CF9LOCK);
62
Julius Wernercd49cce2019-03-05 16:53:33 -080063 if (CONFIG(SOUTHBRIDGE_INTEL_LYNXPOINT))
Tristan Corrick63626b12018-11-30 22:53:50 +130064 /* PMSYNC */
65 RCBA32_OR(0x33c4, (1UL << 31));
Patrick Rudolph7565cf12017-05-03 18:38:21 +020066
Stefan Reinauer8e073822012-04-04 00:07:22 +020067 /* R/WO registers */
68 RCBA32(0x21a4) = RCBA32(0x21a4);
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030069 pci_write_config32(PCI_DEV(0, 27, 0), 0x74,
70 pci_read_config32(PCI_DEV(0, 27, 0), 0x74));
Duncan Laurie04c5bae2012-08-13 09:37:42 -070071
Patrick Rudolph2dc63892018-06-28 14:13:06 +020072 write_pmbase16(TCO1_CNT, read_pmbase16(TCO1_CNT) | TCO_LOCK);
Dennis Wassenberg0c047202015-09-10 12:03:45 +020073
Tristan Corrick63626b12018-11-30 22:53:50 +130074 outb(POST_OS_BOOT, CONFIG_POST_IO_PORT);
Stefan Reinauer8e073822012-04-04 00:07:22 +020075}