summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/memory/lib/spd/rdimm/rdimm_decoder_v1_1.C
blob: 4a6a2dc148f699ba08bb8c958e16d668c4b008df (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/memory/lib/spd/rdimm/rdimm_decoder_v1_1.C $ */
/*                                                                        */
/* 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                                                     */

// std lib
#include <vector>

// fapi2
#include <fapi2.H>

// mss lib
#include <lib/spd/rdimm/rdimm_decoder.H>
#include <lib/spd/common/spd_decoder.H>
#include <lib/utils/checker.H>
#include <generic/memory/lib/utils/c_str.H>
#include <lib/utils/find.H>

using fapi2::TARGET_TYPE_MCBIST;
using fapi2::TARGET_TYPE_MCA;
using fapi2::TARGET_TYPE_MCS;
using fapi2::TARGET_TYPE_DIMM;


namespace mss
{
namespace spd
{

/////////////////////////
// Member Method implementation
// For RDIMM module rev 1.1
/////////////////////////

///
/// @brief Decodes register type
/// @param[out] o_output encoding from SPD
/// @return FAPI2_RC_SUCCESS if okay
/// @note SPD Byte 131 (Bits 7~4)
/// @note Item JEDEC Standard No. 21-C
/// @note DDR4 SPD Document Release 3
/// @note Page 4.1.2.12.3 - 63
///
fapi2::ReturnCode rdimm_decoder_v1_1::register_and_buffer_type(uint8_t& o_output)
{
    constexpr size_t BYTE = 131;
    // Extracting desired bits
    uint8_t l_field_bits = extract_spd_field<BYTE, REGISTER_TYPE_START, REGISTER_TYPE_LEN>(iv_target, iv_spd_data);
    FAPI_INF("Field Bits value: %d", l_field_bits);

    // This checks my extracting params returns a value within bound
    constexpr size_t RESERVED = 2;

    FAPI_TRY( mss::check::spd::fail_for_invalid_value(iv_target,
              (l_field_bits < RESERVED), // extract sanity check
              BYTE,
              l_field_bits,
              "Failed bounds check for Register and Data Buffer Types") );

    // Update output only if check passes
    o_output = l_field_bits;

    FAPI_INF("%s. Register Types: %d",
             mss::c_str(iv_target),
             o_output);

fapi_try_exit:
    return fapi2::current_err;

}

///
/// @brief Decodes register output drive strength for CKE signal
/// @param[out] o_output drive strength encoding from SPD
/// @return FAPI2_RC_SUCCESS if okay
/// @note SPD Byte 137 (bit 1~0)
/// @note Item JC-45-2220.01x
/// @note Page 76
/// @note DDR4 SPD Document Release 4
///
fapi2::ReturnCode rdimm_decoder_v1_1::cke_signal_output_driver(uint8_t& o_output)
{
    // Extracting desired bits
    constexpr size_t BYTE = 137;
    uint8_t l_field_bits = extract_spd_field<BYTE, CKE_DRIVER_START, CKE_DRIVER_LEN>(iv_target, iv_spd_data);

    FAPI_INF("Field_Bits value: %d", l_field_bits);

    // This really just checks my extract gives me a valid value
    constexpr size_t MAX_VALID_VALUE = 0b11;

    FAPI_TRY( mss::check::spd::fail_for_invalid_value(iv_target,
              (l_field_bits <= MAX_VALID_VALUE), // extract sanity check
              BYTE,
              l_field_bits,
              "Failed bounds check for Register Output Driver for CKE") );

    o_output = l_field_bits;

    FAPI_INF("%s. Register Output Driver for CKE: %d",
             mss::c_str(iv_target),
             o_output);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Decodes register output drive strength for ODT signal
/// @param[out] o_output drive strength encoding from SPD
/// @return FAPI2_RC_SUCCESS if okay
/// @note SPD Byte 137 (bit 3~2)
/// @note Item JC-45-2220.01x
/// @note Page 76
/// @note DDR4 SPD Document Release 4
///
fapi2::ReturnCode rdimm_decoder_v1_1::odt_signal_output_driver(uint8_t& o_output)
{
    // Extracting desired bits
    constexpr size_t BYTE = 137;
    uint8_t l_field_bits = extract_spd_field<BYTE, ODT_DRIVER_START, ODT_DRIVER_LEN>(iv_target, iv_spd_data);

    FAPI_INF("Field_Bits value: %d", l_field_bits);

    // This really just checks my extract gives me a valid value
    constexpr size_t MAX_VALID_VALUE = 0b11;

    FAPI_TRY( mss::check::spd::fail_for_invalid_value(iv_target,
              (l_field_bits <= MAX_VALID_VALUE), // extract sanity check
              BYTE,
              l_field_bits,
              "Failed bounds check for Register Output Driver for ODT") );

    o_output = l_field_bits;

    FAPI_INF("%s. Register Output Driver for ODT: %d",
             mss::c_str(iv_target),
             o_output);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Decodes register output drive strength for chip select (CS) signal
/// @param[out] o_output drive strength encoding from SPD
/// @return FAPI2_RC_SUCCESS if okay
/// @note SPD Byte 137 (bit 6~7)
/// @note Item JC-45-2220.01x
/// @note Page 76
/// @note DDR4 SPD Document Release 4
///
fapi2::ReturnCode rdimm_decoder_v1_1::cs_signal_output_driver(uint8_t& o_output)
{
    // Extracting desired bits
    constexpr size_t BYTE = 137;
    uint8_t l_field_bits = extract_spd_field<BYTE, CS_DRIVER_START, CS_DRIVER_LEN>(iv_target, iv_spd_data);

    FAPI_INF("Field_Bits value: %d", l_field_bits);

    // This really just checks my extract gives me a valid value
    constexpr size_t MAX_VALID_VALUE = 0b11;

    FAPI_TRY( mss::check::spd::fail_for_invalid_value(iv_target,
              (l_field_bits <= MAX_VALID_VALUE), // extract sanity check
              BYTE,
              l_field_bits,
              "Failed bounds check for Register Output Driver for chip select") );

    o_output = l_field_bits;

    FAPI_INF("%s. Register Output Driver for CS: %d",
             mss::c_str(iv_target),
             o_output);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Decodes register output drive strength for clock (B side)
/// @param[out] o_output drive strength encoding from SPD
/// @return FAPI2_RC_SUCCESS if okay
/// @note SPD Byte 138 (bit 1~0)
/// @note Item JC-45-2220.01x
/// @note Page 76
/// @note DDR4 SPD Document Release 4
///
fapi2::ReturnCode rdimm_decoder_v1_1::b_side_clk_output_driver(uint8_t& o_output)
{
    // Extracting desired bits
    constexpr size_t BYTE = 138;
    uint8_t l_field_bits = extract_spd_field<BYTE, YO_Y2_DRIVER_START, YO_Y2_DRIVER_LEN>(iv_target, iv_spd_data);

    FAPI_INF("Field_Bits value: %d", l_field_bits);

    // This really just checks my extract gives me a valid value
    constexpr size_t MAX_VALID_VAL = 2;

    FAPI_TRY( mss::check::spd::fail_for_invalid_value(iv_target,
              (l_field_bits <= MAX_VALID_VAL), // extract sanity check
              BYTE,
              l_field_bits,
              "Failed bounds check for Register Output Driver for clock (Y0,Y2)") );

    o_output = l_field_bits;

    FAPI_INF("%s. Register Output Driver for clock (Y0,Y2): %d",
             mss::c_str(iv_target),
             o_output);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Decodes register output drive strength for clock (A side)
/// @param[out] o_output drive strength encoding from SPD
/// @return FAPI2_RC_SUCCESS if okay
/// @note SPD Byte 138 (bit 3~2)
/// @note Item JC-45-2220.01x
/// @note Page 76
/// @note DDR4 SPD Document Release 4
///
fapi2::ReturnCode rdimm_decoder_v1_1::a_side_clk_output_driver(uint8_t& o_output)
{
    // Extracting desired bits
    constexpr size_t BYTE = 138;
    uint8_t l_field_bits = extract_spd_field<BYTE, Y1_Y3_DRIVER_START, Y1_Y3_DRIVER_LEN>(iv_target, iv_spd_data);

    FAPI_INF("Field_Bits value: %d", l_field_bits);

    // This really just checks my extract gives me a valid value
    constexpr size_t MAX_VALID_VAL = 2;

    FAPI_TRY( mss::check::spd::fail_for_invalid_value(iv_target,
              (l_field_bits <= MAX_VALID_VAL), // extract sanity check
              BYTE,
              l_field_bits,
              "Failed bounds check for Register Output Driver for clock (Y1,Y3)") );

    o_output = l_field_bits;

    FAPI_INF("%s. Register Output Driver for clock (Y1,Y3): %d",
             mss::c_str(iv_target),
             o_output);

fapi_try_exit:
    return fapi2::current_err;
}

}//spd
}// mss
OpenPOWER on IntegriCloud