spi25: Remove now obsolete `four_bytes_addr_funcs` path
Change-Id: Idb7c576cb159630da2268813388b497cb5f46b43
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/22386
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/flash.h b/flash.h
index ad7c91b..f310e23 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 4bf71c5..439c05f 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -8135,13 +8135,6 @@
.page_size = 256,
/* OTP: 512B total; enter 0xB1, exit 0xC1 */
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT,
- .four_bytes_addr_funcs =
- {
- .set_4ba = spi_enter_4ba_b7, /* enter 4-bytes addressing mode by CMD B7 */
- .read_nbyte = spi_nbyte_read_4ba, /* read from 4-bytes addressing mode */
- .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,
@@ -8149,13 +8142,13 @@
{
{
.eraseblocks = { {4 * 1024, 8192} },
- .block_erase = spi_block_erase_20_4ba,
+ .block_erase = spi_block_erase_20,
}, {
.eraseblocks = { {32 * 1024, 1024} },
- .block_erase = spi_block_erase_52_4ba,
+ .block_erase = spi_block_erase_52,
}, {
.eraseblocks = { {64 * 1024, 512} },
- .block_erase = spi_block_erase_d8_4ba,
+ .block_erase = spi_block_erase_d8,
}, {
.eraseblocks = { {32 * 1024 * 1024, 1} },
.block_erase = spi_block_erase_60,
@@ -8169,6 +8162,7 @@
.unlock = spi_disable_blockprotect_bp3_srwd,
.write = spi_chip_write_256,
.read = spi_chip_read, /* Fast read (0x0B) supported */
+ .set_4ba = spi_enter_4ba_b7,
.voltage = {2700, 3600},
},
@@ -8182,13 +8176,6 @@
.page_size = 256,
/* OTP: 512B total; enter 0xB1, exit 0xC1 */
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT,
- .four_bytes_addr_funcs =
- {
- .set_4ba = spi_enter_4ba_b7, /* enter 4-bytes addressing mode by CMD B7 */
- .read_nbyte = spi_nbyte_read_4ba, /* read from 4-bytes addressing mode */
- .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,
@@ -8196,13 +8183,13 @@
{
{
.eraseblocks = { {4 * 1024, 16384} },
- .block_erase = spi_block_erase_20_4ba,
+ .block_erase = spi_block_erase_20,
}, {
.eraseblocks = { {32 * 1024, 2048} },
- .block_erase = spi_block_erase_52_4ba,
+ .block_erase = spi_block_erase_52,
}, {
.eraseblocks = { {64 * 1024, 1024} },
- .block_erase = spi_block_erase_d8_4ba,
+ .block_erase = spi_block_erase_d8,
}, {
.eraseblocks = { {64 * 1024 * 1024, 1} },
.block_erase = spi_block_erase_60,
@@ -8216,6 +8203,7 @@
.unlock = spi_disable_blockprotect_bp3_srwd,
.write = spi_chip_write_256,
.read = spi_chip_read, /* Fast read (0x0B) supported */
+ .set_4ba = spi_enter_4ba_b7,
.voltage = {2700, 3600},
},
@@ -9929,12 +9917,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,
@@ -9968,12 +9950,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,
@@ -14852,13 +14828,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,
@@ -14866,13 +14835,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,
@@ -14885,6 +14854,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 8849f63..9cc1be6 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 ce3d184..1da7d53 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;
}