Commit b4b09ca5 authored by Roberto Vargas's avatar Roberto Vargas
Browse files

norflash: Clear status register before sending commands



The status register bits remain until explicitly cleared, which means
that a command can be incorrectly considered to have generated an error -
for example, after reset the status register contents may be unknown or
if a previous command had failed.

This patch clears the status register before beginning any command to
be sure that the status register only represents information about the
current operation.

Change-Id: I9e98110ee24179937215461c00b6543a3467b350
Signed-off-by: default avatarRoberto Vargas <roberto.vargas@arm.com>
parent 9753cb5b
......@@ -68,6 +68,8 @@ int nor_word_program(uintptr_t base_addr, unsigned long data)
uint32_t status;
int ret;
nor_send_cmd(base_addr, NOR_CMD_CLEAR_STATUS_REG);
/* Set the device in write word mode */
nor_send_cmd(base_addr, NOR_CMD_WORD_PROGRAM);
mmio_write_32(base_addr, data);
......@@ -98,8 +100,10 @@ int nor_lock(uintptr_t base_addr)
{
int ret;
nor_send_cmd(base_addr, NOR_CMD_CLEAR_STATUS_REG);
nor_send_cmd(base_addr, NOR_CMD_LOCK_UNLOCK);
mmio_write_32(base_addr, NOR_2X16(NOR_LOCK_BLOCK));
nor_send_cmd(base_addr, NOR_LOCK_BLOCK);
ret = nor_poll_dws(base_addr, DWS_WORD_LOCK_RETRIES);
nor_send_cmd(base_addr, NOR_CMD_READ_ARRAY);
......@@ -117,8 +121,10 @@ int nor_unlock(uintptr_t base_addr)
{
int ret;
nor_send_cmd(base_addr, NOR_CMD_CLEAR_STATUS_REG);
nor_send_cmd(base_addr, NOR_CMD_LOCK_UNLOCK);
mmio_write_32(base_addr, NOR_2X16(NOR_UNLOCK_BLOCK));
nor_send_cmd(base_addr, NOR_UNLOCK_BLOCK);
ret = nor_poll_dws(base_addr, DWS_WORD_LOCK_RETRIES);
nor_send_cmd(base_addr, NOR_CMD_READ_ARRAY);
......
Markdown is supported
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