[flashrom] [PATCH] Clean up probe functions

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Sun Mar 14 17:03:43 CET 2010


Add FEATURE_REGISTERMAP to
* Intel 82802AB, 82802AC
* Sharp LHF00L04
* SST SST49LF004C, SST49LF008C, SST49LF016C, SST49LF160C
* ST M50FLW040A, M50FLW040B, M50FLW080A, M50FLW080B, M50FW002, M50FW016
     M50FW040, M50FW080, M50LPW116

Make register mapping conditional on FEATURE_REGISTERMAP in 82802ab.c.
Replace probe_49lfxxxc with probe_82802ab.
Replace probe_28sf040 with probe_82802ab.
Replace probe_sst_fwhub with probe_jedec.
Add printlock_sst_fwhub to chips which used probe_sst_fwhub.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: flashrom-probe_cleanup/flashchips.c
===================================================================
--- flashrom-probe_cleanup/flashchips.c	(Revision 935)
+++ flashrom-probe_cleanup/flashchips.c	(Arbeitskopie)
@@ -2388,15 +2388,15 @@
 		.vendor		= "Intel",
 		.name		= "82802AB",
 		.bustype	= CHIP_BUSTYPE_FWH,
 		.manufacture_id	= INTEL_ID,
 		.model_id	= I_82802AB,
 		.total_size	= 512,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_OK_PRW,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine does not use probe_timing (82802ab.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {64 * 1024, 8} },
@@ -2411,15 +2411,15 @@
 		.vendor		= "Intel",
 		.name		= "82802AC",
 		.bustype	= CHIP_BUSTYPE_FWH,
 		.manufacture_id	= INTEL_ID,
 		.model_id	= I_82802AC,
 		.total_size	= 1024,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_OK_PRW,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine does not use probe_timing (82802ab.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {64 * 1024, 16} },
@@ -3438,17 +3438,17 @@
 		.vendor		= "Sharp",
 		.name		= "LHF00L04",
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= SHARP_ID,
 		.model_id	= SHARP_LHF00L04,
 		.total_size	= 1024,
 		.page_size	= 64 * 1024,
-		.feature_bits	= FEATURE_EITHER_RESET,
+		.feature_bits	= FEATURE_EITHER_RESET | FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
-		.probe		= probe_49lfxxxc,
+		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_ZERO,
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = {
 					{64 * 1024, 15},
 					{8 * 1024, 8}
@@ -3719,15 +3719,15 @@
 		.bustype	= CHIP_BUSTYPE_PARALLEL,
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_28SF040,
 		.total_size	= 512,
 		.page_size	= 256,
 		.feature_bits	= 0,
 		.tested		= TEST_UNTESTED,
-		.probe		= probe_28sf040,
+		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (sst28sf040.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {128, 4096} },
 				.block_erase = erase_sector_28sf040,
 			}, {
@@ -4074,58 +4074,60 @@
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF002A,
 		.total_size	= 256,
 		.page_size	= 16 * 1024,
 		.feature_bits	= FEATURE_REGISTERMAP | FEATURE_EITHER_RESET,
 		.tested		= TEST_OK_PRW,
-		.probe		= probe_sst_fwhub,
-		.probe_timing	= 1,		/* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
+		.probe		= probe_jedec,
+		.probe_timing	= 1,		/* 150 ns */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 64} },
 				.block_erase = erase_sst_fwhub_sector,
 			}, {
 				.eraseblocks = { {16 * 1024, 16} },
 				.block_erase = erase_sst_fwhub_block,
 			}, {
 				.eraseblocks = { {256 * 1024, 1} },
 				.block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
 			}
 		},
+		.printlock	= printlock_sst_fwhub,
 		.write		= write_sst_fwhub,
 		.read		= read_memmapped,
 	},
 
 	{
 		.vendor		= "SST",
 		.name		= "SST49LF003A/B",
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF003A,
 		.total_size	= 384,
 		.page_size	= 64 * 1024,
 		.feature_bits	= FEATURE_REGISTERMAP | FEATURE_EITHER_RESET,
 		.tested		= TEST_OK_PR,
-		.probe		= probe_sst_fwhub,
-		.probe_timing	= 1,		/* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
+		.probe		= probe_jedec,
+		.probe_timing	= 1,		/* 150 ns */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 96} },
 				.block_erase = erase_sst_fwhub_sector,
 			}, {
 				.eraseblocks = { {64 * 1024, 6} },
 				.block_erase = erase_sst_fwhub_block,
 			}, {
 				.eraseblocks = { {384 * 1024, 1} },
 				.block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
 			}
 		},
