summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/memory/lib/mss_attribute_accessors_manual.H
blob: 7b77aa04d5f8b7aa8b4d6d9b8b639f842e4d9091 (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
/* 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,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_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: Brian Silver <bsilver@us.ibm.com>
// *HWP HWP Backup: Steven Glancy <sglancy@usi.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/find.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_UT_EC_NIMBUS_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_UT_EC_NIMBUS_LESS_THAN_TWO_OH, l_chip, l_value) );

    return l_value != 0;

fapi_try_exit:
    FAPI_ERR("failed accessing ATTR_CHIP_EC_FEATURE_MSS_UT_EC_NIMBUS_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)
{
    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);
    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:165862 - need to get the minor EC number and check that in here.
    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;
}

} // close mss namespace

#endif
OpenPOWER on IntegriCloud