blob: c543b8208f36894c0e77d88473176f047ccf0723 [file] [log] [blame]
Frank Vibrans2b4c8312011-02-14 18:30:54 +00001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * mfodthermal.c
6 *
7 * On Dimm thermal management.
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: (Mem/Feat)
12 * @e \$Revision: 35136 $ @e \$Date: 2010-07-16 11:29:48 +0800 (Fri, 16 Jul 2010) $
13 *
14 **/
15/*
16 *****************************************************************************
17 *
18 * Copyright (c) 2011, Advanced Micro Devices, Inc.
19 * All rights reserved.
Edward O'Callaghan1542a6f2014-07-06 19:24:06 +100020 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000021 * 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'Callaghan1542a6f2014-07-06 19:24:06 +100028 * * 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 Vibrans2b4c8312011-02-14 18:30:54 +000030 * from this software without specific prior written permission.
Edward O'Callaghan1542a6f2014-07-06 19:24:06 +100031 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000032 * 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'Callaghan1542a6f2014-07-06 19:24:06 +100042 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000043 * ***************************************************************************
44 *
45 */
46
47/*
48 *----------------------------------------------------------------------------
49 * MODULES USED
50 *
51 *----------------------------------------------------------------------------
52 */
53
54
55
56#include "AGESA.h"
57#include "mm.h"
58#include "mn.h"
59#include "mt.h"
60#include "Ids.h"
61#include "mfodthermal.h"
62#include "Filecode.h"
63CODE_GROUP (G2_PEI)
64RDATA_GROUP (G2_PEI)
65
66#define FILECODE PROC_MEM_FEAT_ODTHERMAL_MFODTHERMAL_FILECODE
67
68/*----------------------------------------------------------------------------
69 * DEFINITIONS AND MACROS
70 *
71 *----------------------------------------------------------------------------
72 */
73
74/*----------------------------------------------------------------------------
75 * TYPEDEFS AND STRUCTURES
76 *
77 *----------------------------------------------------------------------------
78 */
79
80/*----------------------------------------------------------------------------
81 * PROTOTYPES OF LOCAL FUNCTIONS
82 *
83 *----------------------------------------------------------------------------
84 */
85
86/*----------------------------------------------------------------------------
87 * EXPORTED FUNCTIONS
88 *
89 *----------------------------------------------------------------------------
90 */
91/*-----------------------------------------------------------------------------*/
92/**
93 *
94 * This function does On-Dimm thermal management.
95 *
96 * @param[in, out] *NBPtr - Pointer to the MEM_NB_BLOCK.
97 *
98 * @return TRUE - This feature is enabled.
99 * @return FALSE - This feature is not enabled.
100 */
101
102BOOLEAN
103MemFOnDimmThermal (
104 IN OUT MEM_NB_BLOCK *NBPtr
105 )
106{
107 UINT8 i;
108 UINT8 Dct;
109 CH_DEF_STRUCT *ChannelPtr;
110 MEM_DATA_STRUCT *MemPtr;
111 UINT8 *SpdBufferPtr;
112 UINT8 ThermalOp;
113 BOOLEAN ODTSEn;
114 BOOLEAN ExtendTmp;
115
116 ODTSEn = FALSE;
117 ExtendTmp = FALSE;
118
119 ASSERT (NBPtr != NULL);
120 MemPtr = NBPtr->MemPtr;
121 AGESA_TESTPOINT (TpProcMemOnDimmThermal, &MemPtr->StdHeader);
122 if (NBPtr->MCTPtr->NodeMemSize != 0) {
123 for (Dct = 0; Dct < NBPtr->DctCount; Dct++) {
124 NBPtr->SwitchDCT (NBPtr, Dct);
125 // Only go through the DCT if it is not disabled.
126 if (NBPtr->GetBitField (NBPtr, BFDisDramInterface) == 0) {
127 ChannelPtr = NBPtr->ChannelPtr;
128 // If Ganged mode is enabled, need to go through all dram devices on both DCTs.
129 if (!NBPtr->Ganged || (NBPtr->Dct != 1)) {
130 if (!(NBPtr->IsSupported[CheckSetSameDctODTsEn]) || (NBPtr->IsSupported[CheckSetSameDctODTsEn] && (NBPtr->Dct != 1))) {
131 ODTSEn = TRUE;
132 ExtendTmp = TRUE;
133 }
134 }
135 for (i = 0; i < MAX_DIMMS_PER_CHANNEL; i ++) {
136 if (NBPtr->TechPtr->GetDimmSpdBuffer (NBPtr->TechPtr, &SpdBufferPtr, i)) {
137 // Check byte 31: thermal and refresh option.
138 ThermalOp = SpdBufferPtr[THERMAL_OPT];
139 // Bit 3: ODTS readout
140 if (!((ThermalOp >> 3) & 1)) {
141 ODTSEn = FALSE;
142 }
143 // Bit 0: Extended Temperature Range.
144 if (!(ThermalOp & 1)) {
145 ExtendTmp = FALSE;
146 }
147 }
148 }
149
150 if (!NBPtr->Ganged || (NBPtr->Dct == 1)) {
151 // If in ganged mode, need to switch back to DCT0 to set the registers.
152 if (NBPtr->Ganged || NBPtr->IsSupported[CheckSetSameDctODTsEn]) {
153 NBPtr->SwitchDCT (NBPtr, 0);
154 ChannelPtr = NBPtr->ChannelPtr;
155 }
156 // If all dram devices on a DCT support ODTS
157 if (ODTSEn) {
158 NBPtr->SetBitField (NBPtr, BFODTSEn, 1);
159 }
160 ChannelPtr->ExtendTmp = ExtendTmp;
161 }
162 }
163 IDS_HDT_CONSOLE (MEM_FLOW, "\tDct %d\n", Dct);
164 IDS_HDT_CONSOLE (MEM_FLOW, "\t\tODTSEn = %d\n", ODTSEn);
165 IDS_HDT_CONSOLE (MEM_FLOW, "\t\tExtendTmp = %d\n", ExtendTmp);
166 }
167 }
168 return TRUE;
169}
170
171
172/*----------------------------------------------------------------------------
173 * LOCAL FUNCTIONS
174 *
175 *----------------------------------------------------------------------------
176 */