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>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/67715
Original-Reviewed-by: Thomas Heijligen <src@posteo.de>
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72540
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/spi.c b/spi.c
index 78698ce..ef28928 100644
--- a/spi.c
+++ b/spi.c
@@ -164,3 +164,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-stable@flashrom.org\n", __func__, func);
+	return 0x00; //Assuming 0x00 is not a erase function opcode
+}
diff --git a/spi25.c b/spi25.c
index 17de949..be612c6 100644
--- a/spi25.c
+++ b/spi25.c
@@ -633,18 +633,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-stable@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);