summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/bus_training/io_clear_firs.C
blob: a34f347bc096489f1e255389b0e231d4e09bed48 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/bus_training/io_clear_firs.C $               */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013                   */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
// $Id: io_clear_firs.C,v 1.9 2013/03/26 14:45:18 jaswamin Exp $
// *!***************************************************************************
// *! (C) Copyright International Business Machines Corp. 2012, 2013
// *!           All Rights Reserved -- Property of IBM
// *!                   *** IBM Confidential ***
// *!***************************************************************************
// *! FILENAME             : io_clear_firs.C
// *! TITLE                : 
// *! DESCRIPTION          : To clear summary fir registers
// *! CONTEXT              : 
// *!
// *! OWNER  NAME          : Swaminathan, Janani         Email: jaswamin@in.ibm.com
// *! BACKUP NAME          : Varghese, Varkey            Email: varkey.kv@in.ibm.com
// *!
// *!***************************************************************************
// CHANGE HISTORY:
//------------------------------------------------------------------------------
// Version:|Author: | Date:  | Comment:
// --------|--------|--------|--------------------------------------------------
//   1.9   |jaswmain|03/26/13|  Removed DOS line endings
//   1.8   |jaswamin|03/25/13|  Removed 64 bit fir clearing function.
//   1.7   |varkeykv|03/20/13|  Additional moved FIR functions from clear firs to training files
//   1.6   |jaswamin|03/05/13|  Modifications as per review comments
//   1.5   |jaswamin|02/20/13|  Changes as per review comment
//   1.4   |varkeykv|02/18/13|  Missing function check in
//   1.3   |jaswamin|02/14/13|  function for reading the fir scom register contents, enums and arrays for doing fir isolation
//   1.2   |jaswamin|02/14/13|  Additions for reading the fir register.
//   1.1   |jaswamin|01/30/13|  Initial check in .
//------------------------------------------------------------------------------

#include <fapi.H>
#include "io_clear_firs.H"
//#include "gcr_funcs.H"
//#include "ei4_regs.h"

extern "C" {


using namespace fapi;


// for toggling the rx and tx fir reset.
ReturnCode clear_fir_err_regs(const Target &i_target,io_interface_t i_chip_interface,uint32_t i_group){
    
    ReturnCode rc;
    uint32_t rc_ecmd=0;
    uint16_t bits = 0;
    ecmdDataBufferBase data_buffer;
 
    ecmdDataBufferBase set_bits(16);
    ecmdDataBufferBase clear_bits(16);
    
    //set the rx_fir_reset bit
    bits=rx_fir_reset;
    rc_ecmd|=set_bits.insert(bits,0,16);
    bits=rx_fir_reset_clear;
    rc_ecmd|=clear_bits.insert(bits,0,16);
    if(rc_ecmd)
    {
        rc.setEcmdError(rc_ecmd);
        return(rc);
    }
    rc=GCR_write(i_target,i_chip_interface,rx_reset_act_pg,i_group,0,set_bits ,clear_bits);if (rc) {return(rc);}
    
    //clear the rx_fir_reset bit
    bits=0x0000;
    rc_ecmd|=set_bits.insert(bits,0,16);
    bits=rx_fir_reset_clear;
    rc_ecmd|=clear_bits.insert(bits,0,16);
    if(rc_ecmd)
    {
        rc.setEcmdError(rc_ecmd);
        return(rc);
    }
    rc=GCR_write(i_target,i_chip_interface,rx_reset_act_pg,i_group,0,set_bits ,clear_bits);if (rc) {return(rc);}
    
    //set the tx_fir_reset bit
    bits=tx_fir_reset;
    rc_ecmd|=set_bits.insert(bits,0,16);
    bits=tx_fir_reset_clear;
    rc_ecmd|=clear_bits.insert(bits,0,16);
    if(rc_ecmd)
    {
        rc.setEcmdError(rc_ecmd);
        return(rc);
    }
    rc=GCR_write(i_target,i_chip_interface,tx_reset_act_pg,i_group,0,set_bits ,clear_bits);if (rc) {return(rc);}
    
    //clear the tx_fir_reset
    bits=0x0000;
    rc_ecmd|=set_bits.insert(bits,0,16);
    bits=tx_fir_reset_clear;
    rc_ecmd|=clear_bits.insert(bits,0,16);
    if(rc_ecmd)
    {
        rc.setEcmdError(rc_ecmd);
        return(rc);
    }
    rc=GCR_write(i_target,i_chip_interface,tx_reset_act_pg,i_group,0,set_bits ,clear_bits);if (rc) {return(rc);}
    
    return(rc);

    
}


ReturnCode read_fir_reg(const Target &i_target,fir_io_interface_t i_chip_interface,ecmdDataBufferBase &o_databuf_64bit){
    
    ReturnCode rc;
    uint32_t rc_ecmd=0;
    uint64_t scom_address64=0;
    ecmdDataBufferBase temp(64);
    rc_ecmd |=o_databuf_64bit.flushTo0();
    
    //get the 64 bit scom address.
    temp.setDoubleWord(0,fir_rw_reg_addr[i_chip_interface]);
    scom_address64=temp.getDoubleWord(0);
    
    //read the 64 bit fir register
    rc=fapiGetScom(i_target,scom_address64,o_databuf_64bit);
    
    return(rc);
}

ReturnCode io_clear_firs(const fapi::Target &i_target){
    
    ReturnCode rc;
    fir_io_interface_t interface;
    io_interface_t gcr_interface; // requires different base address for gcr scoms
    uint32_t group;
    
    //on dmi
    if( (i_target.getType() == fapi::TARGET_TYPE_MCS_CHIPLET )){
          FAPI_DBG("This is a Processor DMI bus using base DMI scom address");
          interface=FIR_CP_IOMC0_P0; // base scom for MC bus
          gcr_interface=CP_IOMC0_P0;
          group=3; // design requires us to swap
          
     }
     else if((i_target.getType() ==  fapi::TARGET_TYPE_MEMBUF_CHIP)){
            FAPI_DBG("This is a Centaur DMI bus using base DMI scom address");
            interface=FIR_CEN_DMI;
            gcr_interface=CEN_DMI;
            group=0;
           
     }
     else if((i_target.getType() == fapi::TARGET_TYPE_XBUS_ENDPOINT)){
            FAPI_DBG("This is a X Bus invocation");
            interface=FIR_CP_FABRIC_X0;
            gcr_interface=CP_FABRIC_X0;
            group=0;
            
     }
     
     else if((i_target.getType() == fapi::TARGET_TYPE_ABUS_ENDPOINT)){
            FAPI_DBG("This is an A Bus invocation");
            interface=FIR_CP_FABRIC_A0;
            gcr_interface=CP_FABRIC_A0;
            group=0;
            
     }
     else{
        FAPI_ERR("Invalid io_clear_firs HWP invocation . Target doesnt belong to DMI/X/A instances");
        FAPI_SET_HWP_ERROR(rc, IO_CLEAR_FIRS_INVALID_INVOCATION_RC);
        return(rc);
     }
     
    rc=clear_fir_err_regs(i_target,gcr_interface,group);
    
    return(rc);
}

} //end extern C
OpenPOWER on IntegriCloud