-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I827ea3219f60ebcf9951db1ab0feb3421858767f Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/63578 Tested-by: HWSV CI <[email protected]> Tested-by: Hostboot CI <[email protected]> Tested-by: Jenkins Server <[email protected]> Reviewed-by: Louis Stermole <[email protected]> Reviewed-by: STEPHEN GLANCY <[email protected]> Reviewed-by: Jennifer A. Stofer <[email protected]> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/69956 Tested-by: FSP CI Jenkins <[email protected]> Reviewed-by: Sachin Gupta <[email protected]>
- Loading branch information
Showing
1 changed file
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,135 @@ | |
/* permissions and limitations under the License. */ | ||
/* */ | ||
/* IBM_PROLOG_END_TAG */ | ||
|
||
/// | ||
/// @file exp_i2c.H | ||
/// @brief explorer I2C utility function declarations | ||
/// | ||
// *HWP HWP Owner: Andre A. Marin <[email protected]> | ||
// *HWP HWP Backup: Louis Stermole <[email protected]> | ||
// *HWP Team: Memory | ||
// *HWP Level: 2 | ||
// *HWP Consumed by: HB:FSP | ||
|
||
#ifndef _MSS_EXP_I2C_H_ | ||
#define _MSS_EXP_I2C_H_ | ||
|
||
#include <fapi2.H> | ||
#include <i2c_access.H> | ||
|
||
#include <vector> | ||
#include <lib/i2c/exp_i2c_fields.H> | ||
|
||
namespace mss | ||
{ | ||
namespace exp | ||
{ | ||
namespace i2c | ||
{ | ||
namespace check | ||
{ | ||
|
||
/// | ||
/// @brief Checks the I2c explorer status codes | ||
/// @param[in] i_target the OCMB target | ||
/// @param[in] i_cmd_id the command ID | ||
/// @param[in] i_data data to check from EXP_FW_STATUS | ||
/// | ||
inline fapi2::ReturnCode status_code( const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target, | ||
const uint8_t i_cmd_id, | ||
const std::vector<uint8_t>& i_data ) | ||
{ | ||
// Set to a high number to make sure check for SUCCESS (== 0) isn't a fluke | ||
size_t l_status = ~(0); | ||
FAPI_TRY( status::get_status_code(i_target, i_data, l_status) ); | ||
|
||
// Technically many cmds have their own status code decoding..but SUCCESS is always 0. | ||
// If it's anything else we can just look up the status code | ||
FAPI_ASSERT( l_status == status_codes::SUCCESS, | ||
fapi2::MSS_EXP_STATUS_CODE_UNSUCCESSFUL(). | ||
set_TARGET(i_target). | ||
set_STATUS_CODE(l_status). | ||
set_CMD_ID(i_cmd_id), | ||
"Status code did not return SUCCESS (%d), received (%d) for %s", | ||
status_codes::SUCCESS, l_status, mss::c_str(i_target) ); | ||
|
||
return fapi2::FAPI2_RC_SUCCESS; | ||
|
||
fapi_try_exit: | ||
return fapi2::current_err; | ||
} | ||
|
||
}// check | ||
|
||
/// | ||
/// @brief EXP_FW_STATUS setup helper function - useful for testing | ||
/// @param[out] o_size the size of data | ||
/// @param[out] o_cmd_id the explorer command ID | ||
/// | ||
inline void fw_status_setup(size_t& o_size, | ||
std::vector<uint8_t>& o_cmd_id) | ||
{ | ||
o_size = FW_STATUS_BYTE_LEN; | ||
o_cmd_id.assign({FW_STATUS}); | ||
} | ||
|
||
/// | ||
/// @brief EXP_FW_STATUS | ||
/// @param[in] i_target the OCMB target | ||
/// @return FAPI2_RC_SUCCESS iff okay | ||
/// | ||
inline fapi2::ReturnCode fw_status(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target) | ||
{ | ||
// Retrieve setup data | ||
size_t l_size = 0; | ||
std::vector<uint8_t> l_cmd_id; | ||
fw_status_setup(l_size, l_cmd_id); | ||
|
||
// Get data and check for errors | ||
{ | ||
std::vector<uint8_t> l_data; | ||
FAPI_TRY(fapi2::getI2c(i_target, l_size, l_cmd_id, l_data)); | ||
FAPI_TRY( check::status_code(i_target, l_cmd_id[0], l_data) ); | ||
} | ||
|
||
fapi_try_exit: | ||
return fapi2::current_err; | ||
} | ||
|
||
/// | ||
/// @brief EXP_FW_BOOT_CONFIG setup | ||
/// @param[in,out] io_data the data to go to boot config | ||
/// | ||
inline void boot_config_setup(std::vector<uint8_t>& io_data) | ||
|
||
{ | ||
io_data.insert(io_data.begin(), FW_BOOT_CONFIG); | ||
} | ||
|
||
/// | ||
/// @brief EXP_FW_BOOT_CONFIG | ||
/// @param[in] i_target the OCMB target | ||
/// @param[in] i_data the data to write | ||
/// @return FAPI2_RC_SUCCESS iff okay | ||
/// | ||
inline fapi2::ReturnCode boot_config(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target, | ||
const std::vector<uint8_t>& i_data) | ||
{ | ||
// Retrieve setup data | ||
std::vector<uint8_t> l_configured_data(i_data); | ||
boot_config_setup(l_configured_data); | ||
|
||
// Get data and check for errors | ||
FAPI_TRY(fapi2::putI2c(i_target, l_configured_data)); | ||
FAPI_TRY(fw_status(i_target)); | ||
|
||
fapi_try_exit: | ||
return fapi2::current_err; | ||
} | ||
|
||
}// i2c | ||
}// exp | ||
}// mss | ||
|
||
#endif |