summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/hbToHwsvVoltageMsg.H
blob: 0f7e9704cb0a04ed892fab1a120a0dc5a8b7ebb2 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/hbToHwsvVoltageMsg.H $                         */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2012,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                                                     */

#ifndef __HB_VOLT_MSG_H
#define __HB_VOLT_MSG_H

/*****************************************************************************/
// I n c l u d e s
/*****************************************************************************/
#include <sys/task.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mm.h>
#include <sys/msg.h>
#include <sys/sync.h>
#include <stdint.h>

#include <util/singleton.H>
#include <errl/errlentry.H>
#include <kernel/timemgr.H>
#include <hbotcompid.H>
#include <hwas/common/hwasCallout.H>
#include <mbox/mbox_queues.H>
#include <mbox/mboxif.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
#include <isteps/hwpf_reasoncodes.H>
#include <attributeenums.H>

/*****************************************************************************/
// Forward class declarations
/*****************************************************************************/
class HBToHwsvVoltageMsg;

/**
 *  @brief  HBToHwsvVoltageMsg
 *  This class provides interfaces to send and process messages to and from
 *  hwsv with respect to powr.  It also indicates when to stop the IPL via
 *  errorlogs
 */
class HBToHwsvVoltageMsg
{

public:

    /**
     *  @brief Enum specifying a memory voltage domain type
     */
    enum VOLTAGE_DOMAIN
    {
        // For unknown / uninitialized values
        VOLTAGE_DOMAIN_UNKNOWN = 0x00,

        // Valid values
        VOLTAGE_DOMAIN_MEM_VDD       = 0x01,
        VOLTAGE_DOMAIN_MEM_AVDD      = 0x02,
        VOLTAGE_DOMAIN_MEM_VCS       = 0x03,
        VOLTAGE_DOMAIN_MEM_VPP       = 0x04,
        VOLTAGE_DOMAIN_MEM_VDDR      = 0x05,  // aka VMEM
        VOLTAGE_DOMAIN_NEST_VDD      = 0x06,
        VOLTAGE_DOMAIN_NEST_VDN      = 0x07,
        VOLTAGE_DOMAIN_NEST_VCS      = 0x08,
        VOLTAGE_DOMAIN_NEST_VIO      = 0x09,
        VOLTAGE_DOMAIN_NEST_VDDR     = 0x0A,

        // Good range markers - Need to be adjusted if the above change
        VOLTAGE_DOMAIN_MIN_VALUE = VOLTAGE_DOMAIN_MEM_VDD,
        VOLTAGE_DOMAIN_MAX_VALUE = VOLTAGE_DOMAIN_NEST_VDDR,
    };

    /**
     * @brief Identifies hwsvPowrMemVoltDomainRequest_t as a DEFAULT voltage
     *        request if voltageMillivolts is set to this constant
     *
     */
    const uint32_t VOLTAGE_SETTING_ALERT_DEFAULT  = 0xFFFFFFFF;

    /**
     *  @struct hwsvPowrMemVoltDomainRequest_t
     *
     *  @brief Structure containing a memory voltage domain type, ID, and
     *      voltage in mV
     */
    struct hwsvPowrMemVoltDomainRequest_t
    {
        VOLTAGE_DOMAIN      domain;
        uint16_t            domainId;
        uint32_t            voltageMillivolts;

        hwsvPowrMemVoltDomainRequest_t()
            : domain(VOLTAGE_DOMAIN_UNKNOWN),
              domainId(0x0000),
              voltageMillivolts(0x00000000)
        {
        }

    } __attribute__ ((packed));

    /**
     *  @struct hwsvPowrMemVoltDomainReply_t
     *
     *  @brief Structure containing a memory voltage domain type, ID, and error
     *      log PLID as returned by the FSP POWR function when it tried to set
     *      the implied voltage regulator to the specified voltage.
     */
    struct hwsvPowrMemVoltDomainReply_t
    {
        VOLTAGE_DOMAIN        domain;
        uint16_t              domainId;
        uint32_t              plid;

        hwsvPowrMemVoltDomainReply_t()
            : domain(VOLTAGE_DOMAIN_UNKNOWN),
              domainId(0x0000),
              plid(0x00000000)
        {
        }

    } __attribute__ ((packed));

    /**
     * @enum VOLT_MSG_TYPE
     *
     * @brief  Message enum to determine how the msg should be processed
     *
     */
    enum VOLT_MSG_TYPE
    {
        HB_VOLT_ENABLE = 0x40000041,
        HB_VOLT_DISABLE = 0x40000042,
        HB_VOLT_POST_DRAM_INIT_ENABLE = 0x40000043,
    };

    /**
     * @brief typedefs for containers for structures
     */
    typedef std::vector<hwsvPowrMemVoltDomainReply_t> ResponseContainer;
    typedef std::vector<hwsvPowrMemVoltDomainRequest_t> RequestContainer;

    /**
     * @brief Default constructor
     */
    HBToHwsvVoltageMsg();

    /**
     * @brief   Destructor
     *
     * Releases all resources owned by the handle.
     *
     * @return  None
     *
     */
    ~HBToHwsvVoltageMsg();

    /**
     *  @brief Accumulates memory voltage domain type/ID/voltage records and
     *      appends them to the provided container
     *
     *  @par Detailed Description:
     *      This function will accumulates memory voltage domain type/ID/voltage
     *      records and appends them to the provided container.  If an "enable"
     *      request, adds records from all memory voltage domains.  If a
     *      "disable" message, only adds records from the VDDR (a.k.a. VMEM)
     *      voltage domain.
     *
     *  @param[in] i_requestType
     *      Type of data accumulation request
     *
     *  @param[in/out] io_request
     *      On input, a container to hold the memory voltage domain programming
     *      records.  On output, the container holds the relevant records.
     *
     *  @return N/A
     */
    void createVddrData(
              VOLT_MSG_TYPE     i_requestType,
              RequestContainer& io_request) const;

