qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: marcin.krzeminski@nokia.com
To: qemu-devel@nongnu.org
Cc: pawel.lenkow@nokia.com, peter.crosthwaite@xilinx.com,
	marcin.krzeminski@nokia.com
Subject: [Qemu-devel] [PATCH 10/12] Support for quad commands.
Date: Wed, 16 Dec 2015 13:57:13 +0100	[thread overview]
Message-ID: <1450270635-27080-11-git-send-email-marcin.krzeminski@nokia.com> (raw)
In-Reply-To: <1450270635-27080-1-git-send-email-marcin.krzeminski@nokia.com>

From: Marcin Krzeminski <marcin.krzeminski@nokia.com>

Signed-off-by: Pawel Lenkow <pawel.lenkow@nokia.com>
---
 hw/block/m25p80.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 6fc55a3..25ec666 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -255,19 +255,24 @@ typedef enum {
     BULK_ERASE = 0xc7,
 
     READ = 0x3,
+    READ4 = 0x13,
     FAST_READ = 0xb,
     DOR = 0x3b,
     QOR = 0x6b,
     DIOR = 0xbb,
     QIOR = 0xeb,
+    QIOR4 = 0xec,
 
     PP = 0x2,
+    PP4 = 0x12,
     DPP = 0xa2,
     QPP = 0x32,
 
     ERASE_4K = 0x20,
+    ERASE4_4K = 0x21,
     ERASE_32K = 0x52,
     ERASE_SECTOR = 0xd8,
+    ERASE4_SECTOR = 0xdc,
 
     EN_4BYTE_ADDR = 0xB7,
     EX_4BYTE_ADDR = 0xE9,
@@ -307,6 +312,7 @@ typedef struct Flash {
     bool write_enable;
     bool four_bytes_address_mode;
     bool reset_enable;
+    bool quad_enable;
     bool initialized;
     uint8_t reset_pin;
     uint8_t ear;
@@ -381,6 +387,7 @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd)
 
     switch (cmd) {
     case ERASE_4K:
+    case ERASE4_4K:
         len = 4 << 10;
         capa_to_assert = ER_4K;
         break;
@@ -389,6 +396,7 @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd)
         capa_to_assert = ER_32K;
         break;
     case ERASE_SECTOR:
+    case ERASE4_SECTOR:
         len = s->pi->sector_size;
         break;
     case BULK_ERASE:
@@ -447,6 +455,14 @@ void flash_write8(Flash *s, uint64_t addr, uint8_t data)
 
 static inline int is_4bytes(Flash *s)
 {
+   switch (s->cmd_in_progress) {
+   case PP4:
+   case READ4:
+   case QIOR4:
+   case ERASE4_4K:
+   case ERASE4_SECTOR:
+       return 1;
+   default:
        return s->four_bytes_address_mode;
    }
 }
@@ -472,19 +488,24 @@ static void complete_collecting_data(Flash *s)
     case DPP:
     case QPP:
     case PP:
+    case PP4:
         s->state = STATE_PAGE_PROGRAM;
         break;
     case READ:
+    case READ4:
     case FAST_READ:
     case DOR:
     case QOR:
     case DIOR:
     case QIOR:
+    case QIOR4:
         s->state = STATE_READ;
         break;
     case ERASE_4K:
+    case ERASE4_4K:
     case ERASE_32K:
     case ERASE_SECTOR:
+    case ERASE4_SECTOR:
         flash_erase(s, s->cur_addr, s->cmd_in_progress);
         break;
     case WRSR:
@@ -512,6 +533,7 @@ static void reset_memory(Flash *s)
     s->state = STATE_IDLE;
     s->write_enable = false;
     s->reset_enable = false;
+    s->quad_enable = false;
 
     DB_PRINT_L(0, "Reset done.\n");
 }
