summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C
blob: 9dc8d134c7f9c07ffdedefd1b9b3bb91e145d26a (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] 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_scominit.C
/// @brief SCOM inits for PHY, MC
///
// *HWP HWP Owner: Louis Stermole <stermole@us.ibm.com>
// *HWP HWP Backup: Andre Marin <aamarin@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 3
// *HWP Consumed by: FSP:HB

#include <lib/shared/nimbus_defaults.H>
#include <fapi2.H>
#include <p9_mss_scominit.H>
#include <p9n_mca_scom.H>
#include <p9n_mcbist_scom.H>
#include <p9n_ddrphy_scom.H>
#include <generic/memory/lib/utils/count_dimm.H>
#include <lib/utils/nimbus_find.H>
#include <lib/phy/ddr_phy.H>
#include <lib/mc/mc.H>
#include <lib/fir/unmask.H>
#include <lib/utils/find_magic.H>

using fapi2::TARGET_TYPE_MCA;
using fapi2::TARGET_TYPE_MCBIST;
using fapi2::FAPI2_RC_SUCCESS;

///
/// @brief SCOM inits for PHY, MC
/// @param[in] i_target, the MCBIST
/// @return FAPI2_RC_SUCCESS iff ok
///
fapi2::ReturnCode p9_mss_scominit( const fapi2::Target<TARGET_TYPE_MCBIST>& i_target )
{
    FAPI_INF("Start MSS SCOM init");

    // We need to make sure we scominit the magic port.
    const auto l_mca_targets = mss::find_targets_with_magic<TARGET_TYPE_MCA>(i_target);

    fapi2::ReturnCode l_rc;
    fapi2::Target<fapi2::TARGET_TYPE_SYSTEM> FAPI_SYSTEM;

    if (mss::count_dimm(i_target) == 0)
    {
        FAPI_INF("... skipping mss_scominit %s - no DIMM ...", mss::c_str(i_target));
        return fapi2::FAPI2_RC_SUCCESS;
    }

    for (const auto& l_mca_target : l_mca_targets )
    {
        FAPI_INF("scominit for %s", mss::c_str(l_mca_target));

        // Can't MCA init ports with no DIMM, they don't have attributes like timing.
        if (mss::count_dimm(l_mca_target) != 0)
        {
            FAPI_INF("mca scominit for %s", mss::c_str(l_mca_target));
            FAPI_EXEC_HWP(l_rc, p9n_mca_scom, l_mca_target, i_target, l_mca_target.getParent<fapi2::TARGET_TYPE_MCS>(),
                          FAPI_SYSTEM, i_target.getParent<fapi2::TARGET_TYPE_PROC_CHIP>());

            if (l_rc)
            {
                FAPI_ERR("%s Error from p9.mca.scom.initfile", mss::c_str(l_mca_target));
                fapi2::current_err = l_rc;
                goto fapi_try_exit;
            }

            FAPI_INF("mca thermal throttle scominit for %s", mss::c_str(l_mca_target));
            FAPI_TRY(mss::mc::thermal_throttle_scominit(l_mca_target));
        }

        // ... but we do scominit PHY's with no DIMM. There are no attributes needed and we need
        // to make sure we init the magic port.
        FAPI_INF("phy scominit for %s", mss::c_str(l_mca_target));
        FAPI_EXEC_HWP(l_rc, p9n_ddrphy_scom, l_mca_target, i_target.getParent<fapi2::TARGET_TYPE_PROC_CHIP>());

        if (l_rc)
        {
            FAPI_ERR("%s Error from p9.ddrphy.scom.initfile", mss::c_str(l_mca_target));
            fapi2::current_err = l_rc;
            goto fapi_try_exit;
        }
    }

    FAPI_EXEC_HWP(l_rc, p9n_mcbist_scom, i_target );

    if (l_rc)
    {
        FAPI_ERR("%s Error from p9.mcbist.scom.initfile", mss::c_str(i_target));
        fapi2::current_err = l_rc;
        goto fapi_try_exit;
    }

    // Initialize via scoms for non-static PHY items.
    FAPI_TRY( mss::phy_scominit(i_target), "%s failed phy_scominit", mss::c_str(i_target) );

    // Do FIRry things
    FAPI_TRY( mss::unmask::after_scominit(i_target), "%s failed after_scominit",
              mss::c_str(i_target) );

fapi_try_exit:
    FAPI_INF("%s End MSS SCOM init ReturnCode:0x%016lx", mss::c_str(i_target), uint64_t(fapi2::current_err));
    return fapi2::current_err;
}
OpenPOWER on IntegriCloud