summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/pm/p9_pm_pba_firinit.C
blob: ff20e4d05490c180f95417d72f6caa96372c1a1f (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_pm_pba_firinit.C $   */
/*                                                                        */
/* 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 p9_pm_pba_firinit.C
/// @brief Configures the PBA LFIR, Mask and Action
///
// *HWP HWP Owner: Greg Still <stillgs@us.ibm.com>
// *HWP Backup HWP Owner : Amit Kumar <akumar3@us.ibm.com>
// *HWP FW  Owner: Sangeetha T S <sangeet2@in.ibm.com>
// *HWP Team: PM
// *HWP Level: 3
// *HWP Consumed by: HS
//

/// High-level procedure flow:
/// @verbatim
///   if reset:
///      Mask all bits of FIR
///   else if init:
///      Establish the respective mask/action bits for the following settings:
///          1) Checkstop
///          2) Malf Alert
///          3) Recoverable Attention
///          4) Recoverable Interrupt
///
/// @endverbatim
///
/// Procedure Prereq:
///   o System clocks are running

// ----------------------------------------------------------------------
// Includes
// ----------------------------------------------------------------------
#include <p9_pm_pba_firinit.H>

// ----------------------------------------------------------------------
// Constant definitions
// ----------------------------------------------------------------------

enum PBA_FIR_BITS
{
    PBAFIR_OCI_APAR_ERR,     // 0
    PBAFIR_PB_RDADRERR_FW,   // 1
    PBAFIR_PB_RDDATATO_FW,   // 2
    PBAFIR_PB_SUE_FW,        // 3
    PBAFIR_PB_UE_FW,         // 4
    PBAFIR_PB_CE_FW,         // 5
    PBAFIR_OCI_SLAVE_INIT,   // 6
    PBAFIR_OCI_WRPAR_ERR,    // 7
    PBAFIR_SPARE,            // 8
    PBAFIR_PB_UNEXPCRESP,    // 9
    PBAFIR_PB_UNEXPDATA,     // 10
    PBAFIR_PB_PARITY_ERR,    // 11
    PBAFIR_PB_WRADRERR_FW,   // 12
    PBAFIR_PB_BADCRESP,      // 13
    PBAFIR_PB_ACKDEAD_FW_RD, // 14
    PBAFIR_PB_CRESPTO,       // 15
    PBAFIR_BCUE_SETUP_ERR,   // 16
    PBAFIR_BCUE_PB_ACK_DEAD, // 17
    PBAFIR_BCUE_PB_ADRERR,   // 18
    PBAFIR_BCUE_OCI_DATERR,  // 19
    PBAFIR_BCDE_SETUP_ERR,   // 20
    PBAFIR_BCDE_PB_ACK_DEAD, // 21
    PBAFIR_BCDE_PB_ADRERR,   // 22
    PBAFIR_BCDE_RDDATATO_ERR,// 23
    PBAFIR_BCDE_SUE_ERR,     // 24
    PBAFIR_BCDE_UE_ERR,      // 25
    PBAFIR_BCDE_CE,          // 26
    PBAFIR_BCDE_OCI_DATERR,  // 27
    PBAFIR_INTERNAL_ERR,     // 28
    PBAFIR_ILLEGAL_CACHE_OP, // 29
    PBAFIR_OCI_BAD_REG_ADDR, // 30
    PBAFIR_AXPUSH_WRERR,     // 31
    PBAFIR_AXRCV_DLO_ERR,    // 32
    PBAFIR_AXRCV_DLO_TO,     // 33
    PBAFIR_AXRCV_RSVDATA_TO, // 34
    PBAFIR_AXFLOW_ERR,       // 35
    PBAFIR_AXSND_DHI_RTYTO,  // 36
    PBAFIR_AXSND_DLO_RTYTO,  // 37
    PBAFIR_AXSND_RSVTO,      // 38
    PBAFIR_AXSND_RSVERR,     // 39
    PBAFIR_PB_ACKDEAD_FW_WR, // 40
    PBAFIR_RESERVED_41,      // 41
    PBAFIR_RESERVED_42,      // 42
    PBAFIR_RESERVED_43,      // 43
    PBAFIR_FIR_PARITY_ERR2,  // 44
    PBAFIR_FIR_PARITY_ERR    // 45
};

// ----------------------------------------------------------------------
// Function prototypes
// ----------------------------------------------------------------------

fapi2::ReturnCode pm_pba_fir_reset(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target);

fapi2::ReturnCode pm_pba_fir_init(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target);

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

fapi2::ReturnCode p9_pm_pba_firinit(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
    const p9pm::PM_FLOW_MODE i_mode)
{
    FAPI_IMP("p9_pm_pba_firinit Enter");

    if(i_mode == p9pm::PM_RESET)
    {
        FAPI_TRY(pm_pba_fir_reset(i_target),
                 "ERROR: Failed to reset the PBA FIRs");
    }
    else if(i_mode == p9pm::PM_INIT)
    {
        FAPI_TRY(pm_pba_fir_init(i_target),
                 "ERROR: Failed to initialize the PBA FIRs");
    }
    else
    {
        FAPI_ASSERT(false, fapi2::PM_PBA_FIRINIT_BAD_MODE().set_BADMODE(i_mode),
                    "ERROR; Unknown mode passed to p9_pm_pba_firinit. Mode %x",
                    i_mode);
    }

fapi_try_exit:
    FAPI_IMP("p9_pm_pba_firinit Exit");
    return fapi2::current_err;
}

fapi2::ReturnCode pm_pba_fir_reset(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    FAPI_IMP("pm_pba_fir_reset Enter");

    uint8_t firinit_done_flag;
    p9pmFIR::PMFir <p9pmFIR::FIRTYPE_PBA_LFIR> l_pbaFir(i_target);

    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_PM_FIRINIT_DONE_ONCE_FLAG,
                           i_target, firinit_done_flag),
             "ERROR: Failed to fetch the entry status of FIRINIT");

    if (firinit_done_flag
        == fapi2::ENUM_ATTR_PM_FIRINIT_DONE_ONCE_FLAG_FIRS_INITED)
    {
        FAPI_TRY(l_pbaFir.get(p9pmFIR::REG_FIRMASK),
                 "ERROR: Failed to get the PBA FIR MASK value");
        /* Fetch the PBA FIR MASK; Save it to HWP attribute; clear it */
        FAPI_TRY(l_pbaFir.saveMask(),
                 "ERROR: Failed to save the PBA FIR Mask to the attribute");
    }

    FAPI_TRY(l_pbaFir.setAllRegBits(p9pmFIR::REG_FIRMASK),
             "ERROR: Faled to set the PBA FIR MASK");

    FAPI_TRY(l_pbaFir.put(),
             "ERROR:Failed to write to the PBA FIR MASK");

