All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/9] 5p80: Add SFDP support
@ 2020-09-02  9:30 Cédric Le Goater
  2020-09-02  9:30 ` [PATCH v2 1/9] m25p80: Add basic support for the SFDP command Cédric Le Goater
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, Cédric Le Goater

Hello,

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. 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.

This is the initial framework for the RDSFDP command giving access to
a private SFDP area under the flash.

The patches available here :

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

Thanks,

C.

Changes in v2:

 - fixed dummy value
 - replaced  'sfdp' table by a 'sfdp_read' handler
 - more SFDP tables
 - fixed Aspeed SMC support
 - introduced mx25l25635f chip model for test under Linux.

Cédric Le Goater (9):
  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
  aspeed/smc: Add support for RDSFDP command

 hw/block/m25p80_sfdp.h      |  27 ++++
 include/hw/ssi/aspeed_smc.h |   1 +
 hw/arm/aspeed.c             |   6 +-
 hw/block/m25p80.c           |  47 +++++-
 hw/block/m25p80_sfdp.c      | 296 ++++++++++++++++++++++++++++++++++++
 hw/ssi/aspeed_smc.c         |  21 ++-
 MAINTAINERS                 |   2 +-
 hw/block/meson.build        |   1 +
 hw/block/trace-events       |   1 +
 9 files changed, 385 insertions(+), 17 deletions(-)
 create mode 100644 hw/block/m25p80_sfdp.h
 create mode 100644 hw/block/m25p80_sfdp.c

-- 
2.25.4



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

* [PATCH v2 1/9] m25p80: Add basic support for the SFDP command
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
@ 2020-09-02  9:30 ` Cédric Le Goater
  2020-09-02  9:31 ` [PATCH v2 2/9] m25p80: Add the n25q256a SFDP table Cédric Le Goater
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, 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 15824450cd10..4d6133b3594e 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -33,6 +33,7 @@
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "trace.h"
+#include "m25p80_sfdp.h"
 
 /* Fields for FlashPartInfo->flags */
 
@@ -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 */
@@ -336,6 +338,7 @@ typedef enum {
     BULK_ERASE = 0xc7,
     READ_FSR = 0x70,
     RDCR = 0x15,
+    RDSFDP = 0x5a,
 
     READ = 0x03,
     READ4 = 0x13,
@@ -401,6 +404,7 @@ typedef enum {
     STATE_COLLECTING_DATA,
     STATE_COLLECTING_VAR_LEN_DATA,
     STATE_READING_DATA,
+    STATE_READING_SFDP,
 } CMDState;
 
 typedef enum {
@@ -622,6 +626,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:
@@ -747,6 +753,11 @@ static void complete_collecting_data(Flash *s)
                           " by device\n");
         }
         break;
+
+    case RDSFDP:
+        s->state = STATE_READING_SFDP;
+        break;
+
     default:
         break;
     }
@@ -1163,6 +1174,16 @@ static void decode_new_cmd(Flash *s, uint32_t value)
     case RSTQIO:
         s->quad_enable = false;
         break;
+    case RDSFDP:
+        if (s->pi->sfdp_read) {
+            s->needed_bytes = get_addr_length(s) + 8 ; /* SFDP addr + dummy */
+            s->pos = 0;
+            s->len = 0;
+            s->state = STATE_COLLECTING_DATA;
+            break;
+        }
+        /* Fallthrough */
+
     default:
         s->pos = 0;
         s->len = 1;
@@ -1259,6 +1280,12 @@ static uint32_t m25p80_transfer8(SSISlave *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 5a22c8be4296..dc8769b8303e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1669,7 +1669,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 958fcc5508d1..53d377ca2b46 100644
--- a/hw/block/trace-events
+++ b/hw/block/trace-events
@@ -152,5 +152,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.25.4



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

* [PATCH v2 2/9] m25p80: Add the n25q256a SFDP table
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
  2020-09-02  9:30 ` [PATCH v2 1/9] m25p80: Add basic support for the SFDP command Cédric Le Goater
@ 2020-09-02  9:31 ` Cédric Le Goater
  2020-09-17 15:10   ` Francisco Iglesias
  2020-09-02  9:31 ` [PATCH v2 3/9] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, 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      |  6 +++--
 hw/block/m25p80_sfdp.c | 58 ++++++++++++++++++++++++++++++++++++++++++
 hw/block/meson.build   |  1 +
 4 files changed, 65 insertions(+), 2 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 4d6133b3594e..dbfd88b41a12 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -234,11 +234,13 @@ 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) },
+    { INFO("n25q256a",    0x20ba19,      0,  64 << 10, 512, ER_4K),
+      .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) },
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 78cad8f7cba1..6f0380a12081 100644
--- a/hw/block/meson.build
+++ b/hw/block/meson.build
@@ -10,6 +10,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_SH4', if_true: files('tc58128.c'))
-- 
2.25.4



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

* [PATCH v2 3/9] m25p80: Add the mx25l25635e SFPD table
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
  2020-09-02  9:30 ` [PATCH v2 1/9] m25p80: Add basic support for the SFDP command Cédric Le Goater
  2020-09-02  9:31 ` [PATCH v2 2/9] m25p80: Add the n25q256a SFDP table Cédric Le Goater
@ 2020-09-02  9:31 ` Cédric Le Goater
  2020-09-02  9:31 ` [PATCH v2 4/9] m25p80: Add the mx25l25635f " Cédric Le Goater
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, 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 dbfd88b41a12..757beab3065f 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -219,7 +219,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.25.4



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

* [PATCH v2 4/9] m25p80: Add the mx25l25635f SFPD table
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
                   ` (2 preceding siblings ...)
  2020-09-02  9:31 ` [PATCH v2 3/9] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
@ 2020-09-02  9:31 ` Cédric Le Goater
  2020-09-02  9:31 ` [PATCH v2 5/9] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, 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 757beab3065f..fe4e8c8716d8 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -221,6 +221,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.25.4



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

* [PATCH v2 5/9] m25p80: Add the mx66l1g45g SFDP table
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
                   ` (3 preceding siblings ...)
  2020-09-02  9:31 ` [PATCH v2 4/9] m25p80: Add the mx25l25635f " Cédric Le Goater
@ 2020-09-02  9:31 ` Cédric Le Goater
  2020-09-02  9:31 ` [PATCH v2 6/9] m25p80: Add the w25q256 SFPD table Cédric Le Goater
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, 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 fe4e8c8716d8..9f1fe01c0d05 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -227,7 +227,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.25.4



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

* [PATCH v2 6/9] m25p80: Add the w25q256 SFPD table
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
                   ` (4 preceding siblings ...)
  2020-09-02  9:31 ` [PATCH v2 5/9] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
@ 2020-09-02  9:31 ` Cédric Le Goater
  2020-09-02  9:31 ` [PATCH v2 7/9] m25p80: Add the w25q512jv " Cédric Le Goater
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, 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 9f1fe01c0d05..b5626a62082a 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -327,7 +327,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) },
 };
 
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.25.4



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

* [PATCH v2 7/9] m25p80: Add the w25q512jv SFPD table
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
                   ` (5 preceding siblings ...)
  2020-09-02  9:31 ` [PATCH v2 6/9] m25p80: Add the w25q256 SFPD table Cédric Le Goater
@ 2020-09-02  9:31 ` Cédric Le Goater
  2020-09-02  9:31 ` [PATCH v2 8/9] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, 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 b5626a62082a..4f41a68f741c 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -329,7 +329,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 },
 };
 
 typedef enum {
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.25.4



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

* [PATCH v2 8/9] arm/aspeed: Replace mx25l25635e chip model
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
                   ` (6 preceding siblings ...)
  2020-09-02  9:31 ` [PATCH v2 7/9] m25p80: Add the w25q512jv " Cédric Le Goater
@ 2020-09-02  9:31 ` Cédric Le Goater
  2020-09-17 14:52   ` Francisco Iglesias
  2020-09-02  9:31 ` [PATCH v2 9/9] aspeed/smc: Add support for RDSFDP command Cédric Le Goater
  2020-10-07  1:43 ` [PATCH v2 0/9] 5p80: Add SFDP support Joel Stanley
  9 siblings, 1 reply; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, 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 8bfb1c79ddc5..df65d949b7e6 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -609,7 +609,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;
@@ -643,7 +643,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 = "w25q256";
-    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;
@@ -710,7 +710,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.25.4



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

* [PATCH v2 9/9] aspeed/smc: Add support for RDSFDP command
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
                   ` (7 preceding siblings ...)
  2020-09-02  9:31 ` [PATCH v2 8/9] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
@ 2020-09-02  9:31 ` Cédric Le Goater
  2020-09-17 14:47   ` Francisco Iglesias
  2020-10-07  1:43 ` [PATCH v2 0/9] 5p80: Add SFDP support Joel Stanley
  9 siblings, 1 reply; 16+ messages in thread
