changeset 325:545e1718f5fb

fc-loadtool: support for 28F640W30B flash chip with partition quirks
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 Jan 2018 05:20:40 +0000
parents 0937521ec2f4
children 2b5ed962c2f9
files loadtools/flashops.c loadtools/flmain.c
diffstat 2 files changed, 88 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/flashops.c	Fri Dec 29 20:38:39 2017 +0000
+++ b/loadtools/flashops.c	Sat Jan 20 05:20:40 2018 +0000
@@ -108,6 +108,21 @@
 	return(0);
 }
 
+intel_w30_reset_cmd(bi)
+	struct flash_bank_info *bi;
+{
+	uint32_t part;
+
+	for (part = 0; part < bi->geom->total_size; part += 0x80000) {
+		if (do_w16(bi->base_addr + part, 0xFF)) {
+			fprintf(stderr,
+	"unexpected response to w16 when resetting flash to read mode!\n");
+			return(-1);
+		}
+	}
+	return(0);
+}
+
 intel_status_cmd(bi)
 	struct flash_bank_info *bi;
 {
@@ -129,6 +144,31 @@
 	return(0);
 }
 
+intel_w30_status_cmd(bi)
+	struct flash_bank_info *bi;
+{
+	uint32_t part;
+	int stat;
+	uint16_t sr;
+
+	for (part = 0; part < bi->geom->total_size; part += 0x80000) {
+		/* issue Read SR command */
+		stat = do_w16(bi->base_addr + part, 0x70);
+		if (stat) {
+			fprintf(stderr,
+			"unexpected response to w16 for Read SR command\n");
+			return(-1);
+		}
+		stat = do_r16(bi->base_addr + part, &sr);
+		if (stat)
+			return(stat);	/* error msg already printed */
+		sr &= 0xFF;
+		printf("Status Register for partition %08lX: %02X\n",
+			(u_long) part, sr);
+	}
+	return(0);
+}
+
 intel_sector_unlock(bi, sp)
 	struct flash_bank_info *bi;
 	struct sector_info *sp;
@@ -205,6 +245,22 @@
 	return(0);
 }
 
+intel_w30_clear_sr(bi)
+	struct flash_bank_info *bi;
+{
+	uint32_t part;
+
+	printf("Clearing Intel flash SR\n");
+	for (part = 0; part < bi->geom->total_size; part += 0x80000) {
+		if (do_w16(bi->base_addr + part, 0x50)) {
+			fprintf(stderr,
+			"unexpected response to w16 for Clear SR command\n");
+			return(-1);
+		}
+	}
+	return(0);
+}
+
 struct flash_cmdset flash_cmdset_intel = {
 	.cmdset_name		= "Intel",
 	.reset_cmd		= intel_reset_cmd,
@@ -216,3 +272,15 @@
 	.loadagent_program_cmd	= "INFW",
 	.needs_unlock		= 1,
 };
+
+struct flash_cmdset flash_cmdset_intel_w30 = {
+	.cmdset_name		= "Intel",
+	.reset_cmd		= intel_w30_reset_cmd,
+	.status_cmd		= intel_w30_status_cmd,
+	.unlock_sector		= intel_sector_unlock,
+	.erase_sector		= intel_sector_erase,
+	.prep_for_program	= intel_w30_clear_sr,
+	.loadagent_setbase_cmd	= "INFB",
+	.loadagent_program_cmd	= "INFW",
+	.needs_unlock		= 1,
+};
--- a/loadtools/flmain.c	Fri Dec 29 20:38:39 2017 +0000
+++ b/loadtools/flmain.c	Sat Jan 20 05:20:40 2018 +0000
@@ -57,6 +57,24 @@
 	{0x800000, &pl129n_ce2_geom, pl129n_idcheck, 4}
 };
 
+/* 28F640W30B device description */
+
+static struct flash_geom f640w30b_geom = {
+	.total_size	= 0x800000,
+	.nregions	= 2,
+	.regions	= {0x2000, 8, 0x10000, 127},
+	.total_sectors	= 135,
+};
+
+static struct flash_idcheck f640w30b_idcheck[2] = {
+	{0x00, 0x0089},
+	{0x02, 0x8855}
+};
+
+static struct flash_bank_desc f640w30b_bankdesc = {
+	0x800000, &f640w30b_geom, f640w30b_idcheck, 2
+};
+
 /* bank configurations for CFI */
 
 static struct flash_bank_desc cfi_4M_bankdesc = {
@@ -70,12 +88,14 @@
 /* list of supported flash devices */
 
 extern struct flash_cmdset flash_cmdset_amd;
+extern struct flash_cmdset flash_cmdset_intel_w30;
 
 struct flash_device_desc flash_device_list[] = {
 	{"cfi-4M", &cfi_4M_bankdesc, 1, 0},
 	{"cfi-8M", &cfi_8M_bankdesc, 1, 0},
 	{"k5a32xx_t", &k5a32xx_topboot_bankdesc, 1, &flash_cmdset_amd},
 	{"pl129n", pl129n_banks, 2, &flash_cmdset_amd},
+	{"28f640w30b", &f640w30b_bankdesc, 1, &flash_cmdset_intel_w30},
 	{0, 0, 0, 0}	/* array terminator */
 };