+		.printlock	= printlock_sst_fwhub,
 		.write		= write_sst_fwhub,
 		.read		= read_memmapped,
 	},
 
 	{
 		/* Contrary to the data sheet, TBL# on the SST49LF004B affects the top 128kB (instead of 64kB)
 		 * and is only honored for 64k block erase, but not 4k sector erase.
@@ -4135,44 +4137,45 @@
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF004A,
 		.total_size	= 512,
 		.page_size	= 64 * 1024,
 		.feature_bits	= FEATURE_REGISTERMAP | FEATURE_EITHER_RESET,
 		.tested		= TEST_OK_PREW,
-		.probe		= probe_sst_fwhub,
-		.probe_timing	= 1,		/* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
+		.probe		= probe_jedec,
+		.probe_timing	= 1,		/* 150 ns */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 128} },
 				.block_erase = erase_sector_jedec, /* missing unlock */
 			}, {
 				.eraseblocks = { {64 * 1024, 8} },
 				.block_erase = erase_sst_fwhub_block, /* same as erase_block_jedec, but with unlock */
 			}, {
 				.eraseblocks = { {512 * 1024, 1} },
 				.block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
 			},
 		},
+		.printlock	= printlock_sst_fwhub,
 		.write		= write_sst_fwhub,
 		.read		= read_memmapped,
 	},
 
 	{
 		.vendor		= "SST",
 		.name		= "SST49LF004C",
 		.bustype	= CHIP_BUSTYPE_FWH,
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF004C,
 		.total_size	= 512,
 		.page_size	= 4 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
-		.probe		= probe_49lfxxxc,
+		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 128} },
 				.block_erase = erase_sector_49lfxxxc,
 			}, {
@@ -4195,44 +4198,45 @@
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF008A,
 		.total_size	= 1024,
 		.page_size	= 64 * 1024,
 		.feature_bits	= FEATURE_REGISTERMAP | FEATURE_EITHER_RESET,
 		.tested		= TEST_OK_PRW,
-		.probe		= probe_sst_fwhub,
-		.probe_timing	= 1,		/* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
+		.probe		= probe_jedec,
+		.probe_timing	= 1,		/* 150 ns */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 256} },
 				.block_erase = erase_sst_fwhub_sector,
 			}, {
 				.eraseblocks = { {64 * 1024, 16} },
 				.block_erase = erase_sst_fwhub_block,
 			}, {
 				.eraseblocks = { {1024 * 1024, 1} },
 				.block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
 			}
 		},
