blob: a211c236021aedeba48928e423dae26b4954ba88 [file] [log] [blame]
Frank Vibrans2b4c8312011-02-14 18:30:54 +00001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * mtot3.c
6 *
7 * Technology Non-SPD Timings for DDR3
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: (Mem/Tech/DDR3)
12 * @e \$Revision: 38442 $ @e \$Date: 2010-09-24 06:39:57 +0800 (Fri, 24 Sep 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 "Ids.h"
58#include "mm.h"
59#include "mn.h"
60#include "mu.h"
61#include "mt.h"
62#include "mtot3.h"
63#include "Filecode.h"
64CODE_GROUP (G1_PEICC)
65RDATA_GROUP (G1_PEICC)
66
67#define FILECODE PROC_MEM_TECH_DDR3_MTOT3_FILECODE
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 *
95 * This function adjusts the Twrwr value for DDR3.
96 *
97 * @param[in,out] *TechPtr - Pointer to the MEM_TECH_BLOCK
98 *
99 */
100
101VOID
102MemTAdjustTwrwr3 (
103 IN OUT MEM_TECH_BLOCK *TechPtr
104 )
105{
106 DCT_STRUCT *DCTPtr;
107
108 DCTPtr = TechPtr->NBPtr->DCTPtr;
109
110 // For DDR3, value 0000b-0001b and >= 1011b of Twrwr is reserved.
111 if (DCTPtr->Timings.Twrwr < 2) {
112 DCTPtr->Timings.Twrwr = 2;
113 } else if (DCTPtr->Timings.Twrwr > 10) {
114 DCTPtr->Timings.Twrwr = 10;
115 }
116}
117
118/* -----------------------------------------------------------------------------*/
119/**
120 *
121 * This function adjusts the Twrrd value for DDR3.
122 *
123 * @param[in,out] *TechPtr - Pointer to the MEM_TECH_BLOCK
124 *
125 */
126
127VOID
128MemTAdjustTwrrd3 (
129 IN OUT MEM_TECH_BLOCK *TechPtr
130 )
131{
132 DCT_STRUCT *DCTPtr;
133
134 DCTPtr = TechPtr->NBPtr->DCTPtr;
135
136 // For DDR3, value 0000b, 0001b, and > 1010b of Twrrd is reserved.
137 if (DCTPtr->Timings.Twrrd < 2) {
138 DCTPtr->Timings.Twrrd = 2;
139 } else if (DCTPtr->Timings.Twrrd > 10) {
140 DCTPtr->Timings.Twrrd = 10;
141 }
142}
143
144/* -----------------------------------------------------------------------------*/
145/**
146 *
147 * This function gets the LD value for DDR3.
148 *
149 * @param[in,out] *TechPtr - Pointer to the MEM_TECH_BLOCK
150 *
151 * @return Value of LD
152 */
153
154INT8
155MemTGetLD3 (
156 IN OUT MEM_TECH_BLOCK *TechPtr
157 )
158{
159 INT8 LD;
160 MEM_NB_BLOCK *NBPtr;
161 NBPtr = TechPtr->NBPtr;
162 //
163 // For DDR3, BIOS calculates the latency difference (Ld) as equal to read CAS latency minus write CAS
164 // latency, in MEMCLKs (see F2x[1, 0]88[Tcl] and F2x[1, 0]84[Tcwl]) which can be a negative or positive
165 // value.
166 //
167 LD = ((INT8) NBPtr->GetBitField (NBPtr, BFTcl) + 4) - ((INT8) NBPtr->GetBitField (NBPtr, BFTcwl) + 5);
168
169 return LD;
170}