diff mbox

[8/9] m25p80: Fast read commands family changes.

Message ID 1465998071-7355-9-git-send-email-marcin.krzeminski@nokia.com (mailing list archive)
State New, archived
Headers show

Commit Message

marcin.krzeminski@nokia.com June 15, 2016, 1:41 p.m. UTC
From: Marcin Krzeminski <marcin.krzeminski@nokia.com>

Add support for Spansion and Macronix flashes.
Additionally Numonyx(Micron) move from default
in fast read commands family.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
---
 hw/block/m25p80.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 64 insertions(+), 8 deletions(-)

Comments

Cédric Le Goater June 16, 2016, 7:19 a.m. UTC | #1
On 06/15/2016 03:41 PM, marcin.krzeminski@nokia.com wrote:
> From: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> 
> Add support for Spansion and Macronix flashes.
> Additionally Numonyx(Micron) move from default
> in fast read commands family.

maybe we could start adding sub routines to decode some of the 
larger commands, to ease reading. DIOR and QIOR are good candidates.

C. 

> Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> ---
>  hw/block/m25p80.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 64 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 21998db..7bc0e03 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -758,9 +758,23 @@ static void decode_new_cmd(Flash *s, uint32_t value)
>      case QOR4:
>          s->needed_bytes = get_addr_length(s);
>          switch (get_man(s)) {
> +        /* Dummy cycles - modeled with bytes writes instead of bits */
>          case MAN_NUMONYX:
>              s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
>              break;
> +        case MAN_MACRONIX:
> +            if (extract32(s->volatile_cfg, 6, 2) == 1) {
> +                s->needed_bytes += 6;
> +            } else {
> +                s->needed_bytes += 8;
> +            }
> +            break;
> +        case MAN_SPANSION:
> +            s->needed_bytes += extract32(s->spansion_cr2v,
> +                                        SPANSION_DUMMY_CLK_POS,
> +                                        SPANSION_DUMMY_CLK_LEN
> +                                        );
> +            break;
>          default:
>              break;
>          }
> @@ -771,15 +785,36 @@ static void decode_new_cmd(Flash *s, uint32_t value)
> 
>      case DIOR:
>      case DIOR4:
> +        s->needed_bytes = get_addr_length(s);
> +        /* Dummy cycles modeled with bytes writes instead of bits */
>          switch (get_man(s)) {
>          case MAN_WINBOND:
> +            s->needed_bytes += 4;
> +            break;
>          case MAN_SPANSION:
> -            s->needed_bytes = 4;
> +            s->needed_bytes += extract32(s->spansion_cr2v,
> +                                        SPANSION_DUMMY_CLK_POS,
> +                                        SPANSION_DUMMY_CLK_LEN
> +                                        );
>              break;
> -        default:
> -            s->needed_bytes = get_addr_length(s);
> -            /* Dummy cycles modeled with bytes writes instead of bits */
> +        case MAN_NUMONYX:
>              s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
> +            break;
> +        case MAN_MACRONIX:
> +            switch (extract32(s->volatile_cfg, 6, 2)) {
> +            case 1:
> +                s->needed_bytes += 6;
> +                break;
> +            case 2:
> +                s->needed_bytes += 8;
> +                break;
> +            default:
> +                s->needed_bytes += 4;
> +                break;
> +            }
> +            break;
> +        default:
> +            break;
>          }
>          s->pos = 0;
>          s->len = 0;
> @@ -788,15 +823,36 @@ static void decode_new_cmd(Flash *s, uint32_t value)
> 
>      case QIOR:
>      case QIOR4:
> +        s->needed_bytes = get_addr_length(s);
> +        /* Dummy cycles modeled with bytes writes instead of bits */
>          switch (get_man(s)) {
>          case MAN_WINBOND:
> +            s->needed_bytes += 4;
> +            break;
>          case MAN_SPANSION:
> -            s->needed_bytes = 6;
> +            s->needed_bytes += extract32(s->spansion_cr2v,
> +                                        SPANSION_DUMMY_CLK_POS,
> +                                        SPANSION_DUMMY_CLK_LEN
> +                                        );
>              break;
> -        default:
> -            s->needed_bytes = get_addr_length(s);
> -            /* Dummy cycles modeled with bytes writes instead of bits */
> +        case MAN_NUMONYX:
>              s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
> +            break;
> +        case MAN_MACRONIX:
> +            switch (extract32(s->volatile_cfg, 6, 2)) {
> +            case 1:
> +                s->needed_bytes += 4;
> +                break;
> +            case 2:
> +                s->needed_bytes += 8;
> +                break;
> +            default:
> +                s->needed_bytes += 6;
> +                break;
> +            }
> +            break;
> +        default:
> +            break;
>          }
>          s->pos = 0;
>          s->len = 0;
>
marcin.krzeminski@nokia.com June 16, 2016, 7:53 a.m. UTC | #2
> -----Original Message-----
> From: Cédric Le Goater [mailto:clg@kaod.org]
> Sent: Thursday, June 16, 2016 9:20 AM
> To: Krzeminski, Marcin (Nokia - PL/Wroclaw)
> <marcin.krzeminski@nokia.com>; qemu-devel@nongnu.org
> Cc: crosthwaitepeter@gmail.com; pawel.lenkow@itlen.com;
> peter.maydell@linaro.org
> Subject: Re: [PATCH 8/9] m25p80: Fast read commands family changes.
> 
> On 06/15/2016 03:41 PM, marcin.krzeminski@nokia.com wrote:
> > From: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> >
> > Add support for Spansion and Macronix flashes.
> > Additionally Numonyx(Micron) move from default in fast read commands
> > family.
> 
> maybe we could start adding sub routines to decode some of the larger
> commands, to ease reading. DIOR and QIOR are good candidates.
> 
> C.
Agree. I will put it in V2.

