From 5b99b40b7364c5986006df36b115784bd967d47b Mon Sep 17 00:00:00 2001 From: Santosh Puranik Date: Wed, 7 Jun 2017 11:03:09 -0500 Subject: Fix putScomUnderMask Change-Id: I06452679730b236a4e00f4df89265c3f8fcf5a52 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41487 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Benjamin Gass Reviewed-by: Sachin Gupta --- src/hwpf/hw_access.H | 25 +++++++++---------------- src/hwpf/plat_hw_access.C | 26 ++++++++++++++++++++++++++ src/hwpf/plat_hw_access.H | 14 ++++++++++++++ 3 files changed, 49 insertions(+), 16 deletions(-) (limited to 'src/hwpf') diff --git a/src/hwpf/hw_access.H b/src/hwpf/hw_access.H index 9c5da3aa..de0ac924 100644 --- a/src/hwpf/hw_access.H +++ b/src/hwpf/hw_access.H @@ -6,6 +6,7 @@ /* OpenPOWER sbe Project */ /* */ /* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -151,6 +152,7 @@ namespace fapi2 const buffer i_data, const ChipOpModifyMode i_modifyMode) { + static_assert(does_plat_allow::value, "modifyScom not suppported"); fapi2::buffer l_modifyDataBuffer; fapi2::ReturnCode l_rc; @@ -197,23 +199,11 @@ __fapi2exit__: template< TargetType K, typename V > inline ReturnCode putScomUnderMask( const Target& i_target, const uint64_t i_address, - buffer i_data, - buffer i_mask) + const buffer i_data, + const buffer i_mask) { - // TODO: via RTC: 160143: Fix the plat implementation - static_assert(does_plat_allow::value, "putScomUnderMask not suppported"); - fapi2::buffer l_modifyDataBuffer = i_data; - - l_modifyDataBuffer &= i_mask; - - fapi2::ReturnCode l_rc; - PLAT_PUTSCOM(l_rc, - i_target, - (uint32_t)(i_address & BITS(40,24)), - l_modifyDataBuffer()); - - return l_rc; - + return fapi2::putscom_under_mask(&i_target, i_address, i_data(), + i_mask()); } @@ -229,6 +219,7 @@ __fapi2exit__: const uint32_t i_address, buffer& o_data) { + static_assert(does_plat_allow::value, "getCfamRegister not suppported"); PLAT_GETCFAM(i_target.get(), (uint32_t)(i_address & BITS(40,24)), &(o_data())); @@ -248,6 +239,7 @@ __fapi2exit__: const uint32_t i_address, buffer& i_data) { + static_assert(does_plat_allow::value, "putCfamRegister not suppported"); PLAT_PUTCFAM(i_target.get(), (uint32_t)(i_address & BITS(40,24)), &(i_data())); @@ -269,6 +261,7 @@ __fapi2exit__: const buffer& i_data, const ChipOpModifyMode i_modifyMode) { + static_assert(does_plat_allow::value, "modifyCfamRegister not suppported"); PLAT_MODCFAM(i_target.get(), (uint32_t)(i_address & BITS(40,24)), &(i_data()), diff --git a/src/hwpf/plat_hw_access.C b/src/hwpf/plat_hw_access.C index bdf6ae3b..99f92a39 100644 --- a/src/hwpf/plat_hw_access.C +++ b/src/hwpf/plat_hw_access.C @@ -315,6 +315,32 @@ fapi_try_exit: return fapi2::current_err; } + +fapi2::ReturnCode putscom_under_mask(const void *i_target, + uint32_t i_addr, + uint64_t i_data, + uint64_t i_mask) +{ + uint64_t l_read = 0; + fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS; + + do + { + l_rc = getscom_abs_wrap(i_target, i_addr, &l_read); + + if(l_rc) + { + break; + } + + l_read = (l_read & ~i_mask) | (i_data & i_mask); + + l_rc = putscom_abs_wrap(i_target, i_addr, l_read); + } while (false); + + return l_rc; +} + uint32_t p9_pibErrRetry( const uint32_t i_addr, uint64_t *io_data, const uint8_t i_pibErr, const bool i_isRead) { diff --git a/src/hwpf/plat_hw_access.H b/src/hwpf/plat_hw_access.H index 16bbf0ce..7af79bd3 100644 --- a/src/hwpf/plat_hw_access.H +++ b/src/hwpf/plat_hw_access.H @@ -6,6 +6,7 @@ /* OpenPOWER sbe Project */ /* */ /* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -147,6 +148,19 @@ namespace fapi2 const uint32_t i_addr, uint64_t i_data); /// + /// @brief Plat implementation of putScomUnderMask + /// + /// @param [in] i_target Pointer to fapi2::Target as a void* + /// @param [in] i_addr The SCOM address + /// @param [in] i_data The data to write (after applying the mask) + /// @param [in] i_mask The data mask + /// + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + fapi2::ReturnCode putscom_under_mask(const void *i_target, + uint32_t i_addr, + uint64_t i_data, + uint64_t i_mask); + /// /// @brief Platform wrapper to retry scom for parity/timeout errors /// /// @param [in] i_addr The SCOM address -- cgit v1.2.1