1414// / \author Kostas Alexopoulos ([email protected] )1515
1616#include < iostream>
17- #include " Common.h"
1817#include " Gbt.h"
1918#include " Utilities/Util.h"
2019
2120namespace AliceO2 {
2221namespace roc {
2322
2423using Link = Cru::Link;
24+ using LinkStatus = Cru::LinkStatus;
2525
2626Gbt::Gbt (std::shared_ptr<Pda::PdaBar> pdaBar, std::map<int , Link> &linkMap, int wrapperCount) :
2727 mPdaBar (pdaBar),
@@ -232,26 +232,33 @@ uint32_t Gbt::getAtxPllRegisterAddress(int wrapper, uint32_t reg)
232232 Cru::Registers::GBT_WRAPPER_ATX_PLL.address + 4 * reg;
233233}
234234
235- bool Gbt::getStickyBit (Link link)
235+ LinkStatus Gbt::getStickyBit (Link link)
236236{
237237 uint32_t addr = getStatusAddress (link);
238238 uint32_t data = mPdaBar ->readRegister (addr/4 );
239239 uint32_t lockedData = Utilities::getBit (~data, 14 ); // phy up 1 = locked, 0 = down
240240 uint32_t ready = Utilities::getBit (~data, 15 ); // data layer up 1 = locked, 0 = down
241241 if ((lockedData == 0x0 ) || (ready == 0x0 )) {
242242 resetStickyBit (link);
243+ data = mPdaBar ->readRegister (addr/4 );
244+ lockedData = Utilities::getBit (~data, 14 ); // phy up 1 = locked, 0 = down
245+ ready = Utilities::getBit (~data, 15 ); // data layer up 1 = locked, 0 = down
246+
247+ return (lockedData == 0x1 && ready == 0x1 ) ? LinkStatus::UpWasDown : LinkStatus::Down;
243248 }
244249
245- return (lockedData == 0x1 && ready == 0x1 ) ? true : false ;
250+ return (lockedData == 0x1 && ready == 0x1 ) ? LinkStatus::Up : LinkStatus::UpWasDown ;
246251}
247252
248- void Gbt::resetStickyBit (Link link) {
253+ void Gbt::resetStickyBit (Link link)
254+ {
249255 uint32_t addr = getClearErrorAddress (link);
250256
251257 mPdaBar ->writeRegister (addr/4 , 0x0 );
252258}
253259
254- uint32_t Gbt::getRxClockFrequency (Link link) { // In Hz
260+ uint32_t Gbt::getRxClockFrequency (Link link) // In Hz
261+ {
255262 uint32_t address = Cru::getWrapperBaseAddress (link.wrapper ) +
256263 Cru::Registers::GBT_WRAPPER_BANK_OFFSET.address * (link.bank + 1 ) +
257264 Cru::Registers::GBT_BANK_LINK_OFFSET.address * (link.id + 1 ) +
@@ -261,7 +268,8 @@ uint32_t Gbt::getRxClockFrequency(Link link) { //In Hz
261268 return mPdaBar ->readRegister (address/4 );
262269}
263270
264- uint32_t Gbt::getTxClockFrequency (Link link) { // In Hz
271+ uint32_t Gbt::getTxClockFrequency (Link link) // In Hz
272+ {
265273 uint32_t address = Cru::getWrapperBaseAddress (link.wrapper ) +
266274 Cru::Registers::GBT_WRAPPER_BANK_OFFSET.address * (link.bank + 1 ) +
267275 Cru::Registers::GBT_BANK_LINK_OFFSET.address * (link.id + 1 ) +
0 commit comments