Commit d8ece229 authored by Michael Schwingen's avatar Michael Schwingen Committed by Øyvind Harboe
Browse files

non-CFI flash code uses data from CFI structures. Make sure that timeouts are...


non-CFI flash code uses data from CFI structures. Make sure that timeouts are filled in on non-CFI flashes, and print CFI information in all cases, nut just on CFI flashes.
Signed-off-by: default avatarMichael Schwingen <michael@schwingen.org>
parent d356034f
......@@ -2563,39 +2563,6 @@ static int cfi_probe(struct flash_bank *bank)
if (retval != ERROR_OK)
return retval;
LOG_DEBUG("Vcc min: %x.%x, Vcc max: %x.%x, Vpp min: %u.%x, Vpp max: %u.%x",
(cfi_info->vcc_min & 0xf0) >> 4, cfi_info->vcc_min & 0x0f,
(cfi_info->vcc_max & 0xf0) >> 4, cfi_info->vcc_max & 0x0f,
(cfi_info->vpp_min & 0xf0) >> 4, cfi_info->vpp_min & 0x0f,
(cfi_info->vpp_max & 0xf0) >> 4, cfi_info->vpp_max & 0x0f);
LOG_DEBUG("typ. word write timeout: %u us, typ. buf write timeout: %u us, "
"typ. block erase timeout: %u ms, typ. chip erase timeout: %u ms",
1 << cfi_info->word_write_timeout_typ, 1 << cfi_info->buf_write_timeout_typ,
1 << cfi_info->block_erase_timeout_typ, 1 << cfi_info->chip_erase_timeout_typ);
LOG_DEBUG("max. word write timeout: %u us, max. buf write timeout: %u us, "
"max. block erase timeout: %u ms, max. chip erase timeout: %u ms",
(1 << cfi_info->word_write_timeout_max) * (1 << cfi_info->word_write_timeout_typ),
(1 << cfi_info->buf_write_timeout_max) * (1 << cfi_info->buf_write_timeout_typ),
(1 << cfi_info->block_erase_timeout_max) * (1 << cfi_info->block_erase_timeout_typ),
(1 << cfi_info->chip_erase_timeout_max) * (1 << cfi_info->chip_erase_timeout_typ));
/* convert timeouts to real values in ms */
cfi_info->word_write_timeout = DIV_ROUND_UP((1 << cfi_info->word_write_timeout_typ) *
(1 << cfi_info->word_write_timeout_max), 1000);
cfi_info->buf_write_timeout = DIV_ROUND_UP((1 << cfi_info->buf_write_timeout_typ) *
(1 << cfi_info->buf_write_timeout_max), 1000);
cfi_info->block_erase_timeout = (1 << cfi_info->block_erase_timeout_typ) *
(1 << cfi_info->block_erase_timeout_max);
cfi_info->chip_erase_timeout = (1 << cfi_info->chip_erase_timeout_typ) *
(1 << cfi_info->chip_erase_timeout_max);
LOG_DEBUG("calculated word write timeout: %u ms, buf write timeout: %u ms, "
"block erase timeout: %u ms, chip erase timeout: %u ms",
cfi_info->word_write_timeout, cfi_info->buf_write_timeout,
cfi_info->block_erase_timeout, cfi_info->chip_erase_timeout);
uint8_t data;
retval = cfi_query_u8(bank, 0, 0x27, &data);
if (retval != ERROR_OK)
......@@ -2663,6 +2630,39 @@ static int cfi_probe(struct flash_bank *bank)
}
} /* end CFI case */
LOG_DEBUG("Vcc min: %x.%x, Vcc max: %x.%x, Vpp min: %u.%x, Vpp max: %u.%x",
(cfi_info->vcc_min & 0xf0) >> 4, cfi_info->vcc_min & 0x0f,
(cfi_info->vcc_max & 0xf0) >> 4, cfi_info->vcc_max & 0x0f,
(cfi_info->vpp_min & 0xf0) >> 4, cfi_info->vpp_min & 0x0f,
(cfi_info->vpp_max & 0xf0) >> 4, cfi_info->vpp_max & 0x0f);
LOG_DEBUG("typ. word write timeout: %u us, typ. buf write timeout: %u us, "
"typ. block erase timeout: %u ms, typ. chip erase timeout: %u ms",
1 << cfi_info->word_write_timeout_typ, 1 << cfi_info->buf_write_timeout_typ,
1 << cfi_info->block_erase_timeout_typ, 1 << cfi_info->chip_erase_timeout_typ);
LOG_DEBUG("max. word write timeout: %u us, max. buf write timeout: %u us, "
"max. block erase timeout: %u ms, max. chip erase timeout: %u ms",
(1 << cfi_info->word_write_timeout_max) * (1 << cfi_info->word_write_timeout_typ),
(1 << cfi_info->buf_write_timeout_max) * (1 << cfi_info->buf_write_timeout_typ),
(1 << cfi_info->block_erase_timeout_max) * (1 << cfi_info->block_erase_timeout_typ),
(1 << cfi_info->chip_erase_timeout_max) * (1 << cfi_info->chip_erase_timeout_typ));
/* convert timeouts to real values in ms */
cfi_info->word_write_timeout = DIV_ROUND_UP((1L << cfi_info->word_write_timeout_typ) *
(1L << cfi_info->word_write_timeout_max), 1000);
cfi_info->buf_write_timeout = DIV_ROUND_UP((1L << cfi_info->buf_write_timeout_typ) *
(1L << cfi_info->buf_write_timeout_max), 1000);
cfi_info->block_erase_timeout = (1L << cfi_info->block_erase_timeout_typ) *
(1L << cfi_info->block_erase_timeout_max);
cfi_info->chip_erase_timeout = (1L << cfi_info->chip_erase_timeout_typ) *
(1L << cfi_info->chip_erase_timeout_max);
LOG_DEBUG("calculated word write timeout: %u ms, buf write timeout: %u ms, "
"block erase timeout: %u ms, chip erase timeout: %u ms",
cfi_info->word_write_timeout, cfi_info->buf_write_timeout,
cfi_info->block_erase_timeout, cfi_info->chip_erase_timeout);
/* apply fixups depending on the primary command set */
switch (cfi_info->pri_id)
{
......@@ -2858,19 +2858,17 @@ static int get_cfi_info(struct flash_bank *bank, char *buf, int buf_size)
}
if (cfi_info->not_cfi == 0)
printed = snprintf(buf, buf_size, "\ncfi information:\n");
printed = snprintf(buf, buf_size, "\nCFI flash: ");
else
printed = snprintf(buf, buf_size, "\nnon-cfi flash:\n");
printed = snprintf(buf, buf_size, "\nnon-CFI flash: ");
buf += printed;
buf_size -= printed;
printed = snprintf(buf, buf_size, "\nmfr: 0x%4.4x, id:0x%4.4x\n",
printed = snprintf(buf, buf_size, "mfr: 0x%4.4x, id:0x%4.4x\n\n",
cfi_info->manufacturer, cfi_info->device_id);
buf += printed;
buf_size -= printed;
if (cfi_info->not_cfi == 0)
{
printed = snprintf(buf, buf_size, "qry: '%c%c%c', pri_id: 0x%4.4x, pri_addr: "
"0x%4.4x, alt_id: 0x%4.4x, alt_addr: 0x%4.4x\n",
cfi_info->qry[0], cfi_info->qry[1], cfi_info->qry[2],
......@@ -2929,7 +2927,6 @@ static int get_cfi_info(struct flash_bank *bank, char *buf, int buf_size)
LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id);
break;
}
}
return ERROR_OK;
}
......
......@@ -477,10 +477,12 @@ void cfi_fixup_non_cfi(struct flash_bank *bank)
cfi_info->vcc_max = 0x0;
cfi_info->vpp_min = 0x0;
cfi_info->vpp_max = 0x0;
cfi_info->word_write_timeout_typ = 0x0;
cfi_info->buf_write_timeout_typ = 0x0;
cfi_info->block_erase_timeout_typ = 0x0;
cfi_info->chip_erase_timeout_typ = 0x0;
/* these are used for timeouts - use vales that should be long enough
for normal operation. */
cfi_info->word_write_timeout_typ = 0x0a;
cfi_info->buf_write_timeout_typ = 0x0d;
cfi_info->block_erase_timeout_typ = 0x0d;
cfi_info->chip_erase_timeout_typ = 0x10;
cfi_info->word_write_timeout_max = 0x0;
cfi_info->buf_write_timeout_max = 0x0;
cfi_info->block_erase_timeout_max = 0x0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment