blob: 76e75c824066247b939c9e14db6f3e57abd7251e [file] [log] [blame]
Stefan Reinauer8e073822012-04-04 00:07:22 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauer8e073822012-04-04 00:07:22 +020019 */
20
21#include <arch/io.h>
Duncan Laurie04c5bae2012-08-13 09:37:42 -070022#include <console/post_codes.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +020023#include "pch.h"
Zheng Bao600784e2013-02-07 17:30:23 +080024#include <spi-generic.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +020025
26void intel_pch_finalize_smm(void)
27{
Nico Huberd1fb5642013-07-01 16:02:36 +020028#if CONFIG_LOCK_SPI_ON_RESUME
29 /* Copy flash regions from FREG0-4 to PR0-4
30 and enable write protection bit31 */
31 int i;
32 for (i = 0; i < 20; i += 4)
33 RCBA32(0x3874 + i) = RCBA32(0x3854 + i) | (1 << 31);
34#endif
35
Stefan Reinauer8e073822012-04-04 00:07:22 +020036 /* Set SPI opcode menu */
37 RCBA16(0x3894) = SPI_OPPREFIX;
38 RCBA16(0x3896) = SPI_OPTYPE;
39 RCBA32(0x3898) = SPI_OPMENU_LOWER;
40 RCBA32(0x389c) = SPI_OPMENU_UPPER;
41
42 /* Lock SPIBAR */
43 RCBA32_OR(0x3804, (1 << 15));
Stefan Reinauer8e073822012-04-04 00:07:22 +020044
Duncan Laurie312ee0c2012-09-09 20:12:32 -070045#if CONFIG_SPI_FLASH_SMM
46 /* Re-init SPI driver to handle locked BAR */
47 spi_init();
48#endif
49
Stefan Reinauer8e073822012-04-04 00:07:22 +020050 /* TCLOCKDN: TC Lockdown */
51 RCBA32_OR(0x0050, (1 << 31));
52
53 /* BIOS Interface Lockdown */
54 RCBA32_OR(0x3410, (1 << 0));
55
56 /* Function Disable SUS Well Lockdown */
57 RCBA_AND_OR(8, 0x3420, ~0U, (1 << 7));
58
59 /* Global SMI Lock */
60 pcie_or_config16(PCH_LPC_DEV, 0xa0, 1 << 4);
61
62 /* GEN_PMCON Lock */
63 pcie_or_config8(PCH_LPC_DEV, 0xa6, (1 << 1) | (1 << 2));
64
65 /* R/WO registers */
66 RCBA32(0x21a4) = RCBA32(0x21a4);
67 pcie_write_config32(PCI_DEV(0, 27, 0), 0x74,
68 pcie_read_config32(PCI_DEV(0, 27, 0), 0x74));
Duncan Laurie04c5bae2012-08-13 09:37:42 -070069
70 /* Indicate finalize step with post code */
71 outb(POST_OS_BOOT, 0x80);
Stefan Reinauer8e073822012-04-04 00:07:22 +020072}