Skip to content

Commit

Permalink
Add support for EXP_FW_TWI_FFE_SETTINGS command
Browse files Browse the repository at this point in the history
Change-Id: I5e767f5cc1ee8bac9fcbbc01a1d542604393e19c
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/95927
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Dev-Ready: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com>
Reviewed-by: Mark Pizzutillo <mark.pizzutillo@ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Jennifer A Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/96144
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
  • Loading branch information
stermole authored and dcrowell77 committed May 21, 2020
1 parent d3e376b commit fbb698a
Show file tree
Hide file tree
Showing 9 changed files with 408 additions and 5 deletions.
Expand Up @@ -61,13 +61,25 @@ extern "C"
mss::display_git_commit_info("exp_omi_setup");
fapi2::ReturnCode l_rc(fapi2::FAPI2_RC_SUCCESS);
uint8_t l_gem_menterp_workaround = 0;
uint8_t l_enable_ffe_settings = 0;

// Declares variables
std::vector<uint8_t> l_boot_config_data;
std::vector<uint8_t> l_ffe_setup_data;

// BOOT CONFIG 0
uint8_t l_dl_layer_boot_mode = fapi2::ENUM_ATTR_MSS_OCMB_EXP_BOOT_CONFIG_DL_LAYER_BOOT_MODE_NON_DL_TRAINING;

// FFE Setup
FAPI_TRY(mss::attr::get_omi_ffe_settings_command(i_target, l_enable_ffe_settings));

if (l_enable_ffe_settings == fapi2::ENUM_ATTR_OMI_FFE_SETTINGS_COMMAND_ENABLE)
{
FAPI_TRY(mss::exp::omi::ffe_setup(i_target, l_ffe_setup_data));
FAPI_TRY(mss::exp::i2c::send_ffe_settings(i_target, l_ffe_setup_data));
FAPI_TRY(mss::exp::i2c::fw_status(i_target, mss::DELAY_1MS, 100));
}

// Gets the data setup
FAPI_TRY(mss::exp::omi::train::setup_fw_boot_config(i_target, l_boot_config_data));

Expand Down
Expand Up @@ -664,6 +664,41 @@ fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief FW_TWI_FFE_SETTINGS setup
/// @param[in,out] io_data the data to go to the command
///
inline void ffe_settings_setup(std::vector<uint8_t>& io_data)

{

// Need data length as well - ffe_settings can only ever be written
io_data.insert(io_data.begin(), FW_TWI_FFE_SETTINGS_BYTE_LEN);

// Then add the command
io_data.insert(io_data.begin(), FW_TWI_FFE_SETTINGS);
}

///
/// @brief FW_TWI_FFE_SETTINGS
/// @param[in] i_target the OCMB target
/// @param[in] i_data the data to write
/// @return FAPI2_RC_SUCCESS iff okay
///
inline fapi2::ReturnCode send_ffe_settings(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);
ffe_settings_setup(l_configured_data);

// Send the command
FAPI_TRY(fapi2::putI2c(i_target, l_configured_data));

fapi_try_exit:
return fapi2::current_err;
}

