Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * AMD DMI Record Creation API, and related functions. |
| 6 | * |
| 7 | * Contains code that produce the DMI related information. |
| 8 | * |
| 9 | * @xrefitem bom "File Content Label" "Release Content" |
| 10 | * @e project: AGESA |
| 11 | * @e sub-project: CPU |
| 12 | * @e \$Revision: 38893 $ @e \$Date: 2010-10-01 23:54:37 +0800 (Fri, 01 Oct 2010) $ |
| 13 | * |
| 14 | */ |
| 15 | /* |
| 16 | ***************************************************************************** |
| 17 | * |
| 18 | * Copyright (c) 2011, Advanced Micro Devices, Inc. |
| 19 | * All rights reserved. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 20 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 21 | * Redistribution and use in source and binary forms, with or without |
| 22 | * modification, are permitted provided that the following conditions are met: |
| 23 | * * Redistributions of source code must retain the above copyright |
| 24 | * notice, this list of conditions and the following disclaimer. |
| 25 | * * Redistributions in binary form must reproduce the above copyright |
| 26 | * notice, this list of conditions and the following disclaimer in the |
| 27 | * documentation and/or other materials provided with the distribution. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 28 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 29 | * its contributors may be used to endorse or promote products derived |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 30 | * from this software without specific prior written permission. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 31 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 35 | * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY |
| 36 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 37 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 38 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 39 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 40 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 41 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 42 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 43 | * *************************************************************************** |
| 44 | * |
| 45 | */ |
| 46 | |
| 47 | /*---------------------------------------------------------------------------------------- |
| 48 | * M O D U L E S U S E D |
| 49 | *---------------------------------------------------------------------------------------- |
| 50 | */ |
| 51 | #include "AGESA.h" |
| 52 | #include "amdlib.h" |
| 53 | #include "cpuRegisters.h" |
| 54 | #include "OptionDmi.h" |
| 55 | #include "cpuLateInit.h" |
| 56 | #include "cpuF14PowerMgmt.h" |
| 57 | #include "cpuFamilyTranslation.h" |
| 58 | #include "cpuPstateTables.h" |
| 59 | #include "cpuF14Utilities.h" |
| 60 | #include "Filecode.h" |
| 61 | #define FILECODE PROC_CPU_FAMILY_0X14_CPUF14DMI_FILECODE |
| 62 | |
| 63 | /*---------------------------------------------------------------------------------------- |
| 64 | * D E F I N I T I O N S A N D M A C R O S |
| 65 | *---------------------------------------------------------------------------------------- |
| 66 | */ |
| 67 | extern CPU_FAMILY_SUPPORT_TABLE PstateFamilyServiceTable; |
| 68 | |
| 69 | /*---------------------------------------------------------------------------------------- |
| 70 | * T Y P E D E F S A N D S T R U C T U R E S |
| 71 | *---------------------------------------------------------------------------------------- |
| 72 | */ |
| 73 | |
| 74 | /*---------------------------------------------------------------------------------------- |
| 75 | * P R O T O T Y P E S O F L O C A L F U N C T I O N S |
| 76 | *---------------------------------------------------------------------------------------- |
| 77 | */ |
| 78 | |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 79 | VOID |
| 80 | DmiF14GetInfo ( |
| 81 | IN OUT CPU_TYPE_INFO *CpuInfoPtr, |
| 82 | IN AMD_CONFIG_PARAMS *StdHeader |
| 83 | ); |
| 84 | |
| 85 | UINT8 |
| 86 | DmiF14GetVoltage ( |
| 87 | IN AMD_CONFIG_PARAMS *StdHeader |
| 88 | ); |
| 89 | |
| 90 | UINT16 |
| 91 | DmiF14GetMaxSpeed ( |
| 92 | IN AMD_CONFIG_PARAMS *StdHeader |
| 93 | ); |
| 94 | |
| 95 | UINT16 |
| 96 | DmiF14GetExtClock ( |
| 97 | IN AMD_CONFIG_PARAMS *StdHeader |
| 98 | ); |
| 99 | |
| 100 | VOID |
| 101 | DmiF14GetMemInfo ( |
| 102 | IN OUT CPU_GET_MEM_INFO *CpuGetMemInfoPtr, |
| 103 | IN AMD_CONFIG_PARAMS *StdHeader |
| 104 | ); |
| 105 | |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 106 | /*---------------------------------------------------------------------------------------- |
| 107 | * E X P O R T E D F U N C T I O N S |
| 108 | *---------------------------------------------------------------------------------------- |
| 109 | */ |
| 110 | |
| 111 | /* -----------------------------------------------------------------------------*/ |
| 112 | /** |
| 113 | * |
| 114 | * DmiF14GetInfo |
| 115 | * |
| 116 | * Get CPU type information |
| 117 | * |
| 118 | * @param[in,out] CpuInfoPtr Pointer to CPU_TYPE_INFO struct. |
| 119 | * @param[in] StdHeader Standard Head Pointer |
| 120 | * |
| 121 | */ |
| 122 | VOID |
| 123 | DmiF14GetInfo ( |
| 124 | IN OUT CPU_TYPE_INFO *CpuInfoPtr, |
| 125 | IN AMD_CONFIG_PARAMS *StdHeader |
| 126 | ) |
| 127 | { |
| 128 | CPUID_DATA CpuId; |
| 129 | |
| 130 | LibAmdCpuidRead (AMD_CPUID_FMF, &CpuId, StdHeader); |
| 131 | CpuInfoPtr->ExtendedFamily = (UINT8) (CpuId.EAX_Reg >> 20) & 0xFF; // bit 27:20 |
| 132 | CpuInfoPtr->ExtendedModel = (UINT8) (CpuId.EAX_Reg >> 16) & 0xF; // bit 19:16 |
| 133 | CpuInfoPtr->BaseFamily = (UINT8) (CpuId.EAX_Reg >> 8) & 0xF; // bit 11:8 |
| 134 | CpuInfoPtr->BaseModel = (UINT8) (CpuId.EAX_Reg >> 4) & 0xF; // bit 7:4 |
| 135 | CpuInfoPtr->Stepping = (UINT8) (CpuId.EAX_Reg & 0xF); // bit 3:0 |
| 136 | |
| 137 | CpuInfoPtr->PackageType = (UINT8) (CpuId.EBX_Reg >> 28) & 0xF; // bit 31:28 |
| 138 | CpuInfoPtr->BrandId.Pg = (UINT8) (CpuId.EBX_Reg >> 15) & 0x1; // bit 15 |
| 139 | CpuInfoPtr->BrandId.String1 = (UINT8) (CpuId.EBX_Reg >> 11) & 0xF; // bit 14:11 |
| 140 | CpuInfoPtr->BrandId.Model = (UINT8) (CpuId.EBX_Reg >> 4) & 0x7F; // bit 10:4 |
| 141 | CpuInfoPtr->BrandId.String2 = (UINT8) (CpuId.EBX_Reg & 0xF); // bit 3:0 |
| 142 | |
| 143 | LibAmdCpuidRead (AMD_CPUID_ASIZE_PCCOUNT, &CpuId, StdHeader); |
| 144 | CpuInfoPtr->TotalCoreNumber = (UINT8) (CpuId.ECX_Reg & 0xFF); // bit 7:0 |
| 145 | CpuInfoPtr->EnabledCoreNumber = (UINT8) (CpuId.ECX_Reg & 0xFF); // bit 7:0 |
| 146 | |
| 147 | switch (CpuInfoPtr->PackageType) { |
| 148 | case ON_SOCKET_FT1: |
| 149 | CpuInfoPtr->ProcUpgrade = P_UPGRADE_NONE; |
| 150 | break; |
| 151 | default: |
| 152 | CpuInfoPtr->ProcUpgrade = P_UPGRADE_UNKNOWN; |
| 153 | break; |
| 154 | } |
| 155 | |
| 156 | } |
| 157 | |
| 158 | /* -----------------------------------------------------------------------------*/ |
| 159 | /** |
| 160 | * |
| 161 | * DmiF14GetVoltage |
| 162 | * |
| 163 | * Get the voltage value according to SMBIOS SPEC's requirement. |
| 164 | * |
| 165 | * @param[in] StdHeader Standard Head Pointer |
| 166 | * |
| 167 | * @retval Voltage - CPU Voltage. |
| 168 | * |
| 169 | */ |
| 170 | UINT8 |
| 171 | DmiF14GetVoltage ( |
| 172 | IN AMD_CONFIG_PARAMS *StdHeader |
| 173 | ) |
| 174 | { |
| 175 | UINT8 MaxVid; |
| 176 | UINT8 Voltage; |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 177 | UINT8 NumberBoostStates; |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 178 | UINT64 MsrData; |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 179 | PCI_ADDR TempAddr; |
| 180 | CPU_LOGICAL_ID CpuFamilyRevision; |
| 181 | CPB_CTRL_REGISTER CpbCtrl; |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 182 | |
| 183 | // Voltage = 0x80 + (voltage at boot time * 10) |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 184 | GetLogicalIdOfCurrentCore (&CpuFamilyRevision, StdHeader); |
| 185 | if ((CpuFamilyRevision.Revision & (AMD_F14_ON_Ax | AMD_F14_ON_Bx)) == 0) { |
| 186 | TempAddr.AddressValue = CPB_CTRL_PCI_ADDR; |
| 187 | LibAmdPciRead (AccessWidth32, TempAddr, &CpbCtrl, StdHeader); // F4x15C |
| 188 | NumberBoostStates = (UINT8) CpbCtrl.NumBoostStates; |
| 189 | } else { |
| 190 | NumberBoostStates = 0; |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 191 | } |
| 192 | |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 193 | LibAmdMsrRead ((MSR_PSTATE_0 + NumberBoostStates), &MsrData, StdHeader); |
| 194 | MaxVid = (UINT8) (((PSTATE_MSR *)&MsrData)->CpuVid); |
| 195 | |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 196 | if ((MaxVid >= 0x7C) && (MaxVid <= 0x7F)) { |
| 197 | Voltage = 0; |
| 198 | } else { |
| 199 | Voltage = (UINT8) ((15500 - (125 * MaxVid) + 500) / 1000); |
| 200 | } |
| 201 | |
| 202 | Voltage += 0x80; |
| 203 | return (Voltage); |
| 204 | } |
| 205 | |
| 206 | /* -----------------------------------------------------------------------------*/ |
| 207 | /** |
| 208 | * |
| 209 | * DmiF14GetMaxSpeed |
| 210 | * |
| 211 | * Get the Max Speed |
| 212 | * |
| 213 | * @param[in] StdHeader Standard Head Pointer |
| 214 | * |
| 215 | * @retval MaxSpeed - CPU Max Speed. |
| 216 | * |
| 217 | */ |
| 218 | UINT16 |
| 219 | DmiF14GetMaxSpeed ( |
| 220 | IN AMD_CONFIG_PARAMS *StdHeader |
| 221 | ) |
| 222 | { |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 223 | UINT8 NumBoostStates; |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 224 | UINT32 P0Frequency; |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 225 | UINT32 PciData; |
| 226 | PCI_ADDR PciAddress; |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 227 | PSTATE_CPU_FAMILY_SERVICES *FamilyServices; |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 228 | CPU_LOGICAL_ID CpuFamilyRevision; |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 229 | |
| 230 | FamilyServices = NULL; |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 231 | GetFeatureServicesOfCurrentCore (&PstateFamilyServiceTable, (const VOID **)&FamilyServices, StdHeader); |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 232 | ASSERT (FamilyServices != NULL); |
| 233 | |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 234 | GetLogicalIdOfCurrentCore (&CpuFamilyRevision, StdHeader); |
| 235 | if ((CpuFamilyRevision.Revision & (AMD_F14_ON_Ax | AMD_F14_ON_Bx)) == 0) { |
| 236 | PciAddress.AddressValue = MAKE_SBDFO (0, 0 , PCI_DEV_BASE, FUNC_4, 0x15C); |
| 237 | LibAmdPciRead (AccessWidth32, PciAddress, &PciData, StdHeader); |
| 238 | NumBoostStates = (UINT8) ((PciData >> 2) & 7); |
| 239 | } else { |
| 240 | NumBoostStates = 0; |
| 241 | } |
| 242 | |
| 243 | FamilyServices->GetPstateFrequency (FamilyServices, NumBoostStates, &P0Frequency, StdHeader); |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 244 | return ((UINT16) P0Frequency); |
| 245 | } |
| 246 | |
| 247 | /* -----------------------------------------------------------------------------*/ |
| 248 | /** |
| 249 | * |
| 250 | * DmiF14GetExtClock |
| 251 | * |
| 252 | * Get the external clock Speed |
| 253 | * |
| 254 | * @param[in, out] StdHeader Standard Head Pointer |
| 255 | * |
| 256 | * @retval ExtClock - CPU external clock Speed. |
| 257 | * |
| 258 | */ |
| 259 | UINT16 |
| 260 | DmiF14GetExtClock ( |
| 261 | IN AMD_CONFIG_PARAMS *StdHeader |
| 262 | ) |
| 263 | { |
| 264 | return (EXTERNAL_CLOCK_100MHZ); |
| 265 | } |
| 266 | |
| 267 | /* -----------------------------------------------------------------------------*/ |
| 268 | /** |
| 269 | * |
| 270 | * DmiF14GetMemInfo |
| 271 | * |
| 272 | * Get memory information. |
| 273 | * |
| 274 | * @param[in,out] CpuGetMemInfoPtr Pointer to CPU_GET_MEM_INFO struct. |
| 275 | * @param[in] StdHeader Standard Head Pointer |
| 276 | * |
| 277 | */ |
| 278 | VOID |
| 279 | DmiF14GetMemInfo ( |
| 280 | IN OUT CPU_GET_MEM_INFO *CpuGetMemInfoPtr, |
| 281 | IN AMD_CONFIG_PARAMS *StdHeader |
| 282 | ) |
| 283 | { |
| 284 | // Ontario only has one DCT and does NOT support ECC DIMM |
| 285 | CpuGetMemInfoPtr->EccCapable = FALSE; |
| 286 | // Partition Row Position - 2 is for single channel memory |
| 287 | CpuGetMemInfoPtr->PartitionRowPosition = 2; |
| 288 | } |
| 289 | |
| 290 | /*--------------------------------------------------------------------------------------- |
| 291 | * Processor Family Table |
| 292 | * |
| 293 | * Note: 'x' means we don't care this field |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 294 | * 046h = "AMD C-Series Processor" |
| 295 | * 047h = "AMD E-Series Processor" |
| 296 | * 048h = "AMD S-Series Processor" |
| 297 | * 049h = "AMD G-Series Processor" |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 298 | * 002h = "Unknown" |
| 299 | *-------------------------------------------------------------------------------------*/ |
| 300 | CONST DMI_BRAND_ENTRY ROMDATA Family14BrandList[] = |
| 301 | { |
| 302 | // Brand --> DMI ID translation table |
| 303 | // PackageType, PgOfBrandId, NumberOfCores, String1ofBrandId, ValueSetToDmiTable |
| 304 | {0, 0, 'x', 1, 0x46}, |
| 305 | {0, 0, 'x', 2, 0x47}, |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 306 | {0, 0, 'x', 4, 0x49}, |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 307 | {'x', 'x', 'x', 'x', 0x02} |
| 308 | }; |
| 309 | |
| 310 | CONST PROC_FAMILY_TABLE ROMDATA ProcFamily14DmiTable = |
| 311 | { |
| 312 | AMD_FAMILY_14, // ID for Family 14h |
| 313 | &DmiF14GetInfo, // Transfer vectors for family |
| 314 | &DmiF14GetVoltage, // specific routines (above) |
| 315 | &DmiF14GetMaxSpeed, |
| 316 | &DmiF14GetExtClock, |
| 317 | &DmiF14GetMemInfo, // Get memory information |
Patrick Georgi | 6b688f5 | 2021-02-12 13:49:11 +0100 | [diff] [blame] | 318 | ARRAY_SIZE(Family14BrandList), // Number of entries in following table |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 319 | &Family14BrandList[0] |
| 320 | }; |
| 321 | |
| 322 | |
| 323 | /*--------------------------------------------------------------------------------------- |
| 324 | * L O C A L F U N C T I O N S |
| 325 | *--------------------------------------------------------------------------------------- |
| 326 | */ |