qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/8] m25p80: Add SFDP support
@ 2022-07-22  6:35 Cédric Le Goater
  2022-07-22  6:35 ` [PATCH v3 1/8] m25p80: Add basic support for the SFDP command Cédric Le Goater
                   ` (9 more replies)
  0 siblings, 10 replies; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

Hello, 

This is a refresh of a patchset sent long ago [1] adding support for
JEDEC STANDARD JESD216 Serial Flash Discovery Parameters (SFDP). SFDP
describes the features of a serial flash device using a set of internal
parameter tables. Support in Linux has been added some time ago and
the spi-nor driver is using it more often to detect the flash settings
and even flash models.

Francisco and I are not entirely satisfied with the way the tables are
defined. We add some private discussion on how to resolve that but
neither of us had the time to pursue the study. Latest Francisco
proposal was : 

    #define define_sfdp_read_wrap(model, wrap_sz)            \
    uint8_t m25p80_sdfp_read_##model(SFDPTable t, uint32_t addr) \
    {                                                            \
         return m25p80_sdfp_read(t, addr & (wrap_sz-1));          \
    }
    ...
    define_sfdp_read_wrap(mt25ql512ab, SZ_256)
    
    A new variable in the section would solve it aswell but not convinced at the
    moment if it is clear enough:
    
    typedef struct SFDPSection {
         const uint32_t addr;
         const uint32_t size;
         const uint32_t wrap_sz;
         const uint8_t *data;
    } SFDPSection;
    
    #define SFDP_RAW(start_addr, vals...) \
    {                                     \
       .addr = start_addr,                 \
       .size = sizeof((uint8_t[]){vals}),  \
       .data = (const uint8_t[]){vals}     \
    }
    
    #define SFDP_RAW_WRAP(start_addr, _wrap_sz, vals...) \
    {                                     \
       .addr = start_addr,                 \
       .size = sizeof((uint8_t[]){vals}),  \
       .wrap_sz = _wrap_sz,                \
       .data = (const uint8_t[]){vals}     \
    }
    
    #define SFDP_TABLE_END() { 0 }
    #define IS_SFDP_END(x) (x.size == 0)
    
    #define M35T4545_WRAP_SZ 0x100
    
    static const SFDPTable m35t4545 = {
         SFDP_RAW_WRAP(0, M35T4545_WRAP_SZ,
                       0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff,
                       0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff),
    
         SFDP_RAW(0x38,
                  0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x0f,
                  0x29, 0xeb, 0x27, 0x6b, 0x08, 0x3b, 0x27, 0xbb,
                  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x27, 0xbb,
                  0xff, 0xff, 0x29, 0xeb, 0x0c, 0x20, 0x10, 0xd8,
                  0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff),
    
         SFDP_TABLE_END()
    };
    
    uint8_t m25p80_sfdp_read(SFDPTable t, uint32_t addr)
    {
         if (t[0].wrap_sz) {
             addr &= (t.wrap_sz-1);
         }
    
         for (int i = 0; !IS_SFDP_END(t[i]); i++) {
             if (addr >= t[i].addr && addr < (t[i].addr + t[i].size)) {
                 return t[i].data[addr];
             }
         }
         return 0xFF;
    }

Since there is a need, we have been using these patches in OpenBMC for
some time now and other projects/companies have requested it, I am
resending the patchset as it is to restart the discussion.

Thanks,

C.

Cédric Le Goater (8):
  m25p80: Add basic support for the SFDP command
  m25p80: Add the n25q256a SFDP table
  m25p80: Add the mx25l25635e SFPD table
  m25p80: Add the mx25l25635f SFPD table
  m25p80: Add the mx66l1g45g SFDP table
  m25p80: Add the w25q256 SFPD table
  m25p80: Add the w25q512jv SFPD table
  arm/aspeed: Replace mx25l25635e chip model

 hw/block/m25p80_sfdp.h |  27 ++++
 hw/arm/aspeed.c        |   6 +-
 hw/block/m25p80.c      |  49 ++++++-
 hw/block/m25p80_sfdp.c | 296 +++++++++++++++++++++++++++++++++++++++++
 MAINTAINERS            |   2 +-
 hw/block/meson.build   |   1 +
 hw/block/trace-events  |   1 +
 7 files changed, 371 insertions(+), 11 deletions(-)
 create mode 100644 hw/block/m25p80_sfdp.h
 create mode 100644 hw/block/m25p80_sfdp.c

-- 
2.35.3



^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v3 1/8] m25p80: Add basic support for the SFDP command
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
@ 2022-07-22  6:35 ` Cédric Le Goater
  2022-07-22 10:02   ` Francisco Iglesias
  2022-07-22  6:35 ` [PATCH v3 2/8] m25p80: Add the n25q256a SFDP table Cédric Le Goater
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

JEDEC STANDARD JESD216 for Serial Flash Discovery Parameters (SFDP)
provides a mean to describe the features of a serial flash device
using a set of internal parameter tables.

This is the initial framework for the RDSFDP command giving access to
a private SFDP area under the flash. This area now needs to be
populated with the flash device characteristics, using a new
'sfdp_read' handler under FlashPartInfo.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/block/m25p80_sfdp.h | 18 ++++++++++++++++++
 hw/block/m25p80.c      | 27 +++++++++++++++++++++++++++
 MAINTAINERS            |  2 +-
 hw/block/trace-events  |  1 +
 4 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 hw/block/m25p80_sfdp.h

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
new file mode 100644
index 000000000000..230b07ef3308
--- /dev/null
+++ b/hw/block/m25p80_sfdp.h
@@ -0,0 +1,18 @@
+/*
+ * M25P80 SFDP
+ *
+ * Copyright (c) 2020, IBM Corporation.
+ *
+ * This code is licensed under the GPL version 2 or later. See the
+ * COPYING file in the top-level directory.
+ */
+
+#ifndef HW_M25P80_SFDP_H
+#define HW_M25P80_SFDP_H
+
+/*
+ * SFDP area has a 3 bytes address space.
+ */
+#define M25P80_SFDP_MAX_SIZE  (1 << 24)
+
+#endif
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index a8d2519141f7..abdc4c0b0da7 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -35,6 +35,7 @@
 #include "qapi/error.h"
 #include "trace.h"
 #include "qom/object.h"
+#include "m25p80_sfdp.h"
 
 /* 16 MiB max in 3 byte address mode */
 #define MAX_3BYTES_SIZE 0x1000000
@@ -72,6 +73,7 @@ typedef struct FlashPartInfo {
      * This field inform how many die is in the chip.
      */
     uint8_t die_cnt;
+    uint8_t (*sfdp_read)(uint32_t sfdp_addr);
 } FlashPartInfo;
 
 /* adapted from linux */
@@ -355,6 +357,7 @@ typedef enum {
     BULK_ERASE = 0xc7,
     READ_FSR = 0x70,
     RDCR = 0x15,
+    RDSFDP = 0x5a,
 
     READ = 0x03,
     READ4 = 0x13,
@@ -421,6 +424,7 @@ typedef enum {
     STATE_COLLECTING_DATA,
     STATE_COLLECTING_VAR_LEN_DATA,
     STATE_READING_DATA,
+    STATE_READING_SFDP,
 } CMDState;
 
 typedef enum {
@@ -679,6 +683,8 @@ static inline int get_addr_length(Flash *s)
     }
 
    switch (s->cmd_in_progress) {
+   case RDSFDP:
+       return 3;
    case PP4:
    case PP4_4:
    case QPP_4:
@@ -823,6 +829,11 @@ static void complete_collecting_data(Flash *s)
                           " by device\n");
         }
         break;
+
+    case RDSFDP:
+        s->state = STATE_READING_SFDP;
+        break;
+
     default:
         break;
     }
@@ -1431,6 +1442,16 @@ static void decode_new_cmd(Flash *s, uint32_t value)
             qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value);
         }
         break;
+    case RDSFDP:
+        if (s->pi->sfdp_read) {
+            s->needed_bytes = get_addr_length(s) + 1; /* SFDP addr + dummy */
+            s->pos = 0;
+            s->len = 0;
+            s->state = STATE_COLLECTING_DATA;
+            break;
+        }
+        /* Fallthrough */
+
     default:
         s->pos = 0;
         s->len = 1;
@@ -1538,6 +1559,12 @@ static uint32_t m25p80_transfer8(SSIPeripheral *ss, uint32_t tx)
             }
         }
         break;
+    case STATE_READING_SFDP:
+        assert(s->pi->sfdp_read);
+        r = s->pi->sfdp_read(s->cur_addr);
+        trace_m25p80_read_sfdp(s, s->cur_addr, (uint8_t)r);
+        s->cur_addr = (s->cur_addr + 1) & (M25P80_SFDP_MAX_SIZE - 1);
+        break;
 
     default:
     case STATE_IDLE:
diff --git a/MAINTAINERS b/MAINTAINERS
index 6af9cd985cea..92f232f01e3c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1915,7 +1915,7 @@ SSI
 M: Alistair Francis <alistair@alistair23.me>
 S: Maintained
 F: hw/ssi/*
-F: hw/block/m25p80.c
+F: hw/block/m25p80*
 F: include/hw/ssi/ssi.h
 X: hw/ssi/xilinx_*
 F: tests/qtest/m25p80-test.c
diff --git a/hw/block/trace-events b/hw/block/trace-events
index d86b53520cc5..2c45a62bd59c 100644
--- a/hw/block/trace-events
+++ b/hw/block/trace-events
@@ -80,5 +80,6 @@ m25p80_page_program(void *s, uint32_t addr, uint8_t tx) "[%p] page program cur_a
 m25p80_transfer(void *s, uint8_t state, uint32_t len, uint8_t needed, uint32_t pos, uint32_t cur_addr, uint8_t t) "[%p] Transfer state 0x%"PRIx8" len 0x%"PRIx32" needed 0x%"PRIx8" pos 0x%"PRIx32" addr 0x%"PRIx32" tx 0x%"PRIx8
 m25p80_read_byte(void *s, uint32_t addr, uint8_t v) "[%p] Read byte 0x%"PRIx32"=0x%"PRIx8
 m25p80_read_data(void *s, uint32_t pos, uint8_t v) "[%p] Read data 0x%"PRIx32"=0x%"PRIx8
+m25p80_read_sfdp(void *s, uint32_t addr, uint8_t v) "[%p] Read SFDP 0x%"PRIx32"=0x%"PRIx8
 m25p80_binding(void *s) "[%p] Binding to IF_MTD drive"
 m25p80_binding_no_bdrv(void *s) "[%p] No BDRV - binding to RAM"
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 2/8] m25p80: Add the n25q256a SFDP table
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
  2022-07-22  6:35 ` [PATCH v3 1/8] m25p80: Add basic support for the SFDP command Cédric Le Goater
@ 2022-07-22  6:35 ` Cédric Le Goater
  2022-10-07 14:03   ` Francisco Iglesias
  2022-07-22  6:35 ` [PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

The same values were collected on 4 differents OpenPower systems,
palmettos, romulus and tacoma.

The SFDP table size is defined as being 0x100 bytes but it could be
bigger. Only the mandatory table for basic features is available at
byte 0x30.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/block/m25p80_sfdp.h |  2 ++
 hw/block/m25p80.c      |  8 +++---
 hw/block/m25p80_sfdp.c | 58 ++++++++++++++++++++++++++++++++++++++++++
 hw/block/meson.build   |  1 +
 4 files changed, 66 insertions(+), 3 deletions(-)
 create mode 100644 hw/block/m25p80_sfdp.c

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
index 230b07ef3308..d3a0a778ae84 100644
--- a/hw/block/m25p80_sfdp.h
+++ b/hw/block/m25p80_sfdp.h
@@ -15,4 +15,6 @@
  */
 #define M25P80_SFDP_MAX_SIZE  (1 << 24)
 
+extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
+
 #endif
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index abdc4c0b0da7..13e7b28fd2b0 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -247,13 +247,15 @@ static const FlashPartInfo known_devices[] = {
     { INFO("n25q128a11",  0x20bb18,      0,  64 << 10, 256, ER_4K) },
     { INFO("n25q128a13",  0x20ba18,      0,  64 << 10, 256, ER_4K) },
     { INFO("n25q256a11",  0x20bb19,      0,  64 << 10, 512, ER_4K) },
-    { INFO("n25q256a13",  0x20ba19,      0,  64 << 10, 512, ER_4K) },
+    { INFO("n25q256a13",  0x20ba19,      0,  64 << 10, 512, ER_4K),
+      .sfdp_read = m25p80_sfdp_n25q256a },
     { INFO("n25q512a11",  0x20bb20,      0,  64 << 10, 1024, ER_4K) },
     { INFO("n25q512a13",  0x20ba20,      0,  64 << 10, 1024, ER_4K) },
     { INFO("n25q128",     0x20ba18,      0,  64 << 10, 256, 0) },
     { INFO("n25q256a",    0x20ba19,      0,  64 << 10, 512,
-           ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB) },
-    { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
+           ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB),
+      .sfdp_read = m25p80_sfdp_n25q256a },
+   { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
     { INFO("n25q512ax3",  0x20ba20,  0x1000,  64 << 10, 1024, ER_4K) },
     { INFO("mt25ql512ab", 0x20ba20, 0x1044, 64 << 10, 1024, ER_4K | ER_32K) },
     { INFO_STACKED("mt35xu01g", 0x2c5b1b, 0x104100, 128 << 10, 1024,
diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
new file mode 100644
index 000000000000..24ec05de79a1
--- /dev/null
+++ b/hw/block/m25p80_sfdp.c
@@ -0,0 +1,58 @@
+/*
+ * M25P80 Serial Flash Discoverable Parameter (SFDP)
+ *
+ * Copyright (c) 2020, IBM Corporation.
+ *
+ * This code is licensed under the GPL version 2 or later. See the
+ * COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/host-utils.h"
+#include "m25p80_sfdp.h"
+
+#define define_sfdp_read(model)                                       \
+    uint8_t m25p80_sfdp_##model(uint32_t addr)                        \
+    {                                                                 \
+        assert(is_power_of_2(sizeof(sfdp_##model)));                  \
+        return sfdp_##model[addr & (sizeof(sfdp_##model) - 1)];       \
+    }
+
+/*
+ * Micron
+ */
+static const uint8_t sfdp_n25q256a[] = {
+    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff,
+    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x0f,
+    0x29, 0xeb, 0x27, 0x6b, 0x08, 0x3b, 0x27, 0xbb,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x27, 0xbb,
+    0xff, 0xff, 0x29, 0xeb, 0x0c, 0x20, 0x10, 0xd8,
+    0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+define_sfdp_read(n25q256a);
diff --git a/hw/block/meson.build b/hw/block/meson.build
index 2389326112ae..3129ca4c52eb 100644
--- a/hw/block/meson.build
+++ b/hw/block/meson.build
@@ -12,6 +12,7 @@ softmmu_ss.add(when: 'CONFIG_ONENAND', if_true: files('onenand.c'))
 softmmu_ss.add(when: 'CONFIG_PFLASH_CFI01', if_true: files('pflash_cfi01.c'))
 softmmu_ss.add(when: 'CONFIG_PFLASH_CFI02', if_true: files('pflash_cfi02.c'))
 softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80.c'))
+softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80_sfdp.c'))
 softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c'))
 softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
 softmmu_ss.add(when: 'CONFIG_TC58128', if_true: files('tc58128.c'))
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
  2022-07-22  6:35 ` [PATCH v3 1/8] m25p80: Add basic support for the SFDP command Cédric Le Goater
  2022-07-22  6:35 ` [PATCH v3 2/8] m25p80: Add the n25q256a SFDP table Cédric Le Goater
@ 2022-07-22  6:35 ` Cédric Le Goater
  2022-10-07 13:59   ` Francisco Iglesias
  2022-07-22  6:35 ` [PATCH v3 4/8] m25p80: Add the mx25l25635f " Cédric Le Goater
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

