qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw:m25p80: Add STATE_STANDBY command state
@ 2022-06-14 20:02 Dan Zhang
  2022-06-20 11:22 ` Francisco Iglesias
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Zhang @ 2022-06-14 20:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: clg, alistair, andrew, dz4list, frasse.iglesias, hreitz,
	irischenlj, irischenlj, joel, kwolf, lvivier, patrick, pbonzini,
	pdel, peter.maydell, qemu-arm, qemu-block, thuth

HW normally will switch it to stand by mode when receive incorrect
command.
i.e. Macronix MX66L1G45G data sheet section 8 DEVICE OPERATION described
```
2. When an incorrect command is written to this device, it enters
standby mode and stays in standby mode until the next CS# falling edge.
In standby mode, This device's SO pin should be High-Z.
```
Add STATE_STANDBY CMDState and let the device ignore all input and keep
SO as HIZ (output 1)

Signed-off-by: Dan Zhang <dz4list@gmail.com>
---
A usage of this new state can be aborting in HPM checking 
or unknown command code received.

 hw/block/m25p80.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index b6bd430a99..9f89773b11 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -423,6 +423,7 @@ typedef enum {
     STATE_COLLECTING_DATA,
     STATE_COLLECTING_VAR_LEN_DATA,
     STATE_READING_DATA,
+    STATE_STANDBY,
 } CMDState;
 
 typedef enum {
@@ -1472,6 +1473,9 @@ static uint32_t m25p80_transfer8(SSIPeripheral *ss, uint32_t tx)
                           s->cur_addr, (uint8_t)tx);
 
     switch (s->state) {
+    case STATE_STANDBY:
+        r = 0xFFFFFFFF; /* StandBy state SO shall be HiZ */
+        break;
 
     case STATE_PAGE_PROGRAM:
         trace_m25p80_page_program(s, s->cur_addr, (uint8_t)tx);
-- 
2.34.3



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

* Re: [PATCH] hw:m25p80: Add STATE_STANDBY command state
  2022-06-14 20:02 [PATCH] hw:m25p80: Add STATE_STANDBY command state Dan Zhang
@ 2022-06-20 11:22 ` Francisco Iglesias
  0 siblings, 0 replies; 2+ messages in thread
From: Francisco Iglesias @ 2022-06-20 11:22 UTC (permalink / raw)
  To: Dan Zhang
  Cc: qemu-devel, clg, alistair, andrew, hreitz, irischenlj, irischenlj,
	joel, kwolf, lvivier, patrick, pbonzini, pdel, peter.maydell,
	qemu-arm, qemu-block, thuth

Hi Dan,

On [2022 Jun 14] Tue 13:02:05, Dan Zhang wrote:
> HW normally will switch it to stand by mode when receive incorrect
> command.
> i.e. Macronix MX66L1G45G data sheet section 8 DEVICE OPERATION described
> ```
> 2. When an incorrect command is written to this device, it enters
> standby mode and stays in standby mode until the next CS# falling edge.
> In standby mode, This device's SO pin should be High-Z.
> ```
> Add STATE_STANDBY CMDState and let the device ignore all input and keep
> SO as HIZ (output 1)
> 
> Signed-off-by: Dan Zhang <dz4list@gmail.com>
> ---
> A usage of this new state can be aborting in HPM checking 
> or unknown command code received.
> 
>  hw/block/m25p80.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index b6bd430a99..9f89773b11 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -423,6 +423,7 @@ typedef enum {
>      STATE_COLLECTING_DATA,
>      STATE_COLLECTING_VAR_LEN_DATA,
>      STATE_READING_DATA,
> +    STATE_STANDBY,

Should we enter the state also? (Otherwise we will be adding code that is
unused).

>  } CMDState;
>  
>  typedef enum {
> @@ -1472,6 +1473,9 @@ static uint32_t m25p80_transfer8(SSIPeripheral *ss, uint32_t tx)
>                            s->cur_addr, (uint8_t)tx);
>  
>      switch (s->state) {
> +    case STATE_STANDBY:
> +        r = 0xFFFFFFFF; /* StandBy state SO shall be HiZ */

0xFF should be enough here (since we are dealing with 8 bits, e.g.
m25p80_transfer8). More safe is probably to return 0 though and see this as if
a pulldown was connected to the line instead (this because r has been default
to 0 and was the most likely return value before in this situation). If you
would agree we can remove above line.

Thanks,
Best regards,
Francisco Iglesias

> +        break;
>  
>      case STATE_PAGE_PROGRAM:
>          trace_m25p80_page_program(s, s->cur_addr, (uint8_t)tx);
> -- 
> 2.34.3
> 


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

end of thread, other threads:[~2022-06-20 11:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-14 20:02 [PATCH] hw:m25p80: Add STATE_STANDBY command state Dan Zhang
2022-06-20 11:22 ` Francisco Iglesias

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