+		.printlock	= printlock_sst_fwhub,
 		.write		= write_sst_fwhub,
 		.read		= read_memmapped,
 	},
 
 	{
 		.vendor		= "SST",
 		.name		= "SST49LF008C",
 		.bustype	= CHIP_BUSTYPE_FWH,
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF008C,
 		.total_size	= 1024,
 		.page_size	= 4 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
-		.probe		= probe_49lfxxxc,
+		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 256} },
 				.block_erase = erase_sector_49lfxxxc,
 			}, {
@@ -4253,17 +4257,17 @@
 		.vendor		= "SST",
 		.name		= "SST49LF016C",
 		.bustype	= CHIP_BUSTYPE_FWH,
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF016C,
 		.total_size	= 2048,
 		.page_size	= 4 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_OK_PRW,
-		.probe		= probe_49lfxxxc,
+		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 512} },
 				.block_erase = erase_sector_49lfxxxc,
 			}, {
@@ -4374,15 +4378,15 @@
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF040B,
 		.total_size	= 512,
 		.page_size	= 64 * 1024,
 		.feature_bits	= FEATURE_EITHER_RESET,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_jedec,
-		.probe_timing	= 1,		/* 150ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
+		.probe_timing	= 1,		/* 150ns */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 128} },
 				.block_erase = erase_sector_jedec,
 			}, {
 				.eraseblocks = { {64 * 1024, 8} },
@@ -4429,17 +4433,17 @@
 		.vendor		= "SST",
 		.name		= "SST49LF160C",
 		.bustype	= CHIP_BUSTYPE_LPC,
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_49LF160C,
 		.total_size	= 2048,
 		.page_size	= 4 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_OK_PRW,
-		.probe		= probe_49lfxxxc,
+		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {4 * 1024, 512} },
 				.block_erase = erase_sector_49lfxxxc,
 			}, {
@@ -4962,15 +4966,15 @@
 		.vendor		= "ST",
 		.name		= "M50FLW040A",
 		.bustype	= CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_LPC, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50FLW040A,
 		.total_size	= 512,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_FIXME,
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = {
@@ -4996,15 +5000,15 @@
 		.vendor		= "ST",
 		.name		= "M50FLW040B",
 		.bustype	= CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_LPC, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50FLW040B,
 		.total_size	= 512,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_FIXME,
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = {
@@ -5030,15 +5034,15 @@
 		.vendor		= "ST",
 		.name		= "M50FLW080A",
 		.bustype	= CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_LPC, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50FLW080A,
 		.total_size	= 1024,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_FIXME,
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = {
@@ -5064,15 +5068,15 @@
 		.vendor		= "ST",
 		.name		= "M50FLW080B",
 		.bustype	= CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_LPC, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50FLW080B,
 		.total_size	= 1024,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_FIXME,
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = {
@@ -5098,15 +5102,15 @@
 		.vendor		= "ST",
 		.name		= "M50FW002",
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50FW002,
 		.total_size	= 256,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = {
@@ -5129,15 +5133,15 @@
 		.vendor		= "ST",
 		.name		= "M50FW016",
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50FW016,
 		.total_size	= 2048,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (82802ab.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {64 * 1024, 32}, },
@@ -5155,15 +5159,15 @@
 		.vendor		= "ST",
 		.name		= "M50FW040",
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50FW040,
 		.total_size	= 512,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_OK_PRW,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (82802ab.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {64 * 1024, 8}, },
@@ -5181,15 +5185,15 @@
 		.vendor		= "ST",
 		.name		= "M50FW080",
 		.bustype	= CHIP_BUSTYPE_FWH, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50FW080,
 		.total_size	= 1024,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_OK_PRW,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (82802ab.c) */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = { {64 * 1024, 16}, },
@@ -5207,15 +5211,15 @@
 		.vendor		= "ST",
 		.name		= "M50LPW116",
 		.bustype	= CHIP_BUSTYPE_LPC, /* A/A Mux */
 		.manufacture_id	= ST_ID,
 		.model_id	= ST_M50LPW116,
 		.total_size	= 2048,
 		.page_size	= 64 * 1024,
-		.feature_bits	= 0,
+		.feature_bits	= FEATURE_REGISTERMAP,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_82802ab,
 		.probe_timing	= TIMING_ZERO,	/* Datasheet has no timing info specified */
 		.block_erasers	=
 		{
 			{
 				.eraseblocks = {
Index: flashrom-probe_cleanup/sst_fwhub.c
===================================================================
--- flashrom-probe_cleanup/sst_fwhub.c	(Revision 935)
+++ flashrom-probe_cleanup/sst_fwhub.c	(Arbeitskopie)
@@ -79,26 +79,22 @@
 		blockstatus = check_sst_fwhub_block_lock(flash, offset);
 		printf_debug("%s\n", (blockstatus) ? "failed" : "OK");
 	}
 
 	return blockstatus;
 }
 
-/* probe_jedec works fine for probing */
-int probe_sst_fwhub(struct flashchip *flash)
+int printlock_sst_fwhub(struct flashchip *flash)
 {
 	int i;
 
-	if (probe_jedec(flash) == 0)
-		return 0;
-
 	for (i = 0; i < flash->total_size * 1024; i += flash->page_size)
 		check_sst_fwhub_block_lock(flash, i);
 
-	return 1;
+	return 0;
 }
 
 int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size)
 {
 	uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset);
 
 	if (blockstatus) {
Index: flashrom-probe_cleanup/82802ab.c
===================================================================
--- flashrom-probe_cleanup/82802ab.c	(Revision 935)
+++ flashrom-probe_cleanup/82802ab.c	(Arbeitskopie)
@@ -65,15 +65,16 @@
 	programmer_delay(10);
 
 	printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2);
 
 	if (id1 != flash->manufacture_id || id2 != flash->model_id)
 		return 0;
 
-	map_flash_registers(flash);
+	if (flash->feature_bits & FEATURE_REGISTERMAP)
+		map_flash_registers(flash);
 
 	return 1;
 }
 
 uint8_t wait_82802ab(chipaddr bios)
 {
 	uint8_t status;
Index: flashrom-probe_cleanup/chipdrivers.h
===================================================================
--- flashrom-probe_cleanup/chipdrivers.h	(Revision 935)
+++ flashrom-probe_cleanup/chipdrivers.h	(Arbeitskopie)
@@ -113,14 +113,15 @@
 
 /* sst_fwhub.c */
 int probe_sst_fwhub(struct flashchip *flash);
 int erase_sst_fwhub(struct flashchip *flash);
 int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size);
 int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size);
 int write_sst_fwhub(struct flashchip *flash, uint8_t *buf);
+int printlock_sst_fwhub(struct flashchip *flash);
 
 /* w39v040c.c */
 int probe_w39v040c(struct flashchip *flash);
 int erase_w39v040c(struct flashchip *flash);
 int write_w39v040c(struct flashchip *flash, uint8_t *buf);
 int printlock_w39v040c(struct flashchip *flash);
 


-- 
"I do consider assignment statements and pointer variables to be among
computer science's most valuable treasures."
-- Donald E. Knuth





More information about the flashrom mailing list