summaryrefslogtreecommitdiffstats
path: root/src/import/chips/centaur/procedures/hwp/memory/p9c_mss_termination_control.H
blob: ccebbf44fdfdfb5e4326e604f64972dceec6d227 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/centaur/procedures/hwp/memory/p9c_mss_termination_control.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_draminit_training_advanced.H
/// @brief Tools for DDR4 DIMMs centaur procedures
///
/// *HWP HWP Owner: Luke Mulkey <lwmulkey@us.ibm.com>
/// *HWP HWP Backup: SARAVANAN SETHURAMAN <saravanans@in.ibm.com>
/// *HWP Team: Memory
/// *HWP Level: 2
/// *HWP Consumed by: HB:CI
//
//


#ifndef MSS_TERMINATION_CONTROL_H
#define MSS_TERMINATION_CONTROL_H
//----------------------------------------------------------------------
//  Includes
//----------------------------------------------------------------------
#include <fapi2.H>
#include <cen_gen_scom_addresses_fld.H>
#include <cen_gen_scom_addresses.H>

///
/// @brief termination constants
///
enum term_consts : size_t
{
    SLEW = 0,
    IMP = 1,
    MAX_NUM_IMP = 4,      // number of impedances valid per slew type
    // bypass slew (MAX slew rate) not included since it is not calibrated.
    MAX_NUM_CAL_SLEW_RATES = 4,  // 3V/ns, 4V/ns, 5V/ns, 6V/n
    MAX_NUM_SLEW_RATES = 4,   // 3V/ns, 4V/ns, 5V/ns, 6V/n, MAX?
    MAX_SLEW_VALUE = 15,      // 4 bit value
    MAX_WR_VREF = 32,
    MAX_DRV_IMP = 4,
    MAX_RCV_IMP = 9,
};

///
/// @brief Address shmoo is not done as a part of Training advanced, so the order matches attribute enum
///
const uint8_t adr_imp_array[] =
{
    15,
    20,
    30,
    40,
};

///
/// @brief slew rate values
///
const uint8_t slew_rate_array[] =
{
    6,
    5,
    4,
    3,
};

///
/// @brief Wr vref values
///
const uint32_t wr_vref_array[] =
{
    420,
    425,
    430,
    435,
    440,
    445,
    450,
    455,
    460,
    465,
    470,
    475,
    480,
    485,
    490,
    495,
    500,
    505,
    510,
    515,
    520,
    525,
    530,
    535,
    540,
    545,
    550,
    555,
    560,
    565,
    570,
    575
};


//The Array is re-arranged inorder to find the best Eye margin based on the
//Fitness level - 500 is the best value
const uint32_t wr_vref_array_fitness[] =
{
    420,
    425,
    575,
    430,
    570,
    435,
    565,
    440,
    560,
    445,
    555,
    450,
    550,
    455,
    545,
    460,
    540,
    465,
    535,
    470,
    530,
    475,
    525,
    480,
    520,
    485,
    515,
    490,
    510,
    495,
    505,
    500
};

const uint8_t MAX_RD_VREF = 16;

///
/// @brief rd vref values
///
const uint32_t rd_cen_vref_array[] =
{
    40375,
    41750,
    43125,
    44500,
    45875,
    47250,
    48625,
    50000,
    51375,
    52750,
    54125,
    55500,
    56875,
    58250,
    59625,
    61000
};

///
/// @brief The Array is re-arranged inorder to find the best Eye margin based on the
/// Fitness level - 50000 is the best value
///
const uint32_t rd_cen_vref_array_fitness[] =
{
    61000,
    59625,
    40375,
    58250,
    41750,
    56875,
    43125,
    55500,
    44500,
    54125,
    45875,
    52750,
    47250,
    51375,
    48625,
    50000
};

///
/// @brief The Array is re-arranged inorder to find the best Eye margin based on the
/// Fitness level - 24 is the best value
///
const uint8_t drv_imp_array[] =
{
    40,
    34,
    30,
    24
};

///
/// @brief The Array is re-arranged inorder to find the best Eye margin based on the
/// Fitness level - 15 is the best value
///
const uint8_t rcv_imp_array[] =
{
    120,
    80,
    60,
    48,
    40,
    34,
    30,
    20,
    15
};

///
/// @brief slew calibration control register
///
constexpr uint64_t SLEW_CAL_CNTL[] =
{
    CEN_MBA_DDRPHY_ADR_SLEW_CAL_CNTL_P0_ADR32S0, // port 0
    CEN_MBA_DDRPHY_ADR_SLEW_CAL_CNTL_P1_ADR32S0  // port 1
};