The SFDP table is 0x80 bytes long. The mandatory table for basic
features is available at byte 0x30 and an extra Macronix specific
table is available at 0x60.

4B opcodes are not supported.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/block/m25p80_sfdp.h |  3 +++
 hw/block/m25p80.c      |  3 ++-
 hw/block/m25p80_sfdp.c | 26 ++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
index d3a0a778ae84..0c46e669b335 100644
--- a/hw/block/m25p80_sfdp.h
+++ b/hw/block/m25p80_sfdp.h
@@ -17,4 +17,7 @@
 
 extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
 
+extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
+
+
 #endif
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 13e7b28fd2b0..028b026d8ba2 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -232,7 +232,8 @@ static const FlashPartInfo known_devices[] = {
     { INFO("mx25l6405d",  0xc22017,      0,  64 << 10, 128, 0) },
     { INFO("mx25l12805d", 0xc22018,      0,  64 << 10, 256, 0) },
     { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
-    { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0) },
+    { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0),
+      .sfdp_read = m25p80_sfdp_mx25l25635e },
     { INFO("mx25l25655e", 0xc22619,      0,  64 << 10, 512, 0) },
     { INFO("mx66l51235f", 0xc2201a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
     { INFO("mx66u51235f", 0xc2253a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
index 24ec05de79a1..6499c4c39954 100644
--- a/hw/block/m25p80_sfdp.c
+++ b/hw/block/m25p80_sfdp.c
@@ -56,3 +56,29 @@ static const uint8_t sfdp_n25q256a[] = {
     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 };
 define_sfdp_read(n25q256a);
+
+
+/*
+ * Matronix
+ */
+
+/* mx25l25635e. No 4B opcodes */
+static const uint8_t sfdp_mx25l25635e[] = {
+    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff,
+    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
+    0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f,
+    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb,
+    0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
+    0xff, 0xff, 0x00, 0xff, 0x0c, 0x20, 0x0f, 0x52,
+    0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0x00, 0x36, 0x00, 0x27, 0xf7, 0x4f, 0xff, 0xff,
+    0xd9, 0xc8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+define_sfdp_read(mx25l25635e)
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 4/8] m25p80: Add the mx25l25635f SFPD table
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
                   ` (2 preceding siblings ...)
  2022-07-22  6:35 ` [PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
@ 2022-07-22  6:35 ` Cédric Le Goater
  2022-10-07 14:44   ` Francisco Iglesias
  2022-07-22  6:35 ` [PATCH v3 5/8] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

The mx25l25635e and mx25l25635f chips have the same JEDEC id but the
mx25l25635f has more capabilities reported in the SFDP table. Support
for 4B opcodes is of interest because it is exploited by the Linux
kernel.

The SFDP table size is 0x200 bytes long. The mandatory table for basic
features is available at byte 0x30 and an extra Macronix specific
table is available at 0x60.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/block/m25p80_sfdp.h |  1 +
 hw/block/m25p80.c      |  2 ++
 hw/block/m25p80_sfdp.c | 68 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
index 0c46e669b335..87690a173c78 100644
--- a/hw/block/m25p80_sfdp.h
+++ b/hw/block/m25p80_sfdp.h
@@ -18,6 +18,7 @@
 extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
 
 extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
+extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
 
 
 #endif
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 028b026d8ba2..6b120ce65212 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -234,6 +234,8 @@ static const FlashPartInfo known_devices[] = {
     { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
     { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0),
       .sfdp_read = m25p80_sfdp_mx25l25635e },
+    { INFO6("mx25l25635f", 0xc22019,     0xc22019,  64 << 10, 512, 0),
+      .sfdp_read = m25p80_sfdp_mx25l25635f },
     { INFO("mx25l25655e", 0xc22619,      0,  64 << 10, 512, 0) },
     { INFO("mx66l51235f", 0xc2201a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
     { INFO("mx66u51235f", 0xc2253a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
index 6499c4c39954..70c13aea7c63 100644
--- a/hw/block/m25p80_sfdp.c
+++ b/hw/block/m25p80_sfdp.c
@@ -82,3 +82,71 @@ static const uint8_t sfdp_mx25l25635e[] = {
     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 };
 define_sfdp_read(mx25l25635e)
+
+static const uint8_t sfdp_mx25l25635f[] = {
+    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff,
+    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
+    0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f,
+    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb,
+    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
+    0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
+    0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64,
+    0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xc2, 0xf5, 0x08, 0x0a,
+    0x08, 0x04, 0x03, 0x06, 0x00, 0x00, 0x07, 0x29,
+    0x17, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+define_sfdp_read(mx25l25635f);
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 5/8] m25p80: Add the mx66l1g45g SFDP table
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
                   ` (3 preceding siblings ...)
  2022-07-22  6:35 ` [PATCH v3 4/8] m25p80: Add the mx25l25635f " Cédric Le Goater
@ 2022-07-22  6:35 ` Cédric Le Goater
  2022-10-07 14:59   ` Francisco Iglesias
  2022-07-22  6:36 ` [PATCH v3 6/8] m25p80: Add the w25q256 SFPD table Cédric Le Goater
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

The SFDP table size is 0x200 bytes long. The mandatory table for basic
features is available at byte 0x30 plus some more Macronix specific
tables.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/block/m25p80_sfdp.h |  2 +-
 hw/block/m25p80.c      |  3 +-
 hw/block/m25p80_sfdp.c | 68 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
index 87690a173c78..468e3434151b 100644
--- a/hw/block/m25p80_sfdp.h
+++ b/hw/block/m25p80_sfdp.h
@@ -19,6 +19,6 @@ extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
 
 extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
 extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
-
+extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr);
 
 #endif
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 6b120ce65212..52df24d24751 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -240,7 +240,8 @@ static const FlashPartInfo known_devices[] = {
     { INFO("mx66l51235f", 0xc2201a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
     { INFO("mx66u51235f", 0xc2253a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
     { INFO("mx66u1g45g",  0xc2253b,      0,  64 << 10, 2048, ER_4K | ER_32K) },
-    { INFO("mx66l1g45g",  0xc2201b,      0,  64 << 10, 2048, ER_4K | ER_32K) },
+    { INFO("mx66l1g45g",  0xc2201b,      0,  64 << 10, 2048, ER_4K | ER_32K),
+      .sfdp_read = m25p80_sfdp_mx66l1g45g },
 
     /* Micron */
     { INFO("n25q032a11",  0x20bb16,      0,  64 << 10,  64, ER_4K) },
diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
index 70c13aea7c63..38c3ced34d2e 100644
--- a/hw/block/m25p80_sfdp.c
+++ b/hw/block/m25p80_sfdp.c
@@ -150,3 +150,71 @@ static const uint8_t sfdp_mx25l25635f[] = {
     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 };
 define_sfdp_read(mx25l25635f);
+
+static const uint8_t sfdp_mx66l1g45g[] = {
+    0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x02, 0xff,
+    0x00, 0x06, 0x01, 0x10, 0x30, 0x00, 0x00, 0xff,
+    0xc2, 0x00, 0x01, 0x04, 0x10, 0x01, 0x00, 0xff,
+    0x84, 0x00, 0x01, 0x02, 0xc0, 0x00, 0x00, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x3f,
+    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb,
+    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
+    0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
+    0x10, 0xd8, 0x00, 0xff, 0xd6, 0x49, 0xc5, 0x00,
+    0x85, 0xdf, 0x04, 0xe3, 0x44, 0x03, 0x67, 0x38,
+    0x30, 0xb0, 0x30, 0xb0, 0xf7, 0xbd, 0xd5, 0x5c,
+    0x4a, 0x9e, 0x29, 0xff, 0xf0, 0x50, 0xf9, 0x85,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0x7f, 0xef, 0xff, 0xff, 0x21, 0x5c, 0xdc, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64,
+    0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xc2, 0xf5, 0x08, 0x00, 0x0c, 0x04, 0x08, 0x08,
+    0x01, 0x00, 0x19, 0x0f, 0x01, 0x01, 0x06, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+define_sfdp_read(mx66l1g45g);
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 6/8] m25p80: Add the w25q256 SFPD table
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
                   ` (4 preceding siblings ...)
  2022-07-22  6:35 ` [PATCH v3 5/8] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
@ 2022-07-22  6:36 ` Cédric Le Goater
  2022-10-07 15:13   ` Francisco Iglesias
  2022-07-22  6:36 ` [PATCH v3 7/8] m25p80: Add the w25q512jv " Cédric Le Goater
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

The SFDP table size is 0x100 bytes long. Only the mandatory table for
basic features is available at byte 0x80.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/block/m25p80_sfdp.h |  2 ++
 hw/block/m25p80.c      |  3 ++-
 hw/block/m25p80_sfdp.c | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
index 468e3434151b..f60429ab8542 100644
--- a/hw/block/m25p80_sfdp.h
+++ b/hw/block/m25p80_sfdp.h
@@ -21,4 +21,6 @@ extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
 extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
 extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr);
 
+extern uint8_t m25p80_sfdp_w25q256(uint32_t addr);
+
 #endif
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 52df24d24751..220dbc8fb327 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -345,7 +345,8 @@ static const FlashPartInfo known_devices[] = {
     { INFO("w25q64",      0xef4017,      0,  64 << 10, 128, ER_4K) },
     { INFO("w25q80",      0xef5014,      0,  64 << 10,  16, ER_4K) },
     { INFO("w25q80bl",    0xef4014,      0,  64 << 10,  16, ER_4K) },
-    { INFO("w25q256",     0xef4019,      0,  64 << 10, 512, ER_4K) },
+    { INFO("w25q256",     0xef4019,      0,  64 << 10, 512, ER_4K),
+      .sfdp_read = m25p80_sfdp_w25q256 },
     { INFO("w25q512jv",   0xef4020,      0,  64 << 10, 1024, ER_4K) },
     { INFO("w25q01jvq",   0xef4021,      0,  64 << 10, 2048, ER_4K) },
 };
diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
index 38c3ced34d2e..5b011559d43d 100644
--- a/hw/block/m25p80_sfdp.c
+++ b/hw/block/m25p80_sfdp.c
@@ -218,3 +218,43 @@ static const uint8_t sfdp_mx66l1g45g[] = {
     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 };
 define_sfdp_read(mx66l1g45g);
+
+/*
+ * Windbond
+ */
+
+static const uint8_t sfdp_w25q256[] = {
+    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff,
+    0x00, 0x00, 0x01, 0x09, 0x80, 0x00, 0x00, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f,
+    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb,
+    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+    0xff, 0xff, 0x21, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
+    0x10, 0xd8, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+define_sfdp_read(w25q256);
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 7/8] m25p80: Add the w25q512jv SFPD table
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
                   ` (5 preceding siblings ...)
  2022-07-22  6:36 ` [PATCH v3 6/8] m25p80: Add the w25q256 SFPD table Cédric Le Goater
@ 2022-07-22  6:36 ` Cédric Le Goater
  2022-10-07 15:14   ` Francisco Iglesias
  2022-07-22  6:36 ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

The SFDP table size is 0x100 bytes long. The mandatory table for basic
features is available at byte 0x80 and two extra Winbond specifics
table are available at 0xC0 and 0xF0.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/block/m25p80_sfdp.h |  1 +
 hw/block/m25p80.c      |  3 ++-
 hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
index f60429ab8542..62f140a2fcef 100644
--- a/hw/block/m25p80_sfdp.h
+++ b/hw/block/m25p80_sfdp.h
@@ -22,5 +22,6 @@ extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
 extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr);
 
 extern uint8_t m25p80_sfdp_w25q256(uint32_t addr);
+extern uint8_t m25p80_sfdp_w25q512jv(uint32_t addr);
 
 #endif
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 220dbc8fb327..8ba9d732a323 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -347,7 +347,8 @@ static const FlashPartInfo known_devices[] = {
     { INFO("w25q80bl",    0xef4014,      0,  64 << 10,  16, ER_4K) },
     { INFO("w25q256",     0xef4019,      0,  64 << 10, 512, ER_4K),
       .sfdp_read = m25p80_sfdp_w25q256 },
-    { INFO("w25q512jv",   0xef4020,      0,  64 << 10, 1024, ER_4K) },
+    { INFO("w25q512jv",   0xef4020,      0,  64 << 10, 1024, ER_4K),
+      .sfdp_read = m25p80_sfdp_w25q512jv },
     { INFO("w25q01jvq",   0xef4021,      0,  64 << 10, 2048, ER_4K) },
 };
 
diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
index 5b011559d43d..dad3d7e64f9f 100644
--- a/hw/block/m25p80_sfdp.c
+++ b/hw/block/m25p80_sfdp.c
@@ -258,3 +258,39 @@ static const uint8_t sfdp_w25q256[] = {
     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 };
 define_sfdp_read(w25q256);
+
+static const uint8_t sfdp_w25q512jv[] = {
+    0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x01, 0xff,
+    0x00, 0x06, 0x01, 0x10, 0x80, 0x00, 0x00, 0xff,
+    0x84, 0x00, 0x01, 0x02, 0xd0, 0x00, 0x00, 0xff,
+    0x03, 0x00, 0x01, 0x02, 0xf0, 0x00, 0x00, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x1f,
+    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb,
+    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+    0xff, 0xff, 0x40, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
+    0x10, 0xd8, 0x00, 0x00, 0x36, 0x02, 0xa6, 0x00,
+    0x82, 0xea, 0x14, 0xe2, 0xe9, 0x63, 0x76, 0x33,
+    0x7a, 0x75, 0x7a, 0x75, 0xf7, 0xa2, 0xd5, 0x5c,
+    0x19, 0xf7, 0x4d, 0xff, 0xe9, 0x70, 0xf9, 0xa5,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0x0a, 0xf0, 0xff, 0x21, 0xff, 0xdc, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+define_sfdp_read(w25q512jv);
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
                   ` (6 preceding siblings ...)
  2022-07-22  6:36 ` [PATCH v3 7/8] m25p80: Add the w25q512jv " Cédric Le Goater
@ 2022-07-22  6:36 ` Cédric Le Goater
  2022-07-25  2:08   ` Andrew Jeffery
                     ` (2 more replies)
  2022-07-22  7:05 ` [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
  2022-10-06 22:49 ` Patrick Williams
  9 siblings, 3 replies; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  6:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, Cédric Le Goater

A mx25l25635f chip model is generally found on these machines. It's
newer and uses 4B opcodes which is better to exercise the support in
the Linux kernel.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/arm/aspeed.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 1c611284819d..7e95abc55b09 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -1157,7 +1157,7 @@ static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
     amc->soc_name  = "ast2400-a1";
     amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1;
     amc->fmc_model = "n25q256a";
-    amc->spi_model = "mx25l25635e";
+    amc->spi_model = "mx25l25635f";
     amc->num_cs    = 1;
     amc->i2c_init  = palmetto_bmc_i2c_init;
     mc->default_ram_size       = 256 * MiB;
@@ -1208,7 +1208,7 @@ static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data)
     amc->soc_name  = "ast2500-a1";
     amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
     amc->fmc_model = "mx25l25635e";
-    amc->spi_model = "mx25l25635e";
+    amc->spi_model = "mx25l25635f";
     amc->num_cs    = 1;
     amc->i2c_init  = ast2500_evb_i2c_init;
     mc->default_ram_size       = 512 * MiB;
@@ -1258,7 +1258,7 @@ static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data)
     mc->desc       = "OpenPOWER Witherspoon BMC (ARM1176)";
     amc->soc_name  = "ast2500-a1";
     amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1;
-    amc->fmc_model = "mx25l25635e";
+    amc->fmc_model = "mx25l25635f";
     amc->spi_model = "mx66l1g45g";
     amc->num_cs    = 2;
     amc->i2c_init  = witherspoon_bmc_i2c_init;
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 0/8] m25p80: Add SFDP support
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
                   ` (7 preceding siblings ...)
  2022-07-22  6:36 ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
@ 2022-07-22  7:05 ` Cédric Le Goater
  2022-07-22  8:06   ` Ben Dooks
  2022-10-06 22:49 ` Patrick Williams
  9 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  7:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle

On 7/22/22 08:35, Cédric Le Goater wrote:
> Hello,
> 
> This is a refresh of a patchset sent long ago [1] adding support for

[1] was lost while writing the cover :

   https://lore.kernel.org/qemu-devel/20200902093107.608000-1-clg@kaod.org/

C.

> JEDEC STANDARD JESD216 Serial Flash Discovery Parameters (SFDP). SFDP
> describes the features of a serial flash device using a set of internal
> parameter tables. Support in Linux has been added some time ago and
> the spi-nor driver is using it more often to detect the flash settings
> and even flash models.
> 
> Francisco and I are not entirely satisfied with the way the tables are
> defined. We add some private discussion on how to resolve that but
> neither of us had the time to pursue the study. Latest Francisco
> proposal was :
> 
>      #define define_sfdp_read_wrap(model, wrap_sz)            \
>      uint8_t m25p80_sdfp_read_##model(SFDPTable t, uint32_t addr) \
>      {                                                            \
>           return m25p80_sdfp_read(t, addr & (wrap_sz-1));          \
>      }
>      ...
>      define_sfdp_read_wrap(mt25ql512ab, SZ_256)
>      
>      A new variable in the section would solve it aswell but not convinced at the
>      moment if it is clear enough:
>      
>      typedef struct SFDPSection {
>           const uint32_t addr;
>           const uint32_t size;
>           const uint32_t wrap_sz;
>           const uint8_t *data;
>      } SFDPSection;
>      
>      #define SFDP_RAW(start_addr, vals...) \
>      {                                     \
>         .addr = start_addr,                 \
>         .size = sizeof((uint8_t[]){vals}),  \
>         .data = (const uint8_t[]){vals}     \
>      }
>      
>      #define SFDP_RAW_WRAP(start_addr, _wrap_sz, vals...) \
>      {                                     \
>         .addr = start_addr,                 \
>         .size = sizeof((uint8_t[]){vals}),  \
>         .wrap_sz = _wrap_sz,                \
>         .data = (const uint8_t[]){vals}     \
>      }
>      
>      #define SFDP_TABLE_END() { 0 }
>      #define IS_SFDP_END(x) (x.size == 0)
>      
>      #define M35T4545_WRAP_SZ 0x100
>      
>      static const SFDPTable m35t4545 = {
>           SFDP_RAW_WRAP(0, M35T4545_WRAP_SZ,
>                         0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff,
>                         0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff),
>      
>           SFDP_RAW(0x38,
>                    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x0f,
>                    0x29, 0xeb, 0x27, 0x6b, 0x08, 0x3b, 0x27, 0xbb,
>                    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x27, 0xbb,
>                    0xff, 0xff, 0x29, 0xeb, 0x0c, 0x20, 0x10, 0xd8,
>                    0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff),
>      
>           SFDP_TABLE_END()
>      };
>      
>      uint8_t m25p80_sfdp_read(SFDPTable t, uint32_t addr)
>      {
>           if (t[0].wrap_sz) {
>               addr &= (t.wrap_sz-1);
>           }
>      
>           for (int i = 0; !IS_SFDP_END(t[i]); i++) {
>               if (addr >= t[i].addr && addr < (t[i].addr + t[i].size)) {
>                   return t[i].data[addr];
>               }
>           }
>           return 0xFF;
>      }
> 
> Since there is a need, we have been using these patches in OpenBMC for
> some time now and other projects/companies have requested it, I am
> resending the patchset as it is to restart the discussion.
> 
> Thanks,
> 
> C.
> 
> Cédric Le Goater (8):
>    m25p80: Add basic support for the SFDP command
>    m25p80: Add the n25q256a SFDP table
>    m25p80: Add the mx25l25635e SFPD table
>    m25p80: Add the mx25l25635f SFPD table
>    m25p80: Add the mx66l1g45g SFDP table
>    m25p80: Add the w25q256 SFPD table
>    m25p80: Add the w25q512jv SFPD table
>    arm/aspeed: Replace mx25l25635e chip model
> 
>   hw/block/m25p80_sfdp.h |  27 ++++
>   hw/arm/aspeed.c        |   6 +-
>   hw/block/m25p80.c      |  49 ++++++-
>   hw/block/m25p80_sfdp.c | 296 +++++++++++++++++++++++++++++++++++++++++
>   MAINTAINERS            |   2 +-
>   hw/block/meson.build   |   1 +
>   hw/block/trace-events  |   1 +
>   7 files changed, 371 insertions(+), 11 deletions(-)
>   create mode 100644 hw/block/m25p80_sfdp.h
>   create mode 100644 hw/block/m25p80_sfdp.c
> 



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 0/8] m25p80: Add SFDP support
  2022-07-22  7:05 ` [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
@ 2022-07-22  8:06   ` Ben Dooks
  2022-07-22  8:14     ` Cédric Le Goater
  0 siblings, 1 reply; 33+ messages in thread
From: Ben Dooks @ 2022-07-22  8:06 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, sudip.mhukerjee, ben.dooks

On Fri, Jul 22, 2022 at 09:05:39AM +0200, Cédric Le Goater wrote:
> On 7/22/22 08:35, Cédric Le Goater wrote:
> > Hello,
> > 
> > This is a refresh of a patchset sent long ago [1] adding support for
> 
> [1] was lost while writing the cover :
> 
>   https://lore.kernel.org/qemu-devel/20200902093107.608000-1-clg@kaod.org/

Is there a git branch this could be pulled from to have a look at and
test on our setup?

-- 
Ben Dooks, ben@fluff.org, http://www.fluff.org/ben/

Large Hadron Colada: A large Pina Colada that makes the universe disappear.



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 0/8] m25p80: Add SFDP support
  2022-07-22  8:06   ` Ben Dooks
@ 2022-07-22  8:14     ` Cédric Le Goater
  0 siblings, 0 replies; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-22  8:14 UTC (permalink / raw)
  To: Ben Dooks
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle, sudip.mhukerjee, ben.dooks

On 7/22/22 10:06, Ben Dooks wrote:
> On Fri, Jul 22, 2022 at 09:05:39AM +0200, Cédric Le Goater wrote:
>> On 7/22/22 08:35, Cédric Le Goater wrote:
>>> Hello,
>>>
>>> This is a refresh of a patchset sent long ago [1] adding support for
>>
>> [1] was lost while writing the cover :
>>
>>    https://lore.kernel.org/qemu-devel/20200902093107.608000-1-clg@kaod.org/
> 
> Is there a git branch this could be pulled from to have a look at and
> test on our setup?

Yes,

   https://github.com/legoater/qemu/commits/aspeed-7.1

Thanks,

C.


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 1/8] m25p80: Add basic support for the SFDP command
  2022-07-22  6:35 ` [PATCH v3 1/8] m25p80: Add basic support for the SFDP command Cédric Le Goater
@ 2022-07-22 10:02   ` Francisco Iglesias
  0 siblings, 0 replies; 33+ messages in thread
From: Francisco Iglesias @ 2022-07-22 10:02 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On [2022 Jul 22] Fri 08:35:55, Cédric Le Goater wrote:
> JEDEC STANDARD JESD216 for Serial Flash Discovery Parameters (SFDP)
> provides a mean to describe the features of a serial flash device
> using a set of internal parameter tables.
> 
> This is the initial framework for the RDSFDP command giving access to
> a private SFDP area under the flash. This area now needs to be
> populated with the flash device characteristics, using a new
> 'sfdp_read' handler under FlashPartInfo.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

> ---
>  hw/block/m25p80_sfdp.h | 18 ++++++++++++++++++
>  hw/block/m25p80.c      | 27 +++++++++++++++++++++++++++
>  MAINTAINERS            |  2 +-
>  hw/block/trace-events  |  1 +
>  4 files changed, 47 insertions(+), 1 deletion(-)
>  create mode 100644 hw/block/m25p80_sfdp.h
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> new file mode 100644
> index 000000000000..230b07ef3308
> --- /dev/null
> +++ b/hw/block/m25p80_sfdp.h
> @@ -0,0 +1,18 @@
> +/*
> + * M25P80 SFDP
> + *
> + * Copyright (c) 2020, IBM Corporation.
> + *
> + * This code is licensed under the GPL version 2 or later. See the
> + * COPYING file in the top-level directory.
> + */
> +
> +#ifndef HW_M25P80_SFDP_H
> +#define HW_M25P80_SFDP_H
> +
> +/*
> + * SFDP area has a 3 bytes address space.
> + */
> +#define M25P80_SFDP_MAX_SIZE  (1 << 24)
> +
> +#endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index a8d2519141f7..abdc4c0b0da7 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -35,6 +35,7 @@
>  #include "qapi/error.h"
>  #include "trace.h"
>  #include "qom/object.h"
> +#include "m25p80_sfdp.h"
>  
>  /* 16 MiB max in 3 byte address mode */
>  #define MAX_3BYTES_SIZE 0x1000000
> @@ -72,6 +73,7 @@ typedef struct FlashPartInfo {
>       * This field inform how many die is in the chip.
>       */
>      uint8_t die_cnt;
> +    uint8_t (*sfdp_read)(uint32_t sfdp_addr);
>  } FlashPartInfo;
>  
>  /* adapted from linux */
> @@ -355,6 +357,7 @@ typedef enum {
>      BULK_ERASE = 0xc7,
>      READ_FSR = 0x70,
>      RDCR = 0x15,
> +    RDSFDP = 0x5a,
>  
>      READ = 0x03,
>      READ4 = 0x13,
> @@ -421,6 +424,7 @@ typedef enum {
>      STATE_COLLECTING_DATA,
>      STATE_COLLECTING_VAR_LEN_DATA,
>      STATE_READING_DATA,
> +    STATE_READING_SFDP,
>  } CMDState;
>  
>  typedef enum {
> @@ -679,6 +683,8 @@ static inline int get_addr_length(Flash *s)
>      }
>  
>     switch (s->cmd_in_progress) {
> +   case RDSFDP:
> +       return 3;
>     case PP4:
>     case PP4_4:
>     case QPP_4:
> @@ -823,6 +829,11 @@ static void complete_collecting_data(Flash *s)
>                            " by device\n");
>          }
>          break;
> +
> +    case RDSFDP:
> +        s->state = STATE_READING_SFDP;
> +        break;
> +
>      default:
>          break;
>      }
> @@ -1431,6 +1442,16 @@ static void decode_new_cmd(Flash *s, uint32_t value)
>              qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value);
>          }
>          break;
> +    case RDSFDP:
> +        if (s->pi->sfdp_read) {
> +            s->needed_bytes = get_addr_length(s) + 1; /* SFDP addr + dummy */
> +            s->pos = 0;
> +            s->len = 0;
> +            s->state = STATE_COLLECTING_DATA;
> +            break;
> +        }
> +        /* Fallthrough */
> +
>      default:
>          s->pos = 0;
>          s->len = 1;
> @@ -1538,6 +1559,12 @@ static uint32_t m25p80_transfer8(SSIPeripheral *ss, uint32_t tx)
>              }
>          }
>          break;
> +    case STATE_READING_SFDP:
> +        assert(s->pi->sfdp_read);
> +        r = s->pi->sfdp_read(s->cur_addr);
> +        trace_m25p80_read_sfdp(s, s->cur_addr, (uint8_t)r);
> +        s->cur_addr = (s->cur_addr + 1) & (M25P80_SFDP_MAX_SIZE - 1);
> +        break;
>  
>      default:
>      case STATE_IDLE:
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6af9cd985cea..92f232f01e3c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1915,7 +1915,7 @@ SSI
>  M: Alistair Francis <alistair@alistair23.me>
>  S: Maintained
>  F: hw/ssi/*
> -F: hw/block/m25p80.c
> +F: hw/block/m25p80*
>  F: include/hw/ssi/ssi.h
>  X: hw/ssi/xilinx_*
>  F: tests/qtest/m25p80-test.c
> diff --git a/hw/block/trace-events b/hw/block/trace-events
> index d86b53520cc5..2c45a62bd59c 100644
> --- a/hw/block/trace-events
> +++ b/hw/block/trace-events
> @@ -80,5 +80,6 @@ m25p80_page_program(void *s, uint32_t addr, uint8_t tx) "[%p] page program cur_a
>  m25p80_transfer(void *s, uint8_t state, uint32_t len, uint8_t needed, uint32_t pos, uint32_t cur_addr, uint8_t t) "[%p] Transfer state 0x%"PRIx8" len 0x%"PRIx32" needed 0x%"PRIx8" pos 0x%"PRIx32" addr 0x%"PRIx32" tx 0x%"PRIx8
>  m25p80_read_byte(void *s, uint32_t addr, uint8_t v) "[%p] Read byte 0x%"PRIx32"=0x%"PRIx8
>  m25p80_read_data(void *s, uint32_t pos, uint8_t v) "[%p] Read data 0x%"PRIx32"=0x%"PRIx8
> +m25p80_read_sfdp(void *s, uint32_t addr, uint8_t v) "[%p] Read SFDP 0x%"PRIx32"=0x%"PRIx8
>  m25p80_binding(void *s) "[%p] Binding to IF_MTD drive"
>  m25p80_binding_no_bdrv(void *s) "[%p] No BDRV - binding to RAM"
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model
  2022-07-22  6:36 ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
@ 2022-07-25  2:08   ` Andrew Jeffery
  2022-07-25  6:32     ` Cédric Le Goater
  2022-10-06 22:44   ` [PATCH] m25p80: Add the w25q01jvq SFPD table Patrick Williams
  2022-10-07 14:04   ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Francisco Iglesias
  2 siblings, 1 reply; 33+ messages in thread
From: Andrew Jeffery @ 2022-07-25  2:08 UTC (permalink / raw)
  To: Cédric Le Goater, Cameron Esfahani via
  Cc: Philippe Mathieu-Daudé via, qemu-block, Peter Maydell,
	Joel Stanley, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle



On Fri, 22 Jul 2022, at 16:06, Cédric Le Goater wrote:
> A mx25l25635f chip model is generally found on these machines. It's
> newer and uses 4B opcodes which is better to exercise the support in
> the Linux kernel.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/arm/aspeed.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 1c611284819d..7e95abc55b09 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -1157,7 +1157,7 @@ static void 
> aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
>      amc->soc_name  = "ast2400-a1";
>      amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1;
>      amc->fmc_model = "n25q256a";
> -    amc->spi_model = "mx25l25635e";
> +    amc->spi_model = "mx25l25635f";

Hmm, dmesg reported mx25l25635e on the palmetto I checked

>      amc->num_cs    = 1;
>      amc->i2c_init  = palmetto_bmc_i2c_init;
>      mc->default_ram_size       = 256 * MiB;
> @@ -1208,7 +1208,7 @@ static void 
> aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data)
>      amc->soc_name  = "ast2500-a1";
>      amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
>      amc->fmc_model = "mx25l25635e";
> -    amc->spi_model = "mx25l25635e";
> +    amc->spi_model = "mx25l25635f";
>      amc->num_cs    = 1;
>      amc->i2c_init  = ast2500_evb_i2c_init;
>      mc->default_ram_size       = 512 * MiB;
> @@ -1258,7 +1258,7 @@ static void 
> aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data)
>      mc->desc       = "OpenPOWER Witherspoon BMC (ARM1176)";
>      amc->soc_name  = "ast2500-a1";
>      amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1;
> -    amc->fmc_model = "mx25l25635e";
> +    amc->fmc_model = "mx25l25635f";

The witherspoon I checked also reported mx25l25635e in dmesg for the 
FMC.

You do say "generally" in the commit message though.

Andrew


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model
  2022-07-25  2:08   ` Andrew Jeffery
@ 2022-07-25  6:32     ` Cédric Le Goater
  2022-07-25  6:34       ` Andrew Jeffery
  0 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-07-25  6:32 UTC (permalink / raw)
  To: Andrew Jeffery, Cameron Esfahani via
  Cc: Philippe Mathieu-Daudé via, qemu-block, Peter Maydell,
	Joel Stanley, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle

On 7/25/22 04:08, Andrew Jeffery wrote:
> 
> 
> On Fri, 22 Jul 2022, at 16:06, Cédric Le Goater wrote:
>> A mx25l25635f chip model is generally found on these machines. It's
>> newer and uses 4B opcodes which is better to exercise the support in
>> the Linux kernel.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   hw/arm/aspeed.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
>> index 1c611284819d..7e95abc55b09 100644
>> --- a/hw/arm/aspeed.c
>> +++ b/hw/arm/aspeed.c
>> @@ -1157,7 +1157,7 @@ static void
>> aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
>>       amc->soc_name  = "ast2400-a1";
>>       amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1;
>>       amc->fmc_model = "n25q256a";
>> -    amc->spi_model = "mx25l25635e";
>> +    amc->spi_model = "mx25l25635f";
> 
> Hmm, dmesg reported mx25l25635e on the palmetto I checked
> 
>>       amc->num_cs    = 1;
>>       amc->i2c_init  = palmetto_bmc_i2c_init;
>>       mc->default_ram_size       = 256 * MiB;
>> @@ -1208,7 +1208,7 @@ static void
>> aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data)
>>       amc->soc_name  = "ast2500-a1";
>>       amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
>>       amc->fmc_model = "mx25l25635e";
>> -    amc->spi_model = "mx25l25635e";
>> +    amc->spi_model = "mx25l25635f";
>>       amc->num_cs    = 1;
>>       amc->i2c_init  = ast2500_evb_i2c_init;
>>       mc->default_ram_size       = 512 * MiB;
>> @@ -1258,7 +1258,7 @@ static void
>> aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data)
>>       mc->desc       = "OpenPOWER Witherspoon BMC (ARM1176)";
>>       amc->soc_name  = "ast2500-a1";
>>       amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1;
>> -    amc->fmc_model = "mx25l25635e";
>> +    amc->fmc_model = "mx25l25635f";
> 
> The witherspoon I checked also reported mx25l25635e in dmesg for the
> FMC.
> 
> You do say "generally" in the commit message though.

You can not tell from dmesg.

The MX25L25635F and MX25L25635E models share the same JEDEC ID and
the spi-nor flash device table only contains a mx25l25635e entry.
The MX25L25635F is detected in mx25l25635_post_bfpt_fixups using SFDP.

That's why I added this warning  :

   https://github.com/legoater/linux/commit/934f0708ac597022cbf6c8d6f2ce91d55025e943


C.

> 
> Andrew



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model
  2022-07-25  6:32     ` Cédric Le Goater
@ 2022-07-25  6:34       ` Andrew Jeffery
  0 siblings, 0 replies; 33+ messages in thread
From: Andrew Jeffery @ 2022-07-25  6:34 UTC (permalink / raw)
  To: Cédric Le Goater, Cameron Esfahani via
  Cc: Philippe Mathieu-Daudé via, qemu-block, Peter Maydell,
	Joel Stanley, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle



On Mon, 25 Jul 2022, at 16:02, Cédric Le Goater wrote:
> On 7/25/22 04:08, Andrew Jeffery wrote:
>> 
>> 
>> On Fri, 22 Jul 2022, at 16:06, Cédric Le Goater wrote:
>>> aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data)
>>>       mc->desc       = "OpenPOWER Witherspoon BMC (ARM1176)";
>>>       amc->soc_name  = "ast2500-a1";
>>>       amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1;
>>> -    amc->fmc_model = "mx25l25635e";
>>> +    amc->fmc_model = "mx25l25635f";
>> 
>> The witherspoon I checked also reported mx25l25635e in dmesg for the
>> FMC.
>> 
>> You do say "generally" in the commit message though.
>
> You can not tell from dmesg.
>
> The MX25L25635F and MX25L25635E models share the same JEDEC ID and
> the spi-nor flash device table only contains a mx25l25635e entry.
> The MX25L25635F is detected in mx25l25635_post_bfpt_fixups using SFDP.
>
> That's why I added this warning  :
>
>    
> https://github.com/legoater/linux/commit/934f0708ac597022cbf6c8d6f2ce91d55025e943
>

Oh righto, sorry for the noise.


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] m25p80: Add the w25q01jvq SFPD table
  2022-07-22  6:36 ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
  2022-07-25  2:08   ` Andrew Jeffery
@ 2022-10-06 22:44   ` Patrick Williams
  2022-10-07 15:24     ` Francisco Iglesias
  2022-10-07 14:04   ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Francisco Iglesias
  2 siblings, 1 reply; 33+ messages in thread
From: Patrick Williams @ 2022-10-06 22:44 UTC (permalink / raw)
  To: clg
  Cc: alistair, andrew, frasse.iglesias, irischenlj, joel, michael,
	peter.maydell, qemu-arm, qemu-block, qemu-devel,
	Patrick Williams, Kevin Wolf, Hanna Reitz

Generated from hardware using the following command and then padding
with 0xff to fill out a power-of-2:
    hexdump -v -e '8/1 "0x%02x, " "\n"' sfdp`

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
---
 hw/block/m25p80.c      |  3 ++-
 hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++++++
 hw/block/m25p80_sfdp.h |  2 ++
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 8ba9d732a3..86343160ef 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -349,7 +349,8 @@ static const FlashPartInfo known_devices[] = {
       .sfdp_read = m25p80_sfdp_w25q256 },
     { INFO("w25q512jv",   0xef4020,      0,  64 << 10, 1024, ER_4K),
       .sfdp_read = m25p80_sfdp_w25q512jv },
-    { INFO("w25q01jvq",   0xef4021,      0,  64 << 10, 2048, ER_4K) },
+    { INFO("w25q01jvq",   0xef4021,      0,  64 << 10, 2048, ER_4K),
+      .sfdp_read = m25p80_sfdp_w25q01jvq },
 };
 
 typedef enum {
diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
index dad3d7e64f..77615fa29e 100644
--- a/hw/block/m25p80_sfdp.c
+++ b/hw/block/m25p80_sfdp.c
@@ -294,3 +294,39 @@ static const uint8_t sfdp_w25q512jv[] = {
     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 };
 define_sfdp_read(w25q512jv);
+
+static const uint8_t sfdp_w25q01jvq[] = {
+    0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x01, 0xff,
+    0x00, 0x06, 0x01, 0x10, 0x80, 0x00, 0x00, 0xff,
+    0x84, 0x00, 0x01, 0x02, 0xd0, 0x00, 0x00, 0xff,
+    0x03, 0x00, 0x01, 0x02, 0xf0, 0x00, 0x00, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x3f,
+    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb,
+    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+    0xff, 0xff, 0x40, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
+    0x10, 0xd8, 0x00, 0x00, 0x36, 0x02, 0xa6, 0x00,
+    0x82, 0xea, 0x14, 0xe2, 0xe9, 0x63, 0x76, 0x33,
+    0x7a, 0x75, 0x7a, 0x75, 0xf7, 0xa2, 0xd5, 0x5c,
+    0x19, 0xf7, 0x4d, 0xff, 0xe9, 0x70, 0xf9, 0xa5,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0x0a, 0xf0, 0xff, 0x21, 0xff, 0xdc, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+define_sfdp_read(w25q01jvq);
diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
index 62f140a2fc..8fb1cd3f8a 100644
--- a/hw/block/m25p80_sfdp.h
+++ b/hw/block/m25p80_sfdp.h
@@ -24,4 +24,6 @@ extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr);
 extern uint8_t m25p80_sfdp_w25q256(uint32_t addr);
 extern uint8_t m25p80_sfdp_w25q512jv(uint32_t addr);
 
+extern uint8_t m25p80_sfdp_w25q01jvq(uint32_t addr);
+
 #endif
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 0/8] m25p80: Add SFDP support
  2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
                   ` (8 preceding siblings ...)
  2022-07-22  7:05 ` [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
@ 2022-10-06 22:49 ` Patrick Williams
  9 siblings, 0 replies; 33+ messages in thread
From: Patrick Williams @ 2022-10-06 22:49 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Francisco Iglesias, Iris Chen,
	Michael Walle

[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]

On Fri, Jul 22, 2022 at 08:35:54AM +0200, Cédric Le Goater wrote:
> 
> Cédric Le Goater (8):
>   m25p80: Add basic support for the SFDP command
>   m25p80: Add the n25q256a SFDP table
>   m25p80: Add the mx25l25635e SFPD table
>   m25p80: Add the mx25l25635f SFPD table
>   m25p80: Add the mx66l1g45g SFDP table
>   m25p80: Add the w25q256 SFPD table
>   m25p80: Add the w25q512jv SFPD table
>   arm/aspeed: Replace mx25l25635e chip model
> 
>  hw/block/m25p80_sfdp.h |  27 ++++
>  hw/arm/aspeed.c        |   6 +-
>  hw/block/m25p80.c      |  49 ++++++-
>  hw/block/m25p80_sfdp.c | 296 +++++++++++++++++++++++++++++++++++++++++
>  MAINTAINERS            |   2 +-
>  hw/block/meson.build   |   1 +
>  hw/block/trace-events  |   1 +
>  7 files changed, 371 insertions(+), 11 deletions(-)
>  create mode 100644 hw/block/m25p80_sfdp.h
>  create mode 100644 hw/block/m25p80_sfdp.c
> 
> -- 
> 2.35.3
> 
> 

It seems that the kernel spi-nor driver maintainers really prefer to use
SFDP for parsing rather than relying on flags, so this support would be
really good to get added to QEMU now.  I've tested this patch set and
added (in reply to patch 8) support for the w25q01jvq chip.

Tested-by: Patrick Williams <patrick@stwcx.xyz>

-- 
Patrick Williams

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table
  2022-07-22  6:35 ` [PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
@ 2022-10-07 13:59   ` Francisco Iglesias
  2022-10-10  6:09     ` Cédric Le Goater
  0 siblings, 1 reply; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-07 13:59 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

Hi Cedric,

On [2022 Jul 22] Fri 08:35:57, Cédric Le Goater wrote:
> The SFDP table is 0x80 bytes long. The mandatory table for basic
> features is available at byte 0x30 and an extra Macronix specific
> table is available at 0x60.
> 
> 4B opcodes are not supported.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/block/m25p80_sfdp.h |  3 +++
>  hw/block/m25p80.c      |  3 ++-
>  hw/block/m25p80_sfdp.c | 26 ++++++++++++++++++++++++++
>  3 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> index d3a0a778ae84..0c46e669b335 100644
> --- a/hw/block/m25p80_sfdp.h
> +++ b/hw/block/m25p80_sfdp.h
> @@ -17,4 +17,7 @@
>  
>  extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
>  
> +extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);

We could be without 'extern' in above hdr if we like (also the other patches),
either way:

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

> +
> +
>  #endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 13e7b28fd2b0..028b026d8ba2 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -232,7 +232,8 @@ static const FlashPartInfo known_devices[] = {
>      { INFO("mx25l6405d",  0xc22017,      0,  64 << 10, 128, 0) },
>      { INFO("mx25l12805d", 0xc22018,      0,  64 << 10, 256, 0) },
>      { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
> -    { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0) },
> +    { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0),
> +      .sfdp_read = m25p80_sfdp_mx25l25635e },
>      { INFO("mx25l25655e", 0xc22619,      0,  64 << 10, 512, 0) },
>      { INFO("mx66l51235f", 0xc2201a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
>      { INFO("mx66u51235f", 0xc2253a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
> index 24ec05de79a1..6499c4c39954 100644
> --- a/hw/block/m25p80_sfdp.c
> +++ b/hw/block/m25p80_sfdp.c
> @@ -56,3 +56,29 @@ static const uint8_t sfdp_n25q256a[] = {
>      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>  };
>  define_sfdp_read(n25q256a);
> +
> +
> +/*
> + * Matronix
> + */
> +
> +/* mx25l25635e. No 4B opcodes */
> +static const uint8_t sfdp_mx25l25635e[] = {
> +    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff,
> +    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
> +    0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f,
> +    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb,
> +    0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
> +    0xff, 0xff, 0x00, 0xff, 0x0c, 0x20, 0x0f, 0x52,
> +    0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0x00, 0x36, 0x00, 0x27, 0xf7, 0x4f, 0xff, 0xff,
> +    0xd9, 0xc8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +};
> +define_sfdp_read(mx25l25635e)
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 2/8] m25p80: Add the n25q256a SFDP table
  2022-07-22  6:35 ` [PATCH v3 2/8] m25p80: Add the n25q256a SFDP table Cédric Le Goater
@ 2022-10-07 14:03   ` Francisco Iglesias
  2022-10-10  6:15     ` Cédric Le Goater
  0 siblings, 1 reply; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-07 14:03 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On [2022 Jul 22] Fri 08:35:56, Cédric Le Goater wrote:
> The same values were collected on 4 differents OpenPower systems,
> palmettos, romulus and tacoma.
> 
> The SFDP table size is defined as being 0x100 bytes but it could be
> bigger. Only the mandatory table for basic features is available at
> byte 0x30.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/block/m25p80_sfdp.h |  2 ++
>  hw/block/m25p80.c      |  8 +++---
>  hw/block/m25p80_sfdp.c | 58 ++++++++++++++++++++++++++++++++++++++++++
>  hw/block/meson.build   |  1 +
>  4 files changed, 66 insertions(+), 3 deletions(-)
>  create mode 100644 hw/block/m25p80_sfdp.c
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> index 230b07ef3308..d3a0a778ae84 100644
> --- a/hw/block/m25p80_sfdp.h
> +++ b/hw/block/m25p80_sfdp.h
> @@ -15,4 +15,6 @@
>   */
>  #define M25P80_SFDP_MAX_SIZE  (1 << 24)
>  
> +extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);

(-extern above if we would like)


> +
>  #endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index abdc4c0b0da7..13e7b28fd2b0 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -247,13 +247,15 @@ static const FlashPartInfo known_devices[] = {
>      { INFO("n25q128a11",  0x20bb18,      0,  64 << 10, 256, ER_4K) },
>      { INFO("n25q128a13",  0x20ba18,      0,  64 << 10, 256, ER_4K) },
>      { INFO("n25q256a11",  0x20bb19,      0,  64 << 10, 512, ER_4K) },
> -    { INFO("n25q256a13",  0x20ba19,      0,  64 << 10, 512, ER_4K) },
> +    { INFO("n25q256a13",  0x20ba19,      0,  64 << 10, 512, ER_4K),
> +      .sfdp_read = m25p80_sfdp_n25q256a },
>      { INFO("n25q512a11",  0x20bb20,      0,  64 << 10, 1024, ER_4K) },
>      { INFO("n25q512a13",  0x20ba20,      0,  64 << 10, 1024, ER_4K) },
>      { INFO("n25q128",     0x20ba18,      0,  64 << 10, 256, 0) },
>      { INFO("n25q256a",    0x20ba19,      0,  64 << 10, 512,
> -           ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB) },
> -    { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
> +           ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB),
> +      .sfdp_read = m25p80_sfdp_n25q256a },
> +   { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
>      { INFO("n25q512ax3",  0x20ba20,  0x1000,  64 << 10, 1024, ER_4K) },
>      { INFO("mt25ql512ab", 0x20ba20, 0x1044, 64 << 10, 1024, ER_4K | ER_32K) },
>      { INFO_STACKED("mt35xu01g", 0x2c5b1b, 0x104100, 128 << 10, 1024,
> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
> new file mode 100644
> index 000000000000..24ec05de79a1
> --- /dev/null
> +++ b/hw/block/m25p80_sfdp.c
> @@ -0,0 +1,58 @@
> +/*
> + * M25P80 Serial Flash Discoverable Parameter (SFDP)
> + *
> + * Copyright (c) 2020, IBM Corporation.
> + *
> + * This code is licensed under the GPL version 2 or later. See the
> + * COPYING file in the top-level directory.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/host-utils.h"
> +#include "m25p80_sfdp.h"
> +
> +#define define_sfdp_read(model)                                       \
> +    uint8_t m25p80_sfdp_##model(uint32_t addr)                        \
> +    {                                                                 \
> +        assert(is_power_of_2(sizeof(sfdp_##model)));                  \
> +        return sfdp_##model[addr & (sizeof(sfdp_##model) - 1)];       \
> +    }
> +
> +/*
> + * Micron
> + */
> +static const uint8_t sfdp_n25q256a[] = {

The datasheets I found wasn't completetly as this table but I can't argue
with the hw read out of 4 flashes.

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

> +    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff,
> +    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x0f,
> +    0x29, 0xeb, 0x27, 0x6b, 0x08, 0x3b, 0x27, 0xbb,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x27, 0xbb,
> +    0xff, 0xff, 0x29, 0xeb, 0x0c, 0x20, 0x10, 0xd8,
> +    0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +};
> +define_sfdp_read(n25q256a);
> diff --git a/hw/block/meson.build b/hw/block/meson.build
> index 2389326112ae..3129ca4c52eb 100644
> --- a/hw/block/meson.build
> +++ b/hw/block/meson.build
> @@ -12,6 +12,7 @@ softmmu_ss.add(when: 'CONFIG_ONENAND', if_true: files('onenand.c'))
>  softmmu_ss.add(when: 'CONFIG_PFLASH_CFI01', if_true: files('pflash_cfi01.c'))
>  softmmu_ss.add(when: 'CONFIG_PFLASH_CFI02', if_true: files('pflash_cfi02.c'))
>  softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80.c'))
> +softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80_sfdp.c'))
>  softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c'))
>  softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
>  softmmu_ss.add(when: 'CONFIG_TC58128', if_true: files('tc58128.c'))
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model
  2022-07-22  6:36 ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
  2022-07-25  2:08   ` Andrew Jeffery
  2022-10-06 22:44   ` [PATCH] m25p80: Add the w25q01jvq SFPD table Patrick Williams
@ 2022-10-07 14:04   ` Francisco Iglesias
  2 siblings, 0 replies; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-07 14:04 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On [2022 Jul 22] Fri 08:36:02, Cédric Le Goater wrote:
> A mx25l25635f chip model is generally found on these machines. It's
> newer and uses 4B opcodes which is better to exercise the support in
> the Linux kernel.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

> ---
>  hw/arm/aspeed.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 1c611284819d..7e95abc55b09 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -1157,7 +1157,7 @@ static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
>      amc->soc_name  = "ast2400-a1";
>      amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1;
>      amc->fmc_model = "n25q256a";
> -    amc->spi_model = "mx25l25635e";
> +    amc->spi_model = "mx25l25635f";
>      amc->num_cs    = 1;
>      amc->i2c_init  = palmetto_bmc_i2c_init;
>      mc->default_ram_size       = 256 * MiB;
> @@ -1208,7 +1208,7 @@ static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data)
>      amc->soc_name  = "ast2500-a1";
>      amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
>      amc->fmc_model = "mx25l25635e";
> -    amc->spi_model = "mx25l25635e";
> +    amc->spi_model = "mx25l25635f";
>      amc->num_cs    = 1;
>      amc->i2c_init  = ast2500_evb_i2c_init;
>      mc->default_ram_size       = 512 * MiB;
> @@ -1258,7 +1258,7 @@ static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data)
>      mc->desc       = "OpenPOWER Witherspoon BMC (ARM1176)";
>      amc->soc_name  = "ast2500-a1";
>      amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1;
> -    amc->fmc_model = "mx25l25635e";
> +    amc->fmc_model = "mx25l25635f";
>      amc->spi_model = "mx66l1g45g";
>      amc->num_cs    = 2;
>      amc->i2c_init  = witherspoon_bmc_i2c_init;
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 4/8] m25p80: Add the mx25l25635f SFPD table
  2022-07-22  6:35 ` [PATCH v3 4/8] m25p80: Add the mx25l25635f " Cédric Le Goater
@ 2022-10-07 14:44   ` Francisco Iglesias
  2022-10-10  6:23     ` Cédric Le Goater
  0 siblings, 1 reply; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-07 14:44 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On [2022 Jul 22] Fri 08:35:58, Cédric Le Goater wrote:
> The mx25l25635e and mx25l25635f chips have the same JEDEC id but the
> mx25l25635f has more capabilities reported in the SFDP table. Support
> for 4B opcodes is of interest because it is exploited by the Linux
> kernel.
> 
> The SFDP table size is 0x200 bytes long. The mandatory table for basic
> features is available at byte 0x30 and an extra Macronix specific
> table is available at 0x60.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/block/m25p80_sfdp.h |  1 +
>  hw/block/m25p80.c      |  2 ++
>  hw/block/m25p80_sfdp.c | 68 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 71 insertions(+)
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> index 0c46e669b335..87690a173c78 100644
> --- a/hw/block/m25p80_sfdp.h
> +++ b/hw/block/m25p80_sfdp.h
> @@ -18,6 +18,7 @@
>  extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
>  
>  extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
> +extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
(optional -extern above)

>  
>  
>  #endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 028b026d8ba2..6b120ce65212 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -234,6 +234,8 @@ static const FlashPartInfo known_devices[] = {
>      { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
>      { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0),
>        .sfdp_read = m25p80_sfdp_mx25l25635e },
> +    { INFO6("mx25l25635f", 0xc22019,     0xc22019,  64 << 10, 512, 0),

I think I'm not seeing the extended id part in the datasheet I've found so
might be that you can switch to just INFO and _ext_id 0 above (might be the
same in the previous patch with the similar flash). Otherwise looks good to
me:

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>


> +      .sfdp_read = m25p80_sfdp_mx25l25635f },
>      { INFO("mx25l25655e", 0xc22619,      0,  64 << 10, 512, 0) },
>      { INFO("mx66l51235f", 0xc2201a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
>      { INFO("mx66u51235f", 0xc2253a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
> index 6499c4c39954..70c13aea7c63 100644
> --- a/hw/block/m25p80_sfdp.c
> +++ b/hw/block/m25p80_sfdp.c
> @@ -82,3 +82,71 @@ static const uint8_t sfdp_mx25l25635e[] = {
>      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>  };
>  define_sfdp_read(mx25l25635e)
> +
> +static const uint8_t sfdp_mx25l25635f[] = {
> +    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff,
> +    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
> +    0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f,
> +    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb,
> +    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
> +    0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
> +    0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64,
> +    0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xc2, 0xf5, 0x08, 0x0a,
> +    0x08, 0x04, 0x03, 0x06, 0x00, 0x00, 0x07, 0x29,
> +    0x17, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +};
> +define_sfdp_read(mx25l25635f);
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 5/8] m25p80: Add the mx66l1g45g SFDP table
  2022-07-22  6:35 ` [PATCH v3 5/8] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
@ 2022-10-07 14:59   ` Francisco Iglesias
  0 siblings, 0 replies; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-07 14:59 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On [2022 Jul 22] Fri 08:35:59, Cédric Le Goater wrote:
> The SFDP table size is 0x200 bytes long. The mandatory table for basic
> features is available at byte 0x30 plus some more Macronix specific
> tables.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/block/m25p80_sfdp.h |  2 +-
>  hw/block/m25p80.c      |  3 +-
>  hw/block/m25p80_sfdp.c | 68 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 71 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> index 87690a173c78..468e3434151b 100644
> --- a/hw/block/m25p80_sfdp.h
> +++ b/hw/block/m25p80_sfdp.h
> @@ -19,6 +19,6 @@ extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
>  
>  extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
>  extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
> -
> +extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr);

(optional -extern)

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

>  
>  #endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 6b120ce65212..52df24d24751 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -240,7 +240,8 @@ static const FlashPartInfo known_devices[] = {
>      { INFO("mx66l51235f", 0xc2201a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
>      { INFO("mx66u51235f", 0xc2253a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
>      { INFO("mx66u1g45g",  0xc2253b,      0,  64 << 10, 2048, ER_4K | ER_32K) },
> -    { INFO("mx66l1g45g",  0xc2201b,      0,  64 << 10, 2048, ER_4K | ER_32K) },
> +    { INFO("mx66l1g45g",  0xc2201b,      0,  64 << 10, 2048, ER_4K | ER_32K),
> +      .sfdp_read = m25p80_sfdp_mx66l1g45g },
>  
>      /* Micron */
>      { INFO("n25q032a11",  0x20bb16,      0,  64 << 10,  64, ER_4K) },
> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
> index 70c13aea7c63..38c3ced34d2e 100644
> --- a/hw/block/m25p80_sfdp.c
> +++ b/hw/block/m25p80_sfdp.c
> @@ -150,3 +150,71 @@ static const uint8_t sfdp_mx25l25635f[] = {
>      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>  };
>  define_sfdp_read(mx25l25635f);
> +
> +static const uint8_t sfdp_mx66l1g45g[] = {
> +    0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x02, 0xff,
> +    0x00, 0x06, 0x01, 0x10, 0x30, 0x00, 0x00, 0xff,
> +    0xc2, 0x00, 0x01, 0x04, 0x10, 0x01, 0x00, 0xff,
> +    0x84, 0x00, 0x01, 0x02, 0xc0, 0x00, 0x00, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x3f,
> +    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb,
> +    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
> +    0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
> +    0x10, 0xd8, 0x00, 0xff, 0xd6, 0x49, 0xc5, 0x00,
> +    0x85, 0xdf, 0x04, 0xe3, 0x44, 0x03, 0x67, 0x38,
> +    0x30, 0xb0, 0x30, 0xb0, 0xf7, 0xbd, 0xd5, 0x5c,
> +    0x4a, 0x9e, 0x29, 0xff, 0xf0, 0x50, 0xf9, 0x85,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0x7f, 0xef, 0xff, 0xff, 0x21, 0x5c, 0xdc, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64,
> +    0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xc2, 0xf5, 0x08, 0x00, 0x0c, 0x04, 0x08, 0x08,
> +    0x01, 0x00, 0x19, 0x0f, 0x01, 0x01, 0x06, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +};
> +define_sfdp_read(mx66l1g45g);
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 6/8] m25p80: Add the w25q256 SFPD table
  2022-07-22  6:36 ` [PATCH v3 6/8] m25p80: Add the w25q256 SFPD table Cédric Le Goater
@ 2022-10-07 15:13   ` Francisco Iglesias
  0 siblings, 0 replies; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-07 15:13 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On [2022 Jul 22] Fri 08:36:00, Cédric Le Goater wrote:
> The SFDP table size is 0x100 bytes long. Only the mandatory table for
> basic features is available at byte 0x80.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/block/m25p80_sfdp.h |  2 ++
>  hw/block/m25p80.c      |  3 ++-
>  hw/block/m25p80_sfdp.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> index 468e3434151b..f60429ab8542 100644
> --- a/hw/block/m25p80_sfdp.h
> +++ b/hw/block/m25p80_sfdp.h
> @@ -21,4 +21,6 @@ extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
>  extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
>  extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr);
>  
> +extern uint8_t m25p80_sfdp_w25q256(uint32_t addr);
(optional -extern)

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

> +
>  #endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 52df24d24751..220dbc8fb327 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -345,7 +345,8 @@ static const FlashPartInfo known_devices[] = {
>      { INFO("w25q64",      0xef4017,      0,  64 << 10, 128, ER_4K) },
>      { INFO("w25q80",      0xef5014,      0,  64 << 10,  16, ER_4K) },
>      { INFO("w25q80bl",    0xef4014,      0,  64 << 10,  16, ER_4K) },
> -    { INFO("w25q256",     0xef4019,      0,  64 << 10, 512, ER_4K) },
> +    { INFO("w25q256",     0xef4019,      0,  64 << 10, 512, ER_4K),
> +      .sfdp_read = m25p80_sfdp_w25q256 },
>      { INFO("w25q512jv",   0xef4020,      0,  64 << 10, 1024, ER_4K) },
>      { INFO("w25q01jvq",   0xef4021,      0,  64 << 10, 2048, ER_4K) },
>  };
> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
> index 38c3ced34d2e..5b011559d43d 100644
> --- a/hw/block/m25p80_sfdp.c
> +++ b/hw/block/m25p80_sfdp.c
> @@ -218,3 +218,43 @@ static const uint8_t sfdp_mx66l1g45g[] = {
>      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>  };
>  define_sfdp_read(mx66l1g45g);
> +
> +/*
> + * Windbond
> + */
> +
> +static const uint8_t sfdp_w25q256[] = {
> +    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff,
> +    0x00, 0x00, 0x01, 0x09, 0x80, 0x00, 0x00, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f,
> +    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb,
> +    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
> +    0xff, 0xff, 0x21, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
> +    0x10, 0xd8, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +};
> +define_sfdp_read(w25q256);
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 7/8] m25p80: Add the w25q512jv SFPD table
  2022-07-22  6:36 ` [PATCH v3 7/8] m25p80: Add the w25q512jv " Cédric Le Goater
@ 2022-10-07 15:14   ` Francisco Iglesias
  0 siblings, 0 replies; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-07 15:14 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On [2022 Jul 22] Fri 08:36:01, Cédric Le Goater wrote:
> The SFDP table size is 0x100 bytes long. The mandatory table for basic
> features is available at byte 0x80 and two extra Winbond specifics
> table are available at 0xC0 and 0xF0.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/block/m25p80_sfdp.h |  1 +
>  hw/block/m25p80.c      |  3 ++-
>  hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> index f60429ab8542..62f140a2fcef 100644
> --- a/hw/block/m25p80_sfdp.h
> +++ b/hw/block/m25p80_sfdp.h
> @@ -22,5 +22,6 @@ extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
>  extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr);
>  
>  extern uint8_t m25p80_sfdp_w25q256(uint32_t addr);
> +extern uint8_t m25p80_sfdp_w25q512jv(uint32_t addr);
(optional -extern)

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

>  
>  #endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 220dbc8fb327..8ba9d732a323 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -347,7 +347,8 @@ static const FlashPartInfo known_devices[] = {
>      { INFO("w25q80bl",    0xef4014,      0,  64 << 10,  16, ER_4K) },
>      { INFO("w25q256",     0xef4019,      0,  64 << 10, 512, ER_4K),
>        .sfdp_read = m25p80_sfdp_w25q256 },
> -    { INFO("w25q512jv",   0xef4020,      0,  64 << 10, 1024, ER_4K) },
> +    { INFO("w25q512jv",   0xef4020,      0,  64 << 10, 1024, ER_4K),
> +      .sfdp_read = m25p80_sfdp_w25q512jv },
>      { INFO("w25q01jvq",   0xef4021,      0,  64 << 10, 2048, ER_4K) },
>  };
>  
> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
> index 5b011559d43d..dad3d7e64f9f 100644
> --- a/hw/block/m25p80_sfdp.c
> +++ b/hw/block/m25p80_sfdp.c
> @@ -258,3 +258,39 @@ static const uint8_t sfdp_w25q256[] = {
>      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>  };
>  define_sfdp_read(w25q256);
> +
> +static const uint8_t sfdp_w25q512jv[] = {
> +    0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x01, 0xff,
> +    0x00, 0x06, 0x01, 0x10, 0x80, 0x00, 0x00, 0xff,
> +    0x84, 0x00, 0x01, 0x02, 0xd0, 0x00, 0x00, 0xff,
> +    0x03, 0x00, 0x01, 0x02, 0xf0, 0x00, 0x00, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x1f,
> +    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb,
> +    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
> +    0xff, 0xff, 0x40, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
> +    0x10, 0xd8, 0x00, 0x00, 0x36, 0x02, 0xa6, 0x00,
> +    0x82, 0xea, 0x14, 0xe2, 0xe9, 0x63, 0x76, 0x33,
> +    0x7a, 0x75, 0x7a, 0x75, 0xf7, 0xa2, 0xd5, 0x5c,
> +    0x19, 0xf7, 0x4d, 0xff, 0xe9, 0x70, 0xf9, 0xa5,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0x0a, 0xf0, 0xff, 0x21, 0xff, 0xdc, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +};
> +define_sfdp_read(w25q512jv);
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] m25p80: Add the w25q01jvq SFPD table
  2022-10-06 22:44   ` [PATCH] m25p80: Add the w25q01jvq SFPD table Patrick Williams
@ 2022-10-07 15:24     ` Francisco Iglesias
  0 siblings, 0 replies; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-07 15:24 UTC (permalink / raw)
  To: Patrick Williams
  Cc: clg, alistair, andrew, irischenlj, joel, michael, peter.maydell,
	qemu-arm, qemu-block, qemu-devel, Kevin Wolf, Hanna Reitz

On [2022 Oct 06] Thu 17:44:24, Patrick Williams wrote:
> Generated from hardware using the following command and then padding
> with 0xff to fill out a power-of-2:
>     hexdump -v -e '8/1 "0x%02x, " "\n"' sfdp`
> 
> Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
> ---
>  hw/block/m25p80.c      |  3 ++-
>  hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++++++
>  hw/block/m25p80_sfdp.h |  2 ++
>  3 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 8ba9d732a3..86343160ef 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -349,7 +349,8 @@ static const FlashPartInfo known_devices[] = {
>        .sfdp_read = m25p80_sfdp_w25q256 },
>      { INFO("w25q512jv",   0xef4020,      0,  64 << 10, 1024, ER_4K),
>        .sfdp_read = m25p80_sfdp_w25q512jv },
> -    { INFO("w25q01jvq",   0xef4021,      0,  64 << 10, 2048, ER_4K) },
> +    { INFO("w25q01jvq",   0xef4021,      0,  64 << 10, 2048, ER_4K),
> +      .sfdp_read = m25p80_sfdp_w25q01jvq },
>  };
>  
>  typedef enum {
> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
> index dad3d7e64f..77615fa29e 100644
> --- a/hw/block/m25p80_sfdp.c
> +++ b/hw/block/m25p80_sfdp.c
> @@ -294,3 +294,39 @@ static const uint8_t sfdp_w25q512jv[] = {
>      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>  };
>  define_sfdp_read(w25q512jv);
> +
> +static const uint8_t sfdp_w25q01jvq[] = {
> +    0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x01, 0xff,
> +    0x00, 0x06, 0x01, 0x10, 0x80, 0x00, 0x00, 0xff,
> +    0x84, 0x00, 0x01, 0x02, 0xd0, 0x00, 0x00, 0xff,
> +    0x03, 0x00, 0x01, 0x02, 0xf0, 0x00, 0x00, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x3f,
> +    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb,
> +    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
> +    0xff, 0xff, 0x40, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
> +    0x10, 0xd8, 0x00, 0x00, 0x36, 0x02, 0xa6, 0x00,
> +    0x82, 0xea, 0x14, 0xe2, 0xe9, 0x63, 0x76, 0x33,
> +    0x7a, 0x75, 0x7a, 0x75, 0xf7, 0xa2, 0xd5, 0x5c,
> +    0x19, 0xf7, 0x4d, 0xff, 0xe9, 0x70, 0xf9, 0xa5,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0x0a, 0xf0, 0xff, 0x21, 0xff, 0xdc, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +};
> +define_sfdp_read(w25q01jvq);
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> index 62f140a2fc..8fb1cd3f8a 100644
> --- a/hw/block/m25p80_sfdp.h
> +++ b/hw/block/m25p80_sfdp.h
> @@ -24,4 +24,6 @@ extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr);
>  extern uint8_t m25p80_sfdp_w25q256(uint32_t addr);
>  extern uint8_t m25p80_sfdp_w25q512jv(uint32_t addr);
>  
> +extern uint8_t m25p80_sfdp_w25q01jvq(uint32_t addr);
(optional -extern)

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

> +
>  #endif
> -- 
> 2.35.1
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table
  2022-10-07 13:59   ` Francisco Iglesias
@ 2022-10-10  6:09     ` Cédric Le Goater
  0 siblings, 0 replies; 33+ messages in thread
From: Cédric Le Goater @ 2022-10-10  6:09 UTC (permalink / raw)
  To: Francisco Iglesias
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

Hello Francisco

On 10/7/22 15:59, Francisco Iglesias wrote:
> Hi Cedric,
> 
> On [2022 Jul 22] Fri 08:35:57, Cédric Le Goater wrote:
>> The SFDP table is 0x80 bytes long. The mandatory table for basic
>> features is available at byte 0x30 and an extra Macronix specific
>> table is available at 0x60.
>>
>> 4B opcodes are not supported.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   hw/block/m25p80_sfdp.h |  3 +++
>>   hw/block/m25p80.c      |  3 ++-
>>   hw/block/m25p80_sfdp.c | 26 ++++++++++++++++++++++++++
>>   3 files changed, 31 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
>> index d3a0a778ae84..0c46e669b335 100644
>> --- a/hw/block/m25p80_sfdp.h
>> +++ b/hw/block/m25p80_sfdp.h
>> @@ -17,4 +17,7 @@
>>   
>>   extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
>>   
>> +extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
> 
> We could be without 'extern' in above hdr if we like (also the other patches),

Yes. I dropped all of them in v4.

Thanks,

C.

> either way:
> 
> Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
> 
>> +
>> +
>>   #endif
>> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
>> index 13e7b28fd2b0..028b026d8ba2 100644
>> --- a/hw/block/m25p80.c
>> +++ b/hw/block/m25p80.c
>> @@ -232,7 +232,8 @@ static const FlashPartInfo known_devices[] = {
>>       { INFO("mx25l6405d",  0xc22017,      0,  64 << 10, 128, 0) },
>>       { INFO("mx25l12805d", 0xc22018,      0,  64 << 10, 256, 0) },
>>       { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
>> -    { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0) },
>> +    { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0),
>> +      .sfdp_read = m25p80_sfdp_mx25l25635e },
>>       { INFO("mx25l25655e", 0xc22619,      0,  64 << 10, 512, 0) },
>>       { INFO("mx66l51235f", 0xc2201a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
>>       { INFO("mx66u51235f", 0xc2253a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
>> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
>> index 24ec05de79a1..6499c4c39954 100644
>> --- a/hw/block/m25p80_sfdp.c
>> +++ b/hw/block/m25p80_sfdp.c
>> @@ -56,3 +56,29 @@ static const uint8_t sfdp_n25q256a[] = {
>>       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>>   };
>>   define_sfdp_read(n25q256a);
>> +
>> +
>> +/*
>> + * Matronix
>> + */
>> +
>> +/* mx25l25635e. No 4B opcodes */
>> +static const uint8_t sfdp_mx25l25635e[] = {
>> +    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff,
>> +    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
>> +    0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f,
>> +    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb,
>> +    0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
>> +    0xff, 0xff, 0x00, 0xff, 0x0c, 0x20, 0x0f, 0x52,
>> +    0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0x00, 0x36, 0x00, 0x27, 0xf7, 0x4f, 0xff, 0xff,
>> +    0xd9, 0xc8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +};
>> +define_sfdp_read(mx25l25635e)
>> -- 
>> 2.35.3
>>



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 2/8] m25p80: Add the n25q256a SFDP table
  2022-10-07 14:03   ` Francisco Iglesias
@ 2022-10-10  6:15     ` Cédric Le Goater
  0 siblings, 0 replies; 33+ messages in thread
From: Cédric Le Goater @ 2022-10-10  6:15 UTC (permalink / raw)
  To: Francisco Iglesias
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On 10/7/22 16:03, Francisco Iglesias wrote:
> On [2022 Jul 22] Fri 08:35:56, Cédric Le Goater wrote:
>> The same values were collected on 4 differents OpenPower systems,
>> palmettos, romulus and tacoma.
>>
>> The SFDP table size is defined as being 0x100 bytes but it could be
>> bigger. Only the mandatory table for basic features is available at
>> byte 0x30.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   hw/block/m25p80_sfdp.h |  2 ++
>>   hw/block/m25p80.c      |  8 +++---
>>   hw/block/m25p80_sfdp.c | 58 ++++++++++++++++++++++++++++++++++++++++++
>>   hw/block/meson.build   |  1 +
>>   4 files changed, 66 insertions(+), 3 deletions(-)
>>   create mode 100644 hw/block/m25p80_sfdp.c
>>
>> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
>> index 230b07ef3308..d3a0a778ae84 100644
>> --- a/hw/block/m25p80_sfdp.h
>> +++ b/hw/block/m25p80_sfdp.h
>> @@ -15,4 +15,6 @@
>>    */
>>   #define M25P80_SFDP_MAX_SIZE  (1 << 24)
>>   
>> +extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
> 
> (-extern above if we would like)
> 
> 
>> +
>>   #endif
>> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
>> index abdc4c0b0da7..13e7b28fd2b0 100644
>> --- a/hw/block/m25p80.c
>> +++ b/hw/block/m25p80.c
>> @@ -247,13 +247,15 @@ static const FlashPartInfo known_devices[] = {
>>       { INFO("n25q128a11",  0x20bb18,      0,  64 << 10, 256, ER_4K) },
>>       { INFO("n25q128a13",  0x20ba18,      0,  64 << 10, 256, ER_4K) },
>>       { INFO("n25q256a11",  0x20bb19,      0,  64 << 10, 512, ER_4K) },
>> -    { INFO("n25q256a13",  0x20ba19,      0,  64 << 10, 512, ER_4K) },
>> +    { INFO("n25q256a13",  0x20ba19,      0,  64 << 10, 512, ER_4K),
>> +      .sfdp_read = m25p80_sfdp_n25q256a },
>>       { INFO("n25q512a11",  0x20bb20,      0,  64 << 10, 1024, ER_4K) },
>>       { INFO("n25q512a13",  0x20ba20,      0,  64 << 10, 1024, ER_4K) },
>>       { INFO("n25q128",     0x20ba18,      0,  64 << 10, 256, 0) },
>>       { INFO("n25q256a",    0x20ba19,      0,  64 << 10, 512,
>> -           ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB) },
>> -    { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
>> +           ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB),
>> +      .sfdp_read = m25p80_sfdp_n25q256a },
>> +   { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
>>       { INFO("n25q512ax3",  0x20ba20,  0x1000,  64 << 10, 1024, ER_4K) },
>>       { INFO("mt25ql512ab", 0x20ba20, 0x1044, 64 << 10, 1024, ER_4K | ER_32K) },
>>       { INFO_STACKED("mt35xu01g", 0x2c5b1b, 0x104100, 128 << 10, 1024,
>> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
>> new file mode 100644
>> index 000000000000..24ec05de79a1
>> --- /dev/null
>> +++ b/hw/block/m25p80_sfdp.c
>> @@ -0,0 +1,58 @@
>> +/*
>> + * M25P80 Serial Flash Discoverable Parameter (SFDP)
>> + *
>> + * Copyright (c) 2020, IBM Corporation.
>> + *
>> + * This code is licensed under the GPL version 2 or later. See the
>> + * COPYING file in the top-level directory.
>> + */
>> +
>> +#include "qemu/osdep.h"
>> +#include "qemu/host-utils.h"
>> +#include "m25p80_sfdp.h"
>> +
>> +#define define_sfdp_read(model)                                       \
>> +    uint8_t m25p80_sfdp_##model(uint32_t addr)                        \
>> +    {                                                                 \
>> +        assert(is_power_of_2(sizeof(sfdp_##model)));                  \
>> +        return sfdp_##model[addr & (sizeof(sfdp_##model) - 1)];       \
>> +    }
>> +
>> +/*
>> + * Micron
>> + */
>> +static const uint8_t sfdp_n25q256a[] = {
> 
> The datasheets I found wasn't completetly as this table but I can't argue
> with the hw read out of 4 flashes.

It is mentioned there :

   http://datasheet.octopart.com/N25Q256A13E1241F-Micron-datasheet-11552757.pdf

C.


> 
> Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
> 
>> +    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff,
>> +    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x0f,
>> +    0x29, 0xeb, 0x27, 0x6b, 0x08, 0x3b, 0x27, 0xbb,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x27, 0xbb,
>> +    0xff, 0xff, 0x29, 0xeb, 0x0c, 0x20, 0x10, 0xd8,
>> +    0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +};
>> +define_sfdp_read(n25q256a);
>> diff --git a/hw/block/meson.build b/hw/block/meson.build
>> index 2389326112ae..3129ca4c52eb 100644
>> --- a/hw/block/meson.build
>> +++ b/hw/block/meson.build
>> @@ -12,6 +12,7 @@ softmmu_ss.add(when: 'CONFIG_ONENAND', if_true: files('onenand.c'))
>>   softmmu_ss.add(when: 'CONFIG_PFLASH_CFI01', if_true: files('pflash_cfi01.c'))
>>   softmmu_ss.add(when: 'CONFIG_PFLASH_CFI02', if_true: files('pflash_cfi02.c'))
>>   softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80.c'))
>> +softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80_sfdp.c'))
>>   softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c'))
>>   softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
>>   softmmu_ss.add(when: 'CONFIG_TC58128', if_true: files('tc58128.c'))
>> -- 
>> 2.35.3
>>



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 4/8] m25p80: Add the mx25l25635f SFPD table
  2022-10-07 14:44   ` Francisco Iglesias
@ 2022-10-10  6:23     ` Cédric Le Goater
  2022-10-10  9:58       ` Michael Walle
  0 siblings, 1 reply; 33+ messages in thread
From: Cédric Le Goater @ 2022-10-10  6:23 UTC (permalink / raw)
  To: Francisco Iglesias
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen, Michael Walle

On 10/7/22 16:44, Francisco Iglesias wrote:
> On [2022 Jul 22] Fri 08:35:58, Cédric Le Goater wrote:
>> The mx25l25635e and mx25l25635f chips have the same JEDEC id but the
>> mx25l25635f has more capabilities reported in the SFDP table. Support
>> for 4B opcodes is of interest because it is exploited by the Linux
>> kernel.
>>
>> The SFDP table size is 0x200 bytes long. The mandatory table for basic
>> features is available at byte 0x30 and an extra Macronix specific
>> table is available at 0x60.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   hw/block/m25p80_sfdp.h |  1 +
>>   hw/block/m25p80.c      |  2 ++
>>   hw/block/m25p80_sfdp.c | 68 ++++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 71 insertions(+)
>>
>> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
>> index 0c46e669b335..87690a173c78 100644
>> --- a/hw/block/m25p80_sfdp.h
>> +++ b/hw/block/m25p80_sfdp.h
>> @@ -18,6 +18,7 @@
>>   extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr);
>>   
>>   extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr);
>> +extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr);
> (optional -extern above)
> 
>>   
>>   
>>   #endif
>> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
>> index 028b026d8ba2..6b120ce65212 100644
>> --- a/hw/block/m25p80.c
>> +++ b/hw/block/m25p80.c
>> @@ -234,6 +234,8 @@ static const FlashPartInfo known_devices[] = {
>>       { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
>>       { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0),
>>         .sfdp_read = m25p80_sfdp_mx25l25635e },
>> +    { INFO6("mx25l25635f", 0xc22019,     0xc22019,  64 << 10, 512, 0),
> 
> I think I'm not seeing the extended id part in the datasheet I've found so
> might be that you can switch to just INFO and _ext_id 0 above

This was added by commit 6bbe036f32dc ("m25p80: Return the JEDEC ID twice for
mx25l25635e") to fix a real breakage on HW.

Thanks,

C.


  (might be the
> same in the previous patch with the similar flash). Otherwise looks good to
> me:
> 
> Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
> 
> 
>> +      .sfdp_read = m25p80_sfdp_mx25l25635f },
>>       { INFO("mx25l25655e", 0xc22619,      0,  64 << 10, 512, 0) },
>>       { INFO("mx66l51235f", 0xc2201a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
>>       { INFO("mx66u51235f", 0xc2253a,      0,  64 << 10, 1024, ER_4K | ER_32K) },
>> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
>> index 6499c4c39954..70c13aea7c63 100644
>> --- a/hw/block/m25p80_sfdp.c
>> +++ b/hw/block/m25p80_sfdp.c
>> @@ -82,3 +82,71 @@ static const uint8_t sfdp_mx25l25635e[] = {
>>       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>>   };
>>   define_sfdp_read(mx25l25635e)
>> +
>> +static const uint8_t sfdp_mx25l25635f[] = {
>> +    0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff,
>> +    0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff,
>> +    0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f,
>> +    0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb,
>> +    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
>> +    0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52,
>> +    0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64,
>> +    0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xc2, 0xf5, 0x08, 0x0a,
>> +    0x08, 0x04, 0x03, 0x06, 0x00, 0x00, 0x07, 0x29,
>> +    0x17, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
>> +};
>> +define_sfdp_read(mx25l25635f);
>> -- 
>> 2.35.3
>>



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 4/8] m25p80: Add the mx25l25635f SFPD table
  2022-10-10  6:23     ` Cédric Le Goater
@ 2022-10-10  9:58       ` Michael Walle
  2022-10-10 10:51         ` Francisco Iglesias
  2022-10-10 15:00         ` Cédric Le Goater
  0 siblings, 2 replies; 33+ messages in thread
From: Michael Walle @ 2022-10-10  9:58 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Francisco Iglesias, qemu-devel, qemu-arm, qemu-block,
	Peter Maydell, Joel Stanley, Andrew Jeffery, Alistair Francis,
	Iris Chen

Am 2022-10-10 08:23, schrieb Cédric Le Goater:
> On 10/7/22 16:44, Francisco Iglesias wrote:

>>> --- a/hw/block/m25p80.c
>>> +++ b/hw/block/m25p80.c
>>> @@ -234,6 +234,8 @@ static const FlashPartInfo known_devices[] = {
>>>       { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
>>>       { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 
>>> 0),
>>>         .sfdp_read = m25p80_sfdp_mx25l25635e },
>>> +    { INFO6("mx25l25635f", 0xc22019,     0xc22019,  64 << 10, 512, 
>>> 0),
>> 
>> I think I'm not seeing the extended id part in the datasheet I've 
>> found so
>> might be that you can switch to just INFO and _ext_id 0 above
> 
> This was added by commit 6bbe036f32dc ("m25p80: Return the JEDEC ID 
> twice for
> mx25l25635e") to fix a real breakage on HW.

 From my experience, the ID has a particular length, at least three bytes
and if you read past that length for some (all?) devices the id bytes 
just
get repeated. I.e. the counter in the device will just wrap to offset 0
again. If you want to emulate the hardware correctly, you would have to
take that into consideration.
But I don't think it's worth it, OTOH there seems to be some broken
software which rely on that (undefined?) behavior.

-michael


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 4/8] m25p80: Add the mx25l25635f SFPD table
  2022-10-10  9:58       ` Michael Walle
@ 2022-10-10 10:51         ` Francisco Iglesias
  2022-10-10 15:11           ` Cédric Le Goater
  2022-10-10 15:00         ` Cédric Le Goater
  1 sibling, 1 reply; 33+ messages in thread
From: Francisco Iglesias @ 2022-10-10 10:51 UTC (permalink / raw)
  To: Michael Walle
  Cc: Cédric Le Goater, qemu-devel, qemu-arm, qemu-block,
	Peter Maydell, Joel Stanley, Andrew Jeffery, Alistair Francis,
	Iris Chen

Hi  Cedric,

On [2022 Oct 10] Mon 11:58:40, Michael Walle wrote:
> Am 2022-10-10 08:23, schrieb Cédric Le Goater:
> > On 10/7/22 16:44, Francisco Iglesias wrote:
> 
> > > > --- a/hw/block/m25p80.c
> > > > +++ b/hw/block/m25p80.c
> > > > @@ -234,6 +234,8 @@ static const FlashPartInfo known_devices[] = {
> > > >       { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
> > > >       { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10,
> > > > 512, 0),
> > > >         .sfdp_read = m25p80_sfdp_mx25l25635e },
> > > > +    { INFO6("mx25l25635f", 0xc22019,     0xc22019,  64 << 10,
> > > > 512, 0),

I think I missed the (ER_4K | ER_32K) flags above (in case we go for a v4 we 
can add it in). 

> > > 
> > > I think I'm not seeing the extended id part in the datasheet I've
> > > found so
> > > might be that you can switch to just INFO and _ext_id 0 above
> > 
> > This was added by commit 6bbe036f32dc ("m25p80: Return the JEDEC ID
> > twice for
> > mx25l25635e") to fix a real breakage on HW.
> 
> From my experience, the ID has a particular length, at least three bytes
> and if you read past that length for some (all?) devices the id bytes just
> get repeated. I.e. the counter in the device will just wrap to offset 0
> again. If you want to emulate the hardware correctly, you would have to
> take that into consideration.

If we decide to go with Michael's proposal above you can use '0' on the
'extended_id' and enable 's->data_read_loop = true' when reading the ID.

Best regards,
Francisco

> But I don't think it's worth it, OTOH there seems to be some broken
> software which rely on that (undefined?) behavior.
> 
> -michael



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 4/8] m25p80: Add the mx25l25635f SFPD table
  2022-10-10  9:58       ` Michael Walle
  2022-10-10 10:51         ` Francisco Iglesias
@ 2022-10-10 15:00         ` Cédric Le Goater
  1 sibling, 0 replies; 33+ messages in thread
From: Cédric Le Goater @ 2022-10-10 15:00 UTC (permalink / raw)
  To: Michael Walle
  Cc: Francisco Iglesias, qemu-devel, qemu-arm, qemu-block,
	Peter Maydell, Joel Stanley, Andrew Jeffery, Alistair Francis,
	Iris Chen

On 10/10/22 11:58, Michael Walle wrote:
> Am 2022-10-10 08:23, schrieb Cédric Le Goater:
>> On 10/7/22 16:44, Francisco Iglesias wrote:
> 
>>>> --- a/hw/block/m25p80.c
>>>> +++ b/hw/block/m25p80.c
>>>> @@ -234,6 +234,8 @@ static const FlashPartInfo known_devices[] = {
>>>>       { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
>>>>       { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10, 512, 0),
>>>>         .sfdp_read = m25p80_sfdp_mx25l25635e },
>>>> +    { INFO6("mx25l25635f", 0xc22019,     0xc22019,  64 << 10, 512, 0),
>>>
>>> I think I'm not seeing the extended id part in the datasheet I've found so
>>> might be that you can switch to just INFO and _ext_id 0 above
>>
>> This was added by commit 6bbe036f32dc ("m25p80: Return the JEDEC ID twice for
>> mx25l25635e") to fix a real breakage on HW.
> 
>  From my experience, the ID has a particular length, at least three bytes
> and if you read past that length for some (all?) devices the id bytes just
> get repeated. I.e. the counter in the device will just wrap to offset 0
> again. 
At the time, I did some specific tests on these mx25l25635e chips and
this how they behaved. I can not check anymore as I don't have access
to these systems.

> If you want to emulate the hardware correctly, you would have to
> take that into consideration.

But this is not the case for all chips, most return 0 and don't
wrap around. I just did on w25q512jvq and w25q256 chips with a 6.0.

> But I don't think it's worth it, OTOH there seems to be some broken
> software which rely on that (undefined?) behavior.

I can't really tell :/ The driver (kernel based Linux 2.6.28) reads
4 bytes and expect the last to be the Manufacturer id: 0xC2. That's
valid for this chip.

Setting an extended ID in the flash info is an alternative :

   { INFO("mx25l25635e", 0xc22019,     0xc200,  ...

which does not seem to break other machines using mx25l25635e, with
recent kernels at least.

To reproduce, grab :

   http://smbserver.frankfurt.de.velia.net/ipmi/SMT_X11_158.bin

Run :

   qemu-system-arm -M supermicrox11-bmc -nic user -drive file=./SMT_X11_158.bin,format=raw,if=mtd -nographic -serial mon:stdio
   ...
   BMC flash ID:0xc21920c2
    platform_flash: MX25L25635E (32768 Kbytes)
   Creating 7 MTD partitions on "spi0.0":
   ...

C.


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 4/8] m25p80: Add the mx25l25635f SFPD table
  2022-10-10 10:51         ` Francisco Iglesias
@ 2022-10-10 15:11           ` Cédric Le Goater
  0 siblings, 0 replies; 33+ messages in thread
From: Cédric Le Goater @ 2022-10-10 15:11 UTC (permalink / raw)
  To: Francisco Iglesias, Michael Walle
  Cc: qemu-devel, qemu-arm, qemu-block, Peter Maydell, Joel Stanley,
	Andrew Jeffery, Alistair Francis, Iris Chen

On 10/10/22 12:51, Francisco Iglesias wrote:
> Hi  Cedric,
> 
> On [2022 Oct 10] Mon 11:58:40, Michael Walle wrote:
>> Am 2022-10-10 08:23, schrieb Cédric Le Goater:
>>> On 10/7/22 16:44, Francisco Iglesias wrote:
>>
>>>>> --- a/hw/block/m25p80.c
>>>>> +++ b/hw/block/m25p80.c
>>>>> @@ -234,6 +234,8 @@ static const FlashPartInfo known_devices[] = {
>>>>>        { INFO("mx25l12855e", 0xc22618,      0,  64 << 10, 256, 0) },
>>>>>        { INFO6("mx25l25635e", 0xc22019,     0xc22019,  64 << 10,
>>>>> 512, 0),
>>>>>          .sfdp_read = m25p80_sfdp_mx25l25635e },
>>>>> +    { INFO6("mx25l25635f", 0xc22019,     0xc22019,  64 << 10,
>>>>> 512, 0),
> 
> I think I missed the (ER_4K | ER_32K) flags above (in case we go for a v4 we
> can add it in).

sure.

>>>>
>>>> I think I'm not seeing the extended id part in the datasheet I've
>>>> found so
>>>> might be that you can switch to just INFO and _ext_id 0 above
>>>
>>> This was added by commit 6bbe036f32dc ("m25p80: Return the JEDEC ID
>>> twice for
>>> mx25l25635e") to fix a real breakage on HW.
>>
>>  From my experience, the ID has a particular length, at least three bytes
>> and if you read past that length for some (all?) devices the id bytes just
>> get repeated. I.e. the counter in the device will just wrap to offset 0
>> again. If you want to emulate the hardware correctly, you would have to
>> take that into consideration.
> 
> If we decide to go with Michael's proposal above you can use '0' on the
> 'extended_id' and enable 's->data_read_loop = true' when reading the ID.

This part :

             for (; i < SPI_NOR_MAX_ID_LEN; i++) {
                 s->data[i] = 0;
             }

will fill the remaining JEDEC ID bytes with zeros which is not what we
want for the mx25l25635e chip.

Thanks,
C.

> Best regards,
> Francisco
> 
>> But I don't think it's worth it, OTOH there seems to be some broken
>> software which rely on that (undefined?) behavior.
>>
>> -michael
> 



^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2022-10-10 15:26 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
2022-07-22  6:35 ` [PATCH v3 1/8] m25p80: Add basic support for the SFDP command Cédric Le Goater
2022-07-22 10:02   ` Francisco Iglesias
2022-07-22  6:35 ` [PATCH v3 2/8] m25p80: Add the n25q256a SFDP table Cédric Le Goater
2022-10-07 14:03   ` Francisco Iglesias
2022-10-10  6:15     ` Cédric Le Goater
2022-07-22  6:35 ` [PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
2022-10-07 13:59   ` Francisco Iglesias
2022-10-10  6:09     ` Cédric Le Goater
2022-07-22  6:35 ` [PATCH v3 4/8] m25p80: Add the mx25l25635f " Cédric Le Goater
2022-10-07 14:44   ` Francisco Iglesias
2022-10-10  6:23     ` Cédric Le Goater
2022-10-10  9:58       ` Michael Walle
2022-10-10 10:51         ` Francisco Iglesias
2022-10-10 15:11           ` Cédric Le Goater
2022-10-10 15:00         ` Cédric Le Goater
2022-07-22  6:35 ` [PATCH v3 5/8] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
2022-10-07 14:59   ` Francisco Iglesias
2022-07-22  6:36 ` [PATCH v3 6/8] m25p80: Add the w25q256 SFPD table Cédric Le Goater
2022-10-07 15:13   ` Francisco Iglesias
2022-07-22  6:36 ` [PATCH v3 7/8] m25p80: Add the w25q512jv " Cédric Le Goater
2022-10-07 15:14   ` Francisco Iglesias
2022-07-22  6:36 ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
2022-07-25  2:08   ` Andrew Jeffery
2022-07-25  6:32     ` Cédric Le Goater
2022-07-25  6:34       ` Andrew Jeffery
2022-10-06 22:44   ` [PATCH] m25p80: Add the w25q01jvq SFPD table Patrick Williams
2022-10-07 15:24     ` Francisco Iglesias
2022-10-07 14:04   ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Francisco Iglesias
2022-07-22  7:05 ` [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
2022-07-22  8:06   ` Ben Dooks
2022-07-22  8:14     ` Cédric Le Goater
2022-10-06 22:49 ` Patrick Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).