OpenOCD
cfi.c File Reference
Include dependency graph for cfi.c:

Go to the source code of this file.

Macros

#define AT49BV6416   0x00d6
 
#define AT49BV6416T   0x00d2
 
#define CFI_MAX_INTEL_CODESIZE   256
 

Functions

int cfi_auto_probe (struct flash_bank *bank)
 
static void cfi_command (struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
 
static uint32_t cfi_command_val (struct flash_bank *bank, uint8_t cmd)
 
int cfi_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static void cfi_fixup (struct flash_bank *bank, const struct cfi_fixup *fixups)
 
static void cfi_fixup_0002_erase_regions (struct flash_bank *bank, const void *param)
 
static void cfi_fixup_0002_polling_bits (struct flash_bank *bank, const void *param)
 
static void cfi_fixup_0002_unlock_addresses (struct flash_bank *bank, const void *param)
 
static void cfi_fixup_0002_write_buffer (struct flash_bank *bank, const void *param)
 
static void cfi_fixup_reversed_erase_regions (struct flash_bank *bank, const void *param)
 
uint32_t cfi_flash_address (struct flash_bank *bank, int sector, uint32_t offset)
 
int cfi_flash_bank_cmd (struct flash_bank *bank, unsigned int argc, const char **argv)
 
int cfi_get_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int cfi_get_u8 (struct flash_bank *bank, int sector, uint32_t offset, uint8_t *val)
 
static void cfi_intel_clear_status_register (struct flash_bank *bank)
 
static int cfi_intel_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int cfi_intel_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int cfi_intel_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int cfi_intel_protect_check (struct flash_bank *bank)
 
static int cfi_intel_wait_status_busy (struct flash_bank *bank, int timeout, uint8_t *val)
 
static int cfi_intel_write_block (struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t count)
 
static int cfi_intel_write_word (struct flash_bank *bank, uint8_t *word, uint32_t address)
 
static int cfi_intel_write_words (struct flash_bank *bank, const uint8_t *word, uint32_t wordcount, uint32_t address)
 
int cfi_probe (struct flash_bank *bank)
 
int cfi_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
int cfi_protect_check (struct flash_bank *bank)
 
static int cfi_query_string (struct flash_bank *bank, int address)
 
static int cfi_query_u16 (struct flash_bank *bank, int sector, uint32_t offset, uint16_t *val)
 
static int cfi_query_u32 (struct flash_bank *bank, int sector, uint32_t offset, uint32_t *val)
 
static int cfi_query_u8 (struct flash_bank *bank, int sector, uint32_t offset, uint8_t *val)
 
static int cfi_read (struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int cfi_read_0002_pri_ext (struct flash_bank *bank)
 
static int cfi_read_atmel_pri_ext (struct flash_bank *bank)
 
static int cfi_read_intel_pri_ext (struct flash_bank *bank)
 
static int cfi_read_spansion_pri_ext (struct flash_bank *bank)
 
int cfi_reset (struct flash_bank *bank)
 
int cfi_send_command (struct flash_bank *bank, uint8_t cmd, uint32_t address)
 
static int cfi_spansion_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int cfi_spansion_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int cfi_spansion_protect_check (struct flash_bank *bank)
 
int cfi_spansion_unlock_seq (struct flash_bank *bank)
 
int cfi_spansion_wait_status_busy (struct flash_bank *bank, int timeout)
 
static int cfi_spansion_write_block (struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t count)
 
static int cfi_spansion_write_block_mips (struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t count)
 
static int cfi_spansion_write_word (struct flash_bank *bank, uint8_t *word, uint32_t address)
 
static int cfi_spansion_write_words (struct flash_bank *bank, const uint8_t *word, uint32_t wordcount, uint32_t address)
 
int cfi_target_read_memory (struct flash_bank *bank, target_addr_t addr, uint32_t count, uint8_t *buffer)
 
static int cfi_target_write_memory (struct flash_bank *bank, target_addr_t addr, uint32_t count, const uint8_t *buffer)
 
static int cfi_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
int cfi_write_word (struct flash_bank *bank, uint8_t *word, uint32_t address)
 
static int cfi_write_words (struct flash_bank *bank, const uint8_t *word, uint32_t wordcount, uint32_t address)
 
 FLASH_BANK_COMMAND_HANDLER (cfi_flash_bank_command)
 

Variables

static const struct cfi_fixup cfi_0001_fixups []
 
static const struct cfi_fixup cfi_0002_fixups []
 
const struct flash_driver cfi_flash
 
static const int cfi_status_poll_mask_dq6_dq7 = CFI_STATUS_POLL_MASK_DQ6_DQ7
 
static const struct cfi_unlock_addresses cfi_unlock_addresses []
 

Macro Definition Documentation

◆ AT49BV6416

#define AT49BV6416   0x00d6

Definition at line 30 of file cfi.c.

◆ AT49BV6416T

#define AT49BV6416T   0x00d2

Definition at line 31 of file cfi.c.

◆ CFI_MAX_INTEL_CODESIZE

#define CFI_MAX_INTEL_CODESIZE   256

Definition at line 27 of file cfi.c.

Function Documentation

◆ cfi_auto_probe()

int cfi_auto_probe ( struct flash_bank bank)

Definition at line 2863 of file cfi.c.

References bank, cfi_probe(), ERROR_OK, and cfi_flash_bank::probed.

◆ cfi_command()

static void cfi_command ( struct flash_bank bank,
uint8_t  cmd,
uint8_t *  cmd_buf 
)
static

Definition at line 143 of file cfi.c.

References bank, CFI_MAX_BUS_WIDTH, cmd, cfi_flash_bank::endianness, and TARGET_LITTLE_ENDIAN.

Referenced by cfi_command_val(), and cfi_send_command().

◆ cfi_command_val()

static uint32_t cfi_command_val ( struct flash_bank bank,
uint8_t  cmd 
)
static

◆ cfi_erase()

int cfi_erase ( struct flash_bank bank,
unsigned int  first,
unsigned int  last 
)

◆ cfi_fixup()

static void cfi_fixup ( struct flash_bank bank,
const struct cfi_fixup fixups 
)
static

◆ cfi_fixup_0002_erase_regions()

static void cfi_fixup_0002_erase_regions ( struct flash_bank bank,
const void *  param 
)
static

◆ cfi_fixup_0002_polling_bits()

static void cfi_fixup_0002_polling_bits ( struct flash_bank bank,
const void *  param 
)
static

Definition at line 2489 of file cfi.c.

References bank, and cfi_flash_bank::status_poll_mask.

◆ cfi_fixup_0002_unlock_addresses()

static void cfi_fixup_0002_unlock_addresses ( struct flash_bank bank,
const void *  param 
)
static

◆ cfi_fixup_0002_write_buffer()

static void cfi_fixup_0002_write_buffer ( struct flash_bank bank,
const void *  param 
)
static

Definition at line 3029 of file cfi.c.

References bank, and cfi_flash_bank::buf_write_timeout_typ.

◆ cfi_fixup_reversed_erase_regions()

static void cfi_fixup_reversed_erase_regions ( struct flash_bank bank,
const void *  param 
)
static

Definition at line 2450 of file cfi.c.

References cfi_spansion_pri_ext::_reversed_geometry, bank, and cfi_flash_bank::pri_ext.

◆ cfi_flash_address()

◆ cfi_flash_bank_cmd()

◆ cfi_get_info()

◆ cfi_get_u8()

static int cfi_get_u8 ( struct flash_bank bank,
int  sector,
uint32_t  offset,
uint8_t *  val 
)
static

◆ cfi_intel_clear_status_register()

static void cfi_intel_clear_status_register ( struct flash_bank bank)
static

◆ cfi_intel_erase()

static int cfi_intel_erase ( struct flash_bank bank,
unsigned int  first,
unsigned int  last 
)
static

◆ cfi_intel_info()

◆ cfi_intel_protect()

static int cfi_intel_protect ( struct flash_bank bank,
int  set,
unsigned int  first,
unsigned int  last 
)
static

◆ cfi_intel_protect_check()

static int cfi_intel_protect_check ( struct flash_bank bank)
static

◆ cfi_intel_wait_status_busy()

static int cfi_intel_wait_status_busy ( struct flash_bank bank,
int  timeout,
uint8_t *  val 
)
static

◆ cfi_intel_write_block()

◆ cfi_intel_write_word()

static int cfi_intel_write_word ( struct flash_bank bank,
uint8_t *  word,
uint32_t  address 
)
static

◆ cfi_intel_write_words()

static int cfi_intel_write_words ( struct flash_bank bank,
const uint8_t *  word,
uint32_t  wordcount,
uint32_t  address 
)
static

◆ cfi_probe()

int cfi_probe ( struct flash_bank bank)

Definition at line 2531 of file cfi.c.

References cfi_flash_bank::alt_addr, cfi_flash_bank::alt_id, bank, cfi_flash_bank::block_erase_timeout, cfi_flash_bank::block_erase_timeout_max, cfi_flash_bank::block_erase_timeout_typ, cfi_flash_bank::buf_write_timeout, cfi_flash_bank::buf_write_timeout_max, cfi_flash_bank::buf_write_timeout_typ, cfi_0001_fixups, cfi_0002_fixups, cfi_fixup(), cfi_fixup_non_cfi(), cfi_flash_address(), CFI_MAX_BUS_WIDTH, cfi_query_string(), cfi_query_u16(), cfi_query_u32(), cfi_query_u8(), cfi_read_0002_pri_ext(), cfi_read_intel_pri_ext(), cfi_reset(), cfi_send_command(), CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, cfi_target_read_memory(), cfi_flash_bank::chip_erase_timeout, cfi_flash_bank::chip_erase_timeout_max, cfi_flash_bank::chip_erase_timeout_typ, cfi_flash_bank::dev_size, cfi_flash_bank::device_id, DIV_ROUND_UP, cfi_flash_bank::erase_region_info, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, ERROR_TARGET_NOT_HALTED, cfi_flash_bank::interface_desc, cfi_flash_bank::jedec_probe, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_USER, LOG_WARNING, cfi_flash_bank::manufacturer, cfi_flash_bank::max_buf_write_size, cfi_flash_bank::not_cfi, NULL, cfi_flash_bank::num_erase_regions, offset, cfi_flash_bank::pri_addr, cfi_flash_bank::pri_id, cfi_flash_bank::probed, cfi_flash_bank::qry, cfi_flash_bank::status_poll_mask, target_buffer_get_u16(), target_buffer_get_u32(), TARGET_HALTED, cfi_flash_bank::vcc_max, cfi_flash_bank::vcc_min, cfi_flash_bank::vpp_max, cfi_flash_bank::vpp_min, cfi_flash_bank::word_write_timeout, cfi_flash_bank::word_write_timeout_max, and cfi_flash_bank::word_write_timeout_typ.

Referenced by cfi_auto_probe().

◆ cfi_protect()

int cfi_protect ( struct flash_bank bank,
int  set,
unsigned int  first,
unsigned int  last 
)

◆ cfi_protect_check()

◆ cfi_query_string()

static int cfi_query_string ( struct flash_bank bank,
int  address 
)
static

◆ cfi_query_u16()

static int cfi_query_u16 ( struct flash_bank bank,
int  sector,
uint32_t  offset,
uint16_t *  val 
)
static

◆ cfi_query_u32()

static int cfi_query_u32 ( struct flash_bank bank,
int  sector,
uint32_t  offset,
uint32_t *  val 
)
static

◆ cfi_query_u8()

static int cfi_query_u8 ( struct flash_bank bank,
int  sector,
uint32_t  offset,
uint8_t *  val 
)
static

◆ cfi_read()

static int cfi_read ( struct flash_bank bank,
uint8_t *  buffer,
uint32_t  offset,
uint32_t  count 
)
static

◆ cfi_read_0002_pri_ext()

static int cfi_read_0002_pri_ext ( struct flash_bank bank)
static

◆ cfi_read_atmel_pri_ext()

◆ cfi_read_intel_pri_ext()

◆ cfi_read_spansion_pri_ext()

◆ cfi_reset()

◆ cfi_send_command()

◆ cfi_spansion_erase()

static int cfi_spansion_erase ( struct flash_bank bank,
unsigned int  first,
unsigned int  last 
)
static

◆ cfi_spansion_info()

◆ cfi_spansion_protect_check()

static int cfi_spansion_protect_check ( struct flash_bank bank)
static

◆ cfi_spansion_unlock_seq()

◆ cfi_spansion_wait_status_busy()

◆ cfi_spansion_write_block()

◆ cfi_spansion_write_block_mips()

◆ cfi_spansion_write_word()

◆ cfi_spansion_write_words()

static int cfi_spansion_write_words ( struct flash_bank bank,
const uint8_t *  word,
uint32_t  wordcount,
uint32_t  address 
)
static

◆ cfi_target_read_memory()

int cfi_target_read_memory ( struct flash_bank bank,
target_addr_t  addr,
uint32_t  count,
uint8_t *  buffer 
)

◆ cfi_target_write_memory()

static int cfi_target_write_memory ( struct flash_bank bank,
target_addr_t  addr,
uint32_t  count,
const uint8_t *  buffer 
)
static

◆ cfi_write()

◆ cfi_write_word()

int cfi_write_word ( struct flash_bank bank,
uint8_t *  word,
uint32_t  address 
)

◆ cfi_write_words()

static int cfi_write_words ( struct flash_bank bank,
const uint8_t *  word,
uint32_t  wordcount,
uint32_t  address 
)
static

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( cfi_flash_bank_command  )

Definition at line 835 of file cfi.c.

References bank, cfi_flash_bank_cmd(), CMD_ARGC, and CMD_ARGV.

Variable Documentation

◆ cfi_0001_fixups

const struct cfi_fixup cfi_0001_fixups[]
static
Initial value:
= {
{0, 0, NULL, NULL}
}
#define NULL
Definition: usb.h:16

Definition at line 45 of file cfi.c.

Referenced by cfi_probe().

◆ cfi_0002_fixups

const struct cfi_fixup cfi_0002_fixups[]
static

Definition at line 45 of file cfi.c.

Referenced by cfi_probe().

◆ cfi_flash

const struct flash_driver cfi_flash
Initial value:
= {
.name = "cfi",
.flash_bank_command = cfi_flash_bank_command,
.erase = cfi_erase,
.protect = cfi_protect,
.write = cfi_write,
.read = cfi_read,
.probe = cfi_probe,
.auto_probe = cfi_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = cfi_protect_check,
.info = cfi_get_info,
.free_driver_priv = default_flash_free_driver_priv,
}
static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: cfi.c:2213
int cfi_protect_check(struct flash_bank *bank)
Definition: cfi.c:2929
int cfi_probe(struct flash_bank *bank)
Definition: cfi.c:2531
static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: cfi.c:2280
int cfi_auto_probe(struct flash_bank *bank)
Definition: cfi.c:2863
int cfi_get_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: cfi.c:2955
int cfi_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: cfi.c:1073
int cfi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: cfi.c:931
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.

Definition at line 3029 of file cfi.c.

◆ cfi_status_poll_mask_dq6_dq7

const int cfi_status_poll_mask_dq6_dq7 = CFI_STATUS_POLL_MASK_DQ6_DQ7
static

Definition at line 38 of file cfi.c.

◆ cfi_unlock_addresses

Initial value:
= {
[CFI_UNLOCK_555_2AA] = { .unlock1 = 0x555, .unlock2 = 0x2aa },
[CFI_UNLOCK_5555_2AAA] = { .unlock1 = 0x5555, .unlock2 = 0x2aaa },
}
@ CFI_UNLOCK_555_2AA
Definition: cfi.h:130
@ CFI_UNLOCK_5555_2AAA
Definition: cfi.h:131

Definition at line 1 of file cfi.c.