summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hwp/cache/p9_hcd_cache_poweron.C51
-rw-r--r--hwp/cache/p9_hcd_cache_poweron.H36
-rw-r--r--hwp/cache/wrapper/proc_cache_poweron_wrap.C224
-rw-r--r--hwp/core/p9_hcd_core_poweron.C55
-rw-r--r--hwp/core/p9_hcd_core_poweron.H31
-rw-r--r--hwp/core/wrapper/proc_core_poweron_wrap.C224
-rw-r--r--hwp/lib/p9_common_poweronoff.C419
-rw-r--r--hwp/lib/p9_common_poweronoff.H72
-rw-r--r--hwp/lib/p9_poweronoff_errors.xml107
-rw-r--r--hwp/lib/wrapper/proc_poweronoff_wrap.C227
10 files changed, 1312 insertions, 134 deletions
diff --git a/hwp/cache/p9_hcd_cache_poweron.C b/hwp/cache/p9_hcd_cache_poweron.C
index 167d0ffc..77d3589a 100644
--- a/hwp/cache/p9_hcd_cache_poweron.C
+++ b/hwp/cache/p9_hcd_cache_poweron.C
@@ -2,17 +2,17 @@
/// @file p9_hcd_cache_poweron.C
/// @brief Cache Chiplet Power-on
///
-/// *HWP HWP Owner : David Du <daviddu@us.ibm.com>
-/// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
-/// *HWP Team : PM
-/// *HWP Consumed by : SBE:SGPE
-/// *HWP Level : 1
-///
-/// Procedure Summary:
-/// Command the cache PFET controller to power-on
-/// Check for valid power on completion
-/// Polled Timeout: 100us
-///
+// *HWP HWP Owner : David Young <davidy@us.ibm.com>
+// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+// *HWP Team : PM
+// *HWP Consumed by : SBE:SGPE
+// *HWP Level : 2
+//
+// Procedure Summary:
+// Command the cache PFET controller to power-on
+// Check for valid power on completion
+// Polled Timeout: 100us
+//
//------------------------------------------------------------------------------
// Includes
@@ -29,32 +29,13 @@
//------------------------------------------------------------------------------
// Procedure: Cache Chiplet Power-on
//------------------------------------------------------------------------------
-
-extern "C"
-{
+#define FAPI_CLEANUP() fapi_try_exit:
fapi2::ReturnCode
p9_hcd_cache_poweron(
- const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target,
- const uint32_t i_operation)
+ const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target)
{
-
-#if 0
- fapi2::buffer<uint64_t> data;
-
- return fapi2::FAPI2_RC_SUCCESS;
-
- FAPI_CLEANUP();
- return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
-
-#endif
-
- return fapi2::FAPI2_RC_SUCCESS;
-
+ fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS;
+ FAPI_EXEC_HWP(l_rc, p9_common_poweronoff, i_target, p9power::POWER_ON);
+ return l_rc;
} // Procedure
-
-
-} // extern C
-
-
-
diff --git a/hwp/cache/p9_hcd_cache_poweron.H b/hwp/cache/p9_hcd_cache_poweron.H
index 43376111..1f7143a1 100644
--- a/hwp/cache/p9_hcd_cache_poweron.H
+++ b/hwp/cache/p9_hcd_cache_poweron.H
@@ -1,42 +1,38 @@
///
/// @file p9_hcd_cache_poweron.H
/// @brief Cache Chiplet Power-on
-///
-/// *HWP HWP Owner : David Du <daviddu@us.ibm.com>
-/// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
-/// *HWP Team : PM
-/// *HWP Consumed by : SBE:SGPE
-/// *HWP Level : 1
-///
+
+//
+// *HWP HWP Owner : David Young <davidy@us.ibm.com>
+// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+// *HWP Team : PM
+// *HWP Level : 2
+// *HWP Consumed by : SBE:SGPE
+//
#ifndef __P9_HCD_CACHE_POWERON_H__
#define __P9_HCD_CACHE_POWERON_H__
-extern "C"
-{
+#include "p9_common_poweronoff.H"
/// @typedef p9_hcd_cache_poweron_FP_t
/// function pointer typedef definition for HWP call support
typedef fapi2::ReturnCode (*p9_hcd_cache_poweron_FP_t) (
- const fapi2::Target<fapi2::TARGET_TYPE_EQ>&,
- const uint32_t);
-
+ const fapi2::Target<fapi2::TARGET_TYPE_EQ>&);
+extern "C"
+{
/// @brief Cache Chiplet Power-on
-///
/// @param [in] i_target TARGET_TYPE_EQ target
/// @param [in] i_operation ENUM(ON,OFF)
///
/// @attr
/// @attritem ATTR_PFET_*
///
-/// @retval FAPI_RC_SUCCESS
+/// @retval FAPI2_RC_SUCCESS if success, else error code
+
fapi2::ReturnCode
p9_hcd_cache_poweron(
- const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target,
- const uint32_t i_operation);
-
-
-} // extern C
-
+ const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target);
+}
#endif // __P9_HCD_CACHE_POWERON_H__
diff --git a/hwp/cache/wrapper/proc_cache_poweron_wrap.C b/hwp/cache/wrapper/proc_cache_poweron_wrap.C
new file mode 100644
index 00000000..9ac22a4e
--- /dev/null
+++ b/hwp/cache/wrapper/proc_cache_poweron_wrap.C
@@ -0,0 +1,224 @@
+// ----------------------------------------------------------------------
+// Includes / eCMD Includes
+// ----------------------------------------------------------------------
+#include <prcdUtils.H>
+
+#include <croClientCapi.H>
+#include <ecmdClientCapi.H>
+#include <ecmdUtils.H>
+#include <ecmdSharedUtils.H>
+#include <fapi2.H>
+#include <fapi2ClientCapi.H>
+#include <fapi2SharedUtils.H>
+
+#include <string>
+#include <sstream>
+
+#include <p9_hcd_cache_poweron.H>
+
+
+// ----------------------------------------------------------------------
+// Function definitions
+// ----------------------------------------------------------------------
+
+// display help message
+void help()
+{
+ // procedure constants
+ const std::string PROCEDURE = "p9_hcd_cache_poweron_wrap";
+ const std::string REVISION = "$Revision: 1.1 $";
+ // build help message
+ char outstr[200];
+ snprintf(outstr, sizeof(outstr), "\nThis is the help text for the procedure %s (%s)\n", PROCEDURE.c_str(), REVISION.c_str());
+ ecmdOutput(outstr);
+ snprintf(outstr, sizeof(outstr), "Syntax: %s\n", PROCEDURE.c_str());
+ ecmdOutput(outstr);
+ ecmdOutput(" [-h] [-k#] [-n#] [-s#] [-p#] [-verif]\n");
+ ecmdOutput("\n");
+ ecmdOutput("Additional options:\n");
+ ecmdOutput(" -h This help\n");
+ ecmdOutput("\n");
+}
+
+
+// main function
+int main(int argc, char *argv[])
+{
+ // procedure constants
+ const std::string PROCEDURE = "p9_hcd_cache_poweron_wrap";
+ const std::string REVISION = "$Revision: 1.1 $";
+
+ // from prcdUtils
+ extern bool GLOBAL_SIM_MODE;
+ extern bool GLOBAL_VERIF_MODE;
+
+ // flow/control variables
+ uint32_t rc = ECMD_SUCCESS;
+ ecmdDllInfo DLLINFO;
+ ecmdLooperData looper;
+ ecmdChipTarget target;
+ bool valid_pos_found = false;
+ char outstr[200];
+
+ fapi2::ReturnCode rc_fapi(fapi2::FAPI2_RC_SUCCESS);
+
+
+ //-----------------------------------------------------------------------------------------
+ // load and initialize the eCMD Dll
+ // if left NULL, which DLL to load is determined by the ECMD_DLL_FILE environment variable
+ // if set to a specific value, the specified DLL will be loaded
+ //-----------------------------------------------------------------------------------------
+ rc = ecmdLoadDll("");
+ if (rc) return rc;
+
+ //-----------------------------------------------------------------------------------------
+ // This is needed if you're running a FAPI procedure from this eCMD procedure
+ //-----------------------------------------------------------------------------------------
+
+ // initalize FAPI2 extension
+ rc = fapi2InitExtension();
+ if (rc)
+ {
+ ecmdOutputError("Error initializing FAPI2 extension!\n");
+ return rc;
+ }
+
+
+
+ // establish if this is a simulation run or not
+ rc = ecmdQueryDllInfo(DLLINFO);
+ if (rc)
+ {
+ ecmdUnloadDll();
+ return rc;
+ }
+ if (DLLINFO.dllEnv == ECMD_DLL_ENV_SIM)
+ {
+ GLOBAL_SIM_MODE = true;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Parse out user options (excluding -pX, -cX, -coe, -debug, etc
+ // E.G., ecmdRunHwp.x86 -testmode
+ //-------------------------------------------------------------------------------------------------
+ if (ecmdParseOption(&argc, &argv, "-h"))
+ {
+ help();
+ ecmdUnloadDll();
+ return rc;
+ }
+
+
+ // run procedure in sim verification mode
+ if (ecmdParseOption(&argc, &argv, "-verif"))
+ {
+ GLOBAL_VERIF_MODE = true;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Parse out common eCMD args like -p0, -c0, -coe, etc..
+ // Any found args will be removed from arg list upon return
+ //-------------------------------------------------------------------------------------------------
+ rc = ecmdCommandArgs(&argc, &argv);
+ if (rc)
+ {
+ ecmdUnloadDll();
+ return rc;
+ }
+
+ // unsupported arguments left over?
+ if (argc != 1)
+ {
+ ecmdOutputError("Unknown/unsupported arguments specified!\n");
+ help();
+ ecmdUnloadDll();
+ return ECMD_INVALID_ARGS;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Let's always print the dll info to the screen, unless in quiet mode
+ //-------------------------------------------------------------------------------------------------
+
+ if (!ecmdGetGlobalVar(ECMD_GLOBALVAR_QUIETMODE))
+ {
+ // print informational message
+ snprintf(outstr, sizeof(outstr), "Procedure %s: %s\n", PROCEDURE.c_str(), REVISION.c_str());
+ ecmdOutput(outstr);
+
+ // always print the DLL info to the screen, unless in quiet mode
+ rc = ecmdDisplayDllInfo();
+ if (rc)
+ {
+ return rc;
+ }
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Loop over all all pu chips
+ //-------------------------------------------------------------------------------------------------
+ target.chipType = "pu";
+ target.chipTypeState = ECMD_TARGET_FIELD_VALID;
+ target.cageState = ECMD_TARGET_FIELD_WILDCARD;
+ target.nodeState = ECMD_TARGET_FIELD_WILDCARD;
+ target.slotState = ECMD_TARGET_FIELD_WILDCARD;
+ target.posState = ECMD_TARGET_FIELD_WILDCARD;
+ target.coreState = ECMD_TARGET_FIELD_UNUSED;
+ target.threadState = ECMD_TARGET_FIELD_UNUSED;
+
+ rc = ecmdConfigLooperInit(target, ECMD_SELECTED_TARGETS_LOOP, looper);
+ if (rc)
+ {
+ ecmdOutputError("Error initializing proc chip looper!\n");
+ ecmdUnloadDll();
+ return rc;
+ }
+ while (ecmdConfigLooperNext(target, looper))
+ {
+ if (!ecmdGetGlobalVar(ECMD_GLOBALVAR_QUIETMODE))
+ {
+ snprintf(outstr, sizeof(outstr),
+ "Going to call %s on proc k%d:n%d:s%d:p%02d\n",
+ PROCEDURE.c_str(), target.cage, target.node,
+ target.slot, target.pos);
+ ecmdOutput(outstr);
+ }
+
+ // EXAMPLE setting up a fapi2::Target from an ecmdChipTarget
+ fapi2::Target<fapi2::TARGET_TYPE_EQ> fapi_target(&target);
+
+ // invoke FAPI procedure core
+ FAPI_EXEC_HWP(rc_fapi, p9_hcd_cache_poweron, fapi_target);
+ rc = (uint64_t) rc_fapi;
+ if (rc)
+ {
+ snprintf(outstr, sizeof(outstr),
+ "ERROR: %s FAPI call exited with return code = %s 0x%08x \n",
+ PROCEDURE.c_str(), ecmdParseReturnCode(rc).c_str(), rc);
+ ecmdOutputError(outstr);
+ ecmdUnloadDll();
+ return rc;
+ }
+
+ // mark that valid position has been found
+ valid_pos_found = true;
+ }
+
+ // check that a valid target was found
+ if (rc == ECMD_SUCCESS && !valid_pos_found)
+ {
+ ecmdOutputError("No valid targets found!\n");
+ ecmdUnloadDll();
+ return ECMD_TARGET_NOT_CONFIGURED;
+ }
+
+ prcdInfoMessage("----------------------------------------\n");
+ prcdInfoMessage(" p9_hcd_cache_poweron is done\n");
+ prcdInfoMessage("----------------------------------------\n");
+
+ //-----------------------------------------------------------------------------------------------
+ // Unload the eCMD Dll, this should always be the last thing you do
+ //-----------------------------------------------------------------------------------------------
+
+ ecmdUnloadDll();
+ return rc;
+}
diff --git a/hwp/core/p9_hcd_core_poweron.C b/hwp/core/p9_hcd_core_poweron.C
index 0f5701af..c6aeab69 100644
--- a/hwp/core/p9_hcd_core_poweron.C
+++ b/hwp/core/p9_hcd_core_poweron.C
@@ -2,25 +2,26 @@
/// @file p9_hcd_core_poweron.C
/// @brief Core Chiplet Power-on
///
-/// *HWP HWP Owner : David Du <daviddu@us.ibm.com>
-/// *HWP FW Owner : Reshmi Nair <resnair5@in.ibm.com>
-/// *HWP Team : PM
-/// *HWP Consumed by : SBE:CME
-/// *HWP Level : 1
-///
-/// Procedure Summary:
-/// 1.Command the core PFET controller to power-on, via putscom to CPPM
-/// -
-/// 2.Check for valid power on completion, via getscom from CPPM
-/// Polled Timeout: 100us
-///
+// *HWP HWP Owner : David Young <davidy@us.ibm.com>
+// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+// *HWP Team : PM
+// *HWP Consumed by : SBE:CME
+// *HWP Level : 2
+//
+// Procedure Summary:
+// 1.Command the core PFET controller to power-on, via putscom to CPPM
+// 2.Check for valid power on completion, via getscom from CPPM
+// Polled Timeout: 100us
+//
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <fapi2.H>
-//#include <common_scom_addresses.H>
+#if 0
+#include <common_scom_addresses.H>
//will be replaced with real scom address header file
+#endif
#include "p9_hcd_core_poweron.H"
//-----------------------------------------------------------------------------
@@ -31,30 +32,14 @@
// Procedure: Core Chiplet Power-on
//-----------------------------------------------------------------------------
-extern "C"
-{
+#define FAPI_CLEANUP() fapi_try_exit:
+#define FAPI_GOTO_EXIT() goto fapi_try_exit;
fapi2::ReturnCode
p9_hcd_core_poweron(
- const fapi2::Target<fapi2::TARGET_TYPE_CORE>& i_target,
- const uint32_t i_operation)
+ const fapi2::Target<fapi2::TARGET_TYPE_CORE>& i_target)
{
-
-#if 0
-
- fapi2::buffer<uint64_t> data;
-
- return fapi2::FAPI2_RC_SUCCESS;
-
- FAPI_CLEANUP();
- return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
-
-#endif
-
- return fapi2::FAPI2_RC_SUCCESS;
-
+ fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS;
+ FAPI_EXEC_HWP(l_rc, p9_common_poweronoff, i_target, p9power::POWER_ON_VDD);
+ return l_rc;
} // Procedure
-
-
-} // extern C
-
diff --git a/hwp/core/p9_hcd_core_poweron.H b/hwp/core/p9_hcd_core_poweron.H
index 5f475fbb..c98d8821 100644
--- a/hwp/core/p9_hcd_core_poweron.H
+++ b/hwp/core/p9_hcd_core_poweron.H
@@ -2,27 +2,26 @@
/// @file p9_hcd_core_poweron.H
/// @brief Core Chiplet Power-on
///
-/// *HWP HWP Owner : David Du <daviddu@us.ibm.com>
-/// *HWP FW Owner : Reshmi Nair <resnair5@in.ibm.com>
-/// *HWP Team : PM
-/// *HWP Consumed by : SBE:CME
-/// *HWP Level : 1
-///
+// *HWP HWP Owner : David Young <daviddu@us.ibm.com>
+// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+// *HWP Team : PM
+// *HWP Consumed by : SBE:CME
+// *HWP Level : 2
+//
#ifndef __P9_HCD_CORE_POWERON_H__
#define __P9_HCD_CORE_POWERON_H__
-extern "C"
-{
+#include "p9_common_poweronoff.H"
/// @typedef p9_hcd_core_poweron_FP_t
/// function pointer typedef definition for HWP call support
typedef fapi2::ReturnCode (*p9_hcd_core_poweron_FP_t) (
- const fapi2::Target<fapi2::TARGET_TYPE_CORE>&,
- const uint32_t);
-
+ const fapi2::Target<fapi2::TARGET_TYPE_CORE>&);
+extern "C"
+{
/// @brief Core Chiplet Power-on
///
/// @param [in] i_target TARGET_TYPE_CORE target
@@ -31,13 +30,9 @@ typedef fapi2::ReturnCode (*p9_hcd_core_poweron_FP_t) (
/// @attr
/// @attritem ATTR_PFET_*
///
-/// @retval FAPI_RC_SUCCESS
+/// @retval FAPI2_RC_SUCCESS if success, else error code
fapi2::ReturnCode
p9_hcd_core_poweron(
- const fapi2::Target<fapi2::TARGET_TYPE_CORE>& i_target,
- const uint32_t i_operation);
-
-
-} // extern C
-
+ const fapi2::Target<fapi2::TARGET_TYPE_CORE>& i_target);
+}
#endif // __P9_HCD_CORE_POWERON_H__
diff --git a/hwp/core/wrapper/proc_core_poweron_wrap.C b/hwp/core/wrapper/proc_core_poweron_wrap.C
new file mode 100644
index 00000000..bc176809
--- /dev/null
+++ b/hwp/core/wrapper/proc_core_poweron_wrap.C
@@ -0,0 +1,224 @@
+// ----------------------------------------------------------------------
+// Includes / eCMD Includes
+// ----------------------------------------------------------------------
+#include <prcdUtils.H>
+
+#include <croClientCapi.H>
+#include <ecmdClientCapi.H>
+#include <ecmdUtils.H>
+#include <ecmdSharedUtils.H>
+#include <fapi2.H>
+#include <fapi2ClientCapi.H>
+#include <fapi2SharedUtils.H>
+
+#include <string>
+#include <sstream>
+
+#include <p9_hcd_core_poweron.H>
+
+
+// ----------------------------------------------------------------------
+// Function definitions
+// ----------------------------------------------------------------------
+
+// display help message
+void help()
+{
+ // procedure constants
+ const std::string PROCEDURE = "p9_hcd_core_poweron_wrap";
+ const std::string REVISION = "$Revision: 1.1 $";
+ // build help message
+ char outstr[200];
+ snprintf(outstr, sizeof(outstr), "\nThis is the help text for the procedure %s (%s)\n", PROCEDURE.c_str(), REVISION.c_str());
+ ecmdOutput(outstr);
+ snprintf(outstr, sizeof(outstr), "Syntax: %s\n", PROCEDURE.c_str());
+ ecmdOutput(outstr);
+ ecmdOutput(" [-h] [-k#] [-n#] [-s#] [-p#] [-verif]\n");
+ ecmdOutput("\n");
+ ecmdOutput("Additional options:\n");
+ ecmdOutput(" -h This help\n");
+ ecmdOutput("\n");
+}
+
+
+// main function
+int main(int argc, char *argv[])
+{
+ // procedure constants
+ const std::string PROCEDURE = "p9_hcd_core_poweron_wrap";
+ const std::string REVISION = "$Revision: 1.1 $";
+
+ // from prcdUtils
+ extern bool GLOBAL_SIM_MODE;
+ extern bool GLOBAL_VERIF_MODE;
+
+ // flow/control variables
+ uint32_t rc = ECMD_SUCCESS;
+ ecmdDllInfo DLLINFO;
+ ecmdLooperData looper;
+ ecmdChipTarget target;
+ bool valid_pos_found = false;
+ char outstr[200];
+
+ fapi2::ReturnCode rc_fapi(fapi2::FAPI2_RC_SUCCESS);
+
+
+ //-----------------------------------------------------------------------------------------
+ // load and initialize the eCMD Dll
+ // if left NULL, which DLL to load is determined by the ECMD_DLL_FILE environment variable
+ // if set to a specific value, the specified DLL will be loaded
+ //-----------------------------------------------------------------------------------------
+ rc = ecmdLoadDll("");
+ if (rc) return rc;
+
+ //-----------------------------------------------------------------------------------------
+ // This is needed if you're running a FAPI procedure from this eCMD procedure
+ //-----------------------------------------------------------------------------------------
+
+ // initalize FAPI2 extension
+ rc = fapi2InitExtension();
+ if (rc)
+ {
+ ecmdOutputError("Error initializing FAPI2 extension!\n");
+ return rc;
+ }
+
+
+
+ // establish if this is a simulation run or not
+ rc = ecmdQueryDllInfo(DLLINFO);
+ if (rc)
+ {
+ ecmdUnloadDll();
+ return rc;
+ }
+ if (DLLINFO.dllEnv == ECMD_DLL_ENV_SIM)
+ {
+ GLOBAL_SIM_MODE = true;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Parse out user options (excluding -pX, -cX, -coe, -debug, etc
+ // E.G., ecmdRunHwp.x86 -testmode
+ //-------------------------------------------------------------------------------------------------
+ if (ecmdParseOption(&argc, &argv, "-h"))
+ {
+ help();
+ ecmdUnloadDll();
+ return rc;
+ }
+
+
+ // run procedure in sim verification mode
+ if (ecmdParseOption(&argc, &argv, "-verif"))
+ {
+ GLOBAL_VERIF_MODE = true;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Parse out common eCMD args like -p0, -c0, -coe, etc..
+ // Any found args will be removed from arg list upon return
+ //-------------------------------------------------------------------------------------------------
+ rc = ecmdCommandArgs(&argc, &argv);
+ if (rc)
+ {
+ ecmdUnloadDll();
+ return rc;
+ }
+
+ // unsupported arguments left over?
+ if (argc != 1)
+ {
+ ecmdOutputError("Unknown/unsupported arguments specified!\n");
+ help();
+ ecmdUnloadDll();
+ return ECMD_INVALID_ARGS;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Let's always print the dll info to the screen, unless in quiet mode
+ //-------------------------------------------------------------------------------------------------
+
+ if (!ecmdGetGlobalVar(ECMD_GLOBALVAR_QUIETMODE))
+ {
+ // print informational message
+ snprintf(outstr, sizeof(outstr), "Procedure %s: %s\n", PROCEDURE.c_str(), REVISION.c_str());
+ ecmdOutput(outstr);
+
+ // always print the DLL info to the screen, unless in quiet mode
+ rc = ecmdDisplayDllInfo();
+ if (rc)
+ {
+ return rc;
+ }
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Loop over all all pu chips
+ //-------------------------------------------------------------------------------------------------
+ target.chipType = "pu";
+ target.chipTypeState = ECMD_TARGET_FIELD_VALID;
+ target.cageState = ECMD_TARGET_FIELD_WILDCARD;
+ target.nodeState = ECMD_TARGET_FIELD_WILDCARD;
+ target.slotState = ECMD_TARGET_FIELD_WILDCARD;
+ target.posState = ECMD_TARGET_FIELD_WILDCARD;
+ target.coreState = ECMD_TARGET_FIELD_UNUSED;
+ target.threadState = ECMD_TARGET_FIELD_UNUSED;
+
+ rc = ecmdConfigLooperInit(target, ECMD_SELECTED_TARGETS_LOOP, looper);
+ if (rc)
+ {
+ ecmdOutputError("Error initializing proc chip looper!\n");
+ ecmdUnloadDll();
+ return rc;
+ }
+ while (ecmdConfigLooperNext(target, looper))
+ {
+ if (!ecmdGetGlobalVar(ECMD_GLOBALVAR_QUIETMODE))
+ {
+ snprintf(outstr, sizeof(outstr),
+ "Going to call %s on proc k%d:n%d:s%d:p%02d\n",
+ PROCEDURE.c_str(), target.cage, target.node,
+ target.slot, target.pos);
+ ecmdOutput(outstr);
+ }
+
+ // EXAMPLE setting up a fapi2::Target from an ecmdChipTarget
+ fapi2::Target<fapi2::TARGET_TYPE_CORE> fapi_target(&target);
+
+ // invoke FAPI procedure core
+ FAPI_EXEC_HWP(rc_fapi, p9_hcd_core_poweron, fapi_target);
+ rc = (uint64_t) rc_fapi;
+ if (rc)
+ {
+ snprintf(outstr, sizeof(outstr),
+ "ERROR: %s FAPI call exited with return code = %s 0x%08x \n",
+ PROCEDURE.c_str(), ecmdParseReturnCode(rc).c_str(), rc);
+ ecmdOutputError(outstr);
+ ecmdUnloadDll();
+ return rc;
+ }
+
+ // mark that valid position has been found
+ valid_pos_found = true;
+ }
+
+ // check that a valid target was found
+ if (rc == ECMD_SUCCESS && !valid_pos_found)
+ {
+ ecmdOutputError("No valid targets found!\n");
+ ecmdUnloadDll();
+ return ECMD_TARGET_NOT_CONFIGURED;
+ }
+
+ prcdInfoMessage("----------------------------------------\n");
+ prcdInfoMessage(" p9_hcd_core_poweron is done\n");
+ prcdInfoMessage("----------------------------------------\n");
+
+ //-----------------------------------------------------------------------------------------------
+ // Unload the eCMD Dll, this should always be the last thing you do
+ //-----------------------------------------------------------------------------------------------
+
+ ecmdUnloadDll();
+ return rc;
+}
diff --git a/hwp/lib/p9_common_poweronoff.C b/hwp/lib/p9_common_poweronoff.C
index 6ebcf054..963ef37b 100644
--- a/hwp/lib/p9_common_poweronoff.C
+++ b/hwp/lib/p9_common_poweronoff.C
@@ -2,46 +2,433 @@
/// @file p9_common_poweronoff.C
/// @brief common procedure for power on/off
///
-/// *HWP HWP Owner : David Du <daviddu@us.ibm.com>
-/// *HWP FW Owner : Reshmi Nair <resnair5@in.ibm.com>
-/// *HWP Team : PM
-/// *HWP Consumed by : SBE:SGPE:CME
-/// *HWP Level : 1
-///
-/// Procedure Summary:
-///
+// *HWP HWP Owner : David Young <davidy@us.ibm.com>
+// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+// *HWP Team : PM
+// *HWP Consumed by : SBE:SGPE:CME
+// *HWP Level : 2
+//
+// Procedure Summary:
+//
//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <fapi2.H>
-//#include <common_scom_addresses.H>
+
+#if 0
+#include <common_scom_addresses.H>
//will be replaced with real scom address header file
+#endif
#include "p9_common_poweronoff.H"
//------------------------------------------------------------------------------
// Constant Definitions:
//------------------------------------------------------------------------------
+enum { CYCLES_PER_MS = 500000,
+ INST_PER_LOOP = 8,
+ PFET_STATE_LENGTH = 2,
+ VXX_PG_SEL_LEN = 4};
+
+enum pfetRegField { PFET_NOP=0,
+ PFET_FORCE_VOFF=1,
+ PFET_NOP_RESERVERD=2,
+ PFET_FORCE_VON=3};
+
+enum pgStateOffset { PG_STATE_IDLE_OFFSET=0,
+ PG_STATE_INC_OFFSET=1,
+ PG_STATE_DEC_OFFSET=2,
+ PG_STATE_WAIT_OFFSET=3};
+
+
+enum PFCS_Bits { VDD_PFET_FORCE_STATE_BIT=0,
+ VCS_PFET_FORCE_STATE_BIT=2,
+ VDD_PFET_VAL_OVERRIDE_BIT=4,
+ VDD_PFET_SEL_OVERRIDE_BIT=5,
+ VCS_PFET_VAL_OVERRIDE_BIT=6,
+ VCS_PFET_SEL_OVERRIDE_BIT=7,
+ VDD_PFET_REGULATION_FINGER_EN_BIT=8,
+ VDD_PFET_REGULATION_FINGER_VALUE_BIT=9,
+ RESERVED1_BIT=10,
+ VDD_PFET_ENABLE_VALUE_BIT=12,
+ VDD_PFET_SEL_VALUE_BIT=20,
+ VCS_PFET_ENABLE_VALUE_BIT=24,
+ VCS_PFET_SEL_VALUE_BIT=32,
+ RESERVED2_BIT=36,
+ VDD_PG_STATE_BIT=42,
+ VDD_PG_SEL_BIT=46,
+ VCS_PG_STATE_BIT=50,
+ VCS_PG_SEL_BIT=54,
+ RESERVED3_BIT=58
+};
+
+
+enum { VDD_PFETS_ENABLED_SENSE_BIT=0,
+ VDD_PFETS_DISABLED_SENSE_BIT=1,
+ VCS_PFETS_ENABLED_SENSE_BIT=2,
+ VCS_PFETS_DISABLED_SENSE_BIT=3
+};
+
+enum { POWDN_DLY_BIT=0,
+ POWUP_DLY_BIT=4,
+ TP_VDD_PFET_ENABLE_ACTUAL_BIT=16,
+ TP_VCS_PFET_ENABLE_ACTUAL_BIT=24
+};
+
+enum { POWDN_DLY_LENGTH=4,
+ POWUP_DLY_LENGTH=4,
+ TP_VDD_PFET_ENABLE_ACTUAL_LENGTH=8,
+ TP_VCS_PFET_ENABLE_ACTUAL_LENGTH=8};
+
+// i_operation defines
+
+
+#define FAPI_CLEANUP() fapi_try_exit:
+#define FAPI_GOTO_EXIT() goto fapi_try_exit;
//------------------------------------------------------------------------------
// Procedure:
//------------------------------------------------------------------------------
-extern "C"
-{
-
+#if OR_TARGET_ENABLED // Cronus may not support
+ // fapi2::TARGET_TYPE_EQ|fapi2::TARGET_TYPE_CORE
fapi2::ReturnCode
p9_common_poweronoff(
const fapi2::Target<fapi2::TARGET_TYPE_EQ|
fapi2::TARGET_TYPE_CORE>& i_target,
- int i_operation)
+ const p9power::powerOperation_t i_operation)
+#else
+fapi2::ReturnCode
+p9_common_poweronoff(
+ const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target,
+ const p9power::powerOperation_t i_operation)
+
+#endif
+
+
{
- return fapi2::FAPI2_RC_SUCCESS;
+ uint32_t l_loopsPerMs;
+ FAPI_INF(">>p9_common_poweronoff: %d", i_operation);
-} // Procedure
+ fapi2::buffer<uint64_t> l_data;
+ fapi2::buffer<uint64_t> l_temp; // extractToRight seems the require space to write into.
+ ///////////////////////////////////////////////////////////////////////////
+ // lambda functions for poweronoff procedure
+ ///////////////////////////////////////////////////////////////////////////
+ auto pollVddFSMIdle = [&] ()
+ {
+ // Poll for PFETCNTLSTAT_REG[VDD_PG_STATE] for 0b1000 (FSM idle)
+ // – Timeout value = 1ms
+ FAPI_DBG("Polling for power gate sequencer state: FSM idle");
+ l_loopsPerMs = CYCLES_PER_MS/INST_PER_LOOP;
+ // Note that the Lamda assumes that l_data already contains the
+ do
+ {
+ FAPI_TRY(fapi2::getScom(i_target, PPM_PFCS, l_data),
+ "getScom failed for address PPM_PFCS"); // poll
+ } while ((l_data.getBit<VDD_PG_STATE_BIT+PG_STATE_IDLE_OFFSET>()
+ != 0 ) && (--l_loopsPerMs != 0));
+ FAPI_ASSERT((l_loopsPerMs != 0),
+ fapi2::PMPROC_PFETLIB_TIMEOUT()
+ .set_ADDRESS(PPM_PFCS),
+ "VDD FSM idle timeout");
+
+ /// (Optional) Check PFETCNTLSTAT_REG[VDD_PG_SEL]being 0x8
+ // (Off encode point)
+#if 0 // this field does not get set yet
+ l_data.extractToRight<VDD_PG_SEL_BIT, VXX_PG_SEL_LEN>(l_temp);
+ FAPI_ASSERT((l_temp == 8),
+ fapi2::PROCPM_PFET_CODE_BAD_MODE(),
+ "VDD_PG_SEL != 8: l_temp %0x", l_temp);
+
+#endif
+ // fapi2::current_err will be initialized with FAPI2_RC_SUCCESS
+ FAPI_CLEANUP()
+ return static_cast<fapi2::ReturnCode>(fapi2::current_err);
+ };
+
+ auto pollVcsFSMIdle = [&] ()
+ {
+ // Poll for PFETCNTLSTAT_REG[VDD_PG_STATE] for 0b1000 (FSM idle)
+ // – Timeout value = 1ms
+ FAPI_DBG("Polling for power gate sequencer state: FSM idle");
+ l_loopsPerMs = CYCLES_PER_MS/INST_PER_LOOP;
+
+ do
+ {
+ FAPI_TRY(fapi2::getScom(i_target, PPM_PFCS, l_data),
+ "getScom failed for address PPM_PFCS"); // poll
+ FAPI_DBG("timeout l_loopsPerMs. %x", l_loopsPerMs);
+ } while ((l_data.getBit<VCS_PG_STATE_BIT+PG_STATE_IDLE_OFFSET>()
+ != 0 ) && (--l_loopsPerMs != 0));
+ FAPI_ASSERT((l_loopsPerMs != 0),
+ fapi2::PMPROC_PFETLIB_TIMEOUT()
+ .set_ADDRESS(PPM_PFCS),
+ "VCS FSM idle timeout");
+
+ // (Optional) Check PFETCNTLSTAT_REG[VDD_PG_SEL]
+ // being 0x8 (Off encode point)
+
+
+#if 0 // this field does not get set yet
+ l_data.extractToRight<VCS_PG_SEL_BIT, VXX_PG_SEL_LEN>(l_temp);
+ FAPI_ASSERT((l_temp == 8),
+ fapi2::PROCPM_PFET_CODE_BAD_MODE(),
+ "VCS_PG_SEL != 8: l_temp %0x", l_temp);
+
+#endif
+ // fapi2::current_err will be initialized with FAPI2_RC_SUCCESS
+ FAPI_CLEANUP()
+ return static_cast<fapi2::ReturnCode>(fapi2::current_err);
+
+ };
+
+
+ auto powerOnVdd = [&] ()
+ {
+ // Command the cache PFET controller to power-on
+
+ // Write PFETCNTLSTAT_REG:
+ // vdd_pfet_force_state = 11 (Force Von)
+ // vdd_pfet_val_override = 0 (Override disabled)
+ // vdd_pfet_sel_override = 0 (Override disabled)
+ // vdd_pfet_enable_regulation_finger = 0
+ // (Regulation finger controlled by FSM)
+ FAPI_DBG("Force VDD on");
+ FAPI_DBG("Clear VDD PFET stage select and value override bits");
+ l_data.flush<0>().insertFromRight
+ <VDD_PFET_FORCE_STATE_BIT, PFET_STATE_LENGTH>(PFET_FORCE_VON).
+ clearBit<VDD_PFET_VAL_OVERRIDE_BIT>().
+ clearBit<VDD_PFET_SEL_OVERRIDE_BIT>();
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS, l_data),
+ "putScom failed for address PPM_PFCS");
+ FAPI_TRY(pollVddFSMIdle());
-} // extern C
+ // Write PFETCNTLSTAT_REG_WCLEAR
+ // vdd_pfet_force_state = 00 (No Operation);
+ // all fields set to 1 for WAND
+ // Use PPM_PFCS_CLR,
+ // vdd_pfet_force_state = 0b11
+ FAPI_DBG("vdd_pfet_force_state = 00, or Idle");
+ l_data.flush<0>().insertFromRight
+ <VDD_PFET_FORCE_STATE_BIT, PFET_STATE_LENGTH>(~PFET_NOP);
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_CLR, l_data),
+ "putScom failed for address PPM_PFCS_CLR");
+ // fapi2::current_err will be initialized with FAPI2_RC_SUCCESS
+ FAPI_CLEANUP()
+ return static_cast<fapi2::ReturnCode>(fapi2::current_err);
+ };
+
+ auto powerOnVcs = [&] ()
+ {
+ FAPI_DBG("Force VSS on");
+ FAPI_DBG("Clear VSS PFET stage select and value override bits");
+
+ // Command the PFET controller to power-on
+ // Write PFETCNTLSTAT_REG_OR with values defined below
+ // vcs_pfet_force_state = 11 (Force Von)
+ // Write to PFETCNTLSTAT_REG_CLR
+ // vcs_pfet_val_override = 0 (Override disabled)
+ // vcs_pfet_sel_override = 0 (Override disabled)
+ // vcs_pfet_enable_regulation_finger = 0
+ // (Regulation finger controlled by FSM)
+ l_data.flush<0>().insertFromRight
+ <VCS_PFET_FORCE_STATE_BIT, PFET_STATE_LENGTH>(PFET_FORCE_VON);
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_OR, l_data),
+ "putScom failed for address PPM_PFCS_OR");
+
+ l_data.flush<0>().
+ setBit<VCS_PFET_VAL_OVERRIDE_BIT>().
+ setBit<VCS_PFET_SEL_OVERRIDE_BIT>();
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_CLR, l_data),
+ "putScom failed for address PPM_PFCS_CLR");
+
+ // Check for valid power on completion
+ // Polled Timeout: 100us
+ FAPI_TRY(pollVcsFSMIdle());
+
+ // Write PFETCNTLSTAT_REG_WCLEAR
+ // vcs_pfet_force_state = 00 (No Operation);
+ // all fields set to 1 for WAND
+ // Use PPM_PFCS_CLR, vdd_pfet_force_state = ~(0b00)
+ FAPI_DBG("vss_pfet_force_state = 00, or Idle");
+ l_data.flush<0>().insertFromRight
+ <VCS_PFET_FORCE_STATE_BIT, PFET_STATE_LENGTH>(~PFET_NOP);
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_CLR, l_data),
+ "putScom failed for address PPM_PFCS_CLR");
+
+ // fapi2::current_err will be initialized with FAPI2_RC_SUCCESS
+ FAPI_CLEANUP()
+ return static_cast<fapi2::ReturnCode>(fapi2::current_err);
+ };
+
+ auto powerOffVdd = [&] ()
+ {
+ // Command the PFET controller to power-off
+ // Write PFETCNTLSTAT_REG:
+ // vdd_pfet_force_state = 01 (Force Voff)
+ // vdd_pfet_val_override = 0 (Override disabled)
+ // vdd_pfet_sel_override = 0 (Override disabled)
+ // vdd_pfet_enable_regulation_finger = 0
+ // (Regulation finger controlled by FSM)
+ FAPI_DBG("Force VDD off");
+ FAPI_DBG("Clear VDD PFET stage select and value override bits");
+ l_data.flush<0>().insertFromRight
+ <VDD_PFET_FORCE_STATE_BIT, PFET_STATE_LENGTH>(PFET_FORCE_VOFF).
+ clearBit<VDD_PFET_VAL_OVERRIDE_BIT>().
+ clearBit<VDD_PFET_SEL_OVERRIDE_BIT>();
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS, l_data),
+ "putScom failed for address PPM_PFCS");
+
+ FAPI_TRY(pollVddFSMIdle());
+
+ // Write PFETCNTLSTAT_REG_WCLEAR
+ // vdd_pfet_force_state = 00 (No Operation);
+ // all fields set to 1 for WAND
+ // Use PPM_PFCS_CLR, vdd_pfet_force_state = 0b11
+ FAPI_DBG("vdd_pfet_force_state = 00, or Idle");
+ l_data.flush<0>().insertFromRight
+ <VDD_PFET_FORCE_STATE_BIT, PFET_STATE_LENGTH>(~PFET_NOP);
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_CLR, l_data),
+ "putScom failed for address PPM_PFCS_CLR");
+
+ // fapi2::current_err will be initialized with FAPI2_RC_SUCCESS
+ FAPI_CLEANUP()
+ return static_cast<fapi2::ReturnCode>(fapi2::current_err);
+ };
+
+ auto powerOffVcs = [&] ()
+ {
+ // Command the PFET controller to power-off
+ FAPI_DBG("Force VSS off");
+ FAPI_DBG("Clear VSS PFET stage select and value override bits");
+
+ // Write PFETCNTLSTAT_REG_OR with values defined below
+ // vcs_pfet_force_state = 11 (Force Voff)
+ // DOC BUG: ?? Write to PFETCNTLSTAT_REG_CLR
+ // vcs_pfet_val_override = 0 (Override disabled)
+ // vcs_pfet_sel_override = 0 (Override disabled)
+ // vcs_pfet_enable_regulation_finger = 0
+ // (Regulation finger controlled by FSM)
+ l_data.flush<0>().
+ insertFromRight
+ <VCS_PFET_FORCE_STATE_BIT, PFET_STATE_LENGTH>(PFET_FORCE_VOFF);
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_OR, l_data),
+ "putScom failed for address PPM_PFCS_OR");
+
+ l_data.flush<0>().
+ setBit<VCS_PFET_VAL_OVERRIDE_BIT>().
+ setBit<VCS_PFET_SEL_OVERRIDE_BIT>();
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_CLR, l_data),
+ "putScom failed for address PPM_PFCS_CLR");
+
+ FAPI_TRY(pollVcsFSMIdle());
+
+ // Write PFETCNTLSTAT_REG_WCLEAR
+ // vcs_pfet_force_state = 00 (No Operation);
+ // all fields set to 1 for WAND
+ // Use PPM_PFCS_CLR, vcs_pfet_force_state = ~(0b00)
+ FAPI_DBG("vcs_pfet_force_state = 00, or Idle");
+ l_data.flush<0>().insertFromRight
+ <VCS_PFET_FORCE_STATE_BIT, PFET_STATE_LENGTH>(~PFET_NOP);
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_CLR, l_data),
+ "putScom failed for address PPM_PFCS_CLR");
+
+ // fapi2::current_err will be initialized with FAPI2_RC_SUCCESS
+ FAPI_CLEANUP()
+ return static_cast<fapi2::ReturnCode>(fapi2::current_err);
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Initialization code
+ ///////////////////////////////////////////////////////////////////////////
+#if 0 // unneeded for AWAN operation. Also, fails if delay field is > 8
+ l_data.flush<0>().insertFromRight<POWDN_DLY_BIT, POWDN_DLY_LENGTH>(0x8).
+ insertFromRight<POWUP_DLY_BIT, POWUP_DLY_LENGTH>(0x8);
+
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFDLY, l_data),
+ "putScom failed for address PPM_PFDLY");
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Procedure code
+ ///////////////////////////////////////////////////////////////////////////
+ switch(i_operation)
+ {
+ case p9power::POWER_ON: case p9power::POWER_ON_VDD:
+ {
+ // 4.3.8.1 Power-on via Hardware FSM
+
+ // VDD first, VCS second
+
+ // 1) Read PFETCNTLSTAT_REG: check for bits 0:3 being 0b0000
+ l_data.flush<0>().
+ setBit<VCS_PFET_VAL_OVERRIDE_BIT>().
+ setBit<VCS_PFET_SEL_OVERRIDE_BIT>();
+ FAPI_TRY(fapi2::putScom(i_target, PPM_PFCS_CLR, l_data),
+ "putScom failed for address PPM_PFCS_CLR");
+
+ FAPI_DBG("Make sure that we are not forcing PFET for VCS or VDD off");
+ FAPI_TRY(fapi2::getScom(i_target, PPM_PFCS, l_data),
+ "getScom failed for address PPM_PFCS");
+ l_data.extractToRight
+ <VDD_PFET_FORCE_STATE_BIT, 2*PFET_STATE_LENGTH>
+ (l_temp);
+ FAPI_ASSERT((l_temp == 0),
+ fapi2::PMPROC_PFETLIB_BAD_SCOM()
+ .set_ADDRESS(PPM_PFCS),
+ "PFET_FORCE_STATE not 0");
+
+ // 2) Set bits to program HW to enable VDD PFET, and
+ // 3) Poll state bit until Pfet sequence is complete
+ FAPI_TRY(powerOnVdd());
+
+ // 4) Set bits to program HW to enable VCS PFET, and
+ // 5) Poll state bit until Pfet sequence is complete
+
+ // Note: if (i_target.getType() & fapi2::TARGET_TYPE_EQ) doesn't work.
+ // Created a POWER_*_VDD label to delineate Vcs and Vdd
+ if (i_operation == p9power::POWER_ON)
+ FAPI_TRY(powerOnVcs());
+
+ } break;
+ case p9power::POWER_OFF: case p9power::POWER_OFF_VDD:
+ {
+ // 4.3.8.2 Power-off via Hardware FSM
+ // 1) Read PFETCNTLSTAT_REG: check for bits 0:3 being 0b0000
+ FAPI_DBG("Make sure that we are not forcing PFET for VCS or VDD off");
+ FAPI_TRY(fapi2::getScom(i_target, PPM_PFCS, l_data),
+ "getScom failed for address PPM_PFCS");
+
+ l_data.extractToRight
+ <VDD_PFET_FORCE_STATE_BIT, 2*PFET_STATE_LENGTH>
+ (l_temp);
+ FAPI_ASSERT((l_temp == 0),
+ fapi2::PMPROC_PFETLIB_BAD_SCOM()
+ .set_ADDRESS(PPM_PFCS),
+ "PFET_FORCE_STATE not 0");
+
+ // 2) Set bits to program HW to turn off VDD PFET, and
+ // 3) Poll state bit until Pfet sequence is complete
+ FAPI_TRY(powerOffVdd());
+
+ // 4) Set bits to program HW to turn off VCS PFET, and
+ // 5) Poll state bit until Pfet sequence is complete
+
+ // Note: if (i_target.getType() & fapi2::TARGET_TYPE_EQ) doesn't work.
+ // Created a POWER_*_VDD label to delineate Vcs and Vdd
+ if (i_operation == p9power::POWER_OFF)
+ FAPI_TRY(powerOffVcs());
+
+ } break;
+ }
+
+ FAPI_INF("<<p9_common_poweronoff");
+ // fapi2::current_err will be initialized with FAPI2_RC_SUCCESS
+ FAPI_CLEANUP()
+ return fapi2::current_err;
+} // Procedure
diff --git a/hwp/lib/p9_common_poweronoff.H b/hwp/lib/p9_common_poweronoff.H
index e3d20adb..c1efec99 100644
--- a/hwp/lib/p9_common_poweronoff.H
+++ b/hwp/lib/p9_common_poweronoff.H
@@ -2,27 +2,73 @@
/// @file p9_common_poweronoff.H
/// @brief common procedure for power on/off
///
-/// *HWP HWP Owner : David Du <daviddu@us.ibm.com>
-/// *HWP FW Owner : Reshmi Nair <resnair5@in.ibm.com>
+/// *HWP HWP Owner : David Young <davidy@us.ibm.com>
+/// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
/// *HWP Team : PM
/// *HWP Consumed by : SBE:SGPE:CME
-/// *HWP Level : 1
+/// *HWP Level : 2
///
#ifndef __P9_COMMON_POWERONOFF_H__
#define __P9_COMMON_POWERONOFF_H__
-extern "C"
+namespace p9power
+{
+ enum powerOperation_t
+ {
+ POWER_ON = 0x0,
+ POWER_OFF = 0xFF,
+ POWER_ON_VDD = 0x1,
+ POWER_OFF_VDD = 0xFE
+ };
+}
+
+
+// Will be auto-generated by Ben Gass's Figtree file
+// #define PPM_PFCS C_PPM_PFCS_SCOM
+// #define PPM_PFCS_CLR C_PPM_PFCS_SCOM1
+// #define PPM_PFCS_OR C_PPM_PFCS_SCOM2
+
+#define PPM_PFCS 0x100f0118
+#define PPM_PFCS_CLR 0x100f0119
+#define PPM_PFCS_OR 0x100f011a
+
+#define PPM_PFDLY 0x100f011b
+#define PPM_PFSNS 0x100f011c
+#define PPM_PFOFF 0x100f011d
+
+#if 0
+namespace fapi2
{
+// Will be auto-generated by error XML file
+
+const unsigned RC_PMPROC_PFETLIB_BAD_DOMAIN = 0;
+const unsigned RC_PMPROC_PFETLIB_BAD_SCOM = 1;
+const unsigned RC_PMPROC_PFETLIB_BAD_OP = 2;
+const unsigned RC_PMPROC_PFETLIB_RAIL_ON = 3;
+const unsigned RC_PMPROC_PFETLIB_RAIL_OFF = 4;
+const unsigned RC_PROCPM_PFETLIB_TIMEOUT = 5;
+const unsigned RC_PROCPM_PFET_CODE_BAD_MODE = 6;
+const unsigned RC_PROCPM_PFET_GET_ATTR = 7;
+}
+#endif
+#define OR_TARGET_ENABLED 1
-/// @typedef p9_common_proweronoff_FP_t
+/// @typedef p9_common_poweronoff_FP_t
/// function pointer typedef definition for HWP call support
-typedef fapi2::ReturnCode (*p9_common_proweronoff_FP_t) (
+#if OR_TARGET_ENABLED // Cronus may not support fapi2::TARGET_TYPE_EQ|fapi2::TARGET_TYPE_CORE
+typedef fapi2::ReturnCode (*p9_common_poweronoff_FP_t) (
const fapi2::Target<fapi2::TARGET_TYPE_EQ|
fapi2::TARGET_TYPE_CORE>&,
- int);
+ const p9power::powerOperation_t i_operation);
+#else
+typedef fapi2::ReturnCode (*p9_common_poweronoff_FP_t) (
+ const fapi2::Target<fapi2::TARGET_TYPE_EQ>&, const uint32_t);
+#endif
+extern "C"
+{
/// @brief common procedure for power on/off
///
/// @param [in] i_target TARGET_TYPE_EQ|TARGET_TYPE_CORE target
@@ -32,12 +78,18 @@ typedef fapi2::ReturnCode (*p9_common_proweronoff_FP_t) (
/// @attritem ATTR_PFET_TIMING - EX target, uint32
///
/// @retval FAPI_RC_SUCCESS
+#if OR_TARGET_ENABLED
fapi2::ReturnCode
-p9_common_proweronoff(
+p9_common_poweronoff(
const fapi2::Target<fapi2::TARGET_TYPE_EQ|
fapi2::TARGET_TYPE_CORE>& i_target,
- int i_operation);
-
+ const p9power::powerOperation_t i_operation);
+#else
+fapi2::ReturnCode
+p9_common_poweronoff(
+ const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target,
+ const p9power::powerOperation_t i_operation);
+#endif
} // extern C
diff --git a/hwp/lib/p9_poweronoff_errors.xml b/hwp/lib/p9_poweronoff_errors.xml
new file mode 100644
index 00000000..a8e44ce9
--- /dev/null
+++ b/hwp/lib/p9_poweronoff_errors.xml
@@ -0,0 +1,107 @@
+<!-- Error definitions for p9_pfet_init and p9_pfet_lib procedures -->
+<hwpErrors>
+ <!-- ********************************************************************* -->
+ <hwpError>
+ <rc>RC_PMPROC_PFETLIB_BAD_DOMAIN</rc>
+ <description>Invalid domain value passed to p9_pfet_control.</description>
+ <ffdc>EX</ffdc>
+ <ffdc>DOMAIN</ffdc>
+ <callout>
+ <procedure>CODE</procedure>
+ <priority>HIGH</priority>
+ </callout>
+ </hwpError>
+ <!-- ********************************************************************* -->
+ <hwpError>
+ <rc>RC_PMPROC_PFETLIB_BAD_SCOM</rc>
+ <description>SCOM request failed.</description>
+ <ffdc>EX</ffdc>
+ <ffdc>DOMAIN</ffdc>
+ <ffdc>ADDRESS</ffdc>
+ <callout>
+ <procedure>CODE</procedure>
+ <priority>HIGH</priority>
+ </callout>
+ </hwpError>
+ <!-- ********************************************************************* -->
+ <hwpError>
+ <rc>RC_PMPROC_PFETLIB_BAD_OP</rc>
+ <description>Invalid operation value passed to p9_pfet_control.</description>
+ <ffdc>EX</ffdc>
+ <ffdc>DOMAIN</ffdc>
+ <ffdc>OPERATION</ffdc>
+ <callout>
+ <procedure>CODE</procedure>
+ <priority>HIGH</priority>
+ </callout>
+ </hwpError>
+ <!-- ********************************************************************* -->
+ <hwpError>
+ <rc>RC_PMPROC_PFETLIB_RAIL_ON</rc>
+ <description>Error returned turning PFETs on in p9_pfet_control.</description>
+ <ffdc>EX</ffdc>
+ <ffdc>DOMAIN</ffdc>
+ <ffdc>OPERATION</ffdc>
+ </hwpError>
+ <!-- ********************************************************************* -->
+ <hwpError>
+ <rc>RC_PMPROC_PFETLIB_RAIL_OFF</rc>
+ <description>Error returned turning PFETs off in p9_pfet_control.</description>
+ <ffdc>EX</ffdc>
+ <ffdc>DOMAIN</ffdc>
+ <ffdc>OPERATION</ffdc>
+ </hwpError>
+ <!-- ********************************************************************* -->
+ <hwpError>
+ <rc>RC_PMPROC_PFETLIB_TIMEOUT</rc>
+ <description>
+ PFET sequencer timed out in p9_pfet_control.
+ Bad EX Chiplet
+ </description>
+ <ffdc>ADDRESS</ffdc>
+ <ffdc>PFETCONTROLVALUE</ffdc>
+ <ffdc>DOMAIN</ffdc>
+ <callout>
+ <childTargets>
+ <parent>PROC_CHIP_IN_ERROR</parent>
+ <childType>TARGET_TYPE_EX_CHIPLET</childType>
+ <childNumber>EX_NUMBER_IN_ERROR</childNumber>
+ </childTargets>
+ <priority>HIGH</priority>
+ </callout>
+ <deconfigure>
+ <childTargets>
+ <parent>PROC_CHIP_IN_ERROR</parent>
+ <childType>TARGET_TYPE_EX_CHIPLET</childType>
+ <childNumber>EX_NUMBER_IN_ERROR</childNumber>
+ </childTargets>
+ </deconfigure>
+ <gard>
+ <childTargets>
+ <parent>PROC_CHIP_IN_ERROR</parent>
+ <childType>TARGET_TYPE_EX_CHIPLET</childType>
+ <childNumber>EX_NUMBER_IN_ERROR</childNumber>
+ </childTargets>
+ </gard>
+ </hwpError>
+ <!-- ********************************************************************* -->
+ <hwpError>
+ <rc>RC_PMPROC_PFET_CODE_BAD_MODE</rc>
+ <description>Unknown mode passed to p9_pfet_init</description>
+ <ffdc>EX</ffdc>
+ <ffdc>DOMAIN</ffdc>
+ <callout>
+ <procedure>CODE</procedure>
+ <priority>HIGH</priority>
+ </callout>
+ </hwpError>
+ <!-- ********************************************************************* -->
+ <hwpError>
+ <rc>RC_PMPROC_PFET_GET_ATTR</rc>
+ <description>p9_pfet_init could not get an attribute.</description>
+ <ffdc>EX</ffdc>
+ <ffdc>DOMAIN</ffdc>
+ <ffdc>OPERATION</ffdc>
+ </hwpError>
+ <!-- ********************************************************************* -->
+</hwpErrors>
diff --git a/hwp/lib/wrapper/proc_poweronoff_wrap.C b/hwp/lib/wrapper/proc_poweronoff_wrap.C
new file mode 100644
index 00000000..0ce17733
--- /dev/null
+++ b/hwp/lib/wrapper/proc_poweronoff_wrap.C
@@ -0,0 +1,227 @@
+// ----------------------------------------------------------------------
+// Includes / eCMD Includes
+// ----------------------------------------------------------------------
+#include <prcdUtils.H>
+
+#include <croClientCapi.H>
+#include <ecmdClientCapi.H>
+#include <ecmdUtils.H>
+#include <ecmdSharedUtils.H>
+#include <fapi2.H>
+#include <fapi2ClientCapi.H>
+#include <fapi2SharedUtils.H>
+
+#include <string>
+#include <sstream>
+
+#include <p9_common_poweronoff.H>
+
+
+// ----------------------------------------------------------------------
+// Function definitions
+// ----------------------------------------------------------------------
+
+// display help message
+void help()
+{
+ // procedure constants
+ const std::string PROCEDURE = "proc_poweronoff_wrap";
+ const std::string REVISION = "$Revision: 1.1 $";
+ // build help message
+ char outstr[200];
+ snprintf(outstr, sizeof(outstr), "\nThis is the help text for the procedure %s (%s)\n", PROCEDURE.c_str(), REVISION.c_str());
+ ecmdOutput(outstr);
+ snprintf(outstr, sizeof(outstr), "Syntax: %s\n", PROCEDURE.c_str());
+ ecmdOutput(outstr);
+ ecmdOutput(" [-off] [-h] [-k#] [-n#] [-s#] [-p#] [-verif]\n");
+ ecmdOutput("\n");
+ ecmdOutput("Additional options:\n");
+ ecmdOutput(" -h This help\n");
+ ecmdOutput("\n");
+}
+
+
+// main function
+int main(int argc, char *argv[])
+{
+ // procedure constants
+ const std::string PROCEDURE = "proc_poweronoff_wrap";
+ const std::string REVISION = "$Revision: 1.1 $";
+
+ // from prcdUtils
+ extern bool GLOBAL_SIM_MODE;
+ extern bool GLOBAL_VERIF_MODE;
+
+ // flow/control variables
+ uint32_t rc = ECMD_SUCCESS;
+ ecmdDllInfo DLLINFO;
+ ecmdLooperData looper;
+ ecmdChipTarget target;
+ bool valid_pos_found = false;
+ char outstr[200];
+ p9power::powerOperation_t l_test1 = p9power::POWER_ON; // turn on
+
+ fapi2::ReturnCode rc_fapi(fapi2::FAPI2_RC_SUCCESS);
+
+
+ //-----------------------------------------------------------------------------------------
+ // load and initialize the eCMD Dll
+ // if left NULL, which DLL to load is determined by the ECMD_DLL_FILE environment variable
+ // if set to a specific value, the specified DLL will be loaded
+ //-----------------------------------------------------------------------------------------
+ rc = ecmdLoadDll("");
+ if (rc) return rc;
+
+ //-----------------------------------------------------------------------------------------
+ // This is needed if you're running a FAPI procedure from this eCMD procedure
+ //-----------------------------------------------------------------------------------------
+
+ // initalize FAPI2 extension
+ rc = fapi2InitExtension();
+ if (rc)
+ {
+ ecmdOutputError("Error initializing FAPI2 extension!\n");
+ return rc;
+ }
+
+ // establish if this is a simulation run or not
+ rc = ecmdQueryDllInfo(DLLINFO);
+ if (rc)
+ {
+ ecmdUnloadDll();
+ return rc;
+ }
+ if (DLLINFO.dllEnv == ECMD_DLL_ENV_SIM)
+ {
+ GLOBAL_SIM_MODE = true;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Parse out user options (excluding -pX, -cX, -coe, -debug, etc
+ // E.G., ecmdRunHwp.x86 -testmode
+ //-------------------------------------------------------------------------------------------------
+ if (ecmdParseOption(&argc, &argv, "-h"))
+ {
+ help();
+ ecmdUnloadDll();
+ return rc;
+ }
+
+ if (ecmdParseOption(&argc, &argv, "-off"))
+ {
+ l_test1 = p9power::POWER_OFF;
+ }
+
+ // run procedure in sim verification mode
+ if (ecmdParseOption(&argc, &argv, "-verif"))
+ {
+ GLOBAL_VERIF_MODE = true;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Parse out common eCMD args like -p0, -c0, -coe, etc..
+ // Any found args will be removed from arg list upon return
+ //-------------------------------------------------------------------------------------------------
+ rc = ecmdCommandArgs(&argc, &argv);
+ if (rc)
+ {
+ ecmdUnloadDll();
+ return rc;
+ }
+
+ // unsupported arguments left over?
+ if (argc != 1)
+ {
+ ecmdOutputError("Unknown/unsupported arguments specified!\n");
+ help();
+ ecmdUnloadDll();
+ return ECMD_INVALID_ARGS;
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Let's always print the dll info to the screen, unless in quiet mode
+ //-------------------------------------------------------------------------------------------------
+
+ if (!ecmdGetGlobalVar(ECMD_GLOBALVAR_QUIETMODE))
+ {
+ // print informational message
+ snprintf(outstr, sizeof(outstr), "Procedure %s: %s\n", PROCEDURE.c_str(), REVISION.c_str());
+ ecmdOutput(outstr);
+
+ // always print the DLL info to the screen, unless in quiet mode
+ rc = ecmdDisplayDllInfo();
+ if (rc)
+ {
+ return rc;
+ }
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ // Loop over all all pu chips
+ //-------------------------------------------------------------------------------------------------
+ target.chipType = "pu";
+ target.chipTypeState = ECMD_TARGET_FIELD_VALID;
+ target.cageState = ECMD_TARGET_FIELD_WILDCARD;
+ target.nodeState = ECMD_TARGET_FIELD_WILDCARD;
+ target.slotState = ECMD_TARGET_FIELD_WILDCARD;
+ target.posState = ECMD_TARGET_FIELD_WILDCARD;
+ target.coreState = ECMD_TARGET_FIELD_UNUSED;
+ target.threadState = ECMD_TARGET_FIELD_UNUSED;
+
+ rc = ecmdConfigLooperInit(target, ECMD_SELECTED_TARGETS_LOOP, looper);
+ if (rc)
+ {
+ ecmdOutputError("Error initializing proc chip looper!\n");
+ ecmdUnloadDll();
+ return rc;
+ }
+ while (ecmdConfigLooperNext(target, looper))
+ {
+ if (!ecmdGetGlobalVar(ECMD_GLOBALVAR_QUIETMODE))
+ {
+ snprintf(outstr, sizeof(outstr),
+ "Going to call %s on proc k%d:n%d:s%d:p%02d\n",
+ PROCEDURE.c_str(), target.cage, target.node,
+ target.slot, target.pos);
+ ecmdOutput(outstr);
+ }
+
+ // EXAMPLE setting up a fapi2::Target from an ecmdChipTarget
+ fapi2::Target<fapi2::TARGET_TYPE_EQ> fapi_target(&target);
+
+ // invoke FAPI procedure core
+ FAPI_EXEC_HWP(rc_fapi, p9_common_poweronoff, fapi_target, l_test1);
+ rc = (uint64_t) rc_fapi;
+ if (rc)
+ {
+ snprintf(outstr, sizeof(outstr),
+ "ERROR: %s FAPI call exited with return code = %s 0x%08x \n",
+ PROCEDURE.c_str(), ecmdParseReturnCode(rc).c_str(), rc);
+ ecmdOutputError(outstr);
+ ecmdUnloadDll();
+ return rc;
+ }
+
+ // mark that valid position has been found
+ valid_pos_found = true;
+ }
+
+ // check that a valid target was found
+ if (rc == ECMD_SUCCESS && !valid_pos_found)
+ {
+ ecmdOutputError("No valid targets found!\n");
+ ecmdUnloadDll();
+ return ECMD_TARGET_NOT_CONFIGURED;
+ }
+
+ prcdInfoMessage("----------------------------------------\n");
+ prcdInfoMessage(" proc_poweronoff is done\n");
+ prcdInfoMessage("----------------------------------------\n");
+
+ //-----------------------------------------------------------------------------------------------
+ // Unload the eCMD Dll, this should always be the last thing you do
+ //-----------------------------------------------------------------------------------------------
+
+ ecmdUnloadDll();
+ return rc;
+}
OpenPOWER on IntegriCloud