summaryrefslogtreecommitdiffstats
path: root/src/import/chips/centaur/procedures/hwp/memory/p9c_mss_ddr4_pda.H
blob: cc884d7709143ae61217da20d6ddb82407defcb6 (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/centaur/procedures/hwp/memory/p9c_mss_ddr4_pda.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2018                        */
/* [+] 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_ddr4_pda.H
/// @brief Tools for DDR4 DIMMs centaur procedures
///
/// *HWP HWP Owner: Luke Mulkey <lwmulkey@us.ibm.com>
/// *HWP HWP Backup: Steve Glancy <sglancy@us.ibm.com>
/// *HWP Team: Memory
/// *HWP Level: 2
/// *HWP Consumed by: HB:CI
///

#ifndef _MSS_DDR4_PDA_H
#define _MSS_DDR4_PDA_H
#include <fapi2.H>
#include <vector>
using namespace std;

extern "C"
{
///
/// @brief PDA MRS storage structure
///
    class PDA_MRS_Storage
    {
        private:
            char pda_string[fapi2::MAX_ECMD_STRING_LEN];
        public:
            uint8_t attribute_data;
            uint32_t attribute_name;
            uint8_t MRS;
            uint8_t dimm;
            uint8_t dram;
            uint8_t rank;
            uint8_t port;

            ///
            /// @brief PDA MRS storage constructor
            /// @param[in] ad attribute data
            /// @param[in] ad attribute name/ID
            /// @param[in] dr dram number
            /// @param[in] di DIMM position
            /// @param[in] r rank
            /// @param[in] p port
            ///
            PDA_MRS_Storage(const uint8_t ad, const uint32_t an, const uint8_t dr, const uint8_t di, const uint8_t r,
                            const uint8_t p);

            ///
            /// @brief Destructor
            ///
            ~PDA_MRS_Storage();

            ///
            /// @brief Greater than operator
            /// @param[in] PDA2 object to compare to
            /// @return bool true iff this object is greater than the one we're comparing against
            ///
            bool operator> (const PDA_MRS_Storage& PDA2) const;

            ///
            /// @brief Greater than operator
            /// @param[in] PDA2 object to compare to
            /// @return bool true iff this object is greater than the one we're comparing against
            ///
            bool operator< (const PDA_MRS_Storage& PDA2) const;

            ///
            /// @brief copies one PDA_MRS_Storage to this one
            /// @param[in] temp MRS storage data structure
            ///
            void copy(PDA_MRS_Storage& temp);

            ///
            /// @brief sets the MRS variable based upon the inputted attribute name
            /// @param[in] i_target Centaur MBA target
            /// @return FAPI2_RC_SUCCESS
            ///
            fapi2::ReturnCode setMRSbyAttr(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

            ///
            /// @brief Checks to make sure that
            /// @param[in] i_target MBA target
            /// @return FAPI2_RC_SUCCESS iff successful
            ///
            fapi2::ReturnCode checkPDAValid(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target);

            ///
            /// @brief sends out the string
            /// @return pda string
            ///
            char* c_str();
            void generatePDAString();
    };

///
/// @brief PDA scom storage structure
///
    class PDA_Scom_Storage
    {
        public:
            uint64_t scom_addr;
            uint32_t start_bit;
            uint32_t num_bits;
            ///
            /// @brief PDA_Scom_Storage constructor
            /// @param[in] sa  Scom Address
            /// @param[in] sb  Start Bit
            /// @param[in] nb  Num Bits
            ///
            PDA_Scom_Storage(const uint64_t sa, const uint32_t sb, const uint32_t nb);

            ///
            /// @brief Default destructor
            ///
            ~PDA_Scom_Storage() = default;
    };

    typedef fapi2::ReturnCode (*mss_ddr4_pda_FP_t)(fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
            vector<PDA_MRS_Storage> pda);

    ///
    /// @brief runs through the vector of given PDA values and issues the PDA commands to the requested DRAMs
    /// @param[in]  i_target:  Reference to centaur.mba target,
    /// @param[in]  i_pda:  Vector of PDA_MRS_Storage class elements - initialized by the user and contains DRAM information and attribute override information
    /// @return FAPI2_RC_SUCCESS iff successful
    ///
    fapi2::ReturnCode mss_ddr4_run_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
                                       vector<PDA_MRS_Storage> i_pda);

    ///
    /// @brief Puts the DRAM in per-DRAM addressability mode (PDA mode)
    /// @param[in]  target:  Reference to centaur.mba target,
    /// @param[in/out]  io_ccs_inst_cnt: starting point of CCS array - needed to properly setup CCS
    /// @param[in] i_dimm Centaur dimm to run
    /// @param[in] i_rank Centaur rank to run
    /// @return FAPI2_RC_SUCCESS iff successful
    ///
    fapi2::ReturnCode mss_ddr4_setup_pda(
        const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
        uint32_t& io_ccs_inst_cnt,
        const uint8_t i_dimm,
        const uint8_t i_rank);

    ///
    /// @brief Takes the DRAM out of per-DRAM addressability mode (PDA mode)
    /// @param[in]  target:  Reference to centaur.mba target,
    /// @param[in/out]  io_ccs_inst_cnt: starting point of CCS array - needed to properly setup CCS
    /// @param[in]  i_dimm: which DIMM to run PDA commands on
    /// @param[in]  i_rank: which rank on which DIMM to run PDA commands on
    /// @return FAPI2_RC_SUCCESS iff successful
    ///
    fapi2::ReturnCode mss_ddr4_disable_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target, uint32_t& io_ccs_inst_cnt,
                                           const uint8_t i_dimm, const uint8_t i_rank);

    ///
    /// @brief called by wrapper - sets up a PDA vector if it's not already configured
    /// @param[in]  i_target:  Reference to centaur.mba target,
    /// @param[in]  i_pda:  Vector of PDA_MRS_Storage class elements - initialized by the user and contains DRAM information and attribute override information
    /// @return FAPI2_RC_SUCCESS iff successful
    ///
    fapi2::ReturnCode mss_ddr4_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target, vector<PDA_MRS_Storage> i_pda);

    ///
    /// @brief Checks the passed in PDA vector to ensure that all entries are good. then sorts the vector to ensure more efficient command stream
    /// @param[in]  i_target:  Reference to centaur.mba target,
    /// @param[in/out]  io_pda:  Vector of PDA_MRS_Storage class elements - initialized by the user and contains DRAM information and attribute override information
    /// @return FAPI2_RC_SUCCESS iff successful
    ///
    fapi2::ReturnCode mss_ddr4_checksort_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
            vector<PDA_MRS_Storage>& io_pda);

    ///
    /// @brief Adds a given DRAM into the scom_storage vector
    /// @param[in]  i_target:  Reference to centaur.mba target,
    /// @param[in]  i_port:  identifies which port the given DRAM is on
    /// @param[in]  i_dram:  identifies which DRAM identifier is to be added
    /// @param[in/out]  io_scom_storage:  list of all DRAMs being modified by PDA. contains address, bit, and length
    /// @return FAPI2_RC_SUCCESS iff successful
    ///
    fapi2::ReturnCode mss_ddr4_add_dram_pda(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target, const uint8_t i_port,
                                            const uint8_t i_dram,
                                            vector<PDA_Scom_Storage>& io_scom_storage);

    ///
    /// @brief sets up the ODT holdtime and number of idles to be issued after
    /// @param[in]  i_target:  Reference to centaur.mba target,
    /// @param[out]  o_wl_launch_time:  holds the number of cycles that the data must be launched after the PDA command is issued
    /// @param[out]  o_odt_hold_time:  holds the number of cycles that the ODT must be held for PDA
    /// @param[out]  o_post_odt_nop_idle:  holds the number of cycles that
    /// @return FAPI2_RC_SUCCESS iff successful
    ///
    fapi2::ReturnCode mss_get_pda_odt_timings(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
            uint8_t& o_wl_launch_time,
            uint8_t& o_odt_hold_time, uint8_t& o_post_odt_nop_idle);

    ///
    /// @brief runs per-DRAM addressability funcitonality on both ports on the passed MBA by dimm and rank
    /// @param[in] i_target Centaur input mba
    /// @param[in] i_pda Vector of PDA_MRS_Storage class elements - initialized by the user and contains DRAM information and attribute override information
    /// @param[in] i_dimm Centaur dimm to run
    /// @param[in] i_rank Centaur rank to run
    /// @return FAPI2_RC_SUCCESS iff successful
    ///
    fapi2::ReturnCode mss_ddr4_run_pda_by_dimm_rank(
        const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target,
        vector<PDA_MRS_Storage> i_pda,
        const uint8_t i_dimm,
        const uint8_t i_rank
    );

    ///
    /// @brief returns a 1 if the PDA is empty for the given DIMM rank - returns 0 if not empty
    /// @param[in] i_pda
    /// @param[in] i_dimm
    /// @param[in] i_rank
    /// @return returns a 1 if the PDA is empty for the given DIMM rank - returns 0 if not empty
    ///
    uint32_t mss_ddr4_check_pda_empty_for_rank(
        vector<PDA_MRS_Storage> i_pda,
        const uint8_t i_dimm,
        const uint8_t i_rank
    );

} // extern "C"

#endif /* _MSS_DDR4_PDA_H */


OpenPOWER on IntegriCloud