/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/i2c/exp_i2c_fields.H $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ /* Contributors Listed Below - COPYRIGHT 2018,2019 */ /* [+] 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 */ /// /// @file exp_i2c_fields.H /// @brief explorer I2C field definition and operations /// // *HWP HWP Owner: Andre A. Marin // *HWP HWP Backup: Louis Stermole // *HWP Team: Memory // *HWP Level: 2 // *HWP Consumed by: HB:FSP #ifndef _MSS_EXP_I2C_FIELDS_H_ #define _MSS_EXP_I2C_FIELDS_H_ #include #ifdef __PPE__ #include #include #else #include #include #endif namespace mss { namespace exp { namespace i2c { /// /// @class fields /// @brief Explorer I2C command fields /// @tparam E Endian type /// struct fields { // First value is byte index, then buffer extract start bit, and extract data length // Part of EXP_FW_BOOT_CONFIG static constexpr mss::field_t DFE_DISABLE{0, 0, 1}; static constexpr mss::field_t LANE_MODE{0, 1, 3}; static constexpr mss::field_t SERDES_FREQ{0, 4, 4}; static constexpr mss::field_t ADAPTATION_MODE{1, 0, 1}; static constexpr mss::field_t FW_MODE{1, 1, 2}; static constexpr mss::field_t LOOPBACK_TEST{1, 3, 1}; static constexpr mss::field_t TRANSPORT_LAYER{1, 4, 2}; static constexpr mss::field_t DL_LAYER_BOOT_MODE{1, 6, 2}; // Part of EXP_FW_STATUS static constexpr mss::field_t CMD_ID{0, 0, 8}; static constexpr mss::field_t STATUS_CODE{1, 0, 8}; static constexpr mss::field_t BOOT_STAGE{2, 6, 2}; }; /// /// @class fieldTraits /// @brief Traits assoiated with the Explorer I2C commands /// @tparam F the Explorer I2C field /// template < const mss::field_t& F > struct fieldTraits; /// /// @class fieldTraits - SERDES_FREQ specialization /// @brief Traits assoiated with the Explorer I2C commands /// template <> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x0F; static constexpr const char* FIELD_STR = "SerDes Frequency"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - LANE_MODE specialization /// @brief Traits assoiated with the Explorer I2C commands /// template <> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x02; static constexpr const char* FIELD_STR = "Lane mode"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - DFE_DISABLE specialization /// @brief Traits assoiated with the Explorer I2C commands /// template <> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x01; static constexpr const char* FIELD_STR = "DFE Disable"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - DL_LAYER_BOOT_MODE specialization /// @brief Traits assoiated with the Explorer I2C commands /// template <> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x01; static constexpr const char* FIELD_STR = "DL Layer Boot mode"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - TRANSPORT_LAYER specialization /// @brief Traits assoiated with the Explorer I2C commands /// template <> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x02; static constexpr const char* FIELD_STR = "Transport Layer"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - LOOPBACK_TEST specialization /// @brief Traits assoiated with the Explorer I2C commands /// template <> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x01; static constexpr const char* FIELD_STR = "OpenCapi looptest test"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - FW_MODE specialization /// @brief Traits assoiated with the Explorer I2C commands /// template <> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x02; static constexpr const char* FIELD_STR = "FW Mode"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - ADAPTATION_MODE specialization /// @brief Traits assoiated with the Explorer I2C commands /// template <> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x01; static constexpr const char* FIELD_STR = "Adaptation Mode"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - CMD_ID specialization /// @brief Traits assoiated with the Explorer I2C commands /// template<> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0xFF; static constexpr const char* FIELD_STR = "Command ID"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - STATUS_CODE specialization /// @brief Traits assoiated with the Explorer I2C commands /// template<> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0xFF; static constexpr const char* FIELD_STR = "Status Code"; template using COMPARISON_OP = std::less_equal; }; /// /// @class fieldTraits - BOOT_STAGE specialization /// @brief Traits assoiated with the Explorer I2C commands /// template<> struct fieldTraits { static constexpr uint8_t COMPARISON_VAL = 0x03; static constexpr const char* FIELD_STR = "Boot Stage"; template using COMPARISON_OP = std::less_equal; }; /// /// @brief Explorer I2C field getter /// @tparam F the explorer I2C field /// @tparam IT Input type /// @tparam OT Output type /// @tparam TT Traits associated with exp I2C - defaults to fieldTraits /// @param[in] i_target the OCMB target /// @param[in] i_data the buffer as a reference to a vector /// @param[out] o_value the output value received /// @return FAPI2_RC_SUCCESS iff okay /// template< const mss::field_t& F, typename IT, typename OT, typename TT = fieldTraits > inline fapi2::ReturnCode get_field(const fapi2::Target& i_target, const std::vector& i_data, OT& o_value) { return mss::get_field(i_target, i_data, EXP_I2C_GET_FIELD, o_value); } #ifndef __PPE__ /// /// @brief Explorer I2C field setter /// @tparam IT Input type /// @tparam OT Output type /// @tparam TT Traits associated with exp I2C - defaults to fieldTraits /// @param[in] i_target the OCMB target /// @param[in] i_value the input value to set /// @param[in,out] io_data the buffer as a reference to a vector /// @return FAPI2_RC_SUCCESS iff okay /// template< const mss::field_t& F, typename IT, typename OT, typename TT = fieldTraits > inline fapi2::ReturnCode set_field(const fapi2::Target& i_target, std::vector& io_data, const IT i_value) { return mss::set_field(i_target, i_value, EXP_I2C_SET_FIELD, io_data); } namespace boot_cfg { /// /// @brief SERDES_FREQ 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_serdes_freq(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief SERDES_FREQ setter /// @param[in] i_target the OCMB target /// @param[in,out] io_data the buffer as a reference to a vector /// @param[in] i_freq frequency to set /// @return FAPI2_RC_SUCCESS iff okay /// fapi2::ReturnCode set_serdes_freq(const fapi2::Target& i_target, std::vector& io_data, const uint32_t i_freq); /// /// @brief LANE_MODE 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_lane_mode(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief LANE_MODE setter /// @param[in] i_target the OCMB target /// @param[in,out] io_data the buffer as a reference to a vector /// @param[in] i_setting the value to set /// @return FAPI2_RC_SUCCESS iff okay /// inline fapi2::ReturnCode set_lane_mode(const fapi2::Target& i_target, std::vector& io_data, const uint8_t i_setting) { return set_field(i_target, io_data, i_setting); } /// /// @brief DFE_DISABLE 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_dfe_disable(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief DFE_DISABLE setter /// @param[in] i_target the OCMB target /// @param[in,out] io_data the buffer as a reference to a vector /// @param[in] i_setting the value to set /// @return FAPI2_RC_SUCCESS iff okay /// inline fapi2::ReturnCode set_dfe_disable(const fapi2::Target& i_target, std::vector& io_data, const uint8_t i_setting) { return set_field(i_target, io_data, i_setting); } /// @brief DL_LAYER_BOOT_MODE 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_dl_layer_boot_mode(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief DL_LAYER_BOOT_MODE setter /// @param[in] i_target the OCMB target /// @param[in,out] io_data the buffer as a reference to a vector /// @param[in] i_setting the value to set /// @return FAPI2_RC_SUCCESS iff okay /// inline fapi2::ReturnCode set_dl_layer_boot_mode(const fapi2::Target& i_target, std::vector& io_data, const uint8_t i_setting) { return set_field(i_target, io_data, i_setting); } /// @brief ADAPTATION_MODE 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_adaptation_mode(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief ADAPTATION_MODE setter /// @param[in] i_target the OCMB target /// @param[in,out] io_data the buffer as a reference to a vector /// @param[in] i_setting the value to set /// @return FAPI2_RC_SUCCESS iff okay /// inline fapi2::ReturnCode set_adaptation_mode(const fapi2::Target& i_target, std::vector& io_data, const uint8_t i_setting) { return set_field(i_target, io_data, i_setting); } /// /// @brief DL_LAYER_BOOT_MODE 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_transport_layer(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief TRANSPORT_LAYER setter /// @param[in] i_target the OCMB target /// @param[in,out] io_data the buffer as a reference to a vector /// @param[in] i_setting the value to set /// @return FAPI2_RC_SUCCESS iff okay /// inline fapi2::ReturnCode set_transport_layer(const fapi2::Target& i_target, std::vector& io_data, const uint8_t i_setting) { return set_field(i_target, io_data, i_setting); } /// /// @brief LOOPBACK_TEST 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_loopback_test(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief LOOPBACK_TEST setter /// @param[in] i_target the OCMB target /// @param[in,out] io_data the buffer as a reference to a vector /// @param[in] i_setting the value to set /// @return FAPI2_RC_SUCCESS iff okay /// inline fapi2::ReturnCode set_loopback_test(const fapi2::Target& i_target, std::vector& io_data, const uint8_t i_setting) { return set_field(i_target, io_data, i_setting); } /// /// @brief FW_MODE 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_fw_mode(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief FW_MODE 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_fw_mode(const fapi2::Target& i_target, std::vector& io_data, const uint8_t i_setting) { return set_field(i_target, io_data, i_setting); } }// boot_cfg #endif namespace status { /// /// @brief BOOT_STAGE 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_boot_stage(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } /// /// @brief STATUS_CODE 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_status_code(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } #ifndef __PPE__ /// /// @brief CMD_ID 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_cmd_id(const fapi2::Target& i_target, const std::vector& i_data, uint8_t& o_setting) { return get_field(i_target, i_data, o_setting); } #endif }// status }// i2c }// exp }// mss #endif