@@ -29,7 +29,7 @@ Anlogic::Anlogic(Jtag *jtag, const std::string &filename,
2929 const std::string &file_type,
3030 Device::prog_type_t prg_type, bool verify, int8_t verbose):
3131 Device(jtag, filename, file_type, verify, verbose),
32- SPIInterface(filename, verbose, 0 , verify)
32+ SPIInterface(filename, verbose, 0 , verify), _target_freq( 0 )
3333{
3434 if (prg_type == Device::RD_FLASH) {
3535 _mode = Device::READ_MODE;
@@ -157,6 +157,11 @@ uint32_t Anlogic::idCode()
157157
158158bool Anlogic::prepare_flash_access ()
159159{
160+ _target_freq = _jtag->getClkFreq ();
161+ if (_target_freq > 6000000 ) {
162+ _jtag->setClkFreq (6000000 );
163+ }
164+
160165 for (int i = 0 ; i < 5 ; i++)
161166 _jtag->shiftIR (BYPASS, IRLENGTH);
162167 // Verify Device id.
@@ -174,6 +179,13 @@ bool Anlogic::prepare_flash_access()
174179 return true ;
175180}
176181
182+ void Anlogic::restore_flash_access_frequency ()
183+ {
184+ if (_target_freq > 6000000 ) {
185+ _jtag->setClkFreq (_target_freq);
186+ }
187+ }
188+
177189/* SPI wrapper
178190 * For read operation a delay of one bit is added
179191 * So add one bit more and move everything by one
0 commit comments