summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/memory/p9_mss_volt.C
blob: fcaa3f3058521379fd0a41758322db38f87ef67a (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/memory/p9_mss_volt.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_mss_volt.C
/// @brief Calculate and save off rail voltages
///
// *HWP HWP Owner: Jacob Harvey <jlharvey@us.ibm.com>
// *HWP HWP Backup: Andre A. Marin  <aamarin@us.ibm.com>
// *HWP FW Owner: Brian Silver <bsilver@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 3
// *HWP Consumed by: FSP:HB

#include <p9_mss_volt.H>

// std lib
#include <vector>
#include <map>

// fapi2
#include <fapi2.H>

// mss lib
#include <lib/spd/spd_factory.H>
#include <lib/spd/common/spd_decoder.H>
#include <lib/eff_config/attr_setters.H>
#include <lib/utils/c_str.H>
#include <lib/utils/pos.H>
#include <lib/utils/find.H>
#include <lib/utils/checker.H>

using fapi2::TARGET_TYPE_MCBIST;
using fapi2::TARGET_TYPE_MCS;
using fapi2::TARGET_TYPE_MCA;
using fapi2::TARGET_TYPE_DIMM;
using fapi2::FAPI2_RC_SUCCESS;

extern "C"
{

    ///
    /// @brief Calculate and save off rail voltages
    /// @param[in] i_targets vector of controllers (e.g., MCS)
    /// @return FAPI2_RC_SUCCESS iff ok
    ///
    fapi2::ReturnCode p9_mss_volt( const std::vector< fapi2::Target<TARGET_TYPE_MCS> >& i_targets )
    {
        // Loop through MCS
        for (const auto& l_mcs : i_targets)
        {
            FAPI_INF("Populating decoder cache for %s", mss::c_str(l_mcs));

            //Factory cache is per MCS
            std::map<uint32_t, std::shared_ptr<mss::spd::decoder> > l_factory_caches;
            FAPI_TRY( mss::spd::populate_decoder_caches(l_mcs, l_factory_caches),
                      "Failed to populate decoder cache");

            // Get dimms for each MCS
            for ( const auto& l_dimm : mss::find_targets<TARGET_TYPE_DIMM> (l_mcs))
            {
                const auto l_dimm_pos = mss::pos(l_dimm);

                // Find decoder factory for this dimm position
                auto l_it = l_factory_caches.find(l_dimm_pos);
                // Check to make sure it's valid
                // TODO - RTC 152390 change factory check
                FAPI_TRY( mss::check::spd::invalid_cache(l_dimm,
                          l_it != l_factory_caches.end(),
                          l_dimm_pos),
                          "Failed to get valid cache");
                {
                    uint8_t l_dimm_nominal = 0;
                    uint8_t l_dimm_endurant = 0;

                    // Read nominal and endurant bits from SPD, 0 = 1.2V is not operable and endurant, 1 = 1.2 is valid
                    FAPI_TRY( l_it->second->operable_nominal_voltage(l_dimm, l_dimm_nominal));
                    FAPI_TRY( l_it->second->endurant_nominal_voltage(l_dimm, l_dimm_endurant));

                    //Check to make sure 1.2 V is both operable and endurant, fail if it is not
                    FAPI_ASSERT ( (l_dimm_nominal == mss::spd::OPERABLE) && (l_dimm_endurant == mss::spd::ENDURANT),
                                  fapi2::MSS_VOLT_DDR_TYPE_REQUIRED_VOLTAGE().
                                  set_OPERABLE(l_dimm_nominal).
                                  set_ENDURANT(l_dimm_endurant).
                                  set_DIMM_TARGET(l_dimm),
                                  "%s: DIMM is not operable (%d)"
                                  " and/or endurant (%d) at 1.2V",
                                  mss::c_str(l_dimm),
                                  l_dimm_nominal,
                                  l_dimm_endurant);
                } // scope
            } // l_dimm

            // Set the attributes for this MCS, values are in mss_const.H
            // TK : will need to change attribute target according to voltage rails in the future
            FAPI_TRY (mss::set_voltage_attributes (l_mcs,
                                                   mss::DDR4_NOMINAL_VOLTAGE,
                                                   mss::DDR4_VPP_VOLTAGE),
                      "Failed to set volt attributes");
        } // mcs

        FAPI_INF("End mss volt");
        return FAPI2_RC_SUCCESS;

    fapi_try_exit:
        return fapi2::current_err;
    } // p9_mss_volt
} //extern "C"
OpenPOWER on IntegriCloud