flashchips: Add function to populate list of voltage ranges
This can be used to attempt to find the supply voltage of a flash
chip. It is intended for use with external programmers so that
the user does not always need to set a voltage parameter.
BUG=none
BRANCH=none
TEST=tested with follow-up patch for dediprog
Change-Id: I48fe0791e59721f99525750d3ef8daa026035098
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313019
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
diff --git a/flash.h b/flash.h
index 10d286b..46059ef 100644
--- a/flash.h
+++ b/flash.h
@@ -128,6 +128,10 @@
#define FEATURE_ERASE_TO_ZERO (1 << 8)
#define FEATURE_UNBOUND_READ (1 << 10)
+struct voltage_range {
+ uint16_t min, max;
+};
+
struct flashchip {
const char *vendor;
const char *name;
@@ -182,10 +186,7 @@
int (*unlock) (struct flashchip *flash);
int (*write) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
int (*read) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
- struct {
- uint16_t min;
- uint16_t max;
- } voltage;
+ struct voltage_range voltage;
/* Some flash devices have an additional register space. */
chipaddr virtual_memory;
@@ -366,4 +367,9 @@
int spi_send_multicommand(struct spi_command *cmds);
uint32_t spi_get_valid_read_addr(void);
+#define NUM_VOLTAGE_RANGES 16
+extern struct voltage_range voltage_ranges[];
+/* returns number of unique voltage ranges, or <0 to indicate failure */
+extern int flash_supported_voltage_ranges(enum chipbustype bus);
+
#endif /* !__FLASH_H__ */