Angel Pons | f94ac9a | 2020-04-05 15:46:48 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 3 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 4 | #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 Werner | 4ee4bd5 | 2014-10-20 13:46:39 -0700 | [diff] [blame] | 10 | #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 Heymans | 3c1e986 | 2019-10-13 22:54:53 +0200 | [diff] [blame] | 16 | #include <southbridge/intel/common/spi.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 17 | |
| 18 | const 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 Laurie | 88bbf16 | 2015-01-09 13:23:05 -0800 | [diff] [blame] | 37 | 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 Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 40 | REG_MMIO_WRITE8(MCH_BASE_ADDRESS + 0x50fc, 0x8f), /* MC */ |
| 41 | |
| 42 | REG_SCRIPT_END |
| 43 | }; |
| 44 | |
| 45 | const struct reg_script pch_finalize_script[] = { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 46 | #if !CONFIG(SPI_CONSOLE) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 47 | /* Lock SPIBAR */ |
| 48 | REG_MMIO_OR32(RCBA_BASE_ADDRESS + SPIBAR_OFFSET + SPIBAR_HSFS, |
| 49 | SPIBAR_HSFS_FLOCKDN), |
Duncan Laurie | 9d08c4a | 2015-12-22 17:08:21 -0800 | [diff] [blame] | 50 | #endif |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 51 | |
| 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 | |
| 74 | static void broadwell_finalize(void *unused) |
| 75 | { |
Kyösti Mälkki | 71756c21 | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 76 | struct device *sa_dev = pcidev_path_on_root(SA_DEVFN_ROOT); |
| 77 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 78 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 79 | |
Kyösti Mälkki | 71756c21 | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 80 | reg_script_run_on_dev(sa_dev, system_agent_finalize_script); |
Arthur Heymans | 3c1e986 | 2019-10-13 22:54:53 +0200 | [diff] [blame] | 81 | |
| 82 | spi_finalize_ops(); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 83 | reg_script_run_on_dev(PCH_DEV_LPC, pch_finalize_script); |
| 84 | |
Kane Chen | 472d0cb | 2014-08-21 10:36:17 -0700 | [diff] [blame] | 85 | /* Lock */ |
| 86 | RCBA32_OR(0x3a6c, 0x00000001); |
| 87 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 88 | /* 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 Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 94 | /* Indicate finalize step with post code */ |
| 95 | post_code(POST_OS_BOOT); |
| 96 | } |
| 97 | |
Aaron Durbin | 9ef9d85 | 2015-03-16 17:30:09 -0500 | [diff] [blame] | 98 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, broadwell_finalize, NULL); |
| 99 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, broadwell_finalize, NULL); |