summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/memory/lib/mss_attribute_accessors_manual.H
blob: cf08841820dd011dc99de10fc2c1c6d58dfb1ae8 (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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/memory/lib/mss_attribute_accessors_manual.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2019                        */
/* [+] 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_attribute_accessors_manual.H
/// @brief Manually created attribute accessors.
/// Some attributes aren't in files we want to incorporate in to our automated
/// accessor generator. EC workarounds is one example - everytime someone creates
/// a work-around they'd be burdened with updating this file.
///
// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com>
// *HWP HWP Backup: Stephen Glancy <sglancy@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 3
// *HWP Consumed by: Memory

#ifndef MSS_ATTR_ACCESS_MANUAL_H_
#define MSS_ATTR_ACCESS_MANUAL_H_

#include <fapi2.H>
#include <lib/utils/nimbus_find.H>
#include <lib/mss_attribute_accessors.H>

namespace mss
{

///
/// @brief 2N mode helper
/// When figuring out 2N mode we need to access two attributes. This helper
/// gives us a place to put that common code
/// @tparam T the fapi2::TargetType of the input target
/// @param[in] the target from which to get the 2N mode autoset attribute
/// @return true iff 2N mode is 'on'
///
template< fapi2::TargetType T >
inline bool two_n_mode_helper(const fapi2::Target<T>& i_target)
{
    uint8_t l_2n_autoset = 0;
    uint8_t l_2n_mrw_mode = 0;

    // There are no VPD enums defined for 2N autoset <shrug>.
    constexpr uint8_t ATTR_MSS_VPD_MR_MC_2N_MODE_AUTOSET_2N_MODE = 0x02;

    const auto l_mcs = mss::find_target<fapi2::TARGET_TYPE_MCS>(i_target);

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MSS_VPD_MR_MC_2N_MODE_AUTOSET, l_mcs, l_2n_autoset) );
    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MSS_MRW_DRAM_2N_MODE, fapi2::Target<fapi2::TARGET_TYPE_SYSTEM>(), l_2n_mrw_mode) );

    // If the MRW states 'auto' we use what's in VPD, otherwise we use what's in the MRW.
    return (l_2n_mrw_mode == fapi2::ENUM_ATTR_MSS_MRW_DRAM_2N_MODE_AUTO) ?
           l_2n_autoset == ATTR_MSS_VPD_MR_MC_2N_MODE_AUTOSET_2N_MODE :
           l_2n_mrw_mode == fapi2::ENUM_ATTR_MSS_MRW_DRAM_2N_MODE_FORCE_TO_2N_MODE;

fapi_try_exit:
    FAPI_ERR("failed accessing vpd_mr_mc_2n_mode_autoset or mrw_dram_2n_mode: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_NIMBUS_EC_LESS_THAN_TWO_OH getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff we're on a Nimbus < EC 2.0
///
template< fapi2::TargetType T >
inline bool chip_ec_nimbus_lt_2_0(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_NIMBUS_EC_LESS_THAN_TWO_OH, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_NIMBUS_EC_LESS_THAN_TWO_OH: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MCBIST_END_OF_RANK getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mcbist_end_of_rank(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MCBIST_END_OF_RANK, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MCBIST_END_OF_RANK: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_WR_VREF getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mss_wr_vref(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;
    uint8_t l_do_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_WR_VREF, l_chip, l_value) );
    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_DO_MSS_WR_VREF, l_chip, l_do_value) );

    return (l_value != 0) && (l_do_value == fapi2::ENUM_ATTR_DO_MSS_WR_VREF_YES);

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_WR_VREF or ATTR_DO_MSS_WR_VREF: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_DQS_POLARITY getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mss_dqs_polarity(const fapi2::Target<T>& i_target)
{
    // Seeing better results with Monza and LaGrange by switching this off
    // TODO RTC:168029 - Remove DQS polarity EC feature if turning it off is a permanent fix.
#ifdef DO_POLARITY_WORKAROUND
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_DQS_POLARITY, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_DQS_POLARITY: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
#endif

    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_VREF_DAC getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mss_vref_dac(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;
    uint8_t l_do_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_VREF_DAC, l_chip, l_value) );
    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_DO_MSS_VREF_DAC, l_chip, l_do_value) );

    return (l_value != 0) && (l_do_value == fapi2::ENUM_ATTR_DO_MSS_VREF_DAC_YES);

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_VREF_DAC or ATTR_DO_MSS_VREF_DAC: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_WAT_DEBUG_ATTN getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mss_wat_debug_attn(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_WAT_DEBUG_ATTN, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_WAT_DEBUG_ATTN: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_TRAINING_BAD_BITS getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mss_training_bad_bits(const fapi2::Target<T>& i_target)
{
    // TODO RTC:168964 Enable training bad bits workaround at appropriate EC levels
    // Running dirty until we know what EC major & minor number we want to add this to.

#ifdef ALWAYS_DO_TRAINING_BAD_BITS_WORKAROUND
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;
    uint8_t l_do_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_TRAINING_BAD_BITS, l_chip, l_value) );
    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_DO_MSS_TRAINING_BAD_BITS, l_chip, l_do_value) );

    return (l_value != 0) && (l_do_value == fapi2::ENUM_ATTR_DO_MSS_TRAINING_BAD_BITS_YES);

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_TRAINING_BAD_BITS"
             " or ATTR_DO_MSS_TRAINING_BAD_BITS: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
#else
    return true;
#endif
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_BLUE_WATERFALL_ADJUST getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_blue_waterfall_adjust(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_BLUE_WATERFALL_ADJUST, l_chip, l_value) );

    return (l_value != 0);

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_BLUE_WATERFALL_ADJUST: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_RED_WATERFALL_ADJUST getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_red_waterfall_adjust(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_RED_WATERFALL_ADJUST, l_chip, l_value) );

    return (l_value != 0);

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_RED_WATERFALL_ADJUST: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_ENABLE_HW_VREF_CAL getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_skip_hw_vref_cal(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_chip_check = 0;
    uint8_t l_skip_check = 0;
    uint8_t l_sim = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_CHECK_DISABLE_HW_VREF_CAL, l_chip, l_chip_check) );
    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_SKIP_HW_VREF_CAL, l_chip, l_skip_check) );
    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_IS_SIMULATION, fapi2::Target<fapi2::TARGET_TYPE_SYSTEM>(), l_sim) );

    FAPI_DBG("Values of the attributes for HW VREF cal skip chip: %d skip: %d", l_chip_check, l_skip_check);

    // Chip check is required   && we're in the HW sub-revision where the skip is required - then set a skip value
    // Skips if we are in sim mode - VREF cal takes too long for simulation
    return l_sim || ((l_chip_check != 0) && (l_skip_check != 0));

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_SKIP_HW_VREF_CAL or ATTR_CHIP_EC_FEATURE_MSS_CHECK_DISABLE_HW_VREF_CAL: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_ODT_CONFIG getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mss_odt_config(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_ODT_CONFIG, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_ODT_CONFIG: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_RUN_RD_CTR_WORKAROUND getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mss_run_rd_ctr_workaround(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_RUN_RD_CTR_WORKAROUND, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_RUN_RD_CTR_WORKAROUND: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_DCD_WORKAROUND getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_dcd_workaround(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_DCD_WORKAROUND, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_DCD_WORKAROUND: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_MSS_RUN_DCD_CALIBRATION getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool run_dcd_calibration(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MSS_RUN_DCD_CALIBRATION, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_MSS_RUN_DCD_CALIBRATION: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_SKIP_RD_VREF_VREFSENSE_OVERRIDE getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff feature is enabled
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_skip_rd_vref_vrefsense_override(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_chip_check = 0;
    uint8_t l_skip_check = 0;
    uint8_t l_sim = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_CHECK_DIABLE_RD_VREF_CAL_VREFSENSE, l_chip, l_chip_check) );
    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_SKIP_RD_VREF_VREFSENSE_OVERRIDE, l_chip, l_skip_check) );
    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_IS_SIMULATION, fapi2::Target<fapi2::TARGET_TYPE_SYSTEM>(), l_sim) );

    FAPI_DBG("Values of the attributes VREFSENSE chip: %d skip: %d", l_chip_check, l_skip_check);

    // Chip check is required   && we're in the HW sub-revision where the skip is required - then set a skip value
    // Skips if we are in sim mode - VREF cal takes too long for simulation
    return l_sim || ((l_chip_check != 0) && (l_skip_check != 0));

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_SKIP_RD_VREF_VREFSENSE_OVERRIDE or ATTR_CHIP_EC_FEATURE_MSS_CHECK_DIABLE_RD_VREF_CAL_VREFSENSE: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_CHIP_EC_FEATURE_MSS_RUN_DQS_LOOP getter
/// @tparam T the fapi2 target type of the target
/// @param[in] const ref to the target
/// @return bool true iff we're on a Nimbus < EC 2.0
///
template< fapi2::TargetType T >
inline bool chip_ec_feature_mss_dqs_workaround(const fapi2::Target<T>& i_target)
{
    const auto l_chip = mss::find_target<fapi2::TARGET_TYPE_PROC_CHIP>(i_target);
    uint8_t l_value = 0;

    FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_EC_FEATURE_MSS_RUN_DQS_LOOP, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_DQS_WORKAROUND: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    fapi2::Assert(false);
    return false;
}

///
/// @brief ATTR_MSS_VOLT_VDDR setter
/// @tparam T the fapi2 target type of the target
/// @param[in] i_target const ref to the TARGET_TYPE_MCBIST
/// @param[in] i_value value to set - cannot be const because FAPI_ATTR_SET expects non-const
/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff set is OK
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode set_volt_vddr(const fapi2::Target<T>& i_target, uint32_t i_value)
{
    const auto l_mcbist = mss::find_target<fapi2::TARGET_TYPE_MCBIST>(i_target);

    FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_MSS_VOLT_VDDR, l_mcbist, i_value) );
    return fapi2::current_err;

fapi_try_exit:
    FAPI_ERR("failed setting ATTR_MSS_VOLT_VDDR: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    return fapi2::current_err;
}

///
/// @brief ATTR_MSS_VOLT_VPP setter
/// @tparam T the fapi2 target type of the target
/// @param[in] i_target const ref to the TARGET_TYPE_MCBIST
/// @param[in] i_value value to set - cannot be const because FAPI_ATTR_SET expects non-const
/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff set is OK
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode set_volt_vpp(const fapi2::Target<T>& i_target, uint32_t i_value)
{
    const auto l_mcbist = mss::find_target<fapi2::TARGET_TYPE_MCBIST>(i_target);

    FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_MSS_VOLT_VPP, l_mcbist, i_value) );
    return fapi2::current_err;

fapi_try_exit:
    FAPI_ERR("failed setting ATTR_MSS_VOLT_VPP: 0x%lx (target: %s)",
             uint64_t(fapi2::current_err), mss::c_str(i_target));
    return fapi2::current_err;
}
} // close mss namespace

#endif
OpenPOWER on IntegriCloud