///
/// @brief slew calibration status registers
///
constexpr uint64_t SLEW_CAL_STAT[] =
{
    CEN_MBA_DDRPHY_ADR_SYSCLK_PR_VALUE_RO_P0_ADR32S0_RO,
    CEN_MBA_DDRPHY_ADR_SYSCLK_PR_VALUE_RO_P1_ADR32S0_RO
};

///
/// @brief adr enums
///
enum adr
{
    ADR_SLEW_CAL_CNTL_ADR32S0_ENABLE = CEN_MBA_DDRPHY_ADR_SLEW_CAL_CNTL_P0_ADR32S0_ADR0_ENABLE,
    ADR_SLEW_CAL_CNTL_ADR32S0_START = CEN_MBA_DDRPHY_ADR_SLEW_CAL_CNTL_P0_ADR32S0_ADR0_START,
    ADR_SYSCLK_PR_VALUE_RO_BB_LOCK = CEN_MBA_DDRPHY_ADR_SYSCLK_PR_VALUE_RO_P0_ADR32S0_ADR0_BB_LOCK,
};

constexpr uint8_t NUM_DRAM_GENS = 2;
constexpr uint8_t NUM_PIN_TYPES = 2;
constexpr uint8_t NUM_SPEEDS = 4;
constexpr uint8_t NUM_IMPS = 4;
constexpr uint8_t NUM_SLEWS = 4;
// DD level 1.0-1.1, Version 1.0
// [ddr3/4][dq/adr][speed][impedance][slew_rate]
// note: Assumes standard voltage for DDR3(1.35V), DDR4(1.2V),
// little endian, if >=128, lab only debug.
//
// ddr_type(2)  ddr3=0, ddr4=1
// data/adr(2)  data(dq/dqs)=0, adr(cmd/cntl)=1
// speed(4)     1066=0, 1333=1, 1600=2, 1866=3
// imped(4)     24ohms=0, 30ohms=1, 34ohms=2, 40ohms=3 for DQ/DQS
// imped(4)     15ohms=0, 20ohms=1, 30ohms=2, 40ohms=3 for ADR driver
// slew(3)      3V/ns=0, 4V/ns=1, 5V/ns=2, 6V/ns=3
constexpr uint8_t SLEW_TABLE[NUM_DRAM_GENS][NUM_PIN_TYPES][NUM_SPEEDS][NUM_IMPS][NUM_SLEWS] =
{
    //  NOTE: bit 7 = unsupported slew, and actual value is in bits 4:0

    /*  DDR3(0) */
    { {
            // dq/dqs(0)
            /* Imp. ________24ohms______..________30ohms______..________34ohms______..________40ohms______
               Slew    3    4    5    6      3    4    5    6      3    4    5    6      3    4    5    6  (V/ns) */
            /*1066*/{{ 12,   9,   7, 134}, { 13,   9,   7, 133}, { 13,  10,   7, 134}, { 14,  10,   7, 132}},
            /*1333*/{{ 15,  11,   8, 135}, { 16,  12,   9, 135}, { 17,  12,   9, 135}, { 17,  12,   8, 133}},
            /*1600*/{{ 18,  13,  10, 136}, { 19,  14,  10, 136}, { 20,  15,  11, 136}, { 21,  14,  10, 134}},
            /*1866*/{{149, 143, 140, 138}, {151, 144, 140, 137}, {151, 145, 141, 138}, {152, 145, 139, 135}}
        }, {
            // adr(1),
            /* Imp. ________15ohms______..________20ohms______..________30ohms______..________40ohms______
               Slew    3    4    5    6      3    4    5    6      3    4    5    6      3    4    5    6  (V/ns) */
            /*1066*/{{ 17,  13,  10,   8}, { 13,  10,   7,   6}, { 12,   8,   5, 131}, {  7,   4, 131, 131}},
            /*1333*/{{ 21,  16,  12,  10}, { 17,  12,   9,   7}, { 15,  10,   6, 132}, {  6,   5, 132, 132}},
            /*1600*/{{ 25,  19,  15,  12}, { 20,  14,  13,   8}, { 19,  12,   7, 133}, {  7,   6, 133, 133}},
            /*1866*/{{157, 150, 145, 142}, {151, 145, 141, 138}, {150, 142, 136, 134}, {141, 134, 134, 134}}
        }
    },
    /* DDR4(1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
    { {
            // dq/dqs(0)
            /* Imp. ________24ohms______..________30ohms______..________34ohms______..________40ohms______
               Slew    3    4    5    6      3    4    5    6      3    4    5    6      3    4    5    6  (V/ns) */
            /*1066*/{{138, 135, 134, 133}, {139, 136, 134, 132}, {140, 136, 134, 132}, {140, 136, 132, 132}},
            /*1333*/{{139, 137, 135, 134}, {142, 138, 135, 133}, {143, 138, 135, 133}, {143, 138, 133, 132}},
            /*1600*/{{ 15,  11,   9, 135}, { 17,  11,   9, 135}, { 18,  13,   9, 134}, { 18,  11,   6, 133}},
            /*1866*/{{ 18,  13,  10, 137}, { 19,  13,  10, 136}, { 21,  15,  10, 135}, { 21,  13,   8, 134}}
        }, {
            // adr(1)
            /* Imp. ________15ohms______..________20ohms______..________30ohms______..________40ohms______
               Slew    3    4    5    6      3    4    5    6      3    4    5    6      3    4    5    6  (V/ns) */
            /*1066*/{{142, 139, 136, 134}, {140, 136, 134, 133}, {138, 134, 131, 131}, {133, 131, 131, 131}},
            /*1333*/{{145, 142, 139, 136}, {143, 138, 135, 134}, {140, 135, 132, 132}, {134, 132, 132, 132}},
            /*1600*/{{ 21,  16,  13,  10}, { 18,  12,   9, 135}, { 15,   8, 133, 133}, {  7, 133, 133, 133}},
            /*1866*/{{ 24,  19,  15,  11}, { 21,  14,  10, 136}, { 17,  10, 134, 134}, {  9, 134, 134, 134}}
        }
    }
};


