From: Martin Johnson <m.j.john...@massey.ac.nz>

Gigadevice flash chips supported in m25p80.c (GD25Q32, GD25Q64)
require a dummy bytes in DIO and QIO modes, similar to Winbond W25Q32
and W25Q64. This patch fixes this behavior.

Signed-off-by: Ivan Grokhotkov <i...@espressif.com>
Signed-off-by: Martin Johnson <m.j.john...@massey.ac.nz>
---
This patch was submitted into our fork at
https://github.com/espressif/qemu/pull/18. The patch seems applicable to
the upstream project, so I am submitting it on behalf of the author.

 hw/block/m25p80.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index a8d2519141..72a209b031 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -168,6 +168,7 @@ typedef struct FlashPartInfo {
 
 #define SPANSION_CONTINUOUS_READ_MODE_CMD_LEN 1
 #define WINBOND_CONTINUOUS_READ_MODE_CMD_LEN 1
+#define GIGADEVICE_CONTINUOUS_READ_MODE_CMD_LEN 1
 
 static const FlashPartInfo known_devices[] = {
     /* Atmel -- some are (confusingly) marketed as "DataFlash" */
@@ -430,6 +431,7 @@ typedef enum {
     MAN_WINBOND,
     MAN_SST,
     MAN_ISSI,
+    MAN_GIGADEVICE,
     MAN_GENERIC,
 } Manufacturer;
 
@@ -514,6 +516,8 @@ static inline Manufacturer get_man(Flash *s)
         return MAN_SST;
     case 0x9D:
         return MAN_ISSI;
+    case 0xC8:
+        return MAN_GIGADEVICE;
     default:
         return MAN_GENERIC;
     }
@@ -992,6 +996,9 @@ static void decode_dio_read_cmd(Flash *s)
     case MAN_WINBOND:
         s->needed_bytes += WINBOND_CONTINUOUS_READ_MODE_CMD_LEN;
         break;
+    case MAN_GIGADEVICE:
+        s->needed_bytes += GIGADEVICE_CONTINUOUS_READ_MODE_CMD_LEN;
+        break;
     case MAN_SPANSION:
         s->needed_bytes += SPANSION_CONTINUOUS_READ_MODE_CMD_LEN;
         s->needed_bytes += extract32(s->spansion_cr2v,
@@ -1042,6 +1049,10 @@ static void decode_qio_read_cmd(Flash *s)
         s->needed_bytes += WINBOND_CONTINUOUS_READ_MODE_CMD_LEN;
         s->needed_bytes += 4;
         break;
+    case MAN_GIGADEVICE:
+        s->needed_bytes += GIGADEVICE_CONTINUOUS_READ_MODE_CMD_LEN;
+        s->needed_bytes += 4;
+        break;
     case MAN_SPANSION:
         s->needed_bytes += SPANSION_CONTINUOUS_READ_MODE_CMD_LEN;
         s->needed_bytes += extract32(s->spansion_cr2v,
-- 
2.34.2

Reply via email to