Thomas Heijligen has uploaded this change for review.

View Change

spi25.c: Move spi_get_opcode_from_erasefn() to spi.c

Split spi_get_opcode_from_erasefn() out into spi.c to add support for
non spi25 flashes next.

Change-Id: Id654e998d0af2d3f5845336bb98b38d724519038
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
---
M spi.c
M spi25.c
2 files changed, 46 insertions(+), 12 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/15/67715/1
diff --git a/spi.c b/spi.c
index 38d8d01..124b296 100644
--- a/spi.c
+++ b/spi.c
@@ -167,3 +167,36 @@
rmst.spi.data = data;
return register_master(&rmst);
}
+
+static const struct {
+ erasefunc_t *func;
+ uint8_t opcode;
+} function_opcode_list[] = {
+ {&spi_block_erase_20, 0x20},
+ {&spi_block_erase_21, 0x21},
+ {&spi_block_erase_50, 0x50},
+ {&spi_block_erase_52, 0x52},
+ {&spi_block_erase_53, 0x53},
+ {&spi_block_erase_5c, 0x5c},
+ {&spi_block_erase_60, 0x60},
+ {&spi_block_erase_62, 0x62},
+ {&spi_block_erase_81, 0x81},
+ {&spi_block_erase_c4, 0xc4},
+ {&spi_block_erase_c7, 0xc7},
+ {&spi_block_erase_d7, 0xd7},
+ {&spi_block_erase_d8, 0xd8},
+ {&spi_block_erase_db, 0xdb},
+ {&spi_block_erase_dc, 0xdc},
+};
+
+uint8_t spi_get_opcode_from_erasefn(erasefunc_t *func)
+{
+ size_t i;
+ for (i = 0; i < ARRAY_SIZE(function_opcode_list); i++) {
+ if (function_opcode_list[i].func == func)
+ return function_opcode_list[i].opcode;
+ }
+ msg_cinfo("%s: unknown erase function (0x%p). Please report "
+ "this at flashrom@flashrom.org\n", __func__, func);
+ return 0x00; //Assuming 0x00 is not a erase function opcode
+}
\ No newline at end of file
diff --git a/spi25.c b/spi25.c
index 6d160eb..0279f9a 100644
--- a/spi25.c
+++ b/spi25.c
@@ -651,18 +651,6 @@
return NULL;
}

-uint8_t spi_get_opcode_from_erasefn(erasefunc_t *func)
-{
- size_t i;
- for (i = 0; i < ARRAY_SIZE(function_opcode_list); i++) {
- if (function_opcode_list[i].func == func)
- return function_opcode_list[i].opcode;
- }
- msg_cinfo("%s: unknown erase function (0x%p). Please report "
- "this at flashrom@flashrom.org\n", __func__, func);
- return 0x00; //Assuming 0x00 is not a erase function opcode
-}
-
static int spi_nbyte_program(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len)
{
const bool native_4ba = flash->chip->feature_bits & FEATURE_4BA_WRITE && spi_master_4ba(flash);

To view, visit change 67715. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Id654e998d0af2d3f5845336bb98b38d724519038
Gerrit-Change-Number: 67715
Gerrit-PatchSet: 1
Gerrit-Owner: Thomas Heijligen <src@posteo.de>
Gerrit-MessageType: newchange