summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/MemoryInit/Pei/MrcOemPlatform.h
blob: 77006bee2adca81b5fbba640098ade4cd3ff6ef8 (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
/** @file
  This file contains platform related functions.

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

#include "MrcTypes.h"
#include "MrcApi.h"
#include "MrcOem.h"
#include "MrcOemIo.h"
#include "MrcOemMmio.h"
#include "MrcWriteDqDqs.h"

#ifdef MRC_MINIBIOS_BUILD

#define GPIO_BASE_ADDRESS (0x800)

#define PLATFORM_MB             (0x04)
#define PLATFORM_SRVER          (0x01)
#define PLATFORM_DT             (0x01)

#define SB_BUS                  (0)
#define SB_PCI2ISA_DEVICE       (31)
#define SB_PCI2ISA_FUNC         (0)
#define SB_PCI2ISA_BUS_DEV_FUNC ((SB_BUS << 8) + ((SB_PCI2ISA_DEVICE << 3) + SB_PCI2ISA_FUNC))
#define PCI_LPC_BASE            (0x80000000 + (SB_PCI2ISA_BUS_DEV_FUNC << 8))

///
/// CPU Mobile SA Device IDs B0:D0:F0
///
#define MRC_SA_DEVICE_ID_MB_0        0x0C04   ///< Haswell Mobile SA DID
#define MRC_SA_DEVICE_ID_MB_1        0x0A04   ///< Haswell Ult Mobile SA DID
#define MRC_SA_DEVICE_ID_MB_2        0x0D04   ///< Crystalwell Mobile SA DID

///
/// CPU Desktop SA Device IDs B0:D0:F0
///
#define MRC_SA_DEVICE_ID_DT_0        0x0C00   ///< Haswell Desktop SA DID
#define MRC_SA_DEVICE_ID_DT_1        0x0D00   ///< Crystalwell Desktop SA DID
#define MRC_SA_DEVICE_ID_DT_2        0x0C0C   ///< Haswell Marketing SpareAffect SA DID

///
/// CPU Server SA Device IDs B0:D0:F0
///
#define MRC_SA_DEVICE_ID_SVR_0       0x0C08   ///< Haswell Server SA DID
#define MRC_SA_DEVICE_ID_SVR_1       0x0D08   ///< Crystalwell Server SA DID

#endif // MRC_MINIBIOS_BUILD
#define MRC_EXIT_VALUE       (0xFF)
#define PCU_CR_PLATFORM_INFO (0xCE)
#define isprint(a)           (((a) >= ' ') && ((a) <= '~') ? (a) : 0)

typedef enum {
  RefRateLowTempOOS,  // Not safe
  RefRateFourth,      // 4x tREFI - Not safe
  RefRateHalf,        // 2x tREFI
  RefRate1x,          // tREFI
  RefRate2x,          // 1/2 tREFI
  RefRate4x,          // 1/4 tREFI
  RefRate4xDeRateAc,  // 1/4 tREFI de-rate AC timing - Not safe
  RefRateHighTempOOS  // Not safe
} LpddrRefreshRates;

#pragma pack (push, 1)
typedef union {
  struct {
    U32                         : 8;
    U32 MAX_NON_TURBO_LIM_RATIO : 8;
    U32                         : 16;
    U32                         : 32;
  } Bits;
  U64 Data;
  U32 Data32[2];
  U16 Data16[4];
  U8  Data8[8];
} PCU_CR_PLATFORM_INFO_STRUCT;

typedef union {
  struct {
    U32 Enable_2x_Refresh                       :  1;  // Bits 0:0
    U32 LPDDR_Min_MR4                           :  3;  // Bits 1:3
    U32                                         :  27; // Bits 4:30
    U32 Lock_Bit                                :  1;  // Bits 31:31
  } Bits;
  U32 Data;
  U16 Data16[2];
  U8  Data8[4];
} MrcMailbox2xRefresh;
#pragma pack (pop)
/**
  This function directs pCode to force 2x Refresh through the mailbox.

  @param[in]  MrcData - Pointer to the MRC global data structure

  @retval - Nothing.
**/
void
MrcOemEnable2xRefresh (
  IN MrcParameters *const MrcData
  );

/**
  This function changes the DIMM Voltage to the closest desired voltage without
  going higher. Default wait time is the minimum value of 200us, if more time
  is needed before deassertion of DIMM Reset#, then change the parameter.

  @param[in, out] MrcData            - The MRC "global data" area.
  @param[in]      VddVoltage         - Selects the DDR voltage to use, in mV.
  @param[in, out] VddSettleWaitTime  - Time needed for Vdd to settle after the update

  @retval TRUE if a voltage change occurred, otherwise FALSE.
**/
extern
BOOL
MrcOemVDDVoltageCheckAndSwitch (
  IN OUT MrcParameters      *MrcData,
  IN     const MrcVddSelect VddVoltage,
  IN OUT U32 * const        VddSettleWaitTime
  );

/**
@brief
  Gets CPU ratio - P-State ratio. for get the real time we need to multiply it in B CLK.

  @param[in] Nothing

  @retval U32 - PERF STATUS.
**/
extern
U32
MrcGetCpuRatio (
  void
  );

/**
@brief
  Gets CPU current time - rdtsc value.
  return the result in millisec.

  @param[in] Nothing

  @retval U64 - rdtsc value.
**/
extern
U64
MrcGetCpuTime (
  void
  );

/**
@brief
  Sets CpuModel and CpuStepping in MrcData based on CpuModelStep.

  @param[out] MrcData     - The Mrc Host data structure
  @param[in]  CpuModel    - The CPU Family Model.
  @param[in]  CpuStepping - The CPU Stepping.

  @retval - mrcSuccess if the model and stepping is found.  Otherwise mrcFail
**/
MrcStatus
MrcSetCpuInformation (
  OUT MrcParameters  *MrcData,
  IN  MrcCpuModel    CpuModel,
  IN  MrcCpuStepping CpuStepping
  );

/**
@brief
  Gets CPU's random number generator.
  return the GeneratedSeed result.

  @param[in] Nothing

  @retval U32 -           GeneratedSeed value.
**/
extern
U32
MrcGetRandomNumber (
  void
  );

/**
@brief
  Hook before normal mode is enabled.

  @param[in, out] MrcData  - The MRC "global data" area.

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

/**
@brief
  Hook after normal mode is enabled

  @param[in] MrcData  - The MRC "global data" area.

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

/**
@brief
  Overwrite Thermal settings

  @param[in] MrcData  - The MRC "global data" area.

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


/**
@brief
  this function use by the OEM to do dedicated task during the MRC.

  @param[in] MrcData           - include all the MRC data
  @param[in] OemStatusCommand  - A command that indicates the task to perform.
  @param[in] ptr               - general ptr for general use.

  @retval The status of the task.
**/
extern
MrcStatus
MrcOemCheckPoint (
  IN MrcParameters        *MrcData,
  IN MRC_OemStatusCommand OemStatusCommand,
  IN void                 *ptr
  );

/**
@brief
  This function display on port 80 number.
  It can be different debug interface.
  This function can be use for any debug ability according to OEM requirements.

  @param[in] MrcData            - Mrc Global Data
  @param[in] DisplayDebugNumber - the number to display on port 80.

  @retval Nothing
**/
extern
void
MrcOemDebugHook (
  IN MrcParameters *MrcData,
  IN U16           DisplayDebugNumber
  );

#ifdef UPSERVER_SUPPORT
void
MrcCltmInit (
  MrcParameters *MrcData
);

void
MrcCltmDisable (
  MrcParameters *MrcData
);
#endif //UPSERVER_SUPPORT

#ifdef MRC_DEBUG_PRINT
/**
@brief
  Print the input parameters to the debug message output port.

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

  @retval mrcSuccess
**/
extern
MrcStatus
MrcPrintInputParameters (
  MrcParameters * const MrcData
  );

/**
@brief
  Print the specified memory to the serial message debug port.

  @param[in] Debug - Serial message debug structure.
  @param[in] Start - The starting address to dump.
  @param[in] Size  - The amount of data in bytes to dump.

  @retval Nothing.
**/
extern
void
MrcPrintMemory (
  IN const MrcDebug *const Debug,
  IN const U8 *const       Start,
  IN const U32              Size
  );
#endif

#if (defined MEMORY_DOWN_SUPPORT && (MEMORY_DOWN_SUPPORT > 0))
/**
@brief
  Enables Memory Down support and sets SPD data for all DIMMs needing support.

  @param[in, out] Inputs - MRC Input data structure.
  @param[in]      BoardId - The ID of the board.

  @retval Nothing
**/
extern
void
EnableMemoryDown (
  IN OUT MrcInput *const Inputs,
  IN     U16             BoardId
  );
#endif  // MEMORY_DOWN_SUPPORT

/**
@brief
  Initialize the board-specific CMD/CTL/CLK and DQ/DQS mapping for LPDDR3.

  @param[in, out] Inputs  - MRC Input data structure.
  @param[in]      BoardId - The ID of the board.

  @retval none
**/
void
MrcOemLpddrBoardMapping (
  IN OUT  MrcInput *Inputs,
  IN      U16      BoardId
  );

#endif // _MrcOemPlatform_h_