Angel Pons | 0612b27 | 2020-04-05 15:46:56 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Subrata Banik | 7e89984 | 2018-05-17 18:28:26 +0530 | [diff] [blame] | 2 | |
Subrata Banik | 32e0673 | 2022-01-28 02:05:15 +0530 | [diff] [blame] | 3 | #define __SIMPLE_DEVICE__ |
| 4 | |
Subrata Banik | 7e89984 | 2018-05-17 18:28:26 +0530 | [diff] [blame] | 5 | #include <commonlib/helpers.h> |
| 6 | #include <console/console.h> |
| 7 | #include <device/pci.h> |
| 8 | #include <device/pci_ids.h> |
| 9 | #include <device/pci_ops.h> |
| 10 | #include <intelblocks/cse.h> |
| 11 | #include <intelblocks/p2sb.h> |
| 12 | #include <intelblocks/pcr.h> |
Matt DeVillier | 148b545 | 2022-02-11 16:21:46 -0600 | [diff] [blame] | 13 | #include <intelblocks/pmc_ipc.h> |
Subrata Banik | 7e89984 | 2018-05-17 18:28:26 +0530 | [diff] [blame] | 14 | #include <soc/pci_devs.h> |
| 15 | #include <soc/pcr_ids.h> |
Subrata Banik | 7e89984 | 2018-05-17 18:28:26 +0530 | [diff] [blame] | 16 | |
| 17 | #define CSME0_FBE 0xf |
| 18 | #define CSME0_BAR 0x0 |
| 19 | #define CSME0_FID 0xb0 |
| 20 | |
Matt DeVillier | 148b545 | 2022-02-11 16:21:46 -0600 | [diff] [blame] | 21 | #define PMC_IPC_MEI_DISABLE_ID 0xa9 |
| 22 | #define PMC_IPC_MEI_DISABLE_SUBID_ENABLE 0 |
| 23 | #define PMC_IPC_MEI_DISABLE_SUBID_DISABLE 1 |
| 24 | |
Subrata Banik | 32e0673 | 2022-01-28 02:05:15 +0530 | [diff] [blame] | 25 | /* Disable HECI using PCR */ |
| 26 | static void heci1_disable_using_pcr(void) |
| 27 | { |
| 28 | soc_disable_heci1_using_pcr(); |
| 29 | } |
| 30 | |
Matt DeVillier | 148b545 | 2022-02-11 16:21:46 -0600 | [diff] [blame] | 31 | bool cse_disable_mei_devices(void) |
| 32 | { |
| 33 | struct pmc_ipc_buffer req = { 0 }; |
| 34 | struct pmc_ipc_buffer rsp; |
| 35 | uint32_t cmd; |
| 36 | |
| 37 | cmd = pmc_make_ipc_cmd(PMC_IPC_MEI_DISABLE_ID, PMC_IPC_MEI_DISABLE_SUBID_DISABLE, 0); |
| 38 | if (pmc_send_ipc_cmd(cmd, &req, &rsp) != CB_SUCCESS) { |
| 39 | printk(BIOS_ERR, "CSE: Failed to disable MEI devices\n"); |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | return true; |
| 44 | } |
| 45 | |
Subrata Banik | 32e0673 | 2022-01-28 02:05:15 +0530 | [diff] [blame] | 46 | /* Disable HECI using PMC IPC communication */ |
| 47 | static void heci1_disable_using_pmc(void) |
| 48 | { |
| 49 | cse_disable_mei_devices(); |
| 50 | } |
| 51 | |
Subrata Banik | 7e89984 | 2018-05-17 18:28:26 +0530 | [diff] [blame] | 52 | /* Disable HECI using Sideband interface communication */ |
Subrata Banik | 32e0673 | 2022-01-28 02:05:15 +0530 | [diff] [blame] | 53 | static void heci1_disable_using_sbi(void) |
Subrata Banik | 7e89984 | 2018-05-17 18:28:26 +0530 | [diff] [blame] | 54 | { |
| 55 | struct pcr_sbi_msg msg = { |
| 56 | .pid = PID_CSME0, |
| 57 | .offset = 0, |
| 58 | .opcode = PCR_WRITE, |
| 59 | .is_posted = false, |
| 60 | .fast_byte_enable = CSME0_FBE, |
| 61 | .bar = CSME0_BAR, |
| 62 | .fid = CSME0_FID |
| 63 | }; |
| 64 | /* Bit 0: Set to make HECI#1 Function disable */ |
| 65 | uint32_t data32 = 1; |
| 66 | uint8_t response; |
| 67 | int status; |
| 68 | |
| 69 | /* unhide p2sb device */ |
| 70 | p2sb_unhide(); |
| 71 | |
| 72 | /* Send SBI command to make HECI#1 function disable */ |
John Zhao | 98ce39d | 2022-01-10 10:51:24 -0800 | [diff] [blame] | 73 | status = pcr_execute_sideband_msg(PCH_DEV_P2SB, &msg, &data32, &response); |
Subrata Banik | 7e89984 | 2018-05-17 18:28:26 +0530 | [diff] [blame] | 74 | if (status || response) |
| 75 | printk(BIOS_ERR, "Fail to make CSME function disable\n"); |
| 76 | |
| 77 | /* Ensure to Lock SBI interface after this command */ |
| 78 | p2sb_disable_sideband_access(); |
| 79 | |
| 80 | /* hide p2sb device */ |
| 81 | p2sb_hide(); |
| 82 | } |
Subrata Banik | 32e0673 | 2022-01-28 02:05:15 +0530 | [diff] [blame] | 83 | |
| 84 | void heci1_disable(void) |
| 85 | { |
| 86 | if (!CONFIG(DISABLE_HECI1_AT_PRE_BOOT)) |
| 87 | return; |
| 88 | |
| 89 | if (ENV_SMM && CONFIG(SOC_INTEL_COMMON_BLOCK_HECI1_DISABLE_USING_SBI)) { |
| 90 | printk(BIOS_INFO, "Disabling Heci using SBI in SMM mode\n"); |
| 91 | return heci1_disable_using_sbi(); |
| 92 | } else if (!ENV_SMM && CONFIG(SOC_INTEL_COMMON_BLOCK_HECI1_DISABLE_USING_PMC_IPC)) { |
| 93 | printk(BIOS_INFO, "Disabling Heci using PMC IPC\n"); |
| 94 | return heci1_disable_using_pmc(); |
| 95 | } else if (!ENV_SMM && CONFIG(SOC_INTEL_COMMON_BLOCK_HECI1_DISABLE_USING_PCR)) { |
| 96 | printk(BIOS_INFO, "Disabling Heci using PCR\n"); |
| 97 | return heci1_disable_using_pcr(); |
| 98 | } else { |
| 99 | printk(BIOS_ERR, "%s Error: Unable to make HECI1 function disable!\n", |
| 100 | __func__); |
| 101 | } |
| 102 | } |