summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/edi_ei_initialization/proc_fab_iovalid/proc_fab_iovalid.C
blob: 32bd122a168dbe95f26e1e92ad3923495801f6d6 (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
/*  IBM_PROLOG_BEGIN_TAG
 *  This is an automatically generated prolog.
 *
 *  $Source: src/usr/hwpf/hwp/edi_ei_initialization/proc_fab_iovalid/proc_fab_iovalid.C $
 *
 *  IBM CONFIDENTIAL
 *
 *  COPYRIGHT International Business Machines Corp. 2012
 *
 *  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 other-
 *  wise divested of its trade secrets, irrespective of what has
 *  been deposited with the U.S. Copyright Office.
 *
 *  Origin: 30
 *
 *  IBM_PROLOG_END_TAG
 */
// $Id: proc_fab_iovalid.C,v 1.8 2012/07/23 14:15:51 jmcgill Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/proc_fab_iovalid.C,v $
//------------------------------------------------------------------------------
// *|
// *! (C) Copyright International Business Machines Corp. 2011
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
// *|
// *! TITLE       : proc_fab_iovalid.C
// *! DESCRIPTION : Manage X/A link iovalid controls (FAPI)
// *!
// *! OWNER NAME  : Joe McGill              Email: jmcgill@us.ibm.com
// *!
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include "p8_scom_addresses.H"
#include "proc_fab_iovalid.H"

extern "C"
{

//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
// function: utility subroutine which writes chiplet GP0 register to
//           set/clear desired iovalid bits
// parameters: i_target            => chip target
//             i_active_link_mask  => bit mask defining active links to act on
//             i_set_not_clear     => define desired operation
//                                    (true=set, false=clear)
//             i_gp0_and_mask_addr => SCOM address for chiplet GP0 AND
//                                    mask register
//             i_gp0_or_mask_addr  => SCOM address for chiplet GP0 OR
//                                    mask register
// returns: FAPI_RC_SUCCESS if operation was successful, else error
//------------------------------------------------------------------------------
fapi::ReturnCode proc_fab_iovalid_write_gp0_mask(
    const fapi::Target& i_target,
    ecmdDataBufferBase& i_active_link_mask,
    bool i_set_not_clear,
    const uint32_t& i_gp0_and_mask_addr,
    const uint32_t& i_gp0_or_mask_addr)
{
    // data buffer to hold final iovalid bit mask
    ecmdDataBufferBase mask(64);

    // return codes
    uint32_t rc_ecmd = 0;
    fapi::ReturnCode rc;

    // mark function entry
    FAPI_DBG("proc_fab_iovalid_write_gp0_mask: Start");

    do
    {
        // copy input mask
        rc_ecmd = i_active_link_mask.copy(mask);
        // form final mask based on desired operation (set/clear)
        if (!i_set_not_clear)
        {
            FAPI_DBG("proc_fab_iovalid_write_gp0_mask: Inverting active link mask");
            rc_ecmd |= mask.invert();
        }

        // check return code from buffer manipulation operations
        rc.setEcmdError(rc_ecmd);
        if (!rc.ok())
        {
            FAPI_ERR("proc_fab_iovalid_write_gp0_mask: Error 0x%x setting up iovalid mask data buffer",
                     rc_ecmd);
            break;
        }

        // write GP0 register (use OR mask address for set operation,
        // AND mask address for clear operation)
        rc = fapiPutScom(i_target,
                         i_set_not_clear?i_gp0_or_mask_addr:i_gp0_and_mask_addr,
                         mask);
        if (!rc.ok())
        {
            FAPI_ERR("proc_fab_iovalid_write_gp0_mask: fapiPutScom error (GP0 Register 0x%08X)",
                     i_set_not_clear?i_gp0_or_mask_addr:i_gp0_and_mask_addr);
            break;
        }

    } while (0);

    // mark function exit
    FAPI_DBG("proc_fab_iovalid_write_gp0_mask: End");
    return rc;
}


//------------------------------------------------------------------------------
// function: utility subroutine to set/clear X bus iovalid bits on one chip
// parameters: i_proc_chip     => structure providing:
//                                o target for this chip
//                                o X busses to act on
//             i_set_not_clear => define desired operation (true=set,
//                                false=clear)
// returns: FAPI_RC_SUCCESS if operation was successful, else error
//------------------------------------------------------------------------------
fapi::ReturnCode proc_fab_iovalid_manage_x_links(
    proc_fab_iovalid_proc_chip& i_proc_chip,
    bool i_set_not_clear)
{
    // data buffer to hold iovalid bit mask
    ecmdDataBufferBase active_link_mask(64);

    // return codes
    uint32_t rc_ecmd = 0;
    fapi::ReturnCode rc;

    // mark function entry
    FAPI_DBG("proc_fab_iovalid_manage_x_links: Start");

    do
    {
        // set mask bit for each link to act on
        if (i_proc_chip.x0 ||
            i_proc_chip.x1 ||
            i_proc_chip.x2 ||
            i_proc_chip.x3)
        {
            if (i_proc_chip.x0)
            {
                FAPI_DBG("proc_fab_iovalid_manage_x_links: Adding link X0 to active link mask");
                rc_ecmd |= active_link_mask.setBit(X_GP0_X0_IOVALID_BIT);
            }
            if (i_proc_chip.x1)
            {
                FAPI_DBG("proc_fab_iovalid_manage_x_links: Adding link X1 to active link mask");
                rc_ecmd |= active_link_mask.setBit(X_GP0_X1_IOVALID_BIT);
            }
            if (i_proc_chip.x2)
            {
                FAPI_DBG("proc_fab_iovalid_manage_x_links: Adding link X2 to active link mask");
                rc_ecmd |= active_link_mask.setBit(X_GP0_X2_IOVALID_BIT);
            }
            if (i_proc_chip.x3)
            {
                FAPI_DBG("proc_fab_iovalid_manage_x_links: Adding link X3 to active link mask");
                rc_ecmd |= active_link_mask.setBit(X_GP0_X3_IOVALID_BIT);
            }

            // check aggregate return code from buffer manipulation operations
            rc.setEcmdError(rc_ecmd);
            if (!rc.ok())
            {
                FAPI_ERR("proc_fab_iovalid_manage_x_links: Error 0x%x setting up active link mask data buffer",
                         rc_ecmd);
                break;
            }

            // write appropriate GP0 mask register to perform desired operation
            rc = proc_fab_iovalid_write_gp0_mask(i_proc_chip.this_chip,
                                                 active_link_mask,
                                                 i_set_not_clear,
                                                 X_GP0_AND_0x04000004,
                                                 X_GP0_OR_0x04000005);
            if (!rc.ok())
            {
                FAPI_ERR("proc_fab_iovalid_manage_x_links: Error from proc_fab_iovalid_write_gp0_mask");
                break;
            }
        }
    } while(0);

    // mark function exit
    FAPI_DBG("proc_fab_iovalid_manage_x_links: End");
    return rc;
}


//------------------------------------------------------------------------------
// function: utility subroutine to set/clear A bus iovalid bits on one chip
// parameters: i_proc_chip     => structure providing:
//                                o target for this chip
//                                o A busses to act on
//             i_set_not_clear => define desired operation (true=set,
//                                false=clear)
// returns: FAPI_RC_SUCCESS if operation was successful, else error
//------------------------------------------------------------------------------
fapi::ReturnCode proc_fab_iovalid_manage_a_links(
    proc_fab_iovalid_proc_chip& i_proc_chip,
    bool i_set_not_clear)
{
    // data buffer to hold iovalid bit mask
    ecmdDataBufferBase active_link_mask(64);

    // return codes
    uint32_t rc_ecmd = 0;
    fapi::ReturnCode rc;

    // mark function entry
    FAPI_DBG("proc_fab_iovalid_manage_a_links: Start");

    do
    {
        // set mask bit for each link to act on
        if (i_proc_chip.a0 ||
            i_proc_chip.a1 ||
            i_proc_chip.a2)
        {
            if (i_proc_chip.a0)
            {
                FAPI_DBG("proc_fab_iovalid_manage_a_links: Adding link A0 to active link mask");
                rc_ecmd |= active_link_mask.setBit(A_GP0_A0_IOVALID_BIT);
            }
            if (i_proc_chip.a1)
            {
                FAPI_DBG("proc_fab_iovalid_manage_a_links: Adding link A1 to active link mask");
                rc_ecmd |= active_link_mask.setBit(A_GP0_A1_IOVALID_BIT);
            }
            if (i_proc_chip.a2)
            {
                FAPI_DBG("proc_fab_iovalid_manage_a_links: Adding link A2 to active link mask");
                rc_ecmd |= active_link_mask.setBit(A_GP0_A2_IOVALID_BIT);
            }

            // check aggregate return code from buffer manipulation operations
            rc.setEcmdError(rc_ecmd);
            if (!rc.ok())
            {
                FAPI_ERR("proc_fab_iovalid_manage_a_links: Error 0x%x setting up active link mask data buffer",
                         rc_ecmd);
                break;
            }

            // write appropriate GP0 mask register to perform desired operation
            rc = proc_fab_iovalid_write_gp0_mask(i_proc_chip.this_chip,
                                                 active_link_mask,
                                                 i_set_not_clear,
                                                 A_GP0_AND_0x08000004,
                                                 A_GP0_OR_0x08000005);
            if (!rc.ok())
            {
                FAPI_ERR("proc_fab_iovalid_manage_a_links: Error from proc_fab_iovalid_write_gp0_mask");
                break;
            }
        }
    } while(0);

    // mark function exit
    FAPI_DBG("proc_fab_iovalid_manage_a_links: End");
    return rc;
}


//------------------------------------------------------------------------------
// HWP entry point
//------------------------------------------------------------------------------
fapi::ReturnCode proc_fab_iovalid(
    std::vector<proc_fab_iovalid_proc_chip>& i_proc_chips,
    bool i_set_not_clear)
{
    // return code
    fapi::ReturnCode rc;
    // iterator for HWP input vector
    std::vector<proc_fab_iovalid_proc_chip>::iterator iter;

    // mark HWP entry
    FAPI_IMP("proc_fab_iovalid: Entering ...");

    do
    {
        // loop over all chips in input vector
        for (iter = i_proc_chips.begin();
             iter != i_proc_chips.end();
             iter++)
        {
            rc = proc_fab_iovalid_manage_x_links(*iter, i_set_not_clear);
            if (!rc.ok())
            {
                FAPI_ERR("proc_fab_iovalid: Error from proc_fab_iovalid_manage_x_links");
                break;
            }

            rc = proc_fab_iovalid_manage_a_links(*iter, i_set_not_clear);
            if (!rc.ok())
            {
                FAPI_ERR("proc_fab_iovalid: Error from proc_fab_iovalid_manage_a_links");
                break;
            }
        }
    } while(0);

    // log function exit
    FAPI_IMP("proc_fab_iovalid: Exiting ...");
    return rc;
}

} // extern "C"
OpenPOWER on IntegriCloud