Skip to content

Commit

Permalink
L3 Update - p9_pm_pba_bar_config HWP
Browse files Browse the repository at this point in the history
Change-Id: Ifda9c02bcc5c2c9143d80c1604e23c1bdabd366e
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/45421
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
Reviewed-by: Brian T. Vanderpool <vanderp@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/45439
Reviewed-by: Hostboot Team <hostboot@us.ibm.com>
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
ibmthi authored and dcrowell77 committed Sep 6, 2017
1 parent 40be8bb commit 4ffde05
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 47 deletions.
95 changes: 55 additions & 40 deletions src/import/chips/p9/procedures/hwp/pm/p9_pm_pba_bar_config.C
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2016 */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand All @@ -27,10 +27,10 @@
///
/// @brief Initialize PAB and PAB_MSK of PBA
///
// *HWP HWP Owner: Greg Still <stillgs@us.ibm.com>
// *HWP FW Owner: Sangeetha T S <sangeet2@in.ibm.com>
// *HWP HWP Owner: Greg Still <stillgs @us.ibm.com>
// *HWP FW Owner: Prem Shanker Jha <premjha2@in.ibm.com>
// *HWP Team: PM
// *HWP Level: 2
// *HWP Level: 3
// *HWP Consumed by: HS
///
/// @verbatim
Expand All @@ -52,6 +52,8 @@
// Includes
// -----------------------------------------------------------------------------
#include <p9_pm_pba_bar_config.H>
#include <p9_misc_scom_addresses.H>
#include <p9_misc_scom_addresses_fld.H>

// -----------------------------------------------------------------------------
// Constant & Structure definitions
Expand Down Expand Up @@ -82,22 +84,28 @@ const uint64_t PBA_BARMSKs[4] =
// -----------------------------------------------------------------------------
// Prototypes
// -----------------------------------------------------------------------------
///
/// @brief Determine if a number is a power of two or not
///
/// @param [in] i_value Input number
/// @return True if value is a power of two
/// False otherwise.
///
inline bool isPowerOfTwo (uint64_t i_value);

///-----------------------------------------------------------------------------
/// Determine if a number is a power of two or not
///-----------------------------------------------------------------------------
inline bool isPowerOfTwo (uint64_t value);

///-----------------------------------------------------------------------------
/// Round up to next higher power of 2 (return value if it's already a power of
/// 2).
///-----------------------------------------------------------------------------
///
/// @brief Round up to next higher power of 2
///
/// @param [in] i_value Input value
/// @return Next higher power of 2 of i_value.
/// If i_value is already a power of 2, return i_value.
///
inline uint64_t PowerOf2Roundedup (uint64_t value);


// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
// See doxygen in header file
fapi2::ReturnCode p9_pm_pba_bar_config (
const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
const uint32_t i_index,
Expand All @@ -106,7 +114,7 @@ fapi2::ReturnCode p9_pm_pba_bar_config (
const p9pba::CMD_SCOPE i_pba_cmd_scope,
const uint16_t i_vectorTarget)
{
FAPI_IMP("Entering P9_PM_PBA_BAR_CONFIG...");
FAPI_DBG("Entering p9_pm_pba_bar_config...");

fapi2::buffer<uint64_t> l_bar64;
uint64_t l_work_size;
Expand All @@ -119,8 +127,10 @@ fapi2::ReturnCode p9_pm_pba_bar_config (
// Check if PBA BAR address is within range,
// High order bits checked to ensure a valid real address
FAPI_ASSERT((BAR_ADDR_RANGECHECK_HIGH & i_pba_bar_addr) == 0x0ull,
fapi2::P9_PBA_ADDR_OUT_OF_RANGE().set_INDEX(i_index)
.set_BAR_ADDR(i_pba_bar_addr).set_BAR_SIZE(i_pba_bar_size)
fapi2::P9_PBA_ADDR_OUT_OF_RANGE()
.set_INDEX(i_index)
.set_BAR_ADDR(i_pba_bar_addr)
.set_BAR_SIZE(i_pba_bar_size)
.set_CMD_SCOPE(i_pba_cmd_scope)
.set_EXP_BAR_ADDR_RANGECHECK_HIGH(BAR_ADDR_RANGECHECK_HIGH),
"ERROR: Address out of Range : i_pba_bar_addr = 0x%016llX & "
Expand All @@ -129,8 +139,10 @@ fapi2::ReturnCode p9_pm_pba_bar_config (

// Low order bits checked for alignment
FAPI_ASSERT((BAR_ADDR_RANGECHECK_LOW & i_pba_bar_addr) == 0x0ull,
fapi2::P9_PBA_ADDR_ALIGNMENT_ERROR().set_INDEX(i_index)
.set_BAR_ADDR(i_pba_bar_addr).set_BAR_SIZE(i_pba_bar_size)
fapi2::P9_PBA_ADDR_ALIGNMENT_ERROR()
.set_INDEX(i_index)
.set_BAR_ADDR(i_pba_bar_addr)
.set_BAR_SIZE(i_pba_bar_size)
.set_CMD_SCOPE(i_pba_cmd_scope)
.set_EXP_BAR_ADDR_RANGECHECK_LOW(BAR_ADDR_RANGECHECK_LOW),
"ERROR: Address must be on a 1MB boundary : i_pba_bar_addr="
Expand All @@ -139,10 +151,11 @@ fapi2::ReturnCode p9_pm_pba_bar_config (

// The combination of both the BAR size and addr being zero is legal.
// But, if the BAR size is 0 and the BAR addr is not zero return error.

FAPI_ASSERT(!((i_pba_bar_size == 0) && (i_pba_bar_addr != 0)),
fapi2::P9_PBA_BAR_SIZE_INVALID().set_INDEX(i_index)
.set_BAR_ADDR(i_pba_bar_addr).set_BAR_SIZE(i_pba_bar_size)
fapi2::P9_PBA_BAR_SIZE_INVALID()
.set_INDEX(i_index)
.set_BAR_ADDR(i_pba_bar_addr)
.set_BAR_SIZE(i_pba_bar_size)
.set_CMD_SCOPE(i_pba_cmd_scope),
"ERROR: Bar size must be >=1MB for PBABAR 0x%llX, but "
"i_pba_bar_size=0x%016llx", i_index, i_pba_bar_size);
Expand All @@ -167,13 +180,15 @@ fapi2::ReturnCode p9_pm_pba_bar_config (

// Write the BAR
l_bar64.set(i_pba_bar_addr);
l_bar64.insertFromRight<0, 3>(i_pba_cmd_scope);
l_bar64.insertFromRight<PU_PBABAR0_CMD_SCOPE,
PU_PBABAR0_CMD_SCOPE_LEN>(i_pba_cmd_scope);

if (i_pba_cmd_scope == p9pba::VECTORED_GROUP)
{
FAPI_DBG("Setting the initial vectored group target for scope 0x%X",
i_pba_cmd_scope);
l_bar64.insertFromRight<48, 16>(i_vectorTarget);
l_bar64.insertFromRight<PU_PBABAR0_VTARGET,
PU_PBABAR0_VTARGET_LEN>(i_vectorTarget);
}

FAPI_TRY(fapi2::putScom(i_target, PBA_BARs[i_index], l_bar64),
Expand Down Expand Up @@ -213,32 +228,32 @@ fapi2::ReturnCode p9_pm_pba_bar_config (
FAPI_TRY(fapi2::putScom(i_target, PBA_BARMSKs[i_index], l_bar64),
"PBA_MASK Putscom failed for channel 0x%llX", i_index);

FAPI_IMP("Exiting P9_PM_PBA_BAR_CONFIG...");

fapi_try_exit:
FAPI_DBG("Exiting p9_pm_pba_bar_config...");
return fapi2::current_err;
}

inline bool isPowerOfTwo(uint64_t value)
// See doxygen in Prototypes section above
inline bool isPowerOfTwo(uint64_t i_value)
{
// if value ANDed with the value-1 is 0, then value is a power of 2.
// if value is 0, this is considered not a power of 2 and will return false.

return !(value & (value - 1));
// if i_value ANDed with the i_value-1 is 0, then i_value is a power of 2.
// if i_value is 0, this is considered not a power of 2 and will return false.
return !(i_value & (i_value - 1));
}

inline uint64_t PowerOf2Roundedup (uint64_t value)
// See doxygen in Prototypes section above
inline uint64_t PowerOf2Roundedup (uint64_t i_value)
{
if (value < 0)
if (i_value < 0)
{
return 0;
}

--value;
value |= value >> 1;
value |= value >> 2;
value |= value >> 4;
value |= value >> 8;
value |= value >> 16;
return value + 1;
--i_value;
i_value |= i_value >> 1;
i_value |= i_value >> 2;
i_value |= i_value >> 4;
i_value |= i_value >> 8;
i_value |= i_value >> 16;
return i_value + 1;
}
12 changes: 5 additions & 7 deletions src/import/chips/p9/procedures/hwp/pm/p9_pm_pba_bar_config.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2016 */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand All @@ -28,9 +28,9 @@
/// @brief Initialize PAB and PAB_MSK of PBA
///
// *HWP HWP Owner: Greg Still <stillgs @us.ibm.com>
// *HWP FW Owner: Sangeetha T S <sangeet2@in.ibm.com>
// *HWP FW Owner: Prem Shanker Jha <premjha2@in.ibm.com>
// *HWP Team: PM
// *HWP Level: 1
// *HWP Level: 3
// *HWP Consumed by: HS
//

Expand All @@ -42,10 +42,8 @@
// -----------------------------------------------------------------------------
#include <fapi2.H>
#include <p9_pm_pba_init.H>
#include <p9_misc_scom_addresses.H>

// function pointer typedef definition for HWP call support

// Function pointer typedef definition for HWP call support
typedef fapi2::ReturnCode (*p9_pm_pba_bar_config_FP_t)
(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>&,
const uint32_t,
Expand All @@ -64,7 +62,7 @@ extern "C"
///
/// @brief Initialize PAB_BAR (cmd_scope & address) and PAB_BARMSK (mask/size)
///
/// @param [in] i_target Chip Target
/// @param [in] i_target Reference to Proc chip target
/// @param [in] i_index Identifies the set of BAR/BARMSK registers [0-3]
/// @param [in] i_pba_bar_addr PBA base address - 1MB granularity
/// @param [in] i_pba_bar_size PBA region size in MB; If not a power of two,
Expand Down

0 comments on commit 4ffde05

Please sign in to comment.