fapi_try_exit:
    return fapi2::current_err;
}

fapi2::ReturnCode pm_pba_fir_init(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    FAPI_IMP("pm_pba_fir_init Enter");

    uint8_t firinit_done_flag;
    p9pmFIR::PMFir <p9pmFIR::FIRTYPE_PBA_LFIR> l_pbaFir(i_target);

    FAPI_TRY(l_pbaFir.get(p9pmFIR::REG_ALL),
             "ERROR: Failed to get the PBA FIR values");

    /* Clear the FIR and action buffers */
    FAPI_TRY(l_pbaFir.clearAllRegBits(p9pmFIR::REG_FIR),
             "ERROR: Failed to clear PBA FIR");
    FAPI_TRY(l_pbaFir.clearAllRegBits(p9pmFIR::REG_ACTION0),
             "ERROR: Failed to clear PBA FIR");
    FAPI_TRY(l_pbaFir.clearAllRegBits(p9pmFIR::REG_ACTION1),
             "ERROR: Failed to clear PBA FIR");
    FAPI_TRY(l_pbaFir.setAllRegBits(p9pmFIR::REG_FIRMASK),
             "ERROR: Faled to set the PBA FIR MASK");

    /*  Set the action and mask for the PBA LFIR bits */
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_OCI_APAR_ERR),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_PB_RDADRERR_FW),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_PB_RDDATATO_FW),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_PB_SUE_FW),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_PB_UE_FW),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_PB_CE_FW),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_OCI_SLAVE_INIT),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_OCI_WRPAR_ERR),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_SPARE),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_PB_UNEXPCRESP),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_PB_UNEXPDATA),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_PB_PARITY_ERR),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_PB_WRADRERR_FW),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_PB_BADCRESP),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_PB_ACKDEAD_FW_RD),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_PB_CRESPTO),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCUE_SETUP_ERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCUE_PB_ACK_DEAD),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCUE_PB_ADRERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCUE_OCI_DATERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCDE_SETUP_ERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCDE_PB_ACK_DEAD),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCDE_PB_ADRERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCDE_RDDATATO_ERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCDE_SUE_ERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCDE_UE_ERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCDE_CE),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_BCDE_OCI_DATERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_INTERNAL_ERR),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_ILLEGAL_CACHE_OP),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.setRecvAttn(PBAFIR_OCI_BAD_REG_ADDR),
             FIR_REC_ATTN_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXPUSH_WRERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXRCV_DLO_ERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXRCV_DLO_TO),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXRCV_RSVDATA_TO),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXFLOW_ERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXSND_DHI_RTYTO),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXSND_DLO_RTYTO),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXSND_RSVTO),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_AXSND_RSVERR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_PB_ACKDEAD_FW_WR),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_RESERVED_41),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_RESERVED_42),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_RESERVED_43),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_FIR_PARITY_ERR2),
             FIR_MASK_ERROR);
    FAPI_TRY(l_pbaFir.mask(PBAFIR_FIR_PARITY_ERR),
             FIR_MASK_ERROR);

    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_PM_FIRINIT_DONE_ONCE_FLAG,
                           i_target, firinit_done_flag),
             "ERROR: Failed to fetch the entry status of FIRINIT");

    FAPI_DBG("firinit_done_flag for PBA = %d", firinit_done_flag);

    if (firinit_done_flag)
    {
        FAPI_TRY(l_pbaFir.restoreSavedMask(),
                 "ERROR: Failed to restore the mask saved");
    }

    FAPI_TRY(l_pbaFir.put(),
             "ERROR:Failed to write to the PBA FIR MASK");

fapi_try_exit:
    return fapi2::current_err;
}
OpenPOWER on IntegriCloud