Thanks,
Marcin
> 
> > Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> > ---
> >  hw/block/m25p80.c | 72
> > ++++++++++++++++++++++++++++++++++++++++++++++++-------
> >  1 file changed, 64 insertions(+), 8 deletions(-)
> >
> > diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index
> > 21998db..7bc0e03 100644
> > --- a/hw/block/m25p80.c
> > +++ b/hw/block/m25p80.c
> > @@ -758,9 +758,23 @@ static void decode_new_cmd(Flash *s, uint32_t
> value)
> >      case QOR4:
> >          s->needed_bytes = get_addr_length(s);
> >          switch (get_man(s)) {
> > +        /* Dummy cycles - modeled with bytes writes instead of bits
> > + */
> >          case MAN_NUMONYX:
> >              s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
> >              break;
> > +        case MAN_MACRONIX:
> > +            if (extract32(s->volatile_cfg, 6, 2) == 1) {
> > +                s->needed_bytes += 6;
> > +            } else {
> > +                s->needed_bytes += 8;
> > +            }
> > +            break;
> > +        case MAN_SPANSION:
> > +            s->needed_bytes += extract32(s->spansion_cr2v,
> > +                                        SPANSION_DUMMY_CLK_POS,
> > +                                        SPANSION_DUMMY_CLK_LEN
> > +                                        );
> > +            break;
> >          default:
> >              break;
> >          }
> > @@ -771,15 +785,36 @@ static void decode_new_cmd(Flash *s, uint32_t
> > value)
> >
> >      case DIOR:
> >      case DIOR4:
> > +        s->needed_bytes = get_addr_length(s);
> > +        /* Dummy cycles modeled with bytes writes instead of bits */
> >          switch (get_man(s)) {
> >          case MAN_WINBOND:
> > +            s->needed_bytes += 4;
> > +            break;
> >          case MAN_SPANSION:
> > -            s->needed_bytes = 4;
> > +            s->needed_bytes += extract32(s->spansion_cr2v,
> > +                                        SPANSION_DUMMY_CLK_POS,
> > +                                        SPANSION_DUMMY_CLK_LEN
> > +                                        );
> >              break;
> > -        default:
> > -            s->needed_bytes = get_addr_length(s);
> > -            /* Dummy cycles modeled with bytes writes instead of bits */
> > +        case MAN_NUMONYX:
> >              s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
> > +            break;
> > +        case MAN_MACRONIX:
> > +            switch (extract32(s->volatile_cfg, 6, 2)) {
> > +            case 1:
> > +                s->needed_bytes += 6;
> > +                break;
> > +            case 2:
> > +                s->needed_bytes += 8;
> > +                break;
> > +            default:
> > +                s->needed_bytes += 4;
> > +                break;
> > +            }
> > +            break;
> > +        default:
> > +            break;
> >          }
> >          s->pos = 0;
> >          s->len = 0;
> > @@ -788,15 +823,36 @@ static void decode_new_cmd(Flash *s, uint32_t
> > value)
> >
> >      case QIOR:
> >      case QIOR4:
> > +        s->needed_bytes = get_addr_length(s);
> > +        /* Dummy cycles modeled with bytes writes instead of bits */
> >          switch (get_man(s)) {
> >          case MAN_WINBOND:
> > +            s->needed_bytes += 4;
> > +            break;
> >          case MAN_SPANSION:
> > -            s->needed_bytes = 6;
> > +            s->needed_bytes += extract32(s->spansion_cr2v,
> > +                                        SPANSION_DUMMY_CLK_POS,
> > +                                        SPANSION_DUMMY_CLK_LEN
> > +                                        );
> >              break;
> > -        default:
> > -            s->needed_bytes = get_addr_length(s);
> > -            /* Dummy cycles modeled with bytes writes instead of bits */
> > +        case MAN_NUMONYX:
> >              s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
> > +            break;
> > +        case MAN_MACRONIX:
> > +            switch (extract32(s->volatile_cfg, 6, 2)) {
> > +            case 1:
> > +                s->needed_bytes += 4;
> > +                break;
> > +            case 2:
> > +                s->needed_bytes += 8;
> > +                break;
> > +            default:
> > +                s->needed_bytes += 6;
> > +                break;
> > +            }
> > +            break;
> > +        default:
> > +            break;
> >          }
> >          s->pos = 0;
> >          s->len = 0;
> >
diff mbox

