Skip to content

Commit 122c4e2

Browse files
committed
[alf] Update SC interface to FW
1 parent b6f0738 commit 122c4e2

File tree

3 files changed

+24
-39
lines changed

3 files changed

+24
-39
lines changed

src/Ic.cxx

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,13 @@ namespace o2
4545
namespace alf
4646
{
4747

48-
namespace ic_regs
49-
{
50-
static constexpr roc::Register IC_BASE(0x00f00000);
51-
static constexpr roc::Register IC_WR_DATA(IC_BASE.address + 0x20);
52-
static constexpr roc::Register IC_WR_CFG(IC_BASE.address + 0x24);
53-
static constexpr roc::Register IC_WR_CMD(IC_BASE.address + 0x28);
54-
static constexpr roc::Register IC_RD_DATA(IC_BASE.address + 0x30);
55-
} // namespace ic_regs
56-
5748
Ic::Ic(AlfLink link, std::shared_ptr<lla::Session> llaSession)
5849
: ScBase(link, llaSession)
5950
{
6051
Logger::setFacility("ALF/IC");
6152

6253
// Set CFG to 0x3 by default
63-
barWrite(ic_regs::IC_WR_CFG.index, 0x3);
54+
barWrite(sc_regs::IC_WR_CFG.index, 0x3);
6455
}
6556

6657
Ic::Ic(const roc::Parameters::CardIdType& cardId, int linkId)
@@ -69,7 +60,7 @@ Ic::Ic(const roc::Parameters::CardIdType& cardId, int linkId)
6960
Logger::setFacility("ALF/IC");
7061

7162
// Set CFG to 0x3 by default
72-
barWrite(ic_regs::IC_WR_CFG.index, 0x3);
63+
barWrite(sc_regs::IC_WR_CFG.index, 0x3);
7364
}
7465

7566
Ic::Ic(std::string cardId, int linkId)
@@ -78,7 +69,7 @@ Ic::Ic(std::string cardId, int linkId)
7869
Logger::setFacility("ALF/IC");
7970

8071
// Set CFG to 0x3 by default
81-
barWrite(ic_regs::IC_WR_CFG.index, 0x3);
72+
barWrite(sc_regs::IC_WR_CFG.index, 0x3);
8273
}
8374

8475
uint32_t Ic::read(uint32_t address)
@@ -91,20 +82,20 @@ uint32_t Ic::read(uint32_t address)
9182
data = data + address;
9283

9384
// Write to the FIFO
94-
barWrite(ic_regs::IC_WR_DATA.index, data);
95-
barWrite(ic_regs::IC_WR_CMD.index, 0x1);
96-
barWrite(ic_regs::IC_WR_CMD.index, 0x0);
85+
barWrite(sc_regs::IC_WR_DATA.index, data);
86+
barWrite(sc_regs::IC_WR_CMD.index, 0x1);
87+
barWrite(sc_regs::IC_WR_CMD.index, 0x0);
9788

9889
// Execute the RD State Machine
99-
barWrite(ic_regs::IC_WR_CMD.index, 0x8);
100-
barWrite(ic_regs::IC_WR_CMD.index, 0x0);
90+
barWrite(sc_regs::IC_WR_CMD.index, 0x8);
91+
barWrite(sc_regs::IC_WR_CMD.index, 0x0);
10192

10293
// Pulse the READ
103-
barWrite(ic_regs::IC_WR_CMD.index, 0x2);
104-
barWrite(ic_regs::IC_WR_CMD.index, 0x0);
94+
barWrite(sc_regs::IC_WR_CMD.index, 0x2);
95+
barWrite(sc_regs::IC_WR_CMD.index, 0x0);
10596

10697
// Read the status of the FIFO
107-
uint32_t ret = barRead(ic_regs::IC_RD_DATA.index);
98+
uint32_t ret = barRead(sc_regs::IC_RD_DATA.index);
10899
//uint32_t gbtAddress = (ret >> 8) & 0xff;
109100
uint32_t retData = ret & 0xff;
110101
//uint32_t empty = (ret >> 16) & 0x1;
@@ -124,18 +115,18 @@ uint32_t Ic::write(uint32_t address, uint32_t data)
124115
data += address;
125116

126117
// Write to the FIFO
127-
barWrite(ic_regs::IC_WR_DATA.index, data);
128-
barWrite(ic_regs::IC_WR_CMD.index, 0x1);
129-
barWrite(ic_regs::IC_WR_CMD.index, 0x0);
118+
barWrite(sc_regs::IC_WR_DATA.index, data);
119+
barWrite(sc_regs::IC_WR_CMD.index, 0x1);
120+
barWrite(sc_regs::IC_WR_CMD.index, 0x0);
130121

