summaryrefslogtreecommitdiffstats
path: root/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdTermData.H
blob: 838db3940f339f3538c82bf217fbc1aa744d075c (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdTermData.H $  */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
// $Id: getMBvpdTermData.H,v 1.5 2014/02/08 11:36:19 whs Exp $

/**
 *  @file getMBvpdTermData.H
 *
 *  @brief Prototype for getMBvpdTermData() -
 *          get Termination Data from MBvpd
 */

#ifndef    _HWP_MBVPDTERMDATA_
#define    _HWP_MBVPDTERMDATA_

#include   <fapi.H>

namespace fapi
{

// The MBvpdTermData enumeration is used on the FAPI_ATTR_GET and
// getMBvpdTermData HWP accessor interface. The lower byte (6 bits)
// matches the offset of the vpd field in the MT keyword. This is a convenient
// use of the value for efficiency to index into the vpd keyword data.
//
// Most of the vpd attribute values can be returned to the requester directly.
// There are some that require special processing. For those, a
// special processing flag is added into the value. This also distinguishes
// values which have the same offset.

// special processing flags to be added on to the MBvpdTermData value
    enum MBvpdTermDataSpecial
    {
        TERM_DATA_HIGH_NIBBLE = 0x0100,  //bits 0:3 of MSB 0 to LSB 7
                                         //  shifted right 4
        TERM_DATA_LOW_NIBBLE  = 0x0200,  //bits 4:7 of MSB 0 to LSB 7
    };
// mask to isolate special processing flags
const uint16_t TERM_DATA_SPECIAL_MASK = 0x0300;

// The vpd keyword changed for some of the attributes going from v5.3 of the vpd
// layout to v6.0 and after. There is a work around to use the previous
// keyword based on the vpd version.
// Flag to be added into MBvpdTermData value for attributes that need to be
// checked for work around.
const uint8_t TERM_DATA_CHK60 = 0x40;  // check version for keyword to use

// There are multiple types of output values. The type is shown in the comment.
//
// Some values are returned directly from the vpd and some vpd values
// are translated before returning. Those translated are marked in the comment
// section with <translated>
//
// The base offset value is incremented based on the vpd data type.
    enum MBvpdTermData
    {
       TERM_DATA_DRAM_RON =             0x00,  //uint8_t [2][2] <translated>
       TERM_DATA_DRAM_RTT_NOM =         0x02,  //uint8_t [2][2][4] <translated>
       TERM_DATA_DRAM_RTT_WR =          0x0a,  //uint8_t [2][2][4] <translated>
       TERM_DATA_ODT_RD =                  0x12,  //uint8_t [2][2][4]
       TERM_DATA_ODT_WR =                  0x1a,  //uint8_t [2][2][4]
       TERM_DATA_CEN_RD_VREF =             0x22,  //uint32_t [2] <translated>
       TERM_DATA_DRAM_WR_VREF =            0x26,  //uint32_t [2] <translated>
       TERM_DATA_DRAM_WRDDR4_VREF =        0x2a,  //uint8_t [2]
       TERM_DATA_CEN_RCV_IMP_DQ_DQS =      0x2b,  //uint8_t [2]
       TERM_DATA_CEN_DRV_IMP_DQ_DQS =      0x2c,  //uint8_t [2]
       TERM_DATA_CEN_DRV_IMP_CNTL =        0x2d,  //uint8_t [2]
       TERM_DATA_CEN_DRV_IMP_ADDR =        0x2e,  //uint8_t [2]
       TERM_DATA_CEN_DRV_IMP_CLK =         0x2f,  //uint8_t [2]
       TERM_DATA_CEN_DRV_IMP_SPCKE =       0x30,  //uint8_t [2]
       TERM_DATA_CEN_SLEW_RATE_DQ_DQS =    0x31,  //uint8_t [2] <translated>
       TERM_DATA_CEN_SLEW_RATE_CNTL =      0x32,  //uint8_t [2] <translated>
       TERM_DATA_CEN_SLEW_RATE_ADDR =      0x33,  //uint8_t [2] <translated>
       TERM_DATA_CEN_SLEW_RATE_CLK =       0x34,  //uint8_t [2] <translated>
       TERM_DATA_CEN_SLEW_RATE_SPCKE =     0x35,  //uint8_t [2] <translated>
// TERM_DATA_CKE_PRI_MAP is a uint16 in the vpd data. It is returned as
// as a uint32. The offset is incremented by only 2 to get the next vpd value.
       TERM_DATA_CKE_PRI_MAP =             0x36,  //uint32_t [2]
// TERM_DATA_CKE_PWR_MAP is a uint64_t composed of the uint32_t port 0 and
// port 1 values at this offset. The offset is incremented by 4.
       TERM_DATA_CKE_PWR_MAP =             0x38,  //uint64_t
       TERM_DATA_RLO = 0x3c|TERM_DATA_CHK60|TERM_DATA_LOW_NIBBLE,   //uint8_t[2]
       TERM_DATA_WLO = 0x3c|TERM_DATA_CHK60|TERM_DATA_HIGH_NIBBLE,  //uint8_t[2]
       TERM_DATA_GPO = 0x3d|TERM_DATA_CHK60,    //uint8_t[2]
    };
}
// The max base offset value is 0x3e. The MT keyword is 255 bytes.
// There is only room for 63 attributes per port. There are 4 x  64 byte
// sections, but the last one is 1 byte short. See diagram below...
const uint8_t TERM_DATA_OFFSET_MASK = 0x003f; //mask attr to isolate base offset

// Template class that is specialized for each attribute specifying it's type
template<const fapi::MBvpdTermData A>
    class MBvpdTermDataSize { };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_DRAM_RON>
    { public: typedef uint8_t Type[2][2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_DRAM_RTT_NOM>
    { public: typedef uint8_t Type[2][2][4]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_DRAM_RTT_WR>
    { public: typedef uint8_t Type[2][2][4]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_ODT_RD>
    { public: typedef uint8_t Type[2][2][4]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_ODT_WR>
    { public: typedef uint8_t Type[2][2][4]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_RD_VREF>
    { public: typedef uint32_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_DRAM_WR_VREF>
    { public: typedef uint32_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_DRAM_WRDDR4_VREF>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_RCV_IMP_DQ_DQS>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_DRV_IMP_DQ_DQS>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_DRV_IMP_CNTL>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_DRV_IMP_ADDR>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_DRV_IMP_CLK>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_DRV_IMP_SPCKE>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_SLEW_RATE_DQ_DQS>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_SLEW_RATE_CNTL>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_SLEW_RATE_ADDR>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_SLEW_RATE_CLK>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CEN_SLEW_RATE_SPCKE>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CKE_PRI_MAP>
    { public: typedef uint32_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_CKE_PWR_MAP>
    { public: typedef uint64_t Type ; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_RLO>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_WLO>
    { public: typedef uint8_t Type[2]; };
template<>class MBvpdTermDataSize<fapi::TERM_DATA_GPO>
    { public: typedef uint8_t Type[2]; };

// Template function that checks that the type is as expected.
// This can be optionally called before calling the main HWP in order
// to check for the expected type at compile-time.
template<const fapi::MBvpdTermData ATTR>
    inline void checkTermDataType
        (typename MBvpdTermDataSize<ATTR>::Type &) {}
/* example
#define ATTR_VPD_DRAM_RON_GETMACRO(ID, PTARGET, VAL)\
   (checkTermDataType<fapi::TERM_DATA_DRAM_RON>(VAL), \
   fapi::platAttrSvc::fapiPlatGetTermData\
      (PTARGET, fapi::TERM_DATA_DRAM_RON , VAL, sizeof(VAL)))
*/
// The complilation will fail unless the output variable matches the type
// in the per attribute template specialization. The error messages will
// include text related to template MBvpdTermDataSize not be able to convert
// the incorrect output variable's type to the expected type.
//
// There will be an additonal error from the general attribute compliation
// checks related to fapiCheckIdType if the output type does not match
// any of the expected types
//
// The inline function checkTermData will be optimized out by the compiler.

// function pointer typedef definition for HWP call support
typedef fapi::ReturnCode (*getMBvpdTermData_FP_t)
     (const fapi::Target &, const fapi::MBvpdTermData,
      void *, const uint32_t);

extern "C"
{
/**
 * @brief get Termination Data from cvpd record VSPD keyword MT
 *
 * The Termination Data attributes are retrieved from cvpd record VSPD
 * keyword MT.
 * There are two mba per memory buffer: position 0 and position 1.
 * There are two ports for each mba. There are 4 sets of Termination
 * Data attributes.
 *
 * cpvd record VSPD keyword MT
 * -----------------------------------
 * | mba position 0                  |
 * |  -----------------------------  |
 * |  | port 0  (Port A) 64 bytes |  |
 * |  |---------------------------|  |
 * |  | port 1  (Port B) 64 bytes |  |
 * |  -----------------------------  |
 * |---------------------------------|
 * | mba postion 1                   |
 * |  -----------------------------  |
 * |  | port 0  (Port C) 64 bytes |  |
 * |  |---------------------------|  |
 * |  | port 1  (Port D) 63 bytes |  |
 * |  -----------------------------  |
 * -----------------------------------
 *
 * The Termination Data attributes have multiple types. The output value
 * is a general void * to handle the multiple attributes types. The expected
 * output variable type is shown in the attribute enumeration comment and in
 * the MBvpdTermDataSize template.
 * An error will be returned if output size does not match the size of the
 * expected output type's size.
 *
 * @param[in]  i_mbaTarget       -   mba target
 * @param[in]  i_attr            -   Termination Data attribute enumerator
 * @param[out] o_pVal            -   pointer to variable typed output variable
 * @param[in]  i_valSize         -   size of output variable
 *
 * @return fapi::ReturnCode -   FAPI_RC_SUCCESS if success,
 *                              relevant error code for failure.
 */
fapi::ReturnCode getMBvpdTermData(
                              const fapi::Target   &i_mbaTarget,
                              const fapi::MBvpdTermData i_attr,
                              void  * o_pVal,
                              const uint32_t i_valSize);

}

#endif
OpenPOWER on IntegriCloud