flash/nor: Allow CFI memory read/write functions be overriden
Add possibility to supply custom CFI memory accessors via cfi_info and override the default memory-mapped ones. Change-Id: I1b6bc1db69fc33e8cdef96c41742c40e6d8917e9 Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Reviewed-on: http://openocd.zylin.com/5147 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
parent
515a30f720
commit
3192717ae9
|
@ -134,15 +134,25 @@ static inline uint32_t flash_address(struct flash_bank *bank, int sector, uint32
|
|||
static int cfi_target_write_memory(struct flash_bank *bank, target_addr_t addr,
|
||||
uint32_t count, const uint8_t *buffer)
|
||||
{
|
||||
return target_write_memory(bank->target, addr, bank->bus_width,
|
||||
count, buffer);
|
||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||
if (cfi_info->write_mem) {
|
||||
return cfi_info->write_mem(bank, addr, count, buffer);
|
||||
} else {
|
||||
return target_write_memory(bank->target, addr, bank->bus_width,
|
||||
count, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
static int cfi_target_read_memory(struct flash_bank *bank, target_addr_t addr,
|
||||
uint32_t count, uint8_t *buffer)
|
||||
{
|
||||
return target_read_memory(bank->target, addr, bank->bus_width,
|
||||
count, buffer);
|
||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||
if (cfi_info->read_mem) {
|
||||
return cfi_info->read_mem(bank, addr, count, buffer);
|
||||
} else {
|
||||
return target_read_memory(bank->target, addr, bank->bus_width,
|
||||
count, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
static void cfi_command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
|
||||
|
|
|
@ -73,6 +73,12 @@ struct cfi_flash_bank {
|
|||
unsigned buf_write_timeout;
|
||||
unsigned block_erase_timeout;
|
||||
unsigned chip_erase_timeout;
|
||||
|
||||
/* memory accessors */
|
||||
int (*write_mem)(struct flash_bank *bank, target_addr_t addr,
|
||||
uint32_t count, const uint8_t *buffer);
|
||||
int (*read_mem)(struct flash_bank *bank, target_addr_t addr,
|
||||
uint32_t count, uint8_t *buffer);
|
||||
};
|
||||
|
||||
/* Intel primary extended query table
|
||||
|
|
Loading…
Reference in New Issue