Marshall Dawson | 5a73fc3 | 2020-01-24 09:42:57 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Marshall Dawson | 5a73fc3 | 2020-01-24 09:42:57 -0700 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <cpu/x86/msr.h> |
Marshall Dawson | e8ffa9f | 2020-03-16 19:20:20 -0600 | [diff] [blame] | 5 | #include <soc/smi.h> |
Kyösti Mälkki | 5b672d5 | 2019-11-25 21:23:37 +0200 | [diff] [blame] | 6 | #include <amdblocks/acpimmio.h> |
Marshall Dawson | 5a73fc3 | 2020-01-24 09:42:57 -0700 | [diff] [blame] | 7 | #include <amdblocks/psp.h> |
Felix Held | a5a5295 | 2020-12-01 18:14:01 +0100 | [diff] [blame^] | 8 | #include <amdblocks/smi.h> |
Marshall Dawson | 5a73fc3 | 2020-01-24 09:42:57 -0700 | [diff] [blame] | 9 | |
| 10 | #define PSP_MAILBOX_OFFSET 0x10570 |
| 11 | #define MSR_CU_CBBCFG 0xc00110a2 |
| 12 | |
| 13 | void *soc_get_mbox_address(void) |
| 14 | { |
| 15 | uintptr_t psp_mmio; |
| 16 | |
| 17 | psp_mmio = rdmsr(MSR_CU_CBBCFG).lo; |
| 18 | if (psp_mmio == 0xffffffff) { |
| 19 | printk(BIOS_WARNING, "PSP: MSR_CU_CBBCFG uninitialized\n"); |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | return (void *)(psp_mmio + PSP_MAILBOX_OFFSET); |
| 24 | } |
Marshall Dawson | e8ffa9f | 2020-03-16 19:20:20 -0600 | [diff] [blame] | 25 | |
| 26 | void soc_fill_smm_trig_info(struct smm_trigger_info *trig) |
| 27 | { |
| 28 | if (!trig) |
| 29 | return; |
| 30 | |
Marshall Dawson | 902518e | 2020-10-27 16:32:11 -0600 | [diff] [blame] | 31 | trig->address = (uintptr_t)acpimmio_smi + SMI_REG_SMITRIG0; |
Marshall Dawson | e8ffa9f | 2020-03-16 19:20:20 -0600 | [diff] [blame] | 32 | trig->address_type = SMM_TRIGGER_MEM; |
| 33 | trig->value_width = SMM_TRIGGER_DWORD; |
Marshall Dawson | 902518e | 2020-10-27 16:32:11 -0600 | [diff] [blame] | 34 | trig->value_and_mask = ~SMITRIG0_PSP; |
| 35 | trig->value_or_mask = SMITRIG0_PSP; |
Marshall Dawson | e8ffa9f | 2020-03-16 19:20:20 -0600 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void soc_fill_smm_reg_info(struct smm_register_info *reg) |
| 39 | { |
| 40 | if (!reg) |
| 41 | return; |
| 42 | |
Kyösti Mälkki | 5b672d5 | 2019-11-25 21:23:37 +0200 | [diff] [blame] | 43 | reg->smi_enb.address = (uintptr_t)acpimmio_smi + SMI_REG_SMITRIG0; |
Marshall Dawson | e8ffa9f | 2020-03-16 19:20:20 -0600 | [diff] [blame] | 44 | reg->smi_enb.address_type = SMM_TRIGGER_MEM; |
| 45 | reg->smi_enb.value_width = SMM_TRIGGER_DWORD; |
| 46 | reg->smi_enb.reg_bit_mask = SMITRG0_SMIENB; |
| 47 | reg->smi_enb.expect_value = 0; |
| 48 | |
Kyösti Mälkki | 5b672d5 | 2019-11-25 21:23:37 +0200 | [diff] [blame] | 49 | reg->eos.address = (uintptr_t)acpimmio_smi + SMI_REG_SMITRIG0; |
Marshall Dawson | e8ffa9f | 2020-03-16 19:20:20 -0600 | [diff] [blame] | 50 | reg->eos.address_type = SMM_TRIGGER_MEM; |
| 51 | reg->eos.value_width = SMM_TRIGGER_DWORD; |
| 52 | reg->eos.reg_bit_mask = SMITRG0_EOS; |
| 53 | reg->eos.expect_value = SMITRG0_EOS; |
| 54 | |
Kyösti Mälkki | 5b672d5 | 2019-11-25 21:23:37 +0200 | [diff] [blame] | 55 | reg->psp_smi_en.address = (uintptr_t)acpimmio_smi + SMI_REG_CONTROL0; |
Marshall Dawson | e8ffa9f | 2020-03-16 19:20:20 -0600 | [diff] [blame] | 56 | reg->psp_smi_en.address += sizeof(uint32_t) * SMITYPE_PSP / 16; |
| 57 | reg->psp_smi_en.address_type = SMM_TRIGGER_MEM; |
| 58 | reg->psp_smi_en.value_width = SMM_TRIGGER_DWORD; |
| 59 | reg->psp_smi_en.reg_bit_mask = SMI_MODE_MASK << (2 * SMITYPE_PSP % 16); |
| 60 | reg->psp_smi_en.expect_value = SMI_MODE_SMI << (2 * SMITYPE_PSP % 16); |
| 61 | } |