Skip to content

Commit

Permalink
Update UCD class member variables and functions
Browse files Browse the repository at this point in the history
This commit makes Ucd class member variables to hold the I2C
information stored in an attribute of the UCD.  It also makes
updateUcdFlash() a member function.

Change-Id: I66221f0bd1b7dbe82ed4547c0635fbf99628471b
RTC:205979
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/74674
Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com>
Reviewed-by: Matthew Raybuck <matthew.raybuck@ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+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>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mabaiocchi authored and dcrowell77 committed Mar 20, 2019
1 parent 810394f commit 08d6bc3
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 69 deletions.
20 changes: 2 additions & 18 deletions src/include/usr/isteps/ucd/updateUcdFlash.H
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,11 @@ errlHndl_t updateAllUcdFlashImages(
const TARGETING::TargetHandleList& i_powerSequencers,
UtilMem& i_image);

/**
* @brief Updates a UCD target's flash image
*
* @param[in] i_pUcd UCD's target; must not be nullptr
* @param[in] i_pFlashImage pointer to the start of the data flash
* image (its table of contents). Must not be nullptr.
*
* @return errlHndl_t Error log handle
* @retval nullptr Successfully updated the UCD's data flash image
* @retval !nullptr Failed to update the UCD's data flash image. Handle
* points to valid error log
*/
errlHndl_t updateUcdFlash(
TARGETING::Target* i_pUcd,
const void* i_pFlashImage);

} // End namespace POWER_SEQUENCER
} // End namespace UCD

} // End namespace TI

} // End namespace UCD
} // End namespace POWER_SEQUENCER

#endif // __UPDATE_UCD_FLASH_H

2 changes: 1 addition & 1 deletion src/usr/isteps/istep21/call_update_ucd_flash.C
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void call_update_ucd_flash(void)

// Destructor automatically unloads the UCD flash binary

} // End valid machine and not-simcis for UCD updates
} // End valid machine and not-simics check for UCD updates

} while(0);

Expand Down
124 changes: 74 additions & 50 deletions src/usr/isteps/ucd/updateUcdFlash.C
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <targeting/common/target.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
#include <attributetraits.H>

#include <errl/errlentry.H>
#include <errl/errlmanager.H>
Expand Down Expand Up @@ -63,7 +64,7 @@ private:
enum DEVICE_OP_LENGTH : size_t
{
MFR_REVISION_MAX_SIZE = 12,
DEVICE_ID_MAX_SIZE = 32,
DEVICE_ID_MAX_SIZE = 32,
};

enum COMMAND : uint8_t
Expand All @@ -78,6 +79,8 @@ private:
const TARGETING::TargetHandle_t iv_pUcd;
char* iv_deviceId;
uint16_t iv_mfrRevision;
TARGETING::TargetHandle_t iv_pI2cMaster;
TARGETING::I2cControlInfo iv_i2cInfo;

