19 #define ISPICFG 0x0000
20 #define ISPISTS 0x0004
21 #define ISPIADDR 0x0008
22 #define ISPICMD 0x000C
23 #define ISPIDAT 0x0100
25 #define ISPISTS_BUSY BIT(0)
26 #define STATUS1_QE BIT(1)
28 #define CFG_READ 0x372
29 #define CFG_WRITE 0x371
31 #define ISPI_CTRL_BASE 0x50101000
38 FLASH_ID(
"ISPI flash", 0x03, 0x00, 0x02, 0x20, 0x60, 0x00132085, 0x100, 0x1000, 0x80000);
62 bank->driver_priv = eneispif_info;
63 eneispif_info->
probed =
false;
86 eneispif_info->
ctrl_base + address, *value);
96 eneispif_info->
ctrl_base + address, value);
100 value, eneispif_info->
ctrl_base + address);
120 if (now -
start > 1000) {
166 LOG_DEBUG(
"%s: from sector %u to sector %u", __func__, first, last);
173 if (last < first || last >=
bank->num_sectors) {
178 if (!(eneispif_info->
probed)) {
183 for (
unsigned int sector = first; sector <= last; sector++) {
184 if (
bank->sectors[sector].is_protected) {
185 LOG_ERROR(
"Flash sector %u protected", sector);
193 for (
unsigned int sector = first; sector <= last; sector++) {
204 for (
unsigned int sector = first; sector <= last; sector++)
205 bank->sectors[sector].is_protected = set;
228 LOG_WARNING(
"Write past end of flash. Extra data discarded.");
233 for (
unsigned int sector = 0; sector <
bank->num_sectors; sector++) {
236 if ((
offset < (
bank->sectors[sector].offset +
bank->sectors[sector].size)) &&
238 bank->sectors[sector].is_protected) {
239 LOG_ERROR(
"Flash sector %u protected", sector);
253 uint32_t page_offset =
offset % page_size;
259 if (page_offset +
count > page_size)
260 cur_count = page_size - page_offset;
293 uint32_t conf, value;
305 LOG_DEBUG(
"ISPCFG = (0x%08" PRIx32
")", conf);
321 LOG_DEBUG(
"ISPDAT = (0x%08" PRIx32
")", value);
337 if (eneispif_info->
probed)
340 eneispif_info->
probed =
false;
355 LOG_INFO(
"Found flash device \'%s\' (ID 0x%08" PRIx32
")", eneispif_info->
dev->
name,
361 if (
bank->size <= (1UL << 16))
362 LOG_WARNING(
"device needs 2-byte addresses - not implemented");
376 for (
unsigned int sector = 0; sector <
bank->num_sectors; sector++) {
377 sectors[sector].
offset = sector * sectorsize;
378 sectors[sector].
size = sectorsize;
383 bank->sectors = sectors;
384 eneispif_info->
probed =
true;
391 if (eneispif_info->
probed)
406 if (!(eneispif_info->
probed)) {
412 "ENE ISPI flash information:\n"
413 " Device \'%s\' (ID 0x%08" PRIx32
")",
421 .usage =
"flash bank <name> 'eneispif' <base_address> <size> 0 0 <target> <ctrl_base>",
422 .flash_bank_command = eneispif_flash_bank_command,
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define COMMAND_PARSE_ADDRESS(in, out)
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
static int eneispif_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
const struct flash_driver eneispif_flash
struct flash_device ene_flash_device
static int eneispif_probe(struct flash_bank *bank)
static int eneispif_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
static int eneispi_erase_sector(struct flash_bank *bank, int sector)
static int eneispif_read_flash_id(struct flash_bank *bank, uint32_t *id)
FLASH_BANK_COMMAND_HANDLER(eneispif_flash_bank_command)
static int eneispif_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
static int eneispif_wait(struct flash_bank *bank)
static int get_eneispif_info(struct flash_bank *bank, struct command_invocation *cmd)
static int eneispif_write_reg(struct flash_bank *bank, target_addr_t address, uint32_t value)
static int eneispif_read_reg(struct flash_bank *bank, uint32_t *value, target_addr_t address)
static int eneispif_protect_check(struct flash_bank *bank)
static int eneispif_auto_probe(struct flash_bank *bank)
#define ERROR_FLASH_OPER_UNSUPPORTED
#define ERROR_FLASH_SECTOR_INVALID
#define ERROR_FLASH_BANK_NOT_PROBED
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
Upper level NOR flash interfaces.
char id[RTT_CB_MAX_ID_LENGTH]
Control block identifier.
#define FLASH_ID(n, re, qr, pp, es, ces, id, psize, ssize, size)
#define SPIFLASH_WRITE_ENABLE
#define SPIFLASH_DEF_PAGESIZE
When run_command is called, a new instance will be created on the stack, filled with the proper value...
const struct flash_device * dev
Provides details of a flash bank, available either on-chip or through a major interface.
Provides the implementation-independent structure that defines all of the callbacks required by OpenO...
const char * name
Gives a human-readable name of this flash driver, This field is used to select and initialize the dri...
Describes the geometry and status of a single flash sector within a flash bank.
int is_erased
Indication of erasure status: 0 = not erased, 1 = erased, other = unknown.
uint32_t offset
Bus offset from start of the flash chip (in bytes).
int is_protected
Indication of protection status: 0 = unprotected/unlocked, 1 = protected/locked, other = unknown.
uint32_t size
Number of bytes in this flash sector.
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
#define ERROR_TARGET_NOT_HALTED
#define ERROR_TARGET_TIMEOUT