Angel Pons | 230e4f9d | 2020-04-05 15:47:14 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 2 | |
Lee Leahy | 70bb057 | 2017-03-13 16:37:20 -0700 | [diff] [blame] | 3 | #include <cbfs.h> |
Lee Leahy | 318ef96 | 2016-02-07 14:48:53 -0800 | [diff] [blame] | 4 | #include <console/console.h> |
Lee Leahy | 43cdff6 | 2016-02-07 14:52:22 -0800 | [diff] [blame] | 5 | #include <fsp/util.h> |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 6 | #include <soc/pci_devs.h> |
Lee Leahy | 318ef96 | 2016-02-07 14:48:53 -0800 | [diff] [blame] | 7 | #include <soc/pm.h> |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 8 | #include <soc/romstage.h> |
Lee Leahy | 3f0fe68 | 2016-05-15 14:13:30 -0700 | [diff] [blame] | 9 | #include <soc/reg_access.h> |
| 10 | |
Lee Leahy | 01728bb | 2016-07-20 08:58:58 -0700 | [diff] [blame] | 11 | static const struct reg_script clear_smi_and_wake_events_script[] = { |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 12 | /* Clear any SMI or wake events */ |
| 13 | REG_GPE0_READ(R_QNC_GPE0BLK_GPE0S), |
| 14 | REG_GPE0_READ(R_QNC_GPE0BLK_SMIS), |
| 15 | REG_GPE0_OR(R_QNC_GPE0BLK_GPE0S, B_QNC_GPE0BLK_GPE0S_ALL), |
| 16 | REG_GPE0_OR(R_QNC_GPE0BLK_SMIS, B_QNC_GPE0BLK_SMIS_ALL), |
| 17 | REG_SCRIPT_END |
| 18 | }; |
| 19 | |
Lee Leahy | 01728bb | 2016-07-20 08:58:58 -0700 | [diff] [blame] | 20 | void clear_smi_and_wake_events(void) |
Lee Leahy | ce9e21a | 2016-06-05 18:48:31 -0700 | [diff] [blame] | 21 | { |
Lee Leahy | 01728bb | 2016-07-20 08:58:58 -0700 | [diff] [blame] | 22 | struct chipset_power_state *ps; |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 23 | |
| 24 | /* Clear SMI and wake events */ |
Lee Leahy | 01728bb | 2016-07-20 08:58:58 -0700 | [diff] [blame] | 25 | ps = get_power_state(); |
| 26 | if (ps->prev_sleep_state != 3) { |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 27 | printk(BIOS_SPEW, "Clearing SMI interrupts and wake events\n"); |
Lee Leahy | 01728bb | 2016-07-20 08:58:58 -0700 | [diff] [blame] | 28 | reg_script_run_on_dev(LPC_BDF, |
| 29 | clear_smi_and_wake_events_script); |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 30 | } |
Lee Leahy | 72179fa | 2016-06-04 16:09:44 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Lee Leahy | 01728bb | 2016-07-20 08:58:58 -0700 | [diff] [blame] | 33 | void disable_rom_shadow(void) |
Lee Leahy | d75ed0b | 2016-03-04 16:49:40 -0800 | [diff] [blame] | 34 | { |
| 35 | uint32_t data; |
| 36 | |
| 37 | /* Determine if the shadow ROM is enabled */ |
| 38 | data = port_reg_read(QUARK_NC_HOST_BRIDGE_SB_PORT_ID, |
| 39 | QNC_MSG_FSBIC_REG_HMISC); |
Lee Leahy | d75ed0b | 2016-03-04 16:49:40 -0800 | [diff] [blame] | 40 | if ((data & (ESEG_RD_DRAM | FSEG_RD_DRAM)) |
| 41 | != (ESEG_RD_DRAM | FSEG_RD_DRAM)) { |
| 42 | |
| 43 | /* Disable the ROM shadow 0x000e0000 - 0x000fffff */ |
| 44 | data |= ESEG_RD_DRAM | FSEG_RD_DRAM; |
| 45 | port_reg_write(QUARK_NC_HOST_BRIDGE_SB_PORT_ID, |
| 46 | QNC_MSG_FSBIC_REG_HMISC, data); |
| 47 | } |
Lee Leahy | d76d60b | 2016-03-03 15:30:48 -0800 | [diff] [blame] | 48 | } |
Lee Leahy | 70bb057 | 2017-03-13 16:37:20 -0700 | [diff] [blame] | 49 | |
| 50 | void *locate_rmu_file(size_t *rmu_file_len) |
| 51 | { |
Lee Leahy | 70bb057 | 2017-03-13 16:37:20 -0700 | [diff] [blame] | 52 | size_t fsize; |
| 53 | void *rmu_data; |
Lee Leahy | 70bb057 | 2017-03-13 16:37:20 -0700 | [diff] [blame] | 54 | |
| 55 | /* Locate the rmu.bin file in the read-only region of the flash */ |
Julius Werner | 9d0cc2a | 2020-01-22 18:00:18 -0800 | [diff] [blame] | 56 | rmu_data = cbfs_ro_map("rmu.bin", &fsize); |
| 57 | if (!rmu_data) |
Lee Leahy | 70bb057 | 2017-03-13 16:37:20 -0700 | [diff] [blame] | 58 | return NULL; |
| 59 | |
Lee Leahy | 70bb057 | 2017-03-13 16:37:20 -0700 | [diff] [blame] | 60 | if (rmu_file_len != NULL) |
| 61 | *rmu_file_len = fsize; |
| 62 | |
Lee Leahy | 70bb057 | 2017-03-13 16:37:20 -0700 | [diff] [blame] | 63 | return rmu_data; |
| 64 | } |