zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * mprc10opspd.c |
| 6 | * |
| 7 | * A sub-engine which extracts RC10 operating speed value for RDIMM configuration. |
| 8 | * |
| 9 | * @xrefitem bom "File Content Label" "Release Content" |
| 10 | * @e project: AGESA |
| 11 | * @e sub-project: (Mem/Ps) |
| 12 | * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $ |
| 13 | * |
| 14 | **/ |
| 15 | /***************************************************************************** |
| 16 | * |
Siyuan Wang | 641f00c | 2013-06-08 11:50:55 +0800 | [diff] [blame] | 17 | * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc. |
| 18 | * All rights reserved. |
| 19 | * |
| 20 | * Redistribution and use in source and binary forms, with or without |
| 21 | * modification, are permitted provided that the following conditions are met: |
| 22 | * * Redistributions of source code must retain the above copyright |
| 23 | * notice, this list of conditions and the following disclaimer. |
| 24 | * * Redistributions in binary form must reproduce the above copyright |
| 25 | * notice, this list of conditions and the following disclaimer in the |
| 26 | * documentation and/or other materials provided with the distribution. |
| 27 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 28 | * its contributors may be used to endorse or promote products derived |
| 29 | * from this software without specific prior written permission. |
| 30 | * |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 32 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 33 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 34 | * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY |
| 35 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 36 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 38 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 41 | * *************************************************************************** |
| 42 | * |
| 43 | */ |
| 44 | /* |
| 45 | *---------------------------------------------------------------------------- |
| 46 | * MODULES USED |
| 47 | * |
| 48 | *---------------------------------------------------------------------------- |
| 49 | */ |
| 50 | |
| 51 | |
| 52 | |
| 53 | #include "AGESA.h" |
| 54 | #include "AdvancedApi.h" |
| 55 | #include "amdlib.h" |
| 56 | #include "Ids.h" |
| 57 | #include "cpuFamRegisters.h" |
| 58 | #include "cpuRegisters.h" |
| 59 | #include "OptionMemory.h" |
| 60 | #include "PlatformMemoryConfiguration.h" |
| 61 | #include "ma.h" |
| 62 | #include "mp.h" |
| 63 | #include "merrhdl.h" |
| 64 | #include "GeneralServices.h" |
| 65 | #include "Filecode.h" |
| 66 | CODE_GROUP (G2_PEI) |
| 67 | RDATA_GROUP (G2_PEI) |
| 68 | #define FILECODE PROC_MEM_PS_MPRC10OPSPD_FILECODE |
| 69 | |
| 70 | |
| 71 | /*---------------------------------------------------------------------------- |
| 72 | * DEFINITIONS AND MACROS |
| 73 | * |
| 74 | *---------------------------------------------------------------------------- |
| 75 | */ |
| 76 | /*---------------------------------------------------------------------------- |
| 77 | * TYPEDEFS AND STRUCTURES |
| 78 | * |
| 79 | *---------------------------------------------------------------------------- |
| 80 | */ |
| 81 | /*---------------------------------------------------------------------------- |
| 82 | * PROTOTYPES OF LOCAL FUNCTIONS |
| 83 | * |
| 84 | *---------------------------------------------------------------------------- |
| 85 | */ |
| 86 | /*---------------------------------------------------------------------------- |
| 87 | * EXPORTED FUNCTIONS |
| 88 | * |
| 89 | *---------------------------------------------------------------------------- |
| 90 | */ |
| 91 | /* -----------------------------------------------------------------------------*/ |
| 92 | /** |
| 93 | * |
| 94 | * A sub-function which extracts RC10 operating speed value from a input table and stores extracted |
| 95 | * value to a specific address. |
| 96 | * |
| 97 | * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK |
| 98 | * @param[in] *EntryOfTables - Pointer to MEM_PSC_TABLE_BLOCK |
| 99 | * |
| 100 | * @return TRUE - Succeed in extracting the table value |
| 101 | * @return FALSE - Fail to extract the table value |
| 102 | * |
| 103 | */ |
| 104 | BOOLEAN |
| 105 | MemPGetRC10OpSpd ( |
| 106 | IN OUT MEM_NB_BLOCK *NBPtr, |
| 107 | IN MEM_PSC_TABLE_BLOCK *EntryOfTables |
| 108 | ) |
| 109 | { |
| 110 | UINT8 i; |
| 111 | UINT8 TableSize; |
| 112 | UINT32 CurDDRrate; |
| 113 | CPU_LOGICAL_ID LogicalCpuid; |
| 114 | UINT8 PackageType; |
| 115 | UINT8 PsoMaskRC10OpSpeed; |
| 116 | PSCFG_OPSPD_ENTRY *TblPtr; |
| 117 | CH_DEF_STRUCT *CurrentChannel; |
| 118 | |
| 119 | CurrentChannel = NBPtr->ChannelPtr; |
| 120 | |
| 121 | if (CurrentChannel->RegDimmPresent == 0) { |
| 122 | return TRUE; |
| 123 | } |
| 124 | |
| 125 | TblPtr = NULL; |
| 126 | TableSize = 0; |
| 127 | PackageType = 0; |
| 128 | LogicalCpuid.Family = AMD_FAMILY_UNKNOWN; |
| 129 | |
| 130 | i = 0; |
| 131 | // Obtain table pointer, table size, Logical Cpuid and PSC type according to NB type and package type. |
| 132 | while (EntryOfTables->TblEntryOfRC10OpSpeed[i] != NULL) { |
| 133 | LogicalCpuid = (EntryOfTables->TblEntryOfRC10OpSpeed[i])->Header.LogicalCpuid; |
| 134 | PackageType = (EntryOfTables->TblEntryOfRC10OpSpeed[i])->Header.PackageType; |
| 135 | // |
| 136 | // Determine if this is the expected NB Type |
| 137 | // |
| 138 | if (MemPIsIdSupported (NBPtr, LogicalCpuid, PackageType)) { |
| 139 | TblPtr = (PSCFG_OPSPD_ENTRY *) ((EntryOfTables->TblEntryOfRC10OpSpeed[i])->TBLPtr); |
| 140 | TableSize = (EntryOfTables->TblEntryOfRC10OpSpeed[i])->TableSize; |
| 141 | break; |
| 142 | } |
| 143 | i++; |
| 144 | } |
| 145 | |
| 146 | // Check whether no table entry is found. |
| 147 | if (EntryOfTables->TblEntryOfRC10OpSpeed[i] == NULL) { |
| 148 | IDS_HDT_CONSOLE (MEM_FLOW, "\nNo RC10 Op Speed table\n"); |
| 149 | return FALSE; |
| 150 | } |
| 151 | |
| 152 | CurDDRrate = (UINT32) (1 << (CurrentChannel->DCTPtr->Timings.Speed / 66)); |
| 153 | |
| 154 | for (i = 0; i < TableSize; i++) { |
| 155 | if ((TblPtr->DDRrate & CurDDRrate) != 0) { |
| 156 | NBPtr->PsPtr->RC10OpSpd = TblPtr->OPSPD; |
| 157 | break; |
| 158 | } |
| 159 | TblPtr++; |
| 160 | } |
| 161 | |
| 162 | // |
| 163 | // If there is no entry, check if overriding value existed. If not, return FALSE. |
| 164 | // |
| 165 | PsoMaskRC10OpSpeed = (UINT8) MemPProceedTblDrvOverride (NBPtr, NBPtr->RefPtr->PlatformMemoryConfiguration, PSO_TBLDRV_RC10_OPSPEED); |
| 166 | if ((PsoMaskRC10OpSpeed == 0) && (i == TableSize)) { |
| 167 | IDS_HDT_CONSOLE (MEM_FLOW, "\nNo RC10 Op Speed entries\n"); |
| 168 | PutEventLog (AGESA_ERROR, MEM_ERROR_RC10_OP_SPEED_NOT_FOUND, NBPtr->Node, NBPtr->Dct, NBPtr->Channel, 0, &NBPtr->MemPtr->StdHeader); |
| 169 | SetMemError (AGESA_ERROR, NBPtr->MCTPtr); |
| 170 | if (!NBPtr->MemPtr->ErrorHandling (NBPtr->MCTPtr, NBPtr->Dct, EXCLUDE_ALL_CHIPSEL, &NBPtr->MemPtr->StdHeader)) { |
| 171 | ASSERT (FALSE); |
| 172 | } |
| 173 | return FALSE; |
| 174 | } |
| 175 | |
| 176 | return TRUE; |
| 177 | } |