Patch

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 21998db..7bc0e03 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -758,9 +758,23 @@  static void decode_new_cmd(Flash *s, uint32_t value)
     case QOR4:
         s->needed_bytes = get_addr_length(s);
         switch (get_man(s)) {
+        /* Dummy cycles - modeled with bytes writes instead of bits */
         case MAN_NUMONYX:
             s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
             break;
+        case MAN_MACRONIX:
+            if (extract32(s->volatile_cfg, 6, 2) == 1) {
+                s->needed_bytes += 6;
+            } else {
+                s->needed_bytes += 8;
+            }
+            break;
+        case MAN_SPANSION:
+            s->needed_bytes += extract32(s->spansion_cr2v,
+                                        SPANSION_DUMMY_CLK_POS,
+                                        SPANSION_DUMMY_CLK_LEN
+                                        );
+            break;
         default:
             break;
         }
@@ -771,15 +785,36 @@  static void decode_new_cmd(Flash *s, uint32_t value)
 
     case DIOR:
     case DIOR4:
+        s->needed_bytes = get_addr_length(s);
+        /* Dummy cycles modeled with bytes writes instead of bits */
         switch (get_man(s)) {
         case MAN_WINBOND:
+            s->needed_bytes += 4;
+            break;
         case MAN_SPANSION:
-            s->needed_bytes = 4;
+            s->needed_bytes += extract32(s->spansion_cr2v,
+                                        SPANSION_DUMMY_CLK_POS,
+                                        SPANSION_DUMMY_CLK_LEN
+                                        );
             break;
-        default:
-            s->needed_bytes = get_addr_length(s);
-            /* Dummy cycles modeled with bytes writes instead of bits */
+        case MAN_NUMONYX:
             s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
+            break;
+        case MAN_MACRONIX:
+            switch (extract32(s->volatile_cfg, 6, 2)) {
+            case 1:
+                s->needed_bytes += 6;
+                break;
+            case 2:
+                s->needed_bytes += 8;
+                break;
+            default:
+                s->needed_bytes += 4;
+                break;
+            }
+            break;
+        default:
+            break;
         }
         s->pos = 0;
         s->len = 0;
@@ -788,15 +823,36 @@  static void decode_new_cmd(Flash *s, uint32_t value)
 
     case QIOR:
     case QIOR4:
+        s->needed_bytes = get_addr_length(s);
+        /* Dummy cycles modeled with bytes writes instead of bits */
         switch (get_man(s)) {
         case MAN_WINBOND:
+            s->needed_bytes += 4;
+            break;
         case MAN_SPANSION:
-            s->needed_bytes = 6;
+            s->needed_bytes += extract32(s->spansion_cr2v,
+                                        SPANSION_DUMMY_CLK_POS,
+                                        SPANSION_DUMMY_CLK_LEN
+                                        );
             break;
-        default:
-            s->needed_bytes = get_addr_length(s);
-            /* Dummy cycles modeled with bytes writes instead of bits */
+        case MAN_NUMONYX:
             s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
+            break;
+        case MAN_MACRONIX:
+            switch (extract32(s->volatile_cfg, 6, 2)) {
+            case 1:
+                s->needed_bytes += 4;
+                break;
+            case 2:
+                s->needed_bytes += 8;
+                break;
+            default:
+                s->needed_bytes += 6;
+                break;
+            }
+            break;
+        default:
+            break;
         }
         s->pos = 0;
         s->len = 0;