diff --git a/ichspi.c b/ichspi.c
index 095d53a..74ce3f0 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -148,7 +148,7 @@
 
 /* Common SPI functions */
 static int program_opcodes(OPCODES * op);
-static int run_opcode(uint8_t nr, OPCODE op, uint32_t offset,
+static int run_opcode(OPCODE op, uint32_t offset,
 		      uint8_t datalength, uint8_t * data);
 static int ich_spi_read_page(struct flashchip *flash, uint8_t * buf,
 			     int offset, int maxdata);
@@ -225,7 +225,7 @@
 	return 0;
 }
 
-static int ich7_run_opcode(uint8_t nr, OPCODE op, uint32_t offset,
+static int ich7_run_opcode(OPCODE op, uint32_t offset,
 			   uint8_t datalength, uint8_t * data, int maxdata)
 {
 	int write_cmd = 0;
@@ -233,6 +233,8 @@
 	uint32_t temp32 = 0;
 	uint16_t temp16;
 	uint32_t a;
+	uint64_t opmenu;
+	int opcode_index;
 
 	/* Is it a write command? */
 	if ((op.spi_type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS)
@@ -280,7 +282,20 @@
 	}
 
 	/* Select opcode */
-	temp16 |= ((uint16_t) (nr & 0x07)) << 4;
+	opmenu = REGREAD32(ICH7_REG_OPMENU);
+	opmenu |= ((uint64_t)REGREAD32(ICH7_REG_OPMENU + 4)) << 32;
+
+	for (opcode_index=0; opcode_index<8; opcode_index++) {
+		if((opmenu & 0xff) == op.opcode) {
+			break;
+		}
+		opmenu >>= 8;
+	}
+	if (opcode_index == 8) {
+		printf_debug("Opcode %x not found.\n", op.opcode);
+		return 1;
+	}
+	temp16 |= ((uint16_t) (opcode_index & 0x07)) << 4;
 
 	/* Handle Atomic */
 	if (op.atomic != 0) {
@@ -328,13 +343,15 @@
 	return 0;
 }
 
-static int ich9_run_opcode(uint8_t nr, OPCODE op, uint32_t offset,
+static int ich9_run_opcode(OPCODE op, uint32_t offset,
 			   uint8_t datalength, uint8_t * data)
 {
 	int write_cmd = 0;
 	int timeout;
 	uint32_t temp32;
 	uint32_t a;
+	uint64_t opmenu;
+	int opcode_index;
 
 	/* Is it a write command? */
 	if ((op.spi_type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS)
@@ -383,7 +400,20 @@
 	}
 
 	/* Select opcode */
-	temp32 |= ((uint32_t) (nr & 0x07)) << (8 + 4);
+	opmenu = REGREAD32(ICH9_REG_OPMENU);
+	opmenu |= ((uint64_t)REGREAD32(ICH9_REG_OPMENU + 4)) << 32;
+
+	for (opcode_index=0; opcode_index<8; opcode_index++) {
+		if((opmenu & 0xff) == op.opcode) {
+			break;
+		}
+		opmenu >>= 8;
+	}
+	if (opcode_index == 8) {
+		printf_debug("Opcode %x not found.\n", op.opcode);
+		return 1;
+	}
+	temp32 |= ((uint32_t) (opcode_index & 0x07)) << (8 + 4);
 
 	/* Handle Atomic */
 	if (op.atomic != 0) {
@@ -431,16 +461,16 @@
 	return 0;
 }
 
-static int run_opcode(uint8_t nr, OPCODE op, uint32_t offset,
+static int run_opcode(OPCODE op, uint32_t offset,
 		      uint8_t datalength, uint8_t * data)
 {
 	switch (flashbus) {
 	case BUS_TYPE_VIA_SPI:
-		return ich7_run_opcode(nr, op, offset, datalength, data, 16);
+		return ich7_run_opcode(op, offset, datalength, data, 16);
 	case BUS_TYPE_ICH7_SPI:
-		return ich7_run_opcode(nr, op, offset, datalength, data, 64);
+		return ich7_run_opcode(op, offset, datalength, data, 64);
 	case BUS_TYPE_ICH9_SPI:
-		return ich9_run_opcode(nr, op, offset, datalength, data);
+		return ich9_run_opcode(op, offset, datalength, data);
 	default:
 		printf_debug("%s: unsupported chipset\n", __FUNCTION__);
 	}
@@ -453,7 +483,7 @@
 {
 	printf_debug("ich_spi_erase_block: offset=%d, sectors=%d\n", offset, 1);
 
-	if (run_opcode(2, curopcodes->opcode[2], offset, 0, NULL) != 0) {
+	if (run_opcode(curopcodes->opcode[2], offset, 0, NULL) != 0) {
 		printf_debug("Error erasing sector at 0x%x", offset);
 		return -1;
 	}
@@ -477,7 +507,7 @@
 		if (remaining < maxdata) {
 
 			if (run_opcode
-			    (1, curopcodes->opcode[1],
+			    (curopcodes->opcode[1],
 			     offset + (page_size - remaining), remaining,
 			     &buf[page_size - remaining]) != 0) {
 				printf_debug("Error reading");
@@ -486,7 +516,7 @@
 			remaining = 0;
 		} else {
 			if (run_opcode
-			    (1, curopcodes->opcode[1],
+			    (curopcodes->opcode[1],
 			     offset + (page_size - remaining), maxdata,
 			     &buf[page_size - remaining]) != 0) {
 				printf_debug("Error reading");
@@ -512,7 +542,7 @@
 	for (a = 0; a < page_size; a += maxdata) {
 		if (remaining < maxdata) {
 			if (run_opcode
-			    (0, curopcodes->opcode[0],
+			    (curopcodes->opcode[0],
 			     offset + (page_size - remaining), remaining,
 			     &bytes[page_size - remaining]) != 0) {
 				printf_debug("Error writing");
@@ -521,7 +551,7 @@
 			remaining = 0;
 		} else {
 			if (run_opcode
-			    (0, curopcodes->opcode[0],
+			    (curopcodes->opcode[0],
 			     offset + (page_size - remaining), maxdata,
 			     &bytes[page_size - remaining]) != 0) {
 				printf_debug("Error writing");
@@ -641,7 +671,7 @@
 		count = readcnt;
 	}
 
-	if (run_opcode(opcode_index, *opcode, addr, count, data) != 0) {
+	if (run_opcode(*opcode, addr, count, data) != 0) {
 		printf_debug("run OPCODE 0x%02x failed\n", opcode->opcode);
 		return 1;
 	}
