Nico Huber has uploaded this change for review.
spi25: Add native 4BA support
Allow 4-byte adresses, cache the upper most byte in flashctx if the chip
uses an extended address register.
Change-Id: I644600beaab9a571b97b67f7516abe571d3460c1
Signed-off-by: Nico Huber <nico.h@gmx.de>
---
M flash.h
M flashrom.c
M spi25.c
M spi4ba.h
4 files changed, 30 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/20/22020/1
diff --git a/flash.h b/flash.h
index 52303f1..a3e7fd4 100644
--- a/flash.h
+++ b/flash.h
@@ -120,6 +120,7 @@
#define FEATURE_OTP (1 << 8)
#define FEATURE_QPI (1 << 9)
#define FEATURE_4BA_SUPPORT (1 << 10)
+#define FEATURE_4BA_EXT_ADDR (1 << 11)
enum test_state {
OK = 0,
@@ -236,6 +237,7 @@
bool verify_after_write;
bool verify_whole_chip;
} flags;
+ int address_high_byte;
};
/* Timing used in probe routines. ZERO is -2 to differentiate between an unset
diff --git a/flashrom.c b/flashrom.c
index 4f17382..62991d5 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -2232,6 +2232,8 @@
}
}
+ flash->address_high_byte = -1;
+
return 0;
}
diff --git a/spi25.c b/spi25.c
index f8ad692..052c6f3 100644
--- a/spi25.c
+++ b/spi25.c
@@ -355,14 +355,34 @@
return result ? result : status;
}
+static int spi_set_extended_address(struct flashctx *const flash, const uint8_t addr_high)
+{
+ if (flash->address_high_byte != addr_high &&
+ spi_write_extended_address_register(flash, addr_high))
+ return -1;
+ flash->address_high_byte = addr_high;
+ return 0;
+}
+
static int spi_prepare_address(struct flashctx *const flash,
uint8_t cmd_buf[], const unsigned int addr)
{
- /* TODO: extend for 4BA */
- cmd_buf[1] = (addr >> 16) & 0xff;
- cmd_buf[2] = (addr >> 8) & 0xff;
- cmd_buf[3] = (addr >> 0) & 0xff;
- return 3;
+ if (flash->chip->feature_bits & FEATURE_4BA_SUPPORT &&
+ !(flash->chip->feature_bits & FEATURE_4BA_EXT_ADDR)) {
+ cmd_buf[1] = (addr >> 24) & 0xff;
+ cmd_buf[2] = (addr >> 16) & 0xff;
+ cmd_buf[3] = (addr >> 8) & 0xff;
+ cmd_buf[4] = (addr >> 0) & 0xff;
+ return 4;
+ } else {
+ if (flash->chip->feature_bits & FEATURE_4BA_EXT_ADDR &&
+ spi_set_extended_address(flash, addr >> 24))
+ return -1;
+ cmd_buf[1] = (addr >> 16) & 0xff;
+ cmd_buf[2] = (addr >> 8) & 0xff;
+ cmd_buf[3] = (addr >> 0) & 0xff;
+ return 3;
+ }
}
static int spi_write_cmd(struct flashctx *const flash,
diff --git a/spi4ba.h b/spi4ba.h
index 8a01792..a0316bc 100644
--- a/spi4ba.h
+++ b/spi4ba.h
@@ -114,5 +114,6 @@
int spi_block_erase_5c_4ba_direct(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
int spi_block_erase_dc_4ba_direct(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+int spi_write_extended_address_register(struct flashctx *flash, uint8_t regdata);
#endif /* __SPI_4BA_H__ */
To view, visit change 22020. To unsubscribe, visit settings.