flashchips: Add a type enum to the chip identification
We used to imply what kind of ID (e.g. RES, REMS, RDID) a chip entry
provides, based on the given probing function. This works well as long
as we call the respective probing function for every single chip entry.
With our ever growing chip database, however, this slows probing signi-
ficantly down. Especially with external programmers with a long command
round-trip.
With the type of identification information stored in the chip entries
explicitly, we'll be able to implement bus-specific probing functions.
These would be called only once and their results would be used to look
a matching chip up in the chip database. Instead of looking for every
possible chip on the buses, we can turn it around and search for the
actually present chips in the database.
Change-Id: Ie658ebf58f21c8994b9b66f7683f9490e8d12267
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/74898
diff --git a/include/chipdrivers/probing.h b/include/chipdrivers/probing.h
new file mode 100644
index 0000000..7563f74
--- /dev/null
+++ b/include/chipdrivers/probing.h
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the flashprog project.
+ *
+ * Copyright (C) 2023 Nico Huber <nico.h@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __PROBING_H__
+#define __PROBING_H__ 1
+
+#include <stdint.h>
+
+enum id_type {
+ ID_FIXME = 0,
+ ID_NONE,
+
+ ID_82802AB,
+ ID_EDI,
+ ID_EN29LV640B,
+ ID_JEDEC,
+ ID_JEDEC_29GL,
+ ID_OPAQUE,
+ ID_SPI_AT25F,
+ ID_SPI_RDID,
+ ID_SPI_RDID4,
+ ID_SPI_REMS,
+ ID_SPI_RES1,
+ ID_SPI_RES2,
+ ID_SPI_RES3,
+ ID_SPI_SFDP,
+ ID_SPI_ST95,
+ ID_W29EE011,
+};
+
+/*
+ * With 32bit manufacture_id and model_id we can cover IDs up to
+ * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's
+ * Identification code.
+ */
+struct id_info {
+ uint32_t manufacture;
+ uint32_t model;
+ enum id_type type;
+};
+
+#endif /* !__PROBING_H__ */
diff --git a/include/flash.h b/include/flash.h
index a67e64c..60e35d0 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -32,6 +32,7 @@
#undef max
#endif
+#include "chipdrivers/probing.h"
#include "libflashprog.h"
#include "layout.h"
#include "writeprotect.h"
@@ -248,13 +249,7 @@
enum chipbustype bustype;
- /*
- * With 32bit manufacture_id and model_id we can cover IDs up to
- * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's
- * Identification code.
- */
- uint32_t manufacture_id;
- uint32_t model_id;
+ struct id_info id;
/* Total chip size in kilobytes */
unsigned int total_size;