flash/nor: Rename flash_address() to cfi_flash_address()

This is a preparatory change, align the function name with the rest
of the API, no functional change.

Change-Id: I6a810d2a54edcd13ad9a87d24a7334802c41623b
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5391
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
Marek Vasut 2020-01-05 22:34:42 +01:00 committed by Tomas Vanek
parent 76de1c8de1
commit f22883e8c1
1 changed files with 51 additions and 51 deletions

View File

@ -112,7 +112,7 @@ static void cfi_fixup(struct flash_bank *bank, const struct cfi_fixup *fixups)
}
}
static inline uint32_t flash_address(struct flash_bank *bank, int sector, uint32_t offset)
static inline uint32_t cfi_flash_address(struct flash_bank *bank, int sector, uint32_t offset)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
@ -193,7 +193,7 @@ static int cfi_query_u8(struct flash_bank *bank, int sector, uint32_t offset, ui
uint8_t data[CFI_MAX_BUS_WIDTH];
int retval;
retval = cfi_target_read_memory(bank, flash_address(bank, sector, offset),
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, sector, offset),
1, data);
if (retval != ERROR_OK)
return retval;
@ -217,7 +217,7 @@ static int cfi_get_u8(struct flash_bank *bank, int sector, uint32_t offset, uint
int i;
int retval;
retval = cfi_target_read_memory(bank, flash_address(bank, sector, offset),
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, sector, offset),
1, data);
if (retval != ERROR_OK)
return retval;
@ -246,13 +246,13 @@ static int cfi_query_u16(struct flash_bank *bank, int sector, uint32_t offset, u
if (cfi_info->x16_as_x8) {
uint8_t i;
for (i = 0; i < 2; i++) {
retval = cfi_target_read_memory(bank, flash_address(bank, sector, offset + i),
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, sector, offset + i),
1, &data[i * bank->bus_width]);
if (retval != ERROR_OK)
return retval;
}
} else {
retval = cfi_target_read_memory(bank, flash_address(bank, sector, offset),
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, sector, offset),
2, data);
if (retval != ERROR_OK)
return retval;
@ -275,13 +275,13 @@ static int cfi_query_u32(struct flash_bank *bank, int sector, uint32_t offset, u
if (cfi_info->x16_as_x8) {
uint8_t i;
for (i = 0; i < 4; i++) {
retval = cfi_target_read_memory(bank, flash_address(bank, sector, offset + i),
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, sector, offset + i),
1, &data[i * bank->bus_width]);
if (retval != ERROR_OK)
return retval;
}
} else {
retval = cfi_target_read_memory(bank, flash_address(bank, sector, offset),
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, sector, offset),
4, data);
if (retval != ERROR_OK)
return retval;
@ -303,11 +303,11 @@ static int cfi_reset(struct flash_bank *bank)
struct cfi_flash_bank *cfi_info = bank->driver_priv;
int retval = ERROR_OK;
retval = cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
@ -315,7 +315,7 @@ static int cfi_reset(struct flash_bank *bank)
(cfi_info->device_id == 0x227E || cfi_info->device_id == 0x7E)) {
/* Numonix M29W128G is cmd 0xFF intolerant - causes internal undefined state
* so we send an extra 0xF0 reset to fix the bug */
retval = cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x00));
retval = cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x00));
if (retval != ERROR_OK)
return retval;
}
@ -325,7 +325,7 @@ static int cfi_reset(struct flash_bank *bank)
static void cfi_intel_clear_status_register(struct flash_bank *bank)
{
cfi_send_command(bank, 0x50, flash_address(bank, 0, 0x0));
cfi_send_command(bank, 0x50, cfi_flash_address(bank, 0, 0x0));
}
static int cfi_intel_wait_status_busy(struct flash_bank *bank, int timeout, uint8_t *val)
@ -554,7 +554,7 @@ static int cfi_read_spansion_pri_ext(struct flash_bank *bank)
pri_ext->_reversed_geometry = 0;
if ((pri_ext->pri[0] != 'P') || (pri_ext->pri[1] != 'R') || (pri_ext->pri[2] != 'I')) {
retval = cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
LOG_ERROR("Could not read spansion bank information");
@ -661,7 +661,7 @@ static int cfi_read_atmel_pri_ext(struct flash_bank *bank)
if ((atmel_pri_ext.pri[0] != 'P') || (atmel_pri_ext.pri[1] != 'R')
|| (atmel_pri_ext.pri[2] != 'I')) {
retval = cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
LOG_ERROR("Could not read atmel bank information");
@ -889,11 +889,11 @@ static int cfi_intel_erase(struct flash_bank *bank, int first, int last)
cfi_intel_clear_status_register(bank);
for (i = first; i <= last; i++) {
retval = cfi_send_command(bank, 0x20, flash_address(bank, i, 0x0));
retval = cfi_send_command(bank, 0x20, cfi_flash_address(bank, i, 0x0));
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0xd0, flash_address(bank, i, 0x0));
retval = cfi_send_command(bank, 0xd0, cfi_flash_address(bank, i, 0x0));
if (retval != ERROR_OK)
return retval;
@ -905,7 +905,7 @@ static int cfi_intel_erase(struct flash_bank *bank, int first, int last)
if (status == 0x80)
bank->sectors[i].is_erased = 1;
else {
retval = cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
@ -915,7 +915,7 @@ static int cfi_intel_erase(struct flash_bank *bank, int first, int last)
}
}
return cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0));
return cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
}
static int cfi_spansion_unlock_seq(struct flash_bank *bank)
@ -924,11 +924,11 @@ static int cfi_spansion_unlock_seq(struct flash_bank *bank)
struct cfi_flash_bank *cfi_info = bank->driver_priv;
struct cfi_spansion_pri_ext *pri_ext = cfi_info->pri_ext;
retval = cfi_send_command(bank, 0xaa, flash_address(bank, 0, pri_ext->_unlock1));
retval = cfi_send_command(bank, 0xaa, cfi_flash_address(bank, 0, pri_ext->_unlock1));
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0x55, flash_address(bank, 0, pri_ext->_unlock2));
retval = cfi_send_command(bank, 0x55, cfi_flash_address(bank, 0, pri_ext->_unlock2));
if (retval != ERROR_OK)
return retval;
@ -947,7 +947,7 @@ static int cfi_spansion_erase(struct flash_bank *bank, int first, int last)
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0x80, flash_address(bank, 0, pri_ext->_unlock1));
retval = cfi_send_command(bank, 0x80, cfi_flash_address(bank, 0, pri_ext->_unlock1));
if (retval != ERROR_OK)
return retval;
@ -955,14 +955,14 @@ static int cfi_spansion_erase(struct flash_bank *bank, int first, int last)
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0x30, flash_address(bank, i, 0x0));
retval = cfi_send_command(bank, 0x30, cfi_flash_address(bank, i, 0x0));
if (retval != ERROR_OK)
return retval;
if (cfi_spansion_wait_status_busy(bank, cfi_info->block_erase_timeout) == ERROR_OK)
bank->sectors[i].is_erased = 1;
else {
retval = cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
@ -972,7 +972,7 @@ static int cfi_spansion_erase(struct flash_bank *bank, int first, int last)
}
}
return cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x0));
return cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
}
static int cfi_erase(struct flash_bank *bank, int first, int last)
@ -1025,16 +1025,16 @@ static int cfi_intel_protect(struct flash_bank *bank, int set, int first, int la
cfi_intel_clear_status_register(bank);
for (i = first; i <= last; i++) {
retval = cfi_send_command(bank, 0x60, flash_address(bank, i, 0x0));
retval = cfi_send_command(bank, 0x60, cfi_flash_address(bank, i, 0x0));
if (retval != ERROR_OK)
return retval;
if (set) {
retval = cfi_send_command(bank, 0x01, flash_address(bank, i, 0x0));
retval = cfi_send_command(bank, 0x01, cfi_flash_address(bank, i, 0x0));
if (retval != ERROR_OK)
return retval;
bank->sectors[i].is_protected = 1;
} else {
retval = cfi_send_command(bank, 0xd0, flash_address(bank, i, 0x0));
retval = cfi_send_command(bank, 0xd0, cfi_flash_address(bank, i, 0x0));
if (retval != ERROR_OK)
return retval;
bank->sectors[i].is_protected = 0;
@ -1051,7 +1051,7 @@ static int cfi_intel_protect(struct flash_bank *bank, int set, int first, int la
} else {
uint8_t block_status;
/* read block lock bit, to verify status */
retval = cfi_send_command(bank, 0x90, flash_address(bank, 0, 0x55));
retval = cfi_send_command(bank, 0x90, cfi_flash_address(bank, 0, 0x55));
if (retval != ERROR_OK)
return retval;
retval = cfi_get_u8(bank, i, 0x2, &block_status);
@ -1062,7 +1062,7 @@ static int cfi_intel_protect(struct flash_bank *bank, int set, int first, int la
LOG_ERROR(
"couldn't change block lock status (set = %i, block_status = 0x%2.2x)",
set, block_status);
retval = cfi_send_command(bank, 0x70, flash_address(bank, 0, 0x55));
retval = cfi_send_command(bank, 0x70, cfi_flash_address(bank, 0, 0x55));
if (retval != ERROR_OK)
return retval;
uint8_t status;
@ -1099,11 +1099,11 @@ static int cfi_intel_protect(struct flash_bank *bank, int set, int first, int la
if (bank->sectors[i].is_protected == 1) {
cfi_intel_clear_status_register(bank);
retval = cfi_send_command(bank, 0x60, flash_address(bank, i, 0x0));
retval = cfi_send_command(bank, 0x60, cfi_flash_address(bank, i, 0x0));
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0x01, flash_address(bank, i, 0x0));
retval = cfi_send_command(bank, 0x01, cfi_flash_address(bank, i, 0x0));
if (retval != ERROR_OK)
return retval;
@ -1115,7 +1115,7 @@ static int cfi_intel_protect(struct flash_bank *bank, int set, int first, int la
}
}
return cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0));
return cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
}
static int cfi_protect(struct flash_bank *bank, int set, int first, int last)
@ -1587,9 +1587,9 @@ static int cfi_spansion_write_block_mips(struct flash_bank *bank, const uint8_t
buf_set_u32(reg_params[2].value, 0, 32, thisrun_count / bank->bus_width);
buf_set_u32(reg_params[3].value, 0, 32, cfi_command_val(bank, 0xA0));
buf_set_u32(reg_params[4].value, 0, 32, cfi_command_val(bank, 0x80));
buf_set_u32(reg_params[6].value, 0, 32, flash_address(bank, 0, pri_ext->_unlock1));
buf_set_u32(reg_params[6].value, 0, 32, cfi_flash_address(bank, 0, pri_ext->_unlock1));
buf_set_u32(reg_params[7].value, 0, 32, 0xaaaaaaaa);
buf_set_u32(reg_params[8].value, 0, 32, flash_address(bank, 0, pri_ext->_unlock2));
buf_set_u32(reg_params[8].value, 0, 32, cfi_flash_address(bank, 0, pri_ext->_unlock2));
buf_set_u32(reg_params[9].value, 0, 32, 0x55555555);
retval = target_run_algorithm(target, 0, NULL, 10, reg_params,
@ -1966,9 +1966,9 @@ static int cfi_spansion_write_block(struct flash_bank *bank, const uint8_t *buff
buf_set_u32(reg_params[2].value, 0, 32, thisrun_count / bank->bus_width);
buf_set_u32(reg_params[3].value, 0, 32, cfi_command_val(bank, 0xA0));
buf_set_u32(reg_params[4].value, 0, 32, cfi_command_val(bank, 0x80));
buf_set_u32(reg_params[6].value, 0, 32, flash_address(bank, 0, pri_ext->_unlock1));
buf_set_u32(reg_params[6].value, 0, 32, cfi_flash_address(bank, 0, pri_ext->_unlock1));
buf_set_u32(reg_params[7].value, 0, 32, 0xaaaaaaaa);
buf_set_u32(reg_params[8].value, 0, 32, flash_address(bank, 0, pri_ext->_unlock2));
buf_set_u32(reg_params[8].value, 0, 32, cfi_flash_address(bank, 0, pri_ext->_unlock2));
buf_set_u32(reg_params[9].value, 0, 32, 0x55555555);
retval = target_run_algorithm(target, 0, NULL, 10, reg_params,
@ -2025,7 +2025,7 @@ static int cfi_intel_write_word(struct flash_bank *bank, uint8_t *word, uint32_t
if (retval != ERROR_OK)
return retval;
if (status != 0x80) {
retval = cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
@ -2079,7 +2079,7 @@ static int cfi_intel_write_words(struct flash_bank *bank, const uint8_t *word,
if (retval != ERROR_OK)
return retval;
if (status != 0x80) {
retval = cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
@ -2110,7 +2110,7 @@ static int cfi_intel_write_words(struct flash_bank *bank, const uint8_t *word,
return retval;
if (status != 0x80) {
retval = cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
@ -2132,7 +2132,7 @@ static int cfi_spansion_write_word(struct flash_bank *bank, uint8_t *word, uint3
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0xa0, flash_address(bank, 0, pri_ext->_unlock1));
retval = cfi_send_command(bank, 0xa0, cfi_flash_address(bank, 0, pri_ext->_unlock1));
if (retval != ERROR_OK)
return retval;
@ -2141,7 +2141,7 @@ static int cfi_spansion_write_word(struct flash_bank *bank, uint8_t *word, uint3
return retval;
if (cfi_spansion_wait_status_busy(bank, cfi_info->word_write_timeout) != ERROR_OK) {
retval = cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
@ -2207,7 +2207,7 @@ static int cfi_spansion_write_words(struct flash_bank *bank, const uint8_t *word
return retval;
if (cfi_spansion_wait_status_busy(bank, cfi_info->buf_write_timeout) != ERROR_OK) {
retval = cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x0));
retval = cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
@ -2563,7 +2563,7 @@ static int cfi_query_string(struct flash_bank *bank, int address)
struct cfi_flash_bank *cfi_info = bank->driver_priv;
int retval;
retval = cfi_send_command(bank, 0x98, flash_address(bank, 0, address));
retval = cfi_send_command(bank, 0x98, cfi_flash_address(bank, 0, address));
if (retval != ERROR_OK)
return retval;
@ -2628,21 +2628,21 @@ static int cfi_probe(struct flash_bank *bank)
}
/* switch to read identifier codes mode ("AUTOSELECT") */
retval = cfi_send_command(bank, 0xaa, flash_address(bank, 0, unlock1));
retval = cfi_send_command(bank, 0xaa, cfi_flash_address(bank, 0, unlock1));
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0x55, flash_address(bank, 0, unlock2));
retval = cfi_send_command(bank, 0x55, cfi_flash_address(bank, 0, unlock2));
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0x90, flash_address(bank, 0, unlock1));
retval = cfi_send_command(bank, 0x90, cfi_flash_address(bank, 0, unlock1));
if (retval != ERROR_OK)
return retval;
retval = cfi_target_read_memory(bank, flash_address(bank, 0, 0x00),
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, 0, 0x00),
1, value_buf0);
if (retval != ERROR_OK)
return retval;
retval = cfi_target_read_memory(bank, flash_address(bank, 0, 0x01),
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, 0, 0x01),
1, value_buf1);
if (retval != ERROR_OK)
return retval;
@ -2946,7 +2946,7 @@ static int cfi_intel_protect_check(struct flash_bank *bank)
if (!(pri_ext->blk_status_reg_mask & 0x1))
return ERROR_FLASH_OPERATION_FAILED;
retval = cfi_send_command(bank, 0x90, flash_address(bank, 0, 0x55));
retval = cfi_send_command(bank, 0x90, cfi_flash_address(bank, 0, 0x55));
if (retval != ERROR_OK)
return retval;
@ -2962,7 +2962,7 @@ static int cfi_intel_protect_check(struct flash_bank *bank)
bank->sectors[i].is_protected = 0;
}
return cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0));
return cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
}
static int cfi_spansion_protect_check(struct flash_bank *bank)
@ -2976,7 +2976,7 @@ static int cfi_spansion_protect_check(struct flash_bank *bank)
if (retval != ERROR_OK)
return retval;
retval = cfi_send_command(bank, 0x90, flash_address(bank, 0, pri_ext->_unlock1));
retval = cfi_send_command(bank, 0x90, cfi_flash_address(bank, 0, pri_ext->_unlock1));
if (retval != ERROR_OK)
return retval;
@ -2992,7 +2992,7 @@ static int cfi_spansion_protect_check(struct flash_bank *bank)
bank->sectors[i].is_protected = 0;
}
return cfi_send_command(bank, 0xf0, flash_address(bank, 0, 0x0));
return cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
}
static int cfi_protect_check(struct flash_bank *bank)