Please see attached fr.cacheprobe_goto.patch.
For those who fiercly advocate against goto; please compare
fr.cacheprobe_goto.patch (which I propose to commit) with the mess in
fr.cacheprobe_if.patch (which is not signed off and only included for
reference) - goto ftw!
Timing:
flashrom r3386: 1.099s
flashrom r3387 (10ms patch): 1.880s
flashrom r3387 + this patch: 0.882s
May be considered petty to optimize away this one second, but it is
quite noticeable, and not neccessary.
//Peter
flashrom: Cache probed id:s
Best case it is merely pointless to repeat a probe sequence.
Worst case it causes system instability, as we saw with the AMIC A49LF040A.
This also shortens flashrom's execution time roughly one second.
Signed-off-by: Peter Stuge <[EMAIL PROTECTED]>
Index: en29f002a.c
===================================================================
--- en29f002a.c (revision 3387)
+++ en29f002a.c (working copy)
@@ -28,8 +28,11 @@
int probe_en29f512(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
*(volatile uint8_t *)(bios + 0x555) = 0xAA;
*(volatile uint8_t *)(bios + 0x2AA) = 0x55;
*(volatile uint8_t *)(bios + 0x555) = 0x90;
@@ -44,7 +47,9 @@
*(volatile uint8_t *)(bios + 0x2AA) = 0x55;
*(volatile uint8_t *)(bios + 0x555) = 0xF0;
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
@@ -59,8 +64,11 @@
int probe_en29f002a(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
*(volatile uint8_t *)(bios + 0x555) = 0xAA;
*(volatile uint8_t *)(bios + 0xAAA) = 0x55;
*(volatile uint8_t *)(bios + 0x555) = 0x90;
@@ -75,7 +83,9 @@
*(volatile uint8_t *)(bios + 0xAAA) = 0x55;
*(volatile uint8_t *)(bios + 0x555) = 0xF0;
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: jedec.c
===================================================================
--- jedec.c (revision 3387)
+++ jedec.c (working copy)
@@ -90,9 +90,12 @@
int probe_jedec(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
- uint32_t largeid1, largeid2;
+ static uint8_t id1, id2, read = 0;
+ static uint32_t largeid1, largeid2;
+ if (read)
+ goto haveread;
+
/* Issue JEDEC Product ID Entry command */
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
myusec_delay(10);
@@ -130,7 +133,9 @@
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
myusec_delay(40);
- printf_debug("%s: id1 0x%x, id2 0x%x", __FUNCTION__, largeid1, largeid2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x", __FUNCTION__, read ? "cached " : "", largeid1, largeid2);
+ read = 1;
if (!oddparity(id1))
printf_debug(", id1 parity violation");
printf_debug("\n");
Index: w29ee011.c
===================================================================
--- w29ee011.c (revision 3387)
+++ w29ee011.c (working copy)
@@ -24,7 +24,7 @@
int probe_w29ee011(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
extern char *chip_to_probe;
if (!chip_to_probe || strcmp(chip_to_probe,"W29EE011")) {
@@ -36,6 +36,9 @@
return 0;
}
+ if (read)
+ goto haveread;
+
/* Issue JEDEC Product ID Entry command */
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
myusec_delay(10);
@@ -62,7 +65,9 @@
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
myusec_delay(10);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: sst49lfxxxc.c
===================================================================
--- sst49lfxxxc.c (revision 3387)
+++ sst49lfxxxc.c (working copy)
@@ -125,8 +125,11 @@
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
*bios = RESET;
*bios = READ_ID;
@@ -135,7 +138,9 @@
*bios = RESET;
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (!(id1 == flash->manufacture_id && id2 == flash->model_id))
return 0;
Index: sharplhf00l04.c
===================================================================
--- sharplhf00l04.c (revision 3387)
+++ sharplhf00l04.c (working copy)
@@ -37,8 +37,11 @@
int probe_lhf00l04(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
#if 0
/* Enter ID mode */
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
@@ -61,7 +64,9 @@
myusec_delay(10);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 != flash->manufacture_id || id2 != flash->model_id)
return 0;
Index: spi.c
===================================================================
--- spi.c (revision 3387)
+++ spi.c (working copy)
@@ -80,9 +80,12 @@
int probe_spi_rdid(struct flashchip *flash)
{
unsigned char readarr[3];
- uint32_t manuf_id;
- uint32_t model_id;
+ static uint32_t manuf_id, model_id;
+ static uint8_t read = 0;
+ if (read)
+ goto haveread;
+
if (spi_rdid(readarr))
return 0;
@@ -100,7 +103,9 @@
model_id = (readarr[1] << 8) | readarr[2];
}
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, manuf_id, model_id);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", manuf_id, model_id);
+ read = 1;
if (manuf_id == flash->manufacture_id &&
model_id == flash->model_id) {
@@ -123,8 +128,12 @@
int probe_spi_res(struct flashchip *flash)
{
unsigned char readarr[3];
- uint32_t model_id;
+ static uint32_t model_id;
+ static uint8_t read = 0;
+ if (read)
+ goto haveread;
+
if (spi_rdid(readarr))
/* We couldn't issue RDID, it's pointless to try RES. */
return 0;
@@ -138,7 +147,11 @@
return 0;
model_id = readarr[0];
- printf_debug("%s: id 0x%x\n", __FUNCTION__, model_id);
+
+haveread:
+ printf_debug("%s: %sid 0x%02x\n", __FUNCTION__, read ? "cached " : "", model_id);
+ read = 1;
+
if (model_id != flash->model_id)
return 0;
Index: sst28sf040.c
===================================================================
--- sst28sf040.c (revision 3387)
+++ sst28sf040.c (working copy)
@@ -98,8 +98,11 @@
int probe_28sf040(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
*bios = RESET;
myusec_delay(10);
@@ -112,7 +115,9 @@
*bios = RESET;
myusec_delay(10);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: stm50flw0x0x.c
===================================================================
--- stm50flw0x0x.c (revision 3387)
+++ stm50flw0x0x.c (working copy)
@@ -45,9 +45,12 @@
int probe_stm50flw0x0x(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
- uint32_t largeid1, largeid2;
+ static uint8_t id1, id2, read = 0;
+ static uint32_t largeid1, largeid2;
+ if (read)
+ goto haveread;
+
/* Issue JEDEC Product ID Entry command */
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
myusec_delay(10);
@@ -82,8 +85,9 @@
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
myusec_delay(40);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, largeid1,
- largeid2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", largeid1, largeid2);
+ read = 1;
if (largeid1 != flash->manufacture_id || largeid2 != flash->model_id)
return 0;
Index: am29f040b.c
===================================================================
--- am29f040b.c (revision 3387)
+++ am29f040b.c (working copy)
@@ -70,8 +70,11 @@
int probe_29f040b(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
*(bios + 0x555) = 0xAA;
*(bios + 0x2AA) = 0x55;
*(bios + 0x555) = 0x90;
@@ -83,7 +86,9 @@
myusec_delay(10);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: w39v080fa.c
===================================================================
--- w39v080fa.c (revision 3387)
+++ w39v080fa.c (working copy)
@@ -24,8 +24,11 @@
int probe_winbond_fwhub(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t vid, did;
+ static uint8_t vid, did, read = 0;
+ if (read)
+ goto haveread;
+
/* Product Identification Entry */
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
@@ -42,7 +45,9 @@
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
myusec_delay(10);
- printf_debug("%s: vid 0x%x, did 0x%x\n", __FUNCTION__, vid, did);
+haveread:
+ printf_debug("%s: %svid 0x%02x, did 0x%02x\n", __FUNCTION__, read ? "cached " : "", vid, did);
+ read = 1;
if (vid != flash->manufacture_id || did != flash->model_id)
return 0;
Index: 82802ab.c
===================================================================
--- 82802ab.c (revision 3387)
+++ 82802ab.c (working copy)
@@ -46,8 +46,11 @@
int probe_82802ab(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
#if 0
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
@@ -69,7 +72,9 @@
myusec_delay(10);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 != flash->manufacture_id || id2 != flash->model_id)
return 0;
Index: mx29f002.c
===================================================================
--- mx29f002.c (revision 3387)
+++ mx29f002.c (working copy)
@@ -25,8 +25,11 @@
int probe_29f002(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
*(bios + 0x5555) = 0xAA;
*(bios + 0x2AAA) = 0x55;
*(bios + 0x5555) = 0x90;
@@ -38,7 +41,9 @@
myusec_delay(10);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: m29f400bt.c
===================================================================
--- m29f400bt.c (revision 3387)
+++ m29f400bt.c (working copy)
@@ -55,8 +55,11 @@
int probe_m29f400bt(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (read)
+ goto haveread;
+
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
*(volatile uint8_t *)(bios + 0x555) = 0x55;
*(volatile uint8_t *)(bios + 0xAAA) = 0x90;
@@ -75,7 +78,9 @@
myusec_delay(10);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+haveread:
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: en29f002a.c
===================================================================
--- en29f002a.c (revision 3387)
+++ en29f002a.c (working copy)
@@ -28,23 +28,26 @@
int probe_en29f512(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
- *(volatile uint8_t *)(bios + 0x555) = 0xAA;
- *(volatile uint8_t *)(bios + 0x2AA) = 0x55;
- *(volatile uint8_t *)(bios + 0x555) = 0x90;
+ if (!read) {
+ *(volatile uint8_t *)(bios + 0x555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x555) = 0x90;
- myusec_delay(10);
+ myusec_delay(10);
- id1 = *(volatile uint8_t *)(bios + 0x100);
- id2 = *(volatile uint8_t *)(bios + 0x101);
+ id1 = *(volatile uint8_t *)(bios + 0x100);
+ id2 = *(volatile uint8_t *)(bios + 0x101);
- /* exit by writing F0 anywhere? or the code below */
- *(volatile uint8_t *)(bios + 0x555) = 0xAA;
- *(volatile uint8_t *)(bios + 0x2AA) = 0x55;
- *(volatile uint8_t *)(bios + 0x555) = 0xF0;
+ /* exit by writing F0 anywhere? or the code below */
+ *(volatile uint8_t *)(bios + 0x555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x555) = 0xF0;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
@@ -59,23 +62,26 @@
int probe_en29f002a(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
- *(volatile uint8_t *)(bios + 0x555) = 0xAA;
- *(volatile uint8_t *)(bios + 0xAAA) = 0x55;
- *(volatile uint8_t *)(bios + 0x555) = 0x90;
+ if (!read) {
+ *(volatile uint8_t *)(bios + 0x555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0xAAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x555) = 0x90;
- myusec_delay(10);
+ myusec_delay(10);
- id1 = *(volatile uint8_t *)(bios + 0x100);
- id2 = *(volatile uint8_t *)(bios + 0x101);
+ id1 = *(volatile uint8_t *)(bios + 0x100);
+ id2 = *(volatile uint8_t *)(bios + 0x101);
- /* exit by writing F0 anywhere? or the code below */
- *(volatile uint8_t *)(bios + 0x555) = 0xAA;
- *(volatile uint8_t *)(bios + 0xAAA) = 0x55;
- *(volatile uint8_t *)(bios + 0x555) = 0xF0;
+ /* exit by writing F0 anywhere? or the code below */
+ *(volatile uint8_t *)(bios + 0x555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0xAAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x555) = 0xF0;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: jedec.c
===================================================================
--- jedec.c (revision 3387)
+++ jedec.c (working copy)
@@ -90,47 +90,50 @@
int probe_jedec(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
- uint32_t largeid1, largeid2;
+ static uint8_t id1, id2, read = 0;
+ static uint32_t largeid1, largeid2;
- /* Issue JEDEC Product ID Entry command */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x5555) = 0x90;
- /* Older chips may need up to 100 us to respond. The ATMEL 29C020
- * needs 10 ms according to the data sheet.
- */
- myusec_delay(10000);
+ if (!read) {
+ /* Issue JEDEC Product ID Entry command */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x5555) = 0x90;
+ /* Older chips may need up to 100 us to respond. The ATMEL 29C020
+ * needs 10 ms according to the data sheet.
+ */
+ myusec_delay(10000);
- /* Read product ID */
- id1 = *(volatile uint8_t *)bios;
- id2 = *(volatile uint8_t *)(bios + 0x01);
- largeid1 = id1;
- largeid2 = id2;
+ /* Read product ID */
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
+ largeid1 = id1;
+ largeid2 = id2;
- /* Check if it is a continuation ID, this should be a while loop. */
- if (id1 == 0x7F) {
- largeid1 <<= 8;
- id1 = *(volatile uint8_t *)(bios + 0x100);
- largeid1 |= id1;
+ /* Check if it is a continuation ID, this should be a while loop. */
+ if (id1 == 0x7F) {
+ largeid1 <<= 8;
+ id1 = *(volatile uint8_t *)(bios + 0x100);
+ largeid1 |= id1;
+ }
+ if (id2 == 0x7F) {
+ largeid2 <<= 8;
+ id2 = *(volatile uint8_t *)(bios + 0x101);
+ largeid2 |= id2;
+ }
+
+ /* Issue JEDEC Product ID Exit command */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
+ myusec_delay(40);
+ read = 1;
}
- if (id2 == 0x7F) {
- largeid2 <<= 8;
- id2 = *(volatile uint8_t *)(bios + 0x101);
- largeid2 |= id2;
- }
- /* Issue JEDEC Product ID Exit command */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
- myusec_delay(40);
-
- printf_debug("%s: id1 0x%x, id2 0x%x", __FUNCTION__, largeid1, largeid2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x", __FUNCTION__, read ? "cached " : "", largeid1, largeid2);
if (!oddparity(id1))
printf_debug(", id1 parity violation");
printf_debug("\n");
Index: w29ee011.c
===================================================================
--- w29ee011.c (revision 3387)
+++ w29ee011.c (working copy)
@@ -24,7 +24,7 @@
int probe_w29ee011(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
extern char *chip_to_probe;
if (!chip_to_probe || strcmp(chip_to_probe,"W29EE011")) {
@@ -36,33 +36,36 @@
return 0;
}
- /* Issue JEDEC Product ID Entry command */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x5555) = 0x80;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x5555) = 0x60;
- myusec_delay(10);
+ if (!read) {
+ /* Issue JEDEC Product ID Entry command */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x5555) = 0x80;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x5555) = 0x60;
+ myusec_delay(10);
- /* Read product ID */
- id1 = *(volatile uint8_t *)bios;
- id2 = *(volatile uint8_t *)(bios + 0x01);
+ /* Read product ID */
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
- /* Issue JEDEC Product ID Exit command */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
- myusec_delay(10);
+ /* Issue JEDEC Product ID Exit command */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
+ myusec_delay(10);
+ read = 1;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: sst49lfxxxc.c
===================================================================
--- sst49lfxxxc.c (revision 3387)
+++ sst49lfxxxc.c (working copy)
@@ -125,17 +125,20 @@
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
- *bios = RESET;
+ if (!read) {
+ *bios = RESET;
- *bios = READ_ID;
- id1 = *(volatile uint8_t *)bios;
- id2 = *(volatile uint8_t *)(bios + 0x01);
+ *bios = READ_ID;
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
- *bios = RESET;
+ *bios = RESET;
+ read = 1;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
if (!(id1 == flash->manufacture_id && id2 == flash->model_id))
return 0;
Index: sharplhf00l04.c
===================================================================
--- sharplhf00l04.c (revision 3387)
+++ sharplhf00l04.c (working copy)
@@ -37,31 +37,34 @@
int probe_lhf00l04(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (!read) {
#if 0
- /* Enter ID mode */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *)(bios + 0x5555) = 0x90;
+ /* Enter ID mode */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0x90;
#endif
- *bios = 0xff;
- myusec_delay(10);
- *bios = 0x90;
- myusec_delay(10);
+ *bios = 0xff;
+ myusec_delay(10);
+ *bios = 0x90;
+ myusec_delay(10);
- id1 = *(volatile uint8_t *)bios;
- id2 = *(volatile uint8_t *)(bios + 0x01);
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
- /* Leave ID mode */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
+ /* Leave ID mode */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
- myusec_delay(10);
+ myusec_delay(10);
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
+ read = 1;
if (id1 != flash->manufacture_id || id2 != flash->model_id)
return 0;
Index: spi.c
===================================================================
--- spi.c (revision 3387)
+++ spi.c (working copy)
@@ -80,24 +80,27 @@
int probe_spi_rdid(struct flashchip *flash)
{
unsigned char readarr[3];
- uint32_t manuf_id;
- uint32_t model_id;
+ static uint32_t manuf_id, model_id;
+ static uint8_t read = 0;
- if (spi_rdid(readarr))
- return 0;
+ if (!read) {
+ if (spi_rdid(readarr))
+ return 0;
- if (!oddparity(readarr[0]))
- printf_debug("RDID byte 0 parity violation.\n");
+ if (!oddparity(readarr[0]))
+ printf_debug("RDID byte 0 parity violation.\n");
- /* Check if this is a continuation vendor ID */
- if (readarr[0] == 0x7f) {
- if (!oddparity(readarr[1]))
- printf_debug("RDID byte 1 parity violation.\n");
- manuf_id = (readarr[0] << 8) | readarr[1];
- model_id = readarr[2];
- } else {
- manuf_id = readarr[0];
- model_id = (readarr[1] << 8) | readarr[2];
+ /* Check if this is a continuation vendor ID */
+ if (readarr[0] == 0x7f) {
+ if (!oddparity(readarr[1]))
+ printf_debug("RDID byte 1 parity violation.\n");
+ manuf_id = (readarr[0] << 8) | readarr[1];
+ model_id = readarr[2];
+ } else {
+ manuf_id = readarr[0];
+ model_id = (readarr[1] << 8) | readarr[2];
+ }
+ read = 1;
}
printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, manuf_id, model_id);
@@ -123,21 +126,26 @@
int probe_spi_res(struct flashchip *flash)
{
unsigned char readarr[3];
- uint32_t model_id;
+ static uint32_t model_id;
+ static uint8_t read = 0;
- if (spi_rdid(readarr))
- /* We couldn't issue RDID, it's pointless to try RES. */
- return 0;
+ if (!read) {
+ if (spi_rdid(readarr))
+ /* We couldn't issue RDID, it's pointless to try RES. */
+ return 0;
- /* Check if RDID returns 0xff 0xff 0xff, then we use RES. */
- if ((readarr[0] != 0xff) || (readarr[1] != 0xff) ||
- (readarr[2] != 0xff))
- return 0;
+ /* Check if RDID returns 0xff 0xff 0xff, then we use RES. */
+ if ((readarr[0] != 0xff) || (readarr[1] != 0xff) ||
+ (readarr[2] != 0xff))
+ return 0;
- if (spi_res(readarr))
- return 0;
+ if (spi_res(readarr))
+ return 0;
- model_id = readarr[0];
+ model_id = readarr[0];
+ read = 1;
+ }
+
printf_debug("%s: id 0x%x\n", __FUNCTION__, model_id);
if (model_id != flash->model_id)
return 0;
Index: sst28sf040.c
===================================================================
--- sst28sf040.c (revision 3387)
+++ sst28sf040.c (working copy)
@@ -98,21 +98,24 @@
int probe_28sf040(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
- *bios = RESET;
- myusec_delay(10);
+ if (!read) {
+ *bios = RESET;
+ myusec_delay(10);
- *bios = READ_ID;
- myusec_delay(10);
- id1 = *(volatile uint8_t *)bios;
- myusec_delay(10);
- id2 = *(volatile uint8_t *)(bios + 0x01);
+ *bios = READ_ID;
+ myusec_delay(10);
+ id1 = *(volatile uint8_t *)bios;
+ myusec_delay(10);
+ id2 = *(volatile uint8_t *)(bios + 0x01);
- *bios = RESET;
- myusec_delay(10);
+ *bios = RESET;
+ myusec_delay(10);
+ read = 1;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: stm50flw0x0x.c
===================================================================
--- stm50flw0x0x.c (revision 3387)
+++ stm50flw0x0x.c (working copy)
@@ -45,46 +45,48 @@
int probe_stm50flw0x0x(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
- uint32_t largeid1, largeid2;
+ static uint8_t id1, id2, read = 0;
+ static uint32_t largeid1, largeid2;
- /* Issue JEDEC Product ID Entry command */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x5555) = 0x90;
- myusec_delay(40);
+ if (!read) {
+ /* Issue JEDEC Product ID Entry command */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x5555) = 0x90;
+ myusec_delay(40);
- /* Read product ID */
- id1 = *(volatile uint8_t *)bios;
- id2 = *(volatile uint8_t *)(bios + 0x01);
- largeid1 = id1;
- largeid2 = id2;
+ /* Read product ID */
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
+ largeid1 = id1;
+ largeid2 = id2;
- /* Check if it is a continuation ID, this should be a while loop. */
- if (id1 == 0x7F) {
- largeid1 <<= 8;
- id1 = *(volatile uint8_t *)(bios + 0x100);
- largeid1 |= id1;
+ /* Check if it is a continuation ID, this should be a while loop. */
+ if (id1 == 0x7F) {
+ largeid1 <<= 8;
+ id1 = *(volatile uint8_t *)(bios + 0x100);
+ largeid1 |= id1;
+ }
+ if (id2 == 0x7F) {
+ largeid2 <<= 8;
+ id2 = *(volatile uint8_t *)(bios + 0x101);
+ largeid2 |= id2;
+ }
+
+ /* Issue JEDEC Product ID Exit command */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ myusec_delay(10);
+ *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
+ myusec_delay(40);
+ read = 1;
}
- if (id2 == 0x7F) {
- largeid2 <<= 8;
- id2 = *(volatile uint8_t *)(bios + 0x101);
- largeid2 |= id2;
- }
- /* Issue JEDEC Product ID Exit command */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- myusec_delay(10);
- *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
- myusec_delay(40);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", largeid1, largeid2);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, largeid1,
- largeid2);
-
if (largeid1 != flash->manufacture_id || largeid2 != flash->model_id)
return 0;
Index: am29f040b.c
===================================================================
--- am29f040b.c (revision 3387)
+++ am29f040b.c (working copy)
@@ -70,20 +70,23 @@
int probe_29f040b(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
- *(bios + 0x555) = 0xAA;
- *(bios + 0x2AA) = 0x55;
- *(bios + 0x555) = 0x90;
+ if (!read) {
+ *(bios + 0x555) = 0xAA;
+ *(bios + 0x2AA) = 0x55;
+ *(bios + 0x555) = 0x90;
- id1 = *bios;
- id2 = *(bios + 0x01);
+ id1 = *bios;
+ id2 = *(bios + 0x01);
- *bios = 0xF0;
+ *bios = 0xF0;
- myusec_delay(10);
+ myusec_delay(10);
+ read = 1;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: w39v080fa.c
===================================================================
--- w39v080fa.c (revision 3387)
+++ w39v080fa.c (working copy)
@@ -24,25 +24,28 @@
int probe_winbond_fwhub(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t vid, did;
+ static uint8_t vid, did, read = 0;
- /* Product Identification Entry */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *)(bios + 0x5555) = 0x90;
- myusec_delay(10);
+ if (!read) {
+ /* Product Identification Entry */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0x90;
+ myusec_delay(10);
- /* Read product ID */
- vid = *(volatile uint8_t *)bios;
- did = *(volatile uint8_t *)(bios + 0x01);
+ /* Read product ID */
+ vid = *(volatile uint8_t *)bios;
+ did = *(volatile uint8_t *)(bios + 0x01);
- /* Product Identifixation Exit */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
- myusec_delay(10);
+ /* Product Identifixation Exit */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
+ myusec_delay(10);
+ read = 1;
+ }
- printf_debug("%s: vid 0x%x, did 0x%x\n", __FUNCTION__, vid, did);
+ printf_debug("%s: %svid 0x%02x, did 0x%02x\n", __FUNCTION__, read ? "cached " : "", vid, did);
if (vid != flash->manufacture_id || did != flash->model_id)
return 0;
Index: 82802ab.c
===================================================================
--- 82802ab.c (revision 3387)
+++ 82802ab.c (working copy)
@@ -46,30 +46,33 @@
int probe_82802ab(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
+ if (!read) {
#if 0
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *)(bios + 0x5555) = 0x90;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0x90;
#endif
- *bios = 0xff;
- myusec_delay(10);
- *bios = 0x90;
- myusec_delay(10);
+ *bios = 0xff;
+ myusec_delay(10);
+ *bios = 0x90;
+ myusec_delay(10);
- id1 = *(volatile uint8_t *)bios;
- id2 = *(volatile uint8_t *)(bios + 0x01);
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
- /* Leave ID mode */
- *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
- *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
+ /* Leave ID mode */
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
- myusec_delay(10);
+ myusec_delay(10);
+ read = 1;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
if (id1 != flash->manufacture_id || id2 != flash->model_id)
return 0;
Index: m29f400bt.c
===================================================================
--- m29f400bt.c (revision 3387)
+++ m29f400bt.c (working copy)
@@ -55,27 +55,30 @@
int probe_m29f400bt(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
- *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
- *(volatile uint8_t *)(bios + 0x555) = 0x55;
- *(volatile uint8_t *)(bios + 0xAAA) = 0x90;
+ if (!read) {
+ *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x555) = 0x55;
+ *(volatile uint8_t *)(bios + 0xAAA) = 0x90;
- myusec_delay(10);
+ myusec_delay(10);
- id1 = *(volatile uint8_t *)bios;
- /* The data sheet says id2 is at (bios + 0x01) and id2 listed in
- * flash.h does not match. It should be possible to use JEDEC probe.
- */
- id2 = *(volatile uint8_t *)(bios + 0x02);
+ id1 = *(volatile uint8_t *)bios;
+ /* The data sheet says id2 is at (bios + 0x01) and id2 listed in
+ * flash.h does not match. It should be possible to use JEDEC probe.
+ */
+ id2 = *(volatile uint8_t *)(bios + 0x02);
- *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
- *(volatile uint8_t *)(bios + 0x555) = 0x55;
- *(volatile uint8_t *)(bios + 0xAAA) = 0xF0;
+ *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x555) = 0x55;
+ *(volatile uint8_t *)(bios + 0xAAA) = 0xF0;
- myusec_delay(10);
+ myusec_delay(10);
+ read = 1;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
Index: mx29f002.c
===================================================================
--- mx29f002.c (revision 3387)
+++ mx29f002.c (working copy)
@@ -25,20 +25,23 @@
int probe_29f002(struct flashchip *flash)
{
volatile uint8_t *bios = flash->virtual_memory;
- uint8_t id1, id2;
+ static uint8_t id1, id2, read = 0;
- *(bios + 0x5555) = 0xAA;
- *(bios + 0x2AAA) = 0x55;
- *(bios + 0x5555) = 0x90;
+ if (!read) {
+ *(bios + 0x5555) = 0xAA;
+ *(bios + 0x2AAA) = 0x55;
+ *(bios + 0x5555) = 0x90;
- id1 = *(volatile uint8_t *)bios;
- id2 = *(volatile uint8_t *)(bios + 0x01);
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
- *bios = 0xF0;
+ *bios = 0xF0;
- myusec_delay(10);
+ myusec_delay(10);
+ read = 1;
+ }
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
+ printf_debug("%s: %sid1 0x%02x, id2 0x%02x\n", __FUNCTION__, read ? "cached " : "", id1, id2);
if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1;
--
coreboot mailing list
[email protected]
http://www.coreboot.org/mailman/listinfo/coreboot