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 02/12] Added reset-pin emulation in model.
Date: Wed, 16 Dec 2015 13:57:05 +0100 [thread overview]
Message-ID: <1450270635-27080-3-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: Marcin Krzeminski <marcin.krzeminski@nokia.com>
---
hw/block/m25p80.c | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index bfd493f..bcb66a5 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -258,6 +258,8 @@ typedef struct Flash {
uint8_t cmd_in_progress;
uint64_t cur_addr;
bool write_enable;
+ bool initialized;
+ uint8_t reset_pin;
int64_t dirty_page;
@@ -430,6 +432,19 @@ static void complete_collecting_data(Flash *s)
}
}
+static void reset_memory(Flash *s)
+{
+ s->cmd_in_progress = NOP;
+ s->cur_addr = 0;
+ s->len = 0;
+ s->needed_bytes = 0;
+ s->pos = 0;
+ s->state = STATE_IDLE;
+ s->write_enable = false;
+
+ DB_PRINT_L(0, "Reset done.\n");
+}
+
static void decode_new_cmd(Flash *s, uint32_t value)
{
s->cmd_in_progress = value;
@@ -620,6 +635,8 @@ static int m25p80_init(SSISlave *ss)
s->size = s->pi->sector_size * s->pi->n_sectors;
s->dirty_page = -1;
+ s->initialized = false;
+
/* FIXME use a qdev drive property instead of drive_get_next() */
dinfo = drive_get_next(IF_MTD);
@@ -650,9 +667,24 @@ static void m25p80_pre_save(void *opaque)
flash_sync_dirty((Flash *)opaque, -1);
}
+static void m25p80_reset(DeviceState *d)
+{
+ Flash *s = M25P80(d);
+
+ if (s->reset_pin || !s->initialized) {
+ reset_memory(s);
+ s->initialized = true;
+ }
+}
+
+static Property m25p80_properties[] = {
+ DEFINE_PROP_UINT8("reset-pin", Flash, reset_pin, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static const VMStateDescription vmstate_m25p80 = {
.name = "xilinx_spi",
- .version_id = 1,
+ .version_id = 2,
.minimum_version_id = 1,
.pre_save = m25p80_pre_save,
.fields = (VMStateField[]) {
@@ -664,6 +696,8 @@ static const VMStateDescription vmstate_m25p80 = {
VMSTATE_UINT8(cmd_in_progress, Flash),
VMSTATE_UINT64(cur_addr, Flash),
VMSTATE_BOOL(write_enable, Flash),
+ VMSTATE_BOOL(initialized, Flash),
+ VMSTATE_UINT8(reset_pin, Flash),
VMSTATE_END_OF_LIST()
}
};
@@ -679,6 +713,8 @@ static void m25p80_class_init(ObjectClass *klass, void *data)
k->set_cs = m25p80_cs;
k->cs_polarity = SSI_CS_LOW;
dc->vmsd = &vmstate_m25p80;
+ dc->reset = &m25p80_reset;
+ dc->props = m25p80_properties;
mc->pi = data;
}
--
2.5.0
next prev 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 ` marcin.krzeminski [this message]
2015-12-21 11:04 ` [Qemu-devel] [PATCH 02/12] Added reset-pin emulation in model 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 ` [Qemu-devel] [PATCH 10/12] Support for quad commands marcin.krzeminski
2015-12-21 11:52 ` 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-3-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).