Skip to content

Commit a01180b

Browse files
Enable/disable links as needed in CRU driver
1 parent bdbe326 commit a01180b

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

src/Cru/BarAccessor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ class BarAccessor
103103
mBar->writeRegister(Registers::DATA_SOURCE_SELECT.index, source);
104104
}
105105

106+
/// Set links
107+
void setLinksEnabled(uint32_t mask)
108+
{
109+
mBar->writeRegister(Registers::LINKS_ENABLE.index, mask);
110+
}
111+
106112
/// Gets the serial number from the card.
107113
/// Note that not all firmwares have a serial number. You should make sure this firmware feature is enabled before
108114
/// calling this function, or the card may crash. See getFirmwareFeatures().

src/Cru/Constants.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ static constexpr uintptr_t SUPERPAGES_PUSHED_INTERVAL = 0x4;
4949
/// Amount of completely pushed superpages
5050
static constexpr IntervalRegister LINK_SUPERPAGES_PUSHED(0x800, SUPERPAGES_PUSHED_INTERVAL);
5151

52+
/// Enable/disable links
53+
/// Every bit represents a link. Set a bit to 1 to disable a link.
54+
static constexpr Register LINKS_ENABLE = 0x604;
55+
5256
/// Configuration register for data generator
5357
/// Bit 0: set to start data generator
5458
/// Bits [2:1] determine the data generator pattern

src/Cru/CruDmaChannel.cxx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,20 @@ CruDmaChannel::~CruDmaChannel()
9090
void CruDmaChannel::deviceStartDma()
9191
{
9292
resetCru();
93-
initCru();
94-
setBufferReady();
9593

94+
// Enable links
95+
uint32_t mask = 0xFfffFfff;
96+
for (const auto& link : mLinks) {
97+
Utilities::setBit(mask, link.id, false);
98+
}
99+
getBar().setLinksEnabled(mask);
100+
101+
// Set data generator pattern
102+
if (mGeneratorEnabled) {
103+
getBar().setDataGeneratorPattern(mGeneratorPattern, mGeneratorDataSize, mGeneratorDataSizeRandomEnabled);
104+
}
105+
106+
// Set data source
96107
if (mGeneratorEnabled) {
97108
if (mLoopbackMode == LoopbackMode::Internal) {
98109
if (mFeatures.dataSelection) {
@@ -117,13 +128,16 @@ void CruDmaChannel::deviceStartDma()
117128
}
118129
}
119130

131+
// Initialize link queues
120132
for (auto &link : mLinks) {
121133
link.queue.clear();
122134
link.superpageCounter = 0;
123135
}
124136
mReadyQueue.clear();
125-
126137
mLinkQueuesTotalAvailable = LINK_QUEUE_CAPACITY * mLinks.size();
138+
139+
// Start DMA
140+
setBufferReady();
127141
}
128142

129143
/// Set buffer to ready
@@ -176,14 +190,6 @@ void CruDmaChannel::resetCru()
176190
std::this_thread::sleep_for(100ms);
177191
}
178192

179-
void CruDmaChannel::initCru()
180-
{
181-
// Set data generator pattern
182-
if (mGeneratorEnabled) {
183-
getBar().setDataGeneratorPattern(mGeneratorPattern, mGeneratorDataSize, mGeneratorDataSizeRandomEnabled);
184-
}
185-
}
186-
187193
auto CruDmaChannel::getNextLinkIndex() -> LinkIndex
188194
{
189195
auto smallestQueueIndex = std::numeric_limits<LinkIndex>::max();

src/Cru/CruDmaChannel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class CruDmaChannel final : public DmaChannelPdaBase
8282
SuperpageQueue queue {LINK_QUEUE_CAPACITY};
8383
};
8484

85-
void initCru();
8685
void resetCru();
8786
void setBufferReady();
8887
void setBufferNonReady();

0 commit comments

Comments
 (0)