From patchwork Fri Jun 17 10:28:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: marcin.krzeminski@nokia.com X-Patchwork-Id: 9183437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B6A260776 for ; Fri, 17 Jun 2016 10:44:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89B5728303 for ; Fri, 17 Jun 2016 10:44:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E3FA28399; Fri, 17 Jun 2016 10:44:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C4E8B28303 for ; Fri, 17 Jun 2016 10:44:16 +0000 (UTC) Received: from localhost ([::1]:55588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDrG3-000329-Ix for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Jun 2016 06:44:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDr4d-0007NS-KH for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:32:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDr4Z-00032w-Ax for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:32:27 -0400 Received: from mail-db3on0141.outbound.protection.outlook.com ([157.55.234.141]:5116 helo=emea01-db3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDr4Y-00032f-R3 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:32:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1Ebw6omvIDuK8KZPcct2EFFgo7K9W1DGvMNCZYCn7R8=; b=nsOP2uyHDJCj3zVOn5ozKtwMogJGfBLNyiZl5UlVWTEb8Faw6IsvNQ0BWccli2KmbVXuskLI8FnR4w2R2kqgMRvLAR21rSgZs9F+De0GS38e1g8ukTgzID0lSpg8Lruh4eY4KmasT6iSc40iz5V627mydAONiU7Vey27EW6+Tfc= Received: from VI1PR07CA0056.eurprd07.prod.outlook.com (10.164.94.152) by VI1PR07MB1069.eurprd07.prod.outlook.com (10.163.168.17) with Microsoft SMTP Server (TLS) id 15.1.517.8; Fri, 17 Jun 2016 10:32:20 +0000 Received: from AM1FFO11FD051.protection.gbl (2a01:111:f400:7e00::128) by VI1PR07CA0056.outlook.office365.com (2a01:111:e400:5967::24) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Fri, 17 Jun 2016 10:32:21 +0000 Authentication-Results: spf=pass (sender IP is 131.228.2.241) smtp.mailfrom=nokia.com; nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=pass action=none header.from=nokia.com; Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.241 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.241; helo=mailrelay.int.nokia.com; Received: from mailrelay.int.nokia.com (131.228.2.241) by AM1FFO11FD051.mail.protection.outlook.com (10.174.65.214) with Microsoft SMTP Server (TLS) id 15.1.511.7 via Frontend Transport; Fri, 17 Jun 2016 10:32:20 +0000 Received: from mailrelay.int.nokia.com (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u5HATHJS000650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 Jun 2016 13:29:17 +0300 Received: from CNU418C7XK.nsn-intra.net ([10.154.155.220]) by mailrelay.int.nokia.com (8.14.9/8.14.5) with ESMTP id u5HATC36000470; Fri, 17 Jun 2016 13:29:16 +0300 X-HPESVCS-Source-Ip: 10.154.155.220 From: To: Date: Fri, 17 Jun 2016 12:28:30 +0200 Message-ID: <1466159314-28597-7-git-send-email-marcin.krzeminski@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466159314-28597-1-git-send-email-marcin.krzeminski@nokia.com> References: <1466159314-28597-1-git-send-email-marcin.krzeminski@nokia.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:131.228.2.241; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(438002)(199003)(189002)(586003)(81166006)(189998001)(16796002)(8676002)(106466001)(229853001)(47776003)(86152002)(2351001)(97736004)(76176999)(50986999)(6806005)(356003)(81156014)(5008740100001)(87936001)(86362001)(33646002)(110136002)(92566002)(2906002)(53416004)(2950100001)(77096005)(36756003)(4326007)(48376002)(50466002)(68736007)(19580405001)(50226002)(2876002)(5003940100001)(19580395003)(8936002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR07MB1069; H:mailrelay.int.nokia.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD051; 1:gz2FXLMgXEI638XSQUOPppVLtdJKhCdYk3FnuYyXZstS7Id811JSioew5+RTjKxN6ikJPB4V/WAhVGpQ901aFegKe/XN4zPX6suKtImpKiPkCkItP3X2liBIcfT2tIZyNZYe+JsOW+i5Fk5T1TydekLCgHdGkK3Uvlsda6av336ihV6XQ8dm8DnuZwTY9XNUEPyCzLQA4q1neW0/WnjluEZ/6GEi+/qVA/cd8o0cHuM8bhSLbqgOVoEg3JSQQ6oEMqJSEJzBxZaPlKvXGzr770uJzDGQJPCAjq7x32YmVMkNPQ3FmDUSA94r55LISPTZc2UMzr8lGOTjJ6VLW07e5uyDJrs0llkK0eaZHmk/lwoGchBdMcUpNcOOpP964CPJv7EORpWmCzSO2ANJODnv6knR3pB8HAv/qHF+SZ0iIHv1ZcIeM1IUsWEQ5CVRN/C5 MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 599c7470-b817-47da-bae0-08d3969aa9cb X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1069; 2:G7oe6+hM3o/8Z8DNBQDJoIZHkmfOeXHnnTSevwhGQ8dfgwg5/8XWzsG4mq6WITaoxE9BQPicjNQSn5EzBXSsB5AXWe64ejzFJwGilctif3BeWsd8VGW2cLAHAX8b6nV5RX5AZp3WiglYubbNouoxDuwlvXMSy1Bfw4Lkm+CRqwirESac+aSKiePRQtM1GLis; 3:uV//aPrhm9eTDqoWkjabQOvn65vBEJPeOWokUvTzZw1n8ImGBljHSBh7e2dCWKbDNCyCjg2TE+3slu3ogaK35yN7xNGHyyZWqukMmywqVZtfJ6jo+rF66gY/uHewyuoSf7zZ8a/JYYSgLiJhYFi6kNNh6ewQpoi/IGOLJVSBjg72t3OwT2y4plOn6ScBb07igKsY9hAyj1XoiQh6HRuaQYo4NehW+Ct3grZrR1/99zr9wCpJSRtMu4dnuu1He9em8b4NF39KndscMO7ULtdoCA== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR07MB1069; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1069; 25:dotQBt7U8/6CNTOnEvFJ9NdKT5+AwU1yOCnusJ41CSNVkcVj0rVB+UU2LPm4jWfW368jNeT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RHA+X+K19H/zcbPFi+IeHenDYldnTGT1g7jhVcxFNyGD4CqilC5evWvE0KE1lIfP8IcC+gGx4Jax0AMA5wy79HYxZlR5Sdaqkp+S0dmfRSF3XK8dd9+v5+UvGmK5hm2kmc2tCh1BmgV7jJTJvYLv3Kjcw11hPsbO3X44wKlYhWtUFy/g5DCfV3D3pcS4ExJUMVp4thGK6dW8TItFwSPlZEqmRY0aF2FJ2NoZjUIr2nbr3FdBcXHkfM83D4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(13018025)(13016025)(10201501046)(3002001); SRVR:VI1PR07MB1069; BCL:0; PCL:0; RULEID:; SRVR:VI1PR07MB1069; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1069; 4:haTtmm7frjVAg0J/8AAkSoPSlvtOvtRjF5RCmXa+nliGRG5JQ+PvAVn7+7uZXvVNu+ONv5mrSef6kGemBhUKrp++lRnLcsG+yckrY79BvVWFzqhRg8wM8Y5WjS9LipzIPvhgdjV6a115AiYmBkNWYCgl827LeyAWuqsqeFanRG2cfuavMgUyId+/3Lp9cvevBxw+tKHmOiyfDGFf9ufghE3LAfkwaQtXZw7qpfyQKRGJmFlintE9E1QdqMRkYHPD94ibtq2G+V+tflmWiMpGv2Sn6U9ojA/gsmlqGjH/2S2q6IVcmDgcw56ypiTpAxO+zylWUyXUjT1kCgIvPEjunGevLOI/zba4REjhXoBLDSAR2H0jGZZw2kisMusFwjkh+gAXzbQ6tCf5JunJkZrTtobcjmec1bGAnH2tzA3TbqOF6QkmI7jMCs27lHhGmOXz X-Forefront-PRVS: 09760A0505 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR07MB1069; 23:RK71Ts+Xa6FuXuigAC/0TnjEevK06/JWoNuLSV6mE?= =?us-ascii?Q?dd822xPHMtY/Lg0+y8Acn/OwzusVqfQ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qrEbKhsVWQchMka2L1fKtR5mOgnrrko9bESQDBwfmdphGKffCFjiaS?= =?us-ascii?Q?UwAk1+1TZHl1mDJ1qABd0kSujqbO+leewzwzsezu9yUOVSDaem2EoIRhn2Mc?= =?us-ascii?Q?d5IuF/dHd/kJT/FgGtEgE0Wur0S?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1069; 6:8P09woXNFbtI/2ffRZKjLFOD4ju1bz06Cw3/zwN0v7VwuUTLPPJotyrJWmnQlkxRhcWtNzybEo4gY/yKqNWKi4lOaOkphasBpnat4lSL5aYpTp1WXX/go7XaRFfQ1FxFd7YgCzu7hVcaIB69/+5F9iaZktd+lRvIYtbjAZsRk754v/NC6iPLXFhQVihwwHS7fAws0oaBT/CHiB/b3ddD1naJHmJBmM4GWCs3W0V9LjHolHqhLsWsmttcNvxRvrslll3nuhNhrEvqpzWsPITpvEBZwk1Go1ukPJdHwVcnKvw=; 5:YLSpT8QcMDXaT5YJO6QvxuGajm7s3OmwXf1/mW/4RQ+wM0Opwj0aeGxOdjG1rfRKGsdE1nxlAuNA7JeUGYmJoBqsll7um9FggpvmZ4phagkdXk1D1s8jeeLXtYncDUwhPhOxV+KbYhg73XF9UCZGcA==; 24:7Yc0OuQj6KKUEdhSe48KCWUIg8uYJHCJocbxO01hxRzebNjz2Dc3RbKW/XuHzEgV49fNoulS9QXR2TVH/e90R8By2p/rXsepQefSoE/yy0Q=; 7:KyRYI80odqeLiLNXXSlJN/0iCAgZqgGny8jV77lXjkqsXSe9n21R7VFMW3LIqG8Uqu9F1Zz66pjTT3nrZpv94L6MSoDb3dyhjMLyJTnEmfqz0iFPE6GSWWidtVu0owzjzCbx6sl0eGDJyqcPjNoK2pXW6jxy+rQIfYOHFZOXAT8n9E97595syYaqkijjBEIwh1dZbSZ07pkwaNveIzXoRA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 10:32:20.5643 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.241]; Helo=[mailrelay.int.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB1069 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 157.55.234.141 Subject: [Qemu-devel] [PATCH v2 06/10] m25p80: Introduce quad and equad modes. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, crosthwaitepeter@gmail.com, clg@fr.ibm.com, clg@kaod.org, pawel.lenkow@itlen.com, rfsw-patches@mlist.emea.nsn-intra.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marcin Krzeminski 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 Reviewed-by: Cédric Le Goater --- 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; + 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() } };