7 * Technology Control word initialization for DDR3 Recovery
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Proc/Recovery/Mem)
12 * @e \$Revision: 44324 $ @e \$Date: 2010-12-22 02:16:51 -0700 (Wed, 22 Dec 2010) $
15 /*****************************************************************************
17 * Copyright (C) 2012 Advanced Micro Devices, Inc.
18 * All rights reserved.
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.
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.
42 * ***************************************************************************
47 *----------------------------------------------------------------------------
50 *----------------------------------------------------------------------------
56 #include "OptionMemory.h"
66 #define FILECODE PROC_RECOVERY_MEM_TECH_DDR3_MRTRCI3_FILECODE
67 /*----------------------------------------------------------------------------
68 * DEFINITIONS AND MACROS
70 *----------------------------------------------------------------------------
73 /*----------------------------------------------------------------------------
74 * TYPEDEFS AND STRUCTURES
76 *----------------------------------------------------------------------------
79 /*----------------------------------------------------------------------------
80 * PROTOTYPES OF LOCAL FUNCTIONS
82 *----------------------------------------------------------------------------
88 IN OUT MEM_TECH_BLOCK *TechPtr,
95 IN OUT MEM_TECH_BLOCK *TechPtr,
100 /*----------------------------------------------------------------------------
103 *----------------------------------------------------------------------------
106 /* -----------------------------------------------------------------------------*/
109 * This function sends control words
111 * @param[in,out] *TechPtr - Pointer to the MEM_TECH_BLOCK
113 * @return pDCT->Timings.TrwtTO updated
117 MemRecTDramControlRegInit3 (
118 IN OUT MEM_TECH_BLOCK *TechPtr
124 MEM_DATA_STRUCT *MemPtr;
127 NBPtr = TechPtr->NBPtr;
128 MemPtr = NBPtr->MemPtr;
130 // wait 8us TACT must be changed to optimize to 8 MEM CLKs
131 // and wait 6us for PLL LOCK
132 MemRecUWait10ns (80 + 60, MemPtr);
134 // 2. Program F2x[1, 0]A8[CtrlWordCS]=bit mask for target chip selects.
135 NBPtr->SetBitField (NBPtr, BFCtrlWordCS, 3 << (NBPtr->DimmToBeUsed << 1));
137 for (RCNum = 0; RCNum <= 15; RCNum++) {
138 // wait 8us for TMRD, must be changed to optimize to 8 MEM CLKs
139 MemRecUWait10ns (80, MemPtr);
141 if ((RCNum != 6) && (RCNum != 7)) {
142 Data = MemRecTGetCtlWord3 (TechPtr, RCNum);
143 MemRecTSendCtlWord3 (TechPtr, RCNum, Data);
147 MemRecUWait10ns (60, MemPtr); // wait 6us for TSTAB
150 /* -----------------------------------------------------------------------------*/
153 * This function calculates the ControlRC value
155 * @param[in,out] *TechPtr - Pointer to the MEM_TECH_BLOCK
156 * @param[in] CtrlWordNum - control Word number.
158 * @return Control Word value
164 IN OUT MEM_TECH_BLOCK *TechPtr,
170 CH_DEF_STRUCT *ChannelPtr;
172 ChannelPtr = TechPtr->NBPtr->ChannelPtr;
174 Data = 0; //Default value for all control words is 0
175 switch (CtrlWordNum) {
177 Data = 0x02; // DA4=1
180 Data = 0x0C; // if single rank, set DBA1 and DBA0
183 Data = ChannelPtr->CtrlWrd03[TechPtr->NBPtr->DimmToBeUsed];
186 Data = ChannelPtr->CtrlWrd04[TechPtr->NBPtr->DimmToBeUsed];
189 Data = ChannelPtr->CtrlWrd05[TechPtr->NBPtr->DimmToBeUsed];
199 /* -----------------------------------------------------------------------------*/
202 * This function sends control word command
204 * @param[in,out] *TechPtr - Pointer to the MEM_TECH_BLOCK
205 * @param[in] CmdNum - control number.
206 * @param[in] Value - value to send
212 MemRecTSendCtlWord3 (
213 IN OUT MEM_TECH_BLOCK *TechPtr,
220 ASSERT (CmdNum < 16);
223 NBPtr = TechPtr->NBPtr;
225 // 1. Program MrsBank and MrsAddress.
226 // n = [BA2, A2, A1, A0].
227 // data = [BA1, BA0, A4, A3].
228 // Set all other bits in MrsAddress to zero.
230 NBPtr->SetBitField (NBPtr, BFMrsBank, ((CmdNum&8) >> 1) | (Value >> 2));
231 NBPtr->SetBitField (NBPtr, BFMrsAddress, ((Value&3) << 3) | (CmdNum&7));
232 IDS_HDT_CONSOLE (MEM_FLOW, "\t\tCS%d RC%02d %04x\n",
233 (NBPtr->GetBitField (NBPtr, BFDramInitRegReg) >> 20) & 0xF,
234 ((NBPtr->GetBitField (NBPtr, BFDramInitRegReg) >> 15) & 8) |
235 (NBPtr->GetBitField (NBPtr, BFDramInitRegReg) & 7),
236 ((NBPtr->GetBitField (NBPtr, BFDramInitRegReg) >> 14) & 0xC) |
237 ((NBPtr->GetBitField (NBPtr, BFDramInitRegReg) >> 3) & 3));
239 // 2.Set SendCtrlWord=1
240 NBPtr->SetBitField (NBPtr, BFSendCtrlWord, 1);
241 // 3.Wait for BFSendCtrlWord=0
242 while (NBPtr->GetBitField (NBPtr, BFSendCtrlWord) != 0) {}