1 /* 2 * Copyright (c) 2017-2018 Cavium, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 * 27 */ 28 29 /**************************************************************************** 30 * Name: spad_layout.h 31 * 32 * Description: Global definitions 33 * 34 * Created: 01/09/2013 35 * 36 ****************************************************************************/ 37 /* 38 * Spad Layout NVM CFG MCP public 39 *========================================================================================================== 40 * MCP_REG_SCRATCH REG_RD(MISC_REG_GEN_PURP_CR0) REG_RD(MISC_REG_SHARED_MEM_ADDR) 41 * +------------------+ +-------------------------+ +-------------------+ 42 * | Num Sections(4B)|Currently 4 | Num Sections(4B) | | Num Sections(4B)|Currently 6 43 * +------------------+ +-------------------------+ +-------------------+ 44 * | Offsize(Trace) |4B -+ +-- | Offset(NVM_CFG1) | | Offsize(drv_mb) | 45 * +-| Offsize(NVM_CFG) |4B | | | (Size is fixed) | | Offsize(mfw_mb) | 46 *+-|-| Offsize(Public) |4B | +-> +-------------------------+ | Offsize(global) | 47 *| | | Offsize(Private) |4B | | | | Offsize(path) | 48 *| | +------------------+ <--+ | nvm_cfg1_glob | | Offsize(port) | 49 *| | | | +-------------------------+ | Offsize(func) | 50 *| | | Trace | | nvm_cfg1_path 0 | +-------------------+ 51 *| +>+------------------+ | nvm_cfg1_path 1 | | drv_mb PF0/2/4..|8 Funcs of engine0 52 *| | | +-------------------------+ | drv_mb PF1/3/5..|8 Funcs of engine1 53 *| | NVM_CFG | | nvm_cfg1_port 0 | +-------------------+ 54 *+-> +------------------+ | .... | | mfw_mb PF0/2/4..|8 Funcs of engine0 55 * | | | nvm_cfg1_port 3 | | mfw_mb PF1/3/5..|8 Funcs of engine1 56 * | Public Data | +-------------------------+ +-------------------+ 57 * +------------------+ 8 Funcs of Engine 0| nvm_cfg1_func PF0/2/4/..| | | 58 * | | 8 Funcs of Engine 1| nvm_cfg1_func PF1/3/5/..| | public_global | 59 * | Private Data | +-------------------------+ +-------------------+ 60 * +------------------+ | public_path 0 | 61 * | Code | | public_path 1 | 62 * | Static Area | +-------------------+ 63 * +--- ---+ | public_port 0 | 64 * | Code | | .... | 65 * | PIM Area | | public_port 3 | 66 * +------------------+ +-------------------+ 67 * | public_func 0/2/4.|8 Funcs of engine0 68 * | public_func 1/3/5.|8 Funcs of engine1 69 * +-------------------+ 70 */ 71 #ifndef SPAD_LAYOUT_H 72 #define SPAD_LAYOUT_H 73 74 #ifndef MDUMP_PARSE_TOOL 75 76 #define PORT_0 0 77 #define PORT_1 1 78 #define PORT_2 2 79 #define PORT_3 3 80 81 #include "mcp_public.h" 82 #include "mfw_hsi.h" 83 #include "nvm_cfg.h" 84 85 #ifdef MFW 86 #include "mcp_private.h" 87 #endif 88 89 extern struct spad_layout g_spad; 90 91 /* TBD - Consider renaming to MCP_STATIC_SPAD_SIZE, since the real size includes another 64kb */ 92 #define MCP_SPAD_SIZE 0x00028000 /* 160 KB */ 93 94 #define SPAD_OFFSET(addr) (((u32)addr - (u32)CPU_SPAD_BASE)) 95 #endif /* MDUMP_PARSE_TOOL */ 96 97 #define TO_OFFSIZE(_offset, _size) \ 98 (u32)((((u32)(_offset) >> 2) << OFFSIZE_OFFSET_OFFSET) | \ 99 (((u32)(_size) >> 2) << OFFSIZE_SIZE_OFFSET)) 100 101 enum spad_sections { 102 SPAD_SECTION_TRACE, 103 SPAD_SECTION_NVM_CFG, 104 SPAD_SECTION_PUBLIC, 105 SPAD_SECTION_PRIVATE, 106 SPAD_SECTION_MAX /* Cannot be modified anymore since ROM relying on this size !! */ 107 }; 108 109 #ifndef MDUMP_PARSE_TOOL 110 struct spad_layout { 111 struct nvm_cfg nvm_cfg; 112 struct mcp_public_data public_data; 113 #ifdef MFW /* Drivers will not be compiled with this flag. */ 114 /* Linux should remove this appearance at all. */ 115 struct mcp_private_data private_data; 116 #endif 117 }; 118 119 #endif /* MDUMP_PARSE_TOOL */ 120 121 #define STRUCT_OFFSET(f) (STATIC_INIT_BASE + __builtin_offsetof(struct static_init, f)) 122 123 /* This section is located at a fixed location in the beginning of the scratchpad, 124 * to ensure that the MCP trace is not run over during MFW upgrade. 125 * All the rest of data has a floating location which differs from version to version, 126 * and is pointed by the mcp_meta_data below. 127 * Moreover, the spad_layout section is part of the MFW firmware, and is loaded with it 128 * from nvram in order to clear this portion. 129 */ 130 131 struct static_init { 132 u32 num_sections; /* 0xe20000 */ 133 offsize_t sections[SPAD_SECTION_MAX]; /* 0xe20004 */ 134 #define SECTION(_sec_) *((offsize_t*)(STRUCT_OFFSET(sections[_sec_]))) 135 136 #ifdef SECURE_BOOT 137 u32 tim_sha256[8]; /* Used by E5 ROM. Do not relocate */ 138 u32 rom_status_code; /* Used by E5 ROM. Do not relocate */ 139 u32 secure_running_mfw; /* Instead of the one after the trace_buffer */ /* Used by E5 ROM. Do not relocate */ 140 #define SECURE_RUNNING_MFW *((u32*)(STRUCT_OFFSET(secure_running_mfw))) 141 #endif 142 143 struct mcp_trace trace; /* 0xe20014 */ 144 145 #ifdef MFW 146 #define MCP_TRACE_P ((struct mcp_trace*)(STRUCT_OFFSET(trace))) 147 u8 trace_buffer[MCP_TRACE_SIZE]; /* 0xe20030 */ 148 #define MCP_TRACE_BUF ((u8*)(STRUCT_OFFSET(trace_buffer))) 149 /* running_mfw has the same definition as in nvm_map.h. 150 * This bit indicate both the running dir, and the running bundle. 151 * It is set once when the LIM is loaded. 152 */ 153 u32 running_mfw; /* 0xe20830 */ 154 #define RUNNING_MFW *((u32*)(STRUCT_OFFSET(running_mfw))) 155 u32 build_time; /* 0xe20834 */ 156 #define MFW_BUILD_TIME *((u32*)(STRUCT_OFFSET(build_time))) 157 u32 reset_type; /* 0xe20838 */ 158 #define RESET_TYPE *((u32*)(STRUCT_OFFSET(reset_type))) 159 u32 mfw_secure_mode; /* 0xe2083c */ 160 #define MFW_SECURE_MODE *((u32*)(STRUCT_OFFSET(mfw_secure_mode))) 161 u16 pme_status_pf_bitmap; /* 0xe20840 */ 162 #define PME_STATUS_PF_BITMAP *((u16*)(STRUCT_OFFSET(pme_status_pf_bitmap))) 163 u16 pme_enable_pf_bitmap; 164 #define PME_ENABLE_PF_BITMAP *((u16*)(STRUCT_OFFSET(pme_enable_pf_bitmap))) 165 u32 mim_nvm_addr; /* 0xe20844 */ 166 u32 mim_start_addr; /* 0xe20848 */ 167 u32 ah_pcie_link_params; /* 0xe20850 Stores PCIe link configuration at start, so they can be used later also for Hot-Reset, without the need to re-reading them from nvm cfg. */ 168 #define AH_PCIE_LINK_PARAMS_LINK_SPEED_MASK (0x000000ff) 169 #define AH_PCIE_LINK_PARAMS_LINK_SPEED_OFFSET (0) 170 #define AH_PCIE_LINK_PARAMS_LINK_WIDTH_MASK (0x0000ff00) 171 #define AH_PCIE_LINK_PARAMS_LINK_WIDTH_OFFSET (8) 172 #define AH_PCIE_LINK_PARAMS_ASPM_MODE_MASK (0x00ff0000) 173 #define AH_PCIE_LINK_PARAMS_ASPM_MODE_OFFSET (16) 174 #define AH_PCIE_LINK_PARAMS_ASPM_CAP_MASK (0xff000000) 175 #define AH_PCIE_LINK_PARAMS_ASPM_CAP_OFFSET (24) 176 #define AH_PCIE_LINK_PARAMS *((u32*)(STRUCT_OFFSET(ah_pcie_link_params))) 177 178 u32 flags; /* 0xe20850 */ 179 #define M_GLOB_FLAGS *((u32*)(STRUCT_OFFSET(flags))) 180 #define FLAGS_VAUX_REQUIRED (1 << 0) 181 #define FLAGS_WAIT_AVS_READY (1 << 1) 182 #define FLAGS_FAILURE_ISSUED (1 << 2) 183 #define FLAGS_FAILURE_DETECTED (1 << 3) 184 #define FLAGS_VAUX (1 << 4) 185 #define FLAGS_PERST_ASSERT_OCCURED (1 << 5) 186 #define FLAGS_HOT_RESET_STEP2 (1 << 6) 187 #define FLAGS_MSIX_SYNC_ALLOWED (1 << 7) 188 #define FLAGS_PROGRAM_PCI_COMPLETED (1 << 8) 189 #define FLAGS_SMBUS_AUX_MODE (1 << 9) 190 #define FLAGS_PEND_SMBUS_VMAIN_TO_AUX (1 << 10) 191 #define FLAGS_NVM_CFG_EFUSE_FAILURE (1 << 11) 192 #define FLAGS_POWER_TRANSITION (1 << 12) 193 #define FLAGS_MCTP_CHECK_PUMA_TIMEOUT (1 << 13) 194 #define FLAGS_MCTP_TX_PLDM_UPDATE (1 << 14) 195 #define FLAGS_MCTP_SENSOR_EVENT (1 << 15) 196 #define FLAGS_PMBUS_ERROR (1 << 28) 197 #define FLAGS_OS_DRV_LOADED (1 << 29) 198 #define FLAGS_OVER_TEMP_OCCUR (1 << 30) 199 #define FLAGS_FAN_FAIL_OCCUR (1 << 31) 200 u32 rsrv_persist[4]; /* Persist reserved for MFW upgrades */ /* 0xe20854 */ 201 #endif /* MFW */ 202 }; 203 204 #ifndef MDUMP_PARSE_TOOL 205 #define NVM_CFG1(x) g_spad.nvm_cfg.cfg1.x 206 #define NVM_GLOB(x) NVM_CFG1(glob).x 207 #define NVM_GLOB_VAL(n, m, o) ((NVM_GLOB(n) & m) >> o) 208 #endif /* MDUMP_PARSE_TOOL */ 209 210 #endif /* SPAD_LAYOUT_H */ 211