Index: flashrom-it87spi_force_port/flash.h
===================================================================
--- flashrom-it87spi_force_port/flash.h	(Revision 634)
+++ flashrom-it87spi_force_port/flash.h	(Arbeitskopie)
@@ -468,6 +468,7 @@
 int ich_spi_write_256(struct flashchip *flash, uint8_t * buf);
 
 /* it87spi.c */
+extern char *it87opts;
 extern uint16_t it8716f_flashport;
 void enter_conf_mode_ite(uint16_t port);
 void exit_conf_mode_ite(uint16_t port);
Index: flashrom-it87spi_force_port/it87spi.c
===================================================================
--- flashrom-it87spi_force_port/it87spi.c	(Revision 634)
+++ flashrom-it87spi_force_port/it87spi.c	(Arbeitskopie)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the flashrom project.
  *
- * Copyright (C) 2007, 2008 Carl-Daniel Hailfinger
+ * Copyright (C) 2007, 2008, 2009 Carl-Daniel Hailfinger
  * Copyright (C) 2008 Ronald Hoogenboom <ronald@zonnet.nl>
  * Copyright (C) 2008 coresystems GmbH
  *
@@ -24,12 +24,14 @@
  */
 
 #include <string.h>
+#include <stdlib.h>
 #include "flash.h"
 #include "spi.h"
 
 #define ITE_SUPERIO_PORT1	0x2e
 #define ITE_SUPERIO_PORT2	0x4e
 
+char *it87opts = NULL;
 uint16_t it8716f_flashport = 0;
 /* use fast 33MHz SPI (<>0) or slow 16MHz (0) */
 int fast_spi = 1;
@@ -56,6 +58,7 @@
 static uint16_t find_ite_spi_flash_port(uint16_t port)
 {
 	uint8_t tmp = 0;
+	char *portpos = NULL;
 	uint16_t id, flashport = 0;
 
 	enter_conf_mode_ite(port);
@@ -77,6 +80,9 @@
 		       0xFFF80000, 0xFFFEFFFF, (tmp & 1 << 3) ? "en" : "dis");
 		printf("LPC write to serial flash %sabled\n",
 		       (tmp & 1 << 4) ? "en" : "dis");
+		/* The LPC->SPI force write enable below only makes sense for
+		 * non-programmer mode.
+		 */
 		/* If any serial flash segment is enabled, enable writing. */
 		if ((tmp & 0xe) && (!(tmp & 1 << 4))) {
 			printf("Enabling LPC write to serial flash\n");
@@ -89,6 +95,17 @@
 		flashport = sio_read(port, 0x64) << 8;
 		flashport |= sio_read(port, 0x65);
 		printf("Serial flash port 0x%04x\n", flashport);
+		if (it87opts && !strlen(it87opts)) {
+			free(it87opts);
+			it87opts = NULL;
+		}
+		if (it87opts && (portpos = strstr(it87opts, "port="))) {
+			portpos += 5;
+			flashport = strtol(portpos, (char **)NULL, 0);
+			printf("Forcing serial flash port 0x%04x\n", flashport);
+			sio_write(port, 0x64, (flashport >> 8));
+			sio_write(port, 0x65, (flashport & 0xff));
+		}
 	}
 	exit_conf_mode_ite(port);
 	return flashport;
Index: flashrom-it87spi_force_port/flashrom.c
===================================================================
--- flashrom-it87spi_force_port/flashrom.c	(Revision 634)
+++ flashrom-it87spi_force_port/flashrom.c	(Arbeitskopie)
@@ -646,6 +646,8 @@
 					pcidev_bdf = strdup(optarg + 8);
 			} else if (strncmp(optarg, "it87spi", 7) == 0) {
 				programmer = PROGRAMMER_IT87SPI;
+				if (optarg[7] == '=')
+					it87opts = strdup(optarg + 8);
 			} else if (strncmp(optarg, "ft2232spi", 9) == 0) {
 				programmer = PROGRAMMER_FT2232SPI;
  			} else if (strncmp(optarg, "serprog", 7) == 0) {
