Add FEATURE_REGISTERMAP to some more chips and change the use of various probing functions

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.

Corresponding to flashrom svn r937.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
diff --git a/82802ab.c b/82802ab.c
index e63dc10..ca08b65 100644
--- a/82802ab.c
+++ b/82802ab.c
@@ -69,7 +69,8 @@
 	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;
 }
diff --git a/chipdrivers.h b/chipdrivers.h
index a378803..6b9f9d6 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -112,11 +112,11 @@
 int unlock_49lfxxxc(struct flashchip *flash);
 
 /* 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);
diff --git a/flashchips.c b/flashchips.c
index 1c30edc..727d69d 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -2392,7 +2392,7 @@
 		.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) */
@@ -2415,7 +2415,7 @@
 		.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) */
@@ -3442,9 +3442,9 @@
 		.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	=
 		{
@@ -3723,7 +3723,7 @@
 		.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	=
 		{
@@ -4078,8 +4078,8 @@
 		.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	=
 		{
 			{
@@ -4093,6 +4093,7 @@
 				.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,
 	},
@@ -4107,8 +4108,8 @@
 		.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	=
 		{
 			{
@@ -4122,6 +4123,7 @@
 				.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,
 	},
@@ -4139,8 +4141,8 @@
 		.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	=
 		{
 			{
@@ -4154,6 +4156,7 @@
 				.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,
 	},
@@ -4166,9 +4169,9 @@
 		.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	=
 		{
@@ -4199,8 +4202,8 @@
 		.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	=
 		{
 			{
@@ -4214,6 +4217,7 @@
 				.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,
 	},
@@ -4226,9 +4230,9 @@
 		.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	=
 		{
@@ -4257,9 +4261,9 @@
 		.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	=
 		{
@@ -4378,7 +4382,7 @@
 		.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	=
 		{
 			{
@@ -4433,9 +4437,9 @@
 		.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	=
 		{
@@ -4966,7 +4970,7 @@
 		.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,
@@ -5000,7 +5004,7 @@
 		.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,
@@ -5034,7 +5038,7 @@
 		.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,
@@ -5068,7 +5072,7 @@
 		.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,
@@ -5102,7 +5106,7 @@
 		.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) */
@@ -5133,7 +5137,7 @@
 		.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) */
@@ -5159,7 +5163,7 @@
 		.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) */
@@ -5185,7 +5189,7 @@
 		.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) */
@@ -5211,7 +5215,7 @@
 		.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 */
diff --git a/sst_fwhub.c b/sst_fwhub.c
index 9819cee..a325278 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -83,18 +83,14 @@
 	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)