blob: aa8a51ae4559a97da3790b421241e1802adb31ed [file] [log] [blame]
Angel Ponsf94ac9a2020-04-05 15:46:48 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Duncan Lauriec88c54c2014-04-30 16:36:13 -07003
Duncan Lauriec88c54c2014-04-30 16:36:13 -07004#include <bootstate.h>
5#include <console/console.h>
6#include <console/post_codes.h>
7#include <cpu/x86/smm.h>
8#include <reg_script.h>
9#include <spi-generic.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070010#include <soc/pci_devs.h>
11#include <soc/lpc.h>
12#include <soc/me.h>
13#include <soc/rcba.h>
14#include <soc/spi.h>
15#include <soc/systemagent.h>
Arthur Heymans3c1e9862019-10-13 22:54:53 +020016#include <southbridge/intel/common/spi.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070017
18const struct reg_script system_agent_finalize_script[] = {
19 REG_PCI_OR16(0x50, 1 << 0), /* GGC */
20 REG_PCI_OR32(0x5c, 1 << 0), /* DPR */
21 REG_PCI_OR32(0x78, 1 << 10), /* ME */
22 REG_PCI_OR32(0x90, 1 << 0), /* REMAPBASE */
23 REG_PCI_OR32(0x98, 1 << 0), /* REMAPLIMIT */
24 REG_PCI_OR32(0xa0, 1 << 0), /* TOM */
25 REG_PCI_OR32(0xa8, 1 << 0), /* TOUUD */
26 REG_PCI_OR32(0xb0, 1 << 0), /* BDSM */
27 REG_PCI_OR32(0xb4, 1 << 0), /* BGSM */
28 REG_PCI_OR32(0xb8, 1 << 0), /* TSEGMB */
29 REG_PCI_OR32(0xbc, 1 << 0), /* TOLUD */
30 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x5500, 1 << 0), /* PAVP */
31 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x5f00, 1 << 31), /* SA PM */
32 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x6020, 1 << 0), /* UMA GFX */
33 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x63fc, 1 << 0), /* VTDTRK */
34 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x6800, 1 << 31),
35 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x7000, 1 << 31),
36 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x77fc, 1 << 0),
Duncan Laurie88bbf162015-01-09 13:23:05 -080037 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x50fc, 0x8f),
38 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x7ffc, 1 << 0),
39 REG_MMIO_OR32(MCH_BASE_ADDRESS + 0x5880, 1 << 5),
Duncan Lauriec88c54c2014-04-30 16:36:13 -070040 REG_MMIO_WRITE8(MCH_BASE_ADDRESS + 0x50fc, 0x8f), /* MC */
41
42 REG_SCRIPT_END
43};
44
45const struct reg_script pch_finalize_script[] = {
Julius Wernercd49cce2019-03-05 16:53:33 -080046#if !CONFIG(SPI_CONSOLE)
Duncan Lauriec88c54c2014-04-30 16:36:13 -070047 /* Lock SPIBAR */
48 REG_MMIO_OR32(RCBA_BASE_ADDRESS + SPIBAR_OFFSET + SPIBAR_HSFS,
49 SPIBAR_HSFS_FLOCKDN),
Duncan Laurie9d08c4a2015-12-22 17:08:21 -080050#endif
Duncan Lauriec88c54c2014-04-30 16:36:13 -070051
52 /* TC Lockdown */
53 REG_MMIO_OR32(RCBA_BASE_ADDRESS + 0x0050, (1 << 31)),
54
55 /* BIOS Interface Lockdown */
56 REG_MMIO_OR32(RCBA_BASE_ADDRESS + GCS, (1 << 0)),
57
58 /* Function Disable SUS Well Lockdown */
59 REG_MMIO_OR8(RCBA_BASE_ADDRESS + FDSW, (1 << 7)),
60
61 /* Global SMI Lock */
62 REG_PCI_OR16(GEN_PMCON_1, SMI_LOCK),
63
64 /* GEN_PMCON Lock */
65 REG_PCI_OR8(GEN_PMCON_LOCK, SLP_STR_POL_LOCK | ACPI_BASE_LOCK),
66
67 /* PMSYNC */
68 REG_MMIO_OR32(RCBA_BASE_ADDRESS + PMSYNC_CONFIG, (1 << 31)),
69
70
71 REG_SCRIPT_END
72};
73
74static void broadwell_finalize(void *unused)
75{
Kyösti Mälkki71756c212019-07-12 13:10:19 +030076 struct device *sa_dev = pcidev_path_on_root(SA_DEVFN_ROOT);
77
Duncan Lauriec88c54c2014-04-30 16:36:13 -070078 printk(BIOS_DEBUG, "Finalizing chipset.\n");
79
Kyösti Mälkki71756c212019-07-12 13:10:19 +030080 reg_script_run_on_dev(sa_dev, system_agent_finalize_script);
Arthur Heymans3c1e9862019-10-13 22:54:53 +020081
82 spi_finalize_ops();
Duncan Lauriec88c54c2014-04-30 16:36:13 -070083 reg_script_run_on_dev(PCH_DEV_LPC, pch_finalize_script);
84
Kane Chen472d0cb2014-08-21 10:36:17 -070085 /* Lock */
86 RCBA32_OR(0x3a6c, 0x00000001);
87
Duncan Lauriec88c54c2014-04-30 16:36:13 -070088 /* Read+Write the following registers */
89 MCHBAR32(0x6030) = MCHBAR32(0x6030);
90 MCHBAR32(0x6034) = MCHBAR32(0x6034);
91 MCHBAR32(0x6008) = MCHBAR32(0x6008);
92 RCBA32(0x21a4) = RCBA32(0x21a4);
93
Duncan Lauriec88c54c2014-04-30 16:36:13 -070094 /* Indicate finalize step with post code */
95 post_code(POST_OS_BOOT);
96}
97
Aaron Durbin9ef9d852015-03-16 17:30:09 -050098BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, broadwell_finalize, NULL);
99BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, broadwell_finalize, NULL);