diff --git a/src/import/chips/p9/procedures/hwp/nest/p9_phb_hv_access.C b/src/import/chips/p9/procedures/hwp/nest/p9_phb_hv_access.C index 815060ab112..bfadd7520b8 100644 --- a/src/import/chips/p9/procedures/hwp/nest/p9_phb_hv_access.C +++ b/src/import/chips/p9/procedures/hwp/nest/p9_phb_hv_access.C @@ -22,7 +22,7 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ -//----------------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // /// @file p9_phb_hv_access.C /// @brief Perform read/write to PHB HV register space. (FAPI) @@ -30,85 +30,72 @@ // *HWP HWP Owner: Ricardo Mata Jr. ricmata@us.ibm.com // *HWP FW Owner: Thi Tran thi@us.ibm.com // *HWP Team: Nest -// *HWP Level: 2 +// *HWP Level: 3 // *HWP Consumed by: HB // -//----------------------------------------------------------------------------------- +//------------------------------------------------------------------------------ -//----------------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Includes -//----------------------------------------------------------------------------------- +//------------------------------------------------------------------------------ #include #include -extern "C" -{ - //--------------------------------------------------------------------------------- - // Function definitions - //--------------------------------------------------------------------------------- - - //------------------------------------------------------------------------------ - // name: p9_phb_hv_access - //------------------------------------------------------------------------------ - // purpose: - // Performs read/write to PHB HV register space. - // - // parameters: - // 'i_target' is reference to phb target. - // 'i_address' is the PHB HV register offset between 0x0000 - 0x1FFF - // 'i_rnw' is flag to specify read (1) or write (0). - // 'i_size' is flag to specify 4B op (1) or 8B op (0). - // 'io_data' input data for writes or output data for reads. - // - // returns: - // FAPI_RC_SUCCESS (success) - // - // getscom/putscom fapi errors - // fapi error assigned from eCMD function failure - // - //------------------------------------------------------------------------------ - fapi2::ReturnCode p9_phb_hv_access(const fapi2::Target& i_target, const uint32_t i_address, - bool const i_rnw, bool const i_size, uint64_t& io_data) - { +//------------------------------------------------------------------------------ +// Function definitions +//------------------------------------------------------------------------------ - uint8_t l_phb_id = 0; +fapi2::ReturnCode p9_phb_hv_access( + const fapi2::Target& i_target, + const uint32_t i_address, + bool const i_rnw, + bool const i_size, + uint64_t& io_data) +{ - //Get the PHB id - FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_target, l_phb_id)); + uint8_t l_phb_id = 0; - FAPI_DBG("PHB%i: Start PHB HV read/write access", l_phb_id); + //Get the PHB id + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_target, l_phb_id)); - //Check ETU state - FAPI_TRY(p9_phb_hv_check_etu_state(i_target), " Error from p9_phb_hv_check_etu_state"); + FAPI_DBG("PHB%i: Start PHB HV read/write access", l_phb_id); - //Check arguments - FAPI_TRY(p9_phb_hv_check_args(i_target, i_address, i_size), " Error from p9_phb_hv_check_args"); + //Check ETU state + FAPI_TRY(p9_phb_hv_check_etu_state(i_target), + "Error from p9_phb_hv_check_etu_state"); - //Clear contents of PHB HV Indirect Address Register - FAPI_TRY(p9_phb_hv_clear(i_target), " Error from p9_phb_hv_clear"); + //Check arguments + FAPI_TRY(p9_phb_hv_check_args(i_target, i_address, i_size), + "Error from p9_phb_hv_check_args"); - //setup the PHB HV registers for the read/write - FAPI_TRY(p9_phb_hv_setup(i_target, i_address, i_size), " Error from p9_phb_hv_setup"); + //Clear contents of PHB HV Indirect Address Register + FAPI_TRY(p9_phb_hv_clear(i_target), + "Error from p9_phb_hv_clear"); - if (i_rnw) - { - //Setup PHB HV Indirect for read access - FAPI_TRY(p9_phb_hv_read(i_target, i_address, i_size, io_data), " Error from p9_phb_hv_read"); - } - else - { - //Setup PHB HV Indirect for write access - FAPI_TRY(p9_phb_hv_write(i_target, i_address, i_size, io_data), " Error from p9_phb_hv_write"); - } + //setup the PHB HV registers for the read/write + FAPI_TRY(p9_phb_hv_setup(i_target, i_address, i_size), + "Error from p9_phb_hv_setup"); - //Clear contents of PHB HV Indirect Address Register - FAPI_TRY(p9_phb_hv_clear(i_target), " Error from p9_phb_hv_clear"); + if (i_rnw) + { + //Setup PHB HV Indirect for read access + FAPI_TRY(p9_phb_hv_read(i_target, i_address, i_size, io_data), + "Error from p9_phb_hv_read"); + } + else + { + //Setup PHB HV Indirect for write access + FAPI_TRY(p9_phb_hv_write(i_target, i_address, i_size, io_data), + "Error from p9_phb_hv_write"); + } + //Clear contents of PHB HV Indirect Address Register + FAPI_TRY(p9_phb_hv_clear(i_target), + "Error from p9_phb_hv_clear"); - fapi_try_exit: - FAPI_DBG("PHB%i: End PHB HV read/write Procedure", l_phb_id); - return fapi2::current_err; - } +fapi_try_exit: + FAPI_DBG("PHB%i: End PHB HV read/write Procedure", l_phb_id); + return fapi2::current_err; -} // extern "C +} diff --git a/src/import/chips/p9/procedures/hwp/nest/p9_phb_hv_access.H b/src/import/chips/p9/procedures/hwp/nest/p9_phb_hv_access.H index 4e1eed059ca..eab676badb1 100644 --- a/src/import/chips/p9/procedures/hwp/nest/p9_phb_hv_access.H +++ b/src/import/chips/p9/procedures/hwp/nest/p9_phb_hv_access.H @@ -22,58 +22,61 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ -//----------------------------------------------------------------------------------- -// *! +//------------------------------------------------------------------------------ + +/// /// @file p9_phb_hv_access.H /// @brief Code to support PHB HV Indirect access procedures (FAPI) /// +/// @author ricmata@us.ibm.com +/// + // *HWP HWP Owner: Ricardo Mata Jr. ricmata@us.ibm.com // *HWP FW Owner: Thi Tran thi@us.ibm.com // *HWP Team: Nest -// *HWP Level: 2 +// *HWP Level: 3 // *HWP Consumed by: HB #ifndef _P9_PHB_HV_ACCESS_H_ #define _P9_PHB_HV_ACCESS_H_ - -//----------------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Includes -//----------------------------------------------------------------------------------- +//------------------------------------------------------------------------------ #include //------------------------------------------------------------------------------ -// Constant definitions -//------------------------------------------------------------------------------ - -//----------------------------------------------------------------------------------- // Structure definitions -//----------------------------------------------------------------------------------- +//------------------------------------------------------------------------------ //function pointer typedef definition for HWP call support -typedef fapi2::ReturnCode (*p9_phb_hv_access_FP_t) (const fapi2::Target&, const uint32_t, - bool const, bool const, uint64_t&); +typedef fapi2::ReturnCode (*p9_phb_hv_access_FP_t) ( + const fapi2::Target&, + const uint32_t, + bool const, + bool const, + uint64_t&); -//----------------------------------------------------------------------------------- -// Constant definitions -//----------------------------------------------------------------------------------- +//------------------------------------------------------------------------------ +// Function prototypes +//------------------------------------------------------------------------------ extern "C" { -//----------------------------------------------------------------------------------- -// Function prototypes -//----------------------------------------------------------------------------------- - -/// @briefF perform read/write to PHB HV register space -/// @param[in] i_target => phb target -/// @param[in] i_address => PHB HV register offset between 0x0000 - 0x1FFF -/// @param[in] i_rnw => 1 for read, 0 for write. -/// @param[in] i_size => 1 for 8B op to access PHB HV. 0 for 4B op for config ops. -/// @param[in, out] io_data => input data for writes. output data for reads. +/// @brief perform read/write to PHB HV register space +/// @param[in] i_target PHB target +/// @param[in] i_address PHB HV register offset between 0x0000 - 0x1FFF +/// @param[in] i_rnw 1 for read, 0 for write +/// @param[in] i_size 1 for 8B op to access PHB HV. 0 for 4B op for config ops +/// @param[inout] io_data Input data for writes / output data for reads /// /// @return FAPI_RC_SUCCESS if the read/write completes successfully. - fapi2::ReturnCode p9_phb_hv_access(const fapi2::Target& i_target, const uint32_t i_address, - bool const i_rnw, bool const i_size, uint64_t& io_data); + fapi2::ReturnCode p9_phb_hv_access( + const fapi2::Target& i_target, + const uint32_t i_address, + bool const i_rnw, + bool const i_size, + uint64_t& io_data); } // extern "C"