summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/dram_initialization/proc_pcie_config/proc_pcie_config.C
blob: 7b1cd0ac48ed99f791b03aeecb64c24fdbfd9936 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/dram_initialization/proc_pcie_config/proc_pcie_config.C $ */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* 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: proc_pcie_config.C,v 1.4 2013/01/20 19:28:14 jmcgill Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/proc_pcie_config.C,v $
//------------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2012
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
//------------------------------------------------------------------------------
// *! TITLE       : proc_pcie_config.C
// *! DESCRIPTION : Perform PCIe PBCQ/AIB Inits (Phase 2, Steps 9-22) (FAPI)
// *!
// *! OWNER NAME  : Joe McGill        Email: jmcgill@us.ibm.com
// *!
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
//  Includes
//------------------------------------------------------------------------------
#include <fapiHwpExecInitFile.H>
#include "proc_pcie_config.H"

extern "C" {

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


//------------------------------------------------------------------------------
// function: apply PBCQ/AIB customization via SCOM initfile
// parameters: i_target => processor chip target
// returns: FAPI_RC_SUCCESS if initfile evaluation is successful,
//          else error
//------------------------------------------------------------------------------
fapi::ReturnCode proc_pcie_config_pbcq(
    const fapi::Target & i_target)
{
    fapi::ReturnCode rc;
    std::vector<fapi::Target> targets;

    // mark function entry
    FAPI_INF("proc_pcie_config_pbcq: Start");

    do
    {
        // execute Phase2 SCOM initfile
        targets.push_back(i_target);
        FAPI_INF("proc_pcie_config_pbcq: Executing %s on %s",
                 PROC_PCIE_CONFIG_PHASE2_IF, i_target.toEcmdString());
        FAPI_EXEC_HWP(
            rc,
            fapiHwpExecInitFile,
            targets,
            PROC_PCIE_CONFIG_PHASE2_IF);
        if (!rc.ok())
        {
            FAPI_ERR("proc_pcie_config_pbcq: Error from fapiHwpExecInitfile executing %s on %s",
                     PROC_PCIE_CONFIG_PHASE2_IF,
                     i_target.toEcmdString());
            break;
        }
    } while(0);

    // mark function exit
    FAPI_INF("proc_pcie_config_pbcq: End");
    return rc;
}


//------------------------------------------------------------------------------
// function: initialize PBCQ FIRs
//             clear FIR/WOF
//             initialize FIR action settings
//             reset FIR masks
// parameters: i_target => processor chip target
// returns: FAPI_RC_SUCCESS if all actions are successful,
//          else error
//------------------------------------------------------------------------------
fapi::ReturnCode proc_pcie_config_pbcq_fir(
    const fapi::Target & i_target)
{
    fapi::ReturnCode rc;

    ecmdDataBufferBase zero_data(64);

    // mark function entry
    FAPI_INF("proc_pcie_config_pbcq_fir: Start");

    // loop over all PHBs
    for (size_t i = 0; i < PROC_PCIE_CONFIG_NUM_PHB; i++)
    {
        // clear FIR
        rc = fapiPutScom(i_target,
                         PROC_PCIE_CONFIG_PCIE_NEST_FIR[i],
                         zero_data);
        if (!rc.ok())
        {
            FAPI_ERR("proc_pcie_config_pbcq_fir: Error from fapiPutScom (PCIE%d_FIR_0x%08X)",
                     i, PROC_PCIE_CONFIG_PCIE_NEST_FIR[i]);
            break;
        }

        // clear FIR WOF
        rc = fapiPutScom(i_target,
                         PROC_PCIE_CONFIG_PCIE_NEST_FIR_WOF[i],
                         zero_data);
        if (!rc.ok())
        {
            FAPI_ERR("proc_pcie_config_pbcq_fir: Error from fapiPutScom (PCIE%d_FIR_WOF_0x%08X)",
                     i, PROC_PCIE_CONFIG_PCIE_NEST_FIR_WOF[i]);
            break;
        }

        // clear FIR mask
        rc = fapiPutScom(i_target,
                         PROC_PCIE_CONFIG_PCIE_NEST_FIR_MASK[i],
                         zero_data);
        if (!rc.ok())
        {
            FAPI_ERR("proc_pcie_config_pbcq_fir: Error from fapiPutScom (PCIE%d_FIR_MASK_0x%08X)",
                     i, PROC_PCIE_CONFIG_PCIE_NEST_FIR_MASK[i]);
            break;
        }
    }

    // mark function exit
    FAPI_INF("proc_pcie_config_pbcq_fir: End");
    return rc;
}


// HWP entry point, comments in header
fapi::ReturnCode proc_pcie_config(
    const fapi::Target & i_target)
{
    fapi::ReturnCode rc;
    uint8_t pcie_enabled;

    // mark HWP entry
    FAPI_INF("proc_pcie_config: Start");

    do
    {
        // check for supported target type
        if (i_target.getType() != fapi::TARGET_TYPE_PROC_CHIP)
        {
            FAPI_ERR("proc_pcie_config: Unsupported target type");
            FAPI_SET_HWP_ERROR(rc, RC_PROC_PCIE_CONFIG_INVALID_TARGET);
            break;
        }

        // query PCIE partial good attribute
        rc = FAPI_ATTR_GET(ATTR_PROC_PCIE_ENABLE,
                           &i_target,
                           pcie_enabled);
        if (!rc.ok())
        {
            FAPI_ERR("proc_pcie_config: Error querying ATTR_PROC_PCIE_ENABLE");
            break;
        }

        // initialize PBCQ/AIB, configure PBCQ FIRs (only if partial good
        // atttribute is set)
        if (pcie_enabled == fapi::ENUM_ATTR_PROC_PCIE_ENABLE_ENABLE)
        {
            rc = proc_pcie_config_pbcq(i_target);
            if (!rc.ok())
            {
                FAPI_ERR("proc_pcie_config: Error from proc_pcie_config_pbcq");
                break;
            }

            rc = proc_pcie_config_pbcq_fir(i_target);
            if (!rc.ok())
            {
                FAPI_ERR("proc_pcie_config: Error from proc_pcie_config_pbcq_fir");
                break;
            }
        }
        else
        {
            FAPI_DBG("proc_pcie_scominit: Skipping initialization (partial good)");
        }

    } while(0);

    // mark HWP exit
    FAPI_INF("proc_pcie_config: End");
    return rc;
}


} // extern "C"
OpenPOWER on IntegriCloud