flash/nor/cfi: Minor code cleanups
Change-Id: I2d45fcc5b9d232db66218aab5fef3add5830bcd7 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5463 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
1c16d76c00
commit
af82b97834
src/flash/nor
|
@ -100,9 +100,8 @@ static const struct cfi_fixup cfi_0001_fixups[] = {
|
||||||
static void cfi_fixup(struct flash_bank *bank, const struct cfi_fixup *fixups)
|
static void cfi_fixup(struct flash_bank *bank, const struct cfi_fixup *fixups)
|
||||||
{
|
{
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
const struct cfi_fixup *f;
|
|
||||||
|
|
||||||
for (f = fixups; f->fixup; f++) {
|
for (const struct cfi_fixup *f = fixups; f->fixup; f++) {
|
||||||
if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi_info->manufacturer)) &&
|
if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi_info->manufacturer)) &&
|
||||||
((f->id == CFI_ID_ANY) || (f->id == cfi_info->device_id)))
|
((f->id == CFI_ID_ANY) || (f->id == cfi_info->device_id)))
|
||||||
f->fixup(bank, f->param);
|
f->fixup(bank, f->param);
|
||||||
|
@ -154,20 +153,19 @@ int cfi_target_read_memory(struct flash_bank *bank, target_addr_t addr,
|
||||||
|
|
||||||
static void cfi_command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
|
static void cfi_command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
|
|
||||||
/* clear whole buffer, to ensure bits that exceed the bus_width
|
/* clear whole buffer, to ensure bits that exceed the bus_width
|
||||||
* are set to zero
|
* are set to zero
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < CFI_MAX_BUS_WIDTH; i++)
|
for (size_t i = 0; i < CFI_MAX_BUS_WIDTH; i++)
|
||||||
cmd_buf[i] = 0;
|
cmd_buf[i] = 0;
|
||||||
|
|
||||||
if (cfi_info->endianness == TARGET_LITTLE_ENDIAN) {
|
if (cfi_info->endianness == TARGET_LITTLE_ENDIAN) {
|
||||||
for (i = bank->bus_width; i > 0; i--)
|
for (int i = bank->bus_width; i > 0; i--)
|
||||||
*cmd_buf++ = (i & (bank->chip_width - 1)) ? 0x0 : cmd;
|
*cmd_buf++ = (i & (bank->chip_width - 1)) ? 0x0 : cmd;
|
||||||
} else {
|
} else {
|
||||||
for (i = 1; i <= bank->bus_width; i++)
|
for (int i = 1; i <= bank->bus_width; i++)
|
||||||
*cmd_buf++ = (i & (bank->chip_width - 1)) ? 0x0 : cmd;
|
*cmd_buf++ = (i & (bank->chip_width - 1)) ? 0x0 : cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +209,6 @@ static int cfi_get_u8(struct flash_bank *bank, int sector, uint32_t offset, uint
|
||||||
{
|
{
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
uint8_t data[CFI_MAX_BUS_WIDTH];
|
uint8_t data[CFI_MAX_BUS_WIDTH];
|
||||||
int i;
|
|
||||||
|
|
||||||
int retval;
|
int retval;
|
||||||
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, sector, offset),
|
retval = cfi_target_read_memory(bank, cfi_flash_address(bank, sector, offset),
|
||||||
|
@ -220,13 +217,13 @@ static int cfi_get_u8(struct flash_bank *bank, int sector, uint32_t offset, uint
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
if (cfi_info->endianness == TARGET_LITTLE_ENDIAN) {
|
if (cfi_info->endianness == TARGET_LITTLE_ENDIAN) {
|
||||||
for (i = 0; i < bank->bus_width / bank->chip_width; i++)
|
for (int i = 0; i < bank->bus_width / bank->chip_width; i++)
|
||||||
data[0] |= data[i];
|
data[0] |= data[i];
|
||||||
|
|
||||||
*val = data[0];
|
*val = data[0];
|
||||||
} else {
|
} else {
|
||||||
uint8_t value = 0;
|
uint8_t value = 0;
|
||||||
for (i = 0; i < bank->bus_width / bank->chip_width; i++)
|
for (int i = 0; i < bank->bus_width / bank->chip_width; i++)
|
||||||
value |= data[bank->bus_width - 1 - i];
|
value |= data[bank->bus_width - 1 - i];
|
||||||
|
|
||||||
*val = value;
|
*val = value;
|
||||||
|
@ -241,8 +238,7 @@ static int cfi_query_u16(struct flash_bank *bank, int sector, uint32_t offset, u
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (cfi_info->x16_as_x8) {
|
if (cfi_info->x16_as_x8) {
|
||||||
uint8_t i;
|
for (uint8_t i = 0; i < 2; i++) {
|
||||||
for (i = 0; i < 2; i++) {
|
|
||||||
retval = cfi_target_read_memory(bank, cfi_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]);
|
1, &data[i * bank->bus_width]);
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
|
@ -270,8 +266,7 @@ static int cfi_query_u32(struct flash_bank *bank, int sector, uint32_t offset, u
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (cfi_info->x16_as_x8) {
|
if (cfi_info->x16_as_x8) {
|
||||||
uint8_t i;
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
retval = cfi_target_read_memory(bank, cfi_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]);
|
1, &data[i * bank->bus_width]);
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
|
@ -841,7 +836,7 @@ int cfi_flash_bank_cmd(struct flash_bank *bank, unsigned int argc, const char **
|
||||||
}
|
}
|
||||||
|
|
||||||
cfi_info = malloc(sizeof(struct cfi_flash_bank));
|
cfi_info = malloc(sizeof(struct cfi_flash_bank));
|
||||||
cfi_info->probed = 0;
|
cfi_info->probed = false;
|
||||||
cfi_info->erase_region_info = NULL;
|
cfi_info->erase_region_info = NULL;
|
||||||
cfi_info->pri_ext = NULL;
|
cfi_info->pri_ext = NULL;
|
||||||
bank->driver_priv = cfi_info;
|
bank->driver_priv = cfi_info;
|
||||||
|
@ -886,11 +881,10 @@ static int cfi_intel_erase(struct flash_bank *bank, int first, int last)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
int i;
|
|
||||||
|
|
||||||
cfi_intel_clear_status_register(bank);
|
cfi_intel_clear_status_register(bank);
|
||||||
|
|
||||||
for (i = first; i <= last; i++) {
|
for (int i = first; i <= last; i++) {
|
||||||
retval = cfi_send_command(bank, 0x20, cfi_flash_address(bank, i, 0x0));
|
retval = cfi_send_command(bank, 0x20, cfi_flash_address(bank, i, 0x0));
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -942,9 +936,8 @@ static int cfi_spansion_erase(struct flash_bank *bank, int first, int last)
|
||||||
int retval;
|
int retval;
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
struct cfi_spansion_pri_ext *pri_ext = cfi_info->pri_ext;
|
struct cfi_spansion_pri_ext *pri_ext = cfi_info->pri_ext;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = first; i <= last; i++) {
|
for (int i = first; i <= last; i++) {
|
||||||
retval = cfi_spansion_unlock_seq(bank);
|
retval = cfi_spansion_unlock_seq(bank);
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1014,7 +1007,6 @@ static int cfi_intel_protect(struct flash_bank *bank, int set, int first, int la
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
struct cfi_intel_pri_ext *pri_ext = cfi_info->pri_ext;
|
struct cfi_intel_pri_ext *pri_ext = cfi_info->pri_ext;
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* if the device supports neither legacy lock/unlock (bit 3) nor
|
/* if the device supports neither legacy lock/unlock (bit 3) nor
|
||||||
* instant individual block locking (bit 5).
|
* instant individual block locking (bit 5).
|
||||||
|
@ -1026,7 +1018,7 @@ static int cfi_intel_protect(struct flash_bank *bank, int set, int first, int la
|
||||||
|
|
||||||
cfi_intel_clear_status_register(bank);
|
cfi_intel_clear_status_register(bank);
|
||||||
|
|
||||||
for (i = first; i <= last; i++) {
|
for (int i = first; i <= last; i++) {
|
||||||
retval = cfi_send_command(bank, 0x60, cfi_flash_address(bank, i, 0x0));
|
retval = cfi_send_command(bank, 0x60, cfi_flash_address(bank, i, 0x0));
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1097,7 +1089,7 @@ static int cfi_intel_protect(struct flash_bank *bank, int set, int first, int la
|
||||||
* 3. re-protect what should be protected.
|
* 3. re-protect what should be protected.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < bank->num_sectors; i++) {
|
for (int i = 0; i < bank->num_sectors; i++) {
|
||||||
if (bank->sectors[i].is_protected == 1) {
|
if (bank->sectors[i].is_protected == 1) {
|
||||||
cfi_intel_clear_status_register(bank);
|
cfi_intel_clear_status_register(bank);
|
||||||
|
|
||||||
|
@ -2276,7 +2268,6 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u
|
||||||
uint32_t read_p;
|
uint32_t read_p;
|
||||||
int align; /* number of unaligned bytes */
|
int align; /* number of unaligned bytes */
|
||||||
uint8_t current_word[CFI_MAX_BUS_WIDTH];
|
uint8_t current_word[CFI_MAX_BUS_WIDTH];
|
||||||
int i;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
LOG_DEBUG("reading buffer of %i byte at 0x%8.8x",
|
LOG_DEBUG("reading buffer of %i byte at 0x%8.8x",
|
||||||
|
@ -2305,7 +2296,7 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* take only bytes we need */
|
/* take only bytes we need */
|
||||||
for (i = align; (i < bank->bus_width) && (count > 0); i++, count--)
|
for (int i = align; (i < bank->bus_width) && (count > 0); i++, count--)
|
||||||
*buffer++ = current_word[i];
|
*buffer++ = current_word[i];
|
||||||
|
|
||||||
read_p += bank->bus_width;
|
read_p += bank->bus_width;
|
||||||
|
@ -2331,7 +2322,7 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* take only bytes we need */
|
/* take only bytes we need */
|
||||||
for (i = 0; (i < bank->bus_width) && (count > 0); i++, count--)
|
for (int i = 0; (i < bank->bus_width) && (count > 0); i++, count--)
|
||||||
*buffer++ = current_word[i];
|
*buffer++ = current_word[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2349,7 +2340,6 @@ static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t of
|
||||||
*programmed */
|
*programmed */
|
||||||
uint8_t *swapped_buffer = NULL;
|
uint8_t *swapped_buffer = NULL;
|
||||||
const uint8_t *real_buffer = NULL;
|
const uint8_t *real_buffer = NULL;
|
||||||
int i;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (bank->target->state != TARGET_HALTED) {
|
if (bank->target->state != TARGET_HALTED) {
|
||||||
|
@ -2375,7 +2365,7 @@ static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t of
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* replace only bytes that must be written */
|
/* replace only bytes that must be written */
|
||||||
for (i = align;
|
for (int i = align;
|
||||||
(i < bank->bus_width) && (count > 0);
|
(i < bank->bus_width) && (count > 0);
|
||||||
i++, count--)
|
i++, count--)
|
||||||
if (cfi_info->data_swap)
|
if (cfi_info->data_swap)
|
||||||
|
@ -2441,12 +2431,12 @@ static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t of
|
||||||
|
|
||||||
/* fall back to memory writes */
|
/* fall back to memory writes */
|
||||||
while (count >= (uint32_t)bank->bus_width) {
|
while (count >= (uint32_t)bank->bus_width) {
|
||||||
int fallback;
|
bool fallback;
|
||||||
if ((write_p & 0xff) == 0) {
|
if ((write_p & 0xff) == 0) {
|
||||||
LOG_INFO("Programming at 0x%08" PRIx32 ", count 0x%08"
|
LOG_INFO("Programming at 0x%08" PRIx32 ", count 0x%08"
|
||||||
PRIx32 " bytes remaining", write_p, count);
|
PRIx32 " bytes remaining", write_p, count);
|
||||||
}
|
}
|
||||||
fallback = 1;
|
fallback = true;
|
||||||
if ((bufferwsize > 0) && (count >= buffersize) &&
|
if ((bufferwsize > 0) && (count >= buffersize) &&
|
||||||
!(write_p & buffermask)) {
|
!(write_p & buffermask)) {
|
||||||
retval = cfi_write_words(bank, buffer, bufferwsize, write_p);
|
retval = cfi_write_words(bank, buffer, bufferwsize, write_p);
|
||||||
|
@ -2454,13 +2444,13 @@ static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t of
|
||||||
buffer += buffersize;
|
buffer += buffersize;
|
||||||
write_p += buffersize;
|
write_p += buffersize;
|
||||||
count -= buffersize;
|
count -= buffersize;
|
||||||
fallback = 0;
|
fallback = false;
|
||||||
} else if (retval != ERROR_FLASH_OPER_UNSUPPORTED)
|
} else if (retval != ERROR_FLASH_OPER_UNSUPPORTED)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
/* try the slow way? */
|
/* try the slow way? */
|
||||||
if (fallback) {
|
if (fallback) {
|
||||||
for (i = 0; i < bank->bus_width; i++)
|
for (int i = 0; i < bank->bus_width; i++)
|
||||||
current_word[i] = *buffer++;
|
current_word[i] = *buffer++;
|
||||||
|
|
||||||
retval = cfi_write_word(bank, current_word, write_p);
|
retval = cfi_write_word(bank, current_word, write_p);
|
||||||
|
@ -2495,7 +2485,7 @@ static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t of
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* replace only bytes that must be written */
|
/* replace only bytes that must be written */
|
||||||
for (i = 0; (i < bank->bus_width) && (count > 0); i++, count--)
|
for (int i = 0; (i < bank->bus_width) && (count > 0); i++, count--)
|
||||||
if (cfi_info->data_swap)
|
if (cfi_info->data_swap)
|
||||||
/* data bytes are swapped (reverse endianness) */
|
/* data bytes are swapped (reverse endianness) */
|
||||||
current_word[bank->bus_width - i] = *buffer++;
|
current_word[bank->bus_width - i] = *buffer++;
|
||||||
|
@ -2522,7 +2512,6 @@ static void cfi_fixup_reversed_erase_regions(struct flash_bank *bank, const void
|
||||||
|
|
||||||
static void cfi_fixup_0002_erase_regions(struct flash_bank *bank, const void *param)
|
static void cfi_fixup_0002_erase_regions(struct flash_bank *bank, const void *param)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
struct cfi_spansion_pri_ext *pri_ext = cfi_info->pri_ext;
|
struct cfi_spansion_pri_ext *pri_ext = cfi_info->pri_ext;
|
||||||
(void) param;
|
(void) param;
|
||||||
|
@ -2530,7 +2519,7 @@ static void cfi_fixup_0002_erase_regions(struct flash_bank *bank, const void *pa
|
||||||
if ((pri_ext->_reversed_geometry) || (pri_ext->TopBottom == 3)) {
|
if ((pri_ext->_reversed_geometry) || (pri_ext->TopBottom == 3)) {
|
||||||
LOG_DEBUG("swapping reversed erase region information on cmdset 0002 device");
|
LOG_DEBUG("swapping reversed erase region information on cmdset 0002 device");
|
||||||
|
|
||||||
for (i = 0; i < cfi_info->num_erase_regions / 2; i++) {
|
for (unsigned int i = 0; i < cfi_info->num_erase_regions / 2; i++) {
|
||||||
int j = (cfi_info->num_erase_regions - 1) - i;
|
int j = (cfi_info->num_erase_regions - 1) - i;
|
||||||
uint32_t swap;
|
uint32_t swap;
|
||||||
|
|
||||||
|
@ -2598,7 +2587,6 @@ int cfi_probe(struct flash_bank *bank)
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
struct target *target = bank->target;
|
struct target *target = bank->target;
|
||||||
int num_sectors = 0;
|
int num_sectors = 0;
|
||||||
int i;
|
|
||||||
int sector = 0;
|
int sector = 0;
|
||||||
uint32_t unlock1 = 0x555;
|
uint32_t unlock1 = 0x555;
|
||||||
uint32_t unlock2 = 0x2aa;
|
uint32_t unlock2 = 0x2aa;
|
||||||
|
@ -2610,7 +2598,7 @@ int cfi_probe(struct flash_bank *bank)
|
||||||
return ERROR_TARGET_NOT_HALTED;
|
return ERROR_TARGET_NOT_HALTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfi_info->probed = 0;
|
cfi_info->probed = false;
|
||||||
cfi_info->num_erase_regions = 0;
|
cfi_info->num_erase_regions = 0;
|
||||||
if (bank->sectors) {
|
if (bank->sectors) {
|
||||||
free(bank->sectors);
|
free(bank->sectors);
|
||||||
|
@ -2782,7 +2770,7 @@ int cfi_probe(struct flash_bank *bank)
|
||||||
if (cfi_info->num_erase_regions) {
|
if (cfi_info->num_erase_regions) {
|
||||||
cfi_info->erase_region_info = malloc(sizeof(*cfi_info->erase_region_info)
|
cfi_info->erase_region_info = malloc(sizeof(*cfi_info->erase_region_info)
|
||||||
* cfi_info->num_erase_regions);
|
* cfi_info->num_erase_regions);
|
||||||
for (i = 0; i < cfi_info->num_erase_regions; i++) {
|
for (unsigned int i = 0; i < cfi_info->num_erase_regions; i++) {
|
||||||
retval = cfi_query_u32(bank,
|
retval = cfi_query_u32(bank,
|
||||||
0,
|
0,
|
||||||
0x2d + (4 * i),
|
0x2d + (4 * i),
|
||||||
|
@ -2897,15 +2885,14 @@ int cfi_probe(struct flash_bank *bank)
|
||||||
} else {
|
} else {
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
|
|
||||||
for (i = 0; i < cfi_info->num_erase_regions; i++)
|
for (unsigned int i = 0; i < cfi_info->num_erase_regions; i++)
|
||||||
num_sectors += (cfi_info->erase_region_info[i] & 0xffff) + 1;
|
num_sectors += (cfi_info->erase_region_info[i] & 0xffff) + 1;
|
||||||
|
|
||||||
bank->num_sectors = num_sectors;
|
bank->num_sectors = num_sectors;
|
||||||
bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
|
bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
|
||||||
|
|
||||||
for (i = 0; i < cfi_info->num_erase_regions; i++) {
|
for (unsigned int i = 0; i < cfi_info->num_erase_regions; i++) {
|
||||||
uint32_t j;
|
for (uint32_t j = 0; j < (cfi_info->erase_region_info[i] & 0xffff) + 1; j++) {
|
||||||
for (j = 0; j < (cfi_info->erase_region_info[i] & 0xffff) + 1; j++) {
|
|
||||||
bank->sectors[sector].offset = offset;
|
bank->sectors[sector].offset = offset;
|
||||||
bank->sectors[sector].size =
|
bank->sectors[sector].size =
|
||||||
((cfi_info->erase_region_info[i] >> 16) * 256)
|
((cfi_info->erase_region_info[i] >> 16) * 256)
|
||||||
|
@ -2924,7 +2911,7 @@ int cfi_probe(struct flash_bank *bank)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfi_info->probed = 1;
|
cfi_info->probed = true;
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
@ -2942,7 +2929,6 @@ static int cfi_intel_protect_check(struct flash_bank *bank)
|
||||||
int retval;
|
int retval;
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
struct cfi_intel_pri_ext *pri_ext = cfi_info->pri_ext;
|
struct cfi_intel_pri_ext *pri_ext = cfi_info->pri_ext;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* check if block lock bits are supported on this device */
|
/* check if block lock bits are supported on this device */
|
||||||
if (!(pri_ext->blk_status_reg_mask & 0x1))
|
if (!(pri_ext->blk_status_reg_mask & 0x1))
|
||||||
|
@ -2952,7 +2938,7 @@ static int cfi_intel_protect_check(struct flash_bank *bank)
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
for (i = 0; i < bank->num_sectors; i++) {
|
for (int i = 0; i < bank->num_sectors; i++) {
|
||||||
uint8_t block_status;
|
uint8_t block_status;
|
||||||
retval = cfi_get_u8(bank, i, 0x2, &block_status);
|
retval = cfi_get_u8(bank, i, 0x2, &block_status);
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
|
@ -2972,7 +2958,6 @@ static int cfi_spansion_protect_check(struct flash_bank *bank)
|
||||||
int retval;
|
int retval;
|
||||||
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
struct cfi_flash_bank *cfi_info = bank->driver_priv;
|
||||||
struct cfi_spansion_pri_ext *pri_ext = cfi_info->pri_ext;
|
struct cfi_spansion_pri_ext *pri_ext = cfi_info->pri_ext;
|
||||||
int i;
|
|
||||||
|
|
||||||
retval = cfi_spansion_unlock_seq(bank);
|
retval = cfi_spansion_unlock_seq(bank);
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
|
@ -2982,7 +2967,7 @@ static int cfi_spansion_protect_check(struct flash_bank *bank)
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
for (i = 0; i < bank->num_sectors; i++) {
|
for (int i = 0; i < bank->num_sectors; i++) {
|
||||||
uint8_t block_status;
|
uint8_t block_status;
|
||||||
retval = cfi_get_u8(bank, i, 0x2, &block_status);
|
retval = cfi_get_u8(bank, i, 0x2, &block_status);
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
|
|
Loading…
Reference in New Issue