summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/nest_chiplets/proc_a_x_pci_dmi_pll_setup/proc_a_x_pci_dmi_pll_setup.C
blob: e6b6e605095eb0241843a3a59fa48fb504d9e18c (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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/nest_chiplets/proc_a_x_pci_dmi_pll_setup/proc_a_x_pci_dmi_pll_setup.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* 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                                                     */
// $Id: proc_a_x_pci_dmi_pll_setup.C,v 1.15 2014/04/02 14:02:33 jmcgill Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/proc_a_x_pci_dmi_pll_setup.C,v $
//------------------------------------------------------------------------------
// *|
// *! (C) Copyright International Business Machines Corp. 2012
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
// *|
// *! TITLE       : proc_a_x_pci_dmi_pll_setup.C
// *! DESCRIPTION : Initialize and lock A/X/PCI/DMI PLLs
// *!
// *! OWNER NAME  : Ralph Koester            Email: rkoester@de.ibm.com
// *!
// *! The purpose of this procedure is to initialize (remove from reset/bypass)
// *! and lock the X/A/PCIE/DMI PLLs
// *!
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <p8_scom_addresses.H>
#include <proc_a_x_pci_dmi_pll_setup.H>
#include <proc_a_x_pci_dmi_pll_utils.H>



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

const uint64_t GENERIC_PCB_CONFIG_0x000F001E = 0x000F001EULL;


//------------------------------------------------------------------------------
// Function definition
//------------------------------------------------------------------------------

extern "C"
{

//------------------------------------------------------------------------------
// function:
//      Clear and unmask chiplet PLL lock indication
//
// parameters: i_target                 => chip target
//             i_chiplet_base_scom_addr => aligned base address of chiplet SCOM
//                                         address space
// returns: FAPI_RC_SUCCESS if operation was successful, else error
//------------------------------------------------------------------------------
fapi::ReturnCode proc_a_x_pci_dmi_pll_setup_unmask_lock(const fapi::Target & i_target,
                                                        const uint32_t i_chiplet_base_scom_addr)
{
    // return codes
    fapi::ReturnCode rc;
    uint32_t rc_ecmd = 0;

    // data buffer to hold register values
    ecmdDataBufferBase data(64);

    do
    {
        rc = fapiGetScom(i_target,
                         i_chiplet_base_scom_addr | GENERIC_PCB_ERR_0x000F001F,
                         data);
        if (!rc.ok())
        {
            FAPI_ERR("Error reading PCB Slave PLL Lock Indication");
            break;
        }
        
        rc_ecmd |= data.setBit(25);  // set bit to clear previous lock errors 
        rc_ecmd |= data.setBit(26);  // set bit to clear previous lock errors 
        rc_ecmd |= data.setBit(27);  // set bit to clear previous lock errors
        rc_ecmd |= data.setBit(28);  // set bit to clear previous lock errors
        
        if (rc_ecmd)
        {
        	FAPI_ERR("Error (0x%x) setting up PLL Lock Indication ecmdDataBufferBase", rc_ecmd);
        	rc.setEcmdError(rc_ecmd);
        	break;		
        }
        
        FAPI_INF("Clearing PCB Slave Lock Indication Bit 25,26,27,28");
        rc = fapiPutScom(i_target,
                         i_chiplet_base_scom_addr | GENERIC_PCB_ERR_0x000F001F,
                         data);
        if (!rc.ok())
        {
            FAPI_ERR("Error writing PCB Slave PLL Lock Indication");
            break;
        }
        
        rc = fapiGetScom(i_target,
                         i_chiplet_base_scom_addr | GENERIC_PCB_CONFIG_0x000F001E,
                         data);
        if (!rc.ok())
        {
           FAPI_ERR("Error reading PCB Slave PLL Lock Mask");
           break;
        }
        
        rc_ecmd |= data.clearBit(12);  // set bit to clear PLL Lock Mask 
        
        if (rc_ecmd)
        {
        	FAPI_ERR("Error (0x%x) setting up PLL Lock Mask ecmdDataBufferBase", rc_ecmd);
        	rc.setEcmdError(rc_ecmd);
        	break;		
        }
        
        FAPI_INF("Clearing PCB Slave Lock Mask Bit 12");
        rc = fapiPutScom(i_target, 
                         i_chiplet_base_scom_addr | GENERIC_PCB_CONFIG_0x000F001E,
                         data);
        if (!rc.ok())
        {
           FAPI_ERR("Error writing PCB Slave Lock Mask");
           break;
        }
    } while(0);

    return rc;
}


//------------------------------------------------------------------------------
// function:
//      Initialize and lock A/X/PCI/DMI PLLs
//
// parameters: i_target       =>   chip target
//             i_startX       =>   True to start X BUS PLL, else false
//             i_startA       =>   True to start A BUS PLL, else false
//             i_startPCIE    =>   True to start PCIE PLL, else false
//             i_startDMI     =>   True to start DMI PLL, else false
// returns: FAPI_RC_SUCCESS if operation was successful, else error
//------------------------------------------------------------------------------
    fapi::ReturnCode proc_a_x_pci_dmi_pll_setup(const fapi::Target & i_target,
                                     const bool i_startX,
                                     const bool i_startA,
                                     const bool i_startPCIE,
                                     const bool i_startDMI)
    {
        // data buffer to hold register values
        ecmdDataBufferBase gp_data(64);
		ecmdDataBufferBase scom_data(64);
	

        // return codes
        fapi::ReturnCode rc;
		
        // locals
        uint8_t pcie_enable_attr;
        uint8_t abus_enable_attr;

        // mark function entry
        FAPI_INF("Entry1, start_XBUS=%s\n, Entry2, start_ABUS=%s\n, Entry3, start_PCIE=%s\n, Entry4, start_DMI=%s \n" ,
                 i_startX? "true":"false",
                 i_startA? "true":"false",
                 i_startPCIE? "true":"false",
                 i_startDMI? "true":"false");

        do
        {
            //------------//
            // X Bus PLL  //
            //------------//
            if (!i_startX)
            {
                FAPI_DBG("X BUS PLL not selected for setup in this routine.");
            }
            else
            {
                FAPI_INF("This routine does not do X-BUS PLL setup at this time!.");
                FAPI_INF("It is assumed that the X-BUS PLL is already set up in synchronous mode for use with the NEST logic.");

                rc = proc_a_x_pci_dmi_pll_setup_unmask_lock(
                    i_target,
                    TP_CHIPLET_0x01000000);
                if (!rc.ok())
                {
                    FAPI_ERR("Error from proc_a_x_pci_dmi_pll_setup_unmask_lock");
                    break;
                }
            }
            // end X-bus PLL setup



            //------------//
            // A Bus PLL  //
            //------------//

            // query ABUS partial good attribute
            rc = FAPI_ATTR_GET(ATTR_PROC_A_ENABLE,
                               &i_target,
                               abus_enable_attr);
            if (!rc.ok())
            {
                FAPI_ERR("Error querying ATTR_PROC_A_ENABLE");
                break;
            }

            if (!i_startA)
            {
                FAPI_DBG("A BUS PLL not selected for setup in this routine.");
            }
            else if (abus_enable_attr != fapi::ENUM_ATTR_PROC_A_ENABLE_ENABLE)
            {
                FAPI_DBG("A BUS PLL setup skipped (partial good).");
            }
            else
            {
                FAPI_DBG("Starting PLL setup for A BUS PLL ...");
                rc = proc_a_x_pci_dmi_pll_release_pll(
                        i_target,
                        A_BUS_CHIPLET_0x08000000,
                        true);
                if (!rc.ok())
                {
                    FAPI_ERR("Error from proc_a_x_pci_dmi_pll_release_pll");
                    break;
                }

                rc = proc_a_x_pci_dmi_pll_setup_unmask_lock(
                    i_target,
                    A_BUS_CHIPLET_0x08000000);
                if (!rc.ok())
                {
                    FAPI_ERR("Error from proc_a_x_pci_dmi_pll_setup_unmask_lock");
                    break;
                }

                FAPI_INF("Done setting up A-Bus PLL. ");
            }  // end A PLL


            //----------//
            // DMI PLL  //
            //----------//
            if (!i_startDMI)
            {
                FAPI_DBG("DMI PLL not selected for setup in this routine.");
            }
            else
            {
                FAPI_DBG("Starting PLL setup for DMI PLL ...");
                rc = proc_a_x_pci_dmi_pll_release_pll(
                        i_target,
                        NEST_CHIPLET_0x02000000,
                        true);
                if (!rc.ok())
                {
                    FAPI_ERR("Error from proc_a_x_pci_dmi_pll_release_pll");
                    break;
                }
                rc = proc_a_x_pci_dmi_pll_setup_unmask_lock(
                    i_target,
                    NEST_CHIPLET_0x02000000);
                if (!rc.ok())
                {
                    FAPI_ERR("Error from proc_a_x_pci_dmi_pll_setup_unmask_lock");
                    break;
                }

                FAPI_INF("Done setting up DMI PLL. ");
            }  // end DMI PLL


            //-----------//
            // PCIE PLL  //
            //-----------//

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

            if (!i_startPCIE)
            {
                FAPI_DBG("PCIE PLL not selected for setup in this routine.");
            }
            else if (pcie_enable_attr != fapi::ENUM_ATTR_PROC_PCIE_ENABLE_ENABLE)
            {
                FAPI_DBG("PCIE PLL setup skipped (partial good).");
            }
            else
            {
                FAPI_DBG("Starting PLL setup for PCIE PLL ...");
                rc = proc_a_x_pci_dmi_pll_release_pll(
                        i_target,
                        PCIE_CHIPLET_0x09000000,
                        true);
                if (!rc.ok())
                {
                    FAPI_ERR("Error from proc_a_x_pci_dmi_pll_release_pll");
                    break;
                }

//TODO: Temporarily undo this unmask for Brazos until Joe McGill fixes SW255565 
//                rc = proc_a_x_pci_dmi_pll_setup_unmask_lock(
//                    i_target,
//                    PCIE_CHIPLET_0x09000000);
//                if (!rc.ok())
//                {
//                    FAPI_ERR("Error from proc_a_x_pci_dmi_pll_setup_unmask_lock");
//                    break;
//                }

                FAPI_INF("Done setting up PCIE PLL. ");

            }  // end PCIE PLL

        } while (0); // end do

        // mark function exit
        FAPI_INF("Exit");
        return rc;
    }  // end FAPI procedure proc_a_x_pci_dmi_pll_setup

} // extern "C"

/*
*************** Do not edit this area ***************
This section is automatically updated by CVS when you check in this file.
Be sure to create CVS comments when you commit so that they can be included here.
$Log: proc_a_x_pci_dmi_pll_setup.C,v $
Revision 1.15  2014/04/02 14:02:33  jmcgill
respect function input parameters/partial good in unlock error clear/unmask logic (SW252901)

Revision 1.14  2014/03/28 15:25:39  bgeukes
updates for SW252901 after RAS review

Revision 1.13  2014/03/27 17:58:08  bgeukes
fix for the scominit updates

Revision 1.12  2014/01/07 14:43:34  mfred
Checking in updates from Andrea Ma:  Include statements fixed and one fapi dbg statement changed.

Revision 1.11  2013/04/17 22:38:42  jmcgill
implement A/DMI PLL workaround for SW194943, reorganize code to use common subroutines for PLL scan/setup

Revision 1.10  2013/01/25 19:30:22  mfred
Release PLLs from bypass before checking for PLL lock.  Also, check for two lock bits on DMI PLL to support Venice.

Revision 1.9  2013/01/20 19:22:44  jmcgill
update for A chiplet partial good support

Revision 1.8  2013/01/10 14:40:13  jmcgill
add partial good support

Revision 1.7  2012/08/14 18:32:45  mfred
Changed input parms from bool & to const bool.

Revision 1.6  2012/08/14 14:18:06  mfred
Separating proc_a_x_pci_dmi_pll_setup into two hwp.  And update code to use real scanning instead of sim cheats.


*/

OpenPOWER on IntegriCloud