diff mbox series

[v2,4/5] hw/block: m25p80: support quad mode for w25q01jvq

Message ID 20240703081623.2740862-5-jamin_lin@aspeedtech.com (mailing list archive)
State New, archived
Headers show
Series support AST2700 network | expand

Commit Message

Jamin Lin July 3, 2024, 8:16 a.m. UTC
According to the w25q01jv datasheet at page 16,
it is required to set QE bit in "Status Register 2".
Besides, users are able to utilize "Write Status Register 1(0x01)"
command to set QE bit in "Status Register 2" and
utilize "Read Status Register 2(0x35)" command to get the QE bit status.

To support quad mode for w25q01jvq, update collecting data needed
2 bytes for WRSR command in decode_new_cmd function and
verify QE bit at the second byte of collecting data bit 2
in complete_collecting_data.

Update RDCR_EQIO command to set bit 2 of return data
if quad mode enable in decode_new_cmd.

Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/block/m25p80.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Cédric Le Goater July 3, 2024, 9:15 a.m. UTC | #1
On 7/3/24 10:16 AM, Jamin Lin wrote:
> According to the w25q01jv datasheet at page 16,
> it is required to set QE bit in "Status Register 2".
> Besides, users are able to utilize "Write Status Register 1(0x01)"
> command to set QE bit in "Status Register 2" and
> utilize "Read Status Register 2(0x35)" command to get the QE bit status.
> 
> To support quad mode for w25q01jvq, update collecting data needed
> 2 bytes for WRSR command in decode_new_cmd function and
> verify QE bit at the second byte of collecting data bit 2
> in complete_collecting_data.
> 
> Update RDCR_EQIO command to set bit 2 of return data
> if quad mode enable in decode_new_cmd.
> 
> Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


> ---
>   hw/block/m25p80.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
> 
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 8dec134832..9e99107b42 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -416,6 +416,7 @@ typedef enum {
>       /*
>        * Micron: 0x35 - enable QPI
>        * Spansion: 0x35 - read control register
> +     * Winbond: 0x35 - quad enable
>        */
>       RDCR_EQIO = 0x35,
>       RSTQIO = 0xf5,
> @@ -798,6 +799,11 @@ static void complete_collecting_data(Flash *s)
>                   s->four_bytes_address_mode = extract32(s->data[1], 5, 1);
>               }
>               break;
> +        case MAN_WINBOND:
> +            if (s->len > 1) {
> +                s->quad_enable = !!(s->data[1] & 0x02);
> +            }
> +            break;
>           default:
>               break;
>           }
> @@ -1254,6 +1260,10 @@ static void decode_new_cmd(Flash *s, uint32_t value)
>               s->needed_bytes = 2;
>               s->state = STATE_COLLECTING_VAR_LEN_DATA;
>               break;
> +        case MAN_WINBOND:
> +            s->needed_bytes = 2;
> +            s->state = STATE_COLLECTING_VAR_LEN_DATA;
> +            break;
>           default:
>               s->needed_bytes = 1;
>               s->state = STATE_COLLECTING_DATA;
> @@ -1431,6 +1441,12 @@ static void decode_new_cmd(Flash *s, uint32_t value)
>           case MAN_MACRONIX:
>               s->quad_enable = true;
>               break;
> +        case MAN_WINBOND:
> +            s->data[0] = (!!s->quad_enable) << 1;
> +            s->pos = 0;
> +            s->len = 1;
> +            s->state = STATE_READING_DATA;
> +            break;
>           default:
>               break;
>           }
diff mbox series

Patch

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 8dec134832..9e99107b42 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -416,6 +416,7 @@  typedef enum {
     /*
      * Micron: 0x35 - enable QPI
      * Spansion: 0x35 - read control register
+     * Winbond: 0x35 - quad enable
      */
     RDCR_EQIO = 0x35,
     RSTQIO = 0xf5,
@@ -798,6 +799,11 @@  static void complete_collecting_data(Flash *s)
                 s->four_bytes_address_mode = extract32(s->data[1], 5, 1);
             }
             break;
+        case MAN_WINBOND:
+            if (s->len > 1) {
+                s->quad_enable = !!(s->data[1] & 0x02);
+            }
+            break;
         default:
             break;
         }
@@ -1254,6 +1260,10 @@  static void decode_new_cmd(Flash *s, uint32_t value)
             s->needed_bytes = 2;
             s->state = STATE_COLLECTING_VAR_LEN_DATA;
             break;
+        case MAN_WINBOND:
+            s->needed_bytes = 2;
+            s->state = STATE_COLLECTING_VAR_LEN_DATA;
+            break;
         default:
             s->needed_bytes = 1;
             s->state = STATE_COLLECTING_DATA;
@@ -1431,6 +1441,12 @@  static void decode_new_cmd(Flash *s, uint32_t value)
         case MAN_MACRONIX:
             s->quad_enable = true;
             break;
+        case MAN_WINBOND:
+            s->data[0] = (!!s->quad_enable) << 1;
+            s->pos = 0;
+            s->len = 1;
+            s->state = STATE_READING_DATA;
+            break;
         default:
             break;
         }