summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-01 02:08:58 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-01 02:08:58 +0000
commitb22918cadc5ba07c037935644f8c6dcef0583e23 (patch)
treec2fd7bff346e61d3433a0c0e2fe66b7173e482de /flashrom.c
parent3504b539bfa33693510d83402a344b1eafd7a592 (diff)
downloadast2050-flashrom-b22918cadc5ba07c037935644f8c6dcef0583e23.zip
ast2050-flashrom-b22918cadc5ba07c037935644f8c6dcef0583e23.tar.gz
Only probe for chips with compatible bus protocols
It doesn't make sense to probe for SPI chips on a LPC host, nor does it make sense to probe for LPC chips on a Parallel host. This change is backwards compatible, but adding host protocol info to chipset init functions will speed up probing. Once all chipset init functions are updated and the Winbond W29EE011 and AMIC A49LF040A chip definitions are updated, the W29EE011 workaround can be deleted as the W29/A49 conflict magically disappears. Corresponding to flashrom svn r560. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Tested on real hardware and Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/flashrom.c b/flashrom.c
index 0eb502d..c7e17d3 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -174,10 +174,51 @@ int read_memmapped(struct flashchip *flash, uint8_t *buf)
return 0;
}
+char *strcat_realloc(char *dest, const char *src)
+{
+ dest = realloc(dest, strlen(dest) + strlen(src) + 1);
+ if (!dest)
+ return NULL;
+ strcat(dest, src);
+ return dest;
+}
+
+/* Return a string corresponding to the bustype parameter.
+ * Memory is obtained with malloc() and can be freed with free().
+ */
+char *flashbuses_to_text(enum chipbustype bustype)
+{
+ char *ret = calloc(1, 1);
+ if (bustype == CHIP_BUSTYPE_UNKNOWN) {
+ ret = strcat_realloc(ret, "Unknown,");
+ /* FIXME: Once all chipsets and flash chips have been updated, NONSPI
+ * will cease to exist and should be eliminated here as well.
+ */
+ } else if (bustype == CHIP_BUSTYPE_NONSPI) {
+ ret = strcat_realloc(ret, "Non-SPI,");
+ } else {
+ if (bustype & CHIP_BUSTYPE_PARALLEL)
+ ret = strcat_realloc(ret, "Parallel,");
+ if (bustype & CHIP_BUSTYPE_LPC)
+ ret = strcat_realloc(ret, "LPC,");
+ if (bustype & CHIP_BUSTYPE_FWH)
+ ret = strcat_realloc(ret, "FWH,");
+ if (bustype & CHIP_BUSTYPE_SPI)
+ ret = strcat_realloc(ret, "SPI,");
+ if (bustype == CHIP_BUSTYPE_NONE)
+ ret = strcat_realloc(ret, "None,");
+ }
+ /* Kill last comma. */
+ ret[strlen(ret) - 1] = '\0';
+ ret = realloc(ret, strlen(ret) + 1);
+ return ret;
+}
+
struct flashchip *probe_flash(struct flashchip *first_flash, int force)
{
struct flashchip *flash;
unsigned long base = 0, size;
+ char *tmp;
for (flash = first_flash; flash && flash->name; flash++) {
if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0)
@@ -188,6 +229,15 @@ struct flashchip *probe_flash(struct flashchip *first_flash, int force)
printf_debug("failed! flashrom has no probe function for this flash chip.\n");
continue;
}
+ if (!(buses_supported & flash->bustype)) {
+ tmp = flashbuses_to_text(buses_supported);
+ printf_debug("skipped. Host bus type %s ", tmp);
+ free(tmp);
+ tmp = flashbuses_to_text(flash->bustype);
+ printf_debug("and chip bus type %s are incompatible.\n", tmp);
+ free(tmp);
+ continue;
+ }
size = flash->total_size * 1024;
OpenPOWER on IntegriCloud