blob: 25ff2d62266cfcedcdb8ff0213505c582bd84ae7 [file] [log] [blame]
Annie Chend31cbc72023-06-02 09:57:28 +08001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <console/console.h>
4#include <drivers/vpd/vpd.h>
5#include <drivers/ocp/include/vpd.h>
6#include <drivers/ipmi/ipmi_if.h>
7#include <drivers/ipmi/ocp/ipmi_ocp.h>
8#include <drivers/ocp/ewl/ocp_ewl.h>
Shuo Liuc2ed5ea2024-05-11 03:23:23 +08009#include <soc/config.h>
Annie Chend31cbc72023-06-02 09:57:28 +080010#include <soc/romstage.h>
11#include <defs_cxl.h>
12#include <defs_iio.h>
13#include <sprsp_ac_iio.h>
Arthur Heymansfff762e2024-03-28 14:42:50 +010014#include <stdint.h>
Annie Chend31cbc72023-06-02 09:57:28 +080015
16#include "ipmi.h"
17
18void mainboard_ewl_check(void)
19{
20 /* Enhanced Warning Log prints EWL type 3 primarily associated with MRC training failures */
21 get_ewl();
22}
23
24static void mainboard_config_iio(FSPM_UPD *mupd)
25{
26 int port;
27
28 UPD_IIO_PCIE_PORT_CONFIG *PciePortConfig =
Arthur Heymansfff762e2024-03-28 14:42:50 +010029 (UPD_IIO_PCIE_PORT_CONFIG *)(uintptr_t)mupd->FspmConfig.IioPcieConfigTablePtr;
Annie Chend31cbc72023-06-02 09:57:28 +080030
31 /* Socket0: Array ac_iio_pci_port_skt0 only configures DMI, IOU0 ~ IOU4, the rest will be left zero */
32 for (port = 0; port < ARRAY_SIZE(ac_iio_pci_port_skt0); port++) {
33 PciePortConfig[0].SLOTIMP[port] = ac_iio_pci_port_skt0[port].SLOTIMP;
34 PciePortConfig[0].SLOTPSP[port] = ac_iio_pci_port_skt0[port].SLOTPSP;
35 PciePortConfig[0].PciePortEnable[port] = ac_iio_pci_port_skt0[port].PciePortEnable;
36 PciePortConfig[0].PEXPHIDE[port] = ac_iio_pci_port_skt0[port].PEXPHIDE;
37 PciePortConfig[0].PcieMaxPayload[port] = ac_iio_pci_port_skt0[port].PcieMaxPayload;
38 PciePortConfig[0].PciePortLinkSpeed[port] = ac_iio_pci_port_skt0[port].PciePortLinkSpeed;
39 PciePortConfig[0].DfxDnTxPresetGen3[port] = ac_iio_pci_port_skt0[port].DfxDnTxPresetGen3;
40 }
41 /* Socket0: IOU5 ~ IOU6 are not used, set PEXPHIDE and HidePEXPMenu to 1 */
42 for (port = ARRAY_SIZE(ac_iio_pci_port_skt0); port < MAX_IIO_PORTS_PER_SOCKET; port++) {
43 PciePortConfig[0].PEXPHIDE[port] = 1;
44 PciePortConfig[0].HidePEXPMenu[port] = 1;
45 }
46 PciePortConfig[0].ConfigIOU[0] = IIO_BIFURCATE_xxxxxx16;
47 PciePortConfig[0].ConfigIOU[1] = IIO_BIFURCATE_xxxxxx16;
48 PciePortConfig[0].ConfigIOU[2] = IIO_BIFURCATE_xxxxxx16;
49 PciePortConfig[0].ConfigIOU[3] = IIO_BIFURCATE_xxx8xxx8;
50 PciePortConfig[0].ConfigIOU[4] = IIO_BIFURCATE_xxxxxx16;
51
52 PciePortConfig[0].PcieGlobalAspm = 0x1;
53 PciePortConfig[0].PcieMaxReadRequestSize = 0x5;
54
55 /* Socket1: Array ac_iio_pci_port_skt1 only configures DMI, IOU0 ~ IOU4, the rest will be left zero */
56 for (port = 0; port < ARRAY_SIZE(ac_iio_pci_port_skt1); port++) {
57 PciePortConfig[1].SLOTIMP[port] = ac_iio_pci_port_skt1[port].SLOTIMP;
58 PciePortConfig[1].SLOTPSP[port] = ac_iio_pci_port_skt1[port].SLOTPSP;
59 PciePortConfig[1].PciePortEnable[port] = ac_iio_pci_port_skt1[port].PciePortEnable;
60 PciePortConfig[1].PEXPHIDE[port] = ac_iio_pci_port_skt1[port].PEXPHIDE;
61 PciePortConfig[1].PcieMaxPayload[port] = ac_iio_pci_port_skt1[port].PcieMaxPayload;
62 PciePortConfig[1].PciePortLinkSpeed[port] = ac_iio_pci_port_skt1[port].PciePortLinkSpeed;
63 PciePortConfig[1].DfxDnTxPresetGen3[port] = ac_iio_pci_port_skt1[port].DfxDnTxPresetGen3;
64 }
65 /* Socket1: IOU5 ~ IOU6 are not used, set PEXPHIDE and HidePEXPMenu to 1 */
66 for (port = ARRAY_SIZE(ac_iio_pci_port_skt1); port < MAX_IIO_PORTS_PER_SOCKET; port++) {
67 PciePortConfig[1].PEXPHIDE[port] = 1;
68 PciePortConfig[1].HidePEXPMenu[port] = 1;
69 }
70 PciePortConfig[1].ConfigIOU[0] = IIO_BIFURCATE_x4x4x4x4;
71 PciePortConfig[1].ConfigIOU[1] = IIO_BIFURCATE_xxxxxx16;
72 PciePortConfig[1].ConfigIOU[2] = IIO_BIFURCATE_xxxxxx16;
73 PciePortConfig[1].ConfigIOU[3] = IIO_BIFURCATE_xxxxxx16;
74 PciePortConfig[1].ConfigIOU[4] = IIO_BIFURCATE_xxx8xxx8;
75
76 PciePortConfig[1].PcieGlobalAspm = 0x1;
77 PciePortConfig[1].PcieMaxReadRequestSize = 0x5;
78
79 /* If CONFIG(OCP_VPD) is not enabled or CXL is explicitly disabled, don't enable CXL */
80 if (!CONFIG(OCP_VPD) || get_cxl_mode_from_vpd() == CXL_DISABLED) {
81 printk(BIOS_DEBUG, "Don't enable CXL via VPD %s\n", CXL_MODE);
82 } else {
83 /* Set socket 0 IIO PCIe PE1 to CXL mode */
84 /* Set socket 1 IIO PCIe PE0 to CXL mode */
85 /* eg. Protocl Auto Negotiation */
86 mupd->FspmConfig.IioPcieSubSystemMode1[0] = IIO_MODE_CXL;
87 mupd->FspmConfig.IioPcieSubSystemMode0[1] = IIO_MODE_CXL;
88
89 /* Disable CXL header bypass */
90 mupd->FspmConfig.DfxCxlHeaderBypass = 0;
91
92 /* Set DFX CXL security level to fully trusted */
93 mupd->FspmConfig.DfxCxlSecLvl = CXL_SECURITY_FULLY_TRUSTED;
94
95 /* Set DelayAfterPCIeLinkTraining to 2000 ms */
96 mupd->FspmConfig.DelayAfterPCIeLinkTraining = 2000;
97 }
98}
99
100void mainboard_memory_init_params(FSPM_UPD *mupd)
101{
Annie Chend31cbc72023-06-02 09:57:28 +0800102 /* Since it's the first IPMI command, it's better to run get BMC selftest result first */
103 if (ipmi_premem_init(CONFIG_BMC_KCS_BASE, 0) == CB_SUCCESS) {
104 init_frb2_wdt();
105 }
106
Shuo Liu45a670d2024-04-26 06:15:35 +0800107 /* Setup FSP log */
108 mupd->FspmConfig.SerialIoUartDebugEnable = get_bool_from_vpd(FSP_LOG,
109 FSP_LOG_DEFAULT);
110 if (mupd->FspmConfig.SerialIoUartDebugEnable) {
111 mupd->FspmConfig.serialDebugMsgLvl = get_int_from_vpd_range(
112 FSP_MEM_LOG_LEVEL, FSP_MEM_LOG_LEVEL_DEFAULT, 0, 4);
113 /* If serialDebugMsgLvl less than 1, disable FSP memory train results */
114 if (mupd->FspmConfig.serialDebugMsgLvl <= 1) {
115 printk(BIOS_DEBUG, "Setting serialDebugMsgLvlTrainResults to 0\n");
116 mupd->FspmConfig.serialDebugMsgLvlTrainResults = 0x0;
117 }
Annie Chend31cbc72023-06-02 09:57:28 +0800118 }
119
Shuo Liu45a670d2024-04-26 06:15:35 +0800120 /* FSP Dfx PMIC Secure mode */
121 mupd->FspmConfig.DfxPmicSecureMode = get_int_from_vpd_range(
122 FSP_PMIC_SECURE_MODE, FSP_PMIC_SECURE_MODE_DEFAULT, 0, 2);
123
Annie Chend31cbc72023-06-02 09:57:28 +0800124 /* Set Rank Margin Tool to disable. */
125 mupd->FspmConfig.EnableRMT = 0x0;
126 /* Enable - Portions of memory reference code will be skipped when possible to increase boot speed on warm boots */
127 /* Disable - Disables this feature */
128 /*Auto - Sets it to the MRC default setting */
129 mupd->FspmConfig.AttemptFastBoot = 0x1;
130 /* Set Attempt Fast Cold Boot to enable */
131 /* Enable - Portions of memory reference code will be skipped when possible to increase boot speed on cold boots */
132 /* Disable - Disables this feature */
133 /* Auto - Sets it to the MRC default setting */
134 mupd->FspmConfig.AttemptFastBootCold = 0x1;
135
136 /* Set Adv MemTest Option to 0. */
137 mupd->FspmConfig.AdvMemTestOptions = 0x0;
138 /* Set MRC Promote Warnings to disable. */
139 /* Determines if MRC warnings are promoted to system level. */
140 mupd->FspmConfig.promoteMrcWarnings = 0x0;
141 /* Set Promote Warnings to disable. */
142 /* Determines if warnings are promoted to system level. */
143 mupd->FspmConfig.promoteWarnings = 0x0;
144
145 /* Reduce FSP debug message to Minimum */
146 mupd->FspmConfig.serialDebugMsgLvl = 0x1;
147
148 /* Disable FSP memory train results */
149 mupd->FspmConfig.serialDebugMsgLvlTrainResults = 0x0;
150
151 mainboard_config_iio(mupd);
152}