blob: 1c5fdb8885d0fcdd4ece45f6d1f331520e3af6b7 [file] [log] [blame]
Duncan Lauriec88c54c2014-04-30 16:36:13 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of 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.
Duncan Lauriec88c54c2014-04-30 16:36:13 -070014 */
15
16#include <arch/io.h>
17#include <bootstate.h>
18#include <console/console.h>
19#include <console/post_codes.h>
20#include <cpu/x86/smm.h>
21#include <reg_script.h>
22#include <spi-generic.h>
23#include <stdlib.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070024#include <soc/pci_devs.h>
25#include <soc/lpc.h>
26#include <soc/me.h>
27#include <soc/rcba.h>
28#include <soc/spi.h>
29#include <soc/systemagent.h>
Arthur Heymans3c1e9862019-10-13 22:54:53 +020030#include <southbridge/intel/common/spi.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070031
32const struct reg_script system_agent_finalize_script[] = {
33 REG_PCI_OR16(0x50, 1 << 0), /* GGC */
34 REG_PCI_OR32(0x5c, 1 << 0), /* DPR */
35 REG_PCI_OR32(0x78, 1 << 10), /* ME */
36 REG_PCI_OR32(0x90, 1 << 0), /* REMAPBASE */
37 REG_PCI_OR32(0x98, 1 << 0), /* REMAPLIMIT */
38 REG_PCI_OR32(0xa0, 1 << 0), /* TOM */
39 REG_PCI_OR32(0xa8, 1 << 0), /* TOUUD */
40 REG_PCI_OR32(0xb0, 1 << 0), /* BDSM */
41 REG_PCI_OR32(0xb4, 1 << 0), /* BGSM */
42 REG_PCI_OR32(0xb8, 1 << 0), /* TSEGMB */
43 REG_PCI_OR32(0xbc, 1 << 0), /* TOLUD */
44 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x5500, 1 << 0), /* PAVP */
45 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x5f00, 1 << 31), /* SA PM */
46 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x6020, 1 << 0), /* UMA GFX */
47 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x63fc, 1 << 0), /* VTDTRK */
48 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x6800, 1 << 31),
49 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x7000, 1 << 31),
50 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x77fc, 1 << 0),
Duncan Laurie88bbf162015-01-09 13:23:05 -080051 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x50fc, 0x8f),
52 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x7ffc, 1 << 0),
53 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x5880, 1 << 5),
Duncan Lauriec88c54c2014-04-30 16:36:13 -070054 REG_MMIO_WRITE8(MCH_BASE_ADDRESS + 0x50fc, 0x8f), /* MC */
55
56 REG_SCRIPT_END
57};
58
59const struct reg_script pch_finalize_script[] = {
Julius Wernercd49cce2019-03-05 16:53:33 -080060#if !CONFIG(SPI_CONSOLE)
Duncan Lauriec88c54c2014-04-30 16:36:13 -070061 /* Lock SPIBAR */
62 REG_MMIO_OR32(RCBA_BASE_ADDRESS + SPIBAR_OFFSET + SPIBAR_HSFS,
63 SPIBAR_HSFS_FLOCKDN),
Duncan Laurie9d08c4a2015-12-22 17:08:21 -080064#endif
Duncan Lauriec88c54c2014-04-30 16:36:13 -070065
66 /* TC Lockdown */
67 REG_MMIO_OR32(RCBA_BASE_ADDRESS + 0x0050, (1 << 31)),
68
69 /* BIOS Interface Lockdown */
70 REG_MMIO_OR32(RCBA_BASE_ADDRESS + GCS, (1 << 0)),
71
72 /* Function Disable SUS Well Lockdown */
73 REG_MMIO_OR8(RCBA_BASE_ADDRESS + FDSW, (1 << 7)),
74
75 /* Global SMI Lock */
76 REG_PCI_OR16(GEN_PMCON_1, SMI_LOCK),
77
78 /* GEN_PMCON Lock */
79 REG_PCI_OR8(GEN_PMCON_LOCK, SLP_STR_POL_LOCK | ACPI_BASE_LOCK),
80
81 /* PMSYNC */
82 REG_MMIO_OR32(RCBA_BASE_ADDRESS + PMSYNC_CONFIG, (1 << 31)),
83
84
85 REG_SCRIPT_END
86};
87
88static void broadwell_finalize(void *unused)
89{
Kyösti Mälkki71756c212019-07-12 13:10:19 +030090 struct device *sa_dev = pcidev_path_on_root(SA_DEVFN_ROOT);
91
Duncan Lauriec88c54c2014-04-30 16:36:13 -070092 printk(BIOS_DEBUG, "Finalizing chipset.\n");
93
Kyösti Mälkki71756c212019-07-12 13:10:19 +030094 reg_script_run_on_dev(sa_dev, system_agent_finalize_script);
Arthur Heymans3c1e9862019-10-13 22:54:53 +020095
96 spi_finalize_ops();
Duncan Lauriec88c54c2014-04-30 16:36:13 -070097 reg_script_run_on_dev(PCH_DEV_LPC, pch_finalize_script);
98
Kane Chen472d0cb2014-08-21 10:36:17 -070099 /* Lock */
100 RCBA32_OR(0x3a6c, 0x00000001);
101
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700102 /* Read+Write the following registers */
103 MCHBAR32(0x6030) = MCHBAR32(0x6030);
104 MCHBAR32(0x6034) = MCHBAR32(0x6034);
105 MCHBAR32(0x6008) = MCHBAR32(0x6008);
106 RCBA32(0x21a4) = RCBA32(0x21a4);
107
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700108 /* Indicate finalize step with post code */
109 post_code(POST_OS_BOOT);
110}
111
Aaron Durbin9ef9d852015-03-16 17:30:09 -0500112BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, broadwell_finalize, NULL);
113BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, broadwell_finalize, NULL);