From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 19/20] hw/block/m25p80: Check SPI mode before running some Numonyx commands
Date: Tue, 15 Dec 2020 14:12:36 +0000 [thread overview]
Message-ID: <20201215141237.17868-20-peter.maydell@linaro.org> (raw)
In-Reply-To: <20201215141237.17868-1-peter.maydell@linaro.org>
From: Joe Komlodi <joe.komlodi@xilinx.com>
Some Numonyx flash commands cannot be executed in DIO and QIO mode, such as
trying to do DPP or DOR when in QIO mode.
Signed-off-by: Joe Komlodi <komlodi@xilinx.com>
Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com>
Message-id: 1605568264-26376-4-git-send-email-komlodi@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/block/m25p80.c | 114 ++++++++++++++++++++++++++++++++++++++--------
1 file changed, 95 insertions(+), 19 deletions(-)
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 7e1d56442f3..f1d7da65c85 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -413,6 +413,12 @@ typedef enum {
MAN_GENERIC,
} Manufacturer;
+typedef enum {
+ MODE_STD = 0,
+ MODE_DIO = 1,
+ MODE_QIO = 2
+} SPIMode;
+
#define M25P80_INTERNAL_DATA_BUFFER_SZ 16
struct Flash {
@@ -820,6 +826,17 @@ static void reset_memory(Flash *s)
trace_m25p80_reset_done(s);
}
+static uint8_t numonyx_mode(Flash *s)
+{
+ if (!(s->enh_volatile_cfg & EVCFG_QUAD_IO_DISABLED)) {
+ return MODE_QIO;
+ } else if (!(s->enh_volatile_cfg & EVCFG_DUAL_IO_DISABLED)) {
+ return MODE_DIO;
+ } else {
+ return MODE_STD;
+ }
+}
+
static void decode_fast_read_cmd(Flash *s)
{
s->needed_bytes = get_addr_length(s);
@@ -950,14 +967,8 @@ static void decode_new_cmd(Flash *s, uint32_t value)
case ERASE4_32K:
case ERASE_SECTOR:
case ERASE4_SECTOR:
- case READ:
- case READ4:
- case DPP:
- case QPP:
- case QPP_4:
case PP:
case PP4:
- case PP4_4:
case DIE_ERASE:
case RDID_90:
case RDID_AB:
@@ -966,24 +977,84 @@ static void decode_new_cmd(Flash *s, uint32_t value)
s->len = 0;
s->state = STATE_COLLECTING_DATA;
break;
+ case READ:
+ case READ4:
+ if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) == MODE_STD) {
+ s->needed_bytes = get_addr_length(s);
+ s->pos = 0;
+ s->len = 0;
+ s->state = STATE_COLLECTING_DATA;
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in "
+ "DIO or QIO mode\n", s->cmd_in_progress);
+ }
+ break;
+ case DPP:
+ if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_QIO) {
+ s->needed_bytes = get_addr_length(s);
+ s->pos = 0;
+ s->len = 0;
+ s->state = STATE_COLLECTING_DATA;
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in "
+ "QIO mode\n", s->cmd_in_progress);
+ }
+ break;
+ case QPP:
+ case QPP_4:
+ case PP4_4:
+ if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_DIO) {
+ s->needed_bytes = get_addr_length(s);
+ s->pos = 0;
+ s->len = 0;
+ s->state = STATE_COLLECTING_DATA;
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in "
+ "DIO mode\n", s->cmd_in_progress);
+ }
+ break;
case FAST_READ:
case FAST_READ4:
+ decode_fast_read_cmd(s);
+ break;
case DOR:
case DOR4:
+ if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_QIO) {
+ decode_fast_read_cmd(s);
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in "
+ "QIO mode\n", s->cmd_in_progress);
+ }
+ break;
case QOR:
case QOR4:
- decode_fast_read_cmd(s);
+ if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_DIO) {
+ decode_fast_read_cmd(s);
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in "
+ "DIO mode\n", s->cmd_in_progress);
+ }
break;
case DIOR:
case DIOR4:
- decode_dio_read_cmd(s);
+ if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_QIO) {
+ decode_dio_read_cmd(s);
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in "
+ "QIO mode\n", s->cmd_in_progress);
+ }
break;
case QIOR:
case QIOR4:
- decode_qio_read_cmd(s);
+ if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_DIO) {
+ decode_qio_read_cmd(s);
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in "
+ "DIO mode\n", s->cmd_in_progress);
+ }
break;
case WRSR:
@@ -1035,17 +1106,22 @@ static void decode_new_cmd(Flash *s, uint32_t value)
break;
case JEDEC_READ:
- trace_m25p80_populated_jedec(s);
- for (i = 0; i < s->pi->id_len; i++) {
- s->data[i] = s->pi->id[i];
- }
- for (; i < SPI_NOR_MAX_ID_LEN; i++) {
- s->data[i] = 0;
- }
+ if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) == MODE_STD) {
+ trace_m25p80_populated_jedec(s);
+ for (i = 0; i < s->pi->id_len; i++) {
+ s->data[i] = s->pi->id[i];
+ }
+ for (; i < SPI_NOR_MAX_ID_LEN; i++) {
+ s->data[i] = 0;
+ }
- s->len = SPI_NOR_MAX_ID_LEN;
- s->pos = 0;
- s->state = STATE_READING_DATA;
+ s->len = SPI_NOR_MAX_ID_LEN;
+ s->pos = 0;
+ s->state = STATE_READING_DATA;
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute JEDEC read "
+ "in DIO or QIO mode\n");
+ }
break;
case RDCR:
--
2.20.1
next prev parent reply other threads:[~2020-12-15 14:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 14:12 [PULL 00/20] target-arm queue Peter Maydell
2020-12-15 14:12 ` [PULL 01/20] gdbstub: Correct misparsing of vCont C/S requests Peter Maydell
2020-12-15 14:12 ` [PULL 02/20] hw/openrisc/openrisc_sim: Use IRQ splitter when connecting IRQ to multiple CPUs Peter Maydell
2020-12-15 14:12 ` [PULL 03/20] hw/openrisc/openrisc_sim: Abstract out "get IRQ x of CPU y" Peter Maydell
2020-12-15 14:12 ` [PULL 04/20] target/openrisc: Move pic_cpu code into CPU object proper Peter Maydell
2020-12-15 14:12 ` [PULL 05/20] target/nios2: Move IIC " Peter Maydell
2020-12-15 14:12 ` [PULL 06/20] target/nios2: Move nios2_check_interrupts() into target/nios2 Peter Maydell
2020-12-15 14:12 ` [PULL 07/20] target/nios2: Use deposit32() to update ipending register Peter Maydell
2020-12-15 14:12 ` [PULL 08/20] hw/core/loader.c: Track last-seen ROM in rom_check_and_register_reset() Peter Maydell
2020-12-15 14:12 ` [PULL 09/20] hw/core/loader.c: Improve reporting of ROM overlap errors Peter Maydell
2020-12-15 14:12 ` [PULL 10/20] elf_ops.h: Don't truncate name of the ROM blobs we create Peter Maydell
2020-12-15 14:12 ` [PULL 11/20] elf_ops.h: Be more verbose with ROM blob names Peter Maydell
2020-12-15 14:12 ` [PULL 12/20] usb: Add versal-usb2-ctrl-regs module Peter Maydell
2020-12-15 14:12 ` [PULL 13/20] usb: Add DWC3 model Peter Maydell
2020-12-15 14:12 ` [PULL 14/20] usb: xlnx-usb-subsystem: Add xilinx usb subsystem Peter Maydell
2020-12-15 14:12 ` [PULL 15/20] arm: xlnx-versal: Connect usb to virt-versal Peter Maydell
2020-12-15 14:12 ` [PULL 16/20] hw/misc/zynq_slcr: Avoid #DIV/0! error Peter Maydell
2020-12-15 14:12 ` [PULL 17/20] hw/block/m25p80: Make Numonyx config field names more accurate Peter Maydell
2020-12-15 14:12 ` [PULL 18/20] hw/block/m25p80: Fix when VCFG XIP bit is set for Numonyx Peter Maydell
2020-12-15 14:12 ` Peter Maydell [this message]
2020-12-15 14:12 ` [PULL 20/20] hw/block/m25p80: Fix Numonyx fast read dummy cycle count Peter Maydell
2020-12-15 15:06 ` Bin Meng
2020-12-15 15:11 ` Peter Maydell
2020-12-15 15:42 ` Francisco Iglesias
2020-12-15 21:15 ` Peter Maydell
2020-12-15 21:16 ` [PULL 00/20] target-arm queue Peter Maydell
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=20201215141237.17868-20-peter.maydell@linaro.org \
--to=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 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).