b7efd35cbbc34fe966333b5522b1f1a6b7a4da68
[coreboot.git] / src / vendorcode / amd / agesa / f14 / Proc / Mem / NB / ON / mnflowon.c
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * mnflowon.c
6  *
7  * Llano initializer for MCT and DCT
8  *
9  * @xrefitem bom "File Content Label" "Release Content"
10  * @e project: AGESA
11  * @e sub-project: (Mem/Main)
12  * @e \$Revision: 34897 $ @e \$Date: 2010-07-14 10:07:10 +0800 (Wed, 14 Jul 2010) $
13  *
14  **/
15 /*
16  *****************************************************************************
17  *
18  * Copyright (c) 2011, Advanced Micro Devices, Inc.
19  * All rights reserved.
20  * 
21  * 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.
28  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of 
29  *       its contributors may be used to endorse or promote products derived 
30  *       from this software without specific prior written permission.
31  * 
32  * 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.
42  * 
43  * ***************************************************************************
44  *
45  */
46
47 /*
48  *----------------------------------------------------------------------------
49  *                                MODULES USED
50  *
51  *----------------------------------------------------------------------------
52  */
53
54
55
56 #include "AGESA.h"
57 #include "AdvancedApi.h"
58 #include "amdlib.h"
59 #include "Ids.h"
60 #include "OptionMemory.h"
61 #include "mm.h"
62 #include "mn.h"
63 #include "mt.h"
64 #include "Filecode.h"
65 #include "GeneralServices.h"
66 #define FILECODE PROC_MEM_NB_ON_MNFLOWON_FILECODE
67 /* features */
68 #include "mftds.h"
69 /*----------------------------------------------------------------------------
70  *                          DEFINITIONS AND MACROS
71  *
72  *----------------------------------------------------------------------------
73  */
74
75 /*----------------------------------------------------------------------------
76  *                           TYPEDEFS AND STRUCTURES
77  *
78  *----------------------------------------------------------------------------
79  */
80
81 /*----------------------------------------------------------------------------
82  *                        PROTOTYPES OF LOCAL FUNCTIONS
83  *
84  *----------------------------------------------------------------------------
85  */
86
87 /*----------------------------------------------------------------------------
88  *                            EXPORTED FUNCTIONS
89  *
90  *----------------------------------------------------------------------------
91  */
92 extern MEM_PLAT_SPEC_CFG* memPlatSpecFFInstalledON[MAX_FF_TYPES];
93
94 /* -----------------------------------------------------------------------------*/
95 /**
96  *
97  *
98  *      This function initializes the platform specific block
99  *
100  *
101  *     @param[in,out]   *NBPtr   - Pointer to the MEM_NB_BLOCK
102  *
103  *     @return          TRUE - AGESA_SUCCESS at least one dorm factor was found
104  *     @return          FALSE - AGESA_UNSUPPORTED - Error indicating that no form factors were found
105  */
106
107 BOOLEAN
108 MemNPlatformSpecificFormFactorInitON (
109   IN OUT   MEM_NB_BLOCK *NBPtr
110   )
111 {
112   UINT8 f;
113
114   if (NBPtr->MCTPtr->DimmValid == 0) {
115     PutEventLog (AGESA_FATAL, MEM_ERROR_NO_DIMM_FOUND_ON_SYSTEM, 0, 0, 0, 0, &(NBPtr->MemPtr->StdHeader));
116     SetMemError (AGESA_FATAL, NBPtr->MCTPtr);
117     ASSERT(FALSE); // Size of memory on BSP = 0, so no DIMM found
118     return FALSE; // There is no dimm present on the system.
119   }
120   for (f = 0; memPlatSpecFFInstalledON[f] != NULL; f++) {
121     if (memPlatSpecFFInstalledON[f] (NBPtr->MemPtr, NBPtr->ChannelPtr, NBPtr->PsPtr) == AGESA_SUCCESS) {
122       break;
123     }
124   }
125   if (memPlatSpecFFInstalledON[f] == NULL) {
126     return FALSE; // No FF types are supported
127   }
128   return TRUE;
129 }
130
131 /* -----------------------------------------------------------------------------*/
132 /**
133  *
134  *      This function selects appropriate Tech functions for the NB.
135  *
136  *     @param[in,out]   *NBPtr   - Pointer to the MEM_NB_BLOCK
137  *
138  */
139
140 VOID
141 MemNTechBlockSwitchON (
142   IN OUT   MEM_NB_BLOCK *NBPtr
143   )
144 {
145   MEM_TECH_BLOCK *TechPtr;
146
147   TechPtr = NBPtr->TechPtr;
148
149   // Specify Dimm-Byte training for Nb
150   MemTDimmByteTrainInit (TechPtr);
151
152   // Remove the following functions because they are not needed for ON
153   TechPtr->SetDramMode = (BOOLEAN (*) (MEM_TECH_BLOCK *)) memDefTrue;
154   TechPtr->SpdCalcWidth = (BOOLEAN (*) (MEM_TECH_BLOCK *)) memDefTrue;
155   TechPtr->SetDqsEccTmgs = (BOOLEAN (*) (MEM_TECH_BLOCK *)) memDefTrue;
156   TechPtr->AdjustTwrwr = (VOID (*) (MEM_TECH_BLOCK *)) memDefRet;
157   TechPtr->AdjustTwrrd = (VOID (*) (MEM_TECH_BLOCK *)) memDefRet;
158   TechPtr->GetLD = (INT8 (*) (MEM_TECH_BLOCK *)) memDefRet;
159   TechPtr->FindMaxDlyForMaxRdLat = MemTFindMaxRcvrEnDlyRdDqsDlyByte;
160   TechPtr->ResetDCTWrPtr = (VOID (*) (MEM_TECH_BLOCK *, UINT8)) memDefRet;
161 }
162
163 /*----------------------------------------------------------------------------
164  *                              LOCAL FUNCTIONS
165  *
166  *----------------------------------------------------------------------------
167  */
168