DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
python
timing
shells
pc059.py
Go to the documentation of this file.
1
from
__future__
import
print_function
2
3
import
click
4
import
time
5
import
collections
6
7
from
.boards
import
BoardShell
8
from
.factory
import
ShellFactory
9
10
from
os.path
import
join, expandvars, basename
11
from
click
import
echo, style, secho
12
from
timing.common.definitions
import
kBoardPC059
13
from
timing.common.definitions
import
kCarrierEnclustraA35, kCarrierKC705, kCarrierMicrozed
14
from
timing.common.definitions
import
kDesignFanout
15
from
timing.core
import
I2CSlave, SI534xSlave, I2CExpanderSlave, DACSlave
16
17
18
# ------------------------------------------------------------------------------
19
class
PC059Shell
(
BoardShell
):
20
21
kPC059Rev1 = 3
22
kPC059FanoutSFP = 5
23
24
kUIDRevisionMap = {
25
0xd88039d980cf: kPC059Rev1,
26
0xd88039d98adf: kPC059Rev1,
27
0xd88039d92491: kPC059Rev1,
28
0xd88039d9248e: kPC059Rev1,
29
0xd88039d98ae9: kPC059Rev1,
30
0xd88039d92498: kPC059Rev1,
31
}
32
33
kClockConfigMap = {
34
kPC059Rev1:
"SI5345/PDTS0005.txt"
,
35
kPC059FanoutSFP:
"wr/FANOUT_PLL_WIDEBW_SFPIN.txt"
,
36
}
37
38
i2cMasters=[
39
'i2c'
,
40
'usfp_i2c'
,
41
]
42
# ------------------------------------------------------------------------------
43
def
getAX3Slave
(self):
44
lIO = self.device.getNode(
'io'
)
45
return
lIO.getNode(
'i2c'
).get_slave(
'AX3_Switch'
)
46
# ------------------------------------------------------------------------------
47
48
49
# ------------------------------------------------------------------------------
50
def
getUIDSlave
(self):
51
lIO = self.device.getNode(
'io'
)
52
return
lIO.getNode(
'i2c'
).get_slave(
'FMC_UID_PROM'
)
53
# ------------------------------------------------------------------------------
54
55
# ------------------------------------------------------------------------------
56
def
getSIChipSlave
(self):
57
# Access the clock chip
58
lI2CBusNode = self.device.getNode(
"io.i2c"
)
59
return
SI534xSlave(lI2CBusNode, lI2CBusNode.get_slave(
'SI5345'
).get_i2c_address())
60
# ------------------------------------------------------------------------------
61
62
63
# ------------------------------------------------------------------------------
64
def
resetI2CnPll
(self):
65
lIO = self.device.getNode(
'io'
)
66
67
# PLL and I@C reset
68
lIO.getNode(
'csr.ctrl.pll_rst'
).write(0x1)
69
lIO.getNode(
'csr.ctrl.rst_i2c'
).write(0x1)
70
lIO.getNode(
'csr.ctrl.rst_i2cmux'
).write(0x1)
71
lIO.getClient().dispatch()
72
73
lIO.getNode(
'csr.ctrl.pll_rst'
).write(0x0)
74
lIO.getNode(
'csr.ctrl.rst_i2c'
).write(0x0)
75
lIO.getNode(
'csr.ctrl.rst_i2cmux'
).write(0x0)
76
lIO.getClient().dispatch()
77
# ------------------------------------------------------------------------------
78
79
80
# ------------------------------------------------------------------------------
81
def
resetLockMon
(self):
82
lIO = self.device.getNode(
'io'
)
83
84
lIO.getNode(
'csr.ctrl.rst_lock_mon'
).write(0x1)
85
lIO.getNode(
'csr.ctrl.rst_lock_mon'
).write(0x0)
86
lIO.getClient().dispatch()
87
# ------------------------------------------------------------------------------
88
89
90
# ------------------------------------------------------------------------------
91
def
configureSFPExpander
(self):
92
93
lI2CBusNode = self.device.getNode(
"io.i2c"
)
94
lSFPExp =
I2CExpanderSlave
(lI2CBusNode, lI2CBusNode.get_slave(
'SFPExpander'
).get_i2c_address())
95
96
# Set invert registers to default for both banks
97
lSFPExp.set_inversion(0, 0x00)
98
lSFPExp.set_inversion(1, 0x00)
99
100
# BAnk 0 input, bank 1 output
101
lSFPExp.set_io(0, 0x00)
102
lSFPExp.set_io(1, 0xff)
103
104
# Bank 0 - enable all SFPGs (enable low)
105
lSFPExp.set_outputs(0, 0x00)
106
# ------------------------------------------------------------------------------
107
108
109
# ------------------------------------------------------------------------------
110
def
reset
(self, soft, fanout, forcepllcfg):
111
'''
112
Perform a hard reset on the timing master, including
113
114
\b
115
- ipbus registers
116
- i2c buses
117
- pll and pll configuration
118
119
\b
120
Fanout mode:
121
0 = local master
122
1 = sfp
123
'''
124
125
126
lDevice = self.device
127
lBoardType = self.info.boardType
128
lCarrierType = self.info.carrierType
129
lDesignType = self.info.designType
130
131
echo(
'Resetting '
+ click.style(lDevice.id(), fg=
'blue'
))
132
133
lIO = lDevice.getNode(
'io'
)
134
135
if
( fanout ):
136
secho(
"Fanout mode enabled"
, fg=
'green'
)
137
138
# Global soft reset
139
self.
soft_reset
()
140
141
if
not
soft:
142
143
# PLL and I@C reset
144
time.sleep(0.1)
145
146
# PLL and I2C reset
147
self.
resetI2CnPll
()
148
149
# Enable the i2c switch on the board
150
self.
enableI2CSwitch
()
151
152
lUniqueID = self.
readUID
()
153
# echo("Timing Board PROM UID: "+style(hex(lUniqueID), fg="blue"))
154
155
# Access the clock chip
156
lSIChip = self.
getSIChipSlave
()
157
158
# Ensure that the board is known to the revision DB
159
try
:
160
lRevision = self.
kUIDRevisionMap
[lUniqueID]
161
except
KeyError:
162
raise
click.ClickException(
"No revision associated to UID "
+hex(lUniqueID))
163
164
# Ensure that the board revision has a registered clock config
165
if
forcepllcfg
is
not
None
:
166
lFullClockConfigPath = forcepllcfg
167
echo(
"Using PLL Clock configuration file: "
+style(basename(lFullClockConfigPath), fg=
'green'
) )
168
169
else
:
170
if
lDesignType == kDesignFanout
and
fanout
in
[0]:
171
secho(
"Overriding clock config - fanout mode"
, fg=
'green'
)
172
lClockConfigPath = self.
kClockConfigMap
[self.
kPC059FanoutSFP
]
173
else
:
174
try
:
175
lClockConfigPath = self.
kClockConfigMap
[lRevision]
176
except
KeyError:
177
raise
ClickException(
"Board revision "
<< lRevision <<
" has no associated clock configuration"
)
178
179
180
echo(
"PLL Clock configuration file: "
+style(lClockConfigPath, fg=
'green'
) )
181
182
# Configure the clock chip
183
lFullClockConfigPath = expandvars(join(
'${TIMING_SHARE}/config/etc/clock'
, lClockConfigPath))
184
185
lSIChip.configure(lFullClockConfigPath)
186
echo(
"SI3545 configuration id: {}"
.format(style(lSIChip.read_config_id(), fg=
'green'
)))
187
188
self.
configureSFPExpander
()
189
190
self.
resetLockMon
()
191
192
if
lDesignType == kDesignFanout:
193
lDevice.getNode(
'switch.csr.ctrl.master_src'
).write(fanout)
194
lIO.getNode(
'csr.ctrl.mux'
).write(0)
195
lDevice.dispatch()
196
197
echo()
198
# ------------------------------------------------------------------------------
199
200
201
# ------------------------------------------------------------------------------
202
def
selectMux
(self, mux):
203
lDevice = self.device
204
205
lDevice.getNode(
'io.csr.ctrl.mux'
).write(mux)
206
lDevice.dispatch()
207
# secho('SFP input mux set to {}'.format(mux), fg='yellow')
208
# ------------------------------------------------------------------------------
209
210
ShellFactory.registerBoard(kBoardPC059, PC059Shell)
211
212
# ------------------------------------------------------------------------------
213
I2CExpanderSlave
Definition
I2CExpanderNode.hpp:25
timing.shells.boards.BoardShell
Definition
boards.py:21
timing.shells.boards.BoardShell.readUID
readUID(self)
Definition
boards.py:49
timing.shells.boards.BoardShell.enableI2CSwitch
enableI2CSwitch(self)
Definition
boards.py:36
timing.shells.boards.BoardShell.soft_reset
soft_reset(self)
Definition
boards.py:26
timing.shells.pc059.PC059Shell
Definition
pc059.py:19
timing.shells.pc059.PC059Shell.kUIDRevisionMap
dict kUIDRevisionMap
Definition
pc059.py:24
timing.shells.pc059.PC059Shell.configureSFPExpander
configureSFPExpander(self)
Definition
pc059.py:91
timing.shells.pc059.PC059Shell.reset
reset(self, soft, fanout, forcepllcfg)
Definition
pc059.py:110
timing.shells.pc059.PC059Shell.getSIChipSlave
getSIChipSlave(self)
Definition
pc059.py:56
timing.shells.pc059.PC059Shell.getUIDSlave
getUIDSlave(self)
Definition
pc059.py:50
timing.shells.pc059.PC059Shell.resetLockMon
resetLockMon(self)
Definition
pc059.py:81
timing.shells.pc059.PC059Shell.getAX3Slave
getAX3Slave(self)
Definition
pc059.py:43
timing.shells.pc059.PC059Shell.kPC059FanoutSFP
int kPC059FanoutSFP
Definition
pc059.py:22
timing.shells.pc059.PC059Shell.selectMux
selectMux(self, mux)
Definition
pc059.py:202
timing.shells.pc059.PC059Shell.resetI2CnPll
resetI2CnPll(self)
Definition
pc059.py:64
timing.shells.pc059.PC059Shell.kClockConfigMap
dict kClockConfigMap
Definition
pc059.py:33
timing.common.definitions
Definition
__init__.py:1
timing.core
Definition
__init__.py:1
Generated on
for DUNE-DAQ by
1.17.0