blob: 84a09fd3b26e83128d05a59871eff8adfed741f3 [file] [log] [blame]
Angel Pons0612b272020-04-05 15:46:56 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Subrata Banik7e899842018-05-17 18:28:26 +05302
Subrata Banik32e06732022-01-28 02:05:15 +05303#define __SIMPLE_DEVICE__
4
Subrata Banik7e899842018-05-17 18:28:26 +05305#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 DeVillier148b5452022-02-11 16:21:46 -060013#include <intelblocks/pmc_ipc.h>
Subrata Banik7e899842018-05-17 18:28:26 +053014#include <soc/pci_devs.h>
15#include <soc/pcr_ids.h>
Subrata Banik7e899842018-05-17 18:28:26 +053016
17#define CSME0_FBE 0xf
18#define CSME0_BAR 0x0
19#define CSME0_FID 0xb0
20
Matt DeVillier148b5452022-02-11 16:21:46 -060021#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 Banik32e06732022-01-28 02:05:15 +053025/* Disable HECI using PCR */
26static void heci1_disable_using_pcr(void)
27{
28 soc_disable_heci1_using_pcr();
29}
30
Matt DeVillier148b5452022-02-11 16:21:46 -060031bool 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 Banik32e06732022-01-28 02:05:15 +053046/* Disable HECI using PMC IPC communication */
47static void heci1_disable_using_pmc(void)
48{
49 cse_disable_mei_devices();
50}
51
Subrata Banik7e899842018-05-17 18:28:26 +053052/* Disable HECI using Sideband interface communication */
Subrata Banik32e06732022-01-28 02:05:15 +053053static void heci1_disable_using_sbi(void)
Subrata Banik7e899842018-05-17 18:28:26 +053054{
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 Zhao98ce39d2022-01-10 10:51:24 -080073 status = pcr_execute_sideband_msg(PCH_DEV_P2SB, &msg, &data32, &response);
Subrata Banik7e899842018-05-17 18:28:26 +053074 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 Banik32e06732022-01-28 02:05:15 +053083
84void 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}