Skip to content

Commit

Permalink
Added I2C fields, EXP_FW_STATUS API
Browse files Browse the repository at this point in the history
Change-Id: If7a0ae8cf93abda451dacac9fec86c33036d53fa
Original-Change-Id: I827ea3219f60ebcf9951db1ab0feb3421858767f
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/63578
Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
  • Loading branch information
aamarin authored and Raja Das committed Jul 26, 2019
1 parent 856ef30 commit 17441d0
Show file tree
Hide file tree
Showing 6 changed files with 783 additions and 20 deletions.
132 changes: 132 additions & 0 deletions src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/i2c/exp_i2c.H
Expand Up @@ -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 <aamarin@us.ibm.com>
// *HWP HWP Backup: Louis Stermole <stermole@us.ibm.com>
// *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

0 comments on commit 17441d0

Please sign in to comment.