diff loadtools/flashid.c @ 916:54a0bc149d9c

fc-loadtool: add support for Samsung K5L29xx_A flash
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 30 Dec 2022 21:07:30 +0000
parents f229efbfd581
children 7c18eac91457
line wrap: on
line diff
--- a/loadtools/flashid.c	Thu Dec 29 23:59:00 2022 +0000
+++ b/loadtools/flashid.c	Fri Dec 30 21:07:30 2022 +0000
@@ -20,6 +20,7 @@
 extern struct flash_device flashdev_PL129N;
 extern struct flash_device flashdev_K5A32xx_T;
 extern struct flash_device flashdev_K5L33xx_A;
+extern struct flash_device flashdev_K5L29xx_A;
 
 extern int flash_global_config;
 extern struct flash_bank_info flash_bank_info[2];
@@ -66,6 +67,33 @@
 }
 
 static
+try_device_amdreset(bi, dev)
+	struct flash_bank_info *bi;
+	struct flash_device *dev;
+{
+	int rc;
+
+	printf("Appears to be %s or compatible, checking CFI\n", dev->name);
+	/* need to go back to read array first, CFI cmd ignored otherwise */
+	if (do_w16(bi->base_addr + 0xAAA, 0xF0)) {
+bad_w16:	fprintf(stderr, "unexpected response to w16 - aborting\n");
+		return(-1);
+	}
+	if (do_w16(bi->base_addr + 0xAA, 0x98))
+		goto bad_w16;
+	rc = run_cfi_check(bi, dev->cfi_table);
+	if (rc < 0)
+		return(rc);
+	if (!rc) {
+		fprintf(stderr, "Error: CFI mismatch, unsafe to continue\n");
+		return(-1);
+	}
+	printf("Confirmed %s or compatible\n", dev->name);
+	bi->device = dev;
+	return(0);
+}
+
+static
 spansion_pl129j_or_n(bi)
 	struct flash_bank_info *bi;
 {
@@ -135,6 +163,8 @@
 	printf("Extended ID: %04X %04X\n", ext1, ext2);
 	if (ext1 == 0x2503 && ext2 == 0x2501)
 		return try_device(bi, &flashdev_K5L33xx_A);
+	if (ext1 == 0x2508 && ext2 == 0x2501)
+		return try_device_amdreset(bi, &flashdev_K5L29xx_A);
 	fprintf(stderr, "Error: unknown device ID\n");
 	return(-1);
 }