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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/i2c/i2cif.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2015 */
/* [+] 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 __I2CIF_H
#define __I2CIF_H
namespace I2C
{
/**
* @enum i2cProcessType
*
* @brief I2C Process Type specifies which targets and which I2C master
* engines are reset or setup
*
* Specifically:
*
* _PROC_ --> loops through the processors in the system
* _MEMBUF_ --> loops through membufs in the system
*
* _HOST_ --> only does the reset if target's active engine is in Host mode
* _FSI_ --> only does the reset if target's active engine is in FSI mode
* [NOTE: active engine is determined by target's I2C_SWITCHES attribute]
*
* _ALL --> combines one or more of the PROC/MEMBUF and HOST/FSI pairs
*
*/
enum i2cProcessType
{
// used to create function-specific enums below
I2C_RANGE_HOST = 0x01,
I2C_RANGE_FSI = 0x02,
I2C_RANGE_PROC = 0x04,
I2C_RANGE_MEMBUF = 0x08,
// external interface for i2cResetActiveMasters and i2cSetupActiveMasters
I2C_PROC_HOST = I2C_RANGE_PROC | I2C_RANGE_HOST,
I2C_PROC_FSI = I2C_RANGE_PROC | I2C_RANGE_FSI,
I2C_PROC_ALL = I2C_PROC_HOST | I2C_PROC_FSI,
I2C_MEMBUF_HOST = I2C_RANGE_MEMBUF | I2C_RANGE_HOST,
I2C_MEMBUF_FSI = I2C_RANGE_MEMBUF | I2C_RANGE_FSI,
I2C_MEMBUF_ALL = I2C_MEMBUF_HOST | I2C_MEMBUF_FSI,
I2C_ALL = I2C_PROC_ALL | I2C_MEMBUF_ALL,
};
/**
* @brief This function will handle everything required to reset a target's
* "active" I2C master engine.
* [NOTE: "active" engine is determined by target's I2C_SWITCHES attribute]
*
*
* @param[in] i_resetType - Specfies which targets and which I2C master engines
* to reset
* (see i2cProcessType description above)
*
* @param[in] i_functional - Specfies if reset is performed on functional or
* any existing targets that match the i_resetType
* if true - functional targets
* if false - existing targets
*
* @return errlHndl_t - Null if successful, otherwise a pointer to
* the error log.
*/
errlHndl_t i2cResetActiveMasters ( i2cProcessType i_resetType,
bool i_functional = true );
/**
* @brief This function will handle everything required to setup a target's
* "active" I2C master engine.
* [NOTE: "active" engine is determined by target's I2C_SWITCHES attribute]
*
*
* @param[in] i_setupType - Specfies which targets and which I2C master engines
* to setup
* (see i2cProcessType description above)
*
* @param[in] i_functional - Specfies if setup is performed on functional or
* any existing targets that match the i_resetType
* if true - functional targets
* if false - existing targets
*
* @return errlHndl_t - Null if successful, otherwise a pointer to
* the error log.
*/
errlHndl_t i2cSetupActiveMasters ( i2cProcessType i_setupType,
bool i_functional = true );
/**
* @brief This function will determine if a given I2C device is present
*
* @param[in] i_target - The target device
* @param[in] i_port - The device's port
* @param[in] i_engine - The device's engine number
* @param[in] i_devAddr - The device's address
*
* @return bool - True if chip is present, False otherwise.
*/
bool i2cPresence( TARGETING::Target * i_target,
uint64_t i_port,
uint64_t i_engine,
uint64_t i_devAddr );
/**
* @enum i2cSetAccessModeType
*
* @brief I2C Set Access Mode Type specifies what targets will be set to
* a specific I2C Access Mode (Host or FSI)
*
*/
enum i2cSetAccessModeType
{
I2C_SET_ACCESS_MODE_INVALID = 0x00,
I2C_SET_ACCESS_MODE_PROC_HOST = 0x01
};
/**
* @brief This function will set the I2C_SWITCH attribute for certain
* targets to a specific mode (Host or FSI) based on the input.
*
* @param i2cSetModeType - Specifies which targets to be set and which
* mode to set them to
*/
void i2cSetAccessMode( i2cSetAccessModeType i_setModeType );
/**
* @brief Define a set of information about the I2C masters
* (primarily used to populate the devtree)
*/
struct MasterInfo_t
{
uint64_t scomAddr; //< Base scom address for control regs
uint8_t engine; //< Engine number
uint32_t freq; //< Clock frequency of master in Hz
};
/**
* @brief Return a set of information related to each I2C master on
* the given target chip
*
* @param[in] i_chip - I2C Master chip (proc or membuf)
* @param[out] o_info - list of I2C Information
*
* @return errlHndl_t - Null if successful, otherwise a pointer to
* the error log.
*/
void getMasterInfo( const TARGETING::Target* i_chip,
std::list<MasterInfo_t>& o_info );
}; // end namespace I2C
#endif // end __I2CIF_H
|