From: "Cédric Le Goater" <clg@kaod.org>
To: marcin.krzeminski@nokia.com, qemu-devel@nongnu.org
Cc: crosthwaitepeter@gmail.com, pawel.lenkow@itlen.com,
peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH 6/9] m25p80: Introduce quad and equad modes.
Date: Wed, 15 Jun 2016 16:25:40 +0200 [thread overview]
Message-ID: <57616564.1070404@kaod.org> (raw)
In-Reply-To: <1465998071-7355-7-git-send-email-marcin.krzeminski@nokia.com>
On 06/15/2016 03:41 PM, marcin.krzeminski@nokia.com wrote:
> From: Marcin Krzeminski <marcin.krzeminski@nokia.com>
>
> Quad and Equad modes for Spansion and Macronix flash devices.
> This commit also includes modification and new command to manipulate
> quad mode (status registers and dedicated commands).
> This work is based on Pawel Lenkow work.
>
> Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> ---
> hw/block/m25p80.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 65 insertions(+), 5 deletions(-)
>
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 55b4377..d1c4d46 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -281,6 +281,7 @@ typedef enum {
> JEDEC_READ = 0x9f,
> BULK_ERASE = 0xc7,
> READ_FSR = 0x70,
> + RDCR = 0x15,
>
> READ = 0x03,
> READ4 = 0x13,
> @@ -317,6 +318,13 @@ typedef enum {
> RESET_ENABLE = 0x66,
> RESET_MEMORY = 0x99,
>
> + /*
> + * Micron: 0x35 - enable QPI
> + * Spansion: 0x35 - read control register
> + */
> + RDCR_EQIO = 0x35,
> + RSTQIO = 0xf5,
> +
> RNVCR = 0xB5,
> WNVCR = 0xB1,
>
> @@ -366,6 +374,7 @@ typedef struct Flash {
> bool write_enable;
> bool four_bytes_address_mode;
> bool reset_enable;
> + bool quad_enable;
> uint8_t ear;
>
> int64_t dirty_page;
> @@ -586,6 +595,16 @@ static void complete_collecting_data(Flash *s)
> flash_erase(s, s->cur_addr, s->cmd_in_progress);
> break;
> case WRSR:
> + switch (get_man(s)) {
> + case MAN_SPANSION:
> + s->quad_enable = !!(s->data[1] & 0x02);
> + break;
> + case MAN_MACRONIX:
> + s->quad_enable = extract32(s->data[0], 6, 1);
> + break;
> + default:
> + break;
> + }
> if (s->write_enable) {
> s->write_enable = false;
> }
> @@ -619,6 +638,7 @@ static void reset_memory(Flash *s)
> s->state = STATE_IDLE;
> s->write_enable = false;
> s->reset_enable = false;
> + s->quad_enable = false;
>
> switch (get_man(s)) {
> case MAN_NUMONYX:
> @@ -747,10 +767,20 @@ static void decode_new_cmd(Flash *s, uint32_t value)
>
> case WRSR:
> if (s->write_enable) {
> - s->needed_bytes = 1;
> + switch (get_man(s)) {
> + case MAN_SPANSION:
> + s->needed_bytes = 2;
> + s->state = STATE_COLLECTING_DATA;
> + break;
> + case MAN_MACRONIX:
> + s->needed_bytes = 2;
> + s->state = STATE_COLLECTING_VAR_LEN_DATA;
> + break;
ah. I am glad you address this topic because I am having a little issue
with the mx25l25635e and the mx25l25635f.
mx25l25635e is a macronix which supports the WRSR command with one byte
and the mx25l25635f needs two. The fun part is that they have the same
JEDEC : 0xc22019.
So not all macronix need 2 bytes. Should we add a flag for that ?
> + default:
> + s->needed_bytes = 1;
> + s->state = STATE_COLLECTING_DATA;
> + }
> s->pos = 0;
> - s->len = 0;
> - s->state = STATE_COLLECTING_DATA;
> }
> break;
>
> @@ -763,6 +793,9 @@ static void decode_new_cmd(Flash *s, uint32_t value)
>
> case RDSR:
> s->data[0] = (!!s->write_enable) << 1;
> + if (get_man(s) == MAN_MACRONIX) {
> + s->data[0] |= (!!s->quad_enable) << 6;
> + }
> s->pos = 0;
> s->len = 1;
> s->state = STATE_READING_DATA;
> @@ -789,6 +822,14 @@ static void decode_new_cmd(Flash *s, uint32_t value)
> s->state = STATE_READING_DATA;
> break;
>
> + case RDCR:
> + s->data[0] = s->volatile_cfg & 0xFF;
> + s->data[0] |= (!!s->four_bytes_address_mode) << 5;
> + s->pos = 0;
> + s->len = 1;
> + s->state = STATE_READING_DATA;
> + break;
> +
> case BULK_ERASE:
> if (s->write_enable) {
> DB_PRINT_L(0, "chip erase\n");
> @@ -828,7 +869,7 @@ static void decode_new_cmd(Flash *s, uint32_t value)
> s->state = STATE_READING_DATA;
> break;
> case WNVCR:
> - if (s->write_enable) {
> + if (s->write_enable && get_man(s) == MAN_NUMONYX) {
> s->needed_bytes = 2;
> s->pos = 0;
> s->len = 0;
> @@ -871,6 +912,24 @@ static void decode_new_cmd(Flash *s, uint32_t value)
> reset_memory(s);
> }
> break;
> + case RDCR_EQIO:
> + switch (get_man(s)) {
> + case MAN_SPANSION:
> + s->data[0] = (!!s->quad_enable) << 1;
> + s->pos = 0;
> + s->len = 1;
> + s->state = STATE_READING_DATA;
> + break;
> + case MAN_MACRONIX:
> + s->quad_enable = true;
> + break;
> + default:
> + break;
> + }
> + break;
> + case RSTQIO:
> + s->quad_enable = false;
> + break;
> default:
> qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value);
> break;
> @@ -999,7 +1058,7 @@ static Property m25p80_properties[] = {
>
> static const VMStateDescription vmstate_m25p80 = {
> .name = "xilinx_spi",
> - .version_id = 2,
> + .version_id = 3,
> .minimum_version_id = 1,
> .pre_save = m25p80_pre_save,
> .fields = (VMStateField[]) {
> @@ -1017,6 +1076,7 @@ static const VMStateDescription vmstate_m25p80 = {
> VMSTATE_UINT32_V(nonvolatile_cfg, Flash, 2),
> VMSTATE_UINT32_V(volatile_cfg, Flash, 2),
> VMSTATE_UINT32_V(enh_volatile_cfg, Flash, 2),
> + VMSTATE_BOOL_V(quad_enable, Flash, 3),
> VMSTATE_END_OF_LIST()
> }
> };
>
next prev parent reply other threads:[~2016-06-15 14:25 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 13:41 [Qemu-devel] [PATCH 0/9] m25p80: Add new 512Mbit and 1Gbit devices marcin.krzeminski
2016-06-15 13:41 ` [Qemu-devel] [PATCH 1/9] m25p80: Replace JEDEC ID masking with function marcin.krzeminski
2016-06-15 14:05 ` Cédric Le Goater
2016-06-15 17:09 ` [Qemu-devel] Odp.: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-06-15 13:41 ` [Qemu-devel] [PATCH 2/9] m25p80: Make a table for JEDEC ID marcin.krzeminski
2016-06-15 14:17 ` Cédric Le Goater
2016-06-15 13:41 ` [Qemu-devel] [PATCH 3/9] m25p80: Allow more than four banks marcin.krzeminski
2016-06-16 7:09 ` Cédric Le Goater
2016-06-15 13:41 ` [Qemu-devel] [PATCH 4/9] m25p80: Introduce COLLECTING_VAR_LEN_DATA state marcin.krzeminski
2016-06-16 7:13 ` Cédric Le Goater
2016-06-16 7:43 ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-06-16 8:13 ` Cédric Le Goater
2016-06-15 13:41 ` [Qemu-devel] [PATCH 5/9] m25p80: Add additional flash commands: marcin.krzeminski
2016-06-16 7:14 ` Cédric Le Goater
2016-06-15 13:41 ` [Qemu-devel] [PATCH 6/9] m25p80: Introduce quad and equad modes marcin.krzeminski
2016-06-15 14:25 ` Cédric Le Goater [this message]
2016-06-15 17:40 ` [Qemu-devel] Odp.: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-06-17 12:43 ` Cédric Le Goater
2016-06-15 13:41 ` [Qemu-devel] [PATCH 7/9] m25p80: Introduce configuration registers marcin.krzeminski
2016-06-16 7:24 ` Cédric Le Goater
2016-06-16 7:52 ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-06-16 8:05 ` Cédric Le Goater
2016-06-17 10:31 ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-06-15 13:41 ` [Qemu-devel] [PATCH 8/9] m25p80: Fast read commands family changes marcin.krzeminski
2016-06-16 7:19 ` Cédric Le Goater
2016-06-16 7:53 ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-06-15 13:41 ` [Qemu-devel] [PATCH 9/9] m25p80: New flash devices marcin.krzeminski
2016-06-16 7:20 ` Cédric Le Goater
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=57616564.1070404@kaod.org \
--to=clg@kaod.org \
--cc=crosthwaitepeter@gmail.com \
--cc=marcin.krzeminski@nokia.com \
--cc=pawel.lenkow@itlen.com \
--cc=peter.maydell@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.