Skip to content

Commit cfddee3

Browse files
authored
colognechip: add bulk erase + quad enable features and simplify spi_wait overload (#582)
* colognechip: add bulk erase + quad enable features and simplify spi_wait overload * colognechip: remove unnecessary code in `set_quad_bit` and `bulk_erase_flash`
1 parent 501d37e commit cfddee3

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

src/colognechip.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,30 @@ bool CologneChip::dumpFlash(uint32_t base_addr, uint32_t len)
213213
return post_flash_access();
214214
}
215215

216+
/**
217+
* Set QE bit, if available. Works in both SPI and JTAG-SPI-bypass mode.
218+
*/
219+
bool CologneChip::set_quad_bit(bool set_quad)
220+
{
221+
if (!SPIInterface::set_quad_bit(set_quad)) {
222+
return false;
223+
}
224+
225+
return true;
226+
}
227+
228+
/**
229+
* Peform bulk erase. Works in both SPI and JTAG-SPI-bypass mode.
230+
*/
231+
bool CologneChip::bulk_erase_flash()
232+
{
233+
if (!SPIInterface::bulk_erase_flash()) {
234+
return false;
235+
}
236+
237+
return true;
238+
}
239+
216240
/**
217241
* Parse bitstream from *.bit or *.cfg and program FPGA in SPI or JTAG mode
218242
* or write configuration to external flash via SPI or JTAG-SPI-bypass.
@@ -450,15 +474,10 @@ int CologneChip::spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
450474
_jtag->read_write(&tx, NULL, 8, 0);
451475

452476
do {
453-
if (count == 0) {
454-
_jtag->read_write(dummy, rx, 16, 0);
455-
uint8_t b0 = ConfigBitstreamParser::reverseByte(rx[0]);
456-
uint8_t b1 = ConfigBitstreamParser::reverseByte(rx[1]);
457-
tmp = (b0 << 1) | ((b1 >> 7) & 0x01);
458-
} else {
459-
_jtag->read_write(dummy, rx, 8, 0);
460-
tmp = ConfigBitstreamParser::reverseByte(rx[0]);
461-
}
477+
_jtag->read_write(dummy, rx, 16, 0);
478+
uint8_t b0 = ConfigBitstreamParser::reverseByte(rx[0]);
479+
uint8_t b1 = ConfigBitstreamParser::reverseByte(rx[1]);
480+
tmp = (b0 << 1) | ((b1 >> 7) & 0x01);
462481

463482
count++;
464483
if (count == timeout) {

src/colognechip.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class CologneChip: public Device, SPIInterface {
4242
printError("protect flash not supported"); return false;}
4343
virtual bool unprotect_flash() override {
4444
printError("unprotect flash not supported"); return false;}
45-
virtual bool bulk_erase_flash() override {
46-
printError("bulk erase flash not supported"); return false;}
45+
bool set_quad_bit(bool set_quad) override;
46+
bool bulk_erase_flash() override;
4747
void program(unsigned int offset, bool unprotect_flash) override;
4848

4949
uint32_t idCode() override {return 0;}

0 commit comments

Comments
 (0)