Nico Huber has uploaded this change for review.

View Change

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, 10 insertions(+), 44 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/22/22022/1
diff --git a/flash.h b/flash.h
index 5538955..973fd47 100644
--- a/flash.h
+++ b/flash.h
@@ -168,14 +168,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;
@@ -212,6 +204,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 9848e5e..a7fdf1c 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -9753,12 +9753,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,
@@ -9792,12 +9786,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,
@@ -14676,13 +14664,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,
@@ -14690,13 +14671,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,
@@ -14709,6 +14690,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 62991d5..9b4b865 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -2224,9 +2224,8 @@
flash->chip->unlock(flash);

/* 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 dcab177..98b314d 100644
--- a/spi25.c
+++ b/spi25.c
@@ -631,10 +631,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;
}
@@ -679,10 +676,7 @@
lenhere = min(start + len, (i + 1) * page_size) - starthere;
for (j = 0; j < lenhere; j += chunksize) {
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)
@@ -708,9 +702,7 @@
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]);
+ result = spi_nbyte_program(flash, i, buf + i - start, 1);
if (result)
return 1;
while (spi_read_status_register(flash) & SPI_SR_WIP)

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

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