From patchwork Fri Jun 24 08:07:07 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: 9196935 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 109A660871 for ; Fri, 24 Jun 2016 08:22:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F164F28499 for ; Fri, 24 Jun 2016 08:22:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E348C2849C; Fri, 24 Jun 2016 08:22:40 +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 499D328499 for ; Fri, 24 Jun 2016 08:22:40 +0000 (UTC) Received: from localhost ([::1]:41821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGMNr-0005Sq-CI for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Jun 2016 04:22:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGMAY-0007jw-LZ for qemu-devel@nongnu.org; Fri, 24 Jun 2016 04:09:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGMAG-00087I-H7 for qemu-devel@nongnu.org; Fri, 24 Jun 2016 04:08:54 -0400 Received: from mail-db5eur01on0097.outbound.protection.outlook.com ([104.47.2.97]:51456 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGMAG-00086I-0a for qemu-devel@nongnu.org; Fri, 24 Jun 2016 04:08:36 -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=a5T2IbxnQP2EKiu8E2mUASuwhxWVHvO/N7zj+6DBsQc=; b=qQglgB9D+Q3GJr2iNuLD1ZIN04jsatLiiNMWriyQAnmDlMGj+qnkC9Iyk4QaC25CTKKMG/+BkzhpR1PF7GxDbbTOZD96TBPhZhY6St1SJoAAMcQ9ztbcqlczaMSWm+FQmP3lZ12+JHVGD527qVfI4J7Wu7LMKhoXr/zAMnnNqyQ= Received: from VI1PR07CA0125.eurprd07.prod.outlook.com (10.165.229.179) by VI1PR0701MB2126.eurprd07.prod.outlook.com (10.169.137.7) with Microsoft SMTP Server (TLS) id 15.1.523.12; Fri, 24 Jun 2016 08:08:34 +0000 Received: from DB3FFO11FD052.protection.gbl (2a01:111:f400:7e04::137) by VI1PR07CA0125.outlook.office365.com (2a01:111:e400:7a52::51) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Fri, 24 Jun 2016 08:08:33 +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=fihe3nok0735.emea.nsn-net.net; Received: from fihe3nok0735.emea.nsn-net.net (131.228.2.241) by DB3FFO11FD052.mail.protection.outlook.com (10.47.217.83) with Microsoft SMTP Server (TLS) id 15.1.517.7 via Frontend Transport; Fri, 24 Jun 2016 08:08:33 +0000 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u5O8800M008613 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Jun 2016 11:08:00 +0300 Received: from CNU418C7XK.nsn-intra.net ([10.154.155.220]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u5O87u77008453; Fri, 24 Jun 2016 11:08:00 +0300 X-HPESVCS-Source-Ip: 10.154.155.220 From: To: Date: Fri, 24 Jun 2016 10:07:07 +0200 Message-ID: <1466755631-25201-7-git-send-email-marcin.krzeminski@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466755631-25201-1-git-send-email-marcin.krzeminski@nokia.com> References: <1466755631-25201-1-git-send-email-marcin.krzeminski@nokia.com> MIME-Version: 1.0 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)(77096005)(2870700001)(47776003)(76176999)(6806005)(92566002)(87936001)(50986999)(33646002)(11100500001)(19580405001)(19580395003)(2950100001)(189998001)(36756003)(23676002)(229853001)(2876002)(68736007)(8936002)(356003)(50226002)(86362001)(81166006)(8676002)(81156014)(86152002)(50466002)(2351001)(2906002)(305945005)(7846002)(53416004)(97736004)(16796002)(5820100001)(106466001)(586003)(4326007)(110136002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0701MB2126; H:fihe3nok0735.emea.nsn-net.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD052; 1:1VaPIcnTV4wPg0Umjtw0LgO3pMAEKcoaVkunLlsSNUekg7qW5kFe6SjK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4A8iMlpz5MEtWEvXpD/Qh5NFuUwcda5ypoO+oKxAikCf4MlHboE3S1A4RQgEsmDX8Wk4SmGpKhyElVg5kkV8641zmv/FZbsvgzoJUqdHzJM8qE98bVadBMortvoJvwy/1H1EzX8XPbdVwj1HvyCwgU32xRA4rV0czbaheRkQkY0k0ae1n+wpPZkm/qSa8C2EUZfLq4gswsjRyDpBkcWb1Csus2w2EN8SM0IQtwjymUDfqmzSx6qa9nLlg/oorBFDXXbaxLetVTcWEdczk9cpqVDobbkWLZ9w071ORSprx+44NYwXqDGl2Se9IL0ScUubvqTS8= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR0701MB2126; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0701MB2126; 20:3iliYeNVaUss9XXf+x+XWS/Fm+wJ9dnmmXhdhC5NNODedq9y1iTx2bk3/cDS8kOXRMtSuRYr1pNrt5uRrLNG6s6TWSYkOvgqYyJz4PbhbnvJsth52EPP6xWWPeZAt4rNq7ttpkhgHObNlIdV/EZX+zq4cZ2VXGIg7wDNIL7Qw/0CbC1SVmUhe9siawVy34nHUYwq3Sj2OmCR5nsaD4asI0gSP31BTrYWQE1GXnr6lP3A/nO7IG+HyJy+h7kG6y2w7QZw9+7AP+S5K6M1dhDeaaXuYUkTXENQYKuaboexjBkcOp9NQ6LDoA9tcA6uuBlFBkevEeAIzEv317QBr6TmmG1xG1syS+CoCJ/EK72dsHc5yap7TgivermQmBZ88io4qxRWHJGaT0QIRgFtScR4QhKfOFWprfnfWFHmiGvbDHiJrmpCGTI7Nf/G6kUkXmh5qaVMiJeGOixxKI73KgKObweSPWxkyqYmBjDqfMAqgdw/oTlPC3rrWV/qBNuMlu458msnOcrdOljM+ZViHk6c0+0RGZ11uOEBu4NKh+3/zWzU0XCaXDrqoUppatG48731pIQbeEKPvqT+WW9eEeUpgPuu0JqsXcPJI9Tn9gSyoQ4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13016025)(8121501046)(5005006)(10201501046)(3002001); SRVR:VI1PR0701MB2126; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0701MB2126; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0701MB2126; 4:DKveg82YzwBycwAhuDVFHWh7YGXoIw4U3l0RM68qq85aLRETMNjhGkIEiOFPNzI8wzSc2jRCGWBJCb0/6roHh0NgRuFJUyqZ+rmwYUTRSMkRfU/89qZE4KPDLG/gCG8afK4ePn32AiVS9CLw8BetML4p9R2NrGxYXDrffiIfacg3mz3ar1GeAM4Ogq3rO+vegEKdhqXmG5Yx60Ghv8qytgBYNaA8WFPOaKh2KTo3gCCRPs4GeWYcrP5+M7QYg1KS4hgX1SAtm85hG26Wh8ZhxoLZdrJ9IYgfUPX591/diVQvPCCqvjXsngu2YNoj5sQTX91ERXCMD96AB9rpb2Qw8gL1J70wY3aMJ73I+4in01ASvcdUB6JxsYocuRnByKnhJLI0vRR0+AcCB50/+LtLlN4RE2IMhKVjFwlcZkghNVtc+Yp215qMkqmkJeZJv+Ln X-Forefront-PRVS: 0983EAD6B2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0701MB2126; 23:AFWpd1foJ1ONnMhHWkZRAkcS8TwPkUKG934BEfq?= =?us-ascii?Q?+QHuQCu0bRXDmCBqSnnAT2ldgcya+ljmuJyPK4FBbCYi37tsUfdUYSXlmcMF?= =?us-ascii?Q?7ie6r0NkWrH884yzyX7YAyRG+6krhSOWr1ghpBNdeGa6s0XnRyW15sFVBBIP?= =?us-ascii?Q?I84P2A52KG3w6bwfusDnKn8G3JgR8tkuuPuRdne2QIIZdTmnAp3r1A/4eUN9?= =?us-ascii?Q?K30eng7o7ChTPzk7zVO6VI5ZGFtozh7K5ALaX3pDjsxjnXUXT1mAcW8jMlfC?= =?us-ascii?Q?PsMFMBlZDLWE9rZ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agnostics: 1; VI1PR0701MB2126; 6:M7KQqePF2bKRGrogu2dBuTiiWBCaU0mcGywSCFFd87SeXyah1bKGU2ByxME3wrn5EEpdkveppQpqEOMYVqFrUFYkoQJK8o/Ak9wO9sPSZgjXCpzZFB9D6WgOjiD3rTQhvoGRAGeD2KtOsZZt3/IfU2zI8/XPCEOSdWkiQA3vBQ6BR+9iq65MxMD01mLZb6onDcwObzwhFCSXXMKT2y0qFvrt33zpmRLMJuylmQKXtUMawkcnJMiOA7k4QKuGsJbjE+Zpa4RDmXpxtGHchr8XIXaS9R8IP2HxpIXiaYP7xdr6oG60BOmXVRtzePJ1sSui; 5:MSxuEUCGSCg4z+y9HMCiG1tq3Yz2s0Eltrd4YDkTZiMMRREnN+wElKScD1v3S87fZD7WjSn7hfFKvvDnmP7Si7qTPhVHM2y4mNbP3ez3S8yL8Tex6cR01dIR1IX4+IzRDaU8DNKQbwJWFabEMI3f1g==; 24:EPTbknoyJutEqC9MaxrJekhQXh/OBxlv8AjRgBCe2pdqxue110W8ggS69K/Dht95W+N6LP0+uFiAlKrFIfUV2rvT1aE4QGDPY3jtZ61GcT4=; 7:woK3TIlDeQ79GBxIMjHeG6yVkDBNfym6rMAwXHfyb9sQQVoFEZ6ld5aWaxzN+eqpWBKc4LWaSwPE8Sg5vCF+hj1di4XN9ef+FPp+uwWTsfq6+mR5M1nZH2GelUt//TfQ6CpXcNfYjfVy1WTueQvR/PyTT6cBLmwJQUiO9V9sYNZVi6w3wPTRz66NI+p1xyn3GBRtgCqcbBF/yJJDRUtGOJPJwK6BP5IZa6Xwp9QPmDl6hluB/QIkHT7FKMOVpUHbOj1e/eTrJ/LAr/F66Lgbkg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2016 08:08:33.3154 (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=[fihe3nok0735.emea.nsn-net.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0701MB2126 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.97 Subject: [Qemu-devel] [PATCH v3 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() } };