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
|
/** @file
Command training definitions.
@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.
**/
///
/// Include files
///
#ifndef _MrcCommandTraining_h_
#define _MrcCommandTraining_h_
#include "MrcTypes.h"
#include "MrcApi.h"
#include "MrcCommon.h"
#include "MrcDdr3.h"
#include "MrcGlobal.h"
#include "MrcIoControl.h"
#include "MrcOem.h"
#include "MrcReadReceiveEnable.h"
#include "MrcReset.h"
#include "MrcTimingConfiguration.h"
#define ECT_CLK_START (0)
#define ECT_CLK_STOP (128)
#define ECT_CLK_STEP (2)
#define ECT_CLK_LOOPS (ECT_CLK_STOP / ECT_CLK_STEP)
#define ECT_DQS_START (-32)
#define ECT_DQS_STOP (32)
#define ECT_DQS_STEP (8)
#define ECT_MIN_WIDTH (16)
/**
@brief
This function performs early command training.
Center CTL-CLK timing to allow subsequent steps to work
@param[in] MrcData - Include all MRC global data.
@retval MrcStatus - mrcSuccess if it succeeded
**/
extern
MrcStatus
MrcEarlyCommandTraining (
IN MrcParameters *const MrcData
);
/**
@brief
This function performs Late command training.
Center CMD/CTL-CLK timing using complex patterns.
@param[in] MrcData - Include all MRC global data.
@retval MrcStatus - If it's a success return mrcSuccess
**/
extern
MrcStatus
MrcLateCommandTraining (
IN MrcParameters *const MrcData
);
/**
@brief
Perform Command Voltage Centering.
@param[in, out] MrcData - Include all MRC global data.
@retval MrcStatus - if it succeded returns mrcSuccess
**/
extern
MrcStatus
MrcCmdVoltageCentering (
IN OUT MrcParameters *const MrcData
);
/**
@brief
Centers Command Timing around a MidPoint
@param[in] MrcData - Include all MRC global data.
@param[in] Iteration - Determines which PI to shift
@param[in] Ranks - Valid Rank bit mask
@param[in] GroupMask - which LPDDR groups to work on for CMD/CLK/CKE; not used for DDR3
@param[in] MidPoint - The MidPoint to center around (per channel)
@retval Nothing
**/
extern
void
CmdTimingCentering (
IN MrcParameters *const MrcData,
IN U8 Iteration,
IN U8 Ranks,
IN U8 GroupMask,
IN U8 MidPoint[MAX_CHANNEL]
);
/**
@brief
Use a linear search to find the edges between Low and High
if WrapAround = 0: Look for largest passing region between low and high
if WrapAround = 1: Look for largest passing region, including wrapping from high to low
@param[in, out] MrcData - Include all MRC global data.
@param[in] Iteration - Determines which PI to shift
@param[in] chBitMask - Valid Channel bit mask
@param[in] Ranks - Valid Rank bit mask
@param[in] GroupMask - which LPDDR groups to work on for CMD/CLK/CKE; not used for DDR3
@param[in] Low - Low limit
@param[in] High - High limit
@param[in] WrapAllowed - Determines the search region
@param[in] VrefOffsets - Array of Vref offsets
@param[in] SkipPrint - Switch to enable or disable debug printing
@param[in] SkipVref - Skip changing CMD Vref offsets, only run test once at the current Vref.
@retval MrcStatus - If it succeeds return mrcSuccess
**/
extern
void
CmdLinearFindEdges (
IN OUT MrcParameters *const MrcData,
IN U8 Iteration,
IN U8 chBitMask,
IN U8 Ranks,
IN U8 GroupMask,
IN S8 Low,
IN U8 High,
IN U8 WrapAllowed,
IN S8 *VrefOffsets,
IN BOOL SkipPrint,
IN BOOL SkipVref
);
/**
@brief
Use a binary search to find the edge between Low and High
High and Low track passing points
if CountUp: Low is a passing point and need to count up to find a failing point
if CountDn: High is a passing point and need to count dn to find a failing point
@param[in] MrcData - Include all MRC global data.
@param[in] Iteration - Determines which PI to shift
@param[in] ChBitMask - Valid Channel bit mask
@param[in] Ranks - Valid Rank bit mask
@param[in] GroupMask - which LPDDR groups to work on for CMD/CLK/CKE; not used for DDR3
@param[in, out] Low - Low limit
@param[in, out] High - High limit
@param[in] CountUp - The direction to search
@param[in] VrefOffsets - Array of Vref offsets
@retval Nothing
**/
extern
void
CmdBinaryFindEdge (
IN MrcParameters *const MrcData,
IN U8 Iteration,
IN U8 ChBitMask,
IN U8 Ranks,
IN U8 GroupMask,
IN OUT U8 *Low,
IN OUT U8 *High,
IN U8 CountUp,
IN S8 *VrefOffsets
);
/**
@brief
Shift the CLK/CTL Timing
Shift the CMD Timing
@param[in] MrcData - Include all MRC global data.
@param[in] Channel - Channel to shift
@param[in] Offset - Offset to shift by
@param[in] UpdateHost - Switch to update the host structure
@retval Nothing
**/
extern
void
ShiftChannelTiming (
IN MrcParameters *const MrcData,
IN U8 Channel,
IN S32 Offset,
IN U8 UpdateHost
);
/**
@brief
This function updtes Command Mode register, tXP and Round trip latency
@param[in, out] MrcData - Include all MRC global data.
@param[in] Channel - Channel to perform update to
@param[in] OldN - Old N Mode value
@param[in] NewN - New N mode value
@retval Nothing
**/
extern
void
UpdateCmdNTiming (
IN OUT MrcParameters *const MrcData,
IN U8 Channel,
IN U8 OldN,
IN U8 NewN
);
#ifdef ULT_FLAG
typedef struct _CADB_LINE {
U32 CaHigh;
U32 CaLow;
U32 ChipSelect;
} CADB_LINE;
typedef enum {
CaTrainingMode41, ///< Enter CA training mode using MRW41
CaTrainingMode48, ///< Enter CA training mode using MRW48
CaTrainingMode42 ///< Exit CA training mode using MRW42
} MrcCaTrainingMode;
/**
@brief
Early CA / CS training for LPDDR.
Main flow:
1. Put DRAMs in CA training mode using MRW41.
2. Run CS vs. CLK training.
3. Map DQ pins according to the board swizzling.
4. Run CA vs. CLK training.
5. Select optimal CA timings for each CA bus per rank
@param[in] MrcData - The MRC global data.
@retval mrcSuccess if succeeded
**/
extern
MrcStatus
EarlyCommandTrainingLpddr (
IN MrcParameters *const MrcData
);
/**
@brief
Early CS / CLK training for LPDDR.
Main flow:
1. Setup CADB pattern for CS Training.
2. Run CS vs. CLK training.
3. Select optimal CS and CLK timings
@param[in] MrcData - The MRC global data.
@retval mrcSuccess if succeeded
**/
extern
MrcStatus
EarlyChipSelectTraining (
IN MrcParameters *const MrcData
);
/**
@brief
Sweep right and left from the current point to find the margins.
@param[in, out] MrcData - Include all MRC global data.
@param[in] Iteration - Determines which PI to shift
@param[in] ChannelMask - Valid Channel bit mask
@param[in] RankMask - Valid Rank bit mask
@param[in] DebugPrint - Print debug messages or not
@retval MrcStatus - If it succeeds return mrcSuccess
**/
void
CmdLinearFindEdgesLpddr (
IN OUT MrcParameters *const MrcData,
IN U8 Iteration,
IN U8 ChannelMask,
IN U8 RankMask,
IN BOOL DebugPrint
);
#endif // ULT_FLAG
#endif // _MrcCommandTraining_h_
|