summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/MemoryInit/Pei/Source/Include/MrcOem.h
blob: 0742d8d23f4aca067ff464895a49504efa611897 (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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
/** @file
  This file is the OEM interface to the MRC core.
  This file includes the OEM MRC implementation and can be changed between projects.
  Each MRC customer must provide those OEM interfaces.

@copyright
  Copyright (c) 1999 - 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 _MrcOem_h_
#define _MrcOem_h_

#include "MrcTypes.h"
#include "MrcApi.h"
#include "MrcGlobal.h"

//
// OEM MMIO routines
//
#include "MrcOemMmio.h"

//
//////////////////////////////////////////////////////////////////////////////////////
//                               OEM debug print routines and types                 //
//////////////////////////////////////////////////////////////////////////////////////
//
#include "MrcOemDebugPrint.h"

#ifndef MRC_DEBUG_MSG
#error "MRC_DEBUG_MSG is not defined"
#endif //MRC_DEBUG_MSG
///
//////////////////////////////////////////////////////////////////////////////////////
///                           OEM platform  routines and types                      //
//////////////////////////////////////////////////////////////////////////////////////
///
/// define the oem check points the OEM can define more point and locate them in the code.
///
typedef enum {
  OemFastBootPermitted,     ///<  before fast boot.
  OemRestoreNonTraining,
  OemPrintInputParameters,  ///<  before printing input parameters
  OemSpdProcessingRun,      ///<  before spd processing code
  OemSetOverridePreSpd,     ///<  before set overrides pre spd
  OemMcCapabilityPreSpd,    ///<  before MC capability pre spd
  OemSetOverride,           ///<  before set overrides
  OemMcCapability,          ///<  before MC capability
  OemMcInitRun,             ///<  before mc init code
  OemMcMemoryMap,           ///<  before memory map
  OemMcResetRun,            ///<  before jedec reset
  OemPreTraining,           ///<  before the training.
  OemMcTrainingRun,         ///<  before training code
  OemEarlyCommandTraining,  ///<  before Early Command training
  OemJedecInitLpddr3,       ///<  before Jedec Init Lpddr3
  OemSenseAmpTraining,      ///<  before Sense Amp Training
  OemReadMprTraining,       ///<  before Read MPR Training
  OemReceiveEnable,         ///<  before Read Leveling
  OemJedecWriteLeveling,    ///<  before Jedec Write Leveling
  OemWriteLeveling,         ///<  before Functional Write Leveling
  OemWriteDqDqs,            ///<  before Write Timing Centering
  OemReadDqDqs,             ///<  before Read Timing Centering
  OemDimmRonTraining,       ///<  before DIMM Ron algorithm.
  OemDimmODTTraining,       ///<  before DIMM ODT algorithm.
  OemDimmODT1dTraining,     ///<  before DIMM ODT 1d algorithm.
  OemWriteDriveStrength,    ///<  before Write DS
  OemWriteSlewRate,         ///<  before Write SR
  OemWriteEQTraining,       ///<  before Write Equalization Training
  OemReadODTTraining,       ///<  before Read ODT algorithm.
  OemReadEQTraining,        ///<  before Read Equalization Training
  OemReadAmplifierPower,    ///<  before Read Amplifier Power
  OemOptimizeComp,          ///<  before Comp Optimization Training
  OemPowerSavingMeter,      ///<  before PowerSavingMeter step
  OemWriteDqDqs2D,          ///<  before Write Timing Centering 2D
  OemReadDqDqs2D,           ///<  before Read Timing Centering 2D
  OemCmdVoltCentering,      ///<  before Command Voltage Centering
  OemWriteVoltCentering2D,  ///<  before Write Voltage Centering 2D
  OemReadVoltCentering2D,   ///<  before Read Voltage Centering 2D
  OemLateCommandTraining,   ///<  before Late Command training
  OemRoundTripLatency,      ///<  before Round Trip Latency Traiing
  OemTurnAroundTimes,       ///<  before Turn Aorund Times.
  OemRcvEnCentering1D,      ///<  before Receive Enable Centring 
  OemSaveMCValues,          ///<  before saving memory controller values
  OemRmt,                   ///<  before RMT crosser tool.
  OemMemTest,               ///<  before Memory testing
  OemRestoreTraining,       ///<  before Restoring Training Values
  OemSelfRefreshExit,       ///<  before Self Refresh Exit
  OemNormalMode,            ///<  before Normal Mode on non-cold boots.
  OemAliasCheck,            ///<  before alias checking on cold boots.
  OemHwMemInit,

  OemPostTraining,          ///<  after the training.
  OemMrcActivate,           ///<  before MrcActivate call.
  OemMrcDone,               ///<  call to MrcOemCheckPoint when MRC was done.
  OemFrequencySet,          ///<  do operation before frequency set.
  OemFrequencySetDone,      ///<  do operation after frequency set.
  OemStartMemoryConfiguration,
  OemBeforeNormalMode,      ///<  call to MrcOemCheckPoint before normal mode is enalbed
  OemAfterNormalMode,       ///<  call to MrcOemCheckPoint after normal mode is enalbed
  OemMrcFillRmt,
  OemRetrainMarginCheck,
  ///
  ///*********************************************************************************
  ///
  OemNumOfCommands          ///<  Should always be last in the list!
} MRC_OemStatusCommand;

///
/// Define the MRC SMBUS devices type.
///
typedef enum {
  datOemSpd_0_0,      ///< use for get the device address for channel 0 dimm 0
  datOemSpd_0_1,      ///< use for get the device address for channel 0 dimm 1
  datOemSpd_1_0,      ///< use for get the device address for channel 1 dimm 0
  datOemSpd_1_1,      ///< use for get the device address for channel 1 dimm 1
  datOemVrefWrite_0,  ///< use for get the device address for dimm vref controlled potentiometer channel 0
  datOemVrefWrite_1,  ///< use for get the device address for dimm vref controlled potentiometer channel 1
  datOemVrefRead      ///< use for get the device address for cpu vref controlled potentiometer
} MRC_OemSmbusDeviceType;

///
//////////////////////////////////////////////////////////////////////////////////////
///                             OEM IO routines and types                           //
//////////////////////////////////////////////////////////////////////////////////////
///

/**
  8 bit I/O port read.
     Needs to be ported for OEM platform requirements.

  @param[in] Address - the IO read address.

  @retval return the read value.
**/
extern
U8
MrcOemInPort8 (
  IN U16 IoAddress
  );

/**
  8 bit I/O port write.
     Needs to be ported for OEM platform requirements.

  @param[in] IoAddress - The I/O port read address.
  @param[in] Data      - The value to write.

  @retval Nothing
**/
extern
void
MrcOemOutPort8 (
  IN U16 IoAddress,
  IN U8  data
  );

/**
  16 bit I/O port read.
     Needs to be ported for OEM platform requirements.

  @param[in] IoAddress - The I/O port read address.

  @retval return the read value.
**/
extern
U16
MrcOemInPort16 (
  IN U16 IoAddress
  );

/**
  16 bit I/O port write.
     Needs to be ported for OEM platform requirements.

  @param[in] IoAddress - The I/O port read address.
  @param[in] Data      - The value to write.

  @retval Nothing
**/
extern
void
MrcOemOutPort16 (
  IN U16 IoAddress,
  IN U16 data
  );

/**
  32 bit I/O port read.
     Needs to be ported for OEM platform requirements.

  @param[in] IoAddress - The I/O port read address.

  @retval The value read.
**/
extern
U32
MrcOemInPort32 (
  IN U16 IoAddress
  );

/**
  32 bit I/O port write.
     Needs to be ported for OEM platform requirements.

  @param[in] IoAddress - The I/O port read address.
  @param[in] Data      - The value to write.

  @retval Nothing
**/
extern
void
MrcOemOutPort32 (
  IN U16 IoAddress,
  IN U32 data
  );

/**
  This function return the PCI index address.
     Needs to be ported for OEM platform requirements.

  @param[in] None.

  @retval The PCI index address.
**/
extern
U16
MrcOemPciIndex (
  void
  );

/**
  This function return the PCI data address.
     Needs to be ported for OEM platform requirements.

  @param[in] None

  @retval The PCI data address.
**/
extern
U16
MrcOemPciData (
  void
  );

/**
  This function return the PCI device address.
      Needs to be ported for OEM platform requirements.

  @param[in] Bus      - PCI bus
  @param[in] Device   - PCI device
  @param[in] Function - PCI function
  @param[in] Offset   - Offset

  @retval The PCI device address.
**/
extern
U32
MrcOemGetPciDeviceAddress (
  IN U8 Bus,
  IN U8 Device,
  IN U8 Function,
  IN U8 Offset
  );

/**
  This function return the PCIE device address.
      Needs to be ported for OEM platform requirements.

  @param[in] Bus      - PCI bus
  @param[in] Device   - PCI device
  @param[in] Function - PCI function
  @param[in] Offset   - Offset

  @retval The PCIe device address.
**/
extern
U32
MrcOemGetPcieDeviceAddress (
  IN U8 Bus,
  IN U8 Device,
  IN U8 Function,
  IN U8 Offset
  );

/**
  Returns the current time, as determined by reading the Real Time Clock (RTC) on the platform.
  Since RTC time is stored in BCD, convert each value to binary.

  @param[out] Seconds       - The current second (0-59).
  @param[out] Minutes       - The current minute (0-59).
  @param[out] Hours         - The current hour (0-23).
  @param[out] DayOfMonth    - The current day of the month (1-31).
  @param[out] Month         - The current month (1-12).
  @param[out] Year          - The current year (2000-2099).

  @retval Nothing
**/
extern
void
MrcOemGetRtcTime (
  U8 *Seconds,
  U8 *Minutes,
  U8 *Hours,
  U8 *DayOfMonth,
  U8 *Month,
  U16*Year
  );

///
//////////////////////////////////////////////////////////////////////////////////////
///                    OEM Memory routines and types                                //
//////////////////////////////////////////////////////////////////////////////////////
///

/**
  Copy the specified number of memory bytes, a byte at a time, from the
  specified source to the specified destination.
     Needs to be ported for OEM platform requirements.

  @param[in, out] Dest            - Destination pointer.
  @param[in]      Src             - Source pointer.
  @param[in]      NumBytes        - The number of bytes to copy.

  @retval Nothing
**/
extern
void
MrcOemMemoryCpy (
  IN OUT U8  *Dest,
  IN     U8  *Src,
  IN     U32 NumBytes
  );

/**
  Sets the specified number of memory bytes, a byte at a time, at the
  specified destination.
     Needs to be ported for OEM platform requirements.

  @param[in, out] Dest            - Destination pointer.
  @param[in]      Value           - The value to set.
  @param[in]      NumBytes        - The number of bytes to set.

  @retval Nothing
**/
extern
void
MrcOemMemorySet (
  IN OUT U8  *Dest,
  IN     U32 Value,
  IN     U32 NumBytes
  );

/**
  Sets the specified number of memory dwords, a dword at a time, at the
  specified destination.

  @param[in, out] Dest     - Destination pointer.
  @param[in]      Value    - The value to set.
  @param[in]      NumWords - The number of dwords to set.

  @retval Nothing.
**/
extern
void
MrcOemMemorySetWord (
  IN OUT U16    *Dest,
  IN const U16  Value,
  IN U32        NumWords
  );

/**
  Sets the specified number of memory dwords, a dword at a time, at the
  specified destination.

  @param[in, out] Dest      - Destination pointer.
  @param[in]      Value     - The value to set.
  @param[in]      NumDwords - The number of dwords to set.

  @retval Nothing.
**/
extern
void
MrcOemMemorySetDword (
  IN OUT U32    *Dest,
  IN const U32  Value,
  IN U32        NumDwords
  );

/**
  Shift the specified data value left by the specified count.
    Needs to be ported for OEM platform requirements.

  @param[in] Data            - 64 bit number to shift left.
  @param[in] Count           - Number of bits to shift (0..63)

  @retval The number of bits shifted left.
**/
extern
U64
MrcOemMemoryLeftShiftU64 (
  IN const U64 Data,
  IN const U8  Count
  );

/**
  Shift the specified data value Right by the specified count.

  @param[in] Data  - U64 number to shift
  @param[in] Count - number of bits to shift (0..63)

  @retval Returns the shifted U64 value.
**/
extern
U64
MrcOemMemoryRightShiftU64 (
  IN const U64 Data,
  IN const U8  Count
  );

/**
  This function Multiply U64 with a U32 number. Result is <= 64 bits
  Needs to be ported for OEM platform requirements.

  @param[in] Multiplicand - U64 number to be multiplied with
  @param[in] Multiplier   - U32 number to multiply

  @retval Returns the multiplication result of U64 value.
**/
extern
U64
MrcOemMemoryMultiplyU64ByU32 (
  IN const U64 Multiplicand,
  IN const U32 Multiplier
  );

/**
  Divide U64 with a U64 number. Result is <= 32 bits

  @param[in] Dividend - U64 number to be multiplied with
  @param[in] Divisor  - U32 number to multiply

  @retval Returns the quotient result of U64 value.
**/
extern
U64
MrcOemMemoryDivideU64ByU64 (
  IN const U64 Dividend,
  IN const U64 Divisor
  );

#endif // _MrcOem_h_