summaryrefslogtreecommitdiffstats
path: root/import/chips/p9/procedures/ppe_closed/cme/pstate_cme/p9_cme_pstate.h
blob: ef8daeedfaef99f3dd83ce8c3c17e04f501f46ab (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: import/chips/p9/procedures/ppe_closed/cme/pstate_cme/p9_cme_pstate.h $ */
/*                                                                        */
/* OpenPOWER HCODE Project                                                */
/*                                                                        */
/* 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                                                     */
//-----------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2014
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
//-----------------------------------------------------------------------------

/// \file pstate.h
/// \brief Shared and global definitions for pstate H codes.
/// \owner  Michael Olsen   Email: cmolsen@us.ibm.com
///

void pmcr_db0_thread(void*);

#define MAX_CORES               24
#define MAX_QUADS               6
#define MAX_CMES                12
#define CORES_PER_QUAD          (MAX_CORES/MAX_QUADS)
#define CORES_PER_CME           (MAX_CORES/MAX_CMES)
#define CMES_PER_QUAD           (MAX_CMES/MAX_QUADS)

#define QUAD_SCOM_ADDR_MASK     0x07000000
#define CME_SCOM_ADDR_MASK      0x00000C00
#define QUAD_CME_SCOM_ADDR_MASK_CLR ~(QUAD_SCOM_ADDR_MASK|CME_SCOM_ADDR_MASK)

#define QUAD_SCOM_ADDR_INCR     (uint32_t)0x01000000
#define CME_SCOM_ADDR_OFFSET    (uint32_t)0x00000400
#define CME_SCOM_ADDR_INCR      (uint32_t)0x00000400
#define CORE_SCOM_ADDR_OFFSET   (uint32_t)0x20000000
#define CORE_SCOM_ADDR_INCR     (uint32_t)0x01000000
#define CORE_SEL_LEFT           (uint32_t)0x00800000
#define CORE_SEL_RIGHT          (uint32_t)0x00400000

//#define TRUE                    1
//#define FALSE                   0

#define RIGHT_SHIFT_PTRN_0x8_32BIT  (uint32_t)0x80000000
#define RIGHT_SHIFT_PTRN_0xC_32BIT  (uint32_t)0xC0000000
#define RIGHT_SHIFT_PTRN_0xF_32BIT  (uint32_t)0xF0000000
#define RIGHT_SHIFT_PTRN_0x8_64BIT  (uint64_t)0x8000000000000000

//
// HOMER variables updated by PGPE
//
extern uint32_t    ULTRA_TURBO_FREQ_STEPS_PS;


#define VEXT_SLEW_RATE_MVPERUS  0x0A0A  // Trise=Tfall=10mv/us
#define MAX_POLL_COUNT_AVS      10
/*
// We define four levels of TRACE outputs:
// _INF:  Trace level used for main informational events.
// _DBG:  Trace level used for expanded debugging.
// _WARN: Trace level used when suspecious event happens.
// _ERR:  Trace level at time of an error that leads to a halt.
#define MY_TRACE_INF(...)   PK_TRACE("INF: "__VA_ARGS__);
#ifdef DEV_DEBUG
    #define MY_TRACE_DBG(...)   PK_TRACE("DBG: "__VA_ARGS__);
#else
    #define MY_TRACE_DBG(...)
#endif
#define MY_TRACE_WARN(...)  PK_TRACE("WARN: "__VA_ARGS__);
#define MY_TRACE_ERR(...)   PK_TRACE("ERR: "__VA_ARGS__);
*/

//
// PIR defines
//
#define PIR_INSTANCE_EVEN_ODD_MASK  (uint32_t)(0x00000001)
#define PIR_INSTANCE_NUM_MASK       (uint32_t)(0x0000001F)


//
// CME FLAGS defines
//
#define CME_FLAGS_STOP_READY    (uint32_t)(0x80000000)
#define CME_FLAGS_PMCR_READY    (uint32_t)(0x40000000)
#define CME_FLAGS_QMGR_READY    (uint32_t)(0x20000000)
#define CME_FLAGS_QMGR_MASTER   (uint32_t)(0x10000000)
#define CME_FLAGS_RCLK_READY    (uint32_t)(0x08000000)
#define CME_FLAGS_IVRM_READY    (uint32_t)(0x04000000)
#define CME_FLAGS_VDM_READY     (uint32_t)(0x02000000)


//
// Pstate defines
//
enum PSTATE_REQUEST_MODE_VALUES     // Partially supported in GA1
{
    PS_REQ_MODE_DEFAULT     = 0,
    PS_REQ_MODE_RELATIVE    = 1,
    PS_REQ_MODE_QOS         = 2,    // Only mode supported in GA1
    PS_REQ_MODE_PERFORMANCE = 3,
    PS_REQ_MODE_LAST        = 4
};

enum PSTATE_REQUEST_PRIORITY_VALUES // Not supported in GA1
{
    PS_REQ_PRTY_LOW         = 0,
    PS_REQ_PRTY_MEDIUM      = 1,
    PS_REQ_PRTY_HIGH        = 2,
    PS_REQ_PRTY_OVERRIDE    = 3,
    PS_REQ_PRTY_LAST        = 4
};

typedef union pmcr_pstate_request
{

    uint32_t value;
    struct
    {
#ifdef _BIG_ENDIAN
        uint32_t reserved1 : 6;
        uint32_t mode : 2;              // Partialy supported in GA1
        uint32_t ps_upper : 8;          // NOT supported in GA1
        uint32_t reserved2 : 6;
        uint32_t priority : 2;          // NOT supported in GA1
        uint32_t ps_lower : 8;          // Only Pstate supported in GA1
#else
        uint32_t ps_lower : 8;
        uint32_t priority : 2;
        uint32_t reserved2 : 6;
        uint32_t ps_upper : 8;
        uint32_t mode : 2;
        uint32_t reserved1 : 6;
#endif // _BIG_ENDIAN
    } fields;

} pmcr_pstate_request_t;

typedef struct pstate_actuation_results
{

    uint32_t  freq_quad_last[MAX_QUADS];
    uint32_t  freq_quad_avg[MAX_QUADS];
    uint32_t  freq_chip_last;
    uint32_t  freq_chip_avg;
    uint32_t  vdd_quad_last[MAX_QUADS];
    uint32_t  vdd_quad_avg[MAX_QUADS];
    uint32_t  vdd_chip_last;
    uint32_t  vdd_chip_avg;

} pstate_actuation_results_t;


//
// QCME<->PGPE API
//

enum MESSAGE_ID_DB0
{
    MSGID_DB0_INVALID       = 0,
    MSGID_DB0_RESUME        = 1,
    MSGID_DB0_SUSPEND       = 2,
    MSGID_DB0_RESET         = 3,
    MSGID_DB0_PS_BROADCAST  = 4,
    MSGID_DB0_ACK           = 5
};

enum MESSAGE_ID_DB3
{
    MSGID_DB3_INVALID       = 0,
    MSGID_DB3_SAFE_MODE     = 1,
    MSGID_DB3_PS_BROADCAST  = 2,
    MSGID_DB3_ACK           = 3
};

enum MESSAGE_ID_TYPE4
{
    MSGID_T4_INVALID        = 0,
    MSGID_T4_REGISTER_QCME  = 1,
    MSGID_T4_ACK            = 2
};

//-------------
// Doorbell0
//-------------

// PGPE->QCME:  cb_to_qcme_base
// ------------------------------------
// This CB to decode the msg_id.
//
typedef union comm_block_to_qcme_base
{
    uint64_t  value;
    struct
    {
#ifdef _BIG_ENDIAN
        uint64_t  msg_id : 8;
        uint64_t  reserved : 56;
#else
        uint64_t  reserved : 56;
        uint64_t  msg_id : 8;
#endif // _BIG_ENDIAN
    } fields;
} cb_to_qcme_base_t;

// PGPE->QCME:  cb_to_qcme_ps_bc
// ------------------------------------
// This CB is used by PGPE to broadcast Pstate requests.
//
typedef union comm_block_to_qcme_ps_bc
{
    uint64_t  value;
    struct
    {
#ifdef _BIG_ENDIAN
        uint64_t  msg_id : 8;
        uint64_t  ps_global : 8;
        uint64_t  ps_local : 8;
        uint64_t  reserved : 40;
#else
        uint64_t  reserved : 40;
        uint64_t  ps_local : 8;
        uint64_t  ps_global : 8;
        uint64_t  msg_id : 8;
#endif // _BIG_ENDIAN
    } fields;
} cb_to_qcme_ps_bc_t;

// PGPE->QCME:  cb_to_qcme_ack
// ---------------------------
// This CB is used by PGPE to acknowledge CME requests.
//
typedef union comm_block_to_qcme_ack
{
    uint64_t  value;
    struct
    {
#ifdef _BIG_ENDIAN
        uint64_t  msg_id : 8;
        uint64_t  msg_id_ref : 8;
        uint64_t  rc : 8;
        uint64_t  reserved : 40;
#else
        uint64_t  reserved : 40;
        uint64_t  rc : 8;
        uint64_t  msg_id_ref : 8;
        uint64_t  msg_id : 8;
#endif // _BIG_ENDIAN
    } fields;
} cb_to_qcme_ack_t;


//--------------
// Type4
//--------------

// QCME->PGPE:  cb_to_pgpe_base
// ----------------------------
// Used by PGPE to decode the msg_id.
//
typedef union comm_block_to_pgpe_base
{
    uint16_t  value;
    struct
    {
#ifdef _BIG_ENDIAN
        uint16_t  do_not_use : 4;
        uint16_t  msg_id : 3;
        uint16_t  reserved : 9;
#else
        uint16_t  reserved : 9;
        uint16_t  msg_id : 3;
        uint16_t  do_not_use : 4;
#endif // _BIG_ENDIAN
    } fields;
} cb_to_pgpe_base_t;

// QCME->PGPE:  cb_to_pgpe_qcme
// ----------------------------
// Used by QCME to register itself with the PGPE.
//
typedef union comm_block_to_pgpe_qcme
{
    uint16_t  value;
    struct
    {
#ifdef _BIG_ENDIAN
        uint16_t  do_not_use : 4;
        uint16_t  msg_id : 3;
        uint16_t  reserved : 9;
#else
        uint16_t  reserved : 9;
        uint16_t  msg_id : 3;
        uint16_t  do_not_use : 4;
#endif // _BIG_ENDIAN
    } fields;
} cb_to_pgpe_qcme_t;

// QCME->PGPE:  cb_to_pgpe_ack
// ---------------------------
// Used by QCME to acknowledge DB requests.
//
typedef union comm_block_to_pgpe_ack
{
    uint16_t  value;
    struct
    {
#ifdef _BIG_ENDIAN
        uint16_t  do_not_use : 4;
        uint16_t  msg_id : 3;
        uint16_t  msg_id_ref : 3; // Put msg_id from PGPE request
        uint16_t  reserved : 3;
        uint16_t  rc : 3;
#else
        uint16_t  rc : 3;
        uint16_t  reserved : 3;
        uint16_t  msg_id_ref : 3;
        uint16_t  msg_id : 3;
        uint16_t  do_not_use : 4;
#endif // _BIG_ENDIAN
    } fields;
} cb_to_pgpe_ack_t;

//
// Return Codes
//
enum API_RETURN_CODES
{
    API_RC_INVALID    =  0,   // Don't use zero. Not reliable.
    API_RC_SUCCESS    =  1,
    API_RC_FAILURE    =  2
};
OpenPOWER on IntegriCloud