    /**
      *  @brief  Uses the internal mailbox to send a message to the FSP
      *
      *
      *  @par Detailed Description:
      *          This function will call into mailbox FSP code using the
      *          FSP_VDDR_MSGQ as the message queue..
      *
      *  @param[in] i_msgType
      *             HBToHwsvVoltageMsg::VDDR_MSG_TYPE passed in to define the
      *             message policy.
      *
      *  @return     errlHndl_t
      *              return errl ==  NULL  -> success
      *              return errl !=  NULL  -> failure
     */
    errlHndl_t sendMsg(VOLT_MSG_TYPE i_msgType) const;


    /**
     * @brief Appropriately formats the request data and sends it to the FSP
     *
     * @param[in]     i_requests - A vector of requests
     * @param[in]     i_msgType - the type of message we are sending
     *
     * @ return errlHndl_t
     *          return errl == NULL  -> success
     *          return errl != NULL  -> failure
     */
    errlHndl_t sendRequestData( RequestContainer & i_requests,
                                VOLT_MSG_TYPE i_msgType ) const;



private:

    /**
     *  @brief For a given mcbist and memory voltage domain, adds a
     *      voltage programming request record to the input list
     *
     *  @tparam MSS_DOMAIN_PROGRAM
     *      ID of the attribute to read to determine how we program this domain.
     *      Value of the attribute should be one of these:
     *      MSS_PROGRAM_TYPE::POWERON_TYPE = no add'l programming necessary,
     *      MSS_PROGRAM_TYPE::STATIC_TYPE  = use static value,
     *      MSS_PROGRAM_TYPE::DYNAMIC_TYPE = use dynamic value,
     *      MSS_PROGRAM_TYPE::DEFAULT_TYPE = send special alert value
     *
     *  @tparam VOLTAGE_ATTR_STATIC
     *      ID of the attribute which should be read to obtain the given memory
     *      voltage domain's offset voltage to program.  In this case the offset
     *      voltage acts as the actual voltage.  Should be one of the
     *      TARGETING::ATTR_MSS_VOLT_*_MILLIVOLTS attribute IDs, where
     *      * = VMEM, VPP, VCS, VDD, or AVDD.  Only used when the memory voltage
     *      domain's programming equals static.  Otherwise the parameter, below,
     *      controls how the voltage, if any, is programmed.
     *
     *  @tparam VOLTAGE_ATTR_DYNAMIC
     *      ID of the attribute which should be read to obtain the given memory
     *      voltage domain's voltage to program.  Only applied if the memory
     *      voltage domain's programming equals dynamic. Should be one of the
     *      TARGETING::ATTR_MSS_VOLT_*_OFFSET_MILLIVOLTS attribute IDs,
     *      where * = VMEM, VPP, VCS, VDD, or AVDD.
     *
     *  @note: This function does not ensure that all permutations of the above
     *    template parameters are valid.
     *
     *  @param[in] i_pMcbist
     *      Handle to a MCBIST target.  Function will assert if NULL or
     *      not a MCBIST target.
     *
     *  @param[in,out] io_domains
     *      On input, an existing list of 0 or more voltage domain records.  On
     *      output, that same list with up to 1 additional voltage domain
     *      record.
     *
     *  @return N/A
     */
    template<
        const TARGETING::ATTRIBUTE_ID MSS_DOMAIN_PROGRAM,
        const TARGETING::ATTRIBUTE_ID VOLTAGE_ATTR_STATIC,
        const TARGETING::ATTRIBUTE_ID VOLTAGE_ATTR_DYNAMIC,
        const TARGETING::ATTRIBUTE_ID VOLTAGE_DOMAIN_ID_ATTR >
    void addMemoryVoltageDomains(
        const TARGETING::Target* const     i_pMcbist,
              HBToHwsvVoltageMsg::RequestContainer& io_domains) const;

protected:

     /**
     * @brief function to process a generic message recieved from the FSP
     *
     * @param[in] i_recvMsg The message from the message queue.
     *               It contains the response data from the FSP
     *
     * @return     errlHndl_t
     *              return errl ==  NULL  -> success
     *              return errl !=  NULL  -> failure
     */
    errlHndl_t processMsg(msg_t* i_recvMsg) const;

     /**
     * @brief function to process a power Vmem message recieved from the FSP
     *
     * @param[in] i_recvMsg The message from the message queue.
     *               It contains the response data from the FSP
     *
     * @param[out] i_passed indicates if powr function succeeded or failed on
     *    the FSP.
     *
     * @return     errlHndl_t
     *              return errl ==  NULL  -> success
     *              return errl !=  NULL  -> failure
     */
    errlHndl_t processVOLTmsg(msg_t* i_recvMsg)const;

     /**
     * @brief function to create error logs for errors that occured in FSP side
     *
     * @param[in/out] io_err.  Error log to generate indicating that an error
     *     has has occured on HB or in the powr messages.  This error
     *     should stop the IPL from processing further.
     *
     * @param[in] i_mod. The module where the error occured
     *
     * @param[in] i_rc. The return code for the error that occured
     *
     * @return     None
     */
    void createErrLog(errlHndl_t& io_err,
                      fapi::hwpfModuleId i_mod,
                      fapi::hwpfReasonCode i_rc,
                      uint32_t i_userData1=0x0) const;


};

//External Interfaces
/**
 * @brief Send processor voltage rail data to HWSV
 * @return NULL | error handle on error
 */
errlHndl_t platform_set_nest_voltages();

#endif
OpenPOWER on IntegriCloud