qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] m25p80: Add SFDP support
@ 2020-08-27  9:11 Cédric Le Goater
  2020-08-27  9:11 ` [PATCH 1/2] m25p80: Add basic support for the SFDP command Cédric Le Goater
  2020-08-27  9:11 ` [PATCH 2/2] m25p80: Add the n25q256a SFDP table Cédric Le Goater
  0 siblings, 2 replies; 7+ messages in thread
From: Cédric Le Goater @ 2020-08-27  9:11 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 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

-- 
2.25.4



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

* [PATCH 1/2] m25p80: Add basic support for the SFDP command
  2020-08-27  9:11 [PATCH 0/2] m25p80: Add SFDP support Cédric Le Goater
@ 2020-08-27  9:11 ` Cédric Le Goater
  2020-09-01 13:36   ` Francisco Iglesias
  2020-08-27  9:11 ` [PATCH 2/2] m25p80: Add the n25q256a SFDP table Cédric Le Goater
  1 sibling, 1 reply; 7+ messages in thread
From: Cédric Le Goater @ 2020-08-27  9:11 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'
pointer under FlashPartInfo.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 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

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
new file mode 100644
index 000000000000..b75fd0b0c13f
--- /dev/null
+++ b/hw/block/m25p80_sfdp.h
@@ -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
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 82270884416e..32925589ec7a 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;
+    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:
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] 7+ messages in thread

* [PATCH 2/2] m25p80: Add the n25q256a SFDP table
  2020-08-27  9:11 [PATCH 0/2] m25p80: Add SFDP support Cédric Le Goater
  2020-08-27  9:11 ` [PATCH 1/2] m25p80: Add basic support for the SFDP command Cédric Le Goater
@ 2020-08-27  9:11 ` Cédric Le Goater
  2020-09-01 13:38   ` Francisco Iglesias
  1 sibling, 1 reply; 7+ messages in thread
From: Cédric Le Goater @ 2020-08-27  9:11 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.

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 | 49 ++++++++++++++++++++++++++++++++++++++++++
 hw/block/Makefile.objs |  2 +-
 4 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 hw/block/m25p80_sfdp.c

diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
index b75fd0b0c13f..ca2658a676e0 100644
--- a/hw/block/m25p80_sfdp.h
+++ b/hw/block/m25p80_sfdp.h
@@ -12,4 +12,6 @@
 
 #define M25P80_SFDP_AREA_SIZE 0x100
 
+extern const uint8_t m25p80_sfdp_n25q256a[M25P80_SFDP_AREA_SIZE];
+
 #endif
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 32925589ec7a..d053bdbb2805 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -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) },
diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
new file mode 100644
index 000000000000..def94bd4ea02
--- /dev/null
+++ b/hw/block/m25p80_sfdp.c
@@ -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,
+};
diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs
index 8855c2265639..b65a12c52b52 100644
--- a/hw/block/Makefile.objs
+++ b/hw/block/Makefile.objs
@@ -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
-- 
2.25.4



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

* Re: [PATCH 1/2] m25p80: Add basic support for the SFDP command
  2020-08-27  9:11 ` [PATCH 1/2] m25p80: Add basic support for the SFDP command Cédric Le Goater
@ 2020-09-01 13:36   ` Francisco Iglesias
  2020-09-01 15:22     ` Cédric Le Goater
  0 siblings, 1 reply; 7+ messages in thread
From: Francisco Iglesias @ 2020-09-01 13:36 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 Aug 27] Thu 11:11:29, Cédric Le Goater wrote:
> JEDEC STANDARD JESD216 for Serial Flash Discovery Parameters (SFDP)
> provides a mean to describe the features of a serial flash device
> using a set of internal parameter tables.
> 
> This is the initial framework for the RDSFDP command giving access to
> a private SFDP area under the flash. This area now needs to be
> populated with the flash device characteristics, using a new 'sfdp'
> pointer under FlashPartInfo.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  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
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> new file mode 100644
> index 000000000000..b75fd0b0c13f
> --- /dev/null
> +++ b/hw/block/m25p80_sfdp.h
> @@ -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
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 82270884416e..32925589ec7a 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;
> +    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) {

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

> +            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 */

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

> +            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:
> 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	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] m25p80: Add the n25q256a SFDP table
  2020-08-27  9:11 ` [PATCH 2/2] m25p80: Add the n25q256a SFDP table Cédric Le Goater
@ 2020-09-01 13:38   ` Francisco Iglesias
  2020-09-01 13:47     ` Cédric Le Goater
  0 siblings, 1 reply; 7+ messages in thread
From: Francisco Iglesias @ 2020-09-01 13:38 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Peter Maydell, Andrew Jeffery, Alistair Francis, qemu-devel,
	qemu-arm, Joel Stanley

Hi Cedric,

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

Best regards,
Francisco 