extern "C"
{
    ///
    /// @brief configures PC_VREF_DRV_CONTROL registers to vary the DRAM VREF
    /// @param[in] i_target_mba   Reference to centaur.mba target
    /// @param[in] i_port         MBA Port
    /// @param[in] i_wr_dram_vref DRAM VREF to set
    /// @return ReturnCode
    ///
    fapi2::ReturnCode config_wr_dram_vref(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target_mba,
                                          const uint8_t i_port,
                                          const uint32_t i_wr_dram_vref);

    ///
    /// @brief configures read vref registers to vary the CEN VREF
    /// @param[in] i_target_mba   Reference to centaur.mba target
    /// @param[in] i_port         MBA Port
    /// @param[in] i_rd_cen_vref  CEN VREF to set
    /// @return ReturnCode
    ///
    fapi2::ReturnCode config_rd_cen_vref(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target_mba,
                                         const uint8_t i_port,
                                         const uint32_t i_rd_cen_vref);

    ///
    /// @brief configures the Driver impedance values to the registers
    /// @param[in] i_target_mba     Reference to centaur.mba target
    /// @param[in] i_port           MBA Port
    /// @param[in] i_drv_imp_dq_dqs Driver impedance values
    /// @return ReturnCode
    ///
    fapi2::ReturnCode config_drv_imp(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target_mba,
                                     const uint8_t i_port,
                                     const uint8_t i_drv_imp_dq_dqs);

    ///
    /// @brief configures the Receiver impedance values to the registers
    /// @param[in] i_target_mba     Reference to centaur.mba target
    /// @param[in] i_port           MBA Port
    /// @param[in] i_rcv_imp_dq_dqs Receiver impedance values
    /// @return ReturnCode
    ///
    fapi2::ReturnCode config_rcv_imp(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target_mba,
                                     const uint8_t i_port,
                                     const uint8_t i_rcv_imp_dq_dqs);

    ///
    /// @brief configures the Slew rate values to the registers
    /// @param[in] i_target_mba Reference to centaur.mba target
    /// @param[in] i_port       MBA Port
    /// @param[in] i_slew_type  Slew Type
    /// @param[in] i_slew_imp   Slew Impedance
    /// @param[in] i_slew_rate  Slew Rate
    /// @return ReturnCode
    ///
    fapi2::ReturnCode config_slew_rate(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target_mba,
                                       const uint8_t i_port,
                                       const uint8_t i_slew_type,
                                       const uint8_t i_slew_imp,
                                       const uint8_t i_slew_rate);

    ///
    /// @brief runs the slew calibration engine
    /// Configures MSS_SLEW_DATA/ADR attributes and calls config_slew_rate to set
    /// the slew rate in the registers.
    /// @param[in] i_target_mba     Reference to centaur.mba target
    /// @return ReturnCode
    ///
    fapi2::ReturnCode mss_slew_cal(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target_mba);

} // extern C
#endif
OpenPOWER on IntegriCloud