summaryrefslogtreecommitdiffstats
path: root/src/import/chips/centaur/procedures/hwp/memory/p9c_mss_generic_shmoo.H
blob: 5a40fa7c89bdde659aa4838b3f212461f07af61c (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/centaur/procedures/hwp/memory/p9c_mss_generic_shmoo.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2017                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

///
/// @file mss_generic_shmoo.H
/// @brief Memory Subsystem Generic Shmoo -- abstraction for HB
///
/// *HWP HWP Owner: Luke Mulkey <lwmulkey@us.ibm.com>
/// *HWP HWP Backup: Stephen Glancy <sglancy@us.ibm.com>
/// *HWP Team: Memory
/// *HWP Level: 2
/// *HWP Consumed by: HB:CI
///

#include <fapi2.H>

#ifndef generic_shmoo_H
#define generic_shmoo_H

//! Globals
#define SHMOO_DEBUG 0
#define SHMOO_DEBUG2 0
#include <p9c_mss_shmoo_common.H>
#include <p9c_mss_mcbist.H>

///
/// @brief MSS Generic Shmoo Class.. Inherits from PHY access class and the knob abstraction
///
class generic_shmoo
{
    private:

        //! MBS Config : Port + Socket + Knobs
        struct SHMOO_SCENARIO
        {
            struct MBS_CONFIG
            {
                struct PORT
                {
                    struct RANK
                    {
                        shmoo_knob_data_t K; // Set of knobs used by this shmoo
                    } S[MAX_RANK];      //Max Rank are 8
                } P[MAX_PORT];          // Max Port 2
            } MBA;
            shmoo_knob_config_t static_knob; // Static info regarding the knob
        } SHMOO[MAX_SHMOO]; // Denote max shmoo scenarios we have; Have 2; so that one for WR/RD and other Clock.

        //! Result Data
        uint8_t convergence_gap;
        shmoo_algorithm_t algorithm;
        shmoo_mode mcbist_mode;
        uint8_t mcbist_error_map[MAX_PORT][MAX_RANK][MAX_BYTE][MAX_NIBBLES];    //MAX byte is 10; Max Nibble are 2;
        uint8_t count_bad_dq[MAX_PORT];
        uint8_t schmoo_error_map[MAX_PORT][MAX_RANK][MAX_BYTE * MAX_NIBBLES];  // 10 * 2 = 20 Nibbles
        uint8_t binary_done_map[MAX_PORT][MAX_RANK][MAX_BYTE * MAX_NIBBLES];   // 10 * 2 = 20 Nibbles
        shmoo_type_t shmoo_mask;
        uint8_t iv_addr;
        uint8_t iv_MAX_RANKS[MAX_PORT];
        uint8_t iv_MAX_BYTES;
        uint32_t iv_pattern;
        uint32_t iv_test_type;
        uint8_t iv_dmm_type;
        uint8_t iv_SHMOO_ON;
        uint8_t iv_DQS_ON;
        uint8_t iv_shmoo_type;
        uint16_t iv_shmoo_param;
        uint16_t iv_binary_diff;
        uint32_t iv_vref_mul;
        uint8_t valid_rank[MAX_RANK];
        uint8_t valid_rank1[MAX_PORT][MAX_RANK];

    public:

        enum bound_t {LEFT, RIGHT};
        ///
        /// @brief generic shmoo constructor
        ///
        generic_shmoo(uint8_t iv_addr, shmoo_type_t shmoo_mask, shmoo_algorithm_t shmoo_algorithm); // Constructor
        ///
        /// @brief generic generic shmoo constructor
        ///
        generic_shmoo() {};
        ~generic_shmoo() {};

        //initialize multi dim arrays to known value
        void init_multi_array(uint16_t (&array)[MAX_DQ],
                              const uint16_t init_val);

        ///
        /// @brief This function gets the nominal values for each DQ of relevant knobs
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_all_noms(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief  set all bits
        /// @param[in] i_target Centaur input MBA
        /// @param[in] bound RIGHT/LEFT
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode set_all_binary(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                         const bound_t bound);

        ///
        /// @brief Read in all nominal values of relevant knobs
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_all_noms_dqs(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief This function calls the knob_update for each DQ which is used to find bound  that is left/right according to schmoo type
        /// @param[in] i_target Centaur input MBA
        /// @param[in] bound RIGHT/LEFT
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode find_bound(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                     const bound_t);

        ///
        /// @brief This is a key function is used to find right and left bound using new algorithm -- there is an option u can chose not to use it by setting a flag
        /// @param[in] i_target Centaur input MBA Parameters: Target:MBA,bound:RIGHT/LEFT,scenario:type of schmoo,iv_port:0/1,rank:0-7,byte:0-7,nibble:0/1,bit:0-3,pass,
        /// @param[in] bound RIGHT/LEFT
        /// @param[in] scenario type of shmoo
        /// @param[in] bit 0-3
        /// @param[in] pass
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode knob_update(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                      const bound_t bound,
                                      const uint8_t scenario,
                                      const uint8_t bit,
                                      uint8_t pass);

        ///
        /// @brief used to find right and left bound
        /// @param[in] i_target Centaur input MBA
        /// @param[in] bound RIGHT/LEFT
        /// @param[in] scenario type of shmoo
        /// @param[in] bit 0-3
        /// @param[in] pass
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode knob_update_bin(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                          const bound_t bound,
                                          const uint8_t scenario,
                                          const uint8_t bit,
                                          uint8_t pass);

        ///
        /// @brief used to find right and left bound
        /// @param[in] i_target Centaur input MBA
        /// @param[in] bound RIGHT/LEFT
        /// @param[in] scenario type of shmoo
        /// @param[in] bit 0-3
        /// @param[in] pass
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode knob_update_dqs_by8(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                              const bound_t bound,
                                              const uint8_t scenario,
                                              const uint8_t bit,
                                              uint8_t pass);

        ///
        /// @brief used to find right and left bound
        /// @param[in] i_target Centaur input MBA
        /// @param[in] bound RIGHT/LEFT
        /// @param[in] scenario type of shmoo
        /// @param[in] bit 0-3
        /// @param[in] pass
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode knob_update_dqs_by4(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                              const bound_t bound,
                                              const uint8_t scenario,
                                              const uint8_t bit,
                                              uint8_t pass);

        ///
        /// @brief This function is used to print the information needed such as freq,voltage etc, and also the right,left and total margin
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode print_report(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief This function is used to print the information needed such as freq,voltage etc, and also the right,left and total margin
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode print_report_dqs(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief This function is used to print the information needed such as freq,voltage etc, and also the right,left and total margin
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode print_report_dqs2(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief This function is used to get margin for setup,hold and total eye width in Ps by using frequency
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_margin(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief This function is used to get margin for setup,hold and total eye width in Ps by using frequency
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_margin2(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief This function is used to get margin for setup,hold and total eye width in Ps by using frequency
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_margin_dqs_by8(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief This function is used to get margin for setup,hold and total eye width in Ps by using frequency
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_margin_dqs_by4(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief This function is used to get margin for setup,hold and total eye width in Ps by using frequency
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_min_margin(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                         uint32_t* o_right_min_margin,
                                         uint32_t* o_left_min_margin);

        ///
        /// @brief This function is used to get margin for setup,hold and total eye width in Ps by using frequency
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        void get_min_margin2(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                             uint32_t* o_right_min_margin,
                             uint32_t* o_left_min_margin);

        ///
        /// @brief This function is used to get margin for setup,hold and total eye width in Ps by using frequency
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_min_margin_dqs(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                             uint32_t* o_right_min_margin,
                                             uint32_t* o_left_min_margin);

        ///
        /// @brief do mcbist check for error on particular nibble
        /// @param[in] i_target: centaur input mba
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode do_mcbist_test(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief do mcbist reset
        /// @param[in] i_target Centaur input mba
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode do_mcbist_reset(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief used by do_mcbist_test  to check the error map for particular nibble
        /// @param[in] i_target Centaur input MBA
        /// @param[in] l_p Centaur input port
        /// @param[out] pass 1 = error found in mcb_error_map
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode check_error_map(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                          uint8_t port,
                                          uint8_t& pass);

        ///
        /// @brief used by do_mcbist_test  to check the error map for particular nibble
        /// @param[in] i_target Centaur input MBA
        /// @param[in] l_p Centaur input port
        /// @param[out] pass 1 = error found in mcb_error_map
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode check_error_map2(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                           uint8_t port,
                                           uint8_t& pass);

        ///
        /// @brief do intial mcbist check in nominal and report spd if any bad bit found
        /// @param[in] i_target Centaur input mba
        /// @return FAPI2_RC_SUCCESS iff succesful
        ///
        fapi2::ReturnCode sanity_check(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief call setup_mcbist
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode schmoo_setup_mcb(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

        ///
        /// @brief used to find right and left bound
        /// @param[in] i_target Centaur input MBA
        /// @param[in] bound RIGHT/LEFT
        /// @param[in] scenario type of shmoo
        /// @param[in] bit 0-3
        /// @param[in] pass
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode knob_update_dqs_by8_isdimm(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                const bound_t bound,
                const uint8_t scenario,
                const uint8_t bit,
                uint8_t pass);

        ///
        /// @brief used to find right and left bound
        /// @param[in] i_target Centaur input MBA
        /// @param[in] bound RIGHT/LEFT
        /// @param[in] scenario type of shmoo
        /// @param[in] bit 0-3
        /// @param[in] pass
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode knob_update_dqs_by4_isdimm(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                const bound_t bound,
                const uint8_t scenario,
                const uint8_t bit,
                uint8_t pass);

        ///
        /// @brief Delegator function that runs shmoo using other  functions
        /// @param[in] i_target Centaur input mba
        /// @param[out] o_right_min_margin Minimum hold time
        /// @param[out] o_left_min_margin Minimum setup time
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode run(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                              uint32_t* right_min_margin,
                              uint32_t* left_min_margin,
                              uint32_t i_vref_mul);
        ///
        /// @brief save and restore registers before and after shmoo
        /// @param[in] i_target Centaur input MBA
        /// @param[in] i_content_array register contents to save/restore
        /// @param[in] i_mode 0 = save; 1 = restore
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode shmoo_save_rest(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                          uint64_t i_content_array[],
                                          const uint8_t i_mode);

        ///
        /// @brief Sets the PDA nibble table  with shmoo values
        /// @param[in] i_target Centaur input MBA
        /// @param[in] pda_nibble_table Per nibble vref + margins
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode get_nibble_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                         uint32_t pda_nibble_table[2][2][4][16][2]);

        ///
        /// @brief used to find right and left bound
        /// @param[in] i_target Centaur input MBA
        /// @param[in] bound RIGHT/LEFT
        /// @param[in] scenario type of shmoo
        /// @param[in] bit 0-3
        /// @param[in] pass
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode knob_update_bin_composite(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                const bound_t bound,
                const uint8_t scenario,
                const uint8_t bit,
                uint8_t pass);

        ///
        /// @brief This function is used to print the information needed such as freq,voltage etc, and also the right,left and total margin
        /// @param[in] i_target Centaur input MBA
        /// @return FAPI2_RC_SUCCESS iff successful
        ///
        fapi2::ReturnCode print_report2(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

};
#endif
OpenPOWER on IntegriCloud