/*
* Delete Copy Constructor
Expand Down Expand Up @@ -115,6 +118,17 @@ public:
assert(i_ucd->getAttr<TARGETING::ATTR_TYPE>()
== TARGETING::TYPE_POWER_SEQUENCER,
"i_ucd must be of type POWER_SEQUENCER");

// Get the I2C info for this UCD.
memset(&iv_i2cInfo, 0, sizeof(iv_i2cInfo));
iv_i2cInfo = iv_pUcd->getAttr<TARGETING::ATTR_I2C_CONTROL_INFO>();

iv_pI2cMaster =
TARGETING::targetService().toTarget(iv_i2cInfo.i2cMasterPath);

assert(iv_pI2cMaster != nullptr, "i2cMaster for UCD 0x%.8X was nullptr",
get_huid(iv_pUcd));

}

/* @brief Destructor that cleans up the iv_deviceId instance
Expand Down Expand Up @@ -149,28 +163,18 @@ public:
{
char deviceIdBuffer[DEVICE_ID_MAX_SIZE]{};

// Get the I2C info for this UCD.
const auto i2cInfo = iv_pUcd->
getAttr<TARGETING::ATTR_I2C_CONTROL_INFO>();

TARGETING::TargetHandle_t i2cMaster =
TARGETING::targetService().toTarget(i2cInfo.i2cMasterPath);

assert(i2cMaster != nullptr, "i2cMaster for UCD 0x%.8X was nullptr",
get_huid(iv_pUcd));

size_t size = sizeof(deviceIdBuffer);

err = deviceOp(DeviceFW::READ,
i2cMaster,
iv_pI2cMaster,
deviceIdBuffer,
size,
DEVICE_I2C_SMBUS_BLOCK(i2cInfo.engine,
i2cInfo.port,
i2cInfo.devAddr,
DEVICE_I2C_SMBUS_BLOCK(iv_i2cInfo.engine,
iv_i2cInfo.port,
iv_i2cInfo.devAddr,
DEVICE_ID,
i2cInfo.i2cMuxBusSelector,
&i2cInfo.i2cMuxPath)
iv_i2cInfo.i2cMuxBusSelector,
&iv_i2cInfo.i2cMuxPath)
);

// @TODO RTC 205982: Handle the PEC byte if it exists.
Expand Down Expand Up @@ -213,10 +217,10 @@ public:
get_huid(iv_pUcd)
);

err->addI2cDeviceCallout(i2cMaster,
i2cInfo.engine,
i2cInfo.port,
i2cInfo.devAddr,
err->addI2cDeviceCallout(iv_pI2cMaster,
iv_i2cInfo.engine,
iv_i2cInfo.port,
iv_i2cInfo.devAddr,
HWAS::SRCI_PRIORITY_HIGH);

err->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE,
Expand Down Expand Up @@ -266,15 +270,15 @@ public:

// Read the MFR revision from the UCD device.
err = deviceOp(DeviceFW::READ,
i2cMaster,
iv_pI2cMaster,
mfrBuf.str,
size,
DEVICE_I2C_SMBUS_BLOCK(i2cInfo.engine,
i2cInfo.port,
i2cInfo.devAddr,
DEVICE_I2C_SMBUS_BLOCK(iv_i2cInfo.engine,
iv_i2cInfo.port,
iv_i2cInfo.devAddr,
MFR_REVISION,
i2cInfo.i2cMuxBusSelector,
&i2cInfo.i2cMuxPath)
iv_i2cInfo.i2cMuxBusSelector,
&iv_i2cInfo.i2cMuxPath)
);

// @TODO RTC 205982: Need to handle the case where a bad PEC byte
Expand Down Expand Up @@ -317,10 +321,10 @@ public:
TWO_UINT32_TO_UINT64(MFR_REVISION_MAX_SIZE, size),
get_huid(iv_pUcd));

err->addI2cDeviceCallout(i2cMaster,
i2cInfo.engine,
i2cInfo.port,
i2cInfo.devAddr,
err->addI2cDeviceCallout(iv_pI2cMaster,
iv_i2cInfo.engine,
iv_i2cInfo.port,
iv_i2cInfo.devAddr,
HWAS::SRCI_PRIORITY_HIGH);

err->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE,
Expand All @@ -340,7 +344,40 @@ public:
} while(0);

return err;
}
} // end of initialize()


/**
* @brief Updates a UCD target's flash image
*
* @param[in] i_pFlashImage pointer to the start of the data flash
* image for this UCD target. Must not be nullptr.
* @param[in] i_size Size of i_pFlashImage
*
* @return errlHndl_t Error log handle
* @retval nullptr Successfully updated the UCD's data flash image
* @retval !nullptr Failed to update the UCD's data flash image. Handle
* points to valid error log
*/
errlHndl_t updateUcdFlash(const void* i_pFlashImage,
size_t i_size)
{
errlHndl_t pError = nullptr;

// Stub for future additional support
TRACFCOMP(g_trac_ucd, ENTER_MRK"updateUcdFlash: ucd_tgt=0x%.08X, "
"i2cInfo: e%d/p%d/da=0x%X. i_pFlashImage=%p, i_size=0x%X",
TARGETING::get_huid(iv_pUcd),
iv_i2cInfo.engine, iv_i2cInfo.port, iv_i2cInfo.devAddr,
i_pFlashImage, i_size);

TRACFBIN(g_trac_ucd,"updateUcdFlash: Start of i_pFlashImage",
i_pFlashImage, 64);

return pError;

} // end of updateUcdFlash()


/*
* @brief Gets the Device ID for the UCD member of this
Expand All @@ -364,7 +401,7 @@ public:
return iv_mfrRevision;
}

};
}; // end of class Ucd

/**
* @brief Header for the UCD flash image content
Expand Down Expand Up @@ -759,12 +796,10 @@ errlHndl_t updateAllUcdFlashImages(
nextUcd=true;

// Update the UCD data flash
// @TODO RTC 205979 - Call this function
//pError = updateUcdFlash(
// powerSequencer,
// reinterpret_cast<const uint8_t*>(i_image.base())
// + tocEntry.imageOffset,
// tocEntry.imageSize);
pError = ucd.updateUcdFlash(
reinterpret_cast<const uint8_t*>(i_image.base())
+ tocEntry.imageOffset,
tocEntry.imageSize);
if(pError)
{
TRACFCOMP(g_trac_ucd,ERR_MRK
Expand Down Expand Up @@ -824,17 +859,6 @@ errlHndl_t updateAllUcdFlashImages(
return pError;
}

errlHndl_t updateUcdFlash(
TARGETING::Target* i_pUcd,
const void* i_pFlashImage)
{
errlHndl_t pError = nullptr;

// Stub for future additional support

return pError;
}

} // End namespace UCD

} // End namespace TI
Expand Down

0 comments on commit 08d6bc3

Please sign in to comment.