From ff74130fcca2fb5f83739ca03f7b310ea8356c36 Mon Sep 17 00:00:00 2001 From: spashabk-in Date: Mon, 13 Aug 2018 01:53:21 -0500 Subject: Move lpc_rw to a source file Moving lpc_rw to its source file to avoid code duplication if more than one file includes lpc_utils.H. This is mainly required by SBE to use lpc_rw for virtual PNOR access. Change-Id: I7de30bcbae932307e0b63d8d42ae6ce050753339 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/64296 Reviewed-by: Joachim Fenkes Tested-by: Jenkins Server Tested-by: HWSV CI Tested-by: PPE CI Tested-by: Hostboot CI Reviewed-by: Sachin Gupta Reviewed-by: Jennifer A. Stofer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/64309 Tested-by: FSP CI Jenkins --- .../chips/p9/procedures/hwp/perv/p9_lpc_utils.H | 76 ++++------------------ 1 file changed, 11 insertions(+), 65 deletions(-) (limited to 'src/import/chips/p9/procedures/hwp/perv/p9_lpc_utils.H') diff --git a/src/import/chips/p9/procedures/hwp/perv/p9_lpc_utils.H b/src/import/chips/p9/procedures/hwp/perv/p9_lpc_utils.H index eee60806..dcf452ad 100644 --- a/src/import/chips/p9/procedures/hwp/perv/p9_lpc_utils.H +++ b/src/import/chips/p9/procedures/hwp/perv/p9_lpc_utils.H @@ -29,85 +29,31 @@ #ifndef P9_LPC_UTILS_H_ #define P9_LPC_UTILS_H_ +#include "fapi2.H" + const uint32_t LPC_CMD_TIMEOUT_DELAY_NS = 1000000; const uint32_t LPC_CMD_TIMEOUT_DELAY_CYCLE = 1000000; const uint32_t LPC_CMD_TIMEOUT_COUNT = 20; -static fapi2::ReturnCode lpc_rw( +fapi2::ReturnCode lpc_rw( const fapi2::Target& i_target_chip, - uint32_t i_addr, bool i_read_notwrite, fapi2::buffer& io_data) -{ - const int l_bit_offset = (i_addr & 4) << 3; - fapi2::buffer l_command; - l_command.writeBit(i_read_notwrite) - .insertFromRight(0x4) - .insertFromRight(i_addr); - FAPI_TRY(fapi2::putScom(i_target_chip, PU_LPC_CMD_REG, l_command), "Error writing LPC command register"); - - if (!i_read_notwrite) - { - fapi2::buffer l_data; - l_data.insert(io_data, l_bit_offset, 32); - FAPI_TRY(fapi2::putScom(i_target_chip, PU_LPC_DATA_REG, l_data), "Error writing LPC data"); - } - - { - fapi2::buffer l_status; - int timeout = LPC_CMD_TIMEOUT_COUNT; - - while (timeout--) - { - FAPI_TRY(fapi2::getScom(i_target_chip, PU_LPC_STATUS_REG, l_status), "Error reading LPC status"); - - if (l_status.getBit()) - { - break; - } - - fapi2::delay(LPC_CMD_TIMEOUT_DELAY_NS, LPC_CMD_TIMEOUT_DELAY_CYCLE); - } - - if (LPC_UTILS_TIMEOUT_FFDC) - { - FAPI_ASSERT(l_status.getBit(), fapi2::LPC_ACCESS_TIMEOUT() - .set_TARGET_CHIP(i_target_chip) - .set_COUNT(LPC_CMD_TIMEOUT_COUNT) - .set_COMMAND(l_command) - .set_DATA(io_data) - .set_STATUS(l_status), - "LPC access timed out"); - } - else if (!l_status.getBit()) - { - return fapi2::RC_LPC_ACCESS_TIMEOUT; - } - } - - if (i_read_notwrite) - { - fapi2::buffer l_data; - FAPI_TRY(fapi2::getScom(i_target_chip, PU_LPC_DATA_REG, l_data), "Error reading LPC data"); - l_data.extract(io_data, l_bit_offset, 32); - } - - return fapi2::FAPI2_RC_SUCCESS; - -fapi_try_exit: - return fapi2::current_err; -} + const uint32_t i_addr, + const bool i_read_notwrite, + const bool i_generate_ffdc, + fapi2::buffer& io_data); static inline fapi2::ReturnCode lpc_read( const fapi2::Target& i_target_chip, - uint32_t i_addr, fapi2::buffer& o_data) + uint32_t i_addr, fapi2::buffer& o_data, bool i_generate_ffdc = true) { - return lpc_rw(i_target_chip, i_addr, true, o_data); + return lpc_rw(i_target_chip, i_addr, true, i_generate_ffdc, o_data); } static inline fapi2::ReturnCode lpc_write( const fapi2::Target& i_target_chip, - uint32_t i_addr, fapi2::buffer i_data) + uint32_t i_addr, fapi2::buffer i_data, bool i_generate_ffdc = true) { - return lpc_rw(i_target_chip, i_addr, false, i_data); + return lpc_rw(i_target_chip, i_addr, false, i_generate_ffdc, i_data); } #endif /* P9_LPC_UTILS_H_ */ -- cgit v1.2.1