Nico Huber has uploaded this change for review.

View Change

spi25: Enable direct 4BA read and write using feature bits

Change-Id: I2f6817ca198bf923671a7aa67e956e5477d71848
Signed-off-by: Nico Huber <nico.h@gmx.de>
---
M flash.h
M flashchips.c
M spi25.c
3 files changed, 15 insertions(+), 5 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/21/22021/1
diff --git a/flash.h b/flash.h
index a3e7fd4..5538955 100644
--- a/flash.h
+++ b/flash.h
@@ -121,6 +121,8 @@
#define FEATURE_QPI (1 << 9)
#define FEATURE_4BA_SUPPORT (1 << 10)
#define FEATURE_4BA_EXT_ADDR (1 << 11)
+#define FEATURE_4BA_READ (1 << 12)
+#define FEATURE_4BA_WRITE (1 << 13)

enum test_state {
OK = 0,
diff --git a/flashchips.c b/flashchips.c
index 742cc6e..9848e5e 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -9752,7 +9752,7 @@
.page_size = 256,
/* supports SFDP */
/* OTP: 64B total; read 0x4B, write 0x42 */
- .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT,
+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT | FEATURE_4BA_READ | FEATURE_4BA_WRITE,
.four_bytes_addr_funcs =
{
.read_nbyte = spi_nbyte_read_4ba_direct,
@@ -9791,7 +9791,7 @@
.page_size = 256,
/* supports SFDP */
/* OTP: 64B total; read 0x4B, write 0x42 */
- .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT,
+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT | FEATURE_4BA_READ | FEATURE_4BA_WRITE,
.four_bytes_addr_funcs =
{
.read_nbyte = spi_nbyte_read_4ba_direct,
@@ -14675,7 +14675,7 @@
/* supports SFDP */
/* OTP: 1024B total, 256B reserved; read 0x48; write 0x42, erase 0x44, read ID 0x4B */
/* FOUR_BYTE_ADDR: supports 4-bytes addressing mode */
- .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT,
+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT | FEATURE_4BA_READ,
.four_bytes_addr_funcs =
{
.set_4ba = spi_enter_4ba_b7_we, /* enter 4-bytes addressing mode by CMD B7 + WREN */
diff --git a/spi25.c b/spi25.c
index 052c6f3..dcab177 100644
--- a/spi25.c
+++ b/spi25.c
@@ -577,13 +577,21 @@

static int spi_nbyte_program(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len)
{
- return spi_write_cmd(flash, JEDEC_BYTE_PROGRAM, addr, bytes, len, 10);
+ const uint8_t op =
+ flash->chip->feature_bits & FEATURE_4BA_WRITE
+ ? JEDEC_BYTE_PROGRAM_4BA
+ : JEDEC_BYTE_PROGRAM;
+ return spi_write_cmd(flash, op, addr, bytes, len, 10);
}

int spi_nbyte_read(struct flashctx *flash, unsigned int address, uint8_t *bytes,
unsigned int len)
{
- uint8_t cmd[1 + JEDEC_MAX_ADDR_LEN] = { JEDEC_READ, };
+ uint8_t cmd[1 + JEDEC_MAX_ADDR_LEN] = {
+ flash->chip->feature_bits & FEATURE_4BA_READ
+ ? JEDEC_READ_4BA
+ : JEDEC_READ,
+ };

const int addr_len = spi_prepare_address(flash, cmd, address);
if (addr_len < 0)

To view, visit change 22021. To unsubscribe, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: staging
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f6817ca198bf923671a7aa67e956e5477d71848
Gerrit-Change-Number: 22021
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h@gmx.de>