summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/slave_sbe/proc_spless_sbe_startWA/proc_spless_sbe_startWA.C
blob: c02edc5ce393268afda692155dfcddf43f40f296 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/slave_sbe/proc_spless_sbe_startWA/proc_spless_sbe_startWA.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013,2014              */
/*                                                                        */
/* 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                                                     */
// -*- mode: C++; c-file-style: "linux";  -*-

// $Id: proc_spless_sbe_startWA.C,v 1.2 2013/08/14 20:44:47 jmcgill Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/proc_cen_ref_clk_enable.C,v $
//------------------------------------------------------------------------------
// *|
// *! (C) Copyright International Business Machines Corp. 2013
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
// *|
// *! TITLE       : proc_spless_sbe_startWA.C
// *! DESCRIPTION : Issue workaround for CFAM Reset SBE start (FAPI)
// *!
// *! OWNER  NAME  : Benedikt Geukes         Email: benedikt.geukes@de.ibm.com
// *! BACKUP NAME  : Ralph Koester           Email: rkoester@de.ibm.com
// *!
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include "proc_spless_sbe_startWA.H"
#include "p8_scom_addresses.H"
#include "p8_mailbox_utils.H"


//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------

extern "C"
{


//------------------------------------------------------------------------------
// Hardware Procedure
//------------------------------------------------------------------------------
// parameters: i_target            => chip target (S1/P8)
// returns:    FAPI_RC_SUCCESS if operation was successful, else error
//------------------------------------------------------------------------------
fapi::ReturnCode proc_spless_sbe_startWA(const fapi::Target & i_target)
{

    uint32_t           rc_ecmd = 0;
    fapi::ReturnCode   rc;
    uint32_t           l_set_data;
    ecmdDataBufferBase  set_data(32);
    uint8_t l_needSbeStartWA = 0;

    do {

        // ---- check if workaround is needed
        rc = FAPI_ATTR_GET(ATTR_CHIP_EC_FEATURE_CFAM_RESET_SBE_START_WA,
                           &i_target,
                           l_needSbeStartWA);
        if(rc)
        {
            FAPI_ERR("Error querying Chip EC feature: "
                     "ATTR_CHIP_EC_FEATURE_CFAM_RESET_SBE_START_WA");
            break;
        }

        if(!l_needSbeStartWA)
        {
            //Workaround not needed -- break
            break;
        }

        // -----------------------------------------------------------
        //Need to set the I2C speed based in the mailbox reg
        //Since not all 1.x part have the correctly programmed OTPROM
        rc = p8_mailbox_utils_get_mbox2( i_target, l_set_data );
        if (rc)
        {
            FAPI_ERR("ERROR: get_mbox2 = 0x%08x",
                     static_cast<uint32_t>(rc) );
            break;
        }

        rc_ecmd |= set_data.setWord( 0, l_set_data );

        FAPI_INF(   "Write 0x%08x to mbox scratch 2",
                    set_data.getWord(0)   );

        // write it to mbox scratch2
        rc = fapiPutCfamRegister( i_target,
                                  MBOX_SCRATCH_REG1_0x00002839,
                                  set_data    );
        if (rc)
        {
            FAPI_ERR("ERROR: write MBOX_SCRATCH_REG1_0x00002839= 0x%08x",
                     static_cast<uint32_t>(rc) );
            break;
        }

        // ------------------------------------------------
        // Now toggle Warmstart bit to circumvent HW254584
        // write it to mbox scratch2
        rc_ecmd |= set_data.setWord( 0, 0x10000000 );


        rc = fapiPutCfamRegister( i_target,
                                  CFAM_FSI_SBE_VITAL_0x0000281C,
                                  set_data    );
        if (rc)
        {
            FAPI_ERR("ERROR: write CFAM_FSI_SBE_VITAL_0x0000281C= 0x%08x",
                     static_cast<uint32_t>(rc) );
            break;
        }

        rc_ecmd |= set_data.setWord( 0, 0x90000000 );


        rc = fapiPutCfamRegister( i_target,
                                  CFAM_FSI_SBE_VITAL_0x0000281C,
                                  set_data    );
        if (rc)
        {
            FAPI_ERR("ERROR: write CFAM_FSI_SBE_VITAL_0x0000281C= 0x%08x",
                     static_cast<uint32_t>(rc) );
            break;
        }

        if(rc_ecmd)
        {
            FAPI_ERR( "Error (0x%08x) writing value to set_data",
                      rc_ecmd);
            rc.setEcmdError(rc_ecmd);
            break;
        }
    } while(0);  // end do

    // mark function exit
    FAPI_INF("proc_spless_sbe_startWA: Exit");
    return rc;
}  // end FAPI procedure proc_spless_sbe_startWA


} // extern "C"
OpenPOWER on IntegriCloud