Nico Huber has uploaded this change for review.
spi25: Remove now obsolete `four_bytes_addr_funcs` path
Change-Id: Idb7c576cb159630da2268813388b497cb5f46b43
Signed-off-by: Nico Huber <nico.h@gmx.de>
---
M flash.h
M flashchips.c
M flashrom.c
M spi25.c
4 files changed, 14 insertions(+), 56 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/86/22386/1
diff --git a/flash.h b/flash.h
index 40c7f28..4f0ab15 100644
--- a/flash.h
+++ b/flash.h
@@ -169,14 +169,6 @@
unsigned int page_size;
int feature_bits;
- /* set of function pointers to use in 4-bytes addressing mode */
- struct four_bytes_addr_funcs_set {
- int (*set_4ba) (struct flashctx *flash);
- int (*read_nbyte) (struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len);
- int (*program_byte) (struct flashctx *flash, unsigned int addr, const uint8_t databyte);
- int (*program_nbyte) (struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len);
- } four_bytes_addr_funcs;
-
/* Indicate how well flashrom supports different operations of this flash chip. */
struct tested {
enum test_state probe;
@@ -213,6 +205,7 @@
int (*unlock) (struct flashctx *flash);
int (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ int (*set_4ba) (struct flashctx *flash);
struct voltage {
uint16_t min;
uint16_t max;
diff --git a/flashchips.c b/flashchips.c
index 05a2906..34bce06 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -9847,12 +9847,6 @@
/* supports SFDP */
/* OTP: 64B total; read 0x4B, write 0x42 */
.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,
- .program_byte = spi_byte_program_4ba_direct,
- .program_nbyte = spi_nbyte_program_4ba_direct
- },
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.probe_timing = TIMING_ZERO,
@@ -9886,12 +9880,6 @@
/* supports SFDP */
/* OTP: 64B total; read 0x4B, write 0x42 */
.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,
- .program_byte = spi_byte_program_4ba_direct,
- .program_nbyte = spi_nbyte_program_4ba_direct
- },
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.probe_timing = TIMING_ZERO,
@@ -14770,13 +14758,6 @@
/* 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_4BA_READ,
- .four_bytes_addr_funcs =
- {
- .set_4ba = spi_enter_4ba_b7_we, /* enter 4-bytes addressing mode by CMD B7 + WREN */
- .read_nbyte = spi_nbyte_read_4ba_direct, /* read directly from any mode, no need to enter 4ba */
- .program_byte = spi_byte_program_4ba, /* write from 4-bytes addressing mode */
- .program_nbyte = spi_nbyte_program_4ba /* write from 4-bytes addressing mode */
- },
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.probe_timing = TIMING_ZERO,
@@ -14784,13 +14765,13 @@
{
{
.eraseblocks = { {4 * 1024, 8192} },
- .block_erase = spi_block_erase_20_4ba, /* erases 4k from 4-bytes addressing mode */
+ .block_erase = spi_block_erase_20,
}, {
.eraseblocks = { {32 * 1024, 1024} },
- .block_erase = spi_block_erase_52_4ba, /* erases 32k from 4-bytes addressing mode */
+ .block_erase = spi_block_erase_52,
}, {
.eraseblocks = { {64 * 1024, 512} },
- .block_erase = spi_block_erase_d8_4ba, /* erases 64k from 4-bytes addressing mode */
+ .block_erase = spi_block_erase_d8,
}, {
.eraseblocks = { {32 * 1024 * 1024, 1} },
.block_erase = spi_block_erase_60,
@@ -14803,6 +14784,7 @@
.unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
+ .set_4ba = spi_enter_4ba_b7_we,
.voltage = {2700, 3600},
},
diff --git a/flashrom.c b/flashrom.c
index db133e6..6944907 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -2219,9 +2219,8 @@
flash->in_4ba_mode = false;
/* Enable/disable 4-byte addressing mode if flash chip supports it */
- if ((flash->chip->feature_bits & FEATURE_4BA_SUPPORT) &&
- flash->chip->four_bytes_addr_funcs.set_4ba) {
- if (flash->chip->four_bytes_addr_funcs.set_4ba(flash)) {
+ if ((flash->chip->feature_bits & FEATURE_4BA_SUPPORT) && flash->chip->set_4ba) {
+ if (flash->chip->set_4ba(flash)) {
msg_cerr("Enabling/disabling 4-byte addressing mode failed!\n");
return 1;
}
diff --git a/spi25.c b/spi25.c
index 67a56df..41e3429 100644
--- a/spi25.c
+++ b/spi25.c
@@ -652,10 +652,7 @@
lenhere = min(start + len, (i + 1) * area_size) - starthere;
for (j = 0; j < lenhere; j += chunksize) {
toread = min(chunksize, lenhere - j);
- rc = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0
- ? spi_nbyte_read(flash, starthere + j, buf + starthere - start + j, toread)
- : flash->chip->four_bytes_addr_funcs.read_nbyte(flash, starthere + j,
- buf + starthere - start + j, toread);
+ rc = spi_nbyte_read(flash, starthere + j, buf + starthere - start + j, toread);
if (rc)
break;
}
@@ -674,7 +671,6 @@
int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int start,
unsigned int len, unsigned int chunksize)
{
- int rc = 0;
unsigned int i, j, starthere, lenhere, towrite;
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
* in struct flashctx to do this properly. All chips using
@@ -699,21 +695,16 @@
/* Length of bytes in the range in this page. */
lenhere = min(start + len, (i + 1) * page_size) - starthere;
for (j = 0; j < lenhere; j += chunksize) {
+ int rc;
+
towrite = min(chunksize, lenhere - j);
- rc = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0
- ? spi_nbyte_program(flash, starthere + j, buf + starthere - start + j, towrite)
- : flash->chip->four_bytes_addr_funcs.program_nbyte(flash, starthere + j,
- buf + starthere - start + j, towrite);
+ rc = spi_nbyte_program(flash, starthere + j, buf + starthere - start + j, towrite);
if (rc)
- break;
- while (spi_read_status_register(flash) & SPI_SR_WIP)
- programmer_delay(10);
+ return rc;
}
- if (rc)
- break;
}
- return rc;
+ return 0;
}
/*
@@ -726,18 +717,11 @@
int spi_chip_write_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len)
{
unsigned int i;
- int result = 0;
for (i = start; i < start + len; i++) {
- result = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0
- ? spi_nbyte_program(flash, i, buf + i - start, 1)
- : flash->chip->four_bytes_addr_funcs.program_byte(flash, i, buf[i - start]);
- if (result)
+ if (spi_nbyte_program(flash, i, buf + i - start, 1))
return 1;
- while (spi_read_status_register(flash) & SPI_SR_WIP)
- programmer_delay(10);
}
-
return 0;
}
To view, visit change 22386. To unsubscribe, visit settings.