Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3554487ybk; Tue, 19 May 2020 07:29:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc+yB+hBy/1QCm+EfR5R1XW1u4CPK5JbWtZWlUl1gw+GU100RGRkBzRy9cMcyOSCvQ+FZA X-Received: by 2002:aa7:cc84:: with SMTP id p4mr17687275edt.157.1589898587655; Tue, 19 May 2020 07:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589898587; cv=none; d=google.com; s=arc-20160816; b=wB27FLA8Q0byJUgsYnqnU7hQGEn3Bo6NxWJhAISSe1bh9hNLKDb0ei+UA/Eowb96Np /oTWz8nkmUEhjb6Vd7auLCM84SGO7Ccq73vEPdn2z6OU9RfZfkXNVdboYObUdw6bDCaC h1m1UxO0yB8t+aWp6DZQdr8dZQ0SVsi/hVhtCETI3zS9CFatDNVYUQfJfMv47pxQZD3E PWRmJlNXI//qlVNslU8lNTMQGTvjR4YMsF3dMfDqlMjzQR9/VcESStZ6m0Irb5tTR6iO pjiOsCkuJb4S7nZs5NDNsjPJTbb0GxgEHqE6OI30OVJGE9cZJb9OjxQpd98K6i0qSdqK bXDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oMN/iHiwQjDWS2EDa3kGydbVWyIjwSamwfacAnOEz7U=; b=IED9YviaOCXpxnbfKOXabLN4qtqu627C6aISDNDsTVtxb9lJkcbKIJCjeWmuIlq2EO AgHkzDmy2aPvFIe5gfNC9ImyulOLf4abc4JsvEMK5XNrNopAUFhmgr65djjzCFRBUIzt Wi/4tHqQqUFTuPfEC6ZvM9GTLAO46jjo017buqh1RaluC3KQev54tb3bVqM/CQGahJ8M bQymu5HOACNuAOuAsMTi0iGSeZd+OlpH/zVftY6QOCOrgv1o5UnD5nxrel3UyF6XueY5 /CzHgt01A2wPa5o3Ibl6uMiAZeX+tzCgU01TR726OnbzzHCvePN/gbbNuFheOMkejpqE MHSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="D/BnVV3a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si9789379edn.261.2020.05.19.07.29.23; Tue, 19 May 2020 07:29:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="D/BnVV3a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729187AbgESO1m (ORCPT + 99 others); Tue, 19 May 2020 10:27:42 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:43586 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729164AbgESO1h (ORCPT ); Tue, 19 May 2020 10:27:37 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 04JERNMl005289; Tue, 19 May 2020 09:27:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1589898443; bh=oMN/iHiwQjDWS2EDa3kGydbVWyIjwSamwfacAnOEz7U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=D/BnVV3aDW+YneYcsvIdC7k2RmUvDoo6rAR2Wg1nrBnTG1kfmuIYJIxff/pR6lrt3 yO57XvTaW6YmIkX66Ucbnp918pzuDNMTnKG2KLXjKux8iqwg7rig5yqCphvBu+fIpN nZ04vZwSaXk9kvfzRM6Aek4jD6eqEPzYC9ZfqIYo= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 04JERNhv039557; Tue, 19 May 2020 09:27:23 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 19 May 2020 09:27:23 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Tue, 19 May 2020 09:27:23 -0500 Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 04JEQgjP008313; Tue, 19 May 2020 09:27:18 -0500 From: Pratyush Yadav To: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mark Brown , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Matthias Brugger , , , , , CC: Pratyush Yadav , Sekhar Nori , Boris Brezillon , Mason Yang Subject: [PATCH v5 07/19] mtd: spi-nor: sfdp: prepare BFPT parsing for JESD216 rev D Date: Tue, 19 May 2020 19:56:29 +0530 Message-ID: <20200519142642.24131-8-p.yadav@ti.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200519142642.24131-1-p.yadav@ti.com> References: <20200519142642.24131-1-p.yadav@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org JESD216 rev D makes BFPT 20 DWORDs. Update the BFPT size define to reflect that. The check for rev A or later compared the BFPT header length with the maximum BFPT length, BFPT_DWORD_MAX. Since BFPT_DWORD_MAX was 16, and so was the BFPT length for both rev A and B, this check worked fine. But now, since BFPT_DWORD_MAX is 20, it means this check will also stop BFPT parsing for rev A or B, since their length is 16. So, instead check for BFPT_DWORD_MAX_JESD216 to stop BFPT parsing for the first JESD216 version, and check for BFPT_DWORD_MAX_JESD216B for the next two versions. Signed-off-by: Pratyush Yadav --- drivers/mtd/spi-nor/sfdp.c | 7 ++++++- drivers/mtd/spi-nor/sfdp.h | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index 5cecc4ba2141..96960f2f3d7a 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -549,7 +549,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, SNOR_ERASE_TYPE_MASK; /* Stop here if not JESD216 rev A or later. */ - if (bfpt_header->length < BFPT_DWORD_MAX) + if (bfpt_header->length == BFPT_DWORD_MAX_JESD216) return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params); @@ -605,6 +605,11 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, return -EINVAL; } + /* Stop here if JESD216 rev B. */ + if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B) + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, + params); + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params); } diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h index e0a8ded04890..f8198af43a63 100644 --- a/drivers/mtd/spi-nor/sfdp.h +++ b/drivers/mtd/spi-nor/sfdp.h @@ -10,11 +10,11 @@ /* Basic Flash Parameter Table */ /* - * JESD216 rev B defines a Basic Flash Parameter Table of 16 DWORDs. + * JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs. * They are indexed from 1 but C arrays are indexed from 0. */ #define BFPT_DWORD(i) ((i) - 1) -#define BFPT_DWORD_MAX 16 +#define BFPT_DWORD_MAX 20 struct sfdp_bfpt { u32 dwords[BFPT_DWORD_MAX]; @@ -22,6 +22,7 @@ struct sfdp_bfpt { /* The first version of JESD216 defined only 9 DWORDs. */ #define BFPT_DWORD_MAX_JESD216 9 +#define BFPT_DWORD_MAX_JESD216B 16 /* 1st DWORD. */ #define BFPT_DWORD1_FAST_READ_1_1_2 BIT(16) -- 2.26.2