Skip to contentSkip to conversation

m25p80: Add SFDP support

PATCH Superseded Cédric Le Goater 2 participants 7 messages Aug 27, 2020 – Sep 1, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover m25p80: Add SFDP support

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 and one example for the n25q256a to check this is a good approach.

Thanks,

C.

Cédric Le Goater (2):
m25p80: Add basic support for the SFDP command
m25p80: Add the n25q256a SFDP table

 hw/block/m25p80_sfdp.h | 17 +++++++++++++++
 hw/block/m25p80.c      | 39 +++++++++++++++++++++++++++++++--
 hw/block/m25p80_sfdp.c | 49 ++++++++++++++++++++++++++++++++++++++++++
 hw/block/Makefile.objs |  2 +-
 hw/block/trace-events  |  1 +
 5 files changed, 105 insertions(+), 3 deletions(-)
 create mode 100644 hw/block/m25p80_sfdp.h
 create mode 100644 hw/block/m25p80_sfdp.c
Signature · 1 line
2.25.4
#1 lore raw

PATCH 1/2 m25p80: Add basic support for the SFDP command

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' pointer under FlashPartInfo.

---
 hw/block/m25p80_sfdp.h | 15 +++++++++++++++
 hw/block/m25p80.c      | 33 +++++++++++++++++++++++++++++++++
 hw/block/trace-events  |  1 +
 3 files changed, 49 insertions(+)
 create mode 100644 hw/block/m25p80_sfdp.h
hw/block/m25p80_sfdp.h new file +15 -0
new file mode 100644
index 000000000000..b75fd0b0c13f
@@ -0,0 +1,15 @@
+/*
+ * 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
+
+#define M25P80_SFDP_AREA_SIZE 0x100
+
+#endif
hw/block/m25p80.c +33 -0
index 82270884416e..32925589ec7a 100644
@@ -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;
+    const uint8_t *sfdp;
 } FlashPartInfo;
 
 /* adapted from linux */
@@ -333,6 +335,7 @@ typedef enum {
     BULK_ERASE = 0xc7,
     READ_FSR = 0x70,
     RDCR = 0x15,
+    RDSFDP = 0x5a,
 
     READ = 0x03,
     READ4 = 0x13,
@@ -398,6 +401,7 @@ typedef enum {
     STATE_COLLECTING_DATA,
     STATE_COLLECTING_VAR_LEN_DATA,
     STATE_READING_DATA,
+    STATE_READING_SFDP,
 } CMDState;
 
 typedef enum {
@@ -619,6 +623,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:
@@ -744,6 +750,17 @@ static void complete_collecting_data(Flash *s)
                           " by device\n");
         }
         break;
+
+    case RDSFDP:
+        if (s->cur_addr < M25P80_SFDP_AREA_SIZE) {
+            s->state = STATE_READING_SFDP;
+        } else {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "M25P80: Invalid SFDP address %#" PRIx32 "\n",
+                          s->cur_addr);
+        }
+        break;
+
     default:
         break;
     }
@@ -1160,6 +1177,16 @@ static void decode_new_cmd(Flash *s, uint32_t value)
     case RSTQIO:
         s->quad_enable = false;
         break;
+    case RDSFDP:
+        if (s->pi->sfdp) {
+            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;
@@ -1256,6 +1283,12 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
             }
         }
         break;
+    case STATE_READING_SFDP:
+        assert(s->pi->sfdp);
+        r = s->pi->sfdp[s->cur_addr];
+        trace_m25p80_read_sfdp(s, s->cur_addr, (uint8_t)r);
+        s->cur_addr = (s->cur_addr + 1) & (M25P80_SFDP_AREA_SIZE - 1);
+        break;
 
     default:
     case STATE_IDLE:
hw/block/trace-events +1 -0
index 958fcc5508d1..53d377ca2b46 100644
@@ -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"
Signature · 1 line
2.25.4
#2 lore raw

Re: [PATCH 1/2] m25p80: Add basic support for the SFDP command

Hi Cedric,

Quoted 84 lines · 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' pointer under FlashPartInfo.

---
 hw/block/m25p80_sfdp.h | 15 +++++++++++++++
 hw/block/m25p80.c      | 33 +++++++++++++++++++++++++++++++++
 hw/block/trace-events  |  1 +
 3 files changed, 49 insertions(+)
 create mode 100644 hw/block/m25p80_sfdp.h
