blob: 90932e16bc8b9558b5412983f3ed38868d4ab624 [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.
Stefan Reinauer8e073822012-04-04 00:07:22 +020015 */
16
17#include <arch/io.h>
Duncan Laurie04c5bae2012-08-13 09:37:42 -070018#include <console/post_codes.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +020019#include "pch.h"
Zheng Bao600784e2013-02-07 17:30:23 +080020#include <spi-generic.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +020021
22void intel_pch_finalize_smm(void)
23{
Vladimir Serbinenkod3b194e2015-05-12 12:39:53 +020024 if (CONFIG_LOCK_SPI_ON_RESUME_RO || CONFIG_LOCK_SPI_ON_RESUME_NO_ACCESS) {
25 /* Copy flash regions from FREG0-4 to PR0-4
26 and enable write protection bit31 */
27 int i;
28 u32 lockmask = (1 << 31);
29 if (CONFIG_LOCK_SPI_ON_RESUME_NO_ACCESS)
30 lockmask |= (1 << 15);
31 for (i = 0; i < 20; i += 4)
32 RCBA32(0x3874 + i) = RCBA32(0x3854 + i) | lockmask;
33 }
Nico Huberd1fb5642013-07-01 16:02:36 +020034
Stefan Reinauer8e073822012-04-04 00:07:22 +020035 /* Set SPI opcode menu */
36 RCBA16(0x3894) = SPI_OPPREFIX;
37 RCBA16(0x3896) = SPI_OPTYPE;
38 RCBA32(0x3898) = SPI_OPMENU_LOWER;
39 RCBA32(0x389c) = SPI_OPMENU_UPPER;
40
41 /* Lock SPIBAR */
42 RCBA32_OR(0x3804, (1 << 15));
Stefan Reinauer8e073822012-04-04 00:07:22 +020043
Duncan Laurie312ee0c2012-09-09 20:12:32 -070044#if CONFIG_SPI_FLASH_SMM
45 /* Re-init SPI driver to handle locked BAR */
46 spi_init();
47#endif
48
Stefan Reinauer8e073822012-04-04 00:07:22 +020049 /* TCLOCKDN: TC Lockdown */
50 RCBA32_OR(0x0050, (1 << 31));
51
52 /* BIOS Interface Lockdown */
53 RCBA32_OR(0x3410, (1 << 0));
54
55 /* Function Disable SUS Well Lockdown */
56 RCBA_AND_OR(8, 0x3420, ~0U, (1 << 7));
57
58 /* Global SMI Lock */
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030059 pci_or_config16(PCH_LPC_DEV, 0xa0, 1 << 4);
Stefan Reinauer8e073822012-04-04 00:07:22 +020060
61 /* GEN_PMCON Lock */
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030062 pci_or_config8(PCH_LPC_DEV, 0xa6, (1 << 1) | (1 << 2));
Stefan Reinauer8e073822012-04-04 00:07:22 +020063
64 /* R/WO registers */
65 RCBA32(0x21a4) = RCBA32(0x21a4);
Kyösti Mälkkifd98c652013-07-26 08:50:53 +030066 pci_write_config32(PCI_DEV(0, 27, 0), 0x74,
67 pci_read_config32(PCI_DEV(0, 27, 0), 0x74));
Duncan Laurie04c5bae2012-08-13 09:37:42 -070068
69 /* Indicate finalize step with post code */
70 outb(POST_OS_BOOT, 0x80);
Stefan Reinauer8e073822012-04-04 00:07:22 +020071}