From patchwork Fri Oct 19 08:29:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 192583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB75E2C0091 for ; Fri, 19 Oct 2012 19:30:00 +1100 (EST) Received: from localhost ([::1]:48446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP7xu-0007ij-Ov for incoming@patchwork.ozlabs.org; Fri, 19 Oct 2012 04:29:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP7xe-0007MZ-BX for qemu-devel@nongnu.org; Fri, 19 Oct 2012 04:29:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TP7xd-0000np-8n for qemu-devel@nongnu.org; Fri, 19 Oct 2012 04:29:42 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:56673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP7xd-0000nl-31 for qemu-devel@nongnu.org; Fri, 19 Oct 2012 04:29:41 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so201161pad.4 for ; Fri, 19 Oct 2012 01:29:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-gm-message-state; bh=slJLY+8omoLnzlCu2NEuZgWVP9q+nLs/EjBvAnNI/n4=; b=RdIgOqnPXOt/dC0oZna+43piega3fuuhsVqwk+I9vZuPyybKWN4Qf3pUhNdnpS15w8 sNzOGjh/+/3yWTV7cMZsY0G1kD9UekjN3YDitkfrMpY7BuhiLE5qgyRKlZkLEn+AMLh3 trpN0PkjDZYDXMUZsalBbdTa0ozQJKcMdjLJEYtXXOBCD7Ikyj7MHFeWvTMYxJFUm+du wKG/L0mfscTOiLZIrsbrjU7S3OQi428DwyX7rY4ZIIXmqaa34xr694ZW1YM0N6mRpTLz Uh+Y1hho7AW3DalyKw3sN3Xr1/JboiiFE1Axld6A2YXYfR5JrBwF7pV6eB8JfZZH78N4 pSPw== Received: by 10.68.230.66 with SMTP id sw2mr3201971pbc.119.1350635380191; Fri, 19 Oct 2012 01:29:40 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id nr5sm902777pbc.20.2012.10.19.01.29.36 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 01:29:39 -0700 (PDT) From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Fri, 19 Oct 2012 18:29:27 +1000 Message-Id: <241ec18f9a1e976e1c132e6164cbe50870376c9f.1350634549.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQnNDjjf3gTqDHLcdq0gEzlkY9wdLMPEZhIlI4kRfF1NZdggiuOxQ366uoFIGtBw45B0d11l X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.220.45 Cc: vineshp@xilinx.com, edgar.iglesias@gmail.com, Peter Crosthwaite , john.williams@xilinx.com, peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH v1 1/3] m25p80: Support for Quad SPI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Added the Quad mode read and write commands. Data remains serialized on a single wire, i.e. the quad mode instructions just behave the same as single mode, with the expection of modelling the varying number of dummy/mode bytes between the address bytes and the first data word. Signed-off-by: Peter Crosthwaite --- hw/m25p80.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 57 insertions(+), 4 deletions(-) diff --git a/hw/m25p80.c b/hw/m25p80.c index 9a56de8..3895e73 100644 --- a/hw/m25p80.c +++ b/hw/m25p80.c @@ -72,6 +72,10 @@ typedef struct FlashPartInfo { .page_size = 256,\ .flags = (_flags),\ +#define JEDEC_NUMONYX 0x20 +#define JEDEC_WINBOND 0xEF +#define JEDEC_SPANSION 0x01 + static const FlashPartInfo known_devices[] = { /* Atmel -- some are (confusingly) marketed as "DataFlash" */ { INFO("at25fs010", 0x1f6601, 0, 32 << 10, 4, ER_4K) }, @@ -180,17 +184,26 @@ static const FlashPartInfo known_devices[] = { typedef enum { NOP = 0, - PP = 0x2, - READ = 0x3, WRDI = 0x4, RDSR = 0x5, WREN = 0x6, + JEDEC_READ = 0x9f, + BULK_ERASE = 0xc7, + + READ = 0x3, FAST_READ = 0xb, + DOR = 0x3b, + QOR = 0x6b, + DIOR = 0xbb, + QIOR = 0xeb, + + PP = 0x2, + DPP = 0xa2, + QPP = 0x32, + ERASE_4K = 0x20, ERASE_32K = 0x52, ERASE_SECTOR = 0xd8, - JEDEC_READ = 0x9f, - BULK_ERASE = 0xc7, } FlashCMD; typedef enum { @@ -346,11 +359,17 @@ static void complete_collecting_data(Flash *s) s->cur_addr |= s->data[2]; switch (s->cmd_in_progress) { + case DPP: + case QPP: case PP: s->state = STATE_PAGE_PROGRAM; break; case READ: case FAST_READ: + case DOR: + case QOR: + case DIOR: + case QIOR: s->state = STATE_READ; break; case ERASE_4K: @@ -374,6 +393,8 @@ static void decode_new_cmd(Flash *s, uint32_t value) case ERASE_32K: case ERASE_SECTOR: case READ: + case DPP: + case QPP: case PP: s->needed_bytes = 3; s->pos = 0; @@ -382,12 +403,44 @@ static void decode_new_cmd(Flash *s, uint32_t value) break; case FAST_READ: + case DOR: + case QOR: s->needed_bytes = 4; s->pos = 0; s->len = 0; s->state = STATE_COLLECTING_DATA; break; + case DIOR: + switch ((s->pi->jedec >> 16) & 0xFF) { + case JEDEC_WINBOND: + case JEDEC_SPANSION: + s->needed_bytes = 4; + break; + case JEDEC_NUMONYX: + default: + s->needed_bytes = 5; + } + s->pos = 0; + s->len = 0; + s->state = STATE_COLLECTING_DATA; + break; + + case QIOR: + switch ((s->pi->jedec >> 16) & 0xFF) { + case JEDEC_WINBOND: + case JEDEC_SPANSION: + s->needed_bytes = 6; + break; + case JEDEC_NUMONYX: + default: + s->needed_bytes = 8; + } + s->pos = 0; + s->len = 0; + s->state = STATE_COLLECTING_DATA; + break; + case WRDI: s->write_enable = false; break;