On [2020 Aug 27] Thu 11:11:30, Cédric Le Goater wrote:
> The same values were collected on 4 differents OpenPower systems,
> palmettos, romulus and tacoma.
> 
> 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 | 49 ++++++++++++++++++++++++++++++++++++++++++
>  hw/block/Makefile.objs |  2 +-
>  4 files changed, 56 insertions(+), 3 deletions(-)
>  create mode 100644 hw/block/m25p80_sfdp.c
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> index b75fd0b0c13f..ca2658a676e0 100644
> --- a/hw/block/m25p80_sfdp.h
> +++ b/hw/block/m25p80_sfdp.h
> @@ -12,4 +12,6 @@
>  
>  #define M25P80_SFDP_AREA_SIZE 0x100
>  
> +extern const uint8_t m25p80_sfdp_n25q256a[M25P80_SFDP_AREA_SIZE];
> +
>  #endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 32925589ec7a..d053bdbb2805 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -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) },
> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
> new file mode 100644
> index 000000000000..def94bd4ea02
> --- /dev/null
> +++ b/hw/block/m25p80_sfdp.c
> @@ -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,
> +};
> diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs
> index 8855c2265639..b65a12c52b52 100644
> --- a/hw/block/Makefile.objs
> +++ b/hw/block/Makefile.objs
> @@ -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
> -- 
> 2.25.4
> 


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

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

On 9/1/20 3:38 PM, Francisco Iglesias wrote:
> 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. 

> Best regards,
> Francisco 
> 
> On [2020 Aug 27] Thu 11:11:30, Cédric Le Goater wrote:
>> The same values were collected on 4 differents OpenPower systems,
>> palmettos, romulus and tacoma.
>>
>> 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 | 49 ++++++++++++++++++++++++++++++++++++++++++
>>  hw/block/Makefile.objs |  2 +-
>>  4 files changed, 56 insertions(+), 3 deletions(-)
>>  create mode 100644 hw/block/m25p80_sfdp.c
>>
>> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
>> index b75fd0b0c13f..ca2658a676e0 100644
>> --- a/hw/block/m25p80_sfdp.h
>> +++ b/hw/block/m25p80_sfdp.h
>> @@ -12,4 +12,6 @@
>>  
>>  #define M25P80_SFDP_AREA_SIZE 0x100
>>  
>> +extern const uint8_t m25p80_sfdp_n25q256a[M25P80_SFDP_AREA_SIZE];
>> +
>>  #endif
>> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
>> index 32925589ec7a..d053bdbb2805 100644
>> --- a/hw/block/m25p80.c
>> +++ b/hw/block/m25p80.c
>> @@ -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) },
>> diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c
>> new file mode 100644
>> index 000000000000..def94bd4ea02
>> --- /dev/null
>> +++ b/hw/block/m25p80_sfdp.c
>> @@ -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,
>> +};
>> diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs
>> index 8855c2265639..b65a12c52b52 100644
>> --- a/hw/block/Makefile.objs
>> +++ b/hw/block/Makefile.objs
>> @@ -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
>> -- 
>> 2.25.4
>>



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

* Re: [PATCH 1/2] m25p80: Add basic support for the SFDP command
  2020-09-01 13:36   ` Francisco Iglesias
@ 2020-09-01 15:22     ` Cédric Le Goater
  0 siblings, 0 replies; 7+ messages in thread
From: Cédric Le Goater @ 2020-09-01 15:22 UTC (permalink / raw)
  To: Francisco Iglesias
  Cc: Peter Maydell, Andrew Jeffery, Alistair Francis, qemu-devel,
	qemu-arm, Joel Stanley

On 9/1/20 3:36 PM, Francisco Iglesias wrote:
> Hi Cedric,
> 
> On [2020 Aug 27] Thu 11:11:29, Cédric Le Goater wrote:
>> JEDEC STANDARD JESD216 for Serial Flash Discovery Parameters (SFDP)
>> provides a mean to describe the features of a serial flash device
>> using a set of internal parameter tables.
>>
>> This is the initial framework for the RDSFDP command giving access to
>> a private SFDP area under the flash. This area now needs to be
>> populated with the flash device characteristics, using a new 'sfdp'
>> pointer under FlashPartInfo.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>  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
>>
>> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
>> new file mode 100644
>> index 000000000000..b75fd0b0c13f
>> --- /dev/null
>> +++ b/hw/block/m25p80_sfdp.h
>> @@ -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
>> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
>> index 82270884416e..32925589ec7a 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;
>> +    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) {
> 
> 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.  

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

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

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

>> +            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 */
> 
> Should above be changed to:
> 
> 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.

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


> Best regards,
> Francisco Iglesias
> 
>> +            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:
>> 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	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-01 16:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-27  9:11 [PATCH 0/2] m25p80: Add SFDP support Cédric Le Goater
2020-08-27  9:11 ` [PATCH 1/2] m25p80: Add basic support for the SFDP command Cédric Le Goater
2020-09-01 13:36   ` Francisco Iglesias
2020-09-01 15:22     ` Cédric Le Goater
2020-08-27  9:11 ` [PATCH 2/2] m25p80: Add the n25q256a SFDP table Cédric Le Goater
2020-09-01 13:38   ` Francisco Iglesias
2020-09-01 13:47     ` Cédric Le Goater

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