hw/block/m25p80_sfdp.h new file +15 -0
new file mode 100644
index 000000000000..b75fd0b0c13f
@@ -0,0 +1,15 @@
+/*
+ * 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
+
+#define M25P80_SFDP_AREA_SIZE 0x100
+
+#endif
hw/block/m25p80.c +6 -0
index 82270884416e..32925589ec7a 100644
@@ -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;
+    const uint8_t *sfdp;
 } FlashPartInfo;
 
 /* adapted from linux */
@@ -333,6 +335,7 @@ typedef enum {
     BULK_ERASE = 0xc7,
     READ_FSR = 0x70,
     RDCR = 0x15,
+    RDSFDP = 0x5a,
 
     READ = 0x03,
     READ4 = 0x13,
@@ -398,6 +401,7 @@ typedef enum {
     STATE_COLLECTING_DATA,
     STATE_COLLECTING_VAR_LEN_DATA,
     STATE_READING_DATA,
+    STATE_READING_SFDP,
 } CMDState;
 
 typedef enum {
@@ -619,6 +623,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:

hw/block/m25p80.c static void complete_collecting_data(Flash *s) · line 755

Quoted 6 lines
hw/block/m25p80.c +3 -0
@@ -744,6 +750,17 @@ static void complete_collecting_data(Flash *s)
                           " by device\n");
         }
         break;
+
+    case RDSFDP:
+        if (s->cur_addr < M25P80_SFDP_AREA_SIZE) {

Is perhaps M25P80_SFDP_AREA_SIZE a limit for the micron flashes in patch 2 (and not sfdp)? An option might be to change .sfdp to a '.sfdp_read' function decoding the address internally (for the micron flashes it could just return the array value in case the address is less than M25P80_SFDP_AREA_SIZE or 0xFF else). It might become easier to add flashes containing parameter tables in higher addresses (the function could then decode the address into a specific table/area).

Quoted 12 lines
hw/block/m25p80.c +8 -0
+            s->state = STATE_READING_SFDP;
+        } else {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "M25P80: Invalid SFDP address %#" PRIx32 "\n",
+                          s->cur_addr);
+        }
+        break;
+
     default:
         break;
     }

hw/block/m25p80.c static void decode_new_cmd(Flash *s, uint32_t value) · line 1182

Quoted 6 lines
hw/block/m25p80.c +3 -0
@@ -1160,6 +1177,16 @@ static void decode_new_cmd(Flash *s, uint32_t value)
     case RSTQIO:
         s->quad_enable = false;
         break;
+    case RDSFDP:
+        if (s->pi->sfdp) {
+            s->needed_bytes = get_addr_length(s) + 1 ; /* SFDP addr + dummy */

Should above be changed to:

s->needed_bytes = get_addr_length(s) + 8; /* SFDP addr + dummy */

(I think it might fail else when the flashes are operating in 2 lines and 4 lines and are generating 8 dummy cycles for the RDSFDP)

Best regards,
Francisco Iglesias

Quoted 37 lines
hw/block/m25p80.c +13 -0
+            s->pos = 0;
+            s->len = 0;
+            s->state = STATE_COLLECTING_DATA;
+            break;
+        }
+        /* Fallthrough */
+
     default:
         s->pos = 0;
         s->len = 1;
@@ -1256,6 +1283,12 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
             }
         }
         break;
+    case STATE_READING_SFDP:
+        assert(s->pi->sfdp);
+        r = s->pi->sfdp[s->cur_addr];
+        trace_m25p80_read_sfdp(s, s->cur_addr, (uint8_t)r);
+        s->cur_addr = (s->cur_addr + 1) & (M25P80_SFDP_AREA_SIZE - 1);
+        break;
 
     default:
     case STATE_IDLE:
hw/block/trace-events +1 -0
index 958fcc5508d1..53d377ca2b46 100644
@@ -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"
Signature · 1 line
2.25.4
#3 lore raw

Re: [PATCH 1/2] m25p80: Add basic support for the SFDP command

Quoted 80 lines · Francisco Iglesias

Hi Cedric,

Quoted 77 lines · 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' pointer under FlashPartInfo.

---
 hw/block/m25p80_sfdp.h | 15 +++++++++++++++
 hw/block/m25p80.c      | 33 +++++++++++++++++++++++++++++++++
 hw/block/trace-events  |  1 +
 3 files changed, 49 insertions(+)
 create mode 100644 hw/block/m25p80_sfdp.h
