From patchwork Wed Jun 15 13:41:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: marcin.krzeminski@nokia.com X-Patchwork-Id: 9178639 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 0BCF96075D for ; Wed, 15 Jun 2016 14:28:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F01E027D4A for ; Wed, 15 Jun 2016 14:28:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E454A27F07; Wed, 15 Jun 2016 14:28:35 +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 3E09E27D4A for ; Wed, 15 Jun 2016 14:28:35 +0000 (UTC) Received: from localhost ([::1]:42522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDBo0-0007Dg-Vk for patchwork-qemu-devel@patchwork.kernel.org; Wed, 15 Jun 2016 10:28:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDBnZ-00078v-PG for qemu-devel@nongnu.org; Wed, 15 Jun 2016 10:28:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDBnV-0005h8-IT for qemu-devel@nongnu.org; Wed, 15 Jun 2016 10:28:04 -0400 Received: from mail-db3on0134.outbound.protection.outlook.com ([157.55.234.134]:12744 helo=emea01-db3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDBnV-0005gp-3R for qemu-devel@nongnu.org; Wed, 15 Jun 2016 10:28:01 -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=M+0/HiUJeSRPq7pJjf1+FEm/g4t8Dnhhj755ESO0/S0=; b=AyL548AhMX4S96E5TM7C3GB8Iqo1ci2u0ywfyTH4I7H88UXd6ssvTxXUssrj5EZ0bNSmIkpTBR//e8FP1Jf57pGeu5VT7W7jaF3/PygA5cv5jROkycyW2r881iTGh+mIakf4GZ9r5N9/satgAn9GWnDf4Im20cPHzQHHTsK0gVs= Received: from HE1PR0701CA0020.eurprd07.prod.outlook.com (2603:10a6:3:5::30) by AM3PR07MB1060.eurprd07.prod.outlook.com (2a01:111:e400:536e::14) with Microsoft SMTP Server (TLS) id 15.1.517.8; Wed, 15 Jun 2016 13:42:49 +0000 Received: from AM1FFO11OLC005.protection.gbl (2a01:111:f400:7e00::162) by HE1PR0701CA0020.outlook.office365.com (2603:10a6:3:5::30) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Wed, 15 Jun 2016 13:42:49 +0000 Authentication-Results: spf=pass (sender IP is 131.228.2.240) 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.240 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.240; helo=mailrelay.int.nokia.com; Received: from mailrelay.int.nokia.com (131.228.2.240) by AM1FFO11OLC005.mail.protection.outlook.com (10.174.64.132) with Microsoft SMTP Server (TLS) id 15.1.511.7 via Frontend Transport; Wed, 15 Jun 2016 13:42:49 +0000 Received: from fihe3nok0734.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u5FDfmGO004072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 15 Jun 2016 16:41:48 +0300 Received: from CNU418C7XK.nsn-intra.net ([10.154.155.220]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u5FDfkX5004036; Wed, 15 Jun 2016 16:41:47 +0300 X-HPESVCS-Source-Ip: 10.154.155.220 From: To: Date: Wed, 15 Jun 2016 15:41:03 +0200 Message-ID: <1465998071-7355-2-git-send-email-marcin.krzeminski@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1465998071-7355-1-git-send-email-marcin.krzeminski@nokia.com> References: <1465998071-7355-1-git-send-email-marcin.krzeminski@nokia.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:131.228.2.240; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(81166006)(50986999)(11100500001)(81156014)(8676002)(2876002)(76176999)(2906002)(4326007)(77096005)(106466001)(87936001)(47776003)(5003940100001)(356003)(19580395003)(19580405001)(2950100001)(92566002)(53416004)(36756003)(586003)(68736007)(86362001)(5008740100001)(16796002)(8936002)(50466002)(22756006)(6806005)(229853001)(33646002)(110136002)(189998001)(50226002)(2351001)(86152002)(97736004)(48376002); DIR:OUT; SFP:1102; SCL:1; SRVR:AM3PR07MB1060; H:mailrelay.int.nokia.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11OLC005; 1:cYjkm7MIIn6BXvIg5nfkTDU7jMwo/a9N2+dK57XODeLvsoRYyoovMe2Qyomt9foy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eZJD1VmiM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35073007944872)(82608151540597)(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13016025)(13018025)(8121501046)(5005006)(3002001)(10201501046); SRVR:AM3PR07MB1060; BCL:0; PCL:0; RULEID:; SRVR:AM3PR07MB1060; X-Microsoft-Exchange-Diagnostics: 1; AM3PR07MB1060; 4:RK6SFElvqTKRcuIKFZYa7psDRw5nx+D3oB3ODPj6OGEVJay7PL+QiE+tozCvEsC9466qmWqc8z9ea1OlbPJubprZr9YUBus9XjLMkGF7d7CkG8iirlZ6CkKrVeaHiRhmksqSi0sJUC8UdmupOcgDh5gmx+5ZrKmVCBdm6vl2recA3PB6JaaSaKqQQksCb0NCSVwx8ouGQxnPCz6dJb+jq5OK5oVZ1lMhy3GSL1Z9yUChvrzjo8k5cc/h+arvk/8l3WCU7ytQRajWSqYh92SzSdRenVqXj38FGx5uf3bTEZljfsPngTnXQALFe2/bVSCs2bf1449I778GckELRGuBf9nwQHzjyqMzMnuDm1fCR66WPrZQZiSGrH3jcAOiBf3Lg9117HLDbeMBLUicxbh45TTUAgB8D51Pc9GYelZ1WRAAGZdlhEBMCDJF26D2k/aDpv3vVSs1xpzC9LP59bwMxrIy6JFqiBrLsfmMGfEVNorcZAQ5GN++bSlPIFPFBnl0 X-Forefront-PRVS: 09749A275C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM3PR07MB1060; 23:FTr5dGGlFDPBKPJqNyNginAe/ApypTKUKe2DsN47A?= =?us-ascii?Q?Y7UGX545wEyxP4G5pS2QkE0n3rZ86MRXAStAqWJ2u0imdE28QJf5OXSZBAt7?= =?us-ascii?Q?UNFnrSAC9yB2jDR2NB4dUcErN+MXYX94M3lWjWziQdL9FRWIVf2CTmJ8MnMR?= =?us-ascii?Q?ctQGa4GzyZZTl69YDM8IoxfHEMOyBjdW6VsEp6fYyTBZO1v0Mt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kIj67Lrq+FuzfA5KKSZtS2G3fdhJoLpoR5zqPt?= =?us-ascii?Q?zpEmak5i7o4sjhEJRJ8yAlikbXxbaef?= X-Microsoft-Exchange-Diagnostics: 1; AM3PR07MB1060; 6:zQ/Gu4WY7DoWtz7hZOmneMq8w3eIrKxxoxy2SPu+rjO3RvKdaZDcOticSIwKA0t9IE/w5y9CxSbuoGbOPrAueWayHFQziOprW9fShfscg8P51vv9ctqEb15DrynUT2U1Sw5IqjmA83KU2NVBoYPa6uimighrppi2wAhfyBfJYm8Y0kCoIMMpMGsI9ZhMQVisaFTddrrarbkomkzAWOdH9z7LifixfS1xOFghYVsPJhfnS/gZ5SfxtKG65Rwmtoo33n7t6UTaSOVUx8ND6pPBqw==; 5:tq6FoqwPsgGS+ywsXyD19sHmKEgWLcj7RoqiLYORtQDBiAedElN8s3LMJ0h0NVeeTqLJhBym6FGMvq05q97iP87zhpuDRf8OXw5e3tXk2YGzxnXAM9s6BrYDv1Ya03h/2SRhPhap74NRthezxV9AGg==; 24:mi/Q9cJg3jBE+DR5CwO+p/7qFACqDSx0Z3sHCV9ZXCCApYV6woKU6QEfObvWvW5VukguvXCZ7kwknbDM/Rjnq5V34GdCwWJhICG4fd3clRo=; 7:B4qOWUoEOHdvBL5MKFubJ3w24YhZcpVdP2spSaEH5bjA7rhjQTKiGFfIvySUYXtQ5T0+gDIJq8jjSH11ASeRXJ2K0TwsAWCb9pJXq874n/RMVKEnOqlwOUxnkzEQsztpit4qDFEfVOb9xIZrCVZX365t3nkd9y7vq1uP50FokMg7UkMv+JifBhsIuzfY2tQIGUjOGnOECCcUDWus53kV+g== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2016 13:42:49.2926 (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.240]; Helo=[mailrelay.int.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR07MB1060 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 157.55.234.134 Subject: [Qemu-devel] [PATCH 1/9] m25p80: Replace JEDEC ID masking with function. 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, rfsw-patches@mlist.emea.nsn-intra.net, pawel.lenkow@itlen.com 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 Instead of always reading and comparing jededc ID, replace it by function. Signed-off-by: Marcin Krzeminski --- hw/block/m25p80.c | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 4c856f5..15765f5 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -307,6 +307,14 @@ typedef enum { STATE_READING_DATA, } CMDState; +typedef enum { + MAN_SPANSION, + MAN_MACRONIX, + MAN_NUMONYX, + MAN_WINBOND, + MAN_GENERIC, +} Manufacturer; + typedef struct Flash { SSISlave parent_obj; @@ -350,6 +358,22 @@ typedef struct M25P80Class { #define M25P80_GET_CLASS(obj) \ OBJECT_GET_CLASS(M25P80Class, (obj), TYPE_M25P80) +static inline Manufacturer get_man(Flash *s) +{ + switch (((s->pi->jedec >> 16) & 0xFF)) { + case 0x20: + return MAN_NUMONYX; + case 0xEF: + return MAN_WINBOND; + case 0x01: + return MAN_SPANSION; + case 0xC2: + return MAN_MACRONIX; + default: + return MAN_GENERIC; + } +} + static void blk_sync_complete(void *opaque, int ret) { /* do nothing. Masters do not directly interact with the backing store, @@ -562,7 +586,8 @@ static void reset_memory(Flash *s) s->write_enable = false; s->reset_enable = false; - if (((s->pi->jedec >> 16) & 0xFF) == JEDEC_NUMONYX) { + switch (get_man(s)) { + case MAN_NUMONYX: s->volatile_cfg = 0; s->volatile_cfg |= VCFG_DUMMY; s->volatile_cfg |= VCFG_WRAP_SEQUENTIAL; @@ -594,6 +619,9 @@ static void reset_memory(Flash *s) if (!(s->nonvolatile_cfg & NVCFG_LOWER_SEGMENT_MASK)) { s->ear = CFG_UPPER_128MB_SEG_ENABLED; } + break; + default: + break; } DB_PRINT_L(0, "Reset done.\n"); @@ -634,9 +662,12 @@ static void decode_new_cmd(Flash *s, uint32_t value) case QOR: case QOR4: s->needed_bytes = get_addr_length(s); - if (((s->pi->jedec >> 16) & 0xFF) == JEDEC_NUMONYX) { - /* Dummy cycles modeled with bytes writes instead of bits */ + switch (get_man(s)) { + case MAN_NUMONYX: s->needed_bytes += extract32(s->volatile_cfg, 4, 4); + break; + default: + break; } s->pos = 0; s->len = 0; @@ -645,9 +676,9 @@ static void decode_new_cmd(Flash *s, uint32_t value) case DIOR: case DIOR4: - switch ((s->pi->jedec >> 16) & 0xFF) { - case JEDEC_WINBOND: - case JEDEC_SPANSION: + switch (get_man(s)) { + case MAN_WINBOND: + case MAN_SPANSION: s->needed_bytes = 4; break; default: @@ -662,9 +693,9 @@ static void decode_new_cmd(Flash *s, uint32_t value) case QIOR: case QIOR4: - switch ((s->pi->jedec >> 16) & 0xFF) { - case JEDEC_WINBOND: - case JEDEC_SPANSION: + switch (get_man(s)) { + case MAN_WINBOND: + case MAN_SPANSION: s->needed_bytes = 6; break; default: