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
139 self.soft_reset()
140
141 if not soft:
142
143
144 time.sleep(0.1)
145
146
147 self.resetI2CnPll()
148
149
150 self.enableI2CSwitch()
151
152 lUniqueID = self.readUID()
153
154
155
156 lSIChip = self.getSIChipSlave()
157
158
159 try:
160 lRevision = self.kUIDRevisionMap[lUniqueID]
161 except KeyError:
162 raise click.ClickException("No revision associated to UID "+hex(lUniqueID))
163
164
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
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