aboutsummaryrefslogtreecommitdiffstats
path: root/spi4ba.c
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2017-10-14 17:47:28 +0200
committerNico Huber <nico.h@gmx.de>2017-12-28 10:44:17 +0000
commitf43c654ad0dcb11b2738bbfac9246d09bb1949e5 (patch)
tree1d1f74d771dc2e8e8a67dab985945c00f68e0097 /spi4ba.c
parent0ecbacbfca7f919f1780f5062c775d94c7869d81 (diff)
downloadflashrom-f43c654ad0dcb11b2738bbfac9246d09bb1949e5.tar.gz
flashrom-f43c654ad0dcb11b2738bbfac9246d09bb1949e5.tar.bz2
flashrom-f43c654ad0dcb11b2738bbfac9246d09bb1949e5.zip
spi25: Integrate 4BA support
Allow 4-byte addresses for instructions usually used with 3-byte addresses. Decide in which way the 4th byte will be communicated based on the state of the chip (i.e. have we enabled 4BA mode) and a new feature bit for an extended address register. If we are not in 4BA mode and no extended address register is available or the write to it fails, bail out. We cache the state of 4BA mode and the extended address register in the flashctx. Change-Id: I644600beaab9a571b97b67f7516abe571d3460c1 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/22384 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'spi4ba.c')
-rw-r--r--spi4ba.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/spi4ba.c b/spi4ba.c
index a44e0674..902f0730 100644
--- a/spi4ba.c
+++ b/spi4ba.c
@@ -39,12 +39,17 @@
/* Enter 4-bytes addressing mode (without sending WREN before) */
int spi_enter_4ba_b7(struct flashctx *flash)
{
+ int result;
const unsigned char cmd[JEDEC_ENTER_4_BYTE_ADDR_MODE_OUTSIZE] = { JEDEC_ENTER_4_BYTE_ADDR_MODE };
msg_trace("-> %s\n", __func__);
/* Switch to 4-bytes addressing mode */
- return spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
+ result = spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
+ if (!result)
+ flash->in_4ba_mode = true;
+
+ return result;
}
/* Enter 4-bytes addressing mode with sending WREN before */
@@ -75,18 +80,25 @@ int spi_enter_4ba_b7_we(struct flashctx *flash)
result = spi_send_multicommand(flash, cmds);
if (result)
msg_cerr("%s failed during command execution\n", __func__);
+ else
+ flash->in_4ba_mode = true;
return result;
}
/* Exit 4-bytes addressing mode (without sending WREN before) */
int spi_exit_4ba_e9(struct flashctx *flash)
{
+ int result;
const unsigned char cmd[JEDEC_EXIT_4_BYTE_ADDR_MODE_OUTSIZE] = { JEDEC_EXIT_4_BYTE_ADDR_MODE };
msg_trace("-> %s\n", __func__);
/* Switch to 3-bytes addressing mode */
- return spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
+ result = spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
+ if (!result)
+ flash->in_4ba_mode = false;
+
+ return result;
}
/* Exit 4-bytes addressing mode with sending WREN before */
@@ -115,9 +127,10 @@ int spi_exit_4ba_e9_we(struct flashctx *flash)
/* Switch to 3-bytes addressing mode */
result = spi_send_multicommand(flash, cmds);
- if (result) {
+ if (result)
msg_cerr("%s failed during command execution\n", __func__);
- }
+ else
+ flash->in_4ba_mode = false;
return result;
}