dediprog: Reimplement target chip option

Change-Id: I594e2a6ee144260f8424d25b304f6ab41a9d3fad
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Acked-by: David Hendricks <david.hendricks@gmail.com>
Reviewed-on: https://review.coreboot.org/19350
Tested-by: build bot (Jenkins)
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/dediprog.c b/dediprog.c
index 019de46..b7276e5 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -942,7 +942,7 @@
 	int spispeed_idx = 1;
 	int millivolt = 3500;
 	long usedevice = 0;
-	long target = 1;
+	long target = FLASH_TYPE_APPLICATION_FLASH_1;
 	int i, ret;
 
 	spispeed = extract_programmer_param("spispeed");
@@ -1014,7 +1014,18 @@
 			free(target_str);
 			return 1;
 		}
-		msg_pinfo("Using target %li.\n", target);
+		switch (target) {
+		case 1:
+			msg_pinfo("Using target %s.\n", "FLASH_TYPE_APPLICATION_FLASH_1");
+			target = FLASH_TYPE_APPLICATION_FLASH_1;
+			break;
+		case 2:
+			msg_pinfo("Using target %s.\n", "FLASH_TYPE_APPLICATION_FLASH_2");
+			target = FLASH_TYPE_APPLICATION_FLASH_2;
+			break;
+		default:
+			break;
+		}
 	}
 	free(target_str);
 
@@ -1073,7 +1084,7 @@
 	dediprog_set_leds(LED_ALL);
 
 	/* Select target/socket, frequency and VCC. */
-	if (set_target_flash(FLASH_TYPE_APPLICATION_FLASH_1) ||
+	if (set_target_flash(target) ||
 	    dediprog_set_spi_speed(spispeed_idx) ||
 	    dediprog_set_spi_voltage(millivolt)) {
 		dediprog_set_leds(LED_ERROR);