hw/block/m25p80_sfdp.h new file +15 -0
new file mode 100644
index 000000000000..b75fd0b0c13f
@@ -0,0 +1,15 @@
+/*
+ * 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
+
+#define M25P80_SFDP_AREA_SIZE 0x100
+
+#endif
hw/block/m25p80.c +4 -0
index 82270884416e..32925589ec7a 100644
@@ -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;
+    const uint8_t *sfdp;
 } FlashPartInfo;
 
 /* adapted from linux */
@@ -333,6 +335,7 @@ typedef enum {
     BULK_ERASE = 0xc7,
     READ_FSR = 0x70,
     RDCR = 0x15,
+    RDSFDP = 0x5a,
 
     READ = 0x03,
     READ4 = 0x13,
@@ -398,6 +401,7 @@ typedef enum {
     STATE_COLLECTING_DATA,
     STATE_COLLECTING_VAR_LEN_DATA,
     STATE_READING_DATA,
+    STATE_READING_SFDP,
 } CMDState;
 
 typedef enum {
@@ -619,6 +623,8 @@ static inline int get_addr_length(Flash *s)
     }
 
Quoted 16 lines

hw/block/m25p80.c static void complete_collecting_data(Flash *s) · line 755

Quoted 13 lines
hw/block/m25p80.c +5 -0
    switch (s->cmd_in_progress) {
+   case RDSFDP:
+       return 3;
    case PP4:
    case PP4_4:
    case QPP_4:
@@ -744,6 +750,17 @@ static void complete_collecting_data(Flash *s)
                           " by device\n");
         }
         break;
+
+    case RDSFDP:
+        if (s->cur_addr < M25P80_SFDP_AREA_SIZE) {

Is perhaps M25P80_SFDP_AREA_SIZE a limit for the micron flashes in patch 2 (and not sfdp)?

No. It's a common limit of the chips available on the systems I have access to. Nothing is said in the specs on a maximum size and only one table is required. But, theoretically, we have a 24bits address space.

Quoted 3 lines

An option might be to change .sfdp to a '.sfdp_read' function decoding the address internally (for the micron flashes it could just return the array value in case the address is less than M25P80_SFDP_AREA_SIZE

Yes. This is one way to make the SFDP table size depend on the chip model.

Quoted 1 line

or 0xFF else).

Some flash seems to wrap around when the max size is reached. See the mx25l25635e in my git tree. But I have only read 0x100 bytes.

Quoted 3 lines

It might become easier
to add flashes containing parameter tables in higher addresses (the function could then decode the address into a specific table/area).

yes. Something like that.

Quoted 21 lines
Quoted 12 lines
hw/block/m25p80.c +8 -0
+            s->state = STATE_READING_SFDP;
+        } else {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "M25P80: Invalid SFDP address %#" PRIx32 "\n",
+                          s->cur_addr);
+        }
+        break;
+
     default:
         break;
     }

hw/block/m25p80.c static void decode_new_cmd(Flash *s, uint32_t value) · line 1182

Quoted 6 lines
hw/block/m25p80.c +3 -0
@@ -1160,6 +1177,16 @@ static void decode_new_cmd(Flash *s, uint32_t value)
     case RSTQIO:
         s->quad_enable = false;
         break;
+    case RDSFDP:
+        if (s->pi->sfdp) {
+            s->needed_bytes = get_addr_length(s) + 1 ; /* SFDP addr + dummy */

Should above be changed to:

Quoted 1 line

s->needed_bytes = get_addr_length(s) + 8; /* SFDP addr + dummy */

oops. I have been lucky. I need to change the Aspeed SMC snooping routine to compute the number of dummies for the RDSFDP command.

Quoted 2 lines

(I think it might fail else when the flashes are operating in 2 lines and 4 lines and are generating 8 dummy cycles for the RDSFDP)

The specs say that the requirement are independent of the I/O mode.

4.5 Instruction Input Modes

The Read SFDP instruction can be used with device supported modes of (1-1-1), (2-2-2), or (4-4-4), but the opcode (0x5A), address (24 bits), eight dummy clocks (8 wait states), and 50 MHz requirements remain the same.

Thanks,

C.

Quoted 40 lines

Best regards,
Francisco Iglesias

Quoted 37 lines
hw/block/m25p80.c +13 -0
+            s->pos = 0;
+            s->len = 0;
+            s->state = STATE_COLLECTING_DATA;
+            break;
+        }
+        /* Fallthrough */
+
     default:
         s->pos = 0;
         s->len = 1;
