summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/MemoryInit/Pei/Source/Api/MrcGeneral.h
blob: 04bd977494a7659df6f3c90c0003c2d67c966a40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/** @file
  MRC Common / Generic functions

@copyright
  Copyright (c) 2011 - 2012 Intel Corporation. All rights reserved.
  This software and associated documentation (if any) is furnished
  under a license and may only be used or copied in accordance
  with the terms of the license. Except as permitted by such
  license, no part of this software or documentation may be
  reproduced, stored in a retrieval system, or transmitted in any
  form or by any means without the express written consent of
  Intel Corporation.

  This file contains an 'Intel Peripheral Driver' and uniquely
  identified as "Intel Reference Module" and is
  licensed for Intel CPUs and chipsets under the terms of your
  license agreement with Intel or your vendor.  This file may
  be modified by the user, subject to additional terms of the
  license agreement
**/

#ifndef _MrcGeneral_h_
#define _MrcGeneral_h_

#include "MrcTypes.h"
#include "MrcApi.h"
#include "MrcAddressDecodeConfiguration.h"
#include "MrcCommon.h"
#include "MrcCrosser.h"
#include "MrcDebugHook.h"
//
// #include "MrcMemoryClean.h"
//
#include "MrcOem.h"
#include "MrcPowerModes.h"
//
// #include "MrcRefreshConfiguration.h"
//
#include "MrcSpdProcessing.h"

#define GENERAL_PM_CONFIGURATION_2_BUS_ADDRESS      (0)
#define GENERAL_PM_CONFIGURATION_2_DEVICE_ADDRESS   (31)
#define GENERAL_PM_CONFIGURATION_2_FUNCTION_ADDRESS (0)

#define GENERAL_PM_CONFIGURATION_2                  ((0xA2) & (~0x03))

#define GENERAL_PM_CONFIGURATION_2_DISB_OFFSET      (0x7)
#define GENERAL_PM_CONFIGURATION_2_DISB_WIDTH       (0x1)
#define GENERAL_PM_CONFIGURATION_2_DISB_MASK        (0x80)
#define GENERAL_PM_CONFIGURATION_2_DISB_DEFAULT     (0x0)

#define GENERAL_PM_CONFIGURATION_2_MEM_SR_OFFSET    (0x5)
#define GENERAL_PM_CONFIGURATION_2_MEM_SR_WIDTH     (0x1)
#define GENERAL_PM_CONFIGURATION_2_MEM_SR_MASK      (0x20)
#define GENERAL_PM_CONFIGURATION_2_MEM_SR_DEFAULT   (0x0)

#define MEMORY_TEST_CACHELINE                       (100) ///< max number can be 100 from one rank
///
/// Define the total memory size of a channel.
///
typedef enum {
  tcs16GB,  ///< 16 GB per channel
  tcs8GB,   ///< 8 GB
  tcs2GB,   ///< 2 GB
  tcs512MB  ///< 512 MB
} MrcTotalChannelSize;

extern MrcUpmPwrRetrainLimits  InitialLimits[MRC_NUMBER_UPM_PWR_RETRAIN_MARGINS];

/**
  Thisfunction performs Software Memory testing

  @param[in] MrcData - Include all MRC global data.

  @retval Always returns mrcSuccess.
**/
extern
MrcStatus
MrcHwMemTest (
  IN     MrcParameters *const MrcData
  );

/**
  This function changes the MC to normal mode, enables the ECC if needed, lock configuration and set PU_MRC_Done.
  If the ECC is enabled, this function should be called after memory is cleaned.

  @param[in, out] MrcData - Include all MRC global data.

  @retval Always returns mrcSuccess.
**/
extern
MrcStatus
MrcMcActivate (
  IN OUT MrcParameters *const MrcData
  );

/**
  This function enables Normal Mode and configures the Power Down Modes
  for the boot flows other than Cold Boot.

  @param[in] MrcData - The MRC general data.

  @retval Always returns mrcSuccess.
**/
extern
MrcStatus
MrcNormalMode (
  IN MrcParameters *const MrcData
  );

