blob: df7b070adb12870f42faef4952566a0501ea1c90 [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{
Vladimir Serbinenkod3b194e2015-05-12 12:39:53 +020028 if (CONFIG_LOCK_SPI_ON_RESUME_RO || CONFIG_LOCK_SPI_ON_RESUME_NO_ACCESS) {
29 /* Copy flash regions from FREG0-4 to PR0-4
30 and enable write protection bit31 */
31 int i;
32 u32 lockmask = (1 << 31);
33 if (CONFIG_LOCK_SPI_ON_RESUME_NO_ACCESS)
34 lockmask |= (1 << 15);
35 for (i = 0; i < 20; i += 4)
36 RCBA32(0x3874 + i) = RCBA32(0x3854 + i) | lockmask;
37 }
Nico Huberd1fb5642013-07-01 16:02:36 +020038
Stefan Reinauer8e073822012-04-04 00:07:22 +020039 /* Set SPI opcode menu */
40 RCBA16(0x3894) = SPI_OPPREFIX;
41 RCBA16(0x3896) = SPI_OPTYPE;
42 RCBA32(0x3898) = SPI_OPMENU_LOWER;
43 RCBA32(0x389c) = SPI_OPMENU_UPPER;
44
45 /* Lock SPIBAR */
46 RCBA32_OR(0x3804, (1 << 15));
Stefan Reinauer8e073822012-04-04 00:07:22 +020047
Duncan Laurie312ee0c2012-09-09 20:12:32 -070048#if CONFIG_SPI_FLASH_SMM
49 /* Re-init SPI driver to handle locked BAR */
50 spi_init();
51#endif
52
Stefan Reinauer8e073822012-04-04 00:07:22 +020053 /* TCLOCKDN: TC Lockdown */
54 RCBA32_OR(0x0050, (1 << 31));
55
56 /* BIOS Interface Lockdown */
57 RCBA32_OR(0x3410, (1 << 0));
58
59 /* Function Disable SUS Well Lockdown */
60 RCBA_AND_OR(8, 0x3420, ~0U, (1 << 7));
61
62 /* Global SMI Lock */
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030063 pci_or_config16(PCH_LPC_DEV, 0xa0, 1 << 4);
Stefan Reinauer8e073822012-04-04 00:07:22 +020064
65 /* GEN_PMCON Lock */
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030066 pci_or_config8(PCH_LPC_DEV, 0xa6, (1 << 1) | (1 << 2));
Stefan Reinauer8e073822012-04-04 00:07:22 +020067
68 /* R/WO registers */
69 RCBA32(0x21a4) = RCBA32(0x21a4);
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030070 pci_write_config32(PCI_DEV(0, 27, 0), 0x74,
71 pci_read_config32(PCI_DEV(0, 27, 0), 0x74));
Duncan Laurie04c5bae2012-08-13 09:37:42 -070072
73 /* Indicate finalize step with post code */
74 outb(POST_OS_BOOT, 0x80);
Stefan Reinauer8e073822012-04-04 00:07:22 +020075}