@@ -1256,6 +1283,12 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
             }
         }
         break;
+    case STATE_READING_SFDP:
+        assert(s->pi->sfdp);
+        r = s->pi->sfdp[s->cur_addr];
+        trace_m25p80_read_sfdp(s, s->cur_addr, (uint8_t)r);
+        s->cur_addr = (s->cur_addr + 1) & (M25P80_SFDP_AREA_SIZE - 1);
+        break;
 
     default:
     case STATE_IDLE:
hw/block/trace-events +1 -0
index 958fcc5508d1..53d377ca2b46 100644
@@ -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"
Signature · 1 line
2.25.4
#4 lore raw

PATCH 2/2 m25p80: Add the n25q256a SFDP table

In reply to Cédric Le Goater

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

---
 hw/block/m25p80_sfdp.h |  2 ++
 hw/block/m25p80.c      |  6 ++++--
 hw/block/m25p80_sfdp.c | 49 ++++++++++++++++++++++++++++++++++++++++++
 hw/block/Makefile.objs |  2 +-
 4 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 hw/block/m25p80_sfdp.c
hw/block/m25p80_sfdp.h +2 -0
index b75fd0b0c13f..ca2658a676e0 100644
@@ -12,4 +12,6 @@
 
 #define M25P80_SFDP_AREA_SIZE 0x100
 
+extern const uint8_t m25p80_sfdp_n25q256a[M25P80_SFDP_AREA_SIZE];
+
 #endif