131122
// Execute the WR State Machine
132-
barWrite(ic_regs::IC_WR_CMD.index, 0x4);
133-
barWrite(ic_regs::IC_WR_CMD.index, 0x0);
123+
barWrite(sc_regs::IC_WR_CMD.index, 0x4);
124+
barWrite(sc_regs::IC_WR_CMD.index, 0x0);
134125

135126
std::this_thread::sleep_for(std::chrono::milliseconds(10));
136127

137128
// Read the status of the FIFO
138-
uint32_t ret = barRead(ic_regs::IC_RD_DATA.index);
129+
uint32_t ret = barRead(sc_regs::IC_RD_DATA.index);
139130
//uint32_t gbtAddress = (ret >> 8) & 0xff;
140131
//uint32_t retData = ret & 0xff;
141132
uint32_t empty = (ret >> 16) & 0x1;
@@ -149,7 +140,7 @@ uint32_t Ic::write(uint32_t address, uint32_t data)
149140

150141
void Ic::writeGbtI2c(uint32_t data)
151142
{
152-
barWrite(ic_regs::IC_WR_CFG.index, data);
143+
barWrite(sc_regs::IC_WR_CFG.index, data);
153144
}
154145

155146
std::vector<std::pair<Ic::Operation, Ic::Data>> Ic::executeSequence(std::vector<std::pair<Operation, Data>> ops, bool lock)
@@ -184,7 +175,7 @@ std::vector<std::pair<Ic::Operation, Ic::Data>> Ic::executeSequence(std::vector<
184175
// If an IC error occurs, we stop executing the sequence of commands and return the results as far as we got them, plus
185176
// the error message.
186177
IcData icData = boost::get<IcData>(data);
187-
std::string meaningfulMessage = (boost::format("ic_regs::IC_SEQUENCE address=0x%08x data=0x%08x serialId=%s link=%d, error='%s'") % icData.address % icData.data % mLink.serialId % mLink.linkId % e.what()).str();
178+
std::string meaningfulMessage = (boost::format("sc_regs::IC_SEQUENCE address=0x%08x data=0x%08x serialId=%s link=%d, error='%s'") % icData.address % icData.data % mLink.serialId % mLink.linkId % e.what()).str();
188179
//Logger::get().err() << meaningfulMessage << endm;
189180

190181
ret.push_back({ Operation::Error, meaningfulMessage });

src/ScBase.cxx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ void ScBase::setChannel(int gbtChannel)
8686

8787
mLink.linkId = gbtChannel;
8888
mLink.rawLinkId = mLink.serialId.getEndpoint() * kCruNumLinks + gbtChannel;
89-
barWrite(sc_regs::SC_LINK.index, mLink.rawLinkId);
9089
}
9190

9291
void ScBase::checkChannelSet()
@@ -95,11 +94,7 @@ void ScBase::checkChannelSet()
9594
BOOST_THROW_EXCEPTION(ScException() << ErrorInfo::Message("No channel selected"));
9695
}
9796

98-
int channel = (barRead(sc_regs::SWT_MON.index) >> 8) & 0xff;
99-
100-
if (channel != mLink.rawLinkId) {
101-
setChannel(mLink.linkId);
102-
}
97+
setChannel(mLink.linkId);
10398
}
10499

105100
void ScBase::scReset()
@@ -110,12 +105,14 @@ void ScBase::scReset()
110105

111106
void ScBase::barWrite(uint32_t index, uint32_t data)
112107
{
113-
mBar2->writeRegister(index, data);
108+
uint32_t linkIndex = (0x00f00000 + (mLink.rawLinkId << 8)) / 4 + index;
109+
mBar2->writeRegister(linkIndex, data);
114110
}
115111

116112
uint32_t ScBase::barRead(uint32_t index)
117113
{
118-
return mBar2->readRegister(index);
114+
uint32_t linkIndex = (0x00f00000 + (mLink.rawLinkId << 8)) / 4 + index;
115+
return mBar2->readRegister(linkIndex);
119116
}
120117

121118
} // namespace alf

src/Swt.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ std::vector<SwtWord> Swt::read(SwtWord::Size wordSize, TimeOut msTimeOut)
8181
for (int i = 0; i < (int)numWords; i++) {
8282
SwtWord tempWord;
8383

84-
barWrite(sc_regs::SWT_CMD.index, 0x2);
85-
barWrite(sc_regs::SWT_CMD.index, 0x0); // void cmd to sync clocks
86-
8784
tempWord.setLow(barRead(sc_regs::SWT_RD_WORD_L.index));
8885

8986
if (wordSize == SwtWord::Size::Medium || wordSize == SwtWord::Size::High) {

0 commit comments

Comments
 (0)