2021-06-26 15:24:07 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2020-08-20 16:58:20 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef SRC_ANLOGIC_HPP_
|
|
|
|
|
#define SRC_ANLOGIC_HPP_
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "bitparser.hpp"
|
|
|
|
|
#include "device.hpp"
|
|
|
|
|
#include "jtag.hpp"
|
2020-08-24 08:54:45 +02:00
|
|
|
#include "spiInterface.hpp"
|
2020-08-20 16:58:20 +02:00
|
|
|
#include "svf_jtag.hpp"
|
|
|
|
|
|
2020-08-24 08:54:45 +02:00
|
|
|
class Anlogic: public Device, SPIInterface {
|
2020-08-20 16:58:20 +02:00
|
|
|
public:
|
2020-08-24 08:54:45 +02:00
|
|
|
Anlogic(Jtag *jtag, const std::string &filename,
|
2021-02-21 18:30:13 +01:00
|
|
|
const std::string &file_type,
|
2021-06-25 08:58:45 +02:00
|
|
|
Device::prog_type_t prg_type, bool verify, int8_t verbose);
|
2020-08-20 16:58:20 +02:00
|
|
|
~Anlogic();
|
|
|
|
|
|
2021-12-22 19:11:35 +01:00
|
|
|
void program(unsigned int offset, bool unprotect_flash) override;
|
2020-08-20 16:58:20 +02:00
|
|
|
int idCode() override;
|
|
|
|
|
void reset() override;
|
2020-08-24 08:54:45 +02:00
|
|
|
|
|
|
|
|
/* spi interface */
|
2021-12-22 19:11:35 +01:00
|
|
|
/*!
|
|
|
|
|
* \brief protect SPI flash blocks
|
|
|
|
|
*/
|
|
|
|
|
bool protect_flash(uint32_t len) override {
|
|
|
|
|
return SPIInterface::protect_flash(len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief protect SPI flash blocks
|
|
|
|
|
*/
|
|
|
|
|
bool unprotect_flash() override {
|
|
|
|
|
return SPIInterface::unprotect_flash();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-10 08:51:54 +01:00
|
|
|
/*!
|
|
|
|
|
* \brief bulk erase SPI flash
|
|
|
|
|
*/
|
|
|
|
|
bool bulk_erase_flash() override {
|
|
|
|
|
return SPIInterface::bulk_erase_flash();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-22 19:11:35 +01:00
|
|
|
/*!
|
|
|
|
|
* \brief dump len byte from base_addr from SPI flash
|
|
|
|
|
* \param[in] base_addr: start offset
|
|
|
|
|
* \param[in] len: dump len
|
|
|
|
|
* \return false if something wrong
|
|
|
|
|
*/
|
|
|
|
|
virtual bool dumpFlash(uint32_t base_addr, uint32_t len) override {
|
|
|
|
|
return SPIInterface::dump(base_addr, len);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-24 08:54:45 +02:00
|
|
|
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
|
|
|
|
uint32_t len) override;
|
|
|
|
|
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
|
|
|
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
|
|
|
|
uint32_t timeout, bool verbose=false) override;
|
2021-12-22 19:11:35 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
/*!
|
|
|
|
|
* \brief move device to SPI access
|
|
|
|
|
*/
|
|
|
|
|
virtual bool prepare_flash_access() override;
|
|
|
|
|
/*!
|
|
|
|
|
* \brief end of device to SPI access
|
|
|
|
|
*/
|
|
|
|
|
virtual bool post_flash_access() override {reset(); return true;}
|
|
|
|
|
|
2020-08-20 16:58:20 +02:00
|
|
|
private:
|
|
|
|
|
SVF_jtag _svf;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // SRC_ANLOGIC_HPP_
|