#endif

}// i2c
Expand Down
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2018,2019 */
/* Contributors Listed Below - COPYRIGHT 2018,2020 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -75,6 +75,16 @@ struct fields
static constexpr mss::field_t<mss::endian::BIG> CMD_ID{0, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> STATUS_CODE{1, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> BOOT_STAGE{2, 6, 2};

// Part of EXP_FW_TWI_FFE_SETTINGS
static constexpr mss::field_t<mss::endian::BIG> FFE_POST_CURSOR_BYTE0{0, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> FFE_POST_CURSOR_BYTE1{1, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> FFE_POST_CURSOR_BYTE2{2, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> FFE_POST_CURSOR_BYTE3{3, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> FFE_PRE_CURSOR_BYTE0{4, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> FFE_PRE_CURSOR_BYTE1{5, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> FFE_PRE_CURSOR_BYTE2{6, 0, 8};
static constexpr mss::field_t<mss::endian::BIG> FFE_PRE_CURSOR_BYTE3{7, 0, 8};
};

///
Expand Down Expand Up @@ -239,6 +249,118 @@ struct fieldTraits<fields::BOOT_STAGE>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class fieldTraits - FFE_PRE_CURSOR_BYTE0 specialization
/// @brief Traits assoiated with the Explorer I2C commands
///
template<>
struct fieldTraits<fields::FFE_PRE_CURSOR_BYTE0>
{
static constexpr uint8_t COMPARISON_VAL = 0x00;
static constexpr const char* FIELD_STR = "FFE Pre-cursor, byte 0";

template <typename T>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class fieldTraits - FFE_PRE_CURSOR_BYTE1 specialization
/// @brief Traits assoiated with the Explorer I2C commands
///
template<>
struct fieldTraits<fields::FFE_PRE_CURSOR_BYTE1>
{
static constexpr uint8_t COMPARISON_VAL = 0x00;
static constexpr const char* FIELD_STR = "FFE Pre-cursor, byte 1";

template <typename T>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class fieldTraits - FFE_PRE_CURSOR_BYTE2 specialization
/// @brief Traits assoiated with the Explorer I2C commands
///
template<>
struct fieldTraits<fields::FFE_PRE_CURSOR_BYTE2>
{
static constexpr uint8_t COMPARISON_VAL = 0x00;
static constexpr const char* FIELD_STR = "FFE Pre-cursor, byte 2";

template <typename T>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class fieldTraits - FFE_PRE_CURSOR_BYTE3 specialization
/// @brief Traits assoiated with the Explorer I2C commands
///
template<>
struct fieldTraits<fields::FFE_PRE_CURSOR_BYTE3>
{
static constexpr uint8_t COMPARISON_VAL = 0x20;
static constexpr const char* FIELD_STR = "FFE Pre-cursor, byte 3";

template <typename T>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class fieldTraits - FFE_POST_CURSOR_BYTE0 specialization
/// @brief Traits assoiated with the Explorer I2C commands
///
template<>
struct fieldTraits<fields::FFE_POST_CURSOR_BYTE0>
{
static constexpr uint8_t COMPARISON_VAL = 0x00;
static constexpr const char* FIELD_STR = "FFE Post-cursor, byte 0";

template <typename T>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class fieldTraits - FFE_POST_CURSOR_BYTE1 specialization
/// @brief Traits assoiated with the Explorer I2C commands
///
template<>
struct fieldTraits<fields::FFE_POST_CURSOR_BYTE1>
{
static constexpr uint8_t COMPARISON_VAL = 0x00;
static constexpr const char* FIELD_STR = "FFE Post-cursor, byte 1";

template <typename T>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class fieldTraits - FFE_POST_CURSOR_BYTE2 specialization
/// @brief Traits assoiated with the Explorer I2C commands
///
template<>
struct fieldTraits<fields::FFE_POST_CURSOR_BYTE2>
{
static constexpr uint8_t COMPARISON_VAL = 0x00;
static constexpr const char* FIELD_STR = "FFE Post-cursor, byte 2";

template <typename T>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class fieldTraits - FFE_POST_CURSOR_BYTE3 specialization
/// @brief Traits assoiated with the Explorer I2C commands
///
template<>
struct fieldTraits<fields::FFE_POST_CURSOR_BYTE3>
{
static constexpr uint8_t COMPARISON_VAL = 0x20;
static constexpr const char* FIELD_STR = "FFE Post-cursor, byte 3";

template <typename T>
using COMPARISON_OP = std::less_equal<T>;
};

///
/// @brief Explorer I2C field getter
/// @tparam F the explorer I2C field
Expand Down Expand Up @@ -511,6 +633,131 @@ inline fapi2::ReturnCode set_fw_mode(const fapi2::Target<fapi2::TARGET_TYPE_OCMB

#endif

namespace ffe_settings
{

///
/// @brief FFE_PRE_CURSOR getter
/// @param[in] i_target the OCMB target
/// @param[in] i_data the buffer as a reference to a vector
/// @param[out] o_setting
/// @return FAPI2_RC_SUCCESS iff okay
///
inline fapi2::ReturnCode get_pre_cursor(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target,
const std::vector<uint8_t>& i_data,
uint32_t& o_setting)
{
uint8_t l_byte0 = 0;
uint8_t l_byte1 = 0;
uint8_t l_byte2 = 0;
uint8_t l_byte3 = 0;
fapi2::buffer<uint32_t> l_output;

FAPI_TRY(get_field<fields::FFE_PRE_CURSOR_BYTE0>(i_target, i_data, l_byte0));
FAPI_TRY(get_field<fields::FFE_PRE_CURSOR_BYTE1>(i_target, i_data, l_byte1));
FAPI_TRY(get_field<fields::FFE_PRE_CURSOR_BYTE2>(i_target, i_data, l_byte2));
FAPI_TRY(get_field<fields::FFE_PRE_CURSOR_BYTE3>(i_target, i_data, l_byte3));

l_output.insertFromRight<0, BITS_PER_BYTE>(l_byte0);
l_output.insertFromRight<8, BITS_PER_BYTE>(l_byte1);
l_output.insertFromRight<16, BITS_PER_BYTE>(l_byte2);
l_output.insertFromRight<24, BITS_PER_BYTE>(l_byte3);

o_setting = l_output;

fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief FFE_PRE_CURSOR setter
/// @param[in] i_target the OCMB target
/// @param[in] i_setting the value to set
/// @param[in,out] io_data the buffer as a reference to a vector
/// @return FAPI2_RC_SUCCESS iff okay
///
inline fapi2::ReturnCode set_pre_cursor(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target,
std::vector<uint8_t>& io_data,
const uint32_t i_setting)
{
uint8_t l_byte = 0;
fapi2::buffer<uint32_t> l_input(i_setting);

l_input.extractToRight<0, BITS_PER_BYTE>(l_byte);
FAPI_TRY(set_field<fields::FFE_PRE_CURSOR_BYTE0>(i_target, io_data, l_byte));
l_input.extractToRight<8, BITS_PER_BYTE>(l_byte);
FAPI_TRY(set_field<fields::FFE_PRE_CURSOR_BYTE1>(i_target, io_data, l_byte));
l_input.extractToRight<16, BITS_PER_BYTE>(l_byte);
FAPI_TRY(set_field<fields::FFE_PRE_CURSOR_BYTE2>(i_target, io_data, l_byte));
l_input.extractToRight<24, BITS_PER_BYTE>(l_byte);
FAPI_TRY(set_field<fields::FFE_PRE_CURSOR_BYTE3>(i_target, io_data, l_byte));

fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief FFE_POST_CURSOR getter
/// @param[in] i_target the OCMB target
/// @param[in] i_data the buffer as a reference to a vector
/// @param[out] o_setting
/// @return FAPI2_RC_SUCCESS iff okay
///
inline fapi2::ReturnCode get_post_cursor(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target,
const std::vector<uint8_t>& i_data,
uint32_t& o_setting)
{
uint8_t l_byte0 = 0;
uint8_t l_byte1 = 0;
uint8_t l_byte2 = 0;
uint8_t l_byte3 = 0;
fapi2::buffer<uint32_t> l_output;

FAPI_TRY(get_field<fields::FFE_POST_CURSOR_BYTE0>(i_target, i_data, l_byte0));
FAPI_TRY(get_field<fields::FFE_POST_CURSOR_BYTE1>(i_target, i_data, l_byte1));
FAPI_TRY(get_field<fields::FFE_POST_CURSOR_BYTE2>(i_target, i_data, l_byte2));
FAPI_TRY(get_field<fields::FFE_POST_CURSOR_BYTE3>(i_target, i_data, l_byte3));

l_output.insertFromRight<0, BITS_PER_BYTE>(l_byte0);
l_output.insertFromRight<8, BITS_PER_BYTE>(l_byte1);
l_output.insertFromRight<16, BITS_PER_BYTE>(l_byte2);
l_output.insertFromRight<24, BITS_PER_BYTE>(l_byte3);

o_setting = l_output;

fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief FFE_POST_CURSOR setter
/// @param[in] i_target the OCMB target
/// @param[in] i_setting the value to set
/// @param[in,out] io_data the buffer as a reference to a vector
/// @return FAPI2_RC_SUCCESS iff okay
///
inline fapi2::ReturnCode set_post_cursor(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target,
std::vector<uint8_t>& io_data,
const uint32_t i_setting)
{
uint8_t l_byte = 0;
fapi2::buffer<uint32_t> l_input(i_setting);

l_input.extractToRight<0, BITS_PER_BYTE>(l_byte);
FAPI_TRY(set_field<fields::FFE_POST_CURSOR_BYTE0>(i_target, io_data, l_byte));
l_input.extractToRight<8, BITS_PER_BYTE>(l_byte);
FAPI_TRY(set_field<fields::FFE_POST_CURSOR_BYTE1>(i_target, io_data, l_byte));
l_input.extractToRight<16, BITS_PER_BYTE>(l_byte);
FAPI_TRY(set_field<fields::FFE_POST_CURSOR_BYTE2>(i_target, io_data, l_byte));
l_input.extractToRight<24, BITS_PER_BYTE>(l_byte);
FAPI_TRY(set_field<fields::FFE_POST_CURSOR_BYTE3>(i_target, io_data, l_byte));

fapi_try_exit:
return fapi2::current_err;
}

}// ffe_settings

namespace status
{

Expand Down
Expand Up @@ -100,6 +100,42 @@ fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief Sets up the FFE_SETTINGS command
/// @param[in] i_target target on which the code is operating
/// @param[out] o_data data for the FFE_SETTINGS command
/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff get is OK
///
fapi2::ReturnCode ffe_setup( const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target,
std::vector<uint8_t>& o_data )
{
constexpr uint32_t MAX_CURSOR_SUM = 63;

uint32_t l_pre_cursor = 0;
uint32_t l_post_cursor = 0;

FAPI_TRY(mss::attr::get_omi_ffe_pre_cursor(i_target, l_pre_cursor));
FAPI_TRY(mss::attr::get_omi_ffe_post_cursor(i_target, l_post_cursor));

FAPI_ASSERT((l_pre_cursor + l_post_cursor) < MAX_CURSOR_SUM,
fapi2::MSS_FFE_CURSOR_OVERFLOW().
set_TARGET(i_target).
set_PRE_CURSOR(l_pre_cursor).
set_POST_CURSOR(l_post_cursor),
"%s Sum of FFE pre-cursor %d and post-cursor %d needs to be less than 64",
mss::c_str(i_target), l_pre_cursor, l_post_cursor);

// Clears o_data, just in case
o_data.clear();
o_data.assign(mss::exp::i2c::FW_TWI_FFE_SETTINGS_BYTE_LEN, 0);

FAPI_TRY(mss::exp::i2c::ffe_settings::set_pre_cursor( i_target, o_data, l_pre_cursor ));
FAPI_TRY(mss::exp::i2c::ffe_settings::set_post_cursor( i_target, o_data, l_post_cursor ));

fapi_try_exit:
return fapi2::current_err;
}

namespace train
{

Expand Down

0 comments on commit fbb698a

Please sign in to comment.