Skip to content

Commit

Permalink
p9c_set_inband_addr
Browse files Browse the repository at this point in the history
Cumulus initial version

Change-Id: I593b2b6bcdb4232147193520462efff67e60cd23
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/39536
Dev-Ready: Brent Wieman <bwieman@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/45326
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
  • Loading branch information
LiuYangFan authored and crgeddes committed Aug 30, 2017
1 parent 13edc6f commit 30e17cd
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 0 deletions.
123 changes: 123 additions & 0 deletions src/import/chips/p9/procedures/hwp/nest/p9c_set_inband_addr.C
@@ -0,0 +1,123 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/import/chips/p9/procedures/hwp/nest/p9c_set_inband_addr.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* [+] 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 p9c_set_inband_addr.H
/// @brief configure Cumulus inband address
///
/// Set the inband base address in the MC
/// driven by attributes representing system memory map.
///

// *HWP HWP Owner: Yang Fan Liu shliuyf@cn.ibm.com
// *HWP FW Owner: Thi Tran thi@us.ibm.com
// *HWP Team: Nest
// *HWP Level: 2
// *HWP Consumed by: HB

//-----------------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------------
#include <p9c_set_inband_addr.H>
#include <p9_fbc_utils.H>
#include <p9_mc_scom_addresses.H>

//-----------------------------------------------------------------------------------
// Function definitions
//-----------------------------------------------------------------------------------
///
/// @brief configure Cumulus inband address
///
/// @param[in] i_target => Processor chip target
///
/// @return FAPI_RC_SUCCESS if the setup completes successfully, else error
//
fapi2::ReturnCode p9c_set_inband_addr(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
FAPI_DBG("Start");

auto l_dmi_chiplets = i_target.getChildren<fapi2::TARGET_TYPE_DMI>();
fapi2::ATTR_DMI_INBAND_BAR_ENABLE_Type l_bar_enable;
fapi2::ATTR_DMI_INBAND_BAR_BASE_ADDR_OFFSET_Type l_bar_offset;
uint8_t l_dmi_pos;
uint64_t l_base_addr_nm0, l_base_addr_nm1, l_base_addr_m, l_base_addr_mmio;
uint64_t l_dmi_inband_addr;
fapi2::buffer<uint64_t> l_scom_data;

// determine base address of chip MMIO range
FAPI_TRY(p9_fbc_utils_get_chip_base_address(i_target,
EFF_FBC_GRP_CHIP_IDS,
l_base_addr_nm0,
l_base_addr_nm1,
l_base_addr_m,
l_base_addr_mmio),
"Error from p9_fbc_utils_get_chip_base_address");

for(auto l_dmi : l_dmi_chiplets)
{
// retrieve inband BAR enable
FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_DMI_INBAND_BAR_ENABLE, l_dmi, l_bar_enable),
"Error from FAPI_ATTR_GET (ATTR_DMI_INBAND_BAR_ENABLE)");

if (l_bar_enable == fapi2::ENUM_ATTR_DMI_INBAND_BAR_ENABLE_ENABLE)
{
// retrieve inband BAR offset
FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_DMI_INBAND_BAR_BASE_ADDR_OFFSET, l_dmi, l_bar_offset),
"Error from FAPI_ATTR_GET (ATTR_DMI_INBAND_BAR_BASE_ADDR_OFFSET)");

// form SCOM register format
l_scom_data.flush<0>();
// BAR address 8:38 into bits 4:34
l_dmi_inband_addr = l_base_addr_mmio + l_bar_offset;
l_scom_data.insert<4, 31, 8>(l_dmi_inband_addr);
// Set valid(bit0 = 1), P9 mode(bit3 = 0)
l_scom_data.setBit<0>();

// get MI target to configure MCFGPR
fapi2::Target<fapi2::TARGET_TYPE_MI> l_mi = l_dmi.getParent<fapi2::TARGET_TYPE_MI>();
// retrieve DMI pos
FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, l_dmi, l_dmi_pos),
"Error from FAPI_ATTR_GET (ATTR_CHIP_UNIT_POS)");