@@ -519,18 +541,23 @@ static void reset_memory(Flash *s)
 static void decode_new_cmd(Flash *s, uint32_t value)
 {
     s->cmd_in_progress = value;
+    int i;
     DB_PRINT_L(0, "decoded new command:%x\n", value);
 
     switch (value) {
 
     case ERASE_4K:
+    case ERASE4_4K:
     case ERASE_32K:
     case ERASE_SECTOR:
+    case ERASE4_SECTOR:
     case READ:
+    case READ4:
     case DPP:
     case QPP:
     case PP:
-        s->needed_bytes = 3;
+    case PP4:
+        s->needed_bytes = is_4bytes(s) ? 4 : 3;
         s->pos = 0;
         s->len = 0;
         s->state = STATE_COLLECTING_DATA;
@@ -574,7 +601,13 @@ static void decode_new_cmd(Flash *s, uint32_t value)
         s->len = 0;
         s->state = STATE_COLLECTING_DATA;
         break;
-
+    case QIOR4:
+        /* 4 address + 1 dummy */
+        s->needed_bytes = 5;
+        s->pos = 0;
+        s->len = 0;
+        s->state = STATE_COLLECTING_DATA;
+        break;
     case WRSR:
         if (s->write_enable) {
             s->needed_bytes = 1;
@@ -792,6 +825,7 @@ static const VMStateDescription vmstate_m25p80 = {
         VMSTATE_BOOL(four_bytes_address_mode, Flash),
         VMSTATE_UINT8(ear, Flash),
         VMSTATE_BOOL(reset_enable, Flash),
+        VMSTATE_BOOL(quad_enable, Flash),
         VMSTATE_BOOL(initialized, Flash),
         VMSTATE_UINT8(reset_pin, Flash),
         VMSTATE_END_OF_LIST()
-- 
2.5.0

  parent reply	other threads:[~2015-12-16 12:57 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-16 12:57 [Qemu-devel] [PATCH 00/12] Support for new flash devices/4bytes commands marcin.krzeminski
2015-12-16 12:57 ` [Qemu-devel] [PATCH 01/12] Removed unused variable marcin.krzeminski
2015-12-21 10:20   ` Peter Crosthwaite
2015-12-16 12:57 ` [Qemu-devel] [PATCH 02/12] Added reset-pin emulation in model marcin.krzeminski
2015-12-21 11:04   ` Peter Crosthwaite
2015-12-21 13:39     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-02-01 18:29       ` [Qemu-devel] " Peter Crosthwaite
2016-02-02  7:15         ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 03/12] Reset enable and reset memory commands support marcin.krzeminski
2015-12-21 11:18   ` Peter Crosthwaite
2015-12-21 13:42     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 04/12] Changed variable type to allow serial eeprom emulation (changing 0->1) marcin.krzeminski
2015-12-21 11:23   ` Peter Crosthwaite
2015-12-21 13:46     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 05/12] Added support for serial eeproms - AT25128A/AT25256A marcin.krzeminski
2015-12-21 11:28   ` Peter Crosthwaite
2015-12-21 13:49     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 06/12] 4byte address mode support added marcin.krzeminski
2015-12-21 11:35   ` Peter Crosthwaite
     [not found]     ` <CA0E6F9BA6AED7458C23277BD87075E51017D30D@DEMUMBX005.nsn-intra.net>
2015-12-21 13:53       ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-22 18:41   ` [Qemu-devel] " Cédric Le Goater
2015-12-22 21:28     ` Peter Crosthwaite
2016-02-04 11:58       ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 07/12] Added support for extend address mode commands marcin.krzeminski
2015-12-21 11:41   ` Peter Crosthwaite
2015-12-21 13:56     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 08/12] Support for N25Q256A/N25Q512A marcin.krzeminski
2015-12-21 10:29   ` Peter Crosthwaite
2015-12-21 13:57     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 09/12] Support for 6Bytes jdec marcin.krzeminski
2015-12-21 10:47   ` Peter Crosthwaite
2015-12-21 14:10     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` marcin.krzeminski [this message]
2015-12-21 11:52   ` [Qemu-devel] [PATCH 10/12] Support for quad commands Peter Crosthwaite
2015-12-21 14:29     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-22 21:40   ` [Qemu-devel] " Peter Crosthwaite
2015-12-23  2:25     ` Peter Crosthwaite
2015-12-29 14:21       ` Lenkow, Pawel (Nokia - PL/Wroclaw)
2015-12-16 12:57 ` [Qemu-devel] [PATCH 11/12] Support for mx66u51235 and s25fl512s marcin.krzeminski
2015-12-16 12:57 ` [Qemu-devel] [PATCH 12/12] Read flag status register command support added marcin.krzeminski
2015-12-21 11:54   ` Peter Crosthwaite
2015-12-21 14:36     ` [Qemu-devel] ODP: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2015-12-16 13:01 ` [Qemu-devel] [PATCH 00/12] Support for new flash devices/4bytes commands Krzeminski, Marcin (Nokia - PL/Wroclaw)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450270635-27080-11-git-send-email-marcin.krzeminski@nokia.com \
    --to=marcin.krzeminski@nokia.com \
    --cc=pawel.lenkow@nokia.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).