hw/block/m25p80.c +4 -2
index 32925589ec7a..d053bdbb2805 100644
@@ -233,11 +233,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 = 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 = m25p80_sfdp_n25q256a },
     { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
     { INFO_STACKED("n25q00",    0x20ba21, 0x1000, 64 << 10, 2048, ER_4K, 4) },
     { INFO_STACKED("n25q00a",   0x20bb21, 0x1000, 64 << 10, 2048, ER_4K, 4) },
hw/block/m25p80_sfdp.c new file +49 -0

49 lines not on this page · raw message

hw/block/Makefile.objs +1 -1
index 8855c2265639..b65a12c52b52 100644
@@ -1,6 +1,6 @@
 common-obj-y += block.o cdrom.o hd-geometry.o
 common-obj-$(CONFIG_FDC) += fdc.o
-common-obj-$(CONFIG_SSI_M25P80) += m25p80.o
+common-obj-$(CONFIG_SSI_M25P80) += m25p80.o m25p80_sfdp.o
 common-obj-$(CONFIG_NAND) += nand.o
 common-obj-$(CONFIG_PFLASH_CFI01) += pflash_cfi01.o
 common-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o
Signature · 1 line
2.25.4
#5 lore raw

Re: [PATCH 2/2] m25p80: Add the n25q256a SFDP table

Hi Cedric,

We need to rebase the patch and modify for meson build (I wasn't able to apply it).

Best regards,
Francisco

Quoted 113 lines · Cédric Le Goater

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

---
 hw/block/m25p80_sfdp.h |  2 ++
 hw/block/m25p80.c      |  6 ++++--
 hw/block/m25p80_sfdp.c | 49 ++++++++++++++++++++++++++++++++++++++++++
 hw/block/Makefile.objs |  2 +-
 4 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 hw/block/m25p80_sfdp.c
hw/block/m25p80_sfdp.h +2 -0
index b75fd0b0c13f..ca2658a676e0 100644
@@ -12,4 +12,6 @@
 
 #define M25P80_SFDP_AREA_SIZE 0x100
 
+extern const uint8_t m25p80_sfdp_n25q256a[M25P80_SFDP_AREA_SIZE];
+
 #endif
hw/block/m25p80.c +4 -2
index 32925589ec7a..d053bdbb2805 100644
@@ -233,11 +233,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 = 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 = m25p80_sfdp_n25q256a },
     { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
     { INFO_STACKED("n25q00",    0x20ba21, 0x1000, 64 << 10, 2048, ER_4K, 4) },
     { INFO_STACKED("n25q00a",   0x20bb21, 0x1000, 64 << 10, 2048, ER_4K, 4) },
hw/block/m25p80_sfdp.c new file +49 -0
new file mode 100644
index 000000000000..def94bd4ea02
@@ -0,0 +1,49 @@
+/*
+ * 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 "m25p80_sfdp.h"
+
+/*
+ * Micron
+ */
+const uint8_t m25p80_sfdp_n25q256a[M25P80_SFDP_AREA_SIZE] = {
+    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,
+};
hw/block/Makefile.objs +1 -1
index 8855c2265639..b65a12c52b52 100644
@@ -1,6 +1,6 @@
 common-obj-y += block.o cdrom.o hd-geometry.o
 common-obj-$(CONFIG_FDC) += fdc.o
-common-obj-$(CONFIG_SSI_M25P80) += m25p80.o
+common-obj-$(CONFIG_SSI_M25P80) += m25p80.o m25p80_sfdp.o
 common-obj-$(CONFIG_NAND) += nand.o
 common-obj-$(CONFIG_PFLASH_CFI01) += pflash_cfi01.o
 common-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o
Signature · 1 line
2.25.4
#6 lore raw

Re: [PATCH 2/2] m25p80: Add the n25q256a SFDP table

Quoted 4 lines · Francisco Iglesias

Hi Cedric,

We need to rebase the patch and modify for meson build (I wasn't able to apply it).

Yes. You will find the patches and more support on my aspeed branch :

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

23c93a8f69c8 m25p80: Add the w25q512jv SFPD table 51c73585a3a0 m25p80: Add the w25q256 SFPD table c1d31a41dd38 m25p80: Add the mx66l1g45g SFDP table 4c66b8670fe2 m25p80: Add the mx25l25635f SFPD table 070620851124 m25p80: Add the mx25l25635e SFPD table a51a58218157 m25p80: Add the n25q256a SFDP table bd6574bba30a m25p80: Add basic support for the SFDP command

Thanks,

C.

Quoted 117 lines

Best regards,
Francisco

Quoted 113 lines · Cédric Le Goater

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

---
 hw/block/m25p80_sfdp.h |  2 ++
 hw/block/m25p80.c      |  6 ++++--
 hw/block/m25p80_sfdp.c | 49 ++++++++++++++++++++++++++++++++++++++++++
 hw/block/Makefile.objs |  2 +-
 4 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 hw/block/m25p80_sfdp.c
hw/block/m25p80_sfdp.h +2 -0
index b75fd0b0c13f..ca2658a676e0 100644
@@ -12,4 +12,6 @@
 
 #define M25P80_SFDP_AREA_SIZE 0x100
 
+extern const uint8_t m25p80_sfdp_n25q256a[M25P80_SFDP_AREA_SIZE];
+
 #endif
hw/block/m25p80.c +4 -2
index 32925589ec7a..d053bdbb2805 100644
@@ -233,11 +233,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 = 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 = m25p80_sfdp_n25q256a },
     { INFO("n25q512a",    0x20ba20,      0,  64 << 10, 1024, ER_4K) },
     { INFO_STACKED("n25q00",    0x20ba21, 0x1000, 64 << 10, 2048, ER_4K, 4) },
     { INFO_STACKED("n25q00a",   0x20bb21, 0x1000, 64 << 10, 2048, ER_4K, 4) },
hw/block/m25p80_sfdp.c new file +49 -0
new file mode 100644
index 000000000000..def94bd4ea02
@@ -0,0 +1,49 @@
+/*
+ * 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 "m25p80_sfdp.h"
+
+/*
+ * Micron
+ */
+const uint8_t m25p80_sfdp_n25q256a[M25P80_SFDP_AREA_SIZE] = {
+    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,
+};
hw/block/Makefile.objs +1 -1
index 8855c2265639..b65a12c52b52 100644
@@ -1,6 +1,6 @@
 common-obj-y += block.o cdrom.o hd-geometry.o
 common-obj-$(CONFIG_FDC) += fdc.o
-common-obj-$(CONFIG_SSI_M25P80) += m25p80.o
+common-obj-$(CONFIG_SSI_M25P80) += m25p80.o m25p80_sfdp.o
 common-obj-$(CONFIG_NAND) += nand.o
 common-obj-$(CONFIG_PFLASH_CFI01) += pflash_cfi01.o
 common-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o
Signature · 1 line
2.25.4