blob: 1847a1d830d3cdd0b7fbf6ef7ab1f2c6a780b997 [file] [log] [blame]
Frank Vibrans2b4c8312011-02-14 18:30:54 +00001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * mnoton.c
6 *
7 * Northbridge Non-SPD timings for ON
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: (Mem/NB/ON)
12 * @e \$Revision: 39158 $ @e \$Date: 2010-10-07 21:34:36 +0800 (Thu, 07 Oct 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 "OptionMemory.h" // need def for MEM_FEAT_BLOCK_NB
61#include "mnon.h"
62#include "mu.h"
63#include "Filecode.h"
64#define FILECODE PROC_MEM_NB_ON_MNOTON_FILECODE
65
66
67/*----------------------------------------------------------------------------
68 * DEFINITIONS AND MACROS
69 *
70 *----------------------------------------------------------------------------
71 */
72
73/*----------------------------------------------------------------------------
74 * TYPEDEFS AND STRUCTURES
75 *
76 *----------------------------------------------------------------------------
77 */
78
79/*----------------------------------------------------------------------------
80 * PROTOTYPES OF LOCAL FUNCTIONS
81 *
82 *----------------------------------------------------------------------------
83 */
84VOID
85STATIC
86MemNSetOtherTimingON (
87 IN OUT MEM_NB_BLOCK *NBPtr
88 );
89
90VOID
91STATIC
92MemNPowerDownCtlON (
93 IN OUT MEM_NB_BLOCK *NBPtr
94 );
95
96/*----------------------------------------------------------------------------
97 * EXPORTED FUNCTIONS
98 *
99 *----------------------------------------------------------------------------
100 */
101
102/* -----------------------------------------------------------------------------*/
103/**
104 *
105 * This function sets the non-SPD timings
106 *
107 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
108 *
109 * @return TRUE - No fatal error occurs.
110 * @return FALSE - Fatal error occurs.
111 */
112
113BOOLEAN
114MemNOtherTimingON (
115 IN OUT MEM_NB_BLOCK *NBPtr
116 )
117{
118 MemNSetOtherTimingON (NBPtr);
119 MemNPowerDownCtlON (NBPtr);
120
121 return (BOOLEAN) (NBPtr->MCTPtr->ErrCode < AGESA_FATAL);
122}
123
124/*----------------------------------------------------------------------------
125 * LOCAL FUNCTIONS
126 *
127 *----------------------------------------------------------------------------
128 */
129
130/* -----------------------------------------------------------------------------*/
131/**
132 *
133 * This function sets the non-SPD timings into the PCI registers
134 *
135 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
136 *
137 */
138
139VOID
140STATIC
141MemNSetOtherTimingON (
142 IN OUT MEM_NB_BLOCK *NBPtr
143 )
144{
145 INT16 ROD;
146 INT16 WOD;
147 UINT8 LD;
148 UINT8 Tcwl;
149 INT16 CDDTrdrd;
150 INT16 Trdrd;
151 INT16 CDDTwrwr;
152 INT16 Twrwr;
153 INT16 CDDTwrrdSD;
154 INT16 TwrrdSD;
155 INT16 CDDTwrrd;
156 INT16 Twrrd;
157 INT16 CDDTrwtTO;
158 INT16 TrwtTO;
159
160 ROD = (DEFAULT_RD_ODT_ON_ON > 6) ? (DEFAULT_RD_ODT_ON_ON - 6) : 0;
161 WOD = (DEFAULT_RD_ODT_ON_ON > 6) ? (DEFAULT_WR_ODT_ON_ON - 6) : 0;
162
163 Tcwl = (UINT8) (NBPtr->DCTPtr->Timings.Speed / 133) + 2;
164 LD = NBPtr->DCTPtr->Timings.CasL - Tcwl;
165
166 // TrdrdSD = 3
167 MemNSetBitFieldNb (NBPtr, BFTrdrdSD, 2 - 2 + 1);
168
169 // Trdrd = CEIL(MAX(ROD + 3, CDDTrdrd/2 + (F2x[94]SlowAccessMode ? 3 : 3.5)))
170 CDDTrdrd = (MemNCalcCDDNb (NBPtr, AccessRcvEnDly, AccessRcvEnDly, FALSE, TRUE) + (INT16) ((NBPtr->ChannelPtr->SlowMode ? 6 : 7) + 1)) / (INT16) 2;
171 Trdrd = MAX (ROD + 3, CDDTrdrd);
172 Trdrd = MIN (MAX (Trdrd, 2), 10);
173 MemNSetBitFieldNb (NBPtr, BFTrdrd, (UINT8) (Trdrd - 2));
174
175 // TwrwrSD = WOD + 3
176 MemNSetBitFieldNb (NBPtr, BFTwrwrSD, (WOD + 3 - 1));
177
178 // Twrwr = CEIL(MAX(WOD + 3, CDDTwrwr / 2 + 3.5))
179 CDDTwrwr = (MemNCalcCDDNb (NBPtr, AccessWrDqsDly, AccessWrDqsDly, FALSE, TRUE) + (INT16) (7 + 1)) / (INT16) 2;
180 Twrwr = MAX (WOD + 3, CDDTwrwr);
181 Twrwr = MIN (MAX (Twrwr, 1), 10);
182 MemNSetBitFieldNb (NBPtr, BFTwrwr, (UINT8) (Twrwr - 1));
183
184 // TwrrdSD = CEIL(MAX(1, MAX(WOD, CDDTwrrdSD / 2 + 0.5) - LD + 3))
185 CDDTwrrdSD = (MemNCalcCDDNb (NBPtr, AccessWrDqsDly, AccessRcvEnDly, TRUE, FALSE) + (INT16) (1 + 1)) / (INT16) 2;
186 TwrrdSD = MAX (WOD, CDDTwrrdSD) - LD + 3;
187 TwrrdSD = MIN (MAX (TwrrdSD, 1), 11);
188 MemNSetBitFieldNb (NBPtr, BFTwrrdSD, (UINT8) (TwrrdSD - 1));
189
190 // Twrrd = CEIL(MAX(1, MAX(WOD, CDDTwrrd / 2 + 0.5) - LD + 3))
191 CDDTwrrd = (MemNCalcCDDNb (NBPtr, AccessWrDqsDly, AccessRcvEnDly, FALSE, TRUE) + (INT16) (1 + 1)) / (INT16) 2;
192 Twrrd = MAX (WOD, CDDTwrrd) - LD + 3;
193 Twrrd = MIN (MAX (Twrrd, 1), 11);
194 Twrrd = MAX (Twrrd, TwrrdSD);
195 MemNSetBitFieldNb (NBPtr, BFTwrrd, (UINT8) (Twrrd - 1));
196
197 // TrwtTO = CEIL(MAX(ROD, CDDTrwtTO / 2 - 0.5) + LD + 3).
198 CDDTrwtTO = (MemNCalcCDDNb (NBPtr, AccessRcvEnDly, AccessWrDqsDly, TRUE, TRUE) + (INT16) (1 - 1)) / (INT16) 2;
199 TrwtTO = MAX (ROD, CDDTrwtTO) + LD + 3;
200 TrwtTO = MIN (MAX (TrwtTO, 3), 17);
201 MemNSetBitFieldNb (NBPtr, BFTrwtTO, (UINT8) (TrwtTO - 2));
202
203 // TrwtWB should be set to 0xF for ON.
204 MemNSetBitFieldNb (NBPtr, BFTrwtWB, 4);
205}
206
207/* -----------------------------------------------------------------------------*/
208/**
209 *
210 * This function enables power down mode
211 *
212 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
213 *
214 */
215
216VOID
217STATIC
218MemNPowerDownCtlON (
219 IN OUT MEM_NB_BLOCK *NBPtr
220 )
221{
222 if (NBPtr->RefPtr->EnablePowerDown) {
223 MemNSetTxpNb (NBPtr);
224 MemNSetBitFieldNb (NBPtr, BFPowerDownEn, 1);
225 }
226
227 if (NBPtr->RefPtr->EnableBankSwizzle) {
228 MemNSetBitFieldNb (NBPtr, BFBankSwizzleMode, 1);
229 }
230}