/**
  This function is the last funtion that call from the MRC core.
  The function set DISB and set the MRC_Done.

  @param[in, out] MrcData - include all the MRC general data.

  @retval Always returns mrcSuccess.
**/
extern
MrcStatus
MrcDone (
  IN OUT MrcParameters *const MrcData
  );

/**
  Print the MRC version to the MRC output device.

  @param[in] Debug   - Pointer to the MRC Debug structure.
  @param[in] Version - The MRC version.

  @retval Nothing.
**/
extern
void
MrcVersionPrint (
  IN const MrcParameters *MrcData,
  IN const MrcVersion    *Version
  );

/**
  This function return the MRC version.

  @param[out] Version - Location to store the MRC version.

  @retval Nothing.
**/
extern
void
MrcVersionGet (
     OUT MrcVersion *const Version
  );

/**
  This function set the MRC vertion to MCDECS_SPARE register.
  The function need to be call by the wrapper after MrcStartMemoryConfiguration function where the MC CLK enable.
  The function write:
  Major number to bits 16-23
  Minor number to bits 8-15
  Build number to bits 0 - 7

  @param[in] MrcData - Include all MRC global data.

  @retval Nothing.
**/
extern
MrcStatus
MrcSetMrcVersion (
  IN     MrcParameters *const MrcData
  );

/**
  This function locks the memory controller and memory map registers.

  @param[in] MrcData - Include all MRC global data.

  @retval Nothing.
**/
extern
void
McRegistersLock (
  IN     MrcParameters *const MrcData
  );

/**
  This function returns the recommended MRC boot mode.

  @param[in] void - No arguments

  @retval bmWarm if we are in self refresh and the DISB bit is set, otherwise returns bmCold.
**/
extern
MrcBootMode
MrcGetBootMode (
  void
  );

/**
  This function sets the DISB bit in General PM Configuration 2 B:D:F 0,31,0 offset 0xA2.

  @param[in] void - No arguments

  @retval Nothing.
**/
extern
void
MrcSetDISB (
  void
  );

/**
  This function resets the DISB bit in General PM Configuration 2 B:D:F 0,31,0 offset 0xA2.

  @param[in] void - No arguments

  @retval Nothing.
**/
extern
void
MrcResetDISB (
  void
  );

/**
  This function reads the CAPID0 register and sets the memory controller's capability.

  @param[in, out] MrcData - All the MRC global data.

  @retval Returns mrcSuccess if the memory controller's capability has been determined, otherwise returns mrcFail.
**/
extern
MrcStatus
MrcMcCapability (
  IN OUT MrcParameters *const MrcData
  );

/**
  This function reads the CAPID0 register and sets the memory controller's capability.

  @param[in, out] MrcData - All the MRC global data.

  @retval Returns mrcSuccess if the memory controller's capability has been determined, otherwise returns mrcFail.
**/
MrcStatus
MrcMcCapabilityPreSpd (
  IN OUT MrcParameters *const MrcData
  );

/**
  This function sets the appropriate timing overrides in the output structure
  prior to Spd processing.

  @param[in, out] MrcData - All the MRC global data.

  @retval Returns mrcSuccess if the timing overrides have been conpleted.
**/
extern
MrcStatus
MrcSetOverridesPreSpd (
  IN OUT MrcParameters *const MrcData
  );

/**
  This function reads the input data structure and sets the appropriate timing overrides in the output structure.

  @param[in, out] MrcData - All the MRC global data.

  @retval Returns mrcSuccess if the timing overrides have been conpleted.
**/
extern
MrcStatus
MrcSetOverrides (
  IN OUT MrcParameters *const MrcData
  );

/**
  This function set the WM0-5 values. Those values are be using by the graphics driver.
  need to be call after PU_MRC_DONE bit is set to 1.

  @param[in] MrcData - include all the MRC data.

  @retval Nothing.

  **/
void
MrcWmRegSet (
  IN     MrcParameters *const MrcData
  );


/**
@brief
  Program DDRPL_CR_DDR_TX_DELAY if Memory Trace is enabled

  @param[in] MrcData - The MRC general data.

  @retval None
**/
void
MrcSetDdrplTxDelay (
  IN MrcParameters *const MrcData
  );

#endif