// configure inband channel 0 MCFGPR0
if(l_dmi_pos % 2 == 0)
{
FAPI_TRY(fapi2::putScom(l_mi, MCS_MCRSVDE, l_scom_data),
"Error from putScom MCFGPR0 for DMI id: %d", l_dmi_pos);
}
// configure inband channel 1 MCFGPR1
else
{
FAPI_TRY(fapi2::putScom(l_mi, MCS_MCRSVDF, l_scom_data),
"Error from putScom MCFGPR1 for DMI id: %d", l_dmi_pos);
}
}
}

fapi_try_exit:
FAPI_DBG("End");
return fapi2::current_err;
}


74 changes: 74 additions & 0 deletions src/import/chips/p9/procedures/hwp/nest/p9c_set_inband_addr.H
@@ -0,0 +1,74 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/import/chips/p9/procedures/hwp/nest/p9c_set_inband_addr.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* [+] 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 p9c_set_inband_addr.H
/// @brief configure Cumulus inband address
///
/// Set the inband base address in the MC
/// driven by attributes representing system memory map.
///

// *HWP HWP Owner: Yang Fan Liu shliuyf@cn.ibm.com
// *HWP FW Owner: Thi Tran thi@us.ibm.com
// *HWP Team: Nest
// *HWP Level: 2
// *HWP Consumed by: HB

#ifndef _P9C_SET_INBAND_ADDR_H_
#define _P9C_SET_INBAND_ADDR_H_


//-----------------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------------
#include <fapi2.H>


//-----------------------------------------------------------------------------------
// Structure definitions
//-----------------------------------------------------------------------------------

// function pointer typedef definition for HWP call support
typedef fapi2::ReturnCode (*p9c_set_inband_addr_FP_t) (const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>&);


extern "C" {

//-----------------------------------------------------------------------------------
// Function prototype
//-----------------------------------------------------------------------------------

///
/// @brief configure Cumulus inband address
///
/// @param[in] i_target => Processor chip target
///
/// @return FAPI_RC_SUCCESS if the setup completes successfully, else error
//
fapi2::ReturnCode p9c_set_inband_addr(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target);

} //extern"C"

#endif //_P9C_SET_INBAND_ADDR_H_
27 changes: 27 additions & 0 deletions src/import/chips/p9/procedures/hwp/nest/p9c_set_inband_addr.mk
@@ -0,0 +1,27 @@
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/import/chips/p9/procedures/hwp/nest/p9c_set_inband_addr.mk $
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2017
# [+] 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
PROCEDURE=p9c_set_inband_addr
OBJS+=p9_fbc_utils.o
$(call BUILD_PROCEDURE)
@@ -0,0 +1,54 @@
<!-- IBM_PROLOG_BEGIN_TAG -->
<!-- This is an automatically generated prolog. -->
<!-- -->
<!-- $Source: src/import/chips/p9/procedures/xml/attribute_info/p9c_set_inband_addr_attributes.xml $ -->
<!-- -->
<!-- OpenPOWER HostBoot Project -->
<!-- -->
<!-- Contributors Listed Below - COPYRIGHT 2017 -->
<!-- [+] 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 -->
<!--p9c_set_inband_addr_attributes.xml-->
<attributes>
<!-- ********************************************************************* -->
<attribute>
<id>ATTR_DMI_INBAND_BAR_ENABLE</id>
<targetType>TARGET_TYPE_DMI</targetType>
<description> DMI inband BAR enable.
Set by platform.
Used by p9c_set_inband_addr.
</description>
<valueType>uint8</valueType>
<enum>DISABLE = 0x0, ENABLE = 0x1</enum>
<platInit/>
<persistRuntime/>
</attribute>
<!-- ********************************************************************* -->
<attribute>
<id>ATTR_DMI_INBAND_BAR_BASE_ADDR_OFFSET</id>
<targetType>TARGET_TYPE_DMI</targetType>
<description> DMI inband BAR address offset (relative to chip MMIO origin).
Set by platform.
Used by p9c_set_inband_addr.
</description>
<valueType>uint64</valueType>
<platInit/>
<persistRuntime/>
</attribute>
<!-- ********************************************************************* -->

</attributes>

0 comments on commit 30e17cd

Please sign in to comment.