blob: 23a551ef57e7abbea2b17ac4f2e893ca3b018f5f [file] [log] [blame]
Angel Pons230e4f9d2020-04-05 15:47:14 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahy87df8d02016-02-07 14:37:13 -08002
Lee Leahy70bb0572017-03-13 16:37:20 -07003#include <cbfs.h>
Lee Leahy318ef962016-02-07 14:48:53 -08004#include <console/console.h>
Lee Leahy43cdff62016-02-07 14:52:22 -08005#include <fsp/util.h>
Lee Leahy87df8d02016-02-07 14:37:13 -08006#include <soc/pci_devs.h>
Lee Leahy318ef962016-02-07 14:48:53 -08007#include <soc/pm.h>
Lee Leahy87df8d02016-02-07 14:37:13 -08008#include <soc/romstage.h>
Lee Leahy3f0fe682016-05-15 14:13:30 -07009#include <soc/reg_access.h>
10
Lee Leahy01728bb2016-07-20 08:58:58 -070011static const struct reg_script clear_smi_and_wake_events_script[] = {
Lee Leahy7f4b0532016-05-22 11:52:28 -070012 /* 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 Leahy01728bb2016-07-20 08:58:58 -070020void clear_smi_and_wake_events(void)
Lee Leahyce9e21a2016-06-05 18:48:31 -070021{
Lee Leahy01728bb2016-07-20 08:58:58 -070022 struct chipset_power_state *ps;
Lee Leahy7f4b0532016-05-22 11:52:28 -070023
24 /* Clear SMI and wake events */
Lee Leahy01728bb2016-07-20 08:58:58 -070025 ps = get_power_state();
26 if (ps->prev_sleep_state != 3) {
Lee Leahy7f4b0532016-05-22 11:52:28 -070027 printk(BIOS_SPEW, "Clearing SMI interrupts and wake events\n");
Lee Leahy01728bb2016-07-20 08:58:58 -070028 reg_script_run_on_dev(LPC_BDF,
29 clear_smi_and_wake_events_script);
Lee Leahy7f4b0532016-05-22 11:52:28 -070030 }
Lee Leahy72179fa2016-06-04 16:09:44 -070031}
32
Lee Leahy01728bb2016-07-20 08:58:58 -070033void disable_rom_shadow(void)
Lee Leahyd75ed0b2016-03-04 16:49:40 -080034{
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 Leahyd75ed0b2016-03-04 16:49:40 -080040 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 Leahyd76d60b2016-03-03 15:30:48 -080048}
Lee Leahy70bb0572017-03-13 16:37:20 -070049
50void *locate_rmu_file(size_t *rmu_file_len)
51{
Lee Leahy70bb0572017-03-13 16:37:20 -070052 size_t fsize;
53 void *rmu_data;
Lee Leahy70bb0572017-03-13 16:37:20 -070054
55 /* Locate the rmu.bin file in the read-only region of the flash */
Julius Werner9d0cc2a2020-01-22 18:00:18 -080056 rmu_data = cbfs_ro_map("rmu.bin", &fsize);
57 if (!rmu_data)
Lee Leahy70bb0572017-03-13 16:37:20 -070058 return NULL;
59
Lee Leahy70bb0572017-03-13 16:37:20 -070060 if (rmu_file_len != NULL)
61 *rmu_file_len = fsize;
62
Lee Leahy70bb0572017-03-13 16:37:20 -070063 return rmu_data;
64}