summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/pm/p9_pm_pfet_control.C
blob: 2712beb9a5627f8b312e553b4702f3890e26f384 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_pm_pfet_control.C $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2017                        */
/* [+] 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_pfet_control.C
/// @brief Enable PFET devices to power on/off all enabled Core and Cache
/// chiplets in target passed.
///
//----------------------------------------------------------------------------
// *HWP HWP Owner       : Greg Still <stillgs@us.ibm.com>
// *HWP FW Owner        : Sumit Kumar <sumit_kumar@in.ibm.com>
// *HWP Team            : PM
// *HWP Level           : 3
// *HWP Consumed by     : OCC:CME:FSP
//----------------------------------------------------------------------------
//
// @verbatim
// High-level procedure flow:
// PFET Control
// Power-on via Hardare FSM:
// ------------------------
// VDD first, VCS second
// Read PFETCNTLSTAT_REG and check for bits 0:3 being 0b0000.
// Write PFETCNTLSTAT_REG with values defined below
// -vdd_pfet_force_state = 11 (Force Von)
// -vdd_pfet_val_override = 0 (Override disabled)
// -vdd_pfet_sel_override = 0 (Override disabled)
// -vdd_pfet_enable_regulation_finger = 0 (Regulation finger controlled by FSM)
// Poll for PFETCNTLSTAT_REG[VDD_PG_STATE] for 0b1000 (FSM idle)-Timeout value = 1ms
// (Optional) Check PFETCNTLSTAT_REG[VDD_PG_SEL]being 0x8 (Off encode point)
// Write PFETCNTLSTAT_REG_WCLEAR
// -vdd_pfet_force_state = 00 (No Operation);all fields set to 1 for WAND
// Write PFETCNTLSTAT_REG_OR with values defined below
// -vcs_pfet_force_state = 11 (Force Von)
// Write to PFETCNTLSTAT_REG_CLR
// -vcs_pfet_val_override = 0 (Override disabled)
// -vcs_pfet_sel_override = 0 (Override disabled)
// Note there is no vcs_pfet_enable_regulation_finger
// Poll for PFETCNTLSTAT_REG[VCS_PG_STATE] for 0b1000 (FSM idle)-Timeout value = 1ms
// (Optional) Check PFETCNTLSTAT_REG[VCS_PG_SEL] being 0x8 (Off encode point)
// Write PFETCNTLSTAT_REG_WCLEAR
// -vcs_pfet_force_state = 00 (No Operation);all fields set to 1 for WAND
//
// Power-off via Hardare FSM:
// -------------------------
// VCS first, VDD second
// Read PFETCNTLSTAT_REG and check for bits 0:3 being 0b0000.
// Write PFETCNTLSTAT_REG with values defined below
// -vcs_pfet_force_state = 01 (Force Voff)
// -vcs_pfet_val_override = 0 (Override disabled)
// -vcs_pfet_sel_override = 0 (Override disabled)
// Note there is no vcs_pfet_enable_regulation_finger
// Poll for PFETCNTLSTAT_REG[VCS_PG_STATE] for 0b1000 (FSM idle)-Timeout value = 1ms
// (Optional) Check PFETCNTLSTAT_REG[VCS_PG_SEL]being 0x8 (Off encode point)
// Write PFETCNTLSTAT_REG_WCLEAR
// -vcs_pfet_force_state = 00 (No Operation);all fields set to 1 for WAND
// Write PFETCNTLSTAT_REG_OR with values defined below
// -vdd_pfet_force_state = 01 (Force Voff)
// Write to PFETCNTLSTAT_REG_CLR
// -vdd_pfet_val_override = 0 (Override disabled)
// -vdd_pfet_sel_override = 0 (Override disabled)
// -vdd_pfet_enable_regulation_finger = 0 (Regulation finger controlled by FSM)
// Poll for PFETCNTLSTAT_REG[VDD_PG_STATE] for 0b1000 (FSM idle)-Timeout value = 1ms
// (Optional) Check PFETCNTLSTAT_REG[VDD_PG_SEL] being 0x8 (Off encode point)
// Write PFETCNTLSTAT_REG_WCLEAR
// -vdd_pfet_force_state = 00 (No Operation);all fields set to 1 for WAND
//
// NOTE:
// For EQ supports: VDD,VCS,BOTH
// For EC & EX supports: VDD only. VCS returns an error. BOTH reports a warning that only VDD was controlled.
// EX target only powers OFF the two cores associated with that 'half' of the quad.
//
// Procedure Prereq:
//    - System clocks are running
//
// @endverbatim
//------------------------------------------------------------------------------

// ----------------------------------------------------------------------
// Includes
// ----------------------------------------------------------------------
#include <p9_common_poweronoff.H>
#include <p9_pm_pfet_control.H>

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

//------------------------------------------------------------------------------
// Global variables
//------------------------------------------------------------------------------

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

///
/// @brief Enable power on/off for core and cache chiplets
///
/// @param [in]  i_target          Target type Core/EQ/Ex chiplet
/// @param [in]  i_rail            Valid rail options:BOTH/VDD/VCS
/// @param [in]  i_op              Valid options:OFF/ON
///
/// @return FAPI2_RC_SUCCESS on success, error otherwise.
///
template <fapi2::TargetType K >
static fapi2::ReturnCode pfet_ctrl(
    const fapi2::Target< K >&  i_target,
    const PM_PFET_TYPE_C::pfet_rail_t  i_rail,
    const PM_PFET_TYPE_C::pfet_force_t i_op);


// Procedure pfet control-EQ entry point, comments in header
fapi2::ReturnCode p9_pm_pfet_control_eq(
    const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target,
    const PM_PFET_TYPE_C::pfet_rail_t  i_rail,
    const PM_PFET_TYPE_C::pfet_force_t i_op)
{
    fapi2::current_err     = fapi2::FAPI2_RC_SUCCESS;
    bool core_target_found = false;

    FAPI_INF("p9_pm_pfet_control_eq: Entering...");

    // Print chiplet position
    FAPI_INF("pfet control for EQ chiplet %d", i_target.getChipletNumber());

    // When i_op == OFF all functional cores first followed by EQ
    // When i_op == ON EQ first followed by all functional cores
    if(i_op == PM_PFET_TYPE_C::ON)
    {
        FAPI_TRY(pfet_ctrl<fapi2::TargetType::TARGET_TYPE_EQ>(i_target,
                 i_rail, i_op), "Error: pfet_ctrl for eq!!");
    }

    // Check for all core chiplets in EQ and power on/off targets accordingly
    for (auto& l_core_target : i_target.getChildren<fapi2::TARGET_TYPE_CORE>
         (fapi2::TARGET_STATE_FUNCTIONAL))
    {
        FAPI_INF("Core chiplet %d in EQ", l_core_target.getChipletNumber());
        FAPI_TRY(pfet_ctrl<fapi2::TargetType::TARGET_TYPE_CORE>(l_core_target,
                 i_rail, i_op), "Error: pfet_ctrl for core!!");
        core_target_found = true;
    }

    // Power on/off EQ target
    if( (i_op == PM_PFET_TYPE_C::OFF) && (core_target_found) )
    {
        FAPI_TRY(pfet_ctrl<fapi2::TargetType::TARGET_TYPE_EQ>(i_target,
                 i_rail, i_op), "Error: pfet_ctrl for eq!!");
    }
    else if( ((i_op == PM_PFET_TYPE_C::ON) && !(core_target_found)) ||
             ((i_op == PM_PFET_TYPE_C::OFF) && !(core_target_found)) )
    {
        FAPI_INF("EQ chiplet no. %d; No core target found in functional state in this EQ\n", i_target.getChipletNumber());
    }

    FAPI_INF("p9_pm_pfet_control_eq: ...Exiting");

fapi_try_exit:
    return fapi2::current_err;
} //p9_pm_pfet_control_eq


// Procedure pfet control-EX entry point, comments in header
fapi2::ReturnCode p9_pm_pfet_control_ex(
    const fapi2::Target<fapi2::TARGET_TYPE_EX>& i_target,
    const PM_PFET_TYPE_C::pfet_rail_t  i_rail,
    const PM_PFET_TYPE_C::pfet_force_t i_op)
{
    fapi2::current_err     = fapi2::FAPI2_RC_SUCCESS;
    bool core_target_found = false;

    FAPI_INF("p9_pm_pfet_control_ex: Entering...");

    // Get chiplet position
    FAPI_INF("pfet control for EX chiplet %d", i_target.getChipletNumber());

    // Check for all core chiplets in EX and power on/off targets accordingly
    for (auto& l_core_target : i_target.getChildren<fapi2::TARGET_TYPE_CORE>
         (fapi2::TARGET_STATE_FUNCTIONAL))
    {
        FAPI_INF("Core chiplet %d in EX", l_core_target.getChipletNumber());
        FAPI_TRY(pfet_ctrl<fapi2::TargetType::TARGET_TYPE_CORE>(l_core_target,
                 i_rail, i_op), "Error: pfet_ctrl for core!!");
        core_target_found = true;
    }

    // When no functional chiplet target found
    if(!core_target_found)
    {
        FAPI_INF("EX chiplet no. %d; No core target found in functional state"
                 " in this EX", i_target.getChipletNumber());
    }

    FAPI_INF("p9_pm_pfet_control_ex: ...Exiting");

fapi_try_exit:
    return fapi2::current_err;
} //p9_pm_pfet_control_ex


// Procedure pfet control-Core entry point, comments in header
fapi2::ReturnCode p9_pm_pfet_control_ec(
    const fapi2::Target<fapi2::TARGET_TYPE_CORE>& i_target,
    const PM_PFET_TYPE_C::pfet_rail_t  i_rail,
    const PM_PFET_TYPE_C::pfet_force_t i_op)
{
    fapi2::current_err = fapi2::FAPI2_RC_SUCCESS;

    FAPI_INF("p9_pm_pfet_control_core: Entering...");

    FAPI_TRY(pfet_ctrl<fapi2::TargetType::TARGET_TYPE_CORE>(i_target,
             i_rail, i_op), "Error: pfet_ctrl for core!!");

    FAPI_INF("p9_pm_pfet_control_core: ...Exiting");

fapi_try_exit:
    return fapi2::current_err;
} //p9_pm_pfet_control_ec


//------------------------------------------------------------------------------
// pfet_ctrl:
//  Function to power on/off core and cache chiplets
//------------------------------------------------------------------------------
template <fapi2::TargetType K >
fapi2::ReturnCode pfet_ctrl(
    const fapi2::Target< K >&  i_target,
    const PM_PFET_TYPE_C::pfet_rail_t  i_rail,
    const PM_PFET_TYPE_C::pfet_force_t i_op)
{
    fapi2::current_err = fapi2::FAPI2_RC_SUCCESS;

    FAPI_INF("pfet_ctrl: Entering...");

    // Check for target passed
    if(i_target.getType() & fapi2::TARGET_TYPE_CORE)
    {
        FAPI_INF("pfet control for Core chiplet %d",
                 i_target.getChipletNumber());
    }
    else if(i_target.getType() & fapi2::TARGET_TYPE_EQ)
    {
        FAPI_INF("pfet control for EQ chiplet %d", i_target.getChipletNumber());
    }
    else
    {
        // Invalid chiplet selected
        FAPI_ASSERT(false,
                    fapi2::PFET_CTRL_INVALID_CHIPLET_ERROR()
                    .set_TARGET(i_target),
                    "ERROR: Invalid chiplet selected");
    }

    switch(i_op)
    {
        case PM_PFET_TYPE_C::OFF:
            switch(i_rail)
            {
                case PM_PFET_TYPE_C::BOTH:
                    if(i_target.getType() & fapi2::TARGET_TYPE_EQ)
                    {
                        FAPI_TRY(p9_common_poweronoff(i_target, p9power::POWER_OFF));
                    }
                    else
                    {
                        FAPI_IMP("WARNING:Only VDD (not BOTH/VCS) is controlled for target Core & EX");
                        FAPI_TRY(p9_common_poweronoff(i_target, p9power::POWER_OFF_VDD));
                    }

                    break;

                case PM_PFET_TYPE_C::VDD:
                    FAPI_TRY(p9_common_poweronoff(i_target, p9power::POWER_OFF_VDD));
                    break;

                case PM_PFET_TYPE_C::VCS:
                    FAPI_IMP("WARNING:Only VDD or both VDD/VCS controlled for target Core/EX & Cache respectively");
                    break;
            }

            break;

        case PM_PFET_TYPE_C::ON:
            switch(i_rail)
            {
                case PM_PFET_TYPE_C::BOTH:
                    if(i_target.getType() & fapi2::TARGET_TYPE_EQ)
                    {
                        FAPI_TRY(p9_common_poweronoff(i_target, p9power::POWER_ON));
                    }
                    else
                    {
                        FAPI_IMP("WARNING:Only VDD (not BOTH/VCS) is controlled for target Core & EX");
                        FAPI_TRY(p9_common_poweronoff(i_target, p9power::POWER_ON_VDD));
                    }

                    break;

                case PM_PFET_TYPE_C::VDD:
                    FAPI_TRY(p9_common_poweronoff(i_target, p9power::POWER_ON_VDD));
                    break;

                case PM_PFET_TYPE_C::VCS:
                    FAPI_IMP("WARNING:Only VDD or both VDD/VCS controlled for target Core/EX & Cache respectively");
                    break;
            }

            break;
    }

fapi_try_exit:
    return fapi2::current_err;
}


OpenPOWER on IntegriCloud