summaryrefslogtreecommitdiffstats
path: root/src/lib/gpsm.h
blob: 5af2e8d586934904d47b95ad283256050ebeb5c6 (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
#ifndef __GPSM_H__
#define __GPSM_H__

// $Id: gpsm.h,v 1.2 2014/02/03 01:30:24 daviddu Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/lib/gpsm.h,v $
//-----------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2013
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
//-----------------------------------------------------------------------------

/// \file gpsm.h
/// \brief PgP Global Pstate Machine (Mechanism)

#include "ssx.h"
#include "gpe_control.h"
#include "pgp_async.h"
#include "pstates.h"

// GPSM modes

#define GPSM_MODE_HW          1
#define GPSM_MODE_FW_AUCTION  2
#define GPSM_MODE_FW          3

// Misc./Error/Panic codes

#define GPSM_INVALID_OBJECT                0x00477601
#define GPSM_INVALID_ARGUMENT_GPST_INSTALL 0x00477602
#define GPSM_INVALID_ARGUMENT_LPST_INSTALL 0x00477603
#define GPSM_INVALID_ARGUMENT_RCLK_INSTALL 0x00477604
#define GPSM_INVALID_ARGUMENT_EPSS         0x00477605
#define GPSM_ILLEGAL_MODE_HW_QUIESCE       0x00477606
#define GPSM_ILLEGAL_MODE_BGA              0x00477607
#define GPSM_ILLEGAL_MODE_GPST_INSTALL     0x00477608
#define GPSM_ILLEGAL_MODE_LPST_INSTALL     0x00477609
#define GPSM_ILLEGAL_MODE_RCLK_INSTALL     0x0047760a
#define GPSM_ILLEGAL_MODE_GPSM_INIT        0x0047760b
#define GPSM_ILLEGAL_MODE_EPSM             0x0047760c
#define GPSM_ILLEGAL_MODE_EPSS             0x0047760d
#define GPSM_SYNC_ERROR                    0x0047760e
#define GPSM_PSTATE_CLIPPED                0x0047760f
#define GPSM_BUG                           0x00477610
#define GPSM_CONFIGURATION_ERROR           0x00477611
#define GPSM_ERROR_BREAK                   0x00477612
#define GPSM_INVALID_MAGIC                 0x00477613
#define GPSM_IVRM_CALIBRATION_TIMEOUT      0x00477614
#define GPSM_IVRM_GROSS_OR_FINE            0x00477615
#define GPSM_PSTATE_ENABLED                0x00477616
#define GPSM_BABYSTEPPER_SYNC_TIMEOUT      0x00477617
#ifndef __ASSEMBLER__

// Lab/VBU/VPO debugging

#if 0
#include "trace.h"
#define TRACE_GPSM(i_code) trace_tbl_bbbb(1, i_code, 0, 0, 0);
#define TRACE_GPSM_B(i_code, i_b0) trace_tbl_bbbb(1, i_code, i_b0, 0, 0);
#define TRACE_GPSM_H(i_code, i_h0) trace_tbl_bbh(1, i_code, 0, i_h0);
#else
#define TRACE_GPSM(i_code)
#define TRACE_GPSM_B(i_code, i_b0)
#define TRACE_GPSM_H(i_code, i_h0)
#endif


/// Information required by an SCM or a DCM master to be passed from
/// gpsm_enable_pstates_master() to gpsm_enable_pstates_slave().

typedef struct {

    /// Indicates whether or not gpsm_enable_pstates_slave() should move the
    /// voltage. 
    ///
    /// If 0, it means that the master has already moved the voltage and only
    /// the frequency needs to move.  If 1, voltage is moved after frequency
    /// moves. 
    int move_voltage;

    /// The current and target external voltage settings as VRM11 VID codes.
    Vid11 currentVdd, currentVcs, targetVdd, targetVcs;

} GpsmEnablePstatesMasterInfo;


/// A GpsmAuctionProcedure is any function of no arguments that returns a
/// Pstate

typedef Pstate (*GpsmAuctionProcedure)();

extern SsxSemaphore G_gpsm_protocol_semaphore;

extern uint8_t G_gpsm_initialized;

// APIs defined in gpsm_init.c

int
gpsm_gpst_install(GlobalPstateTable* o_gpst,
                  const GlobalPstateTable* i_source);

int
gpsm_lpsa_install(const LocalPstateArray* i_lpsa,
                  const PstateOptions* i_options);

int
gpsm_resclk_install(const ResonantClockingSetup* i_resclk,
                    const GlobalPstateTable* i_gpst,
                    const PstateOptions* i_options);

int
gpsm_initialize(const PstateSuperStructure* i_pss, 
                GlobalPstateTable* o_gpst);

int
gpsm_enable_pstates_master(GpsmEnablePstatesMasterInfo* o_info,
                           Pstate* o_voltage_pstate,
                           Pstate* o_frequency_pstate);

int
gpsm_enable_pstates_slave(const GpsmEnablePstatesMasterInfo* i_info,
                          const Pstate i_voltage_pstate,
                          const Pstate i_frequency_pstate);

// APIs defined in gpsm.c

int
gpsm_quiesced_p(void);

int
gpsm_hw_mode_p(void);

int
gpsm_fw_auction_mode_p(void);

int
gpsm_fw_mode_p(void);

int
gpsm_dcm_mode_p(void);

int
gpsm_dcm_master_p(void);

int
gpsm_dcm_slave_p(void);

GlobalPstateTable*
gpsm_gpst();

int
gpsm_quiesce(void);

int
_gpsm_hw_quiesce(void);

int
gpsm_fw_mode(void);

int
gpsm_fw_auction_mode(void);

int
gpsm_hw_mode(void);

Pstate
gpsm_default_auction(void);

void
gpsm_get_global_bids(Pstate* o_bids);

void
gpsm_set_global_bids(const Pstate* i_bids);

void
_gpsm_broadcast_global_actual(const Pstate i_pstate, 
                              const gpst_entry_t i_entry);

int
gpsm_broadcast_global_actual(const GlobalPstateTable *i_gpst, 
                             const Pstate i_pstate, 
                             const int i_bias);

int
gpsm_set_pstate(const Pstate i_pstate);

int
gpsm_hold_auction(const GpsmAuctionProcedure i_procedure);

#endif  /* __ASSEMBLER__ */

#endif  /* __GPSM_H__ */
OpenPOWER on IntegriCloud