From: Cédric Le Goater @ 2020-09-02  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, qemu-arm, Joel Stanley, Cédric Le Goater

Modify the snooping routine to handle RDSFDP, 1 dummy and 3 bytes
address space.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 include/hw/ssi/aspeed_smc.h |  1 +
 hw/ssi/aspeed_smc.c         | 21 ++++++++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
index 6fbbb238f158..5f477eb9cf97 100644
--- a/include/hw/ssi/aspeed_smc.h
+++ b/include/hw/ssi/aspeed_smc.h
@@ -115,6 +115,7 @@ typedef struct AspeedSMCState {
 
     AspeedSMCFlash *flashes;
 
+    uint8_t snoop_addr_width;
     uint8_t snoop_index;
     uint8_t snoop_dummies;
 } AspeedSMCState;
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 795784e5f364..594f34668e7a 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -778,10 +778,15 @@ typedef enum {
     PP = 0x2,           PP_4 = 0x12,
     DPP = 0xa2,
     QPP = 0x32,         QPP_4 = 0x34,
+    RDSFDP = 0x5a,
 } FlashCMD;
 
-static int aspeed_smc_num_dummies(uint8_t command)
+static int aspeed_smc_num_dummies(AspeedSMCFlash *fl, uint8_t command)
 {
+    AspeedSMCState *s = fl->controller;
+
+    s->snoop_addr_width = aspeed_smc_flash_is_4byte(fl) ? 4 : 3;
+
     switch (command) { /* check for dummies */
     case READ: /* no dummy bytes/cycles */
     case PP:
@@ -798,6 +803,9 @@ static int aspeed_smc_num_dummies(uint8_t command)
     case DOR_4:
     case QOR_4:
         return 1;
+    case RDSFDP:
+        s->snoop_addr_width = 3;
+        return 1;
     case DIOR:
     case DIOR_4:
         return 2;
@@ -813,8 +821,6 @@ static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl,  uint64_t data,
                                 unsigned size)
 {
     AspeedSMCState *s = fl->controller;
-    uint8_t addr_width = aspeed_smc_flash_is_4byte(fl) ? 4 : 3;
-
     trace_aspeed_smc_do_snoop(fl->id, s->snoop_index, s->snoop_dummies,
                               (uint8_t) data & 0xff);
 
@@ -823,7 +829,7 @@ static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl,  uint64_t data,
 
     } else if (s->snoop_index == SNOOP_START) {
         uint8_t cmd = data & 0xff;
-        int ndummies = aspeed_smc_num_dummies(cmd);
+        int ndummies = aspeed_smc_num_dummies(fl, cmd);
 
         /*
          * No dummy cycles are expected with the current command. Turn
@@ -836,7 +842,7 @@ static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl,  uint64_t data,
 
         s->snoop_dummies = ndummies * 8;
 
-    } else if (s->snoop_index >= addr_width + 1) {
+    } else if (s->snoop_index >= s->snoop_addr_width + 1) {
 
         /* The SPI transfer has reached the dummy cycles sequence */
         for (; s->snoop_dummies; s->snoop_dummies--) {
@@ -1407,10 +1413,11 @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp)
 
 static const VMStateDescription vmstate_aspeed_smc = {
     .name = "aspeed.smc",
-    .version_id = 2,
-    .minimum_version_id = 2,
+    .version_id = 3,
+    .minimum_version_id = 3,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, AspeedSMCState, ASPEED_SMC_R_MAX),
+        VMSTATE_UINT8(snoop_addr_width, AspeedSMCState),
         VMSTATE_UINT8(snoop_index, AspeedSMCState),
         VMSTATE_UINT8(snoop_dummies, AspeedSMCState),
         VMSTATE_END_OF_LIST()
-- 
2.25.4



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

* Re: [PATCH v2 9/9] aspeed/smc: Add support for RDSFDP command
  2020-09-02  9:31 ` [PATCH v2 9/9] aspeed/smc: Add support for RDSFDP command Cédric Le Goater
@ 2020-09-17 14:47   ` Francisco Iglesias
  0 siblings, 0 replies; 16+ messages in thread
From: Francisco Iglesias @ 2020-09-17 14:47 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Peter Maydell, Andrew Jeffery, Alistair Francis, qemu-devel,
	qemu-arm, Joel Stanley

Hi Cedric,

On [2020 Sep 02] Wed 11:31:07, Cédric Le Goater wrote:
> Modify the snooping routine to handle RDSFDP, 1 dummy and 3 bytes
> address space.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  include/hw/ssi/aspeed_smc.h |  1 +
>  hw/ssi/aspeed_smc.c         | 21 ++++++++++++++-------
>  2 files changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
> index 6fbbb238f158..5f477eb9cf97 100644
> --- a/include/hw/ssi/aspeed_smc.h
> +++ b/include/hw/ssi/aspeed_smc.h
> @@ -115,6 +115,7 @@ typedef struct AspeedSMCState {
>  
>      AspeedSMCFlash *flashes;
>  
> +    uint8_t snoop_addr_width;
>      uint8_t snoop_index;
>      uint8_t snoop_dummies;
>  } AspeedSMCState;
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index 795784e5f364..594f34668e7a 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -778,10 +778,15 @@ typedef enum {
>      PP = 0x2,           PP_4 = 0x12,
>      DPP = 0xa2,
>      QPP = 0x32,         QPP_4 = 0x34,
> +    RDSFDP = 0x5a,
>  } FlashCMD;
>  
> -static int aspeed_smc_num_dummies(uint8_t command)
> +static int aspeed_smc_num_dummies(AspeedSMCFlash *fl, uint8_t command)

Should the function be renamed to reflect that it also calculates the address
width now? (An alternative could be to create a new function for the address
width calculation)

The patch looks good to me else!

Best regards,
Francisco Iglesias

>  {
> +    AspeedSMCState *s = fl->controller;
> +
> +    s->snoop_addr_width = aspeed_smc_flash_is_4byte(fl) ? 4 : 3;
> +
>      switch (command) { /* check for dummies */
>      case READ: /* no dummy bytes/cycles */
>      case PP:
> @@ -798,6 +803,9 @@ static int aspeed_smc_num_dummies(uint8_t command)
>      case DOR_4:
>      case QOR_4:
>          return 1;
> +    case RDSFDP:
> +        s->snoop_addr_width = 3;
> +        return 1;
>      case DIOR:
>      case DIOR_4:
>          return 2;
> @@ -813,8 +821,6 @@ static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl,  uint64_t data,
>                                  unsigned size)
>  {
>      AspeedSMCState *s = fl->controller;
> -    uint8_t addr_width = aspeed_smc_flash_is_4byte(fl) ? 4 : 3;
> -
>      trace_aspeed_smc_do_snoop(fl->id, s->snoop_index, s->snoop_dummies,
>                                (uint8_t) data & 0xff);
>  
> @@ -823,7 +829,7 @@ static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl,  uint64_t data,
>  
>      } else if (s->snoop_index == SNOOP_START) {
>          uint8_t cmd = data & 0xff;
> -        int ndummies = aspeed_smc_num_dummies(cmd);
> +        int ndummies = aspeed_smc_num_dummies(fl, cmd);
>  
>          /*
>           * No dummy cycles are expected with the current command. Turn
> @@ -836,7 +842,7 @@ static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl,  uint64_t data,
>  
>          s->snoop_dummies = ndummies * 8;
>  
> -    } else if (s->snoop_index >= addr_width + 1) {
> +    } else if (s->snoop_index >= s->snoop_addr_width + 1) {
>  
>          /* The SPI transfer has reached the dummy cycles sequence */
>          for (; s->snoop_dummies; s->snoop_dummies--) {
> @@ -1407,10 +1413,11 @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp)
>  
>  static const VMStateDescription vmstate_aspeed_smc = {
>      .name = "aspeed.smc",
> -    .version_id = 2,
> -    .minimum_version_id = 2,
> +    .version_id = 3,
> +    .minimum_version_id = 3,
>      .fields = (VMStateField[]) {
>          VMSTATE_UINT32_ARRAY(regs, AspeedSMCState, ASPEED_SMC_R_MAX),
> +        VMSTATE_UINT8(snoop_addr_width, AspeedSMCState),
>          VMSTATE_UINT8(snoop_index, AspeedSMCState),
>          VMSTATE_UINT8(snoop_dummies, AspeedSMCState),
>          VMSTATE_END_OF_LIST()
> -- 
> 2.25.4
> 


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

* Re: [PATCH v2 8/9] arm/aspeed: Replace mx25l25635e chip model
  2020-09-02  9:31 ` [PATCH v2 8/9] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
@ 2020-09-17 14:52   ` Francisco Iglesias
  0 siblings, 0 replies; 16+ messages in thread
From: Francisco Iglesias @ 2020-09-17 14:52 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Peter Maydell, Andrew Jeffery, Alistair Francis, qemu-devel,
	qemu-arm, Joel Stanley

On [2020 Sep 02] Wed 11:31: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>

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 8bfb1c79ddc5..df65d949b7e6 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -609,7 +609,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;
> @@ -643,7 +643,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 = "w25q256";
> -    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;
> @@ -710,7 +710,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.25.4
> 


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

* Re: [PATCH v2 2/9] m25p80: Add the n25q256a SFDP table
  2020-09-02  9:31 ` [PATCH v2 2/9] m25p80: Add the n25q256a SFDP table Cédric Le Goater
@ 2020-09-17 15:10   ` Francisco Iglesias
  0 siblings, 0 replies; 16+ messages in thread
From: Francisco Iglesias @ 2020-09-17 15:10 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Peter Maydell, Andrew Jeffery, Alistair Francis, qemu-devel,
	qemu-arm, Joel Stanley

Hi Cedric,

On [2020 Sep 02] Wed 11:31:00, 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      |  6 +++--
>  hw/block/m25p80_sfdp.c | 58 ++++++++++++++++++++++++++++++++++++++++++
>  hw/block/meson.build   |  1 +
>  4 files changed, 65 insertions(+), 2 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);

s/extern//

> +
>  #endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 4d6133b3594e..dbfd88b41a12 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -234,11 +234,13 @@ 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) },
> +    { INFO("n25q256a",    0x20ba19,      0,  64 << 10, 512, ER_4K),
> +      .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) },
> 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,

Looking at the SFDP spec I have it says that reserved locations (unused or not
yet defined memory in the address space) are recommended to return 0xFF. Do you
think we could use that and somehow and return 0xFF by default above instead of
having them in the array? (The file will not grow as fast then)

Best regards,
Francisco Iglesias

> +};
> +define_sfdp_read(n25q256a);
> diff --git a/hw/block/meson.build b/hw/block/meson.build
> index 78cad8f7cba1..6f0380a12081 100644
> --- a/hw/block/meson.build
> +++ b/hw/block/meson.build
> @@ -10,6 +10,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_SH4', if_true: files('tc58128.c'))
> -- 
> 2.25.4
> 


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

* Re: [PATCH v2 0/9] 5p80: Add SFDP support
  2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
                   ` (8 preceding siblings ...)
  2020-09-02  9:31 ` [PATCH v2 9/9] aspeed/smc: Add support for RDSFDP command Cédric Le Goater
@ 2020-10-07  1:43 ` Joel Stanley
  2020-10-07  3:55   ` Joel Stanley
  2020-10-07  6:33   ` Cédric Le Goater
  9 siblings, 2 replies; 16+ messages in thread
From: Joel Stanley @ 2020-10-07  1:43 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, QEMU Developers, qemu-arm

On Wed, 2 Sep 2020 at 09:31, Cédric Le Goater <clg@kaod.org> wrote:
>
> Hello,
>
> 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. 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.
>
> This is the initial framework for the RDSFDP command giving access to
> a private SFDP area under the flash.
>
> The patches available here :
>
>   https://github.com/legoater/qemu/commits/aspeed-5.2

Reviewed-by: Joel Stanley <joel@jms.id.au>
Tested-by: Joel Stanley <joel@jms.id.au>

Note that these need to be rebased on master; there are some minor conflicts.

These patches have proved essential in debugging a recent kernel
regression. Thanks for adding this support Cédric.

Cheers,

Joel

>
> Thanks,
>
> C.
>
> Changes in v2:
>
>  - fixed dummy value
>  - replaced  'sfdp' table by a 'sfdp_read' handler
>  - more SFDP tables
>  - fixed Aspeed SMC support
>  - introduced mx25l25635f chip model for test under Linux.
>
> Cédric Le Goater (9):
>   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
>   aspeed/smc: Add support for RDSFDP command
>
>  hw/block/m25p80_sfdp.h      |  27 ++++
>  include/hw/ssi/aspeed_smc.h |   1 +
>  hw/arm/aspeed.c             |   6 +-
>  hw/block/m25p80.c           |  47 +++++-
>  hw/block/m25p80_sfdp.c      | 296 ++++++++++++++++++++++++++++++++++++
>  hw/ssi/aspeed_smc.c         |  21 ++-
>  MAINTAINERS                 |   2 +-
>  hw/block/meson.build        |   1 +
>  hw/block/trace-events       |   1 +
>  9 files changed, 385 insertions(+), 17 deletions(-)
>  create mode 100644 hw/block/m25p80_sfdp.h
>  create mode 100644 hw/block/m25p80_sfdp.c
>
> --
> 2.25.4
>


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

* Re: [PATCH v2 0/9] 5p80: Add SFDP support
  2020-10-07  1:43 ` [PATCH v2 0/9] 5p80: Add SFDP support Joel Stanley
@ 2020-10-07  3:55   ` Joel Stanley
  2020-10-07  6:33   ` Cédric Le Goater
  1 sibling, 0 replies; 16+ messages in thread
From: Joel Stanley @ 2020-10-07  3:55 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, QEMU Developers, qemu-arm

On Wed, 7 Oct 2020 at 01:43, Joel Stanley <joel@jms.id.au> wrote:
>
> On Wed, 2 Sep 2020 at 09:31, Cédric Le Goater <clg@kaod.org> wrote:
> >
> > Hello,
> >
> > 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. 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.
> >
> > This is the initial framework for the RDSFDP command giving access to
> > a private SFDP area under the flash.
> >
> > The patches available here :
> >
> >   https://github.com/legoater/qemu/commits/aspeed-5.2
>
> Reviewed-by: Joel Stanley <joel@jms.id.au>
> Tested-by: Joel Stanley <joel@jms.id.au>
>
> Note that these need to be rebased on master; there are some minor conflicts.
>
> These patches have proved essential in debugging a recent kernel
> regression. Thanks for adding this support Cédric.

For reference, an OpenBMC UBI based NOR image with an upstream (5.8,
5.9-rc) kernel can be used to reproduce the bug as follows:

qemu-system-arm -M witherspoon-bmc -nic user -nographic \
 -drive file=obmc-phosphor-image-witherspoon.ubi.mtd,format=raw,if=mtd \
 -kernel aspeed-g5-dev/arch/arm/boot/zImage \
 -dtb aspeed-g5-dev/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dtb \
 -append "console=ttyS4,115200n8 ubi.mtd=obmc-ubi,0,0,0
ubi.mtd=alt-obmc-ubi,0,0,4 ro rootfstype=squashfs ubi.block=0,1
root=/dev/ubiblock0_1"

The ubi.mtd can be found here[1].

This assumes you're running qemu with this series applied, and an
upstream kernel built with aspeed_g5_defconfig:

git checkout v5.8
CROSS_COMPILE="ccache arm-linux-gnueabi-" ARCH=arm make -j8
O=aspeed-g5-dev aspeed_g5_defconfig
CROSS_COMPILE="ccache arm-linux-gnueabi-" ARCH=arm make -j8 O=aspeed-g5-dev

The fix for the Linux kernel issue is on the linux-mtd list[2].
WIthout the fix, the kernel will fail to attach the UBI volume:

[    1.453224] ubi0: default fastmap pool size: 25
[    1.453370] ubi0: default fastmap WL pool size: 12
[    1.453505] ubi0: attaching mtd3
[    1.467316] ubi0 error: ubi_compare_lebs: unsupported on-flash UBI format
[    1.467902] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd3, error -22

With the fix, the system will boot through to userspace.

Cheers,

Joel

[1] https://jenkins.openbmc.org/view/latest/job/latest-master/label=docker-builder,target=witherspoon/lastSuccessfulBuild/artifact/openbmc/build/tmp/deploy/images/witherspoon/obmc-phosphor-image-witherspoon.ubi.mtd
[2] https://lore.kernel.org/linux-mtd/CACPK8XceL_QHCQOhfus27rei0vwfRJAFjfL6JkVw9pwxJj2d6Q@mail.gmail.com/



>
> Cheers,
>
> Joel
>
> >
> > Thanks,
> >
> > C.
> >
> > Changes in v2:
> >
> >  - fixed dummy value
> >  - replaced  'sfdp' table by a 'sfdp_read' handler
> >  - more SFDP tables
> >  - fixed Aspeed SMC support
> >  - introduced mx25l25635f chip model for test under Linux.
> >
> > Cédric Le Goater (9):
> >   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
> >   aspeed/smc: Add support for RDSFDP command
> >
> >  hw/block/m25p80_sfdp.h      |  27 ++++
> >  include/hw/ssi/aspeed_smc.h |   1 +
> >  hw/arm/aspeed.c             |   6 +-
> >  hw/block/m25p80.c           |  47 +++++-
> >  hw/block/m25p80_sfdp.c      | 296 ++++++++++++++++++++++++++++++++++++
> >  hw/ssi/aspeed_smc.c         |  21 ++-
> >  MAINTAINERS                 |   2 +-
> >  hw/block/meson.build        |   1 +
> >  hw/block/trace-events       |   1 +
> >  9 files changed, 385 insertions(+), 17 deletions(-)
> >  create mode 100644 hw/block/m25p80_sfdp.h
> >  create mode 100644 hw/block/m25p80_sfdp.c
> >
> > --
> > 2.25.4
> >


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

* Re: [PATCH v2 0/9] 5p80: Add SFDP support
  2020-10-07  1:43 ` [PATCH v2 0/9] 5p80: Add SFDP support Joel Stanley
  2020-10-07  3:55   ` Joel Stanley
@ 2020-10-07  6:33   ` Cédric Le Goater
  1 sibling, 0 replies; 16+ messages in thread
From: Cédric Le Goater @ 2020-10-07  6:33 UTC (permalink / raw)
  To: Joel Stanley
  Cc: Peter Maydell, Andrew Jeffery, Francisco Iglesias,
	Alistair Francis, QEMU Developers, qemu-arm

On 10/7/20 3:43 AM, Joel Stanley wrote:
> On Wed, 2 Sep 2020 at 09:31, Cédric Le Goater <clg@kaod.org> wrote:
>>
>> Hello,
>>
>> 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. 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.
>>
>> This is the initial framework for the RDSFDP command giving access to
>> a private SFDP area under the flash.
>>
>> The patches available here :
>>
>>   https://github.com/legoater/qemu/commits/aspeed-5.2
> 
> Reviewed-by: Joel Stanley <joel@jms.id.au>
> Tested-by: Joel Stanley <joel@jms.id.au>
> 
> Note that these need to be rebased on master; there are some minor conflicts.
> 
> These patches have proved essential in debugging a recent kernel
> regression. Thanks for adding this support Cédric.

We have been discussing offline with Francisco of a more subtle approach 
to reduce the size of the definitions of the SFDP tables. I agree that 
the current approach is brutal (and efficient :) but I haven't had time 
to take a close look at his proposal. See below.

    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;
    }


The SFDP header (SFDP_RAW_WRAP) contains the list of the SFDP tables, 
the first being the BFPT at offset 0x30. It would be nice to be able 
to build the list in the header from the different table definitions.

C.




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

end of thread, other threads:[~2020-10-07  6:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02  9:30 [PATCH v2 0/9] 5p80: Add SFDP support Cédric Le Goater
2020-09-02  9:30 ` [PATCH v2 1/9] m25p80: Add basic support for the SFDP command Cédric Le Goater
2020-09-02  9:31 ` [PATCH v2 2/9] m25p80: Add the n25q256a SFDP table Cédric Le Goater
2020-09-17 15:10   ` Francisco Iglesias
2020-09-02  9:31 ` [PATCH v2 3/9] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
2020-09-02  9:31 ` [PATCH v2 4/9] m25p80: Add the mx25l25635f " Cédric Le Goater
2020-09-02  9:31 ` [PATCH v2 5/9] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
2020-09-02  9:31 ` [PATCH v2 6/9] m25p80: Add the w25q256 SFPD table Cédric Le Goater
2020-09-02  9:31 ` [PATCH v2 7/9] m25p80: Add the w25q512jv " Cédric Le Goater
2020-09-02  9:31 ` [PATCH v2 8/9] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
2020-09-17 14:52   ` Francisco Iglesias
2020-09-02  9:31 ` [PATCH v2 9/9] aspeed/smc: Add support for RDSFDP command Cédric Le Goater
2020-09-17 14:47   ` Francisco Iglesias
2020-10-07  1:43 ` [PATCH v2 0/9] 5p80: Add SFDP support Joel Stanley
2020-10-07  3:55   ` Joel Stanley
2020-10-07  6:33   ` Cédric Le Goater

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.