From patchwork Fri Jun 17 10:28:25 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: 9183465 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 BBCE66075F for ; Fri, 17 Jun 2016 10:56:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB1582838B for ; Fri, 17 Jun 2016 10:56:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FE9C28399; Fri, 17 Jun 2016 10:56:45 +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 004072838B for ; Fri, 17 Jun 2016 10:56:44 +0000 (UTC) Received: from localhost ([::1]:55699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDrS7-0006Fs-UN for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Jun 2016 06:56:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDrKS-00078k-4x for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDrKO-0006kv-WC for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:48:48 -0400 Received: from mail-db3on0101.outbound.protection.outlook.com ([157.55.234.101]:52486 helo=emea01-db3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDrKO-0006kW-J3 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:48:44 -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=JCwZU1evl7rp6XrdpXRyh/6cotZTsnR4BpzZtp+BGw9nAYajenFkmBm/hgKmiY/LgyTlhlPseoDPUO4JVa+fo52UiRvp9Rn68/CnPXX1u59ohrM6ODs4n2g39vNBhIpWjUhHa+ADelLeiGYbaWQj5Do49bm1zFb7ISs+b8VRYX8= Received: from VI1PR07CA0068.eurprd07.prod.outlook.com (10.164.94.164) by DB5PR07MB1064.eurprd07.prod.outlook.com (10.163.103.142) with Microsoft SMTP Server (TLS) id 15.1.517.8; Fri, 17 Jun 2016 10:32:16 +0000 Received: from AM1FFO11FD051.protection.gbl (2a01:111:f400:7e00::113) by VI1PR07CA0068.outlook.office365.com (2a01:111:e400:5967::36) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Fri, 17 Jun 2016 10:32:16 +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:16 +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 u5HATECK000553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 Jun 2016 13:29:14 +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 u5HATC31000470; Fri, 17 Jun 2016 13:29:13 +0300 X-HPESVCS-Source-Ip: 10.154.155.220 From: To: Date: Fri, 17 Jun 2016 12:28:25 +0200 Message-ID: <1466159314-28597-2-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)(189002)(199003)(50986999)(8676002)(81166006)(81156014)(106466001)(2906002)(4326007)(2351001)(8936002)(19580405001)(47776003)(229853001)(50466002)(48376002)(97736004)(19580395003)(2876002)(76176999)(87936001)(356003)(189998001)(11100500001)(110136002)(50226002)(53416004)(86362001)(86152002)(5003940100001)(5008740100001)(68736007)(36756003)(6806005)(586003)(16796002)(2950100001)(92566002)(77096005)(33646002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5PR07MB1064; 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; AM1FFO11FD051; 1:s4vnS89+gJuNlxitQpp2UosvBbBAbPnxUvLxLXrb5RtcnKcp1yllDGocSmQiTNz900nJUgeK4QsHo00Z2JApI9yGO9eelyW3GBsPk8HGK/+R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QsyCDQagKzPbZUouc5BRG2W1LRnDHSAtxwh9uI3aBpTmYoX3Rur4UAhTTgVCwv9tbm2OTLeXu/7NJgEaAqqTxL+p6IgknI3tYcylTnFg+QqS/M7lzsozMeDsHt3+pCAC4w9ABci4VjrEn+tafQR2oOGJZ+id89zWMshdgzbGlkPLIhaamSLY1pOl8SU2JK/9JlKvSvu6+5DtMw0gn5BqSQ52aDyFNrEGhS5yf+V/0nQc35ieBcjFbc4CheZaBFFangHZUdfRMaA9DPpJOmyZ4ZoKmupIKA8k= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:DB5PR07MB1064; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1064; 20:YLK+1yVjPOS58CoyvRD5xZ5YVg6fxWt2GmCnyfIjKY8H2oMbdH8GR1tYarfMFo1lL2mBjkToYc8uxJaKj0XdbfJARmT5e6kBG4Sdlma4imVjYY/bOf/zrT2014wq/kRZoqllMoYGoT+AJ8zGTDiIHGOe+YmahjO3YO20qe+AYnNFDUH0tKyR4d33aczgfTETVD1OZTIFLloPHPUsYX5vZ5GEsrDdH/n5RJmI91EZdmda2s3QryMkdQW8y1437Vy8pwt4Xi+r0/uGSwx4Nmu9qE3z8B0VpwVfOYd7816C58GALQV0wvUzFypeHlMMt9KEFKuDk9Seiq8fh+0Nl0BEOLZTpUEdHsIwqnfV23Te0aYUK6wj83vXpn+AmGssLfSnDqiFXkGXDCIOElIV6cwpKGUY5pYJcQnW+QPqCmOnD1SvBsG5wu9f8iJYqpZwrI9LHlvrQzUBtahuqoD/dyO5FFb57cJGnNSPmXGp6xinqoIhtnUPnPq/9nyLrXzJsT840y9qkqPURLhKInZaXKxF047N2+QDne/I7E41iJIGQkmBEoc4h/CaNlsERqZ45TEHsuMssqeCA9/Ry69bprrOj1xWicxJ85mkQB//9MUxX/U= 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)(5005006)(8121501046)(13018025)(13016025)(10201501046)(3002001); SRVR:DB5PR07MB1064; BCL:0; PCL:0; RULEID:; SRVR:DB5PR07MB1064; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1064; 4:4qny3GUk50imRAqtWZMCrLiOO/FoVfVaJa+xgvkyF/OnNgOKt/hRhO6mmC4VGqJ1MW9TW+FcG8mZ9lTUWn0b8BQJ6cvaS+RCGHKNNLrjz2A1brtvketUojgqDeAlcltnH8g43pr02l4SqzoParwMUbd5U9+AQRDhOQe1RaqMQfK5Z6DNLdnUMXAYiD5CxzMPJmeopXhxfNFFKW5utcOEI4rE4lKOFA1S679oI1PQ0DXlzQxrrzCdG0uDTvA186Z0dQVqT8VPX8mUS2bCHGWaoAM33GNsxDU/+au+TGWCR8StqpcxMrys+H9PfgwKKHvHLAxsPbNXJ+4snzyG3vzahm/lghbVALDXK3YojRax1qJe8J+4/x6/YzKe7Yj0vG+ALf+HuywJk7JfYxa2Re/axpPGZulZkh81D3ca7SGtmCVRdsQySoKzJv6OrcimGvVJegnhq6yjoX4EkDkdFTLHviBfcVwVS8VXHRWIjGBnhfjKMRxRXDRNi1OfwaqJJsC5 X-Forefront-PRVS: 09760A0505 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR07MB1064; 23:m+hVbzA5FhRau/7sOIjjcdEOy2+GOMx3dI94mekSi?= =?us-ascii?Q?sIs7jlRJyydzBVqObvpxIdMzEf3UhgvznPs8pQQlqL3ZNCQ59LuGDRIxoJDi?= =?us-ascii?Q?VVpeb9g2zfBOr+iy03Os3zq00yxhVtCSYDSS/L2lRwFVEMwBquDMIHEhGlzU?= =?us-ascii?Q?JR8E+9GXwmIrl6CHedSwVqwvWKje7n9l04E+qvKkezx4+APJfJzbtasORLk1?= =?us-ascii?Q?NoObATqgip96pOpuiFfms0G4qa/nReuwdZqyR82xEpc4Hd6WVD1WwF+azNNf?= =?us-ascii?Q?01jmYuztsb23ba1HFA3Po5YFfkU3XOrzBPeUfUWyyWlpORzlqoywbVc43W5F?= =?us-ascii?Q?be/Um45OE/skq8/01vsqrcocDLmODRupDiYddr3biXlvZs36OOj13fZEkCOe?= =?us-ascii?Q?W3mXw0iKlMzhTTlmxvAdLK10eJgdvLuJrGGC60xy4EqYsjgsx0NuiAGS8DRz?= =?us-ascii?Q?QNCrz/XVxFL1NzJXpvvLEDDKYzgCkiFkNx128x3merHc0JoiLUCySS6Dhg3x?= =?us-ascii?Q?7KfMQQyCLvZS6j0AJB/h5MVBw3JaAzLhXkl3zjKh0Eh7sPK6EZcycoL2U8oR?= =?us-ascii?Q?nAMwfIcyhy+n9Rwsmka32zooC+FIu9etNZlLfO48SwDxEqZtu9u0jOTI62lu?= =?us-ascii?Q?3c0LZhTv8f2F46if8XP2UkkhyOsUM8jgjwnPcANzRy7fEvRBksPym0vCML8y?= =?us-ascii?Q?wTgQ4wjCFpEaLi3hYxSf3QtGqp5FD8UnKFEoH8rhAXnZWKmZp48qeOwTAJ2W?= =?us-ascii?Q?xtqK4UlDFH2KPKjikrt276JKC8o54zck8/g+5j96qe7wMY8dduUYXjFEdAc7?= =?us-ascii?Q?se/iTky/qW3Geto2OlxCgmfiZ6D0KiZPdNxKZnq3tJFoSO+KKul1CPwx5TRA?= =?us-ascii?Q?qCQf2zENiNNVQZPNo9GFcWGK4tLDx87AjHAtQcA0TUB3yNeGx7ffrXocuqP7?= =?us-ascii?Q?rx6gAVYNS4aver6Ak/ORE5f94jZHjD2jpX4hyLtdIiXpJ/+Cga5/CzErk8AL?= =?us-ascii?Q?wy5p5ElzBcGflzMPJW6rPSWHCiYBDglySHNgweJlpOem4vmiAZ23dw/jrFPA?= =?us-ascii?Q?3sohUBhWccU4U71i88WGiW5z+kmVkLf7rI2/7MaZkFnPYGWq+kV9jY9nR2j8?= =?us-ascii?Q?OgrQ86V+Go=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1064; 6:jNCUM75J8MpzfYF0E+EOYgAQlSKIyY/8sCuzKQ0AveW2lYWc/1Mv3s5tMRMGoTPYmzgsK+5EIFUDxlc6AFFE8/NQi8hQZD+809Gn61VrV/HVRx4hCrdsMFq4N4YmbDcBL+w6Zua4mPVesiNZs+64seYfdv4jwcfdrbh4tJDan7CbQashJGKAMAXXV5/jYn/bzozntSUrzPzlI5kDK732MYjm3oSV8xCbq1sfVpMeCHSAORUmmlnINfjuZVDrQZLAR30ixtGgmuWTpm7sUjziQYCqKEuwgdixZMnrvBrRUyE=; 5:ZgdQlDNNnc2plN6QfyWOLMQUCR84gz9XEWEEbMz7O6ukLaqVXD4ekwWohWzZhjiFBftsV6noMebzApRBxnS9hurWOiw2JSZWWvEQMlgBEvSJaTBYqF8gr+1CJ9qWUmEw33IvjTWU0FbEAkkjphgPyg==; 24:mJBUUqMHU2oqwSk4WwIhtLVcxQUiRNcLZNNzVOLspqmuF5ymXtkhPLOGaDPCTtkYGeyX7zRw6nXcuZBjJSePwNqkn9rpJUXCpliRbGFnrEM=; 7:xePizyP0F0ecdvN87SGLfhUN/95ezJKp96lDnVfPO40P55Lv286QsYUk1zwXTt6XM+mHRealCIwKzuyPFWP9/VwFf388vjUsQWKBZM7KY5Baeb2IzyELT2ux+irE+nTD/uFlwLOQLv2Nu94RmReFN/e14A6JOUH8sszmVUSnYCY+CAvHl5m8DnwrhLiEPDwER+ORHE7DZWGU5OkBWsq9TA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 10:32:16.1650 (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: DB5PR07MB1064 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 157.55.234.101 Subject: [Qemu-devel] [PATCH v2 01/10] 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, 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 Instead of always reading and comparing jededc ID, replace it by function. Signed-off-by: Marcin Krzeminski Reviewed